Compare commits
3 Commits
REFLOW_200
...
Bugzilla_P
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b52a1dc48a | ||
|
|
48b5f960fd | ||
|
|
73bf11394f |
1127
mozilla/client.mk
1127
mozilla/client.mk
File diff suppressed because it is too large
Load Diff
@@ -1,63 +0,0 @@
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = content
|
||||
DIRS = base canvas html xml xul xbl xslt
|
||||
|
||||
ifdef MOZ_SVG
|
||||
DIRS += svg
|
||||
endif
|
||||
|
||||
ifdef MOZ_XTF
|
||||
DIRS += xtf
|
||||
endif
|
||||
|
||||
DIRS += events
|
||||
|
||||
ifdef ENABLE_TESTS
|
||||
TOOL_DIRS += test
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = public src
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
@@ -1,105 +0,0 @@
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = content
|
||||
XPIDL_MODULE = content_base
|
||||
GRE_MODULE = 1
|
||||
|
||||
EXPORTS = \
|
||||
mozFlushType.h \
|
||||
nsIContent.h \
|
||||
nsIAttribute.h \
|
||||
nsIContentIterator.h \
|
||||
nsContentErrors.h \
|
||||
nsContentPolicyUtils.h \
|
||||
nsContentUtils.h \
|
||||
nsIDocument.h \
|
||||
nsIDocumentObserver.h \
|
||||
nsIDOMGCParticipant.h \
|
||||
nsINameSpaceManager.h \
|
||||
nsINode.h \
|
||||
nsINodeInfo.h \
|
||||
nsIRangeUtils.h \
|
||||
nsIScriptElement.h \
|
||||
nsIStyleSheetLinkingElement.h \
|
||||
nsITextContent.h \
|
||||
nsIPrivateDOMImplementation.h \
|
||||
nsIContentSerializer.h \
|
||||
nsIHTMLToTextSink.h \
|
||||
nsIXPathEvaluatorInternal.h \
|
||||
mozISanitizingSerializer.h \
|
||||
nsCaseTreatment.h \
|
||||
nsContentCID.h \
|
||||
nsCopySupport.h \
|
||||
nsContentCreatorFunctions.h \
|
||||
nsXMLNameSpaceMap.h \
|
||||
$(NULL)
|
||||
|
||||
SDK_XPIDLSRCS = \
|
||||
nsISelection.idl \
|
||||
$(NULL)
|
||||
|
||||
XPIDLSRCS = \
|
||||
nsIChromeRegistry.idl \
|
||||
nsIContentPolicy.idl \
|
||||
nsIDocumentEncoder.idl \
|
||||
nsIDOMParser.idl \
|
||||
nsIDOMSerializer.idl \
|
||||
nsISelectionController.idl \
|
||||
nsISelectionDisplay.idl \
|
||||
nsISelectionListener.idl \
|
||||
nsISelectionPrivate.idl \
|
||||
nsIScriptLoader.idl \
|
||||
nsIScriptLoaderObserver.idl \
|
||||
nsISyncLoadDOMService.idl \
|
||||
nsIDragDropHandler.idl \
|
||||
nsIScriptEventHandler.idl \
|
||||
nsIScriptEventManager.idl \
|
||||
nsIImageLoadingContent.idl \
|
||||
nsIObjectLoadingContent.idl \
|
||||
nsIFrameLoader.idl \
|
||||
nsIXMLHttpRequest.idl \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Boris Zbarsky.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef mozFlushType_h___
|
||||
#define mozFlushType_h___
|
||||
|
||||
/**
|
||||
* This is the enum used by nsIDocument::FlushPendingNotifications to
|
||||
* decide what to flush.
|
||||
*/
|
||||
enum mozFlushType {
|
||||
Flush_Content = 0x1, /* flush the content model construction */
|
||||
Flush_SinkNotifications = 0x2, /* flush the frame model construction */
|
||||
Flush_StyleReresolves = 0x4, /* flush style reresolution */
|
||||
Flush_OnlyReflow = 0x8, /* flush reflows */
|
||||
Flush_OnlyPaint = 0x10, /* flush painting */
|
||||
Flush_ContentAndNotify = (Flush_Content | Flush_SinkNotifications),
|
||||
Flush_Frames = (Flush_Content | Flush_SinkNotifications |
|
||||
Flush_StyleReresolves),
|
||||
Flush_Style = (Flush_Content | Flush_SinkNotifications |
|
||||
Flush_StyleReresolves),
|
||||
Flush_Layout = (Flush_Content | Flush_SinkNotifications |
|
||||
Flush_StyleReresolves | Flush_OnlyReflow),
|
||||
Flush_Display = (Flush_Content | Flush_SinkNotifications |
|
||||
Flush_StyleReresolves | Flush_OnlyReflow |
|
||||
Flush_OnlyPaint)
|
||||
};
|
||||
|
||||
#endif /* mozFlushType_h___ */
|
||||
@@ -1,128 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org HTML Sanitizer code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ben Bucksch <mozilla@bucksch.org>.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Netscape
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/* Cleans up HTML source from unwanted tags/attributes
|
||||
|
||||
This class implements a content sink, which takes a parsed HTML document
|
||||
and removes all tags and attributes that are not explicitly allowed.
|
||||
|
||||
This may improve the viewing experience of the user and/or the
|
||||
security/privacy.
|
||||
|
||||
What is allowed is defined by a string (format described before the
|
||||
implementation of |mozHTMLSanitizer::ParsePrefs()|). The sytnax of the
|
||||
definition is not very rich - you can only (dis)allow certain tags and
|
||||
attributes, but not where they may appear. (This makes the implementation
|
||||
much more simple.) E.g. it is impossible to disallow ordinary text as a
|
||||
direct child of the <head> node or to disallow multiple <head> nodes.
|
||||
|
||||
We also remove some known bad attribute values like javascript: URLs.
|
||||
Draconian attitude.
|
||||
|
||||
Currently, the output of this class is unparsed (!) HTML source, which
|
||||
means that each document has to go through the parser twice. Of course,
|
||||
that is a performance killer. There are some reasons for for me doing it
|
||||
that way:
|
||||
* There is, to my knowledge, no interface to hook up such modifiers
|
||||
in the document display data flow. We have a nice interface for doing
|
||||
the modifications (the DOM), but no place to get the DOM and to invoke
|
||||
this code. As I don't want to hack this directly into the html sink,
|
||||
I'd have to create a generic interface first, which is too much work for
|
||||
me at the moment.
|
||||
* It is quite easy to hook up modifiers for the (unparsed) data stream,
|
||||
both in netwerk (for the browser) and esp. in libmime (for Mailnews).
|
||||
* It seems like the safest method - it is easier to debug (you have the
|
||||
HTML source output to check) and is less prone to security-relevant bugs
|
||||
and regressions, because in the case of a bug, it will probably fall back
|
||||
to not outputting, which is safer than erring on the side of letting
|
||||
something slip through (most of the alternative approaches listed below
|
||||
are probably vulnerable to the latter).
|
||||
* It should be possible to later change this class to output a parsed HTML
|
||||
document.
|
||||
So, in other words, I had the choice between better design and better
|
||||
performance. I choose design. Bad performance has an effect on the users
|
||||
of this class only, while bad design has an effect on all users and
|
||||
programmers.
|
||||
|
||||
That being said, I have some ideas, how do make it much more efficient, but
|
||||
they involve hacking core code.
|
||||
* At some point when we have DOM, but didn't do anything with it yet
|
||||
(in particular, didn't load any external objects or ran any javascript),
|
||||
walk the DOM and delete everything the user doesn't explicitly like.
|
||||
* There's this nice GetPref() in the HTMLContentSink. It isn't used exactly
|
||||
as I would like to, but that should be doable. Bascially, before
|
||||
processing any tag (e.g. in OpenContainer or AddLeaf), ask that
|
||||
function, if the tag is allowed. If not, just return.
|
||||
In any case, there's the problem, how the users of the renderer
|
||||
(e.g. Mailnews) can tell it to use the sanitizer and which tags are
|
||||
allowed (the browser may want to allow more tags than Mailnews).
|
||||
That probably means that I have to hack into the docshell (incl. its
|
||||
interface) or similar, which I would really like to avoid.
|
||||
Any ideas appreciated.
|
||||
*/
|
||||
#ifndef _mozISanitizingSerializer_h__
|
||||
#define _mozISanitizingSerializer_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsAString;
|
||||
|
||||
#define MOZ_SANITIZINGHTMLSERIALIZER_CONTRACTID "@mozilla.org/layout/htmlsanitizer;1"
|
||||
|
||||
/* starting interface: nsIContentSerializer */
|
||||
#define MOZ_ISANITIZINGHTMLSERIALIZER_IID_STR "feca3c34-205e-4ae5-bd1c-03c686ff012b"
|
||||
|
||||
#define MOZ_ISANITIZINGHTMLSERIALIZER_IID \
|
||||
{0xfeca3c34, 0x205e, 0x4ae5, \
|
||||
{ 0xbd, 0x1c, 0x03, 0xc6, 0x86, 0xff, 0x01, 0x2b }}
|
||||
|
||||
class mozISanitizingHTMLSerializer : public nsISupports {
|
||||
public:
|
||||
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(MOZ_ISANITIZINGHTMLSERIALIZER_IID)
|
||||
|
||||
NS_IMETHOD Initialize(nsAString* aOutString,
|
||||
PRUint32 aFlags,
|
||||
const nsAString& allowedTags) = 0;
|
||||
// This function violates string ownership rules, see impl.
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(mozISanitizingHTMLSerializer,
|
||||
MOZ_ISANITIZINGHTMLSERIALIZER_IID)
|
||||
|
||||
#endif
|
||||
@@ -1,50 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* the Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Boris Zbarsky <bzbarsky@mit.edu> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsCaseTreatment_h___
|
||||
#define nsCaseTreatment_h___
|
||||
|
||||
/**
|
||||
* This is the enum used by functions that need to be told whether to
|
||||
* do case-sensitive or case-insensitive string comparisons.
|
||||
*/
|
||||
enum nsCaseTreatment {
|
||||
eCaseMatters,
|
||||
eIgnoreCase
|
||||
};
|
||||
|
||||
#endif /* nsCaseTreatment_h___ */
|
||||
@@ -1,295 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsContentCID_h__
|
||||
#define nsContentCID_h__
|
||||
|
||||
#define NS_DOC_ENCODER_CONTRACTID_BASE \
|
||||
"@mozilla.org/layout/documentEncoder;1?type="
|
||||
|
||||
#define NS_HTMLCOPY_ENCODER_CONTRACTID \
|
||||
"@mozilla.org/layout/htmlCopyEncoder;1"
|
||||
|
||||
// {1691E1F7-EE41-11d4-9885-00C04FA0CF4B}
|
||||
#define NS_STYLESET_CID \
|
||||
{ 0x1691e1f7, 0xee41, 0x11d4, { 0x98, 0x85, 0x0, 0xc0, 0x4f, 0xa0, 0xcf, 0x4b } }
|
||||
|
||||
// {972D8D8F-F0DA-11d4-9885-00C04FA0CF4B}
|
||||
#define NS_DOCUMENT_VIEWER_CID \
|
||||
{ 0x972d8d8f, 0xf0da, 0x11d4, { 0x98, 0x85, 0x0, 0xc0, 0x4f, 0xa0, 0xcf, 0x4b } }
|
||||
|
||||
// {A5121627-EDB6-11d4-9885-00C04FA0CF4B}
|
||||
#define NS_ANONYMOUSCONTENT_CID \
|
||||
{ 0xa5121627, 0xedb6, 0x11d4, { 0x98, 0x85, 0x0, 0xc0, 0x4f, 0xa0, 0xcf, 0x4b } }
|
||||
|
||||
// {FC886801-E768-11d4-9885-00C04FA0CF4B}
|
||||
#define NS_CONTENT_DOCUMENT_LOADER_FACTORY_CID \
|
||||
{ 0xfc886801, 0xe768, 0x11d4, { 0x98, 0x85, 0x0, 0xc0, 0x4f, 0xa0, 0xcf, 0x4b } }
|
||||
|
||||
/* a6cf90f9-15b3-11d2-932e-00805f8add32 */
|
||||
#define NS_LAYOUT_DEBUGGER_CID \
|
||||
{ 0xa6cf90f9, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
#define NS_HTMLDOCUMENT_CID \
|
||||
{ /* 5d0fcdd0-4daa-11d2-b328-00805f8a3859 */ \
|
||||
0x5d0fcdd0, 0x4daa, 0x11d2, \
|
||||
{0xb3, 0x28, 0x00, 0x80, 0x5f, 0x8a, 0x38, 0x59}}
|
||||
|
||||
#define NS_WYCIWYGPROTOCOLHANDLER_CID \
|
||||
{ /* e7509b46-2eB2-410a-9d7c-c3ce73284d01 */ \
|
||||
0xe7509b46, 0x2eb2, 0x410a, \
|
||||
{0x9d, 0x7c, 0xc3, 0xce, 0x73, 0x28, 0x4d, 0x01}}
|
||||
|
||||
#define NS_XMLDOCUMENT_CID \
|
||||
{ /* a6cf9063-15b3-11d2-932e-00805f8add32 */ \
|
||||
0xa6cf9063, 0x15b3, 0x11d2, \
|
||||
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
#define NS_IMAGEDOCUMENT_CID \
|
||||
{ /* e11a6080-4daa-11d2-b328-00805f8a3859 */ \
|
||||
0xe11a6080, 0x4daa, 0x11d2, \
|
||||
{0xb3, 0x28, 0x00, 0x80, 0x5f, 0x8a, 0x38, 0x59}}
|
||||
|
||||
// {e7ba1480-1dea-11d3-830f-00104bed045e}
|
||||
#define NS_TEXT_ENCODER_CID \
|
||||
{ 0xe7ba1480, 0x1dea, 0x11d3, {0x83, 0x0f, 0x00, 0x10, 0x4b, 0xed, 0x04, 0x5e} }
|
||||
|
||||
// {7f915b01-98fc-11d4-8eb0-a803f80ff1bc}
|
||||
#define NS_HTMLCOPY_TEXT_ENCODER_CID \
|
||||
{ 0x7f915b01, 0x98fc, 0x11d4, { 0x8e, 0xb0, 0xa8, 0x03, 0xf8, 0x0f, 0xf1, 0xbc } }
|
||||
|
||||
// {A1FDE864-E802-11d4-9885-00C04FA0CF4B}
|
||||
#define NS_HTMLHRELEMENT_CID \
|
||||
{ 0xa1fde864, 0xe802, 0x11d4, { 0x98, 0x85, 0x0, 0xc0, 0x4f, 0xa0, 0xcf, 0x4b } }
|
||||
|
||||
// {A1FDE865-E802-11d4-9885-00C04FA0CF4B}
|
||||
#define NS_HTMLINPUTELEMENT_CID \
|
||||
{ 0xa1fde865, 0xe802, 0x11d4, { 0x98, 0x85, 0x0, 0xc0, 0x4f, 0xa0, 0xcf, 0x4b } }
|
||||
|
||||
#define NS_HTMLIMAGEELEMENT_CID \
|
||||
{ /* d6008c40-4dad-11d2-b328-00805f8a3859 */ \
|
||||
0xd6008c40, 0x4dad, 0x11d2, \
|
||||
{0xb3, 0x28, 0x00, 0x80, 0x5f, 0x8a, 0x38, 0x59}}
|
||||
|
||||
#define NS_HTMLOPTIONELEMENT_CID \
|
||||
{ /* a6cf90f5-15b3-11d2-932e-00805f8add32 */ \
|
||||
0xa6cf90f5, 0x15b3, 0x11d2, \
|
||||
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
#define NS_NAMESPACEMANAGER_CID \
|
||||
{ /* d9783472-8fe9-11d2-9d3c-0060088f9ff7 */ \
|
||||
0xd9783472, 0x8fe9, 0x11d2, \
|
||||
{0x9d, 0x3c, 0x00, 0x60, 0x08, 0x8f, 0x9f, 0xf7}}
|
||||
|
||||
/* a6cf90d7-15b3-11d2-932e-00805f8add32 */
|
||||
#define NS_FRAME_UTIL_CID \
|
||||
{ 0xa6cf90d5, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
|
||||
// XXX This should really be factored into a style-specific DLL so
|
||||
// that all the HTML, generic layout, and style stuff isn't munged
|
||||
// together.
|
||||
|
||||
// {2E363D60-872E-11d2-B531-000000000000}
|
||||
#define NS_CSSPARSER_CID \
|
||||
{ 0x2e363d60, 0x872e, 0x11d2, { 0xb5, 0x31, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
|
||||
|
||||
// {95F46161-D177-11d2-BF86-00105A1B0627}
|
||||
#define NS_HTML_CSS_STYLESHEET_CID \
|
||||
{ 0x95f46161, 0xd177, 0x11d2, { 0xbf, 0x86, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } }
|
||||
|
||||
// {A1FDE867-E802-11d4-9885-00C04FA0CF4B}
|
||||
#define NS_CSS_STYLESHEET_CID \
|
||||
{ 0xa1fde867, 0xe802, 0x11d4, { 0x98, 0x85, 0x0, 0xc0, 0x4f, 0xa0, 0xcf, 0x4b } }
|
||||
|
||||
// {eaca2576-0d4a-11d3-9d7e-0060088f9ff7}
|
||||
#define NS_CSS_LOADER_CID \
|
||||
{ 0xeaca2576, 0x0d4a, 0x11d3, { 0x9d, 0x7e, 0x00, 0x60, 0x08, 0x8f, 0x9f, 0xf7 } }
|
||||
|
||||
// {96882B72-8A27-11d2-8EAF-00805F29F370}
|
||||
#define NS_SELECTION_CID \
|
||||
{ 0x96882b72, 0x8a27, 0x11d2, { 0x8e, 0xaf, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
#define NS_FRAMESELECTION_CID \
|
||||
{/* {905F80F1-8A7B-11d2-918C-0080C8E44DB5}*/ \
|
||||
0x905f80f1, 0x8a7b, 0x11d2, { 0x91, 0x8c, 0x0, 0x80, 0xc8, 0xe4, 0x4d, 0xb5 } }
|
||||
|
||||
#define NS_DOMSELECTION_CID \
|
||||
{/* {C87A37FC-8109-4ce2-A322-8CDEC925379F}*/ \
|
||||
0xc87a37fc, 0x8109, 0x4ce2, { 0xa3, 0x22, 0x8c, 0xde, 0xc9, 0x25, 0x37, 0x9f } }
|
||||
|
||||
#define NS_RANGE_CID \
|
||||
{/* {56AD2981-8A87-11d2-918C-0080C8E44DB5}*/ \
|
||||
0x56ad2981, 0x8a87, 0x11d2, { 0x91, 0x8c, 0x0, 0x80, 0xc8, 0xe4, 0x4d, 0xb5 } }
|
||||
#define NS_CONTENTITERATOR_CID \
|
||||
{/* {a6cf90e3-15b3-11d2-932e-00805f8add32}*/ \
|
||||
0xa6cf90e3, 0x15b3, 0x11d2, {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
|
||||
|
||||
#define NS_PRECONTENTITERATOR_CID \
|
||||
{/* {80D7E247-D4B8-45d7-BB59-6F1DD56F384C} */ \
|
||||
0x80d7e247, 0xd4b8, 0x45d7, { 0xbb, 0x59, 0x6f, 0x1d, 0xd5, 0x6f, 0x38, 0x4c } }
|
||||
|
||||
#define NS_GENERATEDSUBTREEITERATOR_CID \
|
||||
{/* {9A45253B-EB8F-49f1-B925-E9EA90D3EB3A}*/ \
|
||||
0x9a45253b, 0xeb8f, 0x49f1, { 0xb9, 0x25, 0xe9, 0xea, 0x90, 0xd3, 0xeb, 0x3a } }
|
||||
|
||||
#define NS_GENERATEDCONTENTITERATOR_CID \
|
||||
{/* {A364930F-E353-49f1-AC69-91637EB8B757}*/ \
|
||||
0xa364930f, 0xe353, 0x49f1, { 0xac, 0x69, 0x91, 0x63, 0x7e, 0xb8, 0xb7, 0x57 } }
|
||||
|
||||
#define NS_SUBTREEITERATOR_CID \
|
||||
{/* {a6cf90e5-15b3-11d2-932e-00805f8add32}*/ \
|
||||
0xa6cf90e5, 0x15b3, 0x11d2, {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
|
||||
|
||||
// {09F689E0-B4DA-11d2-A68B-00104BDE6048}
|
||||
#define NS_EVENTLISTENERMANAGER_CID \
|
||||
{ 0x9f689e0, 0xb4da, 0x11d2, { 0xa6, 0x8b, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } }
|
||||
|
||||
// {66856477-6596-40eb-bb87-59ca2dabb6f7}
|
||||
#define NS_DOMEVENTGROUP_CID \
|
||||
{ 0x66856477, 0x6596, 0x40eb, { 0xbb, 0x87, 0x59, 0xca, 0x2d, 0xab, 0xb6, 0xf7 } }
|
||||
|
||||
// {64F300A1-C88C-11d3-97FB-00400553EEF0}
|
||||
#define NS_XBLSERVICE_CID \
|
||||
{ 0x64f300a1, 0xc88c, 0x11d3, { 0x97, 0xfb, 0x0, 0x40, 0x5, 0x53, 0xee, 0xf0 } }
|
||||
|
||||
// 3a9cd622-264d-11d4-ba06-0060b0fc76dd
|
||||
#define NS_DOM_IMPLEMENTATION_CID \
|
||||
{ 0x3a9cd622, 0x264d, 0x11d4, {0xba, 0x06, 0x00, 0x60, 0xb0, 0xfc, 0x76, 0xdd } }
|
||||
|
||||
// {AE52FE52-683A-437D-B661-DE55F4E0A873}
|
||||
#define NS_NODEINFOMANAGER_CID \
|
||||
{ 0xae52fe52, 0x683a, 0x437d, { 0xb6, 0x61, 0xde, 0x55, 0xf4, 0xe0, 0xa8, 0x73 } }
|
||||
|
||||
// {ECEA1B28-AE54-4047-8BBE-C624235106B4}
|
||||
#define NS_COMPUTEDDOMSTYLE_CID \
|
||||
{ 0xecea1b28, 0xae54, 0x4047, { 0x8b, 0xbe, 0xc6, 0x24, 0x23, 0x51, 0x06, 0xb4 } }
|
||||
|
||||
// {4aef38b7-6364-4e23-a5e7-12f837fbbd9c}
|
||||
#define NS_XMLCONTENTSERIALIZER_CID \
|
||||
{ 0x4aef38b7, 0x6364, 0x4e23, { 0xa5, 0xe7, 0x12, 0xf8, 0x37, 0xfb, 0xbd, 0x9c } }
|
||||
|
||||
// {9d3f70da-86e9-11d4-95ec-00b0d03e37b7}
|
||||
#define NS_HTMLCONTENTSERIALIZER_CID \
|
||||
{ 0x9d3f70da, 0x86e9, 0x11d4, { 0x95, 0xec, 0x00, 0xb0, 0xd0, 0x3e, 0x37, 0xb7 } }
|
||||
|
||||
// {feca3c34-205e-4ae5-bd1c-03c686ff012b}
|
||||
#define MOZ_SANITIZINGHTMLSERIALIZER_CID \
|
||||
{ 0xfeca3c34, 0x205e, 0x4ae5, { 0xbd, 0x1c, 0x03, 0xc6, 0x86, 0xff, 0x01, 0x2b } }
|
||||
|
||||
// {6030f7ef-32ed-46a7-9a63-6a5d3f90445f}
|
||||
#define NS_PLAINTEXTSERIALIZER_CID \
|
||||
{ 0x6030f7ef, 0x32ed, 0x46a7, { 0x9a, 0x63, 0x6a, 0x5d, 0x3f, 0x90, 0x44, 0x5f } }
|
||||
|
||||
// {d4f2b600-b5c1-11d6-b483-cc97c63e567c}
|
||||
#define NS_HTMLFRAGMENTSINK_CID \
|
||||
{ 0xd4f2b600, 0xb5c1, 0x11d6, { 0xb4, 0x83, 0xcc, 0x97, 0xc6, 0x3e, 0x56, 0x7c } }
|
||||
|
||||
// {13111d00-ce81-11d6-8082-ecf3665af67c}
|
||||
#define NS_HTMLFRAGMENTSINK2_CID \
|
||||
{ 0x13111d00, 0xce81, 0x11d6, { 0x80, 0x82, 0xec, 0xf3, 0x66, 0x5a, 0xf6, 0x7c } }
|
||||
|
||||
// {4B664E54-72A2-4bbf-A5C2-66D4DC3066A0}
|
||||
#define NS_XMLFRAGMENTSINK_CID \
|
||||
{ 0x4b664e54, 0x72a2, 0x4bbf, { 0xa5, 0xc2, 0x66, 0xd4, 0xdc, 0x30, 0x66, 0xa0 } }
|
||||
|
||||
// {4DC30689-929D-425e-A709-082C6294E542}
|
||||
#define NS_XMLFRAGMENTSINK2_CID \
|
||||
{ 0x4dc30689, 0x929d, 0x425e, { 0xa7, 0x9, 0x8, 0x2c, 0x62, 0x94, 0xe5, 0x42 } }
|
||||
|
||||
// {3986B301-097C-11d3-BF87-00105A1B0627}
|
||||
#define NS_XULPOPUPLISTENER_CID \
|
||||
{ 0x3986b301, 0x97c, 0x11d3, { 0xbf, 0x87, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } }
|
||||
|
||||
// {1F5C1721-7DC3-11d3-BF87-00105A1B0627}
|
||||
#define NS_XULCONTROLLERS_CID \
|
||||
{ 0x1f5c1721, 0x7dc3, 0x11d3, { 0xbf, 0x87, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } }
|
||||
|
||||
|
||||
// {daedcb43-1dd1-11b2-b1d2-caf06cb40387}
|
||||
#define NS_DLGDEFAULTKEYS_CID \
|
||||
{ 0xdaedcb43, 0x1dd1, 0x11b2, { 0xb1, 0xd2, 0xca, 0xf0, 0x6c, 0xb4, 0x3, 0x87 } }
|
||||
|
||||
// {BFD05264-834C-11d2-8EAC-00805F29F371}
|
||||
#define NS_XULSORTSERVICE_CID \
|
||||
{ 0xbfd05264, 0x834c, 0x11d2, { 0x8e, 0xac, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x71 } }
|
||||
|
||||
// {3D262D00-8B5A-11d2-8EB0-00805F29F370}
|
||||
#define NS_XULTEMPLATEBUILDER_CID \
|
||||
{ 0x3d262d00, 0x8b5a, 0x11d2, { 0x8e, 0xb0, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
// {1abdcc96-1dd2-11b2-b520-f8f59cdd67bc}
|
||||
#define NS_XULTREEBUILDER_CID \
|
||||
{ 0x1abdcc96, 0x1dd2, 0x11b2, { 0xb5, 0x20, 0xf8, 0xf5, 0x9c, 0xdd, 0x67, 0xbc } }
|
||||
|
||||
// {CE058B21-BA9C-11d2-BF86-00105A1B0627}
|
||||
#define NS_XULCONTENTSINK_CID \
|
||||
{ 0xce058b21, 0xba9c, 0x11d2, { 0xbf, 0x86, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } }
|
||||
|
||||
// {541AFCB2-A9A3-11d2-8EC5-00805F29F370}
|
||||
#define NS_XULDOCUMENT_CID \
|
||||
{ 0x541afcb2, 0xa9a3, 0x11d2, { 0x8e, 0xc5, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
// {3A0A0FC1-8349-11d3-BE47-00104BDE6048}
|
||||
#define NS_XULPROTOTYPECACHE_CID \
|
||||
{ 0x3a0a0fc1, 0x8349, 0x11d3, { 0xbe, 0x47, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } }
|
||||
|
||||
// {a6cf9126-15b3-11d2-932e-00805f8add32}
|
||||
#define NS_RANGEUTILS_CID \
|
||||
{ 0xa6cf9126, 0x15b3, 0x11d2, {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
|
||||
#define NS_SVGDOCUMENT_CID \
|
||||
{ /* b7f44954-1dd1-11b2-8c2e-c2feab4186bc */ \
|
||||
0xb7f44954, 0x11d1, 0x11b2, \
|
||||
{0x8c, 0x2e, 0xc2, 0xfe, 0xab, 0x41, 0x86, 0xbc}}
|
||||
|
||||
#endif // MOZ_SVG
|
||||
|
||||
#define NS_SYNCLOADDOMSERVICE_CID \
|
||||
{ /* 0e4e7d00-f71a-439f-9178-1a71ff11b55f */ \
|
||||
0x0e4e7d00, 0xf71a, 0x439f, \
|
||||
{0x91, 0x78, 0x1a, 0x71, 0xff, 0x11, 0xb5, 0x5f} }
|
||||
#define NS_SYNCLOADDOMSERVICE_CONTRACTID \
|
||||
"@mozilla.org/content/syncload-dom-service;1"
|
||||
|
||||
// {f96f5ec9-755b-447e-b1f3-717d1a84bb41}
|
||||
#define NS_PLUGINDOCUMENT_CID \
|
||||
{ 0xf96f5ec9, 0x755b, 0x447e, { 0xb1, 0xf3, 0x71, 0x7d, 0x1a, 0x84, 0xbb, 0x41 } }
|
||||
|
||||
#endif /* nsContentCID_h__ */
|
||||
@@ -1,113 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Peter Van der Beken.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Peter Van der Beken <peter@propagandism.org>
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsContentCreatorFunctions_h__
|
||||
#define nsContentCreatorFunctions_h__
|
||||
|
||||
#include "nscore.h"
|
||||
|
||||
/**
|
||||
* Functions to create content, to be used only inside Gecko
|
||||
* (mozilla/content and mozilla/layout).
|
||||
*/
|
||||
|
||||
class nsAString;
|
||||
class nsIContent;
|
||||
class nsIDocument;
|
||||
class nsINodeInfo;
|
||||
class imgIRequest;
|
||||
class nsNodeInfoManager;
|
||||
|
||||
nsresult
|
||||
NS_NewElement(nsIContent** aResult, PRInt32 aElementType,
|
||||
nsINodeInfo* aNodeInfo);
|
||||
|
||||
nsresult
|
||||
NS_NewXMLElement(nsIContent** aResult, nsINodeInfo* aNodeInfo);
|
||||
|
||||
/**
|
||||
* aNodeInfoManager must not be null.
|
||||
*/
|
||||
nsresult
|
||||
NS_NewXMLProcessingInstruction(nsIContent** aInstancePtrResult,
|
||||
nsNodeInfoManager *aNodeInfoManager,
|
||||
const nsAString& aTarget,
|
||||
const nsAString& aData);
|
||||
|
||||
/**
|
||||
* aNodeInfoManager must not be null.
|
||||
*/
|
||||
nsresult
|
||||
NS_NewXMLStylesheetProcessingInstruction(nsIContent** aInstancePtrResult,
|
||||
nsNodeInfoManager *aNodeInfoManager,
|
||||
const nsAString& aData);
|
||||
|
||||
/**
|
||||
* aNodeInfoManager must not be null.
|
||||
*/
|
||||
nsresult
|
||||
NS_NewXMLCDATASection(nsIContent** aInstancePtrResult,
|
||||
nsNodeInfoManager *aNodeInfoManager);
|
||||
|
||||
nsresult
|
||||
NS_NewHTMLElement(nsIContent** aResult, nsINodeInfo *aNodeInfo);
|
||||
|
||||
#ifdef MOZ_MATHML
|
||||
nsresult
|
||||
NS_NewMathMLElement(nsIContent** aResult, nsINodeInfo* aNodeInfo);
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_XUL
|
||||
nsresult
|
||||
NS_NewXULElement(nsIContent** aResult, nsINodeInfo* aNodeInfo);
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
nsresult
|
||||
NS_NewSVGElement(nsIContent** aResult, nsINodeInfo* aNodeInfo);
|
||||
#endif
|
||||
|
||||
nsresult
|
||||
NS_NewGenConImageContent(nsIContent** aResult, nsINodeInfo* aNodeInfo,
|
||||
imgIRequest* aImageRequest);
|
||||
|
||||
nsresult
|
||||
NS_NewXMLEventsElement(nsIContent** aResult, nsINodeInfo* aNodeInfo);
|
||||
|
||||
#endif // nsContentCreatorFunctions_h__
|
||||
@@ -1,101 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
// vim: ft=cpp sw=2 ts=2 tw=78 et
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Jonas Sicking <jonas@sicking.cc> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsContentErrors_h___
|
||||
#define nsContentErrors_h___
|
||||
|
||||
/** Error codes for nsHTMLStyleSheet */
|
||||
// XXX this is not really used
|
||||
#define NS_HTML_STYLE_PROPERTY_NOT_THERE \
|
||||
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_CONTENT, 2)
|
||||
|
||||
|
||||
/** Error codes for MaybeTriggerAutoLink */
|
||||
#define NS_XML_AUTOLINK_EMBED \
|
||||
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_CONTENT, 3)
|
||||
#define NS_XML_AUTOLINK_NEW \
|
||||
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_CONTENT, 4)
|
||||
#define NS_XML_AUTOLINK_REPLACE \
|
||||
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_CONTENT, 5)
|
||||
#define NS_XML_AUTOLINK_UNDEFINED \
|
||||
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_CONTENT, 6)
|
||||
|
||||
/** Error codes for nsIScriptLoader */
|
||||
#define NS_CONTENT_SCRIPT_IS_EVENTHANDLER \
|
||||
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_CONTENT, 7)
|
||||
|
||||
/** Error codes for image loading */
|
||||
#define NS_ERROR_IMAGE_SRC_CHANGED \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_CONTENT, 8)
|
||||
|
||||
#define NS_ERROR_IMAGE_BLOCKED \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_CONTENT, 9)
|
||||
|
||||
/** Error codes for content policy blocking */
|
||||
#define NS_ERROR_CONTENT_BLOCKED \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_CONTENT, 10)
|
||||
|
||||
#define NS_ERROR_CONTENT_BLOCKED_SHOW_ALT \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_CONTENT, 11)
|
||||
|
||||
/** Success variations of content policy blocking */
|
||||
#define NS_CONTENT_BLOCKED \
|
||||
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_CONTENT, 12)
|
||||
|
||||
#define NS_CONTENT_BLOCKED_SHOW_ALT \
|
||||
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_CONTENT, 13)
|
||||
|
||||
#define NS_PROPTABLE_PROP_NOT_THERE \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_CONTENT, 14)
|
||||
|
||||
#define NS_PROPTABLE_PROP_OVERWRITTEN \
|
||||
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_CONTENT, 15)
|
||||
|
||||
/* Error codes for FindBroadcaster in nsXULDocument.cpp */
|
||||
|
||||
#define NS_FINDBROADCASTER_NOT_FOUND \
|
||||
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_CONTENT, 16)
|
||||
|
||||
#define NS_FINDBROADCASTER_FOUND \
|
||||
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_CONTENT, 17)
|
||||
|
||||
#define NS_FINDBROADCASTER_AWAIT_OVERLAYS \
|
||||
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_CONTENT, 18)
|
||||
|
||||
#endif // nsContentErrors_h___
|
||||
@@ -1,251 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Zero-Knowledge Systems, Inc.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Timothy Watt <riceman+moz@mail.rit.edu>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Utility routines for checking content load/process policy settings,
|
||||
* and routines helpful for content policy implementors.
|
||||
*/
|
||||
|
||||
#ifndef __nsContentPolicyUtils_h__
|
||||
#define __nsContentPolicyUtils_h__
|
||||
|
||||
// for PR_LOGGING
|
||||
#include "prlog.h"
|
||||
|
||||
#include "nsIContentPolicy.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIContent.h"
|
||||
|
||||
//XXXtw sadly, this makes consumers of nsContentPolicyUtils depend on widget
|
||||
#include "nsIDocument.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
|
||||
class nsACString;
|
||||
|
||||
#define NS_CONTENTPOLICY_CONTRACTID "@mozilla.org/layout/content-policy;1"
|
||||
#define NS_CONTENTPOLICY_CATEGORY "content-policy"
|
||||
#define NS_CONTENTPOLICY_CID \
|
||||
{0x0e3afd3d, 0xeb60, 0x4c2b, \
|
||||
{ 0x96, 0x3b, 0x56, 0xd7, 0xc4, 0x39, 0xf1, 0x24 }}
|
||||
|
||||
/**
|
||||
* Evaluates to true if val is ACCEPT.
|
||||
*
|
||||
* @param val the status returned from shouldProcess/shouldLoad
|
||||
*/
|
||||
#define NS_CP_ACCEPTED(val) ((val) == nsIContentPolicy::ACCEPT)
|
||||
|
||||
/**
|
||||
* Evaluates to true if val is a REJECT_* status
|
||||
*
|
||||
* @param val the status returned from shouldProcess/shouldLoad
|
||||
*/
|
||||
#define NS_CP_REJECTED(val) ((val) != nsIContentPolicy::ACCEPT)
|
||||
|
||||
// Offer convenient translations of constants -> const char*
|
||||
|
||||
// convenience macro to reduce some repetative typing...
|
||||
// name is the name of a constant from this interface
|
||||
#define CASE_RETURN(name) \
|
||||
case nsIContentPolicy:: name : \
|
||||
return #name
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
/**
|
||||
* Returns a string corresponding to the name of the response constant, or
|
||||
* "<Unknown Response>" if an unknown response value is given.
|
||||
*
|
||||
* The return value is static and must not be freed.
|
||||
*
|
||||
* @param response the response code
|
||||
* @return the name of the given response code
|
||||
*/
|
||||
inline const char *
|
||||
NS_CP_ResponseName(PRInt16 response)
|
||||
{
|
||||
switch (response) {
|
||||
CASE_RETURN( REJECT_REQUEST );
|
||||
CASE_RETURN( REJECT_TYPE );
|
||||
CASE_RETURN( REJECT_SERVER );
|
||||
CASE_RETURN( REJECT_OTHER );
|
||||
CASE_RETURN( ACCEPT );
|
||||
default:
|
||||
return "<Unknown Response>";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string corresponding to the name of the content type constant, or
|
||||
* "<Unknown Type>" if an unknown content type value is given.
|
||||
*
|
||||
* The return value is static and must not be freed.
|
||||
*
|
||||
* @param contentType the content type code
|
||||
* @return the name of the given content type code
|
||||
*/
|
||||
inline const char *
|
||||
NS_CP_ContentTypeName(PRUint32 contentType)
|
||||
{
|
||||
switch (contentType) {
|
||||
CASE_RETURN( TYPE_OTHER );
|
||||
CASE_RETURN( TYPE_SCRIPT );
|
||||
CASE_RETURN( TYPE_IMAGE );
|
||||
CASE_RETURN( TYPE_STYLESHEET );
|
||||
CASE_RETURN( TYPE_OBJECT );
|
||||
CASE_RETURN( TYPE_DOCUMENT );
|
||||
CASE_RETURN( TYPE_SUBDOCUMENT);
|
||||
CASE_RETURN( TYPE_REFRESH );
|
||||
default:
|
||||
return "<Unknown Type>";
|
||||
}
|
||||
}
|
||||
|
||||
#endif // defined(PR_LOGGING)
|
||||
|
||||
#undef CASE_RETURN
|
||||
|
||||
/* Passes on parameters from its "caller"'s context. */
|
||||
#define CHECK_CONTENT_POLICY(action) \
|
||||
PR_BEGIN_MACRO \
|
||||
nsCOMPtr<nsIContentPolicy> policy = \
|
||||
do_GetService(NS_CONTENTPOLICY_CONTRACTID); \
|
||||
if (!policy) \
|
||||
return NS_ERROR_FAILURE; \
|
||||
\
|
||||
return policy-> action (contentType, contentLocation, requestOrigin, \
|
||||
context, mimeType, extra, decision); \
|
||||
PR_END_MACRO
|
||||
|
||||
/* Passes on parameters from its "caller"'s context. */
|
||||
#define CHECK_CONTENT_POLICY_WITH_SERVICE(action, _policy) \
|
||||
PR_BEGIN_MACRO \
|
||||
return _policy-> action (contentType, contentLocation, requestOrigin, \
|
||||
context, mimeType, extra, decision); \
|
||||
PR_END_MACRO
|
||||
|
||||
/**
|
||||
* Alias for calling ShouldLoad on the content policy service.
|
||||
* Parameters are the same as nsIContentPolicy::shouldLoad, except for
|
||||
* the last parameter, which can be used to pass in a pointer to the
|
||||
* service if the caller already has one.
|
||||
*/
|
||||
inline nsresult
|
||||
NS_CheckContentLoadPolicy(PRUint32 contentType,
|
||||
nsIURI *contentLocation,
|
||||
nsIURI *requestOrigin,
|
||||
nsISupports *context,
|
||||
const nsACString &mimeType,
|
||||
nsISupports *extra,
|
||||
PRInt16 *decision,
|
||||
nsIContentPolicy *policyService = nsnull)
|
||||
{
|
||||
if (policyService) {
|
||||
CHECK_CONTENT_POLICY_WITH_SERVICE(ShouldLoad, policyService);
|
||||
}
|
||||
CHECK_CONTENT_POLICY(ShouldLoad);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for calling ShouldProcess on the content policy service.
|
||||
* Parameters are the same as nsIContentPolicy::shouldProcess.
|
||||
*/
|
||||
inline nsresult
|
||||
NS_CheckContentProcessPolicy(PRUint32 contentType,
|
||||
nsIURI *contentLocation,
|
||||
nsIURI *requestOrigin,
|
||||
nsISupports *context,
|
||||
const nsACString &mimeType,
|
||||
nsISupports *extra,
|
||||
PRInt16 *decision,
|
||||
nsIContentPolicy *policyService = nsnull)
|
||||
{
|
||||
if (policyService) {
|
||||
CHECK_CONTENT_POLICY_WITH_SERVICE(ShouldProcess, policyService);
|
||||
}
|
||||
CHECK_CONTENT_POLICY(ShouldProcess);
|
||||
}
|
||||
|
||||
#undef CHECK_CONTENT_POLICY
|
||||
#undef CHECK_CONTENT_POLICY_WITH_SERVICE
|
||||
|
||||
/**
|
||||
* Helper function to get an nsIDocShell given a context.
|
||||
* If the context is a document or window, the corresponding docshell will be
|
||||
* returned.
|
||||
* If the context is a non-document DOM node, the docshell of its ownerDocument
|
||||
* will be returned.
|
||||
*
|
||||
* @param aContext the context to find a docshell for (can be null)
|
||||
* @return a WEAK pointer to the docshell, or nsnull if it could
|
||||
* not be obtained
|
||||
*/
|
||||
inline nsIDocShell*
|
||||
NS_CP_GetDocShellFromContext(nsISupports *aContext)
|
||||
{
|
||||
if (!aContext) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aContext);
|
||||
|
||||
if (!window) {
|
||||
// our context might be a document (which also QIs to nsIDOMNode), so
|
||||
// try that first
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(aContext);
|
||||
if (!doc) {
|
||||
// we were not a document after all, get our ownerDocument,
|
||||
// hopefully
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(aContext);
|
||||
if (content) {
|
||||
doc = content->GetOwnerDoc();
|
||||
}
|
||||
}
|
||||
|
||||
if (doc) {
|
||||
window = doc->GetWindow();
|
||||
}
|
||||
}
|
||||
|
||||
if (!window) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
return window->GetDocShell();
|
||||
}
|
||||
|
||||
#endif /* __nsContentPolicyUtils_h__ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,69 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsCopySupport_h__
|
||||
#define nsCopySupport_h__
|
||||
|
||||
#include "nscore.h"
|
||||
|
||||
class nsISelection;
|
||||
class nsIDocument;
|
||||
class nsIImageLoadingContent;
|
||||
class nsIContent;
|
||||
class nsITransferable;
|
||||
class nsACString;
|
||||
class nsAString;
|
||||
|
||||
class nsCopySupport
|
||||
{
|
||||
// class of static helper functions for copy support
|
||||
public:
|
||||
static nsresult HTMLCopy(nsISelection *aSel, nsIDocument *aDoc, PRInt16 aClipboardID);
|
||||
static nsresult DoHooks(nsIDocument *aDoc, nsITransferable *aTrans,
|
||||
PRBool *aDoPutOnClipboard);
|
||||
static nsresult IsPlainTextContext(nsISelection *aSel, nsIDocument *aDoc, PRBool *aIsPlainTextContext);
|
||||
|
||||
// Get the selection, or entire document, in the format specified by the mime type
|
||||
// (text/html or text/plain). If aSel is non-null, use it, otherwise get the entire
|
||||
// doc.
|
||||
static nsresult GetContents(const nsACString& aMimeType, PRUint32 aFlags, nsISelection *aSel, nsIDocument *aDoc, nsAString& outdata);
|
||||
|
||||
static nsresult ImageCopy(nsIImageLoadingContent* aImageElement,
|
||||
PRInt32 aCopyFlags);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,88 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Peter Van der Beken <peterv@netscape.com>
|
||||
* Allan Beaufour <allan@beaufour.dk>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsIAttribute_h___
|
||||
#define nsIAttribute_h___
|
||||
|
||||
#include "nsINode.h"
|
||||
|
||||
class nsDOMAttributeMap;
|
||||
class nsIContent;
|
||||
|
||||
#define NS_IATTRIBUTE_IID \
|
||||
{ 0xb65ca480, 0xca76, 0x495c, \
|
||||
{ 0x95, 0xe4, 0x8c, 0xd0, 0x55, 0x5d, 0xd3, 0x13 } }
|
||||
|
||||
class nsIAttribute : public nsINode
|
||||
{
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IATTRIBUTE_IID)
|
||||
|
||||
virtual void SetMap(nsDOMAttributeMap *aMap) = 0;
|
||||
|
||||
nsDOMAttributeMap *GetMap()
|
||||
{
|
||||
return mAttrMap;
|
||||
}
|
||||
|
||||
nsINodeInfo *NodeInfo()
|
||||
{
|
||||
return mNodeInfo;
|
||||
}
|
||||
|
||||
virtual nsIContent* GetContent() const = 0;
|
||||
|
||||
/**
|
||||
* Called when our ownerElement is moved into a new document.
|
||||
* Updates the nodeinfo of this node.
|
||||
*/
|
||||
virtual nsresult SetOwnerDocument(nsIDocument* aDocument) = 0;
|
||||
|
||||
protected:
|
||||
nsIAttribute(nsDOMAttributeMap *aAttrMap, nsINodeInfo *aNodeInfo)
|
||||
: nsINode(aNodeInfo), mAttrMap(aAttrMap)
|
||||
{
|
||||
}
|
||||
|
||||
nsDOMAttributeMap *mAttrMap; // WEAK
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIAttribute, NS_IATTRIBUTE_IID)
|
||||
|
||||
#endif /* nsIAttribute_h___ */
|
||||
@@ -1,117 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla browser.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* pav
|
||||
* Blake Ross (blaker@netscape.com)
|
||||
* Benjamin Smedberg <bsmedberg@covad.net>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIURI;
|
||||
|
||||
[scriptable, uuid(68389281-f6d0-4533-841d-344a2018140c)]
|
||||
interface nsIChromeRegistry : nsISupports
|
||||
{
|
||||
const PRInt32 NONE = 0;
|
||||
const PRInt32 PARTIAL = 1;
|
||||
const PRInt32 FULL = 2;
|
||||
|
||||
/**
|
||||
* Resolve a chrome URL to an loadable URI using the information in the
|
||||
* registry. Does not modify aChromeURL.
|
||||
*
|
||||
* Chrome URLs are allowed to be specified in "shorthand", leaving the
|
||||
* "file" portion off. In that case, the URL is expanded to:
|
||||
*
|
||||
* chrome://package/provider/package.ext
|
||||
*
|
||||
* where "ext" is:
|
||||
*
|
||||
* "xul" for a "content" package,
|
||||
* "css" for a "skin" package, and
|
||||
* "dtd" for a "locale" package.
|
||||
*
|
||||
* @param aChromeURL the URL that is to be converted.
|
||||
*/
|
||||
nsIURI convertChromeURL(in nsIURI aChromeURL);
|
||||
|
||||
/**
|
||||
* refresh the chrome list at runtime, looking for new packages/etc
|
||||
*/
|
||||
void checkForNewChrome();
|
||||
};
|
||||
|
||||
[scriptable, uuid(3e51f40b-b4b0-4e60-ac45-6c63477ebe41)]
|
||||
interface nsIXULChromeRegistry : nsIChromeRegistry
|
||||
{
|
||||
/* Should be called when locales change to reload all chrome (including XUL). */
|
||||
void reloadChrome();
|
||||
|
||||
ACString getSelectedLocale(in ACString packageName);
|
||||
|
||||
/* Should be called when skins change. Reloads only stylesheets. */
|
||||
void refreshSkins();
|
||||
|
||||
/**
|
||||
* Installable skin XBL is not always granted the same privileges as other
|
||||
* chrome. This asks the chrome registry whether scripts are allowed to be
|
||||
* run for a particular chrome URI. Do not pass non-chrome URIs to this
|
||||
* method.
|
||||
*/
|
||||
boolean allowScriptsForPackage(in nsIURI url);
|
||||
};
|
||||
|
||||
%{ C++
|
||||
|
||||
#define NS_CHROMEREGISTRY_CONTRACTID \
|
||||
"@mozilla.org/chrome/chrome-registry;1"
|
||||
|
||||
/**
|
||||
* Chrome registry will notify various caches that all chrome files need
|
||||
* flushing.
|
||||
*/
|
||||
#define NS_CHROME_FLUSH_TOPIC \
|
||||
"chrome-flush-caches"
|
||||
|
||||
/**
|
||||
* Chrome registry will notify various caches that skin files need flushing.
|
||||
* If "chrome-flush-caches" is notified, this topic will *not* be notified.
|
||||
*/
|
||||
#define NS_CHROME_FLUSH_SKINS_TOPIC \
|
||||
"chrome-flush-skin-caches"
|
||||
|
||||
%}
|
||||
@@ -1,724 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsIContent_h___
|
||||
#define nsIContent_h___
|
||||
|
||||
#include "nsCOMPtr.h" // for already_AddRefed
|
||||
#include "nsStringGlue.h"
|
||||
#include "nsCaseTreatment.h"
|
||||
#include "nsChangeHint.h"
|
||||
#include "nsINode.h"
|
||||
|
||||
// Forward declarations
|
||||
class nsIAtom;
|
||||
class nsIDocument;
|
||||
class nsPresContext;
|
||||
class nsVoidArray;
|
||||
class nsIDOMEvent;
|
||||
class nsIContent;
|
||||
class nsISupportsArray;
|
||||
class nsIEventListenerManager;
|
||||
class nsIURI;
|
||||
class nsICSSStyleRule;
|
||||
class nsRuleWalker;
|
||||
class nsAttrValue;
|
||||
class nsAttrName;
|
||||
|
||||
// IID for the nsIContent interface
|
||||
#define NS_ICONTENT_IID \
|
||||
{ 0x67b73e9b, 0x6ec8, 0x4f20, \
|
||||
{ 0x89, 0xb2, 0xb1, 0x46, 0x9e, 0x0a, 0x51, 0x68 } }
|
||||
|
||||
// hack to make egcs / gcc 2.95.2 happy
|
||||
class nsIContent_base : public nsINode {
|
||||
public:
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
// If you're using the external API, the only thing you can know about
|
||||
// nsIContent is that it exists with an IID
|
||||
|
||||
nsIContent_base(nsINodeInfo *aNodeInfo)
|
||||
: nsINode(aNodeInfo)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICONTENT_IID)
|
||||
};
|
||||
|
||||
/**
|
||||
* A node of content in a document's content model. This interface
|
||||
* is supported by all content objects.
|
||||
*/
|
||||
class nsIContent : public nsIContent_base {
|
||||
public:
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
// If you're using the external API, the only thing you can know about
|
||||
// nsIContent is that it exists with an IID
|
||||
|
||||
nsIContent(nsINodeInfo *aNodeInfo)
|
||||
: nsIContent_base(aNodeInfo)
|
||||
{
|
||||
NS_ASSERTION(aNodeInfo,
|
||||
"No nsINodeInfo passed to nsIContent, PREPARE TO CRASH!!!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind this content node to a tree. If this method throws, the caller must
|
||||
* call UnbindFromTree() on the node. In the typical case of a node being
|
||||
* appended to a parent, this will be called after the node has been added to
|
||||
* the parent's child list and before nsIDocumentObserver notifications for
|
||||
* the addition are dispatched.
|
||||
* @param aDocument The new document for the content node. Must match the
|
||||
* current document of aParent, if aParent is not null.
|
||||
* May not be null if aParent is null.
|
||||
* @param aParent The new parent for the content node. May be null if the
|
||||
* node is being bound as a direct child of the document.
|
||||
* @param aBindingParent The new binding parent for the content node.
|
||||
* This is allowed to be null. In that case, the
|
||||
* binding parent of aParent, if any, will be used.
|
||||
* @param aCompileEventHandlers whether to initialize the event handlers in
|
||||
* the document (used by nsXULElement)
|
||||
* @note either aDocument or aParent must be non-null. If both are null,
|
||||
* this method _will_ crash.
|
||||
* @note This method must not be called by consumers of nsIContent on a node
|
||||
* that is already bound to a tree. Call UnbindFromTree first.
|
||||
* @note This method will handle rebinding descendants appropriately (eg
|
||||
* changing their binding parent as needed).
|
||||
* @note This method does not add the content node to aParent's child list
|
||||
* @throws NS_ERROR_OUT_OF_MEMORY if that happens
|
||||
*/
|
||||
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
||||
nsIContent* aBindingParent,
|
||||
PRBool aCompileEventHandlers) = 0;
|
||||
|
||||
/**
|
||||
* Unbind this content node from a tree. This will set its current document
|
||||
* and binding parent to null. In the typical case of a node being removed
|
||||
* from a parent, this will be called after it has been removed from the
|
||||
* parent's child list and after the nsIDocumentObserver notifications for
|
||||
* the removal have been dispatched.
|
||||
* @param aDeep Whether to recursively unbind the entire subtree rooted at
|
||||
* this node. The only time PR_FALSE should be passed is when the
|
||||
* parent node of the content is being destroyed.
|
||||
* @param aNullParent Whether to null out the parent pointer as well. This
|
||||
* is usually desirable. This argument should only be false while
|
||||
* recursively calling UnbindFromTree when a subtree is detached.
|
||||
* @note This method is safe to call on nodes that are not bound to a tree.
|
||||
*/
|
||||
virtual void UnbindFromTree(PRBool aDeep = PR_TRUE,
|
||||
PRBool aNullParent = PR_TRUE) = 0;
|
||||
|
||||
/**
|
||||
* Returns true if the content has an ancestor that is a document.
|
||||
*
|
||||
* @return whether this content is in a document tree
|
||||
*/
|
||||
PRBool IsInDoc() const
|
||||
{
|
||||
return mParentPtrBits & PARENT_BIT_INDOCUMENT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the document that this content is currently in, if any. This will be
|
||||
* null if the content has no ancestor that is a document.
|
||||
*
|
||||
* @return the current document
|
||||
*/
|
||||
nsIDocument *GetCurrentDoc() const
|
||||
{
|
||||
return IsInDoc() ? GetOwnerDoc() : nsnull;
|
||||
}
|
||||
|
||||
/**
|
||||
* DEPRECATED - Use GetCurrentDoc or GetOwnerDoc.
|
||||
* Get the document for this content.
|
||||
* @return the document
|
||||
*/
|
||||
nsIDocument *GetDocument() const
|
||||
{
|
||||
return GetCurrentDoc();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether this content is C++-generated anonymous content
|
||||
* @see nsIAnonymousContentCreator
|
||||
* @return whether this content is anonymous
|
||||
*/
|
||||
PRBool IsNativeAnonymous() const
|
||||
{
|
||||
return HasFlag(NODE_IS_ANONYMOUS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether this content is anonymous
|
||||
* This is virtual and non-inlined due to nsXULElement::SetNativeAnonymous
|
||||
* @see nsIAnonymousContentCreator
|
||||
* @param aAnonymous whether this content is anonymous
|
||||
*/
|
||||
virtual void SetNativeAnonymous(PRBool aAnonymous);
|
||||
|
||||
/**
|
||||
* Get the namespace that this element's tag is defined in
|
||||
* @return the namespace
|
||||
*/
|
||||
PRInt32 GetNameSpaceID() const
|
||||
{
|
||||
return mNodeInfo->NamespaceID();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tag for this element. This will always return a non-null
|
||||
* atom pointer (as implied by the naming of the method).
|
||||
*/
|
||||
nsIAtom *Tag() const
|
||||
{
|
||||
return mNodeInfo->NameAtom();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the NodeInfo for this element
|
||||
* @return the nodes node info
|
||||
*/
|
||||
nsINodeInfo *NodeInfo() const
|
||||
{
|
||||
return mNodeInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an atom holding the name of the attribute of type ID on
|
||||
* this content node (if applicable). Returns null for non-element
|
||||
* content nodes.
|
||||
*/
|
||||
virtual nsIAtom *GetIDAttributeName() const = 0;
|
||||
|
||||
/**
|
||||
* Normalizes an attribute name and returns it as a nodeinfo if an attribute
|
||||
* with that name exists. This method is intended for character case
|
||||
* conversion if the content object is case insensitive (e.g. HTML). Returns
|
||||
* the nodeinfo of the attribute with the specified name if one exists or
|
||||
* null otherwise.
|
||||
*
|
||||
* @param aStr the unparsed attribute string
|
||||
* @return the node info. May be nsnull.
|
||||
*/
|
||||
virtual already_AddRefed<nsINodeInfo> GetExistingAttrNameFromQName(const nsAString& aStr) const = 0;
|
||||
|
||||
/**
|
||||
* Set attribute values. All attribute values are assumed to have a
|
||||
* canonical string representation that can be used for these
|
||||
* methods. The SetAttr method is assumed to perform a translation
|
||||
* of the canonical form into the underlying content specific
|
||||
* form.
|
||||
*
|
||||
* @param aNameSpaceID the namespace of the attribute
|
||||
* @param aName the name of the attribute
|
||||
* @param aValue the value to set
|
||||
* @param aNotify specifies how whether or not the document should be
|
||||
* notified of the attribute change.
|
||||
*/
|
||||
nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
const nsAString& aValue, PRBool aNotify)
|
||||
{
|
||||
return SetAttr(aNameSpaceID, aName, nsnull, aValue, aNotify);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set attribute values. All attribute values are assumed to have a
|
||||
* canonical String representation that can be used for these
|
||||
* methods. The SetAttr method is assumed to perform a translation
|
||||
* of the canonical form into the underlying content specific
|
||||
* form.
|
||||
*
|
||||
* @param aNameSpaceID the namespace of the attribute
|
||||
* @param aName the name of the attribute
|
||||
* @param aPrefix the prefix of the attribute
|
||||
* @param aValue the value to set
|
||||
* @param aNotify specifies how whether or not the document should be
|
||||
* notified of the attribute change.
|
||||
*/
|
||||
virtual nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
nsIAtom* aPrefix, const nsAString& aValue,
|
||||
PRBool aNotify) = 0;
|
||||
|
||||
/**
|
||||
* Get the current value of the attribute. This returns a form that is
|
||||
* suitable for passing back into SetAttr.
|
||||
*
|
||||
* @param aNameSpaceID the namespace of the attr
|
||||
* @param aName the name of the attr
|
||||
* @param aResult the value (may legitimately be the empty string) [OUT]
|
||||
* @returns PR_TRUE if the attribute was set (even when set to empty string)
|
||||
* PR_FALSE when not set.
|
||||
*/
|
||||
virtual PRBool GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
nsAString& aResult) const = 0;
|
||||
|
||||
/**
|
||||
* Determine if an attribute has been set (empty string or otherwise).
|
||||
*
|
||||
* @param aNameSpaceId the namespace id of the attribute
|
||||
* @param aAttr the attribute name
|
||||
* @return whether an attribute exists
|
||||
*/
|
||||
virtual PRBool HasAttr(PRInt32 aNameSpaceID, nsIAtom* aName) const = 0;
|
||||
|
||||
/**
|
||||
* Test whether this content node's given attribute has the given value. If
|
||||
* the attribute is not set at all, this will return false.
|
||||
*
|
||||
* @param aNameSpaceID The namespace ID of the attribute. Must not
|
||||
* be kNameSpaceID_Unknown.
|
||||
* @param aName The name atom of the attribute. Must not be null.
|
||||
* @param aValue The value to compare to.
|
||||
* @param aCaseSensitive Whether to do a case-sensitive compare on the value.
|
||||
*/
|
||||
virtual PRBool AttrValueIs(PRInt32 aNameSpaceID,
|
||||
nsIAtom* aName,
|
||||
const nsAString& aValue,
|
||||
nsCaseTreatment aCaseSensitive) const
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether this content node's given attribute has the given value. If
|
||||
* the attribute is not set at all, this will return false.
|
||||
*
|
||||
* @param aNameSpaceID The namespace ID of the attribute. Must not
|
||||
* be kNameSpaceID_Unknown.
|
||||
* @param aName The name atom of the attribute. Must not be null.
|
||||
* @param aValue The value to compare to. Must not be null.
|
||||
* @param aCaseSensitive Whether to do a case-sensitive compare on the value.
|
||||
*/
|
||||
virtual PRBool AttrValueIs(PRInt32 aNameSpaceID,
|
||||
nsIAtom* aName,
|
||||
nsIAtom* aValue,
|
||||
nsCaseTreatment aCaseSensitive) const
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
enum {
|
||||
ATTR_MISSING = -1,
|
||||
ATTR_VALUE_NO_MATCH = -2
|
||||
};
|
||||
/**
|
||||
* Check whether this content node's given attribute has one of a given
|
||||
* list of values. If there is a match, we return the index in the list
|
||||
* of the first matching value. If there was no attribute at all, then
|
||||
* we return ATTR_MISSING. If there was an attribute but it didn't
|
||||
* match, we return ATTR_VALUE_NO_MATCH. A non-negative result always
|
||||
* indicates a match.
|
||||
*
|
||||
* @param aNameSpaceID The namespace ID of the attribute. Must not
|
||||
* be kNameSpaceID_Unknown.
|
||||
* @param aName The name atom of the attribute. Must not be null.
|
||||
* @param aValues a NULL-terminated array of pointers to atom values to test
|
||||
* against.
|
||||
* @param aCaseSensitive Whether to do a case-sensitive compare on the values.
|
||||
* @return ATTR_MISSING, ATTR_VALUE_NO_MATCH or the non-negative index
|
||||
* indicating the first value of aValues that matched
|
||||
*/
|
||||
typedef nsIAtom* const* const AttrValuesArray;
|
||||
virtual PRInt32 FindAttrValueIn(PRInt32 aNameSpaceID,
|
||||
nsIAtom* aName,
|
||||
AttrValuesArray* aValues,
|
||||
nsCaseTreatment aCaseSensitive) const
|
||||
{
|
||||
return ATTR_MISSING;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an attribute so that it is no longer explicitly specified.
|
||||
*
|
||||
* @param aNameSpaceID the namespace id of the attribute
|
||||
* @param aAttr the name of the attribute to unset
|
||||
* @param aNotify specifies whether or not the document should be
|
||||
* notified of the attribute change
|
||||
*/
|
||||
virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttr,
|
||||
PRBool aNotify) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Get the namespace / name / prefix of a given attribute.
|
||||
*
|
||||
* @param aIndex the index of the attribute name
|
||||
* @returns The name at the given index, or null if the index is
|
||||
* out-of-bounds.
|
||||
* @note The document returned by NodeInfo()->GetDocument() (if one is
|
||||
* present) is *not* neccesarily the owner document of the element.
|
||||
* @note The pointer returned by this function is only valid until the
|
||||
* next call of either GetAttrNameAt or SetAttr on the element.
|
||||
*/
|
||||
virtual const nsAttrName* GetAttrNameAt(PRUint32 aIndex) const = 0;
|
||||
|
||||
/**
|
||||
* Get the number of all specified attributes.
|
||||
*
|
||||
* @return the number of attributes
|
||||
*/
|
||||
virtual PRUint32 GetAttrCount() const = 0;
|
||||
|
||||
/**
|
||||
* Set the focus on this content. This is generally something for the event
|
||||
* state manager to do, not ordinary people. Ordinary people should do
|
||||
* something like nsGenericHTMLElement::SetElementFocus(). This method is
|
||||
* the end result, the point where the content finds out it has been focused.
|
||||
*
|
||||
* All content elements are potentially focusable.
|
||||
*
|
||||
* @param aPresContext the pres context
|
||||
* @see nsGenericHTMLElement::SetElementFocus()
|
||||
*/
|
||||
virtual void SetFocus(nsPresContext* aPresContext)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the focus on this content. This is generally something for the
|
||||
* event state manager to do, not ordinary people. Ordinary people should do
|
||||
* something like nsGenericHTMLElement::SetElementFocus(). This method is
|
||||
* the end result, the point where the content finds out it has been focused.
|
||||
*
|
||||
* All content elements are potentially focusable.
|
||||
*
|
||||
* @param aPresContext the pres context
|
||||
* @see nsGenericHTMLElement::SetElementFocus()
|
||||
*/
|
||||
virtual void RemoveFocus(nsPresContext* aPresContext)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this content is focusable and in the current tab order.
|
||||
* Note: most callers should use nsIFrame::IsFocusable() instead as it
|
||||
* checks visibility and other layout factors as well.
|
||||
* Tabbable is indicated by a nonnegative tabindex & is a subset of focusable.
|
||||
* For example, only the selected radio button in a group is in the
|
||||
* tab order, unless the radio group has no selection in which case
|
||||
* all of the visible, non-disabled radio buttons in the group are
|
||||
* in the tab order. On the other hand, all of the visible, non-disabled
|
||||
* radio buttons are always focusable via clicking or script.
|
||||
* Also, depending on either the accessibility.tabfocus pref or
|
||||
* a system setting (nowadays: Full keyboard access, mac only)
|
||||
* some widgets may be focusable but removed from the tab order.
|
||||
* @param [inout, optional] aTabIndex the computed tab index
|
||||
* In: default tabindex for element (-1 nonfocusable, == 0 focusable)
|
||||
* Out: computed tabindex
|
||||
* @param [optional] aTabIndex the computed tab index
|
||||
* < 0 if not tabbable
|
||||
* == 0 if in normal tab order
|
||||
* > 0 can be tabbed to in the order specified by this value
|
||||
* @return whether the content is focusable via mouse, kbd or script.
|
||||
*/
|
||||
virtual PRBool IsFocusable(PRInt32 *aTabIndex = nsnull)
|
||||
{
|
||||
if (aTabIndex)
|
||||
*aTabIndex = -1; // Default, not tabbable
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get desired IME state for the content.
|
||||
*
|
||||
* @return The desired IME status for the content.
|
||||
* This is a combination of IME_STATUS_* flags,
|
||||
* controlling what happens to IME when the content takes focus.
|
||||
* If this is IME_STATUS_NONE, IME remains in its current state.
|
||||
* IME_STATUS_ENABLE and IME_STATUS_DISABLE must not be set
|
||||
* together; likewise IME_STATUS_OPEN and IME_STATUS_CLOSE must
|
||||
* not be set together.
|
||||
* If you return IME_STATUS_DISABLE, you should not set the
|
||||
* OPEN or CLOSE flag; that way, when IME is next enabled,
|
||||
* the previous OPEN/CLOSE state will be restored (unless the newly
|
||||
* focused content specifies the OPEN/CLOSE state by setting the OPEN
|
||||
* or CLOSE flag with the ENABLE flag).
|
||||
*/
|
||||
enum {
|
||||
IME_STATUS_NONE = 0x0000,
|
||||
IME_STATUS_ENABLE = 0x0001,
|
||||
IME_STATUS_DISABLE = 0x0002,
|
||||
IME_STATUS_OPEN = 0x0004,
|
||||
IME_STATUS_CLOSE = 0x0008
|
||||
};
|
||||
enum {
|
||||
IME_STATUS_MASK_ENABLED = IME_STATUS_ENABLE | IME_STATUS_DISABLE,
|
||||
IME_STATUS_MASK_OPENED = IME_STATUS_OPEN | IME_STATUS_CLOSE
|
||||
};
|
||||
virtual PRUint32 GetDesiredIMEState()
|
||||
{
|
||||
return IME_STATUS_DISABLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets content node with the binding responsible for our construction (and
|
||||
* existence). Used by anonymous content (XBL-generated). null for all
|
||||
* explicit content.
|
||||
*
|
||||
* @return the binding parent
|
||||
*/
|
||||
virtual nsIContent *GetBindingParent() const = 0;
|
||||
|
||||
/**
|
||||
* Get the base URI for any relative URIs within this piece of
|
||||
* content. Generally, this is the document's base URI, but certain
|
||||
* content carries a local base for backward compatibility, and XML
|
||||
* supports setting a per-node base URI.
|
||||
*
|
||||
* @return the base URI
|
||||
*/
|
||||
virtual already_AddRefed<nsIURI> GetBaseURI() const = 0;
|
||||
|
||||
/**
|
||||
* This method is called when the parser finishes creating the element. This
|
||||
* particularly means that it has done everything you would expect it to have
|
||||
* done after it encounters the > at the end of the tag (for HTML or XML).
|
||||
* This includes setting the attributes, setting the document / form, and
|
||||
* placing the element into the tree at its proper place.
|
||||
*
|
||||
* For container elements, this is called *before* any of the children are
|
||||
* created or added into the tree.
|
||||
*
|
||||
* NOTE: this is currently only called for input and button, in the HTML
|
||||
* content sink. If you want to call it on your element, modify the content
|
||||
* sink of your choice to do so. This is an efficiency measure.
|
||||
*
|
||||
* If you also need to determine whether the parser is the one creating your
|
||||
* element (through createElement() or cloneNode() generally) then add a
|
||||
* boolean aFromParser to the NS_NewXXX() constructor for your element and
|
||||
* have the parser pass true. See nsHTMLInputElement.cpp and
|
||||
* nsHTMLContentSink::MakeContentObject().
|
||||
*
|
||||
* DO NOT USE THIS METHOD to get around the fact that it's hard to deal with
|
||||
* attributes dynamically. If you make attributes affect your element from
|
||||
* this method, it will only happen on initialization and JavaScript will not
|
||||
* be able to create elements (which requires them to first create the
|
||||
* element and then call setAttribute() directly, at which point
|
||||
* DoneCreatingElement() has already been called and is out of the picture).
|
||||
*/
|
||||
virtual void DoneCreatingElement()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Call to let the content node know that it may now have a frame.
|
||||
* The content node may use this to determine what MayHaveFrame
|
||||
* returns.
|
||||
*/
|
||||
virtual void SetMayHaveFrame(PRBool aMayHaveFrame)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns PR_TRUE if there is a chance that the content node has a
|
||||
* frame.
|
||||
* @returns PR_FALSE otherwise.
|
||||
*/
|
||||
virtual PRBool MayHaveFrame() const
|
||||
{
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called when the parser begins creating the element's
|
||||
* children, if any are present.
|
||||
*
|
||||
* This is only called for XTF elements currently.
|
||||
*/
|
||||
virtual void BeginAddingChildren()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called when the parser finishes creating the element's children,
|
||||
* if any are present.
|
||||
*
|
||||
* NOTE: this is currently only called for textarea, select, applet, and
|
||||
* object elements in the HTML content sink. If you want
|
||||
* to call it on your element, modify the content sink of your
|
||||
* choice to do so. This is an efficiency measure.
|
||||
*
|
||||
* If you also need to determine whether the parser is the one creating your
|
||||
* element (through createElement() or cloneNode() generally) then add a
|
||||
* boolean aFromParser to the NS_NewXXX() constructor for your element and
|
||||
* have the parser pass true. See nsHTMLInputElement.cpp and
|
||||
* nsHTMLContentSink::MakeContentObject().
|
||||
*
|
||||
* @param aHaveNotified Whether there has been a
|
||||
* ContentInserted/ContentAppended notification for this content node
|
||||
* yet.
|
||||
*/
|
||||
virtual void DoneAddingChildren(PRBool aHaveNotified)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* For HTML textarea, select, applet, and object elements, returns
|
||||
* PR_TRUE if all children have been added OR if the element was not
|
||||
* created by the parser. Returns PR_TRUE for all other elements.
|
||||
* @returns PR_FALSE if the element was created by the parser and
|
||||
* it is an HTML textarea, select, applet, or object
|
||||
* element and not all children have been added.
|
||||
* @returns PR_TRUE otherwise.
|
||||
*/
|
||||
virtual PRBool IsDoneAddingChildren()
|
||||
{
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the _intrinsic_ content state of this content node. This is
|
||||
* the state that is independent of the node's presentation. To get the full
|
||||
* content state, use nsIEventStateManager. Also see nsIEventStateManager
|
||||
* for the possible bits that could be set here.
|
||||
*/
|
||||
// XXXbz this is PRInt32 because all the ESM content state APIs use
|
||||
// PRInt32. We should really use PRUint32 instead.
|
||||
virtual PRInt32 IntrinsicState() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clones this node, using aNodeInfoManager to get the nodeinfo for the
|
||||
* clone. When cloning an element, all attributes of the element will be
|
||||
* cloned. If aDeep is set, all descendants will also be cloned (by calling
|
||||
* the DOM method cloneNode on them if aNodeInfoManager is the same as
|
||||
* the nodeinfo manager of the mNodeInfo of this content node or by calling
|
||||
* the DOM method importNode if they differ).
|
||||
*
|
||||
* @param aNodeInfoManager the nodeinfo manager to get the nodeinfo for the
|
||||
* clone, it should not be null
|
||||
* @param aDeep whether to clone the descendants of this node
|
||||
*/
|
||||
virtual nsresult CloneContent(nsNodeInfoManager *aNodeInfoManager,
|
||||
PRBool aDeep, nsIContent **aResult) const = 0;
|
||||
|
||||
/**
|
||||
* Get the ID of this content node (the atom corresponding to the
|
||||
* value of the null-namespace attribute whose name is given by
|
||||
* GetIDAttributeName(). This may be null if there is no ID.
|
||||
*/
|
||||
virtual nsIAtom* GetID() const = 0;
|
||||
|
||||
/**
|
||||
* Get the class list of this content node (this corresponds to the
|
||||
* value of the null-namespace attribute whose name is given by
|
||||
* GetClassAttributeName(). This may be null if there are no
|
||||
* classes, but that's not guaranteed.
|
||||
*/
|
||||
virtual const nsAttrValue* GetClasses() const = 0;
|
||||
|
||||
/**
|
||||
* Walk aRuleWalker over the content style rules (presentational
|
||||
* hint rules) for this content node.
|
||||
*/
|
||||
NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker) = 0;
|
||||
|
||||
/**
|
||||
* Get the inline style rule, if any, for this content node
|
||||
*/
|
||||
virtual nsICSSStyleRule* GetInlineStyleRule() = 0;
|
||||
|
||||
/**
|
||||
* Set the inline style rule for this node. This will send an
|
||||
* appropriate AttributeChanged notification if aNotify is true.
|
||||
*/
|
||||
NS_IMETHOD SetInlineStyleRule(nsICSSStyleRule* aStyleRule, PRBool aNotify) = 0;
|
||||
|
||||
/**
|
||||
* Is the attribute named stored in the mapped attributes?
|
||||
*
|
||||
* // XXXbz we use this method in HasAttributeDependentStyle, so svg
|
||||
* returns true here even though it stores nothing in the mapped
|
||||
* attributes.
|
||||
*/
|
||||
NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const = 0;
|
||||
|
||||
/**
|
||||
* Get a hint that tells the style system what to do when
|
||||
* an attribute on this node changes, if something needs to happen
|
||||
* in response to the change *other* than the result of what is
|
||||
* mapped into style data via any type of style rule.
|
||||
*/
|
||||
virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,
|
||||
PRInt32 aModType) const = 0;
|
||||
|
||||
/**
|
||||
* Returns an atom holding the name of the "class" attribute on this
|
||||
* content node (if applicable). Returns null if there is no
|
||||
* "class" attribute for this type of content node.
|
||||
*/
|
||||
virtual nsIAtom *GetClassAttributeName() const = 0;
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
/**
|
||||
* List the content (and anything it contains) out to the given
|
||||
* file stream. Use aIndent as the base indent during formatting.
|
||||
*/
|
||||
virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const = 0;
|
||||
|
||||
/**
|
||||
* Dump the content (and anything it contains) out to the given
|
||||
* file stream. Use aIndent as the base indent during formatting.
|
||||
*/
|
||||
virtual void DumpContent(FILE* out = stdout, PRInt32 aIndent = 0,
|
||||
PRBool aDumpAll = PR_TRUE) const = 0;
|
||||
#endif
|
||||
|
||||
enum ETabFocusType {
|
||||
//eTabFocus_textControlsMask = (1<<0), // unused - textboxes always tabbable
|
||||
eTabFocus_formElementsMask = (1<<1), // non-text form elements
|
||||
eTabFocus_linksMask = (1<<2), // links
|
||||
eTabFocus_any = 1 + (1<<1) + (1<<2) // everything that can be focused
|
||||
};
|
||||
|
||||
// Tab focus model bit field:
|
||||
static PRInt32 sTabFocusModel;
|
||||
|
||||
// accessibility.tabfocus_applies_to_xul pref - if it is set to true,
|
||||
// the tabfocus bit field applies to xul elements.
|
||||
static PRBool sTabFocusModelAppliesToXUL;
|
||||
|
||||
#endif // MOZILLA_INTERNAL_API
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIContent, NS_ICONTENT_IID)
|
||||
|
||||
#endif /* nsIContent_h___ */
|
||||
@@ -1,121 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __nsIContentIterator_h___
|
||||
#define __nsIContentIterator_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIContent;
|
||||
class nsIDOMRange;
|
||||
|
||||
#define NS_ICONTENTITERTOR_IID \
|
||||
{0xa6cf90e4, 0x15b3, 0x11d2, \
|
||||
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
|
||||
|
||||
// {B4BC9F63-D9BA-11d3-9938-00108301233C}
|
||||
#define NS_IGENERATEDCONTENTITERTOR_IID \
|
||||
{ 0xb4bc9f63, 0xd9ba, 0x11d3, \
|
||||
{ 0x99, 0x38, 0x0, 0x10, 0x83, 0x1, 0x23, 0x3c } }
|
||||
|
||||
|
||||
class nsIContentIterator : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICONTENTITERTOR_IID)
|
||||
|
||||
/* Initializes an iterator for the subtree rooted by the node aRoot
|
||||
*/
|
||||
virtual nsresult Init(nsIContent* aRoot) = 0;
|
||||
|
||||
/* Initializes an iterator for the subtree defined by the range aRange
|
||||
*/
|
||||
virtual nsresult Init(nsIDOMRange* aRange) = 0;
|
||||
|
||||
/** First will reset the list.
|
||||
*/
|
||||
virtual void First() = 0;
|
||||
|
||||
/** Last will reset the list to the end.
|
||||
*/
|
||||
virtual void Last() = 0;
|
||||
|
||||
/** Next will advance the list.
|
||||
*/
|
||||
virtual void Next() = 0;
|
||||
|
||||
/** Prev will decrement the list.
|
||||
*/
|
||||
virtual void Prev() = 0;
|
||||
|
||||
/** CurrentItem will return the current item, or null if the list is empty
|
||||
* @return the current node
|
||||
*/
|
||||
virtual nsIContent *GetCurrentNode() = 0;
|
||||
|
||||
/** return if the collection is at the end. that is the beginning following a call to Prev
|
||||
* and it is the end of the list following a call to next
|
||||
* @return if the iterator is done.
|
||||
*/
|
||||
virtual PRBool IsDone() = 0;
|
||||
|
||||
/** PositionAt will position the iterator to the supplied node
|
||||
*/
|
||||
virtual nsresult PositionAt(nsIContent* aCurNode) = 0;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIContentIterator, NS_ICONTENTITERTOR_IID)
|
||||
|
||||
class nsIPresShell;
|
||||
|
||||
class nsIGeneratedContentIterator : public nsISupports {
|
||||
public:
|
||||
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IGENERATEDCONTENTITERTOR_IID)
|
||||
|
||||
/* Initializes an iterator for the subtree rooted by the node aRoot
|
||||
*/
|
||||
virtual nsresult Init(nsIPresShell *aShell, nsIDOMRange* aRange) = 0;
|
||||
|
||||
virtual nsresult Init(nsIPresShell *aShell, nsIContent* aContent) = 0;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIGeneratedContentIterator,
|
||||
NS_IGENERATEDCONTENTITERTOR_IID)
|
||||
|
||||
#endif // __nsIContentIterator_h___
|
||||
|
||||
@@ -1,246 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ft=cpp tw=78 sw=2 et ts=8 : */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Zero-Knowledge Systems, Inc.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Timothy Watt <riceman+bmo@mail.rit.edu>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIURI;
|
||||
interface nsIDOMNode;
|
||||
|
||||
/**
|
||||
* Interface for content policy mechanism. Implementations of this
|
||||
* interface can be used to control loading of various types of out-of-line
|
||||
* content, or processing of certain types of in-line content.
|
||||
*
|
||||
* WARNING: do not block the caller from shouldLoad or shouldProcess (e.g.,
|
||||
* by launching a dialog to prompt the user for something).
|
||||
*/
|
||||
|
||||
[scriptable,uuid(3bb1a3c8-3073-41e0-9a26-a7671955fb65)]
|
||||
interface nsIContentPolicy : nsISupports
|
||||
{
|
||||
const unsigned long TYPE_OTHER = 1;
|
||||
|
||||
/**
|
||||
* Indicates an executable script (such as JavaScript).
|
||||
*/
|
||||
const unsigned long TYPE_SCRIPT = 2;
|
||||
|
||||
/**
|
||||
* Indicates an image (e.g., IMG elements).
|
||||
*/
|
||||
const unsigned long TYPE_IMAGE = 3;
|
||||
|
||||
/**
|
||||
* Indicates a stylesheet (e.g., STYLE elements).
|
||||
*/
|
||||
const unsigned long TYPE_STYLESHEET = 4;
|
||||
|
||||
/**
|
||||
* Indicates a generic object (plugin-handled content typically falls under
|
||||
* this category).
|
||||
*/
|
||||
const unsigned long TYPE_OBJECT = 5;
|
||||
|
||||
/**
|
||||
* Indicates a document at the top-level (i.e., in a browser).
|
||||
*/
|
||||
const unsigned long TYPE_DOCUMENT = 6;
|
||||
|
||||
/**
|
||||
* Indicates a document contained within another document (e.g., IFRAMEs,
|
||||
* FRAMES, and OBJECTs).
|
||||
*/
|
||||
const unsigned long TYPE_SUBDOCUMENT = 7;
|
||||
|
||||
/**
|
||||
* Indicates a timed refresh.
|
||||
*
|
||||
* shouldLoad will never get this, because it does not represent content
|
||||
* to be loaded (the actual load triggered by the refresh will go through
|
||||
* shouldLoad as expected).
|
||||
*
|
||||
* shouldProcess will get this for, e.g., META Refresh elements and HTTP
|
||||
* Refresh headers.
|
||||
*/
|
||||
const unsigned long TYPE_REFRESH = 8;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Returned from shouldLoad or shouldProcess if the load or process request
|
||||
* is rejected based on details of the request.
|
||||
*/
|
||||
const short REJECT_REQUEST = -1;
|
||||
|
||||
/**
|
||||
* Returned from shouldLoad or shouldProcess if the load/process is rejected
|
||||
* based solely on its type (of the above flags).
|
||||
*
|
||||
* NOTE that it is not meant to stop future requests for this type--only the
|
||||
* current request.
|
||||
*/
|
||||
const short REJECT_TYPE = -2;
|
||||
|
||||
/**
|
||||
* Returned from shouldLoad or shouldProcess if the load/process is rejected
|
||||
* based on the server it is hosted on or requested from (aContentLocation or
|
||||
* aRequestOrigin), e.g., if you block an IMAGE because it is served from
|
||||
* goatse.cx (even if you don't necessarily block other types from that
|
||||
* server/domain).
|
||||
*
|
||||
* NOTE that it is not meant to stop future requests for this server--only the
|
||||
* current request.
|
||||
*/
|
||||
const short REJECT_SERVER = -3;
|
||||
|
||||
/**
|
||||
* Returned from shouldLoad or shouldProcess if the load/process is rejected
|
||||
* based on some other criteria. Mozilla callers will handle this like
|
||||
* REJECT_REQUEST; third-party implementors may, for example, use this to
|
||||
* direct their own callers to consult the extra parameter for additional
|
||||
* details.
|
||||
*/
|
||||
const short REJECT_OTHER = -4;
|
||||
|
||||
/**
|
||||
* Returned from shouldLoad or shouldProcess if the load or process request
|
||||
* is not rejected.
|
||||
*/
|
||||
const short ACCEPT = 1;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Should the resource at this location be loaded?
|
||||
* ShouldLoad will be called before loading the resource at aContentLocation
|
||||
* to determine whether to start the load at all.
|
||||
*
|
||||
* @param aContentType the type of content being tested. This will be one
|
||||
* one of the TYPE_* constants.
|
||||
*
|
||||
* @param aContentLocation the location of the content being checked; must
|
||||
* not be null
|
||||
*
|
||||
* @param aRequestOrigin OPTIONAL. the location of the resource that
|
||||
* initiated this load request; can be null if
|
||||
* inapplicable
|
||||
*
|
||||
* @param aContext OPTIONAL. the nsIDOMNode or nsIDOMWindow that
|
||||
* initiated the request, or something that can QI
|
||||
* to one of those; can be null if inapplicable.
|
||||
*
|
||||
* @param aMimeTypeGuess OPTIONAL. a guess for the requested content's
|
||||
* MIME type, based on information available to
|
||||
* the request initiator (e.g., an OBJECT's type
|
||||
* attribute); does not reliably reflect the
|
||||
* actual MIME type of the requested content
|
||||
*
|
||||
* @param aExtra an OPTIONAL argument, pass-through for non-Gecko
|
||||
* callers to pass extra data to callees.
|
||||
*
|
||||
* @return ACCEPT or REJECT_*
|
||||
*
|
||||
* @note shouldLoad can be called while the DOM and layout of the document
|
||||
* involved is in an inconsistent state. This means that implementors of
|
||||
* this method MUST NOT do any of the following:
|
||||
* 1) Modify the DOM in any way (e.g. setting attributes is a no-no).
|
||||
* 2) Query any DOM properties that depend on layout (e.g. offset*
|
||||
* properties).
|
||||
* 3) Query any DOM properties that depend on style (e.g. computed style).
|
||||
* 4) Query any DOM properties that depend on the current state of the DOM
|
||||
* outside the "context" node (e.g. lengths of node lists).
|
||||
* 5) [JavaScript implementations only] Access properties of any sort on any
|
||||
* object without using XPCNativeWrapper (either explicitly or
|
||||
* implicitly). Due to various DOM0 things, this leads to item 4.
|
||||
* If you do any of these things in your shouldLoad implementation, expect
|
||||
* unpredictable behavior, possibly including crashes, content not showing
|
||||
* up, content showing up doubled, etc. If you need to do any of the things
|
||||
* above, do them off timeout or event.
|
||||
*/
|
||||
short shouldLoad(in unsigned long aContentType,
|
||||
in nsIURI aContentLocation,
|
||||
in nsIURI aRequestOrigin,
|
||||
in nsISupports aContext,
|
||||
in ACString aMimeTypeGuess,
|
||||
in nsISupports aExtra);
|
||||
|
||||
/**
|
||||
* Should the resource be processed?
|
||||
* ShouldProcess will be called once all the information passed to it has
|
||||
* been determined about the resource, typically after part of the resource
|
||||
* has been loaded.
|
||||
*
|
||||
* @param aContentType the type of content being tested. This will be one
|
||||
* one of the TYPE_* constants.
|
||||
*
|
||||
* @param aContentLocation OPTIONAL; the location of the resource being
|
||||
* requested: MAY be, e.g., a post-redirection URI
|
||||
* for the resource.
|
||||
*
|
||||
* @param aRequestOrigin OPTIONAL. the location of the resource that
|
||||
* initiated this load request; can be null if
|
||||
* inapplicable
|
||||
*
|
||||
* @param aContext OPTIONAL. the nsIDOMNode or nsIDOMWindow that
|
||||
* initiated the request, or something that can QI
|
||||
* to one of those; can be null if inapplicable.
|
||||
*
|
||||
* @param aMimeType the MIME type of the requested resource (e.g.,
|
||||
* image/png), as reported by the networking library,
|
||||
* if available (may be empty if inappropriate for
|
||||
* the type, e.g., TYPE_REFRESH).
|
||||
*
|
||||
* @param aExtra an OPTIONAL argument, pass-through for non-Gecko
|
||||
* callers to pass extra data to callees.
|
||||
*
|
||||
* @return ACCEPT or REJECT_*
|
||||
*
|
||||
* @note shouldProcess can be called while the DOM and layout of the document
|
||||
* involved is in an inconsistent state. See the note on shouldLoad to see
|
||||
* what this means for implementors of this method.
|
||||
*/
|
||||
short shouldProcess(in unsigned long aContentType,
|
||||
in nsIURI aContentLocation,
|
||||
in nsIURI aRequestOrigin,
|
||||
in nsISupports aContext,
|
||||
in ACString aMimeType,
|
||||
in nsISupports aExtra);
|
||||
|
||||
};
|
||||
@@ -1,110 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _nsIContentSerializer_h__
|
||||
#define _nsIContentSerializer_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIDOMText; /* forward declaration */
|
||||
class nsIDOMCDATASection; /* forward declaration */
|
||||
class nsIDOMProcessingInstruction; /* forward declaration */
|
||||
class nsIDOMComment; /* forward declaration */
|
||||
class nsIDOMDocumentType; /* forward declaration */
|
||||
class nsIDOMElement; /* forward declaration */
|
||||
class nsIDOMDocument; /* forward declaration */
|
||||
class nsAString;
|
||||
|
||||
/* starting interface: nsIContentSerializer */
|
||||
|
||||
/* d650439a-ca29-410d-a906-b0557fb62fcd */
|
||||
#define NS_ICONTENTSERIALIZER_IID \
|
||||
{ 0xd650439a, \
|
||||
0xca29, \
|
||||
0x410d, \
|
||||
{0xa9, 0x06, 0xb0, 0x55, 0x7f, 0xb6, 0x2f, 0xcd} }
|
||||
|
||||
class nsIContentSerializer : public nsISupports {
|
||||
public:
|
||||
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICONTENTSERIALIZER_IID)
|
||||
|
||||
NS_IMETHOD Init(PRUint32 flags, PRUint32 aWrapColumn,
|
||||
const char* aCharSet, PRBool aIsCopying) = 0;
|
||||
|
||||
NS_IMETHOD AppendText(nsIDOMText* aText, PRInt32 aStartOffset,
|
||||
PRInt32 aEndOffset, nsAString& aStr) = 0;
|
||||
|
||||
NS_IMETHOD AppendCDATASection(nsIDOMCDATASection* aCDATASection,
|
||||
PRInt32 aStartOffset, PRInt32 aEndOffset,
|
||||
nsAString& aStr) = 0;
|
||||
|
||||
NS_IMETHOD AppendProcessingInstruction(nsIDOMProcessingInstruction* aPI,
|
||||
PRInt32 aStartOffset,
|
||||
PRInt32 aEndOffset,
|
||||
nsAString& aStr) = 0;
|
||||
|
||||
NS_IMETHOD AppendComment(nsIDOMComment* aComment, PRInt32 aStartOffset,
|
||||
PRInt32 aEndOffset, nsAString& aStr) = 0;
|
||||
|
||||
NS_IMETHOD AppendDoctype(nsIDOMDocumentType *aDoctype,
|
||||
nsAString& aStr) = 0;
|
||||
|
||||
NS_IMETHOD AppendElementStart(nsIDOMElement *aElement,
|
||||
nsIDOMElement *aOriginalElement,
|
||||
nsAString& aStr) = 0;
|
||||
|
||||
NS_IMETHOD AppendElementEnd(nsIDOMElement *aElement,
|
||||
nsAString& aStr) = 0;
|
||||
|
||||
NS_IMETHOD Flush(nsAString& aStr) = 0;
|
||||
|
||||
/**
|
||||
* Append any items in the beginning of the document that won't be
|
||||
* serialized by other methods. XML declaration is the most likely
|
||||
* thing this method can produce.
|
||||
*/
|
||||
NS_IMETHOD AppendDocumentStart(nsIDOMDocument *aDocument,
|
||||
nsAString& aStr) = 0;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIContentSerializer, NS_ICONTENTSERIALIZER_IID)
|
||||
|
||||
#define NS_CONTENTSERIALIZER_CONTRACTID_PREFIX \
|
||||
"@mozilla.org/layout/contentserializer;1?mimetype="
|
||||
|
||||
#endif /* __gen_nsIContentSerializer_h__ */
|
||||
@@ -1,95 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998-1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsIDOMGCParticipant_h_
|
||||
#define nsIDOMGCParticipant_h_
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
template<class E> class nsCOMArray;
|
||||
|
||||
// 0e2a5a8d-28fd-4a5c-8bf1-5b0067ff3286
|
||||
#define NS_IDOMGCPARTICIPANT_IID \
|
||||
{ 0x0e2a5a8d, 0x28fd, 0x4a5c, \
|
||||
{0x8b, 0xf1, 0x5b, 0x00, 0x67, 0xff, 0x32, 0x86} }
|
||||
|
||||
/**
|
||||
* DOM GC Participants are objects that expose information about
|
||||
* reachability in the native object graphs to help prevent script ->
|
||||
* native -> script cyclical reference from causing leaks due to the
|
||||
* creation of garbage collection roots and native/script boundaries.
|
||||
*
|
||||
* Some implementations of nsIDOMGCParticipant may be responsible for
|
||||
* enforcing the requirement that callers of
|
||||
* |nsDOMClassInfo::PreserveWrapper| must call
|
||||
* |nsDOMClassInfo::ReleaseWrapper| before the nsIDOMGCParticipant
|
||||
* argument to the former is destroyed.
|
||||
*/
|
||||
class nsIDOMGCParticipant : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOMGCPARTICIPANT_IID)
|
||||
|
||||
/**
|
||||
* Get a reference node for what is known to be a strongly connected
|
||||
* component of nsIDOMGCParticipants. For example, DOM trees are
|
||||
* strongly connected, so can return the root node to greatly reduce
|
||||
* the number of nodes on which we need to run graph algorithms.
|
||||
*
|
||||
* Note that it's acceptable for nodes in a single strongly connected
|
||||
* component to return different values for GetSCCIndex, as long as
|
||||
* those two values claim that they're reachable from each other in
|
||||
* AppendReachableList.
|
||||
*/
|
||||
virtual nsIDOMGCParticipant* GetSCCIndex() = 0;
|
||||
|
||||
/**
|
||||
* Append the list of nsIDOMGCPartipants reachable from this one via
|
||||
* C++ getters exposed to script that return a different result from
|
||||
* |GetSCCIndex|. The caller is responsible for taking the transitive
|
||||
* closure of |AppendReachableList|.
|
||||
*
|
||||
* This will only be called on objects that are returned by GetSCCIndex.
|
||||
*
|
||||
* null pointers may be appended; they will be ignored by the caller.
|
||||
*/
|
||||
virtual void AppendReachableList(nsCOMArray<nsIDOMGCParticipant>& aArray) = 0;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIDOMGCParticipant, NS_IDOMGCPARTICIPANT_IID)
|
||||
|
||||
#endif // !defined(nsIDOMGCParticipant_h_)
|
||||
@@ -1,111 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIInputStream;
|
||||
interface nsIDOMDocument;
|
||||
interface nsIURI;
|
||||
|
||||
/**
|
||||
* The nsIDOMParser interface is a non-SAX interface that can be used
|
||||
* to parse a string or byte stream containing XML or HTML content
|
||||
* to a DOM document. Parsing is always synchronous - a document is always
|
||||
* returned from the parsing methods. This is as opposed to loading and
|
||||
* parsing with the XMLHttpRequest interface, which can be used for
|
||||
* asynchronous (callback-based) loading.
|
||||
*/
|
||||
|
||||
[scriptable, uuid(4f45513e-55e5-411c-a844-e899057026c1)]
|
||||
interface nsIDOMParser : nsISupports {
|
||||
|
||||
/**
|
||||
* The string passed in is parsed into a DOM document.
|
||||
*
|
||||
* @param str The UTF16 string to be parsed
|
||||
* @param contentType The content type of the string (see parseFromStream)
|
||||
* @returns The DOM document created as a result of parsing the
|
||||
* string
|
||||
*/
|
||||
nsIDOMDocument parseFromString(in wstring str, in string contentType);
|
||||
|
||||
/**
|
||||
* The buffer is parsed into a DOM document.
|
||||
* The charset is determined from the xml entity decl.
|
||||
*
|
||||
* @param buf The octet array data to be parsed
|
||||
* @param bufLen Length (in bytes) of the data
|
||||
* @param contentType The content type of the data (see parseFromStream)
|
||||
* @returns The DOM document created as a result of parsing the
|
||||
* string
|
||||
*/
|
||||
nsIDOMDocument parseFromBuffer([const,array,size_is(bufLen)] in octet buf, in PRUint32 bufLen, in string contentType);
|
||||
|
||||
/**
|
||||
* The byte stream passed in is parsed into a DOM document.
|
||||
*
|
||||
* Not accessible from web content.
|
||||
*
|
||||
* @param stream The byte stream whose contents are parsed
|
||||
* @param charset The character set that was used to encode the byte
|
||||
* stream. NULL if not specified.
|
||||
* @param contentLength The number of bytes in the input stream.
|
||||
* @param contentType The content type of the string - either text/xml,
|
||||
* application/xml, or application/xhtml+xml.
|
||||
* Must not be NULL.
|
||||
* @returns The DOM document created as a result of parsing the
|
||||
* stream
|
||||
*/
|
||||
nsIDOMDocument parseFromStream(in nsIInputStream stream,
|
||||
in string charset,
|
||||
in long contentLength,
|
||||
in string contentType);
|
||||
|
||||
/**
|
||||
* Set/Get the baseURI, may be needed when called from native code.
|
||||
*/
|
||||
[noscript] attribute nsIURI baseURI;
|
||||
};
|
||||
|
||||
%{ C++
|
||||
#define NS_DOMPARSER_CID \
|
||||
{ /* 3a8a3a50-512c-11d4-9a54-000064657374 */ \
|
||||
0x3a8a3a50, 0x512c, 0x11d4, \
|
||||
{0x9a, 0x54, 0x00, 0x00, 0x64, 0x65, 0x73, 0x74} }
|
||||
#define NS_DOMPARSER_CONTRACTID \
|
||||
"@mozilla.org/xmlextras/domparser;1"
|
||||
%}
|
||||
@@ -1,84 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIOutputStream;
|
||||
interface nsIDOMNode;
|
||||
|
||||
/**
|
||||
* The nsIDOMSerializer interface is really a placeholder till the W3C
|
||||
* DOM Working Group defines a mechanism for serializing DOM nodes.
|
||||
* An instance of this interface can be used to serialize a DOM document
|
||||
* or any DOM subtree.
|
||||
*/
|
||||
|
||||
[scriptable, uuid(9fd4ba15-e67c-4c98-b52c-7715f62c9196)]
|
||||
interface nsIDOMSerializer : nsISupports
|
||||
{
|
||||
/**
|
||||
* The subtree rooted by the specified element is serialized to
|
||||
* a string.
|
||||
*
|
||||
* @param root The root of the subtree to be serialized. This could
|
||||
* be any node, including a Document.
|
||||
* @returns The serialized subtree in the form of a Unicode string
|
||||
*/
|
||||
AString serializeToString(in nsIDOMNode root);
|
||||
|
||||
/**
|
||||
* The subtree rooted by the specified element is serialized to
|
||||
* a byte stream using the character set specified.
|
||||
* @param root The root of the subtree to be serialized. This could
|
||||
* be any node, including a Document.
|
||||
* @param stream The byte stream to which the subtree is serialized.
|
||||
* @param charset The name of the character set to use for the encoding
|
||||
* to a byte stream.
|
||||
*/
|
||||
void serializeToStream(in nsIDOMNode root, in nsIOutputStream stream,
|
||||
in AUTF8String charset);
|
||||
};
|
||||
|
||||
%{ C++
|
||||
#define NS_XMLSERIALIZER_CID \
|
||||
{ /* a6cf9124-15b3-11d2-932e-00805f8add32 */ \
|
||||
0xa6cf9124, 0x15b3, 0x11d2, \
|
||||
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
|
||||
#define NS_XMLSERIALIZER_CONTRACTID \
|
||||
"@mozilla.org/xmlextras/xmlserializer;1"
|
||||
%}
|
||||
|
||||
@@ -1,931 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsIDocument_h___
|
||||
#define nsIDocument_h___
|
||||
|
||||
#include "nsINode.h"
|
||||
#include "nsStringGlue.h"
|
||||
#include "nsIDocumentObserver.h" // for nsUpdateType
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIBindingManager.h"
|
||||
#include "nsWeakPtr.h"
|
||||
#include "nsIWeakReferenceUtils.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsCRT.h"
|
||||
#include "mozFlushType.h"
|
||||
#include "nsIAtom.h"
|
||||
|
||||
class nsIContent;
|
||||
class nsPresContext;
|
||||
class nsIPresShell;
|
||||
|
||||
class nsIStreamListener;
|
||||
class nsIStreamObserver;
|
||||
class nsStyleSet;
|
||||
class nsIStyleSheet;
|
||||
class nsIStyleRule;
|
||||
class nsIViewManager;
|
||||
class nsIScriptGlobalObject;
|
||||
class nsPIDOMWindow;
|
||||
class nsIDOMEvent;
|
||||
class nsIDeviceContext;
|
||||
class nsIParser;
|
||||
class nsIDOMNode;
|
||||
class nsIDOMDocumentFragment;
|
||||
class nsILineBreaker;
|
||||
class nsIWordBreaker;
|
||||
class nsISelection;
|
||||
class nsIChannel;
|
||||
class nsIPrincipal;
|
||||
class nsIDOMDocument;
|
||||
class nsIDOMDocumentType;
|
||||
class nsIObserver;
|
||||
class nsISupportsArray;
|
||||
class nsIScriptLoader;
|
||||
class nsIContentSink;
|
||||
class nsIScriptEventManager;
|
||||
class nsNodeInfoManager;
|
||||
class nsICSSLoader;
|
||||
class nsHTMLStyleSheet;
|
||||
class nsIHTMLCSSStyleSheet;
|
||||
class nsILayoutHistoryState;
|
||||
class nsIVariant;
|
||||
class nsIDOMUserDataHandler;
|
||||
template<class E> class nsCOMArray;
|
||||
class nsIDocumentObserver;
|
||||
|
||||
// IID for the nsIDocument interface
|
||||
#define NS_IDOCUMENT_IID \
|
||||
{ 0xffa1f165, 0x8b0e, 0x4010, \
|
||||
{ 0xb6, 0xec, 0x6f, 0x49, 0x6b, 0x1b, 0x30, 0x3a } }
|
||||
|
||||
// Flag for AddStyleSheet().
|
||||
#define NS_STYLESHEET_FROM_CATALOG (1 << 0)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// Document interface. This is implemented by all document objects in
|
||||
// Gecko.
|
||||
class nsIDocument : public nsINode
|
||||
{
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOCUMENT_IID)
|
||||
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
|
||||
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
nsIDocument()
|
||||
: nsINode(nsnull),
|
||||
mCharacterSet(NS_LITERAL_CSTRING("ISO-8859-1")),
|
||||
mNodeInfoManager(nsnull),
|
||||
mPartID(0)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Let the document know that we're starting to load data into it.
|
||||
* @param aCommand The parser command
|
||||
* XXXbz It's odd to have that here.
|
||||
* @param aChannel The channel the data will come from
|
||||
* @param aLoadGroup The loadgroup this document should use from now on.
|
||||
* Note that the document might not be the only thing using
|
||||
* this loadgroup.
|
||||
* @param aContainer The container this document is in. This may be null.
|
||||
* XXXbz maybe we should make it more explicit (eg make the
|
||||
* container an nsIWebNavigation or nsIDocShell or
|
||||
* something)?
|
||||
* @param [out] aDocListener the listener to pump data from the channel into.
|
||||
* Generally this will be the parser this document
|
||||
* sets up, or some sort of data-handler for media
|
||||
* documents.
|
||||
* @param aReset whether the document should call Reset() on itself. If this
|
||||
* is false, the document will NOT set its principal to the
|
||||
* channel's owner, will not clear any event listeners that are
|
||||
* already set on it, etc.
|
||||
* @param aSink The content sink to use for the data. If this is null and
|
||||
* the document needs a content sink, it will create one based
|
||||
* on whatever it knows about the data it's going to load.
|
||||
*/
|
||||
virtual nsresult StartDocumentLoad(const char* aCommand,
|
||||
nsIChannel* aChannel,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsISupports* aContainer,
|
||||
nsIStreamListener **aDocListener,
|
||||
PRBool aReset,
|
||||
nsIContentSink* aSink = nsnull) = 0;
|
||||
virtual void StopDocumentLoad() = 0;
|
||||
|
||||
/**
|
||||
* Return the title of the document. This will return a void string
|
||||
* if there is no title for this document).
|
||||
*/
|
||||
const nsString& GetDocumentTitle() const
|
||||
{
|
||||
return mDocumentTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the URI for the document. May return null.
|
||||
*/
|
||||
nsIURI* GetDocumentURI() const
|
||||
{
|
||||
return mDocumentURI;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the URI for the document.
|
||||
*/
|
||||
virtual void SetDocumentURI(nsIURI* aURI) = 0;
|
||||
|
||||
/**
|
||||
* Set the principal responsible for this document.
|
||||
*/
|
||||
virtual void SetPrincipal(nsIPrincipal *aPrincipal) = 0;
|
||||
|
||||
/**
|
||||
* Return the LoadGroup for the document. May return null.
|
||||
*/
|
||||
already_AddRefed<nsILoadGroup> GetDocumentLoadGroup() const
|
||||
{
|
||||
nsILoadGroup *group = nsnull;
|
||||
if (mDocumentLoadGroup)
|
||||
CallQueryReferent(mDocumentLoadGroup.get(), &group);
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the base URI for relative URIs in the document (the document uri
|
||||
* unless it's overridden by SetBaseURI, HTML <base> tags, etc.). The
|
||||
* returned URI could be null if there is no document URI.
|
||||
*/
|
||||
nsIURI* GetBaseURI() const
|
||||
{
|
||||
return mDocumentBaseURI ? mDocumentBaseURI : mDocumentURI;
|
||||
}
|
||||
virtual nsresult SetBaseURI(nsIURI* aURI) = 0;
|
||||
|
||||
/**
|
||||
* Get/Set the base target of a link in a document.
|
||||
*/
|
||||
virtual void GetBaseTarget(nsAString &aBaseTarget) const = 0;
|
||||
virtual void SetBaseTarget(const nsAString &aBaseTarget) = 0;
|
||||
|
||||
/**
|
||||
* Return a standard name for the document's character set. This
|
||||
* will trigger a startDocumentLoad if necessary to answer the
|
||||
* question.
|
||||
*/
|
||||
const nsCString& GetDocumentCharacterSet() const
|
||||
{
|
||||
return mCharacterSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the document's character encoding. |aCharSetID| should be canonical.
|
||||
* That is, callers are responsible for the charset alias resolution.
|
||||
*/
|
||||
virtual void SetDocumentCharacterSet(const nsACString& aCharSetID) = 0;
|
||||
|
||||
PRInt32 GetDocumentCharacterSetSource() const
|
||||
{
|
||||
return mCharacterSetSource;
|
||||
}
|
||||
|
||||
void SetDocumentCharacterSetSource(PRInt32 aCharsetSource)
|
||||
{
|
||||
mCharacterSetSource = aCharsetSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an observer that gets notified whenever the charset changes.
|
||||
*/
|
||||
virtual nsresult AddCharSetObserver(nsIObserver* aObserver) = 0;
|
||||
|
||||
/**
|
||||
* Remove a charset observer.
|
||||
*/
|
||||
virtual void RemoveCharSetObserver(nsIObserver* aObserver) = 0;
|
||||
|
||||
/**
|
||||
* Get the Content-Type of this document.
|
||||
* (This will always return NS_OK, but has this signature to be compatible
|
||||
* with nsIDOMNSDocument::GetContentType())
|
||||
*/
|
||||
NS_IMETHOD GetContentType(nsAString& aContentType) = 0;
|
||||
|
||||
/**
|
||||
* Set the Content-Type of this document.
|
||||
*/
|
||||
virtual void SetContentType(const nsAString& aContentType) = 0;
|
||||
|
||||
/**
|
||||
* Return the language of this document.
|
||||
*/
|
||||
void GetContentLanguage(nsAString& aContentLanguage) const
|
||||
{
|
||||
CopyASCIItoUTF16(mContentLanguage, aContentLanguage);
|
||||
}
|
||||
|
||||
// The state BidiEnabled should persist across multiple views
|
||||
// (screen, print) of the same document.
|
||||
|
||||
/**
|
||||
* Check if the document contains bidi data.
|
||||
* If so, we have to apply the Unicode Bidi Algorithm.
|
||||
*/
|
||||
PRBool GetBidiEnabled() const
|
||||
{
|
||||
return mBidiEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate the document contains bidi data.
|
||||
* Currently, we cannot disable bidi, because once bidi is enabled,
|
||||
* it affects a frame model irreversibly, and plays even though
|
||||
* the document no longer contains bidi data.
|
||||
*/
|
||||
void SetBidiEnabled(PRBool aBidiEnabled)
|
||||
{
|
||||
mBidiEnabled = aBidiEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the bidi options for this document.
|
||||
* @see nsBidiUtils.h
|
||||
*/
|
||||
PRUint32 GetBidiOptions() const
|
||||
{
|
||||
return mBidiOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the bidi options for this document. This just sets the bits;
|
||||
* callers are expected to take action as needed if they want this
|
||||
* change to actually change anything immediately.
|
||||
* @see nsBidiUtils.h
|
||||
*/
|
||||
void SetBidiOptions(PRUint32 aBidiOptions)
|
||||
{
|
||||
mBidiOptions = aBidiOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access HTTP header data (this may also get set from other
|
||||
* sources, like HTML META tags).
|
||||
*/
|
||||
virtual void GetHeaderData(nsIAtom* aHeaderField, nsAString& aData) const = 0;
|
||||
virtual void SetHeaderData(nsIAtom* aheaderField, const nsAString& aData) = 0;
|
||||
|
||||
/**
|
||||
* Create a new presentation shell that will use aContext for its
|
||||
* presentation context (presentation contexts <b>must not</b> be
|
||||
* shared among multiple presentation shells).
|
||||
*/
|
||||
virtual nsresult CreateShell(nsPresContext* aContext,
|
||||
nsIViewManager* aViewManager,
|
||||
nsStyleSet* aStyleSet,
|
||||
nsIPresShell** aInstancePtrResult) = 0;
|
||||
virtual PRBool DeleteShell(nsIPresShell* aShell) = 0;
|
||||
virtual PRUint32 GetNumberOfShells() const = 0;
|
||||
virtual nsIPresShell *GetShellAt(PRUint32 aIndex) const = 0;
|
||||
virtual void SetShellsHidden(PRBool aHide) = 0;
|
||||
|
||||
/**
|
||||
* Return the parent document of this document. Will return null
|
||||
* unless this document is within a compound document and has a
|
||||
* parent. Note that this parent chain may cross chrome boundaries.
|
||||
*/
|
||||
nsIDocument *GetParentDocument() const
|
||||
{
|
||||
return mParentDocument;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the parent document of this document.
|
||||
*/
|
||||
void SetParentDocument(nsIDocument* aParent)
|
||||
{
|
||||
mParentDocument = aParent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the sub document for aContent to aSubDoc.
|
||||
*/
|
||||
virtual nsresult SetSubDocumentFor(nsIContent *aContent,
|
||||
nsIDocument* aSubDoc) = 0;
|
||||
|
||||
/**
|
||||
* Get the sub document for aContent
|
||||
*/
|
||||
virtual nsIDocument *GetSubDocumentFor(nsIContent *aContent) const = 0;
|
||||
|
||||
/**
|
||||
* Find the content node for which aDocument is a sub document.
|
||||
*/
|
||||
virtual nsIContent *FindContentForSubDocument(nsIDocument *aDocument) const = 0;
|
||||
|
||||
/**
|
||||
* Return the root content object for this document.
|
||||
*/
|
||||
nsIContent *GetRootContent() const
|
||||
{
|
||||
return mRootContent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Accessors to the collection of stylesheets owned by this document.
|
||||
* Style sheets are ordered, most significant last.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get the number of stylesheets
|
||||
*
|
||||
* @return the number of stylesheets
|
||||
* @throws no exceptions
|
||||
*/
|
||||
virtual PRInt32 GetNumberOfStyleSheets() const = 0;
|
||||
|
||||
/**
|
||||
* Get a particular stylesheet
|
||||
* @param aIndex the index the stylesheet lives at. This is zero-based
|
||||
* @return the stylesheet at aIndex. Null if aIndex is out of range.
|
||||
* @throws no exceptions
|
||||
*/
|
||||
virtual nsIStyleSheet* GetStyleSheetAt(PRInt32 aIndex) const = 0;
|
||||
|
||||
/**
|
||||
* Insert a sheet at a particular spot in the stylesheet list (zero-based)
|
||||
* @param aSheet the sheet to insert
|
||||
* @param aIndex the index to insert at. This index will be
|
||||
* adjusted for the "special" sheets.
|
||||
* @throws no exceptions
|
||||
*/
|
||||
virtual void InsertStyleSheetAt(nsIStyleSheet* aSheet, PRInt32 aIndex) = 0;
|
||||
|
||||
/**
|
||||
* Get the index of a particular stylesheet. This will _always_
|
||||
* consider the "special" sheets as part of the sheet list.
|
||||
* @param aSheet the sheet to get the index of
|
||||
* @return aIndex the index of the sheet in the full list
|
||||
*/
|
||||
virtual PRInt32 GetIndexOfStyleSheet(nsIStyleSheet* aSheet) const = 0;
|
||||
|
||||
/**
|
||||
* Replace the stylesheets in aOldSheets with the stylesheets in
|
||||
* aNewSheets. The two lists must have equal length, and the sheet
|
||||
* at positon J in the first list will be replaced by the sheet at
|
||||
* position J in the second list. Some sheets in the second list
|
||||
* may be null; if so the corresponding sheets in the first list
|
||||
* will simply be removed.
|
||||
*/
|
||||
virtual void UpdateStyleSheets(nsCOMArray<nsIStyleSheet>& aOldSheets,
|
||||
nsCOMArray<nsIStyleSheet>& aNewSheets) = 0;
|
||||
|
||||
/**
|
||||
* Add a stylesheet to the document
|
||||
*/
|
||||
virtual void AddStyleSheet(nsIStyleSheet* aSheet) = 0;
|
||||
|
||||
/**
|
||||
* Remove a stylesheet from the document
|
||||
*/
|
||||
virtual void RemoveStyleSheet(nsIStyleSheet* aSheet) = 0;
|
||||
|
||||
/**
|
||||
* Notify the document that the applicable state of the sheet changed
|
||||
* and that observers should be notified and style sets updated
|
||||
*/
|
||||
virtual void SetStyleSheetApplicableState(nsIStyleSheet* aSheet,
|
||||
PRBool aApplicable) = 0;
|
||||
|
||||
/**
|
||||
* Just like the style sheet API, but for "catalog" sheets,
|
||||
* extra sheets inserted at the UA level.
|
||||
*/
|
||||
virtual PRInt32 GetNumberOfCatalogStyleSheets() const = 0;
|
||||
virtual nsIStyleSheet* GetCatalogStyleSheetAt(PRInt32 aIndex) const = 0;
|
||||
virtual void AddCatalogStyleSheet(nsIStyleSheet* aSheet) = 0;
|
||||
virtual void EnsureCatalogStyleSheet(const char *aStyleSheetURI) = 0;
|
||||
|
||||
/**
|
||||
* Get this document's CSSLoader. This is guaranteed to not return null.
|
||||
*/
|
||||
nsICSSLoader* CSSLoader() const {
|
||||
return mCSSLoader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channel that was passed to StartDocumentLoad or Reset for this
|
||||
* document. Note that this may be null in some cases (eg if
|
||||
* StartDocumentLoad or Reset were never called)
|
||||
*/
|
||||
virtual nsIChannel* GetChannel() const = 0;
|
||||
|
||||
/**
|
||||
* Get this document's attribute stylesheet. May return null if
|
||||
* there isn't one.
|
||||
*/
|
||||
virtual nsHTMLStyleSheet* GetAttributeStyleSheet() const = 0;
|
||||
|
||||
/**
|
||||
* Get this document's inline style sheet. May return null if there
|
||||
* isn't one
|
||||
*/
|
||||
virtual nsIHTMLCSSStyleSheet* GetInlineStyleSheet() const = 0;
|
||||
|
||||
/**
|
||||
* Get/set the object from which a document can get a script context
|
||||
* and scope. This is the context within which all scripts (during
|
||||
* document creation and during event handling) will run. Note that
|
||||
* this is the *inner* window object.
|
||||
*/
|
||||
virtual nsIScriptGlobalObject* GetScriptGlobalObject() const = 0;
|
||||
virtual void SetScriptGlobalObject(nsIScriptGlobalObject* aGlobalObject) = 0;
|
||||
|
||||
/**
|
||||
* Get the object that is used as the scope for all of the content
|
||||
* wrappers whose owner document is this document. Unlike the script global
|
||||
* object, this will only return null when the global object for this
|
||||
* document is truly gone. Use this object when you're trying to find a
|
||||
* content wrapper in XPConnect.
|
||||
*/
|
||||
virtual nsIScriptGlobalObject* GetScopeObject() = 0;
|
||||
|
||||
/**
|
||||
* Return the window containing the document (the outer window).
|
||||
*/
|
||||
virtual nsPIDOMWindow *GetWindow() = 0;
|
||||
|
||||
/**
|
||||
* Return the inner window used as the script compilation scope for
|
||||
* this document. If you're not absolutely sure you need this, use
|
||||
* GetWindow().
|
||||
*/
|
||||
virtual nsPIDOMWindow *GetInnerWindow() = 0;
|
||||
|
||||
/**
|
||||
* Get the script loader for this document
|
||||
*/
|
||||
virtual nsIScriptLoader* GetScriptLoader() = 0;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// Document notification API's
|
||||
|
||||
/**
|
||||
* Add a new observer of document change notifications. Whenever
|
||||
* content is changed, appended, inserted or removed the observers are
|
||||
* informed.
|
||||
*/
|
||||
virtual void AddObserver(nsIDocumentObserver* aObserver) = 0;
|
||||
|
||||
/**
|
||||
* Remove an observer of document change notifications. This will
|
||||
* return false if the observer cannot be found.
|
||||
*/
|
||||
virtual PRBool RemoveObserver(nsIDocumentObserver* aObserver) = 0;
|
||||
|
||||
// Observation hooks used to propagate notifications to document observers.
|
||||
// BeginUpdate must be called before any batch of modifications of the
|
||||
// content model or of style data, EndUpdate must be called afterward.
|
||||
// To make this easy and painless, use the mozAutoDocUpdate helper class.
|
||||
virtual void BeginUpdate(nsUpdateType aUpdateType) = 0;
|
||||
virtual void EndUpdate(nsUpdateType aUpdateType) = 0;
|
||||
virtual void BeginLoad() = 0;
|
||||
virtual void EndLoad() = 0;
|
||||
virtual void CharacterDataChanged(nsIContent* aContent, PRBool aAppend) = 0;
|
||||
// notify that one or two content nodes changed state
|
||||
// either may be nsnull, but not both
|
||||
virtual void ContentStatesChanged(nsIContent* aContent1,
|
||||
nsIContent* aContent2,
|
||||
PRInt32 aStateMask) = 0;
|
||||
virtual void AttributeWillChange(nsIContent* aChild,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aAttribute) = 0;
|
||||
virtual void AttributeChanged(nsIContent* aChild,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aModType) = 0;
|
||||
virtual void ContentAppended(nsIContent* aContainer,
|
||||
PRInt32 aNewIndexInContainer) = 0;
|
||||
virtual void ContentInserted(nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer) = 0;
|
||||
virtual void ContentRemoved(nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer) = 0;
|
||||
|
||||
// Observation hooks for style data to propagate notifications
|
||||
// to document observers
|
||||
virtual void StyleRuleChanged(nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aOldStyleRule,
|
||||
nsIStyleRule* aNewStyleRule) = 0;
|
||||
virtual void StyleRuleAdded(nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule) = 0;
|
||||
virtual void StyleRuleRemoved(nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule) = 0;
|
||||
|
||||
/**
|
||||
* Flush notifications for this document and its parent documents
|
||||
* (since those may affect the layout of this one).
|
||||
*/
|
||||
virtual void FlushPendingNotifications(mozFlushType aType) = 0;
|
||||
|
||||
nsIBindingManager* BindingManager() const
|
||||
{
|
||||
return mBindingManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only to be used inside Gecko, you can't really do anything with the
|
||||
* pointer outside Gecko anyway.
|
||||
*/
|
||||
nsNodeInfoManager* NodeInfoManager() const
|
||||
{
|
||||
return mNodeInfoManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the document using the given channel and loadgroup. This works
|
||||
* like ResetToURI, but also sets the document's channel to aChannel.
|
||||
*/
|
||||
virtual void Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup) = 0;
|
||||
|
||||
/**
|
||||
* Reset this document to aURI and aLoadGroup. aURI must not be null.
|
||||
*/
|
||||
virtual void ResetToURI(nsIURI *aURI, nsILoadGroup* aLoadGroup) = 0;
|
||||
|
||||
/**
|
||||
* Set the container (docshell) for this document.
|
||||
*/
|
||||
void SetContainer(nsISupports *aContainer)
|
||||
{
|
||||
mDocumentContainer = do_GetWeakReference(aContainer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the container (docshell) for this document.
|
||||
*/
|
||||
already_AddRefed<nsISupports> GetContainer() const
|
||||
{
|
||||
nsISupports* container = nsnull;
|
||||
if (mDocumentContainer)
|
||||
CallQueryReferent(mDocumentContainer.get(), &container);
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
virtual nsIScriptEventManager* GetScriptEventManager() = 0;
|
||||
|
||||
/**
|
||||
* Set and get XML declaration. If aVersion is null there is no declaration.
|
||||
* aStandalone takes values -1, 0 and 1 indicating respectively that there
|
||||
* was no standalone parameter in the declaration, that it was given as no,
|
||||
* or that it was given as yes.
|
||||
*/
|
||||
virtual void SetXMLDeclaration(const PRUnichar *aVersion,
|
||||
const PRUnichar *aEncoding,
|
||||
const PRInt32 aStandalone) = 0;
|
||||
virtual void GetXMLDeclaration(nsAString& aVersion,
|
||||
nsAString& aEncoding,
|
||||
nsAString& Standalone) = 0;
|
||||
|
||||
virtual PRBool IsCaseSensitive()
|
||||
{
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
virtual PRBool IsScriptEnabled() = 0;
|
||||
|
||||
virtual nsresult AddXMLEventsContent(nsIContent * aXMLEventsElement) = 0;
|
||||
|
||||
virtual PRBool IsLoadedAsData()
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an element with the specified name, prefix and namespace ID.
|
||||
* If aDocumentDefaultType is true we create an element of the default type
|
||||
* for that document (currently XHTML in HTML documents and XUL in XUL
|
||||
* documents), otherwise we use the type specified by the namespace ID.
|
||||
*/
|
||||
virtual nsresult CreateElem(nsIAtom *aName, nsIAtom *aPrefix,
|
||||
PRInt32 aNamespaceID,
|
||||
PRBool aDocumentDefaultType,
|
||||
nsIContent** aResult) = 0;
|
||||
|
||||
/**
|
||||
* Get the security info (i.e. SSL state etc) that the document got
|
||||
* from the channel/document that created the content of the
|
||||
* document.
|
||||
*
|
||||
* @see nsIChannel
|
||||
*/
|
||||
nsISupports *GetSecurityInfo()
|
||||
{
|
||||
return mSecurityInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default namespace ID used for elements created in this
|
||||
* document.
|
||||
*/
|
||||
virtual PRInt32 GetDefaultNamespaceID() const = 0;
|
||||
|
||||
nsPropertyTable* PropertyTable() { return &mPropertyTable; }
|
||||
|
||||
/**
|
||||
* Sets the ID used to identify this part of the multipart document
|
||||
*/
|
||||
void SetPartID(PRUint32 aID) {
|
||||
mPartID = aID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the ID used to identify this part of the multipart document
|
||||
*/
|
||||
PRUint32 GetPartID() const {
|
||||
return mPartID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize the document by resetting all input elements and forms that have
|
||||
* autocomplete=off to their default values.
|
||||
*/
|
||||
virtual nsresult Sanitize() = 0;
|
||||
|
||||
/**
|
||||
* Enumerate all subdocuments.
|
||||
* The enumerator callback should return PR_TRUE to continue enumerating, or
|
||||
* PR_FALSE to stop.
|
||||
*/
|
||||
typedef PRBool (*nsSubDocEnumFunc)(nsIDocument *aDocument, void *aData);
|
||||
virtual void EnumerateSubDocuments(nsSubDocEnumFunc aCallback,
|
||||
void *aData) = 0;
|
||||
|
||||
/**
|
||||
* Check whether it is safe to cache the presentation of this document
|
||||
* and all of its subdocuments. This method checks the following conditions
|
||||
* recursively:
|
||||
* - Some document types, such as plugin documents, cannot be safely cached.
|
||||
* - If there are any pending requests, we don't allow the presentation
|
||||
* to be cached. Ideally these requests would be suspended and resumed,
|
||||
* but that is difficult in some cases, such as XMLHttpRequest.
|
||||
* - If there are any beforeunload or unload listeners, we must fire them
|
||||
* for correctness, but this likely puts the document into a state where
|
||||
* it would not function correctly if restored.
|
||||
*
|
||||
* |aNewRequest| should be the request for a new document which will
|
||||
* replace this document in the docshell. The new document's request
|
||||
* will be ignored when checking for active requests. If there is no
|
||||
* request associated with the new document, this parameter may be null.
|
||||
*/
|
||||
virtual PRBool CanSavePresentation(nsIRequest *aNewRequest) = 0;
|
||||
|
||||
/**
|
||||
* Notify the document that its associated ContentViewer is being destroyed.
|
||||
* This releases circular references so that the document can go away.
|
||||
* Destroy() is only called on documents that have a content viewer.
|
||||
*/
|
||||
virtual void Destroy() = 0;
|
||||
|
||||
/**
|
||||
* Get the layout history state that should be used to save and restore state
|
||||
* for nodes in this document. This may return null; if that happens state
|
||||
* saving and restoration is not possible.
|
||||
*/
|
||||
virtual already_AddRefed<nsILayoutHistoryState> GetLayoutHistoryState() const = 0;
|
||||
|
||||
/**
|
||||
* Methods that can be used to prevent onload firing while an event that
|
||||
* should block onload is posted. onload is guaranteed to not fire until
|
||||
* either all calls to BlockOnload() have been matched by calls to
|
||||
* UnblockOnload() or the load has been stopped altogether (by the user
|
||||
* pressing the Stop button, say).
|
||||
*/
|
||||
virtual void BlockOnload() = 0;
|
||||
/**
|
||||
* @param aFireSync whether to fire onload synchronously. If false,
|
||||
* onload will fire asynchronously after all onload blocks have been
|
||||
* removed. It will NOT fire from inside UnblockOnload. If true,
|
||||
* onload may fire from inside UnblockOnload.
|
||||
*/
|
||||
virtual void UnblockOnload(PRBool aFireSync) = 0;
|
||||
|
||||
/**
|
||||
* Notification that the page has been shown, for documents which are loaded
|
||||
* into a DOM window. This corresponds to the completion of document load,
|
||||
* or to the page's presentation being restored into an existing DOM window.
|
||||
* This notification fires applicable DOM events to the content window. See
|
||||
* nsIDOMPageTransitionEvent.idl for a description of the |aPersisted|
|
||||
* parameter.
|
||||
*/
|
||||
virtual void OnPageShow(PRBool aPersisted) = 0;
|
||||
|
||||
/**
|
||||
* Notification that the page has been hidden, for documents which are loaded
|
||||
* into a DOM window. This corresponds to the unloading of the document, or
|
||||
* to the document's presentation being saved but removed from an existing
|
||||
* DOM window. This notification fires applicable DOM events to the content
|
||||
* window. See nsIDOMPageTransitionEvent.idl for a description of the
|
||||
* |aPersisted| parameter.
|
||||
*/
|
||||
virtual void OnPageHide(PRBool aPersisted) = 0;
|
||||
|
||||
/*
|
||||
* We record the set of links in the document that are relevant to
|
||||
* style.
|
||||
*/
|
||||
/**
|
||||
* Notification that an element is a link with a given URI that is
|
||||
* relevant to style.
|
||||
*/
|
||||
virtual void AddStyleRelevantLink(nsIContent* aContent, nsIURI* aURI) = 0;
|
||||
/**
|
||||
* Notification that an element is a link and its URI might have been
|
||||
* changed or the element removed. If the element is still a link relevant
|
||||
* to style, then someone must ensure that AddStyleRelevantLink is
|
||||
* (eventually) called on it again.
|
||||
*/
|
||||
virtual void ForgetLink(nsIContent* aContent) = 0;
|
||||
/**
|
||||
* Notification that the visitedness state of a URI has been changed
|
||||
* and style related to elements linking to that URI should be updated.
|
||||
*/
|
||||
virtual void NotifyURIVisitednessChanged(nsIURI* aURI) = 0;
|
||||
|
||||
/**
|
||||
* Resets and removes a box object from the document's box object cache
|
||||
*
|
||||
* @param aElement canonical nsIContent pointer of the box object's element
|
||||
*/
|
||||
virtual void ClearBoxObjectFor(nsIContent *aContent) = 0;
|
||||
|
||||
protected:
|
||||
~nsIDocument()
|
||||
{
|
||||
// XXX The cleanup of mNodeInfoManager (calling DropDocumentReference and
|
||||
// releasing it) happens in the nsDocument destructor. We'd prefer to
|
||||
// do it here but nsNodeInfoManager is a concrete class that we don't
|
||||
// want to expose to users of the nsIDocument API outside of Gecko.
|
||||
}
|
||||
|
||||
nsString mDocumentTitle;
|
||||
nsCOMPtr<nsIURI> mDocumentURI;
|
||||
nsCOMPtr<nsIURI> mDocumentBaseURI;
|
||||
|
||||
nsWeakPtr mDocumentLoadGroup;
|
||||
|
||||
nsWeakPtr mDocumentContainer;
|
||||
|
||||
nsCString mCharacterSet;
|
||||
PRInt32 mCharacterSetSource;
|
||||
|
||||
// This is just a weak pointer; the parent document owns its children.
|
||||
nsIDocument* mParentDocument;
|
||||
|
||||
// A weak reference to the only child element, or null if no
|
||||
// such element exists.
|
||||
nsIContent* mRootContent;
|
||||
|
||||
nsCOMPtr<nsIBindingManager> mBindingManager;
|
||||
nsNodeInfoManager* mNodeInfoManager; // [STRONG]
|
||||
|
||||
nsICSSLoader* mCSSLoader; // [STRONG; not a COMPtr to avoid
|
||||
// including nsICSSLoader.h; the ownership
|
||||
// is managed by nsDocument]
|
||||
|
||||
// Table of element properties for this document.
|
||||
nsPropertyTable mPropertyTable;
|
||||
|
||||
// True if BIDI is enabled.
|
||||
PRBool mBidiEnabled;
|
||||
|
||||
// The bidi options for this document. What this bitfield means is
|
||||
// defined in nsBidiUtils.h
|
||||
PRUint32 mBidiOptions;
|
||||
|
||||
nsCString mContentLanguage;
|
||||
nsCString mContentType;
|
||||
|
||||
// The document's security info
|
||||
nsCOMPtr<nsISupports> mSecurityInfo;
|
||||
|
||||
// if this document is part of a multipart document,
|
||||
// the ID can be used to distinguish it from the other parts.
|
||||
PRUint32 mPartID;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocument, NS_IDOCUMENT_IID)
|
||||
|
||||
/**
|
||||
* Helper class to automatically handle batching of document updates. This
|
||||
* class will call BeginUpdate on construction and EndUpdate on destruction on
|
||||
* the given document with the given update type. The document could be null,
|
||||
* in which case no updates will be called. The constructor also takes a
|
||||
* boolean that can be set to false to prevent notifications.
|
||||
*/
|
||||
class mozAutoDocUpdate
|
||||
{
|
||||
public:
|
||||
mozAutoDocUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType,
|
||||
PRBool aNotify) :
|
||||
mDocument(aNotify ? aDocument : nsnull),
|
||||
mUpdateType(aUpdateType)
|
||||
{
|
||||
if (mDocument) {
|
||||
mDocument->BeginUpdate(mUpdateType);
|
||||
}
|
||||
}
|
||||
|
||||
~mozAutoDocUpdate()
|
||||
{
|
||||
if (mDocument) {
|
||||
mDocument->EndUpdate(mUpdateType);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIDocument> mDocument;
|
||||
nsUpdateType mUpdateType;
|
||||
};
|
||||
|
||||
#define MOZ_AUTO_DOC_UPDATE_PASTE2(tok,line) tok##line
|
||||
#define MOZ_AUTO_DOC_UPDATE_PASTE(tok,line) \
|
||||
MOZ_AUTO_DOC_UPDATE_PASTE2(tok,line)
|
||||
#define MOZ_AUTO_DOC_UPDATE(doc,type,notify) \
|
||||
mozAutoDocUpdate MOZ_AUTO_DOC_UPDATE_PASTE(_autoDocUpdater_, __LINE__) \
|
||||
(doc,type,notify)
|
||||
|
||||
// XXX These belong somewhere else
|
||||
nsresult
|
||||
NS_NewHTMLDocument(nsIDocument** aInstancePtrResult);
|
||||
|
||||
nsresult
|
||||
NS_NewXMLDocument(nsIDocument** aInstancePtrResult);
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
nsresult
|
||||
NS_NewSVGDocument(nsIDocument** aInstancePtrResult);
|
||||
#endif
|
||||
|
||||
nsresult
|
||||
NS_NewImageDocument(nsIDocument** aInstancePtrResult);
|
||||
|
||||
nsresult
|
||||
NS_NewDocumentFragment(nsIDOMDocumentFragment** aInstancePtrResult,
|
||||
nsNodeInfoManager *aNodeInfoManager);
|
||||
|
||||
// Note: it's the caller's responsibility to create or get aPrincipal as needed
|
||||
// -- this method will not attempt to get a principal based on aDocumentURI.
|
||||
// Also, both aDocumentURI and aBaseURI must not be null.
|
||||
nsresult
|
||||
NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
|
||||
const nsAString& aNamespaceURI,
|
||||
const nsAString& aQualifiedName,
|
||||
nsIDOMDocumentType* aDoctype,
|
||||
nsIURI* aDocumentURI,
|
||||
nsIURI* aBaseURI,
|
||||
nsIPrincipal* aPrincipal);
|
||||
nsresult
|
||||
NS_NewPluginDocument(nsIDocument** aInstancePtrResult);
|
||||
|
||||
#endif /* nsIDocument_h___ */
|
||||
@@ -1,283 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* the Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Josh Lurz <jlurz24@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDOMDocument;
|
||||
interface nsIDOMRange;
|
||||
interface nsISelection;
|
||||
interface nsIDOMNode;
|
||||
interface nsIOutputStream;
|
||||
|
||||
[scriptable, uuid(e770c650-b3d3-11da-a94d-0800200c9a66)]
|
||||
interface nsIDocumentEncoderNodeFixup : nsISupports
|
||||
{
|
||||
/**
|
||||
* Create a fixed up version of a node. This method is called before
|
||||
* each node in a document is about to be persisted. The implementor
|
||||
* may return a new node with fixed up attributes or null. If null is
|
||||
* returned the node should be used as-is.
|
||||
* @param aNode Node to fixup.
|
||||
* @return The resulting fixed up node.
|
||||
*/
|
||||
nsIDOMNode fixupNode(in nsIDOMNode aNode);
|
||||
};
|
||||
|
||||
[scriptable, uuid(ea9f3938-6ba0-11da-9531-00e08161165f)]
|
||||
interface nsIDocumentEncoder : nsISupports
|
||||
{
|
||||
// Output methods flag bits. There are a frightening number of these,
|
||||
// because everyone wants something a little bit different
|
||||
|
||||
|
||||
/**
|
||||
* Output only the selection (as opposed to the whole document).
|
||||
*/
|
||||
const unsigned long OutputSelectionOnly = (1 << 0);
|
||||
|
||||
/** Plaintext output: Convert html to plaintext that looks like the html.
|
||||
* Implies wrap (except inside <pre>), since html wraps.
|
||||
* HTML output: always do prettyprinting, ignoring existing formatting.
|
||||
* (Probably not well tested for HTML output.)
|
||||
*/
|
||||
const unsigned long OutputFormatted = (1 << 1);
|
||||
|
||||
/** Don't do prettyprinting of HTML. Don't do any wrapping that's not in
|
||||
* the existing HTML source. This option overrides OutputFormatted if both
|
||||
* are set.
|
||||
* @note This option does not affect entity conversion.
|
||||
*/
|
||||
const unsigned long OutputRaw = (1 << 2);
|
||||
|
||||
/**
|
||||
* Do not print html head tags.
|
||||
*/
|
||||
const unsigned long OutputBodyOnly = (1 << 3);
|
||||
|
||||
/**
|
||||
* Wrap even if we're not doing formatted output (e.g. for text fields)
|
||||
* XXXbz this doesn't seem to be used by all serializers... document? How
|
||||
* does this interact with
|
||||
* OutputFormatted/OutputRaw/OutputWrap/OutputFormatFlowed?
|
||||
*/
|
||||
const unsigned long OutputPreformatted = (1 << 4);
|
||||
|
||||
/**
|
||||
* Output as though the content is preformatted
|
||||
* (e.g. maybe it's wrapped in a MOZ_PRE or MOZ_PRE_WRAP style tag)
|
||||
* XXXbz this doesn't seem to be used by all serializers... document? How
|
||||
* does this interact with
|
||||
* OutputFormatted/OutputRaw/OutputPreformatted/OutputFormatFlowed?
|
||||
*/
|
||||
const unsigned long OutputWrap = (1 << 5);
|
||||
|
||||
/**
|
||||
* Output for format flowed (RFC 2646). This is used when converting
|
||||
* to text for mail sending. This differs just slightly
|
||||
* but in an important way from normal formatted, and that is that
|
||||
* lines are space stuffed. This can't (correctly) be done later.
|
||||
* XXXbz this doesn't seem to be used by all serializers... document? How
|
||||
* does this interact with
|
||||
* OutputFormatted/OutputRaw/OutputPreformatted/OutputWrap?
|
||||
*/
|
||||
const unsigned long OutputFormatFlowed = (1 << 6);
|
||||
|
||||
/**
|
||||
* Convert links, image src, and script src to absolute URLs when possible
|
||||
*/
|
||||
const unsigned long OutputAbsoluteLinks = (1 << 7);
|
||||
|
||||
/**
|
||||
* Attempt to encode entities standardized at W3C (HTML, MathML, etc).
|
||||
* This is a catch-all flag for documents with mixed contents. Beware of
|
||||
* interoperability issues. See below for other flags which might likely
|
||||
* do what you want.
|
||||
*/
|
||||
const unsigned long OutputEncodeW3CEntities = (1 << 8);
|
||||
|
||||
/**
|
||||
* LineBreak processing: if this flag is set than CR line breaks will
|
||||
* be written. If neither this nor OutputLFLineBreak is set, then we
|
||||
* will use platform line breaks. The combination of the two flags will
|
||||
* cause CRLF line breaks to be written.
|
||||
*/
|
||||
const unsigned long OutputCRLineBreak = (1 << 9);
|
||||
|
||||
/**
|
||||
* LineBreak processing: if this flag is set than LF line breaks will
|
||||
* be written. If neither this nor OutputCRLineBreak is set, then we
|
||||
* will use platform line breaks. The combination of the two flags will
|
||||
* cause CRLF line breaks to be written.
|
||||
*/
|
||||
const unsigned long OutputLFLineBreak = (1 << 10);
|
||||
|
||||
/**
|
||||
* Output the content of noscript elements (only for serializing
|
||||
* to plaintext).
|
||||
*/
|
||||
const unsigned long OutputNoScriptContent = (1 << 11);
|
||||
|
||||
/**
|
||||
* Output the content of noframes elements (only for serializing
|
||||
* to plaintext).
|
||||
*/
|
||||
const unsigned long OutputNoFramesContent = (1 << 12);
|
||||
|
||||
/**
|
||||
* Don't allow any formatting nodes (e.g. <br>, <b>) inside a <pre>.
|
||||
* This is used primarily by mail.
|
||||
*/
|
||||
const unsigned long OutputNoFormattingInPre = (1 << 13);
|
||||
|
||||
/**
|
||||
* Encode entities when outputting to a string.
|
||||
* E.g. If set, we'll output if clear, we'll output 0xa0.
|
||||
* The basic set is just & < > " for interoperability
|
||||
* with older products that don't support α and friends.
|
||||
*/
|
||||
const unsigned long OutputEncodeBasicEntities = (1 << 14);
|
||||
|
||||
/**
|
||||
* Encode entities when outputting to a string.
|
||||
* The Latin1 entity set additionally includes 8bit accented letters
|
||||
* between 128 and 255.
|
||||
*/
|
||||
const unsigned long OutputEncodeLatin1Entities = (1 << 15);
|
||||
|
||||
/**
|
||||
* Encode entities when outputting to a string.
|
||||
* The HTML entity set additionally includes accented letters, greek
|
||||
* letters, and other special markup symbols as defined in HTML4.
|
||||
*/
|
||||
const unsigned long OutputEncodeHTMLEntities = (1 << 16);
|
||||
|
||||
/**
|
||||
* Initialize with a pointer to the document and the mime type.
|
||||
* @param aDocument Document to encode.
|
||||
* @param aMimeType MimeType to use. May also be set by SetMimeType.
|
||||
* @param aFlags Flags to use while encoding. May also be set by SetFlags.
|
||||
*/
|
||||
void init(in nsIDOMDocument aDocument,
|
||||
in AString aMimeType,
|
||||
in unsigned long aFlags);
|
||||
|
||||
/**
|
||||
* If the selection is set to a non-null value, then the
|
||||
* selection is used for encoding, otherwise the entire
|
||||
* document is encoded.
|
||||
* @param aSelection The selection to encode.
|
||||
*/
|
||||
void setSelection(in nsISelection aSelection);
|
||||
|
||||
/**
|
||||
* If the range is set to a non-null value, then the
|
||||
* range is used for encoding, otherwise the entire
|
||||
* document or selection is encoded.
|
||||
* @param aRange The range to encode.
|
||||
*/
|
||||
void setRange(in nsIDOMRange aRange);
|
||||
|
||||
/**
|
||||
* If the node is set to a non-null value, then the
|
||||
* node is used for encoding, otherwise the entire
|
||||
* document or range or selection is encoded.
|
||||
* @param aNode The node to encode.
|
||||
*/
|
||||
void setNode(in nsIDOMNode aNode);
|
||||
|
||||
/**
|
||||
* Documents typically have an intrinsic character set,
|
||||
* but if no intrinsic value is found, the platform character set
|
||||
* is used. This function overrides both the intrinisc and platform
|
||||
* charset.
|
||||
* @param aCharset Overrides the both the intrinsic or platform
|
||||
* character set when encoding the document.
|
||||
*
|
||||
* Possible result codes: NS_ERROR_NO_CHARSET_CONVERTER
|
||||
*/
|
||||
void setCharset(in ACString aCharset);
|
||||
|
||||
/**
|
||||
* Set a wrap column. This may have no effect in some types of encoders.
|
||||
* @param aWrapColumn Column to which to wrap.
|
||||
*/
|
||||
void setWrapColumn(in unsigned long aWrapColumn);
|
||||
|
||||
/**
|
||||
* The mime type preferred by the encoder. This piece of api was
|
||||
* added because the copy encoder may need to switch mime types on you
|
||||
* if you ask it to copy html that really represents plaintext content.
|
||||
* Call this AFTER Init() and SetSelection() have both been called.
|
||||
*/
|
||||
readonly attribute AString mimeType;
|
||||
|
||||
/**
|
||||
* Encode the document and send the result to the nsIOutputStream.
|
||||
*
|
||||
* Possible result codes are the stream errors which might have
|
||||
* been encountered.
|
||||
* @param aStream Stream into which to encode.
|
||||
*/
|
||||
void encodeToStream(in nsIOutputStream aStream);
|
||||
|
||||
/**
|
||||
* Encode the document into a string.
|
||||
*
|
||||
* @return The document encoded into a string.
|
||||
*/
|
||||
AString encodeToString();
|
||||
|
||||
/**
|
||||
* Encode the document into a string. Stores the extra context information
|
||||
* into the two arguments.
|
||||
* @param [OUT] aContextString The string where the parent heirarchy
|
||||
* information will be stored.
|
||||
* @param [OUT] aInfoString The string where extra context info will
|
||||
* be stored.
|
||||
* @return The document encoded as a string.
|
||||
*
|
||||
*/
|
||||
AString encodeToStringWithContext( out AString aContextString,
|
||||
out AString aInfoString);
|
||||
|
||||
/**
|
||||
* Set the fixup object associated with node persistence.
|
||||
* @param aFixup The fixup object.
|
||||
*/
|
||||
void setNodeFixup(in nsIDocumentEncoderNodeFixup aFixup);
|
||||
};
|
||||
@@ -1,484 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsIDocumentObserver_h___
|
||||
#define nsIDocumentObserver_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIAtom;
|
||||
class nsIContent;
|
||||
class nsIPresShell;
|
||||
class nsIStyleSheet;
|
||||
class nsIStyleRule;
|
||||
class nsString;
|
||||
class nsIDocument;
|
||||
|
||||
#define NS_IDOCUMENT_OBSERVER_IID \
|
||||
{ 0x589761bb, 0x9856, 0x42fe, \
|
||||
{ 0x9b, 0xf9, 0x6a, 0xdf, 0xf4, 0x92, 0x17, 0x05 } }
|
||||
|
||||
typedef PRUint32 nsUpdateType;
|
||||
|
||||
#define UPDATE_CONTENT_MODEL 0x00000001
|
||||
#define UPDATE_STYLE 0x00000002
|
||||
#define UPDATE_CONTENT_STATE 0x00000004
|
||||
#define UPDATE_ALL (UPDATE_CONTENT_MODEL | UPDATE_STYLE | UPDATE_CONTENT_STATE)
|
||||
|
||||
// Document observer interface
|
||||
class nsIDocumentObserver : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOCUMENT_OBSERVER_IID)
|
||||
|
||||
/**
|
||||
* Notify that a content model update is beginning. This call can be
|
||||
* nested.
|
||||
*/
|
||||
virtual void BeginUpdate(nsIDocument *aDocument,
|
||||
nsUpdateType aUpdateType) = 0;
|
||||
|
||||
/**
|
||||
* Notify that a content model update is finished. This call can be
|
||||
* nested.
|
||||
*/
|
||||
virtual void EndUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType) = 0;
|
||||
|
||||
/**
|
||||
* Notify the observer that a document load is beginning.
|
||||
*/
|
||||
virtual void BeginLoad(nsIDocument *aDocument) = 0;
|
||||
|
||||
/**
|
||||
* Notify the observer that a document load has finished. Note that
|
||||
* the associated reflow of the document will be done <b>before</b>
|
||||
* EndLoad is invoked, not after.
|
||||
*/
|
||||
virtual void EndLoad(nsIDocument *aDocument) = 0;
|
||||
|
||||
/**
|
||||
* Notification that the content model has changed. This method is
|
||||
* called automatically by content objects when their state is changed
|
||||
* (therefore there is normally no need to invoke this method
|
||||
* directly). The notification is passed to any
|
||||
* IDocumentObservers. The notification is passed on to all of the
|
||||
* document observers. <p>
|
||||
*
|
||||
* This notification is not sent when a piece of content is
|
||||
* added/removed from the document (the other notifications are used
|
||||
* for that).
|
||||
*
|
||||
* @param aDocument The document being observed
|
||||
* @param aContent the piece of content that changed
|
||||
* @param aAppend Whether the change was an append
|
||||
*/
|
||||
virtual void CharacterDataChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
PRBool aAppend) = 0;
|
||||
|
||||
/**
|
||||
* Notification that the state of a content node has changed.
|
||||
* (ie: gained or lost focus, became active or hovered over)
|
||||
* This method is called automatically by content objects
|
||||
* when their state is changed (therefore there is normally
|
||||
* no need to invoke this method directly). The notification
|
||||
* is passed to any IDocumentObservers. The notification is
|
||||
* passed on to all of the document observers. <p>
|
||||
*
|
||||
* This notification is not sent when a piece of content is
|
||||
* added/removed from the document or the content itself changed
|
||||
* (the other notifications are used for that).
|
||||
*
|
||||
* The optional second content node is to allow optimization
|
||||
* of the case where state moves from one node to another
|
||||
* (as is likely for :focus and :hover)
|
||||
*
|
||||
* Either content node may be nsnull, but not both
|
||||
*
|
||||
* @param aDocument The document being observed
|
||||
* @param aContent1 the piece of content that changed
|
||||
* @param aContent2 optional second piece of content that changed
|
||||
*/
|
||||
virtual void ContentStatesChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2,
|
||||
PRInt32 aStateMask) = 0;
|
||||
|
||||
/**
|
||||
* Notification that the content model has changed. This method is called
|
||||
* automatically by content objects when an attribute's value has changed
|
||||
* (therefore there is normally no need to invoke this method directly). The
|
||||
* notification is passed to any IDocumentObservers document observers. <p>
|
||||
*
|
||||
* @param aDocument The document being observed
|
||||
* @param aContent the piece of content whose attribute changed
|
||||
* @param aAttribute the atom name of the attribute
|
||||
* @param aModType Whether or not the attribute was added, changed, or removed.
|
||||
* The constants are defined in nsIDOMMutationEvent.h.
|
||||
*/
|
||||
virtual void AttributeChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aModType) = 0;
|
||||
|
||||
/**
|
||||
* Notifcation that the content model has had data appended to the
|
||||
* given content object. This method is called automatically by the
|
||||
* content container objects when a new content object is appended to
|
||||
* the container (therefore there is normally no need to invoke this
|
||||
* method directly). The notification is passed on to all of the
|
||||
* document observers.
|
||||
*
|
||||
* @param aDocument The document being observed
|
||||
* @param aContainer the container that had a new child appended
|
||||
* @param aNewIndexInContainer the index in the container of the first
|
||||
* new child
|
||||
*/
|
||||
virtual void ContentAppended(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
PRInt32 aNewIndexInContainer) = 0;
|
||||
|
||||
/**
|
||||
* Notification that content has been inserted. This method is called
|
||||
* automatically by the content container objects when a new content
|
||||
* object is inserted in the container (therefore there is normally no
|
||||
* need to invoke this method directly). The notification is passed on
|
||||
* to all of the document observers.
|
||||
*
|
||||
* @param aDocument The document being observed
|
||||
* @param aContainer the container that now contains aChild
|
||||
* @param aChild the child that was inserted
|
||||
* @param aIndexInContainer the index of the child in the container
|
||||
*/
|
||||
virtual void ContentInserted(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer) = 0;
|
||||
|
||||
/**
|
||||
* Content has just been removed. This method is called automatically
|
||||
* by content container objects when a content object has just been
|
||||
* removed from the container (therefore there is normally no need to
|
||||
* invoke this method directly). The notification is passed on to all
|
||||
* of the document observers.
|
||||
*
|
||||
* @param aDocument The document being observed
|
||||
* @param aContainer the container that had a child removed
|
||||
* @param aChild the child that was just removed
|
||||
* @param aIndexInContainer the index of the child in the container
|
||||
* before it was removed
|
||||
*/
|
||||
virtual void ContentRemoved(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer) = 0;
|
||||
|
||||
/**
|
||||
* A StyleSheet has just been added to the document. This method is
|
||||
* called automatically when a StyleSheet gets added to the
|
||||
* document, even if the stylesheet is not applicable. The
|
||||
* notification is passed on to all of the document observers.
|
||||
*
|
||||
* @param aDocument The document being observed
|
||||
* @param aStyleSheet the StyleSheet that has been added
|
||||
* @param aDocumentSheet True if sheet is in document's style sheet list,
|
||||
* false if sheet is not (i.e., UA or user sheet)
|
||||
*/
|
||||
virtual void StyleSheetAdded(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
PRBool aDocumentSheet) = 0;
|
||||
|
||||
/**
|
||||
* A StyleSheet has just been removed from the document. This
|
||||
* method is called automatically when a StyleSheet gets removed
|
||||
* from the document, even if the stylesheet is not applicable. The
|
||||
* notification is passed on to all of the document observers.
|
||||
*
|
||||
* @param aDocument The document being observed
|
||||
* @param aStyleSheet the StyleSheet that has been removed
|
||||
* @param aDocumentSheet True if sheet is in document's style sheet list,
|
||||
* false if sheet is not (i.e., UA or user sheet)
|
||||
*/
|
||||
virtual void StyleSheetRemoved(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
PRBool aDocumentSheet) = 0;
|
||||
|
||||
/**
|
||||
* A StyleSheet has just changed its applicable state.
|
||||
* This method is called automatically when the applicable state
|
||||
* of a StyleSheet gets changed. The style sheet passes this
|
||||
* notification to the document. The notification is passed on
|
||||
* to all of the document observers.
|
||||
*
|
||||
* @param aDocument The document being observed
|
||||
* @param aStyleSheet the StyleSheet that has changed state
|
||||
* @param aApplicable PR_TRUE if the sheet is applicable, PR_FALSE if
|
||||
* it is not applicable
|
||||
*/
|
||||
virtual void StyleSheetApplicableStateChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
PRBool aApplicable) = 0;
|
||||
|
||||
/**
|
||||
* A StyleRule has just been modified within a style sheet.
|
||||
* This method is called automatically when the rule gets
|
||||
* modified. The style sheet passes this notification to
|
||||
* the document. The notification is passed on to all of
|
||||
* the document observers.
|
||||
*
|
||||
* Since nsIStyleRule objects are immutable, there is a new object
|
||||
* replacing the old one. However, the use of this method (rather
|
||||
* than StyleRuleAdded and StyleRuleRemoved) implies that the new rule
|
||||
* matches the same elements and has the same priority (weight,
|
||||
* origin, specificity) as the old one. (However, if it is a CSS
|
||||
* style rule, there may be a change in whether it has an important
|
||||
* rule.)
|
||||
*
|
||||
* @param aDocument The document being observed
|
||||
* @param aStyleSheet the StyleSheet that contians the rule
|
||||
* @param aOldStyleRule The rule being removed. This rule may not be
|
||||
* fully valid anymore -- however, it can still
|
||||
* be used for pointer comparison and
|
||||
* |QueryInterface|.
|
||||
* @param aNewStyleRule The rule being added.
|
||||
*/
|
||||
virtual void StyleRuleChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aOldStyleRule,
|
||||
nsIStyleRule* aNewStyleRule) = 0;
|
||||
|
||||
/**
|
||||
* A StyleRule has just been added to a style sheet.
|
||||
* This method is called automatically when the rule gets
|
||||
* added to the sheet. The style sheet passes this
|
||||
* notification to the document. The notification is passed on
|
||||
* to all of the document observers.
|
||||
*
|
||||
* @param aDocument The document being observed
|
||||
* @param aStyleSheet the StyleSheet that has been modified
|
||||
* @param aStyleRule the rule that was added
|
||||
*/
|
||||
virtual void StyleRuleAdded(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule) = 0;
|
||||
|
||||
/**
|
||||
* A StyleRule has just been removed from a style sheet.
|
||||
* This method is called automatically when the rule gets
|
||||
* removed from the sheet. The style sheet passes this
|
||||
* notification to the document. The notification is passed on
|
||||
* to all of the document observers.
|
||||
*
|
||||
* @param aDocument The document being observed
|
||||
* @param aStyleSheet the StyleSheet that has been modified
|
||||
* @param aStyleRule the rule that was removed
|
||||
*/
|
||||
virtual void StyleRuleRemoved(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule) = 0;
|
||||
|
||||
/**
|
||||
* The document is in the process of being destroyed.
|
||||
* This method is called automatically during document
|
||||
* destruction.
|
||||
*
|
||||
* @param aDocument The document being observed
|
||||
*/
|
||||
virtual void DocumentWillBeDestroyed(nsIDocument *aDocument) = 0;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocumentObserver, NS_IDOCUMENT_OBSERVER_IID)
|
||||
|
||||
#define NS_DECL_NSIDOCUMENTOBSERVER \
|
||||
virtual void BeginUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType);\
|
||||
virtual void EndUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType);\
|
||||
virtual void BeginLoad(nsIDocument* aDocument); \
|
||||
virtual void EndLoad(nsIDocument* aDocument); \
|
||||
virtual void CharacterDataChanged(nsIDocument* aDocument, \
|
||||
nsIContent* aContent, \
|
||||
PRBool aAppend); \
|
||||
virtual void ContentStatesChanged(nsIDocument* aDocument, \
|
||||
nsIContent* aContent1, \
|
||||
nsIContent* aContent2, \
|
||||
PRInt32 aStateMask); \
|
||||
virtual void AttributeChanged(nsIDocument* aDocument, \
|
||||
nsIContent* aContent, \
|
||||
PRInt32 aNameSpaceID, \
|
||||
nsIAtom* aAttribute, \
|
||||
PRInt32 aModType); \
|
||||
virtual void ContentAppended(nsIDocument* aDocument, \
|
||||
nsIContent* aContainer, \
|
||||
PRInt32 aNewIndexInContainer); \
|
||||
virtual void ContentInserted(nsIDocument* aDocument, \
|
||||
nsIContent* aContainer, \
|
||||
nsIContent* aChild, \
|
||||
PRInt32 aIndexInContainer); \
|
||||
virtual void ContentRemoved(nsIDocument* aDocument, \
|
||||
nsIContent* aContainer, \
|
||||
nsIContent* aChild, \
|
||||
PRInt32 aIndexInContainer); \
|
||||
virtual void StyleSheetAdded(nsIDocument* aDocument, \
|
||||
nsIStyleSheet* aStyleSheet, \
|
||||
PRBool aDocumentSheet); \
|
||||
virtual void StyleSheetRemoved(nsIDocument* aDocument, \
|
||||
nsIStyleSheet* aStyleSheet, \
|
||||
PRBool aDocumentSheet); \
|
||||
virtual void StyleSheetApplicableStateChanged(nsIDocument* aDocument, \
|
||||
nsIStyleSheet* aStyleSheet,\
|
||||
PRBool aApplicable); \
|
||||
virtual void StyleRuleChanged(nsIDocument* aDocument, \
|
||||
nsIStyleSheet* aStyleSheet, \
|
||||
nsIStyleRule* aOldStyleRule, \
|
||||
nsIStyleRule* aNewStyleRule); \
|
||||
virtual void StyleRuleAdded(nsIDocument* aDocument, \
|
||||
nsIStyleSheet* aStyleSheet, \
|
||||
nsIStyleRule* aStyleRule); \
|
||||
virtual void StyleRuleRemoved(nsIDocument* aDocument, \
|
||||
nsIStyleSheet* aStyleSheet, \
|
||||
nsIStyleRule* aStyleRule); \
|
||||
virtual void DocumentWillBeDestroyed(nsIDocument* aDocument); \
|
||||
|
||||
|
||||
#define NS_IMPL_NSIDOCUMENTOBSERVER_CORE_STUB(_class) \
|
||||
void \
|
||||
_class::BeginUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType) \
|
||||
{ \
|
||||
} \
|
||||
void \
|
||||
_class::EndUpdate(nsIDocument* aDocument, nsUpdateType aUpdateType) \
|
||||
{ \
|
||||
} \
|
||||
void \
|
||||
_class::DocumentWillBeDestroyed(nsIDocument* aDocument) \
|
||||
{ \
|
||||
}
|
||||
|
||||
#define NS_IMPL_NSIDOCUMENTOBSERVER_LOAD_STUB(_class) \
|
||||
void \
|
||||
_class::BeginLoad(nsIDocument* aDocument) \
|
||||
{ \
|
||||
} \
|
||||
void \
|
||||
_class::EndLoad(nsIDocument* aDocument) \
|
||||
{ \
|
||||
}
|
||||
|
||||
#define NS_IMPL_NSIDOCUMENTOBSERVER_STATE_STUB(_class) \
|
||||
void \
|
||||
_class::ContentStatesChanged(nsIDocument* aDocument, \
|
||||
nsIContent* aContent1, \
|
||||
nsIContent* aContent2, \
|
||||
PRInt32 aStateMask) \
|
||||
{ \
|
||||
}
|
||||
|
||||
#define NS_IMPL_NSIDOCUMENTOBSERVER_CONTENT(_class) \
|
||||
void \
|
||||
_class::CharacterDataChanged(nsIDocument* aDocument, \
|
||||
nsIContent* aContent, \
|
||||
PRBool aAppend) \
|
||||
{ \
|
||||
} \
|
||||
void \
|
||||
_class::AttributeChanged(nsIDocument* aDocument, \
|
||||
nsIContent* aContent, \
|
||||
PRInt32 aNameSpaceID, \
|
||||
nsIAtom* aAttribute, \
|
||||
PRInt32 aModType) \
|
||||
{ \
|
||||
} \
|
||||
void \
|
||||
_class::ContentAppended(nsIDocument* aDocument, \
|
||||
nsIContent* aContainer, \
|
||||
PRInt32 aNewIndexInContainer) \
|
||||
{ \
|
||||
} \
|
||||
void \
|
||||
_class::ContentInserted(nsIDocument* aDocument, \
|
||||
nsIContent* aContainer, \
|
||||
nsIContent* aChild, \
|
||||
PRInt32 aIndexInContainer) \
|
||||
{ \
|
||||
} \
|
||||
void \
|
||||
_class::ContentRemoved(nsIDocument* aDocument, \
|
||||
nsIContent* aContainer, \
|
||||
nsIContent* aChild, \
|
||||
PRInt32 aIndexInContainer) \
|
||||
{ \
|
||||
}
|
||||
|
||||
#define NS_IMPL_NSIDOCUMENTOBSERVER_STYLE_STUB(_class) \
|
||||
void \
|
||||
_class::StyleSheetAdded(nsIDocument* aDocument, \
|
||||
nsIStyleSheet* aStyleSheet, \
|
||||
PRBool aDocumentSheet) \
|
||||
{ \
|
||||
} \
|
||||
void \
|
||||
_class::StyleSheetRemoved(nsIDocument* aDocument, \
|
||||
nsIStyleSheet* aStyleSheet, \
|
||||
PRBool aDocumentSheet) \
|
||||
{ \
|
||||
} \
|
||||
void \
|
||||
_class::StyleSheetApplicableStateChanged(nsIDocument* aDocument, \
|
||||
nsIStyleSheet* aStyleSheet, \
|
||||
PRBool aApplicable) \
|
||||
{ \
|
||||
} \
|
||||
void \
|
||||
_class::StyleRuleChanged(nsIDocument* aDocument, \
|
||||
nsIStyleSheet* aStyleSheet, \
|
||||
nsIStyleRule* aOldStyleRule, \
|
||||
nsIStyleRule* aNewStyleRule) \
|
||||
{ \
|
||||
} \
|
||||
void \
|
||||
_class::StyleRuleAdded(nsIDocument* aDocument, \
|
||||
nsIStyleSheet* aStyleSheet, \
|
||||
nsIStyleRule* aStyleRule) \
|
||||
{ \
|
||||
} \
|
||||
void \
|
||||
_class::StyleRuleRemoved(nsIDocument* aDocument, \
|
||||
nsIStyleSheet* aStyleSheet, \
|
||||
nsIStyleRule* aStyleRule) \
|
||||
{ \
|
||||
}
|
||||
|
||||
#endif /* nsIDocumentObserver_h___ */
|
||||
@@ -1,74 +0,0 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Mike Pinkerton <pinkerton@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDOMEventTarget;
|
||||
interface nsIWebNavigation;
|
||||
|
||||
|
||||
/**
|
||||
* @status UNDER_REVIEW
|
||||
*/
|
||||
|
||||
/**
|
||||
* Interface for communicating with the built-in drag and drop
|
||||
* implementation in the content area. Use this to register where
|
||||
* the listeners should attach (something that implements
|
||||
* |nsIDOMEventReceiver| which is what we end up using under the hood).
|
||||
*/
|
||||
|
||||
[scriptable,uuid(4f418f58-f834-4736-a755-e0395bedca9d)]
|
||||
interface nsIDragDropHandler : nsISupports
|
||||
{
|
||||
/**
|
||||
* Attach drag handlers to receiver specified by |attachPoint| and
|
||||
* specify callbacks to allow overriding of the built-in behaviors.
|
||||
*
|
||||
* @param attachPoint hookup listeners to this location
|
||||
* @param navigator loads dropped urls via this interface. If NULL,
|
||||
* the client must handle the drop itself, either
|
||||
* through the method provided via |overrideDrop| or
|
||||
* by letting the event bubble up through the DOM.
|
||||
*/
|
||||
void hookupTo(in nsIDOMEventTarget attachPoint, in nsIWebNavigation navigator);
|
||||
|
||||
/**
|
||||
* Unregister all handlers related to drag&drop
|
||||
*/
|
||||
void detach();
|
||||
};
|
||||
@@ -1,83 +0,0 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Johnny Stenback <jst@netscape.com> (original author)
|
||||
* Brian Ryner <bryner@brianryner.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDocShell;
|
||||
interface nsIURI;
|
||||
|
||||
[scriptable, uuid(d675c531-6bdc-417c-b176-635060105f07)]
|
||||
interface nsIFrameLoader : nsISupports
|
||||
{
|
||||
/**
|
||||
* Get the docshell from the frame loader.
|
||||
*/
|
||||
readonly attribute nsIDocShell docShell;
|
||||
|
||||
/**
|
||||
* Start loading the frame. This method figures out what to load
|
||||
* from the owner content in the frame loader.
|
||||
*/
|
||||
void loadFrame();
|
||||
|
||||
/**
|
||||
* Loads the specified URI in this frame. Behaves identically to loadFrame,
|
||||
* except that this method allows specifying the URI to load.
|
||||
*/
|
||||
void loadURI(in nsIURI aURI);
|
||||
|
||||
/**
|
||||
* Destroy the frame loader and everything inside it. This will
|
||||
* clear the weak owner content reference.
|
||||
*/
|
||||
void destroy();
|
||||
|
||||
/**
|
||||
* Find out whether the loader's frame is at too great a depth in
|
||||
* the frame tree. This can be used to decide what operations may
|
||||
* or may not be allowed on the loader's docshell.
|
||||
*/
|
||||
readonly attribute boolean depthTooGreat;
|
||||
};
|
||||
|
||||
[scriptable, uuid(feaf9285-05ac-4898-a69f-c3bd350767e4)]
|
||||
interface nsIFrameLoaderOwner : nsISupports
|
||||
{
|
||||
readonly attribute nsIFrameLoader frameLoader;
|
||||
};
|
||||
@@ -1,66 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _nsIPlainTextSink_h__
|
||||
#define _nsIPlainTextSink_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsAString.h"
|
||||
|
||||
#define NS_PLAINTEXTSINK_CONTRACTID "@mozilla.org/layout/plaintextsink;1"
|
||||
|
||||
/* starting interface: nsIContentSerializer */
|
||||
#define NS_IHTMLTOTEXTSINK_IID_STR "b12b5643-07cb-401e-aabb-64b2dcd2717f"
|
||||
|
||||
#define NS_IHTMLTOTEXTSINK_IID \
|
||||
{0xb12b5643, 0x07cb, 0x401e, \
|
||||
{ 0xaa, 0xbb, 0x64, 0xb2, 0xdc, 0xd2, 0x71, 0x7f }}
|
||||
|
||||
|
||||
class nsIHTMLToTextSink : public nsISupports {
|
||||
public:
|
||||
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IHTMLTOTEXTSINK_IID)
|
||||
|
||||
NS_IMETHOD Initialize(nsAString* aOutString,
|
||||
PRUint32 aFlags, PRUint32 aWrapCol) = 0;
|
||||
// This function violates string ownership rules, see impl.
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIHTMLToTextSink, NS_IHTMLTOTEXTSINK_IID)
|
||||
|
||||
#endif
|
||||
@@ -1,163 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Boris Zbarsky <bzbarsky@mit.edu>.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2003
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "imgIDecoderObserver.idl"
|
||||
|
||||
interface imgIRequest;
|
||||
interface nsIChannel;
|
||||
interface nsIStreamListener;
|
||||
interface nsIURI;
|
||||
|
||||
/**
|
||||
* This interface represents a content node that loads images. The interface
|
||||
* exists to allow getting information on the images that the content node
|
||||
* loads and to allow registration of observers for the image loads.
|
||||
*
|
||||
* Implementors of this interface should handle all the mechanics of actually
|
||||
* loading an image -- getting the URI, checking with content policies and
|
||||
* the security manager to see whether loading the URI is allowed, performing
|
||||
* the load, firing any DOM events as needed.
|
||||
*
|
||||
* An implementation of this interface may support the concepts of a
|
||||
* "current" image and a "pending" image. If it does, a request to change
|
||||
* the currently loaded image will start a "pending" request which will
|
||||
* become current only when the image is loaded. It is the responsibility of
|
||||
* observers to check which request they are getting notifications for.
|
||||
*
|
||||
* Observers added in mid-load will not get any notifications they
|
||||
* missed. We should NOT freeze this interface without considering
|
||||
* this issue. (It could be that the image status on imgIRequest is
|
||||
* sufficient, when combined with the imageBlockingStatus information.)
|
||||
*/
|
||||
|
||||
[scriptable, uuid(49b02654-5f96-48a0-bf99-0fe467a3fa52)]
|
||||
interface nsIImageLoadingContent : imgIDecoderObserver
|
||||
{
|
||||
/**
|
||||
* Request types. Image loading content nodes attempt to do atomic
|
||||
* image changes when the image url is changed. This means that
|
||||
* when the url changes the new image load will start, but the old
|
||||
* image will remain the "current" request until the new image is
|
||||
* fully loaded. At that point, the old "current" request will be
|
||||
* discarded and the "pending" request will become "current".
|
||||
*/
|
||||
const long UNKNOWN_REQUEST = -1;
|
||||
const long CURRENT_REQUEST = 0;
|
||||
const long PENDING_REQUEST = 1;
|
||||
|
||||
/**
|
||||
* loadingEnabled is used to enable and disable loading in
|
||||
* situations where loading images is unwanted. Note that enabling
|
||||
* loading will *not* automatically trigger an image load.
|
||||
*/
|
||||
attribute boolean loadingEnabled;
|
||||
|
||||
/**
|
||||
* Returns the image blocking status (@see nsIContentPolicy). This
|
||||
* will always be an nsIContentPolicy REJECT_* status for cases when
|
||||
* the image was blocked. This status always refers to the
|
||||
* CURRENT_REQUEST load.
|
||||
*/
|
||||
readonly attribute short imageBlockingStatus;
|
||||
|
||||
/**
|
||||
* Used to register an image decoder observer. Typically, this will
|
||||
* be a proxy for a frame that wants to paint the image.
|
||||
* Notifications from ongoing image loads will be passed to all
|
||||
* registered observers. Notifications for all request types,
|
||||
* current and pending, will be passed through.
|
||||
*
|
||||
* @param aObserver the observer to register
|
||||
*
|
||||
* @throws NS_ERROR_OUT_OF_MEMORY
|
||||
*/
|
||||
void addObserver(in imgIDecoderObserver aObserver);
|
||||
|
||||
/**
|
||||
* Used to unregister an image decoder observer.
|
||||
*
|
||||
* @param aObserver the observer to unregister
|
||||
*/
|
||||
void removeObserver(in imgIDecoderObserver aObserver);
|
||||
|
||||
/**
|
||||
* Accessor to get the image requests
|
||||
*
|
||||
* @param aRequestType a value saying which request is wanted
|
||||
*
|
||||
* @return the imgIRequest object (may be null, even when no error
|
||||
* is thrown)
|
||||
*
|
||||
* @throws NS_ERROR_UNEXPECTED if the request type requested is not
|
||||
* known
|
||||
*/
|
||||
imgIRequest getRequest(in long aRequestType);
|
||||
|
||||
/**
|
||||
* Used to find out what type of request one is dealing with (eg
|
||||
* which request got passed through to the imgIDecoderObserver
|
||||
* interface of an observer)
|
||||
*
|
||||
* @param aRequest the request whose type we want to know
|
||||
*
|
||||
* @return an enum value saying what type this request is
|
||||
*
|
||||
* @throws NS_ERROR_UNEXPECTED if aRequest is not known
|
||||
*/
|
||||
long getRequestType(in imgIRequest aRequest);
|
||||
|
||||
/**
|
||||
* Gets the URI of the current request, if available.
|
||||
* Otherwise, returns the last URI that this content tried to load, or
|
||||
* null if there haven't been any such attempts.
|
||||
*/
|
||||
readonly attribute nsIURI currentURI;
|
||||
|
||||
/**
|
||||
* loadImageWithChannel allows data from an existing channel to be
|
||||
* used as the image data for this content node.
|
||||
*
|
||||
* @param aChannel the channel that will deliver the data
|
||||
*
|
||||
* @return a stream listener to pump the image data into
|
||||
*
|
||||
* @see imgILoader::loadImageWithChannel
|
||||
*
|
||||
* @throws NS_ERROR_NULL_POINTER if aChannel is null
|
||||
*/
|
||||
nsIStreamListener loadImageWithChannel(in nsIChannel aChannel);
|
||||
};
|
||||
@@ -1,107 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsINameSpaceManager_h___
|
||||
#define nsINameSpaceManager_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsAString.h"
|
||||
|
||||
class nsIAtom;
|
||||
class nsString;
|
||||
|
||||
#define kNameSpaceID_Unknown -1
|
||||
// 0 is special at C++, so use a static const PRInt32 for
|
||||
// kNameSpaceID_None to keep if from being cast to pointers
|
||||
static const PRInt32 kNameSpaceID_None = 0;
|
||||
#define kNameSpaceID_XMLNS 1 // not really a namespace, but it needs to play the game
|
||||
#define kNameSpaceID_XML 2
|
||||
#define kNameSpaceID_XHTML 3
|
||||
#define kNameSpaceID_XLink 4
|
||||
#define kNameSpaceID_XSLT 5
|
||||
#define kNameSpaceID_XBL 6
|
||||
#define kNameSpaceID_MathML 7
|
||||
#define kNameSpaceID_RDF 8
|
||||
#define kNameSpaceID_XUL 9
|
||||
#define kNameSpaceID_SVG 10
|
||||
#define kNameSpaceID_XMLEvents 11
|
||||
#define kNameSpaceID_XHTML2_Unofficial 12
|
||||
#define kNameSpaceID_WAIRoles 13
|
||||
#define kNameSpaceID_WAIProperties 14
|
||||
#define kNameSpaceID_LastBuiltin 14 // last 'built-in' namespace
|
||||
|
||||
#define NS_NAMESPACEMANAGER_CONTRACTID "@mozilla.org/content/namespacemanager;1"
|
||||
|
||||
#define NS_INAMESPACEMANAGER_IID \
|
||||
{ 0xd74e83e6, 0xf932, 0x4289, \
|
||||
{ 0xac, 0x95, 0x9e, 0x10, 0x24, 0x30, 0x88, 0xd6 } }
|
||||
|
||||
/**
|
||||
* The Name Space Manager tracks the associtation between a NameSpace
|
||||
* URI and the PRInt32 runtime id. Mappings between NameSpaces and
|
||||
* NameSpace prefixes are managed by nsINameSpaces.
|
||||
*
|
||||
* All NameSpace URIs are stored in a global table so that IDs are
|
||||
* consistent accross the app. NameSpace IDs are only consistent at runtime
|
||||
* ie: they are not guaranteed to be consistent accross app sessions.
|
||||
*
|
||||
* The nsINameSpaceManager needs to have a live reference for as long as
|
||||
* the NameSpace IDs are needed.
|
||||
*
|
||||
*/
|
||||
|
||||
class nsINameSpaceManager : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_INAMESPACEMANAGER_IID)
|
||||
|
||||
virtual nsresult RegisterNameSpace(const nsAString& aURI,
|
||||
PRInt32& aNameSpaceID) = 0;
|
||||
|
||||
virtual nsresult GetNameSpaceURI(PRInt32 aNameSpaceID, nsAString& aURI) = 0;
|
||||
virtual PRInt32 GetNameSpaceID(const nsAString& aURI) = 0;
|
||||
|
||||
virtual PRBool HasElementCreator(PRInt32 aNameSpaceID) = 0;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsINameSpaceManager, NS_INAMESPACEMANAGER_IID)
|
||||
|
||||
nsresult NS_GetNameSpaceManager(nsINameSpaceManager** aInstancePtrResult);
|
||||
|
||||
void NS_NameSpaceManagerShutdown();
|
||||
|
||||
#endif // nsINameSpaceManager_h___
|
||||
@@ -1,601 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla.com.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Boris Zbarsky <bzbarsky@mit.edu> (Original Author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsINode_h___
|
||||
#define nsINode_h___
|
||||
|
||||
#include "nsIDOMGCParticipant.h"
|
||||
#include "nsEvent.h"
|
||||
#include "nsPropertyTable.h"
|
||||
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
#include "nsINodeInfo.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#endif
|
||||
|
||||
class nsIContent;
|
||||
class nsIDocument;
|
||||
class nsIDOMEvent;
|
||||
class nsPresContext;
|
||||
class nsEventChainPreVisitor;
|
||||
class nsEventChainPostVisitor;
|
||||
class nsIEventListenerManager;
|
||||
class nsIPrincipal;
|
||||
class nsIDOMRange;
|
||||
class nsVoidArray;
|
||||
|
||||
// This bit will be set if the node doesn't have nsDOMSlots
|
||||
#define NODE_DOESNT_HAVE_SLOTS 0x00000001U
|
||||
|
||||
// This bit will be set if the node has a range list in the range list hash
|
||||
#define NODE_HAS_RANGELIST 0x00000002U
|
||||
|
||||
// This bit will be set if the node has a listener manager in the listener
|
||||
// manager hash
|
||||
#define NODE_HAS_LISTENERMANAGER 0x00000004U
|
||||
|
||||
// Whether this node has had any properties set on it
|
||||
#define NODE_HAS_PROPERTIES 0x00000008U
|
||||
|
||||
// Whether this node is anonymous
|
||||
// NOTE: Should only be used on nsIContent nodes
|
||||
#define NODE_IS_ANONYMOUS 0x00000010U
|
||||
|
||||
// Whether this node may have a frame
|
||||
// NOTE: Should only be used on nsIContent nodes
|
||||
#define NODE_MAY_HAVE_FRAME 0x00000020U
|
||||
|
||||
// Remaining bits are node type specific.
|
||||
#define NODE_TYPE_SPECIFIC_BITS_OFFSET 6
|
||||
|
||||
// IID for the nsINode interface
|
||||
#define NS_INODE_IID \
|
||||
{ 0x7b23c37c, 0x18e6, 0x4d80, \
|
||||
{ 0xbc, 0x95, 0xb3, 0x7b, 0x3b, 0x89, 0x7a, 0xe0 } }
|
||||
|
||||
// hack to make egcs / gcc 2.95.2 happy
|
||||
class nsINode_base : public nsIDOMGCParticipant {
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_INODE_IID)
|
||||
};
|
||||
|
||||
/**
|
||||
* An internal interface that abstracts some DOMNode-related parts that both
|
||||
* nsIContent and nsIDocument share. An instance of this interface has a list
|
||||
* of nsIContent children and provides access to them.
|
||||
*/
|
||||
class nsINode : public nsINode_base {
|
||||
public:
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
// If you're using the external API, the only thing you can know about
|
||||
// nsINode is that it exists with an IID, if that....
|
||||
|
||||
nsINode(nsINodeInfo* aNodeInfo)
|
||||
: mNodeInfo(aNodeInfo),
|
||||
mParentPtrBits(0),
|
||||
mFlagsOrSlots(NODE_DOESNT_HAVE_SLOTS)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~nsINode();
|
||||
|
||||
/**
|
||||
* Bit-flags to pass (or'ed together) to IsNodeOfType()
|
||||
*/
|
||||
enum {
|
||||
/** nsIContent nodes */
|
||||
eCONTENT = 1 << 0,
|
||||
/** nsIDocument nodes */
|
||||
eDOCUMENT = 1 << 1,
|
||||
/** nsIAttribute nodes */
|
||||
eATTRIBUTE = 1 << 2,
|
||||
/** elements */
|
||||
eELEMENT = 1 << 3,
|
||||
/** text nodes */
|
||||
eTEXT = 1 << 4,
|
||||
/** xml processing instructions */
|
||||
ePROCESSING_INSTRUCTION = 1 << 5,
|
||||
/** comment nodes */
|
||||
eCOMMENT = 1 << 6,
|
||||
/** html elements */
|
||||
eHTML = 1 << 7,
|
||||
/** form control elements */
|
||||
eHTML_FORM_CONTROL = 1 << 8,
|
||||
/** XUL elements */
|
||||
eXUL = 1 << 9,
|
||||
/** svg elements */
|
||||
eSVG = 1 << 10,
|
||||
/** document fragments */
|
||||
eDOCUMENT_FRAGMENT = 1 << 11
|
||||
};
|
||||
|
||||
/**
|
||||
* API for doing a quick check if a content is of a given
|
||||
* type, such as HTML, XUL, Text, ... Use this when you can instead of
|
||||
* checking the tag.
|
||||
*
|
||||
* @param aFlags what types you want to test for (see above)
|
||||
* @return whether the content matches ALL flags passed in
|
||||
*/
|
||||
virtual PRBool IsNodeOfType(PRUint32 aFlags) const = 0;
|
||||
|
||||
/**
|
||||
* Get the number of children
|
||||
* @return the number of children
|
||||
*/
|
||||
virtual PRUint32 GetChildCount() const = 0;
|
||||
|
||||
/**
|
||||
* Get a child by index
|
||||
* @param aIndex the index of the child to get
|
||||
* @return the child, or null if index out of bounds
|
||||
*/
|
||||
virtual nsIContent* GetChildAt(PRUint32 aIndex) const = 0;
|
||||
|
||||
/**
|
||||
* Get the index of a child within this content
|
||||
* @param aPossibleChild the child to get the index of.
|
||||
* @return the index of the child, or -1 if not a child
|
||||
*
|
||||
* If the return value is not -1, then calling GetChildAt() with that value
|
||||
* will return aPossibleChild.
|
||||
*/
|
||||
virtual PRInt32 IndexOf(nsINode* aPossibleChild) const = 0;
|
||||
|
||||
/**
|
||||
* Do we need a GetCurrentDoc of some sort? I don't think we do...
|
||||
*/
|
||||
|
||||
/**
|
||||
* Return the "owner document" of this node. Note that this is not the same
|
||||
* as the DOM ownerDocument -- that's null for Document nodes, whereas for a
|
||||
* nsIDocument GetOwnerDocument returns the document itself. For nsIContent
|
||||
* implementations the two are the same.
|
||||
*/
|
||||
nsIDocument *GetOwnerDoc() const
|
||||
{
|
||||
return mNodeInfo->GetDocument();
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a content node at a particular index. This method handles calling
|
||||
* BindToTree on the child appropriately.
|
||||
*
|
||||
* @param aKid the content to insert
|
||||
* @param aIndex the index it is being inserted at (the index it will have
|
||||
* after it is inserted)
|
||||
* @param aNotify whether to notify the document (current document for
|
||||
* nsIContent, and |this| for nsIDocument) that the insert has
|
||||
* occurred
|
||||
*
|
||||
* @throws NS_ERROR_DOM_HIERARCHY_REQUEST_ERR if one attempts to have more
|
||||
* than one element node as a child of a document. Doing this will also
|
||||
* assert -- you shouldn't be doing it! Check with
|
||||
* nsIDocument::GetRootContent() first if you're not sure. Apart from this
|
||||
* one constraint, this doesn't do any checking on whether aKid is a valid
|
||||
* child of |this|.
|
||||
*
|
||||
* @throws NS_ERROR_OUT_OF_MEMORY in some cases (from BindToTree).
|
||||
*/
|
||||
virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
|
||||
PRBool aNotify) = 0;
|
||||
|
||||
/**
|
||||
* Append a content node to the end of the child list. This method handles
|
||||
* calling BindToTree on the child appropriately.
|
||||
*
|
||||
* @param aKid the content to append
|
||||
* @param aNotify whether to notify the document (current document for
|
||||
* nsIContent, and |this| for nsIDocument) that the append has
|
||||
* occurred
|
||||
*
|
||||
* @throws NS_ERROR_DOM_HIERARCHY_REQUEST_ERR if one attempts to have more
|
||||
* than one element node as a child of a document. Doing this will also
|
||||
* assert -- you shouldn't be doing it! Check with
|
||||
* nsIDocument::GetRootContent() first if you're not sure. Apart from this
|
||||
* one constraint, this doesn't do any checking on whether aKid is a valid
|
||||
* child of |this|.
|
||||
*
|
||||
* @throws NS_ERROR_OUT_OF_MEMORY in some cases (from BindToTree).
|
||||
*/
|
||||
virtual nsresult AppendChildTo(nsIContent* aKid, PRBool aNotify) = 0;
|
||||
|
||||
/**
|
||||
* Remove a child from this node. This method handles calling UnbindFromTree
|
||||
* on the child appropriately.
|
||||
*
|
||||
* @param aIndex the index of the child to remove
|
||||
* @param aNotify whether to notify the document (current document for
|
||||
* nsIContent, and |this| for nsIDocument) that the remove has
|
||||
* occurred
|
||||
*
|
||||
* Note: If there is no child at aIndex, this method will simply do nothing.
|
||||
*/
|
||||
virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify) = 0;
|
||||
|
||||
/**
|
||||
* Get a property associated with this node.
|
||||
*
|
||||
* @param aPropertyName name of property to get.
|
||||
* @param aStatus out parameter for storing resulting status.
|
||||
* Set to NS_PROPTABLE_PROP_NOT_THERE if the property
|
||||
* is not set.
|
||||
* @return the property. Null if the property is not set
|
||||
* (though a null return value does not imply the
|
||||
* property was not set, i.e. it can be set to null).
|
||||
*/
|
||||
void* GetProperty(nsIAtom *aPropertyName,
|
||||
nsresult *aStatus = nsnull) const
|
||||
{
|
||||
return GetProperty(0, aPropertyName, aStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a property associated with this node.
|
||||
*
|
||||
* @param aCategory category of property to get.
|
||||
* @param aPropertyName name of property to get.
|
||||
* @param aStatus out parameter for storing resulting status.
|
||||
* Set to NS_PROPTABLE_PROP_NOT_THERE if the property
|
||||
* is not set.
|
||||
* @return the property. Null if the property is not set
|
||||
* (though a null return value does not imply the
|
||||
* property was not set, i.e. it can be set to null).
|
||||
*/
|
||||
virtual void* GetProperty(PRUint32 aCategory,
|
||||
nsIAtom *aPropertyName,
|
||||
nsresult *aStatus = nsnull) const;
|
||||
|
||||
/**
|
||||
* Set a property to be associated with this node. This will overwrite an
|
||||
* existing value if one exists. The existing value is destroyed using the
|
||||
* destructor function given when that value was set.
|
||||
*
|
||||
* @param aPropertyName name of property to set.
|
||||
* @param aValue new value of property.
|
||||
* @param aDtor destructor function to be used when this property
|
||||
* is destroyed.
|
||||
*
|
||||
* @return NS_PROPTABLE_PROP_OVERWRITTEN (success value) if the property
|
||||
* was already set
|
||||
* @throws NS_ERROR_OUT_OF_MEMORY if that occurs
|
||||
*/
|
||||
nsresult SetProperty(nsIAtom *aPropertyName,
|
||||
void *aValue,
|
||||
NSPropertyDtorFunc aDtor = nsnull)
|
||||
{
|
||||
return SetProperty(0, aPropertyName, aValue, aDtor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a property to be associated with this node. This will overwrite an
|
||||
* existing value if one exists. The existing value is destroyed using the
|
||||
* destructor function given when that value was set.
|
||||
*
|
||||
* @param aCategory category of property to set.
|
||||
* @param aPropertyName name of property to set.
|
||||
* @param aValue new value of property.
|
||||
* @param aDtor destructor function to be used when this property
|
||||
* is destroyed.
|
||||
* @param aOldValue [out] previous value of property.
|
||||
*
|
||||
* @return NS_PROPTABLE_PROP_OVERWRITTEN (success value) if the property
|
||||
* was already set
|
||||
* @throws NS_ERROR_OUT_OF_MEMORY if that occurs
|
||||
*/
|
||||
virtual nsresult SetProperty(PRUint32 aCategory,
|
||||
nsIAtom *aPropertyName,
|
||||
void *aValue,
|
||||
NSPropertyDtorFunc aDtor = nsnull,
|
||||
void **aOldValue = nsnull);
|
||||
|
||||
/**
|
||||
* Destroys a property associated with this node. The value is destroyed
|
||||
* using the destruction function given when that value was set.
|
||||
*
|
||||
* @param aPropertyName name of property to destroy.
|
||||
*
|
||||
* @throws NS_PROPTABLE_PROP_NOT_THERE if the property was not set
|
||||
*/
|
||||
nsresult DeleteProperty(nsIAtom *aPropertyName)
|
||||
{
|
||||
return DeleteProperty(0, aPropertyName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys a property associated with this node. The value is destroyed
|
||||
* using the destruction function given when that value was set.
|
||||
*
|
||||
* @param aCategory category of property to destroy.
|
||||
* @param aPropertyName name of property to destroy.
|
||||
*
|
||||
* @throws NS_PROPTABLE_PROP_NOT_THERE if the property was not set
|
||||
*/
|
||||
virtual nsresult DeleteProperty(PRUint32 aCategory, nsIAtom *aPropertyName);
|
||||
|
||||
/**
|
||||
* Unset a property associated with this node. The value will not be
|
||||
* destroyed but rather returned. It is the caller's responsibility to
|
||||
* destroy the value after that point.
|
||||
*
|
||||
* @param aPropertyName name of property to unset.
|
||||
* @param aStatus out parameter for storing resulting status.
|
||||
* Set to NS_PROPTABLE_PROP_NOT_THERE if the property
|
||||
* is not set.
|
||||
* @return the property. Null if the property is not set
|
||||
* (though a null return value does not imply the
|
||||
* property was not set, i.e. it can be set to null).
|
||||
*/
|
||||
void* UnsetProperty(nsIAtom *aPropertyName,
|
||||
nsresult *aStatus = nsnull)
|
||||
{
|
||||
return UnsetProperty(0, aPropertyName, aStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unset a property associated with this node. The value will not be
|
||||
* destroyed but rather returned. It is the caller's responsibility to
|
||||
* destroy the value after that point.
|
||||
*
|
||||
* @param aCategory category of property to unset.
|
||||
* @param aPropertyName name of property to unset.
|
||||
* @param aStatus out parameter for storing resulting status.
|
||||
* Set to NS_PROPTABLE_PROP_NOT_THERE if the property
|
||||
* is not set.
|
||||
* @return the property. Null if the property is not set
|
||||
* (though a null return value does not imply the
|
||||
* property was not set, i.e. it can be set to null).
|
||||
*/
|
||||
virtual void* UnsetProperty(PRUint32 aCategory,
|
||||
nsIAtom *aPropertyName,
|
||||
nsresult *aStatus = nsnull);
|
||||
|
||||
PRBool HasProperties() const
|
||||
{
|
||||
return HasFlag(NODE_HAS_PROPERTIES);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inform node of range ownership changes. This allows the node to do the
|
||||
* right thing to ranges in the face of changes to the content model.
|
||||
*
|
||||
* RangeRemove -- informs content that it no longer owns a range endpoint
|
||||
* GetRangeList -- returns the list of ranges that have one or both endpoints
|
||||
* within this content item
|
||||
*/
|
||||
/**
|
||||
* Inform node that it owns one or both range endpoints
|
||||
* @param aRange the range the node owns
|
||||
*/
|
||||
virtual nsresult RangeAdd(nsIDOMRange* aRange);
|
||||
|
||||
/**
|
||||
* Inform node that it no longer owns either range endpoint
|
||||
* @param aRange the range the node no longer owns
|
||||
*/
|
||||
virtual void RangeRemove(nsIDOMRange* aRange);
|
||||
|
||||
/**
|
||||
* Get the list of ranges that have either endpoint in this node
|
||||
* item.
|
||||
* @return the list of ranges owned partially by this node. The
|
||||
* nsVoidArray is owned by the node object and its lifetime is
|
||||
* controlled completely by the node object.
|
||||
*/
|
||||
virtual const nsVoidArray *GetRangeList() const;
|
||||
|
||||
/**
|
||||
* Return the principal of this node. This is guaranteed to never be a null
|
||||
* pointer.
|
||||
*/
|
||||
nsIPrincipal* NodePrincipal() const {
|
||||
return mNodeInfo->NodeInfoManager()->DocumentPrincipal();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called before the capture phase of the event flow.
|
||||
* This is used to create the event target chain and implementations
|
||||
* should set the necessary members of nsEventChainPreVisitor.
|
||||
* At least aVisitor.mCanHandle must be set,
|
||||
* usually also aVisitor.mParentTarget if mCanHandle is PR_TRUE.
|
||||
* First one tells that this object can handle the aVisitor.mEvent event and
|
||||
* the latter one is the possible parent object for the event target chain.
|
||||
* @see nsEventDispatcher.h for more documentation about aVisitor.
|
||||
*
|
||||
* @param aVisitor the visitor object which is used to create the
|
||||
* event target chain for event dispatching.
|
||||
*
|
||||
* @note Only nsEventDispatcher should call this method.
|
||||
*/
|
||||
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor) = 0;
|
||||
|
||||
/**
|
||||
* Called after the bubble phase of the system event group.
|
||||
* The default handling of the event should happen here.
|
||||
* @param aVisitor the visitor object which is used during post handling.
|
||||
*
|
||||
* @see nsEventDispatcher.h for documentation about aVisitor.
|
||||
* @note Only nsEventDispatcher should call this method.
|
||||
*/
|
||||
virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor) = 0;
|
||||
|
||||
/**
|
||||
* Dispatch an event.
|
||||
* @param aEvent the event that is being dispatched.
|
||||
* @param aDOMEvent the event that is being dispatched, use if you want to
|
||||
* dispatch nsIDOMEvent, not only nsEvent.
|
||||
* @param aPresContext the current presentation context, can be nsnull.
|
||||
* @param aEventStatus the status returned from the function, can be nsnull.
|
||||
*
|
||||
* @note If both aEvent and aDOMEvent are used, aEvent must be the internal
|
||||
* event of the aDOMEvent.
|
||||
*
|
||||
* If aDOMEvent is not nsnull (in which case aEvent can be nsnull) it is used
|
||||
* for dispatching, otherwise aEvent is used.
|
||||
*
|
||||
* @deprecated This method is here just until all the callers outside Gecko
|
||||
* have been converted to use nsIDOMEventTarget::dispatchEvent.
|
||||
*/
|
||||
virtual nsresult DispatchDOMEvent(nsEvent* aEvent,
|
||||
nsIDOMEvent* aDOMEvent,
|
||||
nsPresContext* aPresContext,
|
||||
nsEventStatus* aEventStatus) = 0;
|
||||
|
||||
/**
|
||||
* Get the event listener manager, the guy you talk to to register for events
|
||||
* on this node.
|
||||
* @param aCreateIfNotFound If PR_FALSE, returns a listener manager only if
|
||||
* one already exists. [IN]
|
||||
* @param aResult The event listener manager [OUT]
|
||||
*/
|
||||
NS_IMETHOD GetListenerManager(PRBool aCreateIfNotFound,
|
||||
nsIEventListenerManager** aResult);
|
||||
|
||||
/**
|
||||
* Get the parent nsIContent for this node.
|
||||
* @return the parent, or null if no parent or the parent is not an nsIContent
|
||||
*/
|
||||
nsIContent* GetParent() const
|
||||
{
|
||||
return NS_LIKELY(mParentPtrBits & PARENT_BIT_PARENT_IS_CONTENT) ?
|
||||
NS_REINTERPRET_CAST(nsIContent*,
|
||||
mParentPtrBits & ~kParentBitMask) :
|
||||
nsnull;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parent nsINode for this node. This can be either an nsIContent,
|
||||
* an nsIDocument or an nsIAttribute.
|
||||
* @return the parent node
|
||||
*/
|
||||
nsINode* GetNodeParent() const
|
||||
{
|
||||
return NS_REINTERPRET_CAST(nsINode*, mParentPtrBits & ~kParentBitMask);
|
||||
}
|
||||
|
||||
// This class should be extended by subclasses that wish to store more
|
||||
// information in the slots.
|
||||
class nsSlots
|
||||
{
|
||||
public:
|
||||
nsSlots(PtrBits aFlags) : mFlags(aFlags)
|
||||
{
|
||||
}
|
||||
|
||||
PtrBits mFlags;
|
||||
|
||||
protected:
|
||||
// This is protected so that no-one accidentally deletes this rather than
|
||||
// the subclass
|
||||
~nsSlots() {}
|
||||
};
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Functions for managing flags and slots
|
||||
*/
|
||||
|
||||
PRBool HasSlots() const
|
||||
{
|
||||
return !(mFlagsOrSlots & NODE_DOESNT_HAVE_SLOTS);
|
||||
}
|
||||
|
||||
nsSlots* FlagsAsSlots() const
|
||||
{
|
||||
NS_ASSERTION(HasSlots(), "check HasSlots first");
|
||||
return NS_REINTERPRET_CAST(nsSlots*, mFlagsOrSlots);
|
||||
}
|
||||
|
||||
nsSlots* GetExistingSlots() const
|
||||
{
|
||||
return HasSlots() ? FlagsAsSlots() : nsnull;
|
||||
}
|
||||
|
||||
void SetSlots(nsSlots* aSlots)
|
||||
{
|
||||
NS_ASSERTION(!HasSlots(), "Already has slots");
|
||||
mFlagsOrSlots = NS_REINTERPRET_CAST(PtrBits, aSlots);
|
||||
}
|
||||
|
||||
PtrBits GetFlags() const
|
||||
{
|
||||
return NS_UNLIKELY(HasSlots()) ? FlagsAsSlots()->mFlags : mFlagsOrSlots;
|
||||
}
|
||||
|
||||
PRBool HasFlag(PtrBits aFlag) const
|
||||
{
|
||||
return !!(GetFlags() & aFlag);
|
||||
}
|
||||
|
||||
void SetFlags(PtrBits aFlagsToSet)
|
||||
{
|
||||
NS_ASSERTION(!(aFlagsToSet & (NODE_IS_ANONYMOUS | NODE_MAY_HAVE_FRAME)) ||
|
||||
IsNodeOfType(eCONTENT),
|
||||
"Flag only permitted on nsIContent nodes");
|
||||
PtrBits* flags = HasSlots() ? &FlagsAsSlots()->mFlags :
|
||||
&mFlagsOrSlots;
|
||||
*flags |= aFlagsToSet;
|
||||
}
|
||||
|
||||
void UnsetFlags(PtrBits aFlagsToUnset)
|
||||
{
|
||||
PtrBits* flags = HasSlots() ? &FlagsAsSlots()->mFlags :
|
||||
&mFlagsOrSlots;
|
||||
*flags &= ~aFlagsToUnset;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsINodeInfo> mNodeInfo;
|
||||
|
||||
enum { PARENT_BIT_INDOCUMENT = 1 << 0, PARENT_BIT_PARENT_IS_CONTENT = 1 << 1 };
|
||||
enum { kParentBitMask = 0x3 };
|
||||
|
||||
PtrBits mParentPtrBits;
|
||||
|
||||
/**
|
||||
* Used for either storing flags for this element or a pointer to
|
||||
* this contents nsContentSlots. See the definition of the
|
||||
* NODE_* macros for the layout of the bits in this
|
||||
* member.
|
||||
*/
|
||||
PtrBits mFlagsOrSlots;
|
||||
|
||||
#endif // MOZILLA_INTERNAL_API
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsINode_base, NS_INODE_IID)
|
||||
|
||||
#endif /* nsINode_h___ */
|
||||
@@ -1,331 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* nsINodeInfo is an interface to node info, such as name, prefix, namespace
|
||||
* ID and possibly other data that is shared between nodes (elements
|
||||
* and attributes) that have the same name, prefix and namespace ID within
|
||||
* the same document.
|
||||
*
|
||||
* nsNodeInfoManager's are internal objects that manage a list of
|
||||
* nsINodeInfo's, every document object should hold a strong reference to
|
||||
* a nsNodeInfoManager and every nsINodeInfo also holds a strong reference
|
||||
* to their owning manager. When a nsINodeInfo is no longer used it will
|
||||
* automatically remove itself from its owner manager, and when all
|
||||
* nsINodeInfo's have been removed from a nsNodeInfoManager and all external
|
||||
* references are released the nsNodeInfoManager deletes itself.
|
||||
*
|
||||
* -- jst@netscape.com
|
||||
*/
|
||||
|
||||
#ifndef nsINodeInfo_h___
|
||||
#define nsINodeInfo_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsDOMString.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsNodeInfoManager.h"
|
||||
|
||||
// Forward declarations
|
||||
class nsIDocument;
|
||||
class nsIURI;
|
||||
class nsIPrincipal;
|
||||
|
||||
// IID for the nsINodeInfo interface
|
||||
// 35e53115-b884-4cfc-aa95-bdf0aa5152cf
|
||||
#define NS_INODEINFO_IID \
|
||||
{ 0x35e53115, 0xb884, 0x4cfc, \
|
||||
{ 0xaa, 0x95, 0xbd, 0xf0, 0xaa, 0x51, 0x52, 0xcf } }
|
||||
|
||||
class nsINodeInfo : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_INODEINFO_IID)
|
||||
|
||||
nsINodeInfo()
|
||||
: mInner(nsnull, nsnull, kNameSpaceID_None),
|
||||
mOwnerManager(nsnull)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the name from this node as a string, this does not include the prefix.
|
||||
*
|
||||
* For the HTML element "<body>" this will return "body" and for the XML
|
||||
* element "<html:body>" this will return "body".
|
||||
*/
|
||||
void GetName(nsAString& aName) const
|
||||
{
|
||||
mInner.mName->ToString(aName);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the name from this node as an atom, this does not include the prefix.
|
||||
* This function never returns a null atom.
|
||||
*
|
||||
* For the HTML element "<body>" this will return the "body" atom and for
|
||||
* the XML element "<html:body>" this will return the "body" atom.
|
||||
*/
|
||||
nsIAtom* NameAtom() const
|
||||
{
|
||||
return mInner.mName;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the qualified name from this node as a string, the qualified name
|
||||
* includes the prefix, if one exists.
|
||||
*
|
||||
* For the HTML element "<body>" this will return "body" and for the XML
|
||||
* element "<html:body>" this will return "html:body".
|
||||
*/
|
||||
virtual void GetQualifiedName(nsAString& aQualifiedName) const = 0;
|
||||
|
||||
/*
|
||||
* Get the local name from this node as a string, GetLocalName() gets the
|
||||
* same string as GetName() but only if the node has a prefix and/or a
|
||||
* namespace URI. If the node has neither a prefix nor a namespace URI the
|
||||
* local name is a null string.
|
||||
*
|
||||
* For the HTML element "<body>" in a HTML document this will return a null
|
||||
* string and for the XML element "<html:body>" this will return "body".
|
||||
*/
|
||||
virtual void GetLocalName(nsAString& aLocalName) const = 0;
|
||||
|
||||
/*
|
||||
* Get the prefix from this node as a string.
|
||||
*
|
||||
* For the HTML element "<body>" this will return a null string and for
|
||||
* the XML element "<html:body>" this will return the string "html".
|
||||
*/
|
||||
void GetPrefix(nsAString& aPrefix) const
|
||||
{
|
||||
if (mInner.mPrefix) {
|
||||
mInner.mPrefix->ToString(aPrefix);
|
||||
} else {
|
||||
SetDOMStringToNull(aPrefix);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the prefix from this node as an atom.
|
||||
*
|
||||
* For the HTML element "<body>" this will return a null atom and for
|
||||
* the XML element "<html:body>" this will return the "html" atom.
|
||||
*/
|
||||
nsIAtom* GetPrefixAtom() const
|
||||
{
|
||||
return mInner.mPrefix;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the namespace URI for a node, if the node has a namespace URI.
|
||||
*
|
||||
* For the HTML element "<body>" in a HTML document this will return a null
|
||||
* string and for the XML element "<html:body>" (assuming that this element,
|
||||
* or one of it's ancestors has an
|
||||
* xmlns:html='http://www.w3.org/1999/xhtml' attribute) this will return
|
||||
* the string "http://www.w3.org/1999/xhtml".
|
||||
*/
|
||||
virtual nsresult GetNamespaceURI(nsAString& aNameSpaceURI) const = 0;
|
||||
|
||||
/*
|
||||
* Get the namespace ID for a node if the node has a namespace, if not this
|
||||
* returns kNameSpaceID_None.
|
||||
*
|
||||
* For the HTML element "<body>" in a HTML document this will return
|
||||
* kNameSpaceID_None and for the XML element "<html:body>" (assuming that
|
||||
* this element, or one of it's ancestors has an
|
||||
* xmlns:html='http://www.w3.org/1999/xhtml' attribute) this will return
|
||||
* the namespace ID for "http://www.w3.org/1999/xhtml".
|
||||
*/
|
||||
PRInt32 NamespaceID() const
|
||||
{
|
||||
return mInner.mNamespaceID;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get and set the ID attribute atom for this node.
|
||||
* See http://www.w3.org/TR/1998/REC-xml-19980210#sec-attribute-types
|
||||
* for the definition of an ID attribute.
|
||||
*
|
||||
*/
|
||||
nsIAtom* GetIDAttributeAtom() const
|
||||
{
|
||||
return mIDAttributeAtom;
|
||||
}
|
||||
|
||||
void SetIDAttributeAtom(nsIAtom* aID)
|
||||
{
|
||||
mIDAttributeAtom = aID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the owning node info manager. Only to be used inside Gecko, you can't
|
||||
* really do anything with the pointer outside Gecko anyway.
|
||||
*/
|
||||
nsNodeInfoManager *NodeInfoManager() const
|
||||
{
|
||||
return mOwnerManager;
|
||||
}
|
||||
|
||||
/*
|
||||
* Utility functions that can be used to check if a nodeinfo holds a specific
|
||||
* name, name and prefix, name and prefix and namespace ID, or just
|
||||
* namespace ID.
|
||||
*/
|
||||
PRBool Equals(nsINodeInfo *aNodeInfo) const
|
||||
{
|
||||
return aNodeInfo == this || aNodeInfo->Equals(mInner.mName, mInner.mPrefix,
|
||||
mInner.mNamespaceID);
|
||||
}
|
||||
|
||||
PRBool NameAndNamespaceEquals(nsINodeInfo *aNodeInfo) const
|
||||
{
|
||||
return aNodeInfo == this || aNodeInfo->Equals(mInner.mName,
|
||||
mInner.mNamespaceID);
|
||||
}
|
||||
|
||||
PRBool Equals(nsIAtom *aNameAtom) const
|
||||
{
|
||||
return mInner.mName == aNameAtom;
|
||||
}
|
||||
|
||||
PRBool Equals(nsIAtom *aNameAtom, nsIAtom *aPrefixAtom) const
|
||||
{
|
||||
return (mInner.mName == aNameAtom) && (mInner.mPrefix == aPrefixAtom);
|
||||
}
|
||||
|
||||
PRBool Equals(nsIAtom *aNameAtom, PRInt32 aNamespaceID) const
|
||||
{
|
||||
return ((mInner.mName == aNameAtom) &&
|
||||
(mInner.mNamespaceID == aNamespaceID));
|
||||
}
|
||||
|
||||
PRBool Equals(nsIAtom *aNameAtom, nsIAtom *aPrefixAtom,
|
||||
PRInt32 aNamespaceID) const
|
||||
{
|
||||
return ((mInner.mName == aNameAtom) &&
|
||||
(mInner.mPrefix == aPrefixAtom) &&
|
||||
(mInner.mNamespaceID == aNamespaceID));
|
||||
}
|
||||
|
||||
PRBool NamespaceEquals(PRInt32 aNamespaceID) const
|
||||
{
|
||||
return mInner.mNamespaceID == aNamespaceID;
|
||||
}
|
||||
|
||||
virtual PRBool Equals(const nsAString& aName) const = 0;
|
||||
virtual PRBool Equals(const nsAString& aName,
|
||||
const nsAString& aPrefix) const = 0;
|
||||
virtual PRBool Equals(const nsAString& aName,
|
||||
PRInt32 aNamespaceID) const = 0;
|
||||
virtual PRBool Equals(const nsAString& aName, const nsAString& aPrefix,
|
||||
PRInt32 aNamespaceID) const = 0;
|
||||
virtual PRBool NamespaceEquals(const nsAString& aNamespaceURI) const = 0;
|
||||
|
||||
PRBool QualifiedNameEquals(nsIAtom* aNameAtom) const
|
||||
{
|
||||
NS_PRECONDITION(aNameAtom, "Must have name atom");
|
||||
if (!GetPrefixAtom())
|
||||
return Equals(aNameAtom);
|
||||
|
||||
const char* utf8;
|
||||
aNameAtom->GetUTF8String(&utf8);
|
||||
return QualifiedNameEqualsInternal(nsDependentCString(utf8));
|
||||
}
|
||||
|
||||
PRBool QualifiedNameEquals(const nsACString& aQualifiedName) const
|
||||
{
|
||||
if (!GetPrefixAtom())
|
||||
return mInner.mName->EqualsUTF8(aQualifiedName);
|
||||
|
||||
return QualifiedNameEqualsInternal(aQualifiedName);
|
||||
}
|
||||
|
||||
/*
|
||||
* Retrieve a pointer to the document that owns this node info.
|
||||
*/
|
||||
nsIDocument* GetDocument() const
|
||||
{
|
||||
return mOwnerManager->GetDocument();
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual PRBool
|
||||
QualifiedNameEqualsInternal(const nsACString& aQualifiedName) const = 0;
|
||||
|
||||
/*
|
||||
* nsNodeInfoInner is used for two things:
|
||||
*
|
||||
* 1. as a member in nsNodeInfo for holding the name, prefix and
|
||||
* namespace ID
|
||||
* 2. as the hash key in the hash table in nsNodeInfoManager
|
||||
*
|
||||
* nsNodeInfoInner does not do any kind of reference counting,
|
||||
* that's up to the user of this class. Since nsNodeInfoInner is
|
||||
* typically used as a member of nsNodeInfo, the hash table doesn't
|
||||
* need to delete the keys. When the value (nsNodeInfo) is deleted
|
||||
* the key is automatically deleted.
|
||||
*/
|
||||
|
||||
class nsNodeInfoInner
|
||||
{
|
||||
public:
|
||||
nsNodeInfoInner(nsIAtom *aName, nsIAtom *aPrefix, PRInt32 aNamespaceID)
|
||||
: mName(aName), mPrefix(aPrefix), mNamespaceID(aNamespaceID)
|
||||
{
|
||||
}
|
||||
|
||||
nsIAtom* mName;
|
||||
nsIAtom* mPrefix;
|
||||
PRInt32 mNamespaceID;
|
||||
};
|
||||
|
||||
// nsNodeInfoManager needs to pass mInner to the hash table.
|
||||
friend class nsNodeInfoManager;
|
||||
|
||||
nsNodeInfoInner mInner;
|
||||
|
||||
nsCOMPtr<nsIAtom> mIDAttributeAtom;
|
||||
nsNodeInfoManager* mOwnerManager; // Strong reference!
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsINodeInfo, NS_INODEINFO_IID)
|
||||
|
||||
#endif /* nsINodeInfo_h___ */
|
||||
@@ -1,101 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org object loading code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Christian Biesinger <cbiesinger@web.de>.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIObjectFrame;
|
||||
interface nsIPluginInstance;
|
||||
|
||||
/**
|
||||
* This interface represents a content node that loads objects.
|
||||
*/
|
||||
[scriptable, uuid(42f9358e-300f-4a44-afd7-7830b750e955)]
|
||||
interface nsIObjectLoadingContent : nsISupports
|
||||
{
|
||||
const unsigned long TYPE_LOADING = 0;
|
||||
const unsigned long TYPE_IMAGE = 1;
|
||||
const unsigned long TYPE_PLUGIN = 2;
|
||||
const unsigned long TYPE_DOCUMENT = 3;
|
||||
const unsigned long TYPE_NULL = 4;
|
||||
|
||||
/**
|
||||
* The actual mime type (the one we got back from the network
|
||||
* request) for the element.
|
||||
*/
|
||||
readonly attribute ACString actualType;
|
||||
|
||||
/**
|
||||
* Gets the type of the content that's currently loaded. See
|
||||
* the constants above for the list of possible values.
|
||||
*/
|
||||
readonly attribute unsigned long displayedType;
|
||||
|
||||
/**
|
||||
* Gets the content type that corresponds to the give MIME type. See the
|
||||
* constants above for the list of possible values. If nothing else fits,
|
||||
* TYPE_NULL will be returned.
|
||||
*/
|
||||
unsigned long getContentTypeForMIMEType(in AUTF8String aMimeType);
|
||||
|
||||
|
||||
/**
|
||||
* Makes sure that a frame for this object exists, and that the plugin is
|
||||
* instantiated. This method does nothing if the type is not #TYPE_PLUGIN.
|
||||
* There is no guarantee that there will be a frame after this method is
|
||||
* called; for example, the node may have a display:none style. If plugin
|
||||
* instantiation is possible, it will be done synchronously by this method,
|
||||
* and the plugin instance will be returned. A success return value does not
|
||||
* necessarily mean that the instance is nonnull.
|
||||
*
|
||||
* This is a noscript method because it is internal and will go away once
|
||||
* plugin loading moves to content.
|
||||
*
|
||||
* @note If there is an error instantiating the plugin, this method will
|
||||
* trigger fallback to replacement content, and the type will change (and
|
||||
* this method will return a failure code)
|
||||
*/
|
||||
[noscript] nsIPluginInstance ensureInstantiation();
|
||||
|
||||
/**
|
||||
* Tells the content about an associated object frame.
|
||||
* This can be called multiple times for different frames.
|
||||
*
|
||||
* This is noscript because this is an internal method that will go away, and
|
||||
* because nsIObjectFrame is unscriptable.
|
||||
*/
|
||||
[noscript] void hasNewFrame(in nsIObjectFrame aFrame);
|
||||
};
|
||||
@@ -1,69 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsIPrivateDOMImplementation_h__
|
||||
#define nsIPrivateDOMImplementation_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIURI;
|
||||
class nsIPrincipal;
|
||||
|
||||
/*
|
||||
* Event listener manager interface.
|
||||
*/
|
||||
#define NS_IPRIVATEDOMIMPLEMENTATION_IID \
|
||||
{ /* 87c20441-8b0d-4383-a189-52fef1dd5d8a */ \
|
||||
0x87c20441, 0x8b0d, 0x4383, \
|
||||
{ 0xa1, 0x89, 0x52, 0xfe, 0xf1, 0xdd, 0x5d, 0x8a } }
|
||||
|
||||
class nsIPrivateDOMImplementation : public nsISupports {
|
||||
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IPRIVATEDOMIMPLEMENTATION_IID)
|
||||
|
||||
NS_IMETHOD Init(nsIURI* aDocumentURI, nsIURI* aBaseURI,
|
||||
nsIPrincipal* aPrincipal) = 0;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIPrivateDOMImplementation,
|
||||
NS_IPRIVATEDOMIMPLEMENTATION_IID)
|
||||
|
||||
nsresult
|
||||
NS_NewDOMImplementation(nsIDOMDOMImplementation** aInstancePtrResult);
|
||||
|
||||
#endif // nsIPrivateDOMImplementation_h__
|
||||
@@ -1,74 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released
|
||||
* March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/* A class for range utilities. */
|
||||
|
||||
#ifndef nsIRangeUtils_h___
|
||||
#define nsIRangeUtils_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
// Forward declarations
|
||||
class nsIDOMRange;
|
||||
class nsIDOMNode;
|
||||
class nsIContent;
|
||||
|
||||
// IID for the nsIRangeUtils interface
|
||||
#define NS_IRANGEUTILS_IID \
|
||||
{ 0xa6cf9127, 0x15b3, 0x11d2, {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
|
||||
|
||||
class nsIRangeUtils : public nsISupports {
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IRANGEUTILS_IID)
|
||||
|
||||
NS_IMETHOD_(PRInt32) ComparePoints(nsIDOMNode* aParent1, PRInt32 aOffset1,
|
||||
nsIDOMNode* aParent2, PRInt32 aOffset2) = 0;
|
||||
|
||||
NS_IMETHOD_(PRBool) IsNodeIntersectsRange(nsIContent* aNode, nsIDOMRange* aRange) = 0;
|
||||
|
||||
NS_IMETHOD CompareNodeToRange(nsIContent* aNode,
|
||||
nsIDOMRange* aRange,
|
||||
PRBool *outNodeBefore,
|
||||
PRBool *outNodeAfter) = 0;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIRangeUtils, NS_IRANGEUTILS_IID)
|
||||
|
||||
#endif /* nsIRangeUtils_h___ */
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vidur Apparao <vidur@netscape.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsIScriptElement_h___
|
||||
#define nsIScriptElement_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#define NS_ISCRIPTELEMENT_IID \
|
||||
{ 0x0511fba1, 0x1b67, 0x4338, \
|
||||
{ 0x98, 0xff, 0x42, 0xb9, 0x02, 0x0b, 0xeb, 0x92 } }
|
||||
|
||||
/**
|
||||
* Internal interface implemented by script elements
|
||||
*/
|
||||
class nsIScriptElement : public nsISupports {
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISCRIPTELEMENT_IID)
|
||||
|
||||
/**
|
||||
* Content type identifying the scripting language. Can be empty, in
|
||||
* which case javascript will be assumed.
|
||||
*/
|
||||
virtual void GetScriptType(nsAString& type) = 0;
|
||||
|
||||
/**
|
||||
* Location of script source text. Can return null, in which case
|
||||
* this is assumed to be an inline script element.
|
||||
*/
|
||||
virtual already_AddRefed<nsIURI> GetScriptURI() = 0;
|
||||
|
||||
/**
|
||||
* Script source text for inline script elements.
|
||||
*/
|
||||
virtual void GetScriptText(nsAString& text) = 0;
|
||||
|
||||
virtual void GetScriptCharset(nsAString& charset) = 0;
|
||||
|
||||
virtual void SetScriptLineNumber(PRUint32 aLineNumber) = 0;
|
||||
virtual PRUint32 GetScriptLineNumber() = 0;
|
||||
virtual void SetIsMalformed() = 0;
|
||||
virtual PRBool IsMalformed() = 0;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIScriptElement, NS_ISCRIPTELEMENT_IID)
|
||||
|
||||
#endif // nsIScriptElement_h___
|
||||
@@ -1,78 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Rick Potts <rpotts@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
|
||||
[uuid(375f787f-8d3a-4344-b540-293d5645c22c)]
|
||||
interface nsIScriptEventHandler : nsISupports
|
||||
{
|
||||
/**
|
||||
* IsSameEvent:
|
||||
*
|
||||
* Determines if this script event handler is bound to the given
|
||||
* object and event name.
|
||||
*
|
||||
* @param aObjectName Name of the object raising the event.
|
||||
*
|
||||
* @param aEventName Name of the event being raised.
|
||||
*
|
||||
* @param aArgCount Number of arguments expected by the event handler.
|
||||
*
|
||||
*/
|
||||
boolean IsSameEvent(in AString aObjectName,
|
||||
in AString aEventName,
|
||||
in unsigned long aArgCount);
|
||||
|
||||
/**
|
||||
* Invoke:
|
||||
*
|
||||
* Executes this script handler.
|
||||
*
|
||||
* @param aTargetObject Object to which the script handler is bound.
|
||||
*
|
||||
* @param aArgs Array of arguments passed to the script handler.
|
||||
* This is an array of jsvals.
|
||||
*
|
||||
* @param aArgCount Number of elements in the aArgs array.
|
||||
*
|
||||
*/
|
||||
void Invoke(in nsISupports aTargetObject,
|
||||
in voidPtr aArgs,
|
||||
in unsigned long aArgCount);
|
||||
};
|
||||
@@ -1,83 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Rick Potts <rpotts@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
|
||||
[uuid(b6427ace-dc77-495b-ab21-43baeb52bc27)]
|
||||
interface nsIScriptEventManager : nsISupports
|
||||
{
|
||||
/*
|
||||
* FindEventHandler:
|
||||
*
|
||||
* Returns a script event handler for the given object and event name.
|
||||
*
|
||||
* @param aObjectName Name of the object raising the event.
|
||||
*
|
||||
* @param aEventName Name of the event being raised.
|
||||
*
|
||||
* @param aArgCount Number of arguments expected by the event handler.
|
||||
*
|
||||
*/
|
||||
nsISupports FindEventHandler(in AString aObjectName,
|
||||
in AString aEventName,
|
||||
in unsigned long aArgCount);
|
||||
|
||||
/*
|
||||
*
|
||||
* InvokeEventHandler:
|
||||
*
|
||||
* Executes the script handler that was returned from FindEventHandler.
|
||||
*
|
||||
* @param aHandler Script event handler that was returned from
|
||||
* FindEventHandler.
|
||||
*
|
||||
* @param aTargetObject Object to which the script handler is bound.
|
||||
*
|
||||
* @param aArgs Array of arguments passed to the script handler.
|
||||
* This is an array of jsvals.
|
||||
*
|
||||
* @param aArgCount Number of elements in the aArgs array.
|
||||
*
|
||||
*/
|
||||
void InvokeEventHandler(in nsISupports aHandler,
|
||||
in nsISupports aTargetObject,
|
||||
in voidPtr aArgs,
|
||||
in unsigned long aArgCount);
|
||||
};
|
||||
|
||||
@@ -1,106 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vidur Apparao <vidur@netscape.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDocument;
|
||||
interface nsIScriptElement;
|
||||
interface nsIScriptLoaderObserver;
|
||||
|
||||
[scriptable, uuid(339a4eb5-dac6-4034-8c43-f4f8c645ce57)]
|
||||
interface nsIScriptLoader : nsISupports {
|
||||
/**
|
||||
* Initialize loader with a document. The container of this document
|
||||
* will be used for getting script evaluation information, including
|
||||
* the context in which to do the evaluation. The loader maintains a
|
||||
* strong reference to the document.
|
||||
*
|
||||
* @param aDocument The document to use as the basis for script
|
||||
* processing.
|
||||
*/
|
||||
void init(in nsIDocument aDocument);
|
||||
|
||||
/**
|
||||
* The loader maintains a strong reference to the document with
|
||||
* which it is initialized. This call forces the reference to
|
||||
* be dropped.
|
||||
*/
|
||||
void dropDocumentReference();
|
||||
|
||||
/**
|
||||
* Add an observer for all scripts loaded through this loader.
|
||||
*
|
||||
* @param aObserver observer for all script processing.
|
||||
*/
|
||||
void addObserver(in nsIScriptLoaderObserver aObserver);
|
||||
|
||||
/**
|
||||
* Remove an observer.
|
||||
*
|
||||
* @param aObserver observer to be removed
|
||||
*/
|
||||
void removeObserver(in nsIScriptLoaderObserver aObserver);
|
||||
|
||||
/**
|
||||
* Process a script element. This will include both loading the
|
||||
* source of the element if it is not inline and evaluating
|
||||
* the script itself.
|
||||
*
|
||||
* @param aElement The element representing the script to be loaded and
|
||||
* evaluated.
|
||||
* @param aObserver An observer for this script load only
|
||||
*
|
||||
*/
|
||||
void processScriptElement(in nsIScriptElement aElement,
|
||||
in nsIScriptLoaderObserver aObserver);
|
||||
|
||||
/**
|
||||
* Gets the currently executing script. This is useful if you want to
|
||||
* generate a unique key based on the currently executing script.
|
||||
*/
|
||||
nsIScriptElement getCurrentScript();
|
||||
|
||||
/**
|
||||
* Whether the loader is enabled or not.
|
||||
* When disabled, processing of new script elements is disabled.
|
||||
* Any call to processScriptElement() will fail with a return code of
|
||||
* NS_ERROR_NOT_AVAILABLE. Note that this DOES NOT disable
|
||||
* currently loading or executing scripts.
|
||||
*/
|
||||
attribute boolean enabled;
|
||||
};
|
||||
@@ -1,92 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vidur Apparao <vidur@netscape.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIScriptElement;
|
||||
interface nsIURI;
|
||||
|
||||
[scriptable, uuid(501209d3-7edf-437d-9948-3c6d1c08ef7f)]
|
||||
interface nsIScriptLoaderObserver : nsISupports {
|
||||
|
||||
/**
|
||||
* The script is available for evaluation. For inline scripts, this
|
||||
* method will be called synchronously. For externally loaded scripts,
|
||||
* this method will be called when the load completes.
|
||||
*
|
||||
* @param aResult A result code representing the result of loading
|
||||
* a script. If this is a failure code, script evaluation
|
||||
* will not occur.
|
||||
* @param aElement The element being processed.
|
||||
* @param aIsInline Is this an inline script or externally loaded?
|
||||
* @param aWasPending Did script processing have to be delayed,
|
||||
* either for loading of an external script or
|
||||
* because processing of an earlier scheduled
|
||||
* script was delayed?
|
||||
* @param aURI What is the URI of the script (the document URI if
|
||||
* it is inline).
|
||||
* @param aLineNo At what line does the script appear (generally 1
|
||||
* if it is a loaded script).
|
||||
* @param aScript String representation of the string to be evaluated.
|
||||
*/
|
||||
void scriptAvailable(in nsresult aResult,
|
||||
in nsIScriptElement aElement,
|
||||
in boolean aIsInline,
|
||||
in boolean aWasPending,
|
||||
in nsIURI aURI,
|
||||
in PRInt32 aLineNo,
|
||||
in AString aScript);
|
||||
|
||||
/**
|
||||
* The script has been evaluated.
|
||||
*
|
||||
* @param aResult A result code representing the success or failure of
|
||||
* the script evaluation.
|
||||
* @param aElement The element being processed.
|
||||
* @param aIsInline Is this an inline script or externally loaded?
|
||||
* @param aWasPending Did script processing have to be delayed,
|
||||
* either for loading of an external script or
|
||||
* because processing of an earlier scheduled
|
||||
* script was delayed?
|
||||
*/
|
||||
void scriptEvaluated(in nsresult aResult,
|
||||
in nsIScriptElement aElement,
|
||||
in boolean aIsInline,
|
||||
in boolean aWasPending);
|
||||
|
||||
};
|
||||
@@ -1,169 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
/* THIS IS A PUBLIC INTERFACE */
|
||||
|
||||
interface nsIDOMNode;
|
||||
interface nsIDOMRange;
|
||||
|
||||
/**
|
||||
* Interface for manipulating and querying the current selected range
|
||||
* of nodes within the document.
|
||||
*
|
||||
* @status FROZEN
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
[scriptable, uuid(B2C7ED59-8634-4352-9E37-5484C8B6E4E1)]
|
||||
interface nsISelection : nsISupports
|
||||
{
|
||||
/**
|
||||
* Returns the node in which the selection begins.
|
||||
*/
|
||||
readonly attribute nsIDOMNode anchorNode;
|
||||
|
||||
/**
|
||||
* The offset within the (text) node where the selection begins.
|
||||
*/
|
||||
readonly attribute long anchorOffset;
|
||||
|
||||
/**
|
||||
* Returns the node in which the selection ends.
|
||||
*/
|
||||
readonly attribute nsIDOMNode focusNode;
|
||||
|
||||
/**
|
||||
* The offset within the (text) node where the selection ends.
|
||||
*/
|
||||
readonly attribute long focusOffset;
|
||||
|
||||
/**
|
||||
* Indicates if the selection is collapsed or not.
|
||||
*/
|
||||
readonly attribute boolean isCollapsed;
|
||||
|
||||
/**
|
||||
* Returns the number of ranges in the selection.
|
||||
*/
|
||||
readonly attribute long rangeCount;
|
||||
|
||||
/**
|
||||
* Returns the range at the specified index.
|
||||
*/
|
||||
nsIDOMRange getRangeAt(in long index);
|
||||
|
||||
/**
|
||||
* Collapses the selection to a single point, at the specified offset
|
||||
* in the given DOM node. When the selection is collapsed, and the content
|
||||
* is focused and editable, the caret will blink there.
|
||||
* @param parentNode The given dom node where the selection will be set
|
||||
* @param offset Where in given dom node to place the selection (the offset into the given node)
|
||||
*/
|
||||
void collapse(in nsIDOMNode parentNode, in long offset);
|
||||
|
||||
|
||||
/**
|
||||
* Extends the selection by moving the selection end to the specified node and offset,
|
||||
* preserving the selection begin position. The new selection end result will always
|
||||
* be from the anchorNode to the new focusNode, regardless of direction.
|
||||
* @param parentNode The node where the selection will be extended to
|
||||
* @param offset Where in node to place the offset in the new selection end
|
||||
*/
|
||||
void extend(in nsIDOMNode parentNode, in long offset);
|
||||
|
||||
/**
|
||||
* Collapses the whole selection to a single point at the start
|
||||
* of the current selection (irrespective of direction). If content
|
||||
* is focused and editable, the caret will blink there.
|
||||
*/
|
||||
void collapseToStart();
|
||||
|
||||
/**
|
||||
* Collapses the whole selection to a single point at the end
|
||||
* of the current selection (irrespective of direction). If content
|
||||
* is focused and editable, the caret will blink there.
|
||||
*/
|
||||
void collapseToEnd();
|
||||
|
||||
/**
|
||||
* Indicates whether the node is part of the selection. If partlyContained
|
||||
* is set to PR_TRUE, the function returns true when some part of the node
|
||||
* is part of the selection. If partlyContained is set to PR_FALSE, the
|
||||
* function only returns true when the entire node is part of the selection.
|
||||
*/
|
||||
boolean containsNode(in nsIDOMNode node, in boolean partlyContained);
|
||||
|
||||
/**
|
||||
* Adds all children of the specified node to the selection.
|
||||
* @param parentNode the parent of the children to be added to the selection.
|
||||
*/
|
||||
void selectAllChildren(in nsIDOMNode parentNode);
|
||||
|
||||
/**
|
||||
* Adds a range to the current selection.
|
||||
*/
|
||||
void addRange(in nsIDOMRange range);
|
||||
|
||||
/**
|
||||
* Removes a range from the current selection.
|
||||
*/
|
||||
void removeRange(in nsIDOMRange range);
|
||||
|
||||
/**
|
||||
* Removes all ranges from the current selection.
|
||||
*/
|
||||
void removeAllRanges();
|
||||
|
||||
/**
|
||||
* Deletes this selection from document the nodes belong to.
|
||||
*/
|
||||
void deleteFromDocument();
|
||||
|
||||
/**
|
||||
* Modifies the cursor Bidi level after a change in keyboard direction
|
||||
* @param langRTL is PR_TRUE if the new language is right-to-left or
|
||||
* PR_FALSE if the new language is left-to-right.
|
||||
*/
|
||||
void selectionLanguageChange(in boolean langRTL);
|
||||
|
||||
/**
|
||||
* Returns the whole selection into a plain text string.
|
||||
*/
|
||||
wstring toString();
|
||||
};
|
||||
@@ -1,242 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Sammy Ford
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsISelection.idl"
|
||||
#include "nsISelectionDisplay.idl"
|
||||
|
||||
%{C++
|
||||
typedef short SelectionType;
|
||||
typedef short SelectionRegion;
|
||||
%}
|
||||
|
||||
interface nsIDOMNode;
|
||||
interface nsISelection;
|
||||
interface nsISelectionDisplay;
|
||||
|
||||
[scriptable, uuid(93AAA4A9-B78E-42eb-9D67-5DE77EE2F54B)]
|
||||
interface nsISelectionController : nsISelectionDisplay
|
||||
{
|
||||
const short SELECTION_NONE=0;
|
||||
const short SELECTION_NORMAL=1;
|
||||
const short SELECTION_SPELLCHECK=2;
|
||||
const short SELECTION_IME_RAWINPUT=4;
|
||||
const short SELECTION_IME_SELECTEDRAWTEXT=8;
|
||||
const short SELECTION_IME_CONVERTEDTEXT=16;
|
||||
const short SELECTION_IME_SELECTEDCONVERTEDTEXT=32;
|
||||
const short SELECTION_ACCESSIBILITY=64; // For accessibility API usage
|
||||
const short NUM_SELECTIONTYPES=8;
|
||||
|
||||
const short SELECTION_ANCHOR_REGION = 0;
|
||||
const short SELECTION_FOCUS_REGION = 1;
|
||||
const short NUM_SELECTION_REGIONS = 2;
|
||||
|
||||
const short SELECTION_OFF = 0;
|
||||
const short SELECTION_HIDDEN =1;//>HIDDEN displays selection
|
||||
const short SELECTION_ON = 2;
|
||||
const short SELECTION_DISABLED = 3;
|
||||
const short SELECTION_ATTENTION = 4;
|
||||
|
||||
/**
|
||||
* SetDisplaySelection will set the display mode for the selection. OFF,ON,DISABLED
|
||||
*/
|
||||
void setDisplaySelection(in short toggle);
|
||||
|
||||
/**
|
||||
* GetDisplaySelection will get the display mode for the selection. OFF,ON,DISABLED
|
||||
*/
|
||||
short getDisplaySelection();
|
||||
|
||||
/**
|
||||
* GetSelection will return the selection that the presentation
|
||||
* shell may implement.
|
||||
*
|
||||
* @param aType will hold the type of selection //SelectionType
|
||||
* @param _return will hold the return value
|
||||
*/
|
||||
nsISelection getSelection(in short type);
|
||||
|
||||
/**
|
||||
* ScrollSelectionIntoView scrolls a region of the selection,
|
||||
* so that it is visible in the scrolled view.
|
||||
*
|
||||
* @param aType the selection to scroll into view. //SelectionType
|
||||
* @param aRegion the region inside the selection to scroll into view. //SelectionRegion
|
||||
* @param aIsSynchronous when true, scrolls the selection into view
|
||||
* before returning. If false, posts a request which is processed
|
||||
* at some point after the method returns.
|
||||
*/
|
||||
void scrollSelectionIntoView(in short type, in short region, in boolean isSynchronous);
|
||||
/**
|
||||
* RepaintSelection repaints the selection specified by aType.
|
||||
*
|
||||
* @param aType specifies the selection to repaint.
|
||||
*/
|
||||
void repaintSelection(in short type);
|
||||
|
||||
/**
|
||||
* Set the caret as enabled or disabled. An enabled caret will
|
||||
* draw or blink when made visible. A disabled caret will never show up.
|
||||
* Can be called any time.
|
||||
* @param aEnable PR_TRUE to enable caret. PR_FALSE to disable.
|
||||
* @return always NS_OK
|
||||
*/
|
||||
|
||||
void setCaretEnabled(in boolean enabled);
|
||||
|
||||
/**
|
||||
* Set the caret readonly or not. An readonly caret will
|
||||
* draw but not blink when made visible.
|
||||
* @param aReadOnly PR_TRUE to enable caret. PR_FALSE to disable.
|
||||
* @return always NS_OK
|
||||
*/
|
||||
void setCaretReadOnly(in boolean readOnly);
|
||||
|
||||
/**
|
||||
* Gets the current state of the caret.
|
||||
* @param aEnabled [OUT] set to the current caret state, as set by SetCaretEnabled
|
||||
* @return if aOutEnabled==null, returns NS_ERROR_INVALID_ARG
|
||||
* else NS_OK
|
||||
*/
|
||||
boolean getCaretEnabled();
|
||||
|
||||
/**
|
||||
* Show the caret even in selections. By default the caret is hidden unless the
|
||||
* selection is collapsed. Use this function to show the caret even in selections.
|
||||
* @param aVisibility PR_TRUE to show the caret in selections. PR_FALSE to hide.
|
||||
* @return always NS_OK
|
||||
*/
|
||||
void setCaretVisibilityDuringSelection(in boolean visibility);
|
||||
|
||||
/** CharacterMove will move the selection one character forward/backward in the document.
|
||||
* this will also have the effect of collapsing the selection if the aExtend = PR_FALSE
|
||||
* the "point" of selection that is extended is considered the "focus" point.
|
||||
* or the last point adjusted by the selection.
|
||||
* @param aForward forward or backward if PR_FALSE
|
||||
* @param aExtend should it collapse the selection of extend it?
|
||||
*/
|
||||
void characterMove(in boolean forward, in boolean extend);
|
||||
|
||||
/** WordMove will move the selection one word forward/backward in the document.
|
||||
* this will also have the effect of collapsing the selection if the aExtend = PR_FALSE
|
||||
* the "point" of selection that is extended is considered the "focus" point.
|
||||
* or the last point adjusted by the selection.
|
||||
* @param aForward forward or backward if PR_FALSE
|
||||
* @param aExtend should it collapse the selection of extend it?
|
||||
*/
|
||||
|
||||
void wordMove(in boolean forward, in boolean extend);
|
||||
|
||||
/** LineMove will move the selection one line forward/backward in the document.
|
||||
* this will also have the effect of collapsing the selection if the aExtend = PR_FALSE
|
||||
* the "point" of selection that is extended is considered the "focus" point.
|
||||
* or the last point adjusted by the selection.
|
||||
* @param aForward forward or backward if PR_FALSE
|
||||
* @param aExtend should it collapse the selection of extend it?
|
||||
*/
|
||||
void lineMove(in boolean forward, in boolean extend);
|
||||
|
||||
/** IntraLineMove will move the selection to the front of the line or end of the line
|
||||
* in the document.
|
||||
* this will also have the effect of collapsing the selection if the aExtend = PR_FALSE
|
||||
* the "point" of selection that is extended is considered the "focus" point.
|
||||
* or the last point adjusted by the selection.
|
||||
* @param aForward forward or backward if PR_FALSE
|
||||
* @param aExtend should it collapse the selection of extend it?
|
||||
*/
|
||||
void intraLineMove(in boolean forward, in boolean extend);
|
||||
|
||||
/** PageMove will move the selection one page forward/backward in the document.
|
||||
* this will also have the effect of collapsing the selection if the aExtend = PR_FALSE
|
||||
* the "point" of selection that is extended is considered the "focus" point.
|
||||
* or the last point adjusted by the selection.
|
||||
* @param aForward forward or backward if PR_FALSE
|
||||
* @param aExtend should it collapse the selection of extend it?
|
||||
*/
|
||||
void pageMove(in boolean forward, in boolean extend);
|
||||
|
||||
/** CompleteScroll will move page view to the top or bottom of the document
|
||||
* @param aForward forward or backward if PR_FALSE
|
||||
*/
|
||||
void completeScroll(in boolean forward);
|
||||
|
||||
/** CompleteMove will move page view to the top or bottom of the document
|
||||
* this will also have the effect of collapsing the selection if the aExtend = PR_FALSE
|
||||
* the "point" of selection that is extended is considered the "focus" point.
|
||||
* or the last point adjusted by the selection.
|
||||
* @param aForward forward or backward if PR_FALSE
|
||||
* @param aExtend should it collapse the selection of extend it?
|
||||
*/
|
||||
void completeMove(in boolean forward, in boolean extend);
|
||||
|
||||
|
||||
/** ScrollPage will scroll the page without affecting the selection.
|
||||
* @param aForward scroll forward or backwards in selection
|
||||
*/
|
||||
void scrollPage(in boolean forward);
|
||||
|
||||
/** ScrolLine will scroll line up or down dependent on the boolean
|
||||
* @param aForward scroll forward or backwards in selection
|
||||
*/
|
||||
void scrollLine(in boolean forward);
|
||||
|
||||
/** ScrolHorizontal will scroll left or right dependent on the boolean
|
||||
* @param aLeft if true will scroll left. if not will scroll right.
|
||||
*/
|
||||
void scrollHorizontal(in boolean left);
|
||||
/** SelectAll will select the whole page
|
||||
*/
|
||||
void selectAll();
|
||||
|
||||
/** CheckVisibility will return true if textnode and offsets are actually rendered
|
||||
* in the current precontext.
|
||||
* @param aNode textNode to test
|
||||
* @param aStartOffset offset in dom to first char of textnode to test
|
||||
* @param aEndOffset offset in dom to last char of textnode to test
|
||||
* @param aReturnBool boolean returned TRUE if visible FALSE if not
|
||||
*/
|
||||
boolean checkVisibility(in nsIDOMNode node, in short startOffset, in short endOffset);
|
||||
|
||||
};
|
||||
%{ C++
|
||||
#define NS_ISELECTIONCONTROLLER_CID \
|
||||
{ 0xd2d1d179, 0x85a7, 0x11d3, \
|
||||
{ 0x99, 0x32, 0x0, 0x10, 0x83, 0x1, 0x23, 0x3c }}
|
||||
%}
|
||||
@@ -1,71 +0,0 @@
|
||||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla browser.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications, Inc.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(0DDF9E1C-1DD2-11B2-A183-908A08AA75AE)]
|
||||
interface nsISelectionDisplay : nsISupports
|
||||
{
|
||||
const short DISPLAY_TEXT = 1; //display text selected.
|
||||
const short DISPLAY_IMAGES = 2; //show images selected
|
||||
const short DISPLAY_FRAMES = 4; //display hrules ect.
|
||||
const short DISPLAY_ALL = 7; //display all. used for isEditor as well
|
||||
|
||||
/*
|
||||
SetSelectionFlags used to set whether you want to see HRULES/IMAGES with border.
|
||||
also used to tell if the presshell is an editor right now. this should change
|
||||
|
||||
@param aToggle -either DISPLAY_(TEXT,IMAGES,FRAMES,ALL)
|
||||
This will tell the rendering engine to draw the different
|
||||
selection types.
|
||||
|
||||
@return NS_OK if successful.
|
||||
*/
|
||||
void setSelectionFlags(in short toggle);
|
||||
|
||||
/*
|
||||
GetSelectionFlags used to get whether you want to see HRULES/IMAGES with border.
|
||||
also used to tell if the presshell is an editor right now. this should change
|
||||
|
||||
@param short *aReturn - This will be filled with DISPLAY_(TEXT,IMAGE,FRAMES,ALL)
|
||||
bit flags.
|
||||
@return NS_OK if successful.
|
||||
*/
|
||||
short getSelectionFlags();
|
||||
|
||||
};
|
||||
@@ -1,56 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDOMDocument;
|
||||
interface nsISelection;
|
||||
|
||||
[scriptable, uuid(A6CF90E2-15B3-11d2-932E-00805F8ADD32)]
|
||||
interface nsISelectionListener : nsISupports
|
||||
{
|
||||
const short NO_REASON=0;
|
||||
const short DRAG_REASON=1;
|
||||
const short MOUSEDOWN_REASON=2;/*bitflags*/
|
||||
const short MOUSEUP_REASON=4;/*bitflags*/
|
||||
const short KEYPRESS_REASON=8;/*bitflags*/
|
||||
const short SELECTALL_REASON=16;
|
||||
|
||||
void notifySelectionChanged(in nsIDOMDocument doc, in nsISelection sel, in short reason);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsISelectionListener.idl"
|
||||
#include "nsIEnumerator.idl"
|
||||
|
||||
interface nsIDOMRange;
|
||||
interface nsISelectionListener;
|
||||
|
||||
%{C++
|
||||
class nsFrameSelection;
|
||||
class nsIFrame;
|
||||
class nsIPresShell;
|
||||
struct nsPoint;
|
||||
%}
|
||||
|
||||
[ptr] native nsFrameSelection(nsFrameSelection);
|
||||
[ptr] native nsIFrame(nsIFrame);
|
||||
[ptr] native nsIPresShell(nsIPresShell);
|
||||
[ref] native nsPointRef(nsPoint);
|
||||
|
||||
[scriptable, uuid(3225CA54-D7E1-4FF5-8EE9-091B0BFCDA1F)]
|
||||
interface nsISelectionPrivate : nsISupports
|
||||
{
|
||||
const short ENDOFPRECEDINGLINE=0;
|
||||
const short STARTOFNEXTLINE=1;
|
||||
|
||||
attribute boolean interlinePosition;
|
||||
|
||||
/* startBatchChanges
|
||||
match this up with endbatchChanges. will stop ui updates while multiple selection methods are called
|
||||
*/
|
||||
void startBatchChanges();
|
||||
|
||||
/* endBatchChanges
|
||||
match this up with startBatchChanges
|
||||
*/
|
||||
void endBatchChanges();
|
||||
|
||||
nsIEnumerator getEnumerator();
|
||||
wstring toStringWithFormat(in string formatType, in unsigned long flags, in PRInt32 wrapColumn);
|
||||
void addSelectionListener(in nsISelectionListener newListener);
|
||||
void removeSelectionListener(in nsISelectionListener listenerToRemove);
|
||||
|
||||
/* Table selection stuff
|
||||
We should probably move this and table-related
|
||||
items in nsFrameSelection to a
|
||||
new nsITableSelection interface
|
||||
*/
|
||||
const long TABLESELECTION_NONE = 0;
|
||||
const long TABLESELECTION_CELL = 1;
|
||||
const long TABLESELECTION_ROW = 2;
|
||||
const long TABLESELECTION_COLUMN = 3;
|
||||
const long TABLESELECTION_TABLE = 4;
|
||||
const long TABLESELECTION_ALLCELLS = 5;
|
||||
|
||||
/** Test if supplied range points to a single table element:
|
||||
* Result is one of above constants. "None" means
|
||||
* a table element isn't selected.
|
||||
*/
|
||||
long getTableSelectionType(in nsIDOMRange range);
|
||||
|
||||
/* Internal utility method to set the pres shell on a newly created selection */
|
||||
[noscript] void setPresShell(in nsIPresShell aPresShell);
|
||||
|
||||
/* canCacheFrameOffset
|
||||
* Frame Offset cache can be used just during calling nsEditor::EndPlaceHolderTransaction.
|
||||
* EndPlaceHolderTransaction will give rise to reflow/refreshing view/scroll, and call times
|
||||
* of nsTextFrame::GetPointFromOffset whose return value is to be cached.
|
||||
* see bugs 35296 and 199412
|
||||
*/
|
||||
[noscript] attribute boolean canCacheFrameOffset;
|
||||
|
||||
/* GetCachedOffsetForFrame
|
||||
* Returns cached value for nsTextFrame::GetPointFromOffset.
|
||||
*/
|
||||
[noscript] void getCachedFrameOffset(in nsIFrame aFrame, in PRInt32 inOffset, in nsPointRef aPoint);
|
||||
|
||||
/* getFrameSelection
|
||||
* Returnes a reference to the frame selection associated with this selection
|
||||
*/
|
||||
[noscript] nsFrameSelection getFrameSelection();
|
||||
};
|
||||
|
||||
@@ -1,123 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsIStyleSheetLinkingElement_h__
|
||||
#define nsIStyleSheetLinkingElement_h__
|
||||
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIParser;
|
||||
class nsIDocument;
|
||||
class nsICSSLoaderObserver;
|
||||
|
||||
#define NS_ISTYLESHEETLINKINGELEMENT_IID \
|
||||
{0xa6cf90e9, 0x15b3, 0x11d2, \
|
||||
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
class nsIStyleSheet;
|
||||
|
||||
class nsIStyleSheetLinkingElement : public nsISupports {
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISTYLESHEETLINKINGELEMENT_IID)
|
||||
|
||||
/**
|
||||
* Used to make the association between a style sheet and
|
||||
* the element that linked it to the document.
|
||||
*
|
||||
* @param aStyleSheet the style sheet associated with this
|
||||
* element.
|
||||
*/
|
||||
NS_IMETHOD SetStyleSheet(nsIStyleSheet* aStyleSheet) = 0;
|
||||
|
||||
/**
|
||||
* Used to obtain the style sheet linked in by this element.
|
||||
*
|
||||
* @param aStyleSheet out parameter that returns the style
|
||||
* sheet associated with this element.
|
||||
*/
|
||||
NS_IMETHOD GetStyleSheet(nsIStyleSheet*& aStyleSheet) = 0;
|
||||
|
||||
/**
|
||||
* Initialize the stylesheet linking element. This method passes
|
||||
* in a parser that the element blocks if the stylesheet is
|
||||
* a stylesheet that should be loaded with the parser blocked.
|
||||
* If aDontLoadStyle is true the element will ignore the first
|
||||
* modification to the element that would cause a stylesheet to
|
||||
* be loaded. Subsequent modifications to the element will not
|
||||
* be ignored.
|
||||
*/
|
||||
NS_IMETHOD InitStyleLinkElement(nsIParser *aParser, PRBool aDontLoadStyle) = 0;
|
||||
|
||||
/**
|
||||
* Tells this element to update the stylesheet.
|
||||
*
|
||||
* @param aOldDocument the document that this element was part
|
||||
* of (nsnull if we're not moving the element
|
||||
* from one document to another).
|
||||
* @param aObserver observer to notify once the stylesheet is loaded.
|
||||
* It might be notified before the function returns.
|
||||
* @param aForceUpdate If true, force the update even if the URI did not change
|
||||
*/
|
||||
NS_IMETHOD UpdateStyleSheet(nsIDocument *aOldDocument,
|
||||
nsICSSLoaderObserver* aObserver,
|
||||
PRBool aForceUpdate = PR_FALSE) = 0;
|
||||
|
||||
/**
|
||||
* Tells this element whether to update the stylesheet when the
|
||||
* element's properties change.
|
||||
*
|
||||
* @param aEnableUpdates update on changes or not.
|
||||
*/
|
||||
NS_IMETHOD SetEnableUpdates(PRBool aEnableUpdates) = 0;
|
||||
|
||||
/**
|
||||
* Gets the charset that the element claims the style sheet is in
|
||||
*
|
||||
* @param aCharset the charset
|
||||
*/
|
||||
NS_IMETHOD GetCharset(nsAString& aCharset) = 0;
|
||||
|
||||
// This doesn't entirely belong here since they only make sense for
|
||||
// some types of linking elements, but it's a better place than
|
||||
// anywhere else.
|
||||
virtual void SetLineNumber(PRUint32 aLineNumber) = 0;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIStyleSheetLinkingElement,
|
||||
NS_ISTYLESHEETLINKINGELEMENT_IID)
|
||||
|
||||
#endif // nsILinkingElement_h__
|
||||
@@ -1,103 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Jonas Sicking <sicking@bigfoot.com> (Original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIURI;
|
||||
interface nsIDOMDocument;
|
||||
interface nsIChannel;
|
||||
|
||||
/*************************************************************************
|
||||
* *
|
||||
* **** NOTICE **** *
|
||||
* *
|
||||
* nsISyncLoadDOMService defines synchronous methods to download *
|
||||
* data from the network. Any delays from the server will *
|
||||
* appear as a hang in the mozilla UI. Therefore, this interface *
|
||||
* should be avoided as much as possible. *
|
||||
* *
|
||||
* Don't make me come over there!! *
|
||||
* *
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
/**
|
||||
* The nsISyncDOMLoadService interface can be used to synchronously load
|
||||
* a document.
|
||||
*/
|
||||
|
||||
[scriptable, uuid(96a13c30-695a-492c-918b-04ae3edb4e4c)]
|
||||
interface nsISyncLoadDOMService : nsISupports
|
||||
{
|
||||
/**
|
||||
* Synchronously load the document from the specified channel.
|
||||
*
|
||||
* @param aChannel The channel to load the document from.
|
||||
* @param aLoaderURI URI of loading document. For security checks
|
||||
* null if no securitychecks should be done
|
||||
*
|
||||
* @returns The document loaded from the URI.
|
||||
*/
|
||||
nsIDOMDocument loadDocument(in nsIChannel aChannel, in nsIURI aLoaderURI);
|
||||
|
||||
nsIDOMDocument loadDocumentAsXML(in nsIChannel aChannel,
|
||||
in nsIURI aLoaderURI);
|
||||
|
||||
/**
|
||||
* Synchronously load an XML document from the specified
|
||||
* channel. The channel must be possible to open synchronously.
|
||||
*
|
||||
* @param aChannel The channel to load the document from.
|
||||
* @param aLoaderURI URI of loading document. For security checks
|
||||
* null if no securitychecks should be done
|
||||
*
|
||||
* @returns The document loaded from the URI.
|
||||
*/
|
||||
nsIDOMDocument loadLocalDocument(in nsIChannel aChannel,
|
||||
in nsIURI aLoaderURI);
|
||||
|
||||
/**
|
||||
* Synchronously load the xbl-document from the specified channel. The channel
|
||||
* must be possible to open synchronously.
|
||||
*
|
||||
* @param aChannel The channel to load the document from.
|
||||
*
|
||||
* @returns The document loaded from the URI.
|
||||
*/
|
||||
nsIDOMDocument loadLocalXBLDocument(in nsIChannel aChannel);
|
||||
};
|
||||
@@ -1,117 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsITextContent_h___
|
||||
#define nsITextContent_h___
|
||||
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDocument.h"
|
||||
class nsString;
|
||||
class nsTextFragment;
|
||||
|
||||
// IID for the nsITextContent interface
|
||||
// e4ef843f-1061-45e6-9c81-30eac2673f41
|
||||
#define NS_ITEXT_CONTENT_IID \
|
||||
{ 0xe4ef843f, 0x1061, 0x45e6, \
|
||||
{ 0x9c, 0x81, 0x30, 0xea, 0xc2, 0x67, 0x3f, 0x41 } }
|
||||
|
||||
/**
|
||||
* Interface for textual content. This interface is used to provide
|
||||
* an efficient access to text content.
|
||||
*/
|
||||
class nsITextContent : public nsIContent {
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ITEXT_CONTENT_IID)
|
||||
|
||||
nsITextContent(nsINodeInfo *aNodeInfo)
|
||||
: nsIContent(aNodeInfo)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Get direct access (but read only) to the text in the text content.
|
||||
*/
|
||||
virtual const nsTextFragment *Text() = 0;
|
||||
|
||||
/**
|
||||
* Get the length of the text content.
|
||||
*/
|
||||
virtual PRUint32 TextLength() = 0;
|
||||
|
||||
/**
|
||||
* Set the text to the given value. If aNotify is PR_TRUE then
|
||||
* the document is notified of the content change.
|
||||
*/
|
||||
virtual void SetText(const PRUnichar* aBuffer, PRUint32 aLength,
|
||||
PRBool aNotify) = 0;
|
||||
|
||||
/**
|
||||
* Set the text to the given value. If aNotify is PR_TRUE then
|
||||
* the document is notified of the content change.
|
||||
*/
|
||||
void SetText(const nsAString& aStr, PRBool aNotify)
|
||||
{
|
||||
SetText(aStr.BeginReading(), aStr.Length(), aNotify);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query method to see if the frame is nothing but whitespace
|
||||
*/
|
||||
virtual PRBool IsOnlyWhitespace() = 0;
|
||||
|
||||
/**
|
||||
* Append the text content to aResult.
|
||||
*/
|
||||
virtual void AppendTextTo(nsAString& aResult) = 0;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsITextContent, NS_ITEXT_CONTENT_IID)
|
||||
|
||||
// XXX These belong elsewhere
|
||||
/**
|
||||
* aNodeInfoManager must not be null.
|
||||
*/
|
||||
nsresult
|
||||
NS_NewTextNode(nsITextContent **aResult, nsNodeInfoManager *aNodeInfoManager);
|
||||
|
||||
/**
|
||||
* aNodeInfoManager must not be null.
|
||||
*/
|
||||
nsresult
|
||||
NS_NewCommentNode(nsIContent **aResult, nsNodeInfoManager *aNodeInfoManager);
|
||||
|
||||
|
||||
#endif /* nsITextContent_h___ */
|
||||
@@ -1,363 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDOMDocument;
|
||||
interface nsIDOMEventListener;
|
||||
interface nsIChannel;
|
||||
interface nsIVariant;
|
||||
|
||||
/**
|
||||
* Mozilla's XMLHttpRequest is modelled after Microsoft's IXMLHttpRequest
|
||||
* object. The goal has been to make Mozilla's version match Microsoft's
|
||||
* version as closely as possible, but there are bound to be some differences.
|
||||
*
|
||||
* In general, Microsoft's documentation for IXMLHttpRequest can be used.
|
||||
* Mozilla's interface definitions provide some additional documentation. The
|
||||
* web page to look at is http://www.mozilla.org/xmlextras/
|
||||
*
|
||||
* Mozilla's XMLHttpRequest object can be created in JavaScript like this:
|
||||
* new XMLHttpRequest()
|
||||
* compare to Internet Explorer:
|
||||
* new ActiveXObject("Msxml2.XMLHTTP")
|
||||
*
|
||||
* From JavaScript, the methods and properties visible in the XMLHttpRequest
|
||||
* object are a combination of nsIXMLHttpRequest and nsIJSXMLHttpRequest;
|
||||
* there is no need to differentiate between those interfaces.
|
||||
*
|
||||
* From native code, the way to set up onload and onerror handlers is a bit
|
||||
* different. Here is a comment from Johnny Stenback <jst@netscape.com>:
|
||||
*
|
||||
* The mozilla implementation of nsIXMLHttpRequest implements the interface
|
||||
* nsIDOMEventTarget and that's how you're supported to add event listeners.
|
||||
* Try something like this:
|
||||
*
|
||||
* nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(myxmlhttpreq));
|
||||
*
|
||||
* target->AddEventListener(NS_LITERAL_STRING("load"), mylistener,
|
||||
* PR_FALSE)
|
||||
*
|
||||
* where mylistener is your event listener object that implements the
|
||||
* interface nsIDOMEventListener.
|
||||
*
|
||||
* The 'onload', 'onerror', and 'onreadystatechange' attributes moved to
|
||||
* nsIJSXMLHttRequest, but if you're coding in C++ you should avoid using
|
||||
* those. Though actually, if you use addEventListener from C++ weird things
|
||||
* will happen too, since the result will depend on what JS happens to be on
|
||||
* the stack when you do it....
|
||||
*/
|
||||
[scriptable, uuid(7b3b3c62-9d53-4abc-bc89-c33ce78f439f)]
|
||||
interface nsIXMLHttpRequest : nsISupports
|
||||
{
|
||||
/**
|
||||
* The request uses a channel in order to perform the
|
||||
* request. This attribute represents the channel used
|
||||
* for the request. NULL if the channel has not yet been
|
||||
* created.
|
||||
*
|
||||
* In a multipart request case, this is the initial channel, not the
|
||||
* different parts in the multipart request.
|
||||
*
|
||||
* Mozilla only. Requires elevated privileges to access.
|
||||
*/
|
||||
readonly attribute nsIChannel channel;
|
||||
|
||||
/**
|
||||
* The response to the request is parsed as if it were a
|
||||
* text/xml stream. This attributes represents the response as
|
||||
* a DOM Document object. NULL if the request is unsuccessful or
|
||||
* has not yet been sent.
|
||||
*/
|
||||
readonly attribute nsIDOMDocument responseXML;
|
||||
|
||||
/**
|
||||
* The response to the request as text.
|
||||
* NULL if the request is unsuccessful or
|
||||
* has not yet been sent.
|
||||
*/
|
||||
readonly attribute AString responseText;
|
||||
|
||||
|
||||
/**
|
||||
* The status of the response to the request for HTTP requests.
|
||||
*/
|
||||
readonly attribute unsigned long status;
|
||||
|
||||
/**
|
||||
* The string representing the status of the response for
|
||||
* HTTP requests.
|
||||
*/
|
||||
readonly attribute AUTF8String statusText;
|
||||
|
||||
/**
|
||||
* If the request has been sent already, this method will
|
||||
* abort the request.
|
||||
*/
|
||||
void abort();
|
||||
|
||||
/**
|
||||
* Returns all of the response headers as a string for HTTP
|
||||
* requests.
|
||||
*
|
||||
* Note that this will return all the headers from the *current*
|
||||
* part of a multipart request, not from the original channel.
|
||||
*
|
||||
* @returns A string containing all of the response headers.
|
||||
* NULL if the response has not yet been received.
|
||||
*/
|
||||
string getAllResponseHeaders();
|
||||
|
||||
/**
|
||||
* Returns the text of the header with the specified name for
|
||||
* HTTP requests.
|
||||
*
|
||||
* @param header The name of the header to retrieve
|
||||
* @returns A string containing the text of the header specified.
|
||||
* NULL if the response has not yet been received or the
|
||||
* header does not exist in the response.
|
||||
*/
|
||||
ACString getResponseHeader(in AUTF8String header);
|
||||
|
||||
/**
|
||||
* Native (non-script) method to initialize a request. Note that
|
||||
* the request is not sent until the <code>send</code> method
|
||||
* is invoked.
|
||||
*
|
||||
* Will abort currently active loads.
|
||||
*
|
||||
* After the initial response, all event listeners will be cleared.
|
||||
* Call open() before setting new event listeners.
|
||||
*
|
||||
* @param method The HTTP method, for example "POST" or "GET". Ignored
|
||||
* if the URL is not a HTTP(S) URL.
|
||||
* @param url The URL to which to send the request.
|
||||
* @param async Whether the request is synchronous or asynchronous
|
||||
* i.e. whether send returns only after the response
|
||||
* is received or if it returns immediately after
|
||||
* sending the request. In the latter case, notification
|
||||
* of completion is sent through the event listeners.
|
||||
* This argument must be true if the multipart
|
||||
* attribute has been set to true, or an exception will
|
||||
* be thrown.
|
||||
* @param user A username for authentication if necessary.
|
||||
* @param password A password for authentication if necessary.
|
||||
*/
|
||||
[noscript] void openRequest(in AUTF8String method,
|
||||
in AUTF8String url,
|
||||
in boolean async,
|
||||
in AString user,
|
||||
in AString password);
|
||||
|
||||
/**
|
||||
* Meant to be a script-only method for initializing a request.
|
||||
* The parameters are similar to the ones detailed in the
|
||||
* description of <code>openRequest</code>, but the last
|
||||
* 3 are optional.
|
||||
*
|
||||
* Will abort currently active loads.
|
||||
*
|
||||
* After the initial response, all event listeners will be cleared.
|
||||
* Call open() before setting new event listeners.
|
||||
*
|
||||
* @param method The HTTP method - either "POST" or "GET". Ignored
|
||||
* if the URL is not a HTTP URL.
|
||||
* @param url The URL to which to send the request.
|
||||
* @param async (optional) Whether the request is synchronous or
|
||||
* asynchronous i.e. whether send returns only after
|
||||
* the response is received or if it returns immediately after
|
||||
* sending the request. In the latter case, notification
|
||||
* of completion is sent through the event listeners.
|
||||
* The default value is true.
|
||||
* This argument must be true if the multipart
|
||||
* attribute has been set to true, or an exception will
|
||||
* be thrown.
|
||||
* @param user (optional) A username for authentication if necessary.
|
||||
* The default value is the empty string
|
||||
* @param password (optional) A password for authentication if necessary.
|
||||
* The default value is the empty string
|
||||
*/
|
||||
void open(in AUTF8String method, in AUTF8String url);
|
||||
|
||||
/**
|
||||
* Sends the request. If the request is asynchronous, returns
|
||||
* immediately after sending the request. If it is synchronous
|
||||
* returns only after the response has been received.
|
||||
*
|
||||
* After the initial response, all event listeners will be cleared.
|
||||
* Call open() before setting new event listeners.
|
||||
*
|
||||
* @param body Either an instance of nsIDOMDocument, nsIInputStream
|
||||
* or a string (nsISupportsString in the native calling
|
||||
* case). This is used to populate the body of the
|
||||
* HTTP request if the HTTP request method is "POST".
|
||||
* If the parameter is a nsIDOMDocument, it is serialized.
|
||||
* If the parameter is a nsIInputStream, then it must be
|
||||
* compatible with nsIUploadChannel.setUploadStream, and a
|
||||
* Content-Length header will be added to the HTTP request
|
||||
* with a value given by nsIInputStream.available. Any
|
||||
* headers included at the top of the stream will be
|
||||
* treated as part of the message body. The MIME type of
|
||||
* the stream should be specified by setting the Content-
|
||||
* Type header via the setRequestHeader method before
|
||||
* calling send.
|
||||
*/
|
||||
void send(in nsIVariant body);
|
||||
|
||||
/**
|
||||
* Sets a HTTP request header for HTTP requests. You must call open
|
||||
* before setting the request headers.
|
||||
*
|
||||
* @param header The name of the header to set in the request.
|
||||
* @param value The body of the header.
|
||||
*/
|
||||
void setRequestHeader(in AUTF8String header, in AUTF8String value);
|
||||
|
||||
/**
|
||||
* The state of the request.
|
||||
*
|
||||
* Possible values:
|
||||
* 0 UNINITIALIZED open() has not been called yet.
|
||||
* 1 LOADING send() has not been called yet.
|
||||
* 2 LOADED send() has been called, headers and status are available.
|
||||
* 3 INTERACTIVE Downloading, responseText holds the partial data.
|
||||
* 4 COMPLETED Finished with all operations.
|
||||
*/
|
||||
readonly attribute long readyState;
|
||||
|
||||
/**
|
||||
* Override the mime type returned by the server (if any). This may
|
||||
* be used, for example, to force a stream to be treated and parsed
|
||||
* as text/xml, even if the server does not report it as such. This
|
||||
* must be done before the <code>send</code> method is invoked.
|
||||
*
|
||||
* @param mimetype The type used to override that returned by the server
|
||||
* (if any).
|
||||
*/
|
||||
void overrideMimeType(in AUTF8String mimetype);
|
||||
|
||||
/**
|
||||
* Set to true if the response is expected to be a stream of
|
||||
* possibly multiple (XML) documents. If set to true, the content
|
||||
* type of the initial response must be multipart/x-mixed-replace or
|
||||
* an error will be triggerd. All requests must be asynchronous.
|
||||
*
|
||||
* This enables server push. For each XML document that's written to
|
||||
* this request, a new XML DOM document is created and the onload
|
||||
* handler is called inbetween documents. Note that when this is
|
||||
* set, the onload handler and other event handlers are not reset
|
||||
* after the first XML document is loaded, and the onload handler
|
||||
* will be called as each part of the response is received.
|
||||
*/
|
||||
attribute boolean multipart;
|
||||
};
|
||||
|
||||
[scriptable, uuid(261676b4-d508-43bf-b099-74635a0ee2e9)]
|
||||
interface nsIJSXMLHttpRequest : nsISupports {
|
||||
/**
|
||||
* Meant to be a script-only mechanism for setting a load event listener.
|
||||
* The attribute is expected to be JavaScript function object. When
|
||||
* the load event occurs, the function is invoked.
|
||||
* This attribute should not be used from native code!!
|
||||
*
|
||||
* After the initial response, all event listeners will be cleared.
|
||||
* Call open() before setting new event listeners.
|
||||
*
|
||||
* Mozilla only.
|
||||
*/
|
||||
attribute nsIDOMEventListener onload;
|
||||
|
||||
/**
|
||||
* Meant to be a script-only mechanism for setting an error event listener.
|
||||
* The attribute is expected to be JavaScript function object. When
|
||||
* the error event occurs, the function is invoked.
|
||||
* This attribute should not be used from native code!!
|
||||
*
|
||||
* After the initial response, all event listeners will be cleared.
|
||||
* Call open() before setting new event listeners.
|
||||
*
|
||||
* Mozilla only.
|
||||
*/
|
||||
attribute nsIDOMEventListener onerror;
|
||||
|
||||
/**
|
||||
* Meant to be a script-only mechanism for setting a progress event listener.
|
||||
* The attribute is expected to be JavaScript function object. When
|
||||
* the error event occurs, the function is invoked.
|
||||
* This attribute should not be used from native code!!
|
||||
* This event listener may be called multiple times during the open request.
|
||||
*
|
||||
* After the initial response, all event listeners will be cleared.
|
||||
* Call open() before setting new event listeners.
|
||||
*
|
||||
* Mozilla only.
|
||||
*/
|
||||
attribute nsIDOMEventListener onprogress;
|
||||
|
||||
/**
|
||||
* Meant to be a script-only mechanism for setting an upload progress event
|
||||
* listener.
|
||||
* This attribute should not be used from native code!!
|
||||
* This event listener may be called multiple times during the upload..
|
||||
*
|
||||
* After the initial response, all event listeners will be cleared.
|
||||
* Call open() before setting new event listeners.
|
||||
*
|
||||
* Mozilla only.
|
||||
*/
|
||||
attribute nsIDOMEventListener onuploadprogress;
|
||||
|
||||
/**
|
||||
* Meant to be a script-only mechanism for setting a callback function.
|
||||
* The attribute is expected to be JavaScript function object. When the
|
||||
* readyState changes, the callback function will be called.
|
||||
* This attribute should not be used from native code!!
|
||||
*
|
||||
* After the initial response, all event listeners will be cleared.
|
||||
* Call open() before setting new event listeners.
|
||||
*/
|
||||
attribute nsIDOMEventListener onreadystatechange;
|
||||
};
|
||||
|
||||
%{ C++
|
||||
#define NS_XMLHTTPREQUEST_CID \
|
||||
{ /* d164e770-4157-11d4-9a42-000064657374 */ \
|
||||
0xd164e770, 0x4157, 0x11d4, \
|
||||
{0x9a, 0x42, 0x00, 0x00, 0x64, 0x65, 0x73, 0x74} }
|
||||
#define NS_XMLHTTPREQUEST_CONTRACTID \
|
||||
"@mozilla.org/xmlextras/xmlhttprequest;1"
|
||||
%}
|
||||
@@ -1,65 +0,0 @@
|
||||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Jonas Sicking <sicking@bigfoot.com> (Original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsIXPathEvaluatorInternal_h__
|
||||
#define nsIXPathEvaluatorInternal_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIDOMDocument;
|
||||
|
||||
#define NS_IXPATHEVALUATORINTERNAL_IID \
|
||||
{0xb4b72daa, 0x65d6, 0x440f, \
|
||||
{ 0xb6, 0x08, 0xe2, 0xee, 0x9a, 0x82, 0xf3, 0x13 }}
|
||||
|
||||
class nsIXPathEvaluatorInternal : public nsISupports
|
||||
{
|
||||
public:
|
||||
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IXPATHEVALUATORINTERNAL_IID)
|
||||
|
||||
/**
|
||||
* Sets the document this evaluator corresponds to
|
||||
*/
|
||||
NS_IMETHOD SetDocument(nsIDOMDocument* aDocument) = 0;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIXPathEvaluatorInternal,
|
||||
NS_IXPATHEVALUATORINTERNAL_IID)
|
||||
|
||||
#endif //nsIXPathEvaluatorInternal_h__
|
||||
@@ -1,100 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brian Ryner <bryner@brianryner.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsXMLNameSpaceMap_h_
|
||||
#define nsXMLNameSpaceMap_h_
|
||||
|
||||
#include "nsVoidArray.h"
|
||||
|
||||
class nsIAtom;
|
||||
|
||||
/**
|
||||
* nsXMLNameSpaceMap contains a set of prefixes which are mapped onto
|
||||
* namespaces. It allows the set to be searched by prefix or by namespace ID.
|
||||
*/
|
||||
class nsXMLNameSpaceMap
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Allocates a new nsXMLNameSpaceMap (with new()) and initializes it with the
|
||||
* xmlns and xml namespaces.
|
||||
*/
|
||||
static NS_HIDDEN_(nsXMLNameSpaceMap*) Create();
|
||||
|
||||
/**
|
||||
* Add a prefix and its corresponding namespace ID to the map.
|
||||
* Passing a null |aPrefix| corresponds to the default namespace, which may
|
||||
* be set to something other than kNameSpaceID_None.
|
||||
*/
|
||||
NS_HIDDEN_(nsresult) AddPrefix(nsIAtom *aPrefix, PRInt32 aNameSpaceID);
|
||||
|
||||
/**
|
||||
* Add a prefix and a namespace URI to the map. The URI will be converted
|
||||
* to its corresponding namespace ID.
|
||||
*/
|
||||
NS_HIDDEN_(nsresult) AddPrefix(nsIAtom *aPrefix, nsString &aURI);
|
||||
|
||||
/* Remove a prefix from the map. */
|
||||
NS_HIDDEN_(void) RemovePrefix(nsIAtom *aPrefix);
|
||||
|
||||
/*
|
||||
* Returns the namespace ID for the given prefix, if it is in the map.
|
||||
* If |aPrefix| is null and is not in the map, then a null namespace
|
||||
* (kNameSpaceID_None) is returned. If |aPrefix| is non-null and is not in
|
||||
* the map, then kNameSpaceID_Unknown is returned.
|
||||
*/
|
||||
NS_HIDDEN_(PRInt32) FindNameSpaceID(nsIAtom *aPrefix) const;
|
||||
|
||||
/**
|
||||
* If the given namespace ID is in the map, then the first prefix which
|
||||
* maps to that namespace is returned. Otherwise, null is returned.
|
||||
*/
|
||||
NS_HIDDEN_(nsIAtom*) FindPrefix(PRInt32 aNameSpaceID) const;
|
||||
|
||||
/* Removes all prefix mappings. */
|
||||
NS_HIDDEN_(void) Clear();
|
||||
|
||||
~nsXMLNameSpaceMap() { Clear(); }
|
||||
|
||||
private:
|
||||
nsXMLNameSpaceMap() NS_HIDDEN; // use Create() to create new instances
|
||||
|
||||
nsVoidArray mNameSpaces;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,164 +0,0 @@
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = content
|
||||
LIBRARY_NAME = gkconbase_s
|
||||
LIBXUL_LIBRARY = 1
|
||||
|
||||
REQUIRES = xpcom \
|
||||
string \
|
||||
dom \
|
||||
gfx \
|
||||
layout \
|
||||
widget \
|
||||
view \
|
||||
locale \
|
||||
htmlparser \
|
||||
js \
|
||||
webshell \
|
||||
necko \
|
||||
mimetype \
|
||||
caps \
|
||||
lwbrk \
|
||||
uconv \
|
||||
docshell \
|
||||
pref \
|
||||
xpconnect \
|
||||
unicharutil \
|
||||
intl \
|
||||
webbrowserpersist \
|
||||
imglib2 \
|
||||
plugin \
|
||||
prefetch \
|
||||
xuldoc \
|
||||
uriloader \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
nsAtomListUtils.h \
|
||||
nsAttrName.h \
|
||||
nsContentList.h \
|
||||
nsGkAtomList.h \
|
||||
nsGkAtoms.h \
|
||||
nsNodeInfoManager.h \
|
||||
nsPropertyTable.h \
|
||||
nsStubDocumentObserver.h \
|
||||
nsTextFragment.h \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
mozSanitizingSerializer.cpp \
|
||||
nsAtomListUtils.cpp \
|
||||
nsAttrAndChildArray.cpp \
|
||||
nsAttrValue.cpp \
|
||||
nsCommentNode.cpp \
|
||||
nsContentAreaDragDrop.cpp \
|
||||
nsContentIterator.cpp \
|
||||
nsContentList.cpp \
|
||||
nsContentPolicy.cpp \
|
||||
nsContentSink.cpp \
|
||||
nsContentUtils.cpp \
|
||||
nsCopySupport.cpp \
|
||||
nsDataDocumentContentPolicy.cpp \
|
||||
nsDOMAttribute.cpp \
|
||||
nsDOMAttributeMap.cpp \
|
||||
nsDOMDocumentType.cpp \
|
||||
nsDOMLists.cpp \
|
||||
nsDOMParser.cpp \
|
||||
nsDOMSerializer.cpp \
|
||||
nsDocument.cpp \
|
||||
nsDocumentEncoder.cpp \
|
||||
nsDocumentFragment.cpp \
|
||||
nsFrameLoader.cpp \
|
||||
nsGenConImageContent.cpp \
|
||||
nsGeneratedIterator.cpp \
|
||||
nsGenericDOMDataNode.cpp \
|
||||
nsGenericDOMNodeList.cpp \
|
||||
nsGenericElement.cpp \
|
||||
nsGkAtoms.cpp \
|
||||
nsHTMLContentSerializer.cpp \
|
||||
nsImageLoadingContent.cpp \
|
||||
nsLoadListenerProxy.cpp \
|
||||
nsMappedAttributes.cpp \
|
||||
nsNameSpaceManager.cpp \
|
||||
nsNodeInfo.cpp \
|
||||
nsNodeInfoManager.cpp \
|
||||
nsObjectLoadingContent.cpp \
|
||||
nsParserUtils.cpp \
|
||||
nsPlainTextSerializer.cpp \
|
||||
nsPropertyTable.cpp \
|
||||
nsRange.cpp \
|
||||
nsScriptEventManager.cpp \
|
||||
nsScriptLoader.cpp \
|
||||
nsStubDocumentObserver.cpp \
|
||||
nsStyleLinkElement.cpp \
|
||||
nsSyncLoadService.cpp \
|
||||
nsTextFragment.cpp \
|
||||
nsTextNode.cpp \
|
||||
nsTreeWalker.cpp \
|
||||
nsXMLContentSerializer.cpp \
|
||||
nsXMLHttpRequest.cpp \
|
||||
nsXMLNameSpaceMap.cpp \
|
||||
$(NULL)
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a
|
||||
# static lib.
|
||||
FORCE_STATIC_LIB = 1
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
INCLUDES += \
|
||||
-I$(srcdir)/../../events/src \
|
||||
-I$(srcdir)/../../xml/content/src \
|
||||
-I$(srcdir)/../../xul/base/src \
|
||||
-I$(srcdir)/../../xul/content/src \
|
||||
-I$(srcdir)/../../html/content/src \
|
||||
-I$(srcdir)/../../base/src \
|
||||
-I$(srcdir)/../../xbl/src \
|
||||
-I$(srcdir)/../../../layout/generic \
|
||||
-I$(srcdir)/../../../layout/style \
|
||||
-I$(srcdir)/../../../dom/src/base \
|
||||
$(NULL)
|
||||
|
||||
DEFINES += -D_IMPL_NS_LAYOUT
|
||||
@@ -1,697 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=2 sw=2 et tw=80: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org HTML Sanitizer code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ben Bucksch <mozilla@bucksch.org>.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Netscape
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* A serializer and content sink that removes potentially insecure or
|
||||
* otherwise dangerous or offending HTML (eg for display of HTML
|
||||
* e-mail attachments or something).
|
||||
*/
|
||||
|
||||
/* I used nsPlaintextSerializer as base for this class. I don't understand
|
||||
all of the functions in the beginning. Possible that I fail to do
|
||||
something or do something useless.
|
||||
I am not proud about the implementation here at all.
|
||||
Feel free to fix it :-).
|
||||
*/
|
||||
|
||||
#include "mozSanitizingSerializer.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsIDOMText.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsITextContent.h"
|
||||
#include "nsTextFragment.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "plstr.h"
|
||||
#include "nsIProperties.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsEscape.h"
|
||||
|
||||
//#define DEBUG_BenB
|
||||
|
||||
static inline PRUnichar* escape(const nsString& source)
|
||||
{
|
||||
return nsEscapeHTML2(source.get(), source.Length());
|
||||
}
|
||||
|
||||
/* XXX: |printf|s in some error conditions. They are intended as information
|
||||
for the user, because they complain about malformed pref values.
|
||||
Not sure, if popping up dialog boxes is the right thing for such code
|
||||
(and if so, how to do it).
|
||||
*/
|
||||
|
||||
#define TEXT_REMOVED "<Text removed>"
|
||||
#define TEXT_BREAKER "|"
|
||||
|
||||
nsresult NS_NewSanitizingHTMLSerializer(nsIContentSerializer** aSerializer)
|
||||
{
|
||||
mozSanitizingHTMLSerializer* it = new mozSanitizingHTMLSerializer();
|
||||
if (!it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
NS_ADDREF(it);
|
||||
*aSerializer = it;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mozSanitizingHTMLSerializer::mozSanitizingHTMLSerializer()
|
||||
: mSkipLevel(0),
|
||||
mAllowedTags(30) // Just some initial buffer size
|
||||
{
|
||||
mOutputString = nsnull;
|
||||
}
|
||||
|
||||
mozSanitizingHTMLSerializer::~mozSanitizingHTMLSerializer()
|
||||
{
|
||||
#ifdef DEBUG_BenB
|
||||
printf("Output:\n%s\n", NS_LossyConvertUTF16toASCII(*mOutputString).get());
|
||||
#endif
|
||||
mAllowedTags.Enumerate(ReleaseProperties);
|
||||
}
|
||||
|
||||
//<copy from="xpcom/ds/nsProperties.cpp">
|
||||
PRBool PR_CALLBACK
|
||||
mozSanitizingHTMLSerializer::ReleaseProperties(nsHashKey* key, void* data,
|
||||
void* closure)
|
||||
{
|
||||
nsIProperties* prop = (nsIProperties*)data;
|
||||
NS_IF_RELEASE(prop);
|
||||
return PR_TRUE;
|
||||
}
|
||||
//</copy>
|
||||
|
||||
NS_IMPL_ISUPPORTS4(mozSanitizingHTMLSerializer,
|
||||
nsIContentSerializer,
|
||||
nsIContentSink,
|
||||
nsIHTMLContentSink,
|
||||
mozISanitizingHTMLSerializer)
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSanitizingHTMLSerializer::Init(PRUint32 aFlags, PRUint32 dummy,
|
||||
const char* aCharSet, PRBool aIsCopying)
|
||||
{
|
||||
NS_ENSURE_TRUE(nsContentUtils::GetParserService(), NS_ERROR_UNEXPECTED);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSanitizingHTMLSerializer::Initialize(nsAString* aOutString,
|
||||
PRUint32 aFlags,
|
||||
const nsAString& allowedTags)
|
||||
{
|
||||
nsresult rv = Init(aFlags, 0, nsnull, PR_FALSE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// XXX This is wrong. It violates XPCOM string ownership rules.
|
||||
// We're only getting away with this because instances of this
|
||||
// class are restricted to single function scope.
|
||||
// (Comment copied from nsPlaintextSerializer)
|
||||
mOutputString = aOutString;
|
||||
|
||||
ParsePrefs(allowedTags);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// This is not used within the class, but maybe called from somewhere else?
|
||||
NS_IMETHODIMP
|
||||
mozSanitizingHTMLSerializer::Flush(nsAString& aStr)
|
||||
{
|
||||
#ifdef DEBUG_BenB
|
||||
printf("Flush: -%s-", NS_LossyConvertUTF16toASCII(aStr).get());
|
||||
#endif
|
||||
Write(aStr);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSanitizingHTMLSerializer::AppendDocumentStart(nsIDOMDocument *aDocument,
|
||||
nsAString& aStr)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
mozSanitizingHTMLSerializer::Write(const nsAString& aString)
|
||||
{
|
||||
mOutputString->Append(aString);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSanitizingHTMLSerializer::IsEnabled(PRInt32 aTag, PRBool* aReturn)
|
||||
{
|
||||
*aReturn = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true, if the id represents a container
|
||||
*/
|
||||
PRBool
|
||||
mozSanitizingHTMLSerializer::IsContainer(PRInt32 aId)
|
||||
{
|
||||
PRBool isContainer = PR_FALSE;
|
||||
|
||||
nsIParserService* parserService = nsContentUtils::GetParserService();
|
||||
if (parserService) {
|
||||
parserService->IsContainer(aId, isContainer);
|
||||
}
|
||||
|
||||
return isContainer;
|
||||
}
|
||||
|
||||
|
||||
/* XXX I don't really know, what these functions do, but they seem to be
|
||||
needed ;-). Mostly copied from nsPlaintextSerializer. */
|
||||
/* akk says:
|
||||
"I wonder if the sanitizing class could inherit from nsHTMLSerializer,
|
||||
so that at least these methods that none of us understand only have to be
|
||||
written once?" */
|
||||
|
||||
// static
|
||||
PRInt32
|
||||
mozSanitizingHTMLSerializer::GetIdForContent(nsIContent* aContent)
|
||||
{
|
||||
if (!aContent->IsNodeOfType(nsINode::eHTML)) {
|
||||
return eHTMLTag_unknown;
|
||||
}
|
||||
|
||||
nsIParserService* parserService = nsContentUtils::GetParserService();
|
||||
|
||||
return parserService ? parserService->HTMLAtomTagToId(aContent->Tag()) :
|
||||
eHTMLTag_unknown;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSanitizingHTMLSerializer::AppendText(nsIDOMText* aText,
|
||||
PRInt32 aStartOffset,
|
||||
PRInt32 aEndOffset,
|
||||
nsAString& aStr)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
mOutputString = &aStr;
|
||||
|
||||
nsAutoString linebuffer;
|
||||
rv = DoAddLeaf(eHTMLTag_text, linebuffer);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSanitizingHTMLSerializer::AppendElementStart(nsIDOMElement *aElement,
|
||||
nsIDOMElement *aOriginalElement,
|
||||
nsAString& aStr)
|
||||
{
|
||||
NS_ENSURE_ARG(aElement);
|
||||
|
||||
mContent = do_QueryInterface(aElement);
|
||||
NS_ENSURE_TRUE(mContent, NS_ERROR_FAILURE);
|
||||
|
||||
mOutputString = &aStr;
|
||||
|
||||
PRInt32 id = GetIdForContent(mContent);
|
||||
|
||||
PRBool isContainer = IsContainer(id);
|
||||
|
||||
nsresult rv;
|
||||
if (isContainer) {
|
||||
rv = DoOpenContainer(id);
|
||||
}
|
||||
else {
|
||||
rv = DoAddLeaf(id, EmptyString());
|
||||
}
|
||||
|
||||
mContent = 0;
|
||||
mOutputString = nsnull;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSanitizingHTMLSerializer::AppendElementEnd(nsIDOMElement *aElement,
|
||||
nsAString& aStr)
|
||||
{
|
||||
NS_ENSURE_ARG(aElement);
|
||||
|
||||
mContent = do_QueryInterface(aElement);
|
||||
NS_ENSURE_TRUE(mContent, NS_ERROR_FAILURE);
|
||||
|
||||
mOutputString = &aStr;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
PRInt32 id = GetIdForContent(mContent);
|
||||
|
||||
PRBool isContainer = IsContainer(id);
|
||||
|
||||
if (isContainer) {
|
||||
rv = DoCloseContainer(id);
|
||||
}
|
||||
|
||||
mContent = 0;
|
||||
mOutputString = nsnull;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSanitizingHTMLSerializer::OpenContainer(const nsIParserNode& aNode)
|
||||
{
|
||||
PRInt32 type = aNode.GetNodeType();
|
||||
|
||||
mParserNode = NS_CONST_CAST(nsIParserNode *, &aNode);
|
||||
return DoOpenContainer(type);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSanitizingHTMLSerializer::CloseContainer(const nsHTMLTag aTag)
|
||||
{
|
||||
return DoCloseContainer(aTag);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSanitizingHTMLSerializer::AddLeaf(const nsIParserNode& aNode)
|
||||
{
|
||||
eHTMLTags type = (eHTMLTags)aNode.GetNodeType();
|
||||
const nsAString& text = aNode.GetText();
|
||||
|
||||
mParserNode = NS_CONST_CAST(nsIParserNode*, &aNode);
|
||||
return DoAddLeaf(type, text);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSanitizingHTMLSerializer::AddDocTypeDecl(const nsIParserNode& aNode)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSanitizingHTMLSerializer::SetDocumentCharset(nsACString& aCharset)
|
||||
{
|
||||
// No idea, if this works - it isn't invoked by |TestOutput|.
|
||||
Write(NS_LITERAL_STRING("\n<meta http-equiv=\"Context-Type\" content=\"text/html; charset=")
|
||||
/* Danger: breaking the line within the string literal, like
|
||||
"foo"\n"bar", breaks win32! */
|
||||
+ nsAdoptingString(escape(NS_ConvertASCIItoUTF16(aCharset)))
|
||||
+ NS_LITERAL_STRING("\">\n"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSanitizingHTMLSerializer::OpenHead()
|
||||
{
|
||||
// XXX We don't have a parser node here, is it okay to ignore this?
|
||||
// return OpenContainer(aNode);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Here comes the actual code...
|
||||
|
||||
nsresult
|
||||
mozSanitizingHTMLSerializer::DoOpenContainer(PRInt32 aTag)
|
||||
{
|
||||
eHTMLTags type = (eHTMLTags)aTag;
|
||||
|
||||
if (mSkipLevel == 0 && IsAllowedTag(type))
|
||||
{
|
||||
nsIParserService* parserService = nsContentUtils::GetParserService();
|
||||
if (!parserService)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
const PRUnichar* tag_name = parserService->HTMLIdToStringTag(aTag);
|
||||
NS_ENSURE_TRUE(tag_name, NS_ERROR_INVALID_POINTER);
|
||||
|
||||
Write(NS_LITERAL_STRING("<") + nsDependentString(tag_name));
|
||||
|
||||
// Attributes
|
||||
if (mParserNode)
|
||||
{
|
||||
PRInt32 count = mParserNode->GetAttributeCount();
|
||||
for (PRInt32 i = 0; i < count; i++)
|
||||
{
|
||||
const nsAString& key = mParserNode->GetKeyAt(i);
|
||||
if(IsAllowedAttribute(type, key))
|
||||
{
|
||||
// Ensure basic sanity of value
|
||||
nsAutoString value(mParserNode->GetValueAt(i));
|
||||
// SanitizeAttrValue() modifies |value|
|
||||
if (NS_SUCCEEDED(SanitizeAttrValue(type, key, value)))
|
||||
{
|
||||
// Write out
|
||||
Write(NS_LITERAL_STRING(" "));
|
||||
Write(key); // I get an infinive loop with | + key + | !!!
|
||||
Write(NS_LITERAL_STRING("=\"") + value + NS_LITERAL_STRING("\""));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Write(NS_LITERAL_STRING(">"));
|
||||
}
|
||||
else if (mSkipLevel != 0 || type == eHTMLTag_script || type == eHTMLTag_style)
|
||||
++mSkipLevel;
|
||||
else
|
||||
Write(NS_LITERAL_STRING(" "));
|
||||
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
nsresult
|
||||
mozSanitizingHTMLSerializer::DoCloseContainer(PRInt32 aTag)
|
||||
{
|
||||
eHTMLTags type = (eHTMLTags)aTag;
|
||||
|
||||
if (mSkipLevel == 0 && IsAllowedTag(type)) {
|
||||
nsIParserService* parserService = nsContentUtils::GetParserService();
|
||||
if (!parserService)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
const PRUnichar* tag_name = parserService->HTMLIdToStringTag(aTag);
|
||||
NS_ENSURE_TRUE(tag_name, NS_ERROR_INVALID_POINTER);
|
||||
|
||||
Write(NS_LITERAL_STRING("</") + nsDependentString(tag_name)
|
||||
+ NS_LITERAL_STRING(">"));
|
||||
}
|
||||
else if (mSkipLevel == 0)
|
||||
Write(NS_LITERAL_STRING(" "));
|
||||
else
|
||||
--mSkipLevel;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
mozSanitizingHTMLSerializer::DoAddLeaf(PRInt32 aTag,
|
||||
const nsAString& aText)
|
||||
{
|
||||
if (mSkipLevel != 0)
|
||||
return NS_OK;
|
||||
|
||||
eHTMLTags type = (eHTMLTags)aTag;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (type == eHTMLTag_whitespace ||
|
||||
type == eHTMLTag_newline)
|
||||
{
|
||||
Write(aText); // sure to be safe?
|
||||
}
|
||||
else if (type == eHTMLTag_text)
|
||||
{
|
||||
nsAutoString text(aText);
|
||||
if(NS_SUCCEEDED(SanitizeTextNode(text)))
|
||||
Write(text);
|
||||
else
|
||||
Write(NS_LITERAL_STRING(TEXT_REMOVED)); // Does not happen (yet)
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
else if (type == eHTMLTag_entity)
|
||||
{
|
||||
Write(NS_LITERAL_STRING("&"));
|
||||
Write(aText); // sure to be safe?
|
||||
// using + operator here might give an infinitive loop, see above.
|
||||
// not adding ";", because Gecko delivers that as part of |aText| (freaky)
|
||||
}
|
||||
else
|
||||
{
|
||||
DoOpenContainer(type);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Similar to SanitizeAttrValue.
|
||||
*/
|
||||
nsresult
|
||||
mozSanitizingHTMLSerializer::SanitizeTextNode(nsString& aText /*inout*/)
|
||||
{
|
||||
aText.Adopt(escape(aText));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
Ensures basic sanity of attribute value.
|
||||
This function also (tries to :-( ) makes sure, that no
|
||||
unwanted / dangerous URLs appear in the document
|
||||
(like javascript: and data:).
|
||||
|
||||
Pass the value as |aValue| arg. It will be modified in-place.
|
||||
|
||||
If the value is not allowed at all, we return with NS_ERROR_ILLEGAL_VALUE.
|
||||
In that case, do not use the |aValue|, but output nothing.
|
||||
*/
|
||||
nsresult
|
||||
mozSanitizingHTMLSerializer::SanitizeAttrValue(nsHTMLTag aTag,
|
||||
const nsAString& anAttrName,
|
||||
nsString& aValue /*inout*/)
|
||||
{
|
||||
/* First, cut the attribute to 1000 chars.
|
||||
Attributes with values longer than 1000 chars seem bogus,
|
||||
considering that we don't support any JS. The longest attributes
|
||||
I can think of are URLs, and URLs with 1000 chars are likely to be
|
||||
bogus, too. */
|
||||
aValue = Substring(aValue, 0, 1000);
|
||||
//aValue.Truncate(1000); //-- this cuts half of the document !!?!!
|
||||
|
||||
aValue.Adopt(escape(aValue));
|
||||
|
||||
/* Check some known bad stuff. Add more!
|
||||
I don't care too much, if it happens to trigger in some innocent cases
|
||||
(like <img alt="Statistical data: Mortage rates and newspapers">) -
|
||||
security first. */
|
||||
if (aValue.Find("javascript:") != kNotFound ||
|
||||
aValue.Find("data:") != kNotFound ||
|
||||
aValue.Find("base64") != kNotFound)
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
|
||||
// Check img src scheme
|
||||
if (aTag == eHTMLTag_img &&
|
||||
anAttrName.LowerCaseEqualsLiteral("src"))
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIIOService> ioService = do_GetIOService(&rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCAutoString scheme;
|
||||
rv = ioService->ExtractScheme(NS_LossyConvertUTF16toASCII(aValue), scheme);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!scheme.Equals("cid", nsCaseInsensitiveCStringComparator()))
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_BenB
|
||||
printf("attribute value for %s: -%s-\n",
|
||||
NS_LossyConvertUTF16toASCII(anAttrName).get(),
|
||||
NS_LossyConvertUTF16toASCII(aValue).get());
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
PRBool
|
||||
mozSanitizingHTMLSerializer::IsAllowedTag(nsHTMLTag aTag)
|
||||
{
|
||||
|
||||
nsPRUint32Key tag_key(aTag);
|
||||
#ifdef DEBUG_BenB
|
||||
printf("IsAllowedTag %d: %s\n",
|
||||
aTag,
|
||||
mAllowedTags.Exists(&tag_key)?"yes":"no");
|
||||
#endif
|
||||
return mAllowedTags.Exists(&tag_key);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
PRBool
|
||||
mozSanitizingHTMLSerializer::IsAllowedAttribute(nsHTMLTag aTag,
|
||||
const nsAString& anAttributeName)
|
||||
{
|
||||
#ifdef DEBUG_BenB
|
||||
printf("IsAllowedAttribute %d, -%s-\n",
|
||||
aTag,
|
||||
NS_LossyConvertUTF16toASCII(anAttributeName).get());
|
||||
#endif
|
||||
nsresult rv;
|
||||
|
||||
nsPRUint32Key tag_key(aTag);
|
||||
nsIProperties* attr_bag = (nsIProperties*)mAllowedTags.Get(&tag_key);
|
||||
NS_ENSURE_TRUE(attr_bag, PR_FALSE);
|
||||
|
||||
PRBool allowed;
|
||||
nsAutoString attr(anAttributeName);
|
||||
ToLowerCase(attr);
|
||||
rv = attr_bag->Has(NS_LossyConvertUTF16toASCII(attr).get(),
|
||||
&allowed);
|
||||
if (NS_FAILED(rv))
|
||||
return PR_FALSE;
|
||||
|
||||
#ifdef DEBUG_BenB
|
||||
printf(" Allowed: %s\n", allowed?"yes":"no");
|
||||
#endif
|
||||
return allowed;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
aPref is a long string, which holds an exhaustive list of allowed tags
|
||||
and attributes. All other tags and attributes will be removed.
|
||||
|
||||
aPref has the format
|
||||
"html head body ul ol li a(href,name,title) img(src,alt,title) #text"
|
||||
i.e.
|
||||
- tags are separated by whitespace
|
||||
- the attribute list follows the tag directly in brackets
|
||||
- the attributes are separated by commas.
|
||||
|
||||
There is no way to express further restrictions, like "no text inside the
|
||||
<head> element". This is so to considerably reduce the complexity of the
|
||||
pref and this implementation.
|
||||
|
||||
Update: Akk told me that I might be able to use DTD classes. Later(TM)...
|
||||
*/
|
||||
nsresult
|
||||
mozSanitizingHTMLSerializer::ParsePrefs(const nsAString& aPref)
|
||||
{
|
||||
char* pref = ToNewCString(aPref);
|
||||
char* tags_lasts;
|
||||
for (char* iTag = PL_strtok_r(pref, " ", &tags_lasts);
|
||||
iTag;
|
||||
iTag = PL_strtok_r(NULL, " ", &tags_lasts))
|
||||
{
|
||||
ParseTagPref(nsCAutoString(iTag));
|
||||
}
|
||||
delete[] pref;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Parses e.g. "a(href,title)" (but not several tags at once).
|
||||
*/
|
||||
nsresult
|
||||
mozSanitizingHTMLSerializer::ParseTagPref(const nsCAutoString& tagpref)
|
||||
{
|
||||
nsIParserService* parserService = nsContentUtils::GetParserService();
|
||||
if (!parserService)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
// Parsing tag
|
||||
PRInt32 bracket = tagpref.FindChar('(');
|
||||
if (bracket == 0)
|
||||
{
|
||||
printf(" malformed pref: %s\n", tagpref.get());
|
||||
return NS_ERROR_CANNOT_CONVERT_DATA;
|
||||
}
|
||||
|
||||
nsAutoString tag;
|
||||
CopyUTF8toUTF16(StringHead(tagpref, bracket), tag);
|
||||
|
||||
// Create key
|
||||
PRInt32 tag_id = parserService->HTMLStringTagToId(tag);
|
||||
if (tag_id == eHTMLTag_userdefined)
|
||||
{
|
||||
printf(" unknown tag <%s>, won't add.\n",
|
||||
NS_ConvertUTF16toUTF8(tag).get());
|
||||
return NS_ERROR_CANNOT_CONVERT_DATA;
|
||||
}
|
||||
nsPRUint32Key tag_key(tag_id);
|
||||
|
||||
if (mAllowedTags.Exists(&tag_key))
|
||||
{
|
||||
printf(" duplicate tag: %s\n", NS_ConvertUTF16toUTF8(tag).get());
|
||||
return NS_ERROR_CANNOT_CONVERT_DATA;
|
||||
}
|
||||
if (bracket == kNotFound)
|
||||
/* There are no attributes in the pref. So, allow none; only the tag
|
||||
itself */
|
||||
{
|
||||
mAllowedTags.Put(&tag_key, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Attributes
|
||||
|
||||
// where is the macro for non-fatal errors in opt builds?
|
||||
if(tagpref[tagpref.Length() - 1] != ')' ||
|
||||
tagpref.Length() < PRUint32(bracket) + 3)
|
||||
{
|
||||
printf(" malformed pref: %s\n", tagpref.get());
|
||||
return NS_ERROR_CANNOT_CONVERT_DATA;
|
||||
}
|
||||
nsCOMPtr<nsIProperties> attr_bag =
|
||||
do_CreateInstance(NS_PROPERTIES_CONTRACTID);
|
||||
NS_ENSURE_TRUE(attr_bag, NS_ERROR_INVALID_POINTER);
|
||||
nsCAutoString attrList;
|
||||
attrList.Append(Substring(tagpref,
|
||||
bracket + 1,
|
||||
tagpref.Length() - 2 - bracket));
|
||||
char* attrs_lasts;
|
||||
for (char* iAttr = PL_strtok_r(attrList.BeginWriting(),
|
||||
",", &attrs_lasts);
|
||||
iAttr;
|
||||
iAttr = PL_strtok_r(NULL, ",", &attrs_lasts))
|
||||
{
|
||||
attr_bag->Set(iAttr, 0);
|
||||
}
|
||||
|
||||
nsIProperties* attr_bag_raw = attr_bag;
|
||||
NS_ADDREF(attr_bag_raw);
|
||||
mAllowedTags.Put(&tag_key, attr_bag_raw);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
might be useful:
|
||||
htmlparser/public/nsHTMLTokens.h for tag categories
|
||||
*/
|
||||
@@ -1,165 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=2 sw=2 et tw=80: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org HTML Sanitizer code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ben Bucksch <mozilla@bucksch.org>.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Netscape
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* A serializer and content sink that removes potentially insecure or
|
||||
* otherwise dangerous or offending HTML (eg for display of HTML
|
||||
* e-mail attachments or something).
|
||||
*/
|
||||
|
||||
#ifndef mozSanitizingSerializer_h__
|
||||
#define mozSanitizingSerializer_h__
|
||||
|
||||
#include "mozISanitizingSerializer.h"
|
||||
#include "nsIContentSerializer.h"
|
||||
#include "nsIHTMLContentSink.h"
|
||||
#include "nsHTMLTags.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIParserService.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIParser.h"
|
||||
#include "nsHashtable.h"
|
||||
|
||||
class mozSanitizingHTMLSerializer : public nsIContentSerializer,
|
||||
public nsIHTMLContentSink,
|
||||
public mozISanitizingHTMLSerializer
|
||||
{
|
||||
public:
|
||||
mozSanitizingHTMLSerializer();
|
||||
virtual ~mozSanitizingHTMLSerializer();
|
||||
static PRBool PR_CALLBACK ReleaseProperties(nsHashKey* key, void* data,
|
||||
void* closure);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIContentSerializer
|
||||
NS_IMETHOD Init(PRUint32 flags, PRUint32 dummy, const char* aCharSet,
|
||||
PRBool aIsCopying);
|
||||
|
||||
NS_IMETHOD AppendText(nsIDOMText* aText, PRInt32 aStartOffset,
|
||||
PRInt32 aEndOffset, nsAString& aStr);
|
||||
NS_IMETHOD AppendCDATASection(nsIDOMCDATASection* aCDATASection,
|
||||
PRInt32 aStartOffset, PRInt32 aEndOffset,
|
||||
nsAString& aStr)
|
||||
{ return NS_OK; }
|
||||
NS_IMETHOD AppendProcessingInstruction(nsIDOMProcessingInstruction* aPI,
|
||||
PRInt32 aStartOffset,
|
||||
PRInt32 aEndOffset,
|
||||
nsAString& aStr)
|
||||
{ return NS_OK; }
|
||||
NS_IMETHOD AppendComment(nsIDOMComment* aComment, PRInt32 aStartOffset,
|
||||
PRInt32 aEndOffset, nsAString& aStr)
|
||||
{ return NS_OK; }
|
||||
NS_IMETHOD AppendDoctype(nsIDOMDocumentType *aDoctype, nsAString& aStr)
|
||||
{ return NS_OK; }
|
||||
NS_IMETHOD AppendElementStart(nsIDOMElement *aElement,
|
||||
nsIDOMElement *aOriginalElement,
|
||||
nsAString& aStr);
|
||||
NS_IMETHOD AppendElementEnd(nsIDOMElement *aElement, nsAString& aStr);
|
||||
NS_IMETHOD Flush(nsAString& aStr);
|
||||
|
||||
NS_IMETHOD AppendDocumentStart(nsIDOMDocument *aDocument,
|
||||
nsAString& aStr);
|
||||
|
||||
// nsIContentSink
|
||||
NS_IMETHOD WillBuildModel(void) { return NS_OK; }
|
||||
NS_IMETHOD DidBuildModel(void) { return NS_OK; }
|
||||
NS_IMETHOD WillInterrupt(void) { return NS_OK; }
|
||||
NS_IMETHOD WillResume(void) { return NS_OK; }
|
||||
NS_IMETHOD SetParser(nsIParser* aParser) { return NS_OK; }
|
||||
NS_IMETHOD OpenContainer(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseContainer(const nsHTMLTag aTag);
|
||||
NS_IMETHOD AddLeaf(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddComment(const nsIParserNode& aNode) { return NS_OK; }
|
||||
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode)
|
||||
{ return NS_OK; }
|
||||
NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode);
|
||||
virtual void FlushPendingNotifications(mozFlushType aType) { }
|
||||
NS_IMETHOD SetDocumentCharset(nsACString& aCharset);
|
||||
virtual nsISupports *GetTarget() { return nsnull; }
|
||||
|
||||
// nsIHTMLContentSink
|
||||
NS_IMETHOD OpenHead();
|
||||
NS_IMETHOD IsEnabled(PRInt32 aTag, PRBool* aReturn);
|
||||
NS_IMETHOD NotifyTagObservers(nsIParserNode* aNode) { return NS_OK; }
|
||||
NS_IMETHOD_(PRBool) IsFormOnStack() { return PR_FALSE; }
|
||||
NS_IMETHOD BeginContext(PRInt32 aPosition) { return NS_OK; }
|
||||
NS_IMETHOD EndContext(PRInt32 aPosition) { return NS_OK; }
|
||||
NS_IMETHOD WillProcessTokens(void) { return NS_OK; }
|
||||
NS_IMETHOD DidProcessTokens(void) { return NS_OK; }
|
||||
NS_IMETHOD WillProcessAToken(void) { return NS_OK; }
|
||||
NS_IMETHOD DidProcessAToken(void) { return NS_OK; }
|
||||
|
||||
// nsISanitizingHTMLSerializer
|
||||
NS_IMETHOD Initialize(nsAString* aOutString,
|
||||
PRUint32 aFlags, const nsAString& allowedTags);
|
||||
|
||||
protected:
|
||||
nsresult ParsePrefs(const nsAString& aPref);
|
||||
nsresult ParseTagPref(const nsCAutoString& tagpref);
|
||||
PRBool IsAllowedTag(nsHTMLTag aTag);
|
||||
PRBool IsAllowedAttribute(nsHTMLTag aTag, const nsAString& anAttributeName);
|
||||
nsresult SanitizeAttrValue(nsHTMLTag aTag, const nsAString& attr_name,
|
||||
nsString& value /*inout*/);
|
||||
nsresult SanitizeTextNode(nsString& value /*inout*/);
|
||||
PRBool IsContainer(PRInt32 aId);
|
||||
static PRInt32 GetIdForContent(nsIContent* aContent);
|
||||
nsresult GetParserService(nsIParserService** aParserService);
|
||||
nsresult DoOpenContainer(PRInt32 aTag);
|
||||
nsresult DoCloseContainer(PRInt32 aTag);
|
||||
nsresult DoAddLeaf(PRInt32 aTag, const nsAString& aText);
|
||||
void Write(const nsAString& aString);
|
||||
|
||||
protected:
|
||||
PRInt32 mFlags;
|
||||
PRUint32 mSkipLevel;
|
||||
nsHashtable mAllowedTags;
|
||||
|
||||
nsCOMPtr<nsIContent> mContent;
|
||||
nsAString* mOutputString;
|
||||
nsIParserNode* mParserNode;
|
||||
nsCOMPtr<nsIParserService> mParserService;
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewSanitizingHTMLSerializer(nsIContentSerializer** aSerializer);
|
||||
|
||||
#endif
|
||||
@@ -1,57 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is nsAtomListUtils.h .
|
||||
*
|
||||
* The Initial Developer of the Original Code is L. David Baron.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2003
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* L. David Baron <dbaron@fas.harvard.edu> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Static helper class for implementing atom lists.
|
||||
*/
|
||||
|
||||
#include "nsAtomListUtils.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsStaticAtom.h"
|
||||
|
||||
/* static */ PRBool
|
||||
nsAtomListUtils::IsMember(nsIAtom *aAtom,
|
||||
const nsStaticAtom* aInfo,
|
||||
PRUint32 aInfoCount)
|
||||
{
|
||||
for (const nsStaticAtom *info = aInfo, *info_end = aInfo + aInfoCount;
|
||||
info != info_end; ++info) {
|
||||
if (aAtom == *(info->mAtom))
|
||||
return PR_TRUE;
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is nsAtomListUtils.h .
|
||||
*
|
||||
* The Initial Developer of the Original Code is L. David Baron.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2003
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* L. David Baron <dbaron@fas.harvard.edu> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Static helper class for implementing atom lists.
|
||||
*/
|
||||
|
||||
#ifndef nsAtomListUtils_h__
|
||||
#define nsAtomListUtils_h__
|
||||
|
||||
#include "prtypes.h"
|
||||
|
||||
class nsIAtom;
|
||||
struct nsStaticAtom;
|
||||
|
||||
class nsAtomListUtils {
|
||||
public:
|
||||
static PRBool IsMember(nsIAtom *aAtom,
|
||||
const nsStaticAtom* aInfo,
|
||||
PRUint32 aInfoCount);
|
||||
};
|
||||
|
||||
#endif /* !defined(nsAtomListUtils_h__) */
|
||||
@@ -1,797 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2003
|
||||
* IBM Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* IBM Corporation
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Storage of the children and attributes of a DOM node; storage for
|
||||
* the two is unified to minimize footprint.
|
||||
*/
|
||||
|
||||
#include "nsAttrAndChildArray.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "prmem.h"
|
||||
#include "prbit.h"
|
||||
#include "nsString.h"
|
||||
#include "nsHTMLStyleSheet.h"
|
||||
#include "nsRuleWalker.h"
|
||||
#include "nsMappedAttributes.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsAutoPtr.h"
|
||||
|
||||
/*
|
||||
CACHE_POINTER_SHIFT indicates how many steps to downshift the |this| pointer.
|
||||
It should be small enough to not cause collisions between adjecent arrays, and
|
||||
large enough to make sure that all indexes are used. The size below is based
|
||||
on the size of the smallest possible element (currently 24[*] bytes) which is
|
||||
the smallest distance between two nsAttrAndChildArray. 24/(2^_5_) is 0.75.
|
||||
This means that two adjacent nsAttrAndChildArrays will overlap one in 4 times.
|
||||
However not all elements will have enough children to get cached. And any
|
||||
allocator that doesn't return addresses aligned to 64 bytes will ensure that
|
||||
any index will get used.
|
||||
|
||||
[*] sizeof(nsGenericElement) + 4 bytes for nsIDOMElement vtable pointer.
|
||||
*/
|
||||
|
||||
#define CACHE_POINTER_SHIFT 5
|
||||
#define CACHE_NUM_SLOTS 128
|
||||
#define CACHE_CHILD_LIMIT 10
|
||||
|
||||
#define CACHE_GET_INDEX(_array) \
|
||||
((NS_PTR_TO_INT32(_array) >> CACHE_POINTER_SHIFT) & \
|
||||
(CACHE_NUM_SLOTS - 1))
|
||||
|
||||
struct IndexCacheSlot
|
||||
{
|
||||
const nsAttrAndChildArray* array;
|
||||
PRInt32 index;
|
||||
};
|
||||
|
||||
// This is inited to all zeroes since it's static. Though even if it wasn't
|
||||
// the worst thing that'd happen is a small inefficency if you'd get a false
|
||||
// positive cachehit.
|
||||
static IndexCacheSlot indexCache[CACHE_NUM_SLOTS];
|
||||
|
||||
static
|
||||
inline
|
||||
void
|
||||
AddIndexToCache(const nsAttrAndChildArray* aArray, PRInt32 aIndex)
|
||||
{
|
||||
PRUint32 ix = CACHE_GET_INDEX(aArray);
|
||||
indexCache[ix].array = aArray;
|
||||
indexCache[ix].index = aIndex;
|
||||
}
|
||||
|
||||
static
|
||||
inline
|
||||
PRInt32
|
||||
GetIndexFromCache(const nsAttrAndChildArray* aArray)
|
||||
{
|
||||
PRUint32 ix = CACHE_GET_INDEX(aArray);
|
||||
return indexCache[ix].array == aArray ? indexCache[ix].index : -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Due to a compiler bug in VisualAge C++ for AIX, we need to return the
|
||||
* address of the first index into mBuffer here, instead of simply returning
|
||||
* mBuffer itself.
|
||||
*
|
||||
* See Bug 231104 for more information.
|
||||
*/
|
||||
#define ATTRS(_impl) \
|
||||
NS_REINTERPRET_CAST(InternalAttr*, &((_impl)->mBuffer[0]))
|
||||
|
||||
|
||||
#define NS_IMPL_EXTRA_SIZE \
|
||||
((sizeof(Impl) - sizeof(mImpl->mBuffer)) / sizeof(void*))
|
||||
|
||||
nsAttrAndChildArray::nsAttrAndChildArray()
|
||||
: mImpl(nsnull)
|
||||
{
|
||||
}
|
||||
|
||||
nsAttrAndChildArray::~nsAttrAndChildArray()
|
||||
{
|
||||
if (!mImpl) {
|
||||
return;
|
||||
}
|
||||
|
||||
Clear();
|
||||
|
||||
PR_Free(mImpl);
|
||||
}
|
||||
|
||||
nsIContent*
|
||||
nsAttrAndChildArray::GetSafeChildAt(PRUint32 aPos) const
|
||||
{
|
||||
if (aPos < ChildCount()) {
|
||||
return ChildAt(aPos);
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAttrAndChildArray::InsertChildAt(nsIContent* aChild, PRUint32 aPos)
|
||||
{
|
||||
NS_ASSERTION(aChild, "nullchild");
|
||||
NS_ASSERTION(aPos <= ChildCount(), "out-of-bounds");
|
||||
|
||||
PRUint32 offset = AttrSlotsSize();
|
||||
PRUint32 childCount = ChildCount();
|
||||
|
||||
NS_ENSURE_TRUE(childCount < ATTRCHILD_ARRAY_MAX_CHILD_COUNT,
|
||||
NS_ERROR_FAILURE);
|
||||
|
||||
// First try to fit new child in existing childlist
|
||||
if (mImpl && offset + childCount < mImpl->mBufferSize) {
|
||||
void** pos = mImpl->mBuffer + offset + aPos;
|
||||
if (childCount != aPos) {
|
||||
memmove(pos + 1, pos, (childCount - aPos) * sizeof(nsIContent*));
|
||||
}
|
||||
*pos = aChild;
|
||||
NS_ADDREF(aChild);
|
||||
|
||||
SetChildCount(childCount + 1);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Try to fit new child in existing buffer by compressing attrslots
|
||||
if (offset && !mImpl->mBuffer[offset - ATTRSIZE]) {
|
||||
// Compress away all empty slots while we're at it. This might not be the
|
||||
// optimal thing to do.
|
||||
PRUint32 attrCount = NonMappedAttrCount();
|
||||
void** newStart = mImpl->mBuffer + attrCount * ATTRSIZE;
|
||||
void** oldStart = mImpl->mBuffer + offset;
|
||||
memmove(newStart, oldStart, aPos * sizeof(nsIContent*));
|
||||
newStart[aPos] = aChild;
|
||||
memmove(&newStart[aPos + 1], &oldStart[aPos],
|
||||
(childCount - aPos) * sizeof(nsIContent*));
|
||||
NS_ADDREF(aChild);
|
||||
|
||||
SetAttrSlotAndChildCount(attrCount, childCount + 1);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// We can't fit in current buffer, Realloc time!
|
||||
if (!GrowBy(1)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
void** pos = mImpl->mBuffer + offset + aPos;
|
||||
if (childCount != aPos) {
|
||||
memmove(pos + 1, pos, (childCount - aPos) * sizeof(nsIContent*));
|
||||
}
|
||||
*pos = aChild;
|
||||
NS_ADDREF(aChild);
|
||||
|
||||
SetChildCount(childCount + 1);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsAttrAndChildArray::RemoveChildAt(PRUint32 aPos)
|
||||
{
|
||||
NS_ASSERTION(aPos < ChildCount(), "out-of-bounds");
|
||||
|
||||
PRUint32 childCount = ChildCount();
|
||||
void** pos = mImpl->mBuffer + AttrSlotsSize() + aPos;
|
||||
nsIContent* child = NS_STATIC_CAST(nsIContent*, *pos);
|
||||
NS_RELEASE(child);
|
||||
memmove(pos, pos + 1, (childCount - aPos - 1) * sizeof(nsIContent*));
|
||||
SetChildCount(childCount - 1);
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsAttrAndChildArray::IndexOfChild(nsINode* aPossibleChild) const
|
||||
{
|
||||
if (!mImpl) {
|
||||
return -1;
|
||||
}
|
||||
void** children = mImpl->mBuffer + AttrSlotsSize();
|
||||
// Use signed here since we compare count to cursor which has to be signed
|
||||
PRInt32 i, count = ChildCount();
|
||||
|
||||
if (count >= CACHE_CHILD_LIMIT) {
|
||||
PRInt32 cursor = GetIndexFromCache(this);
|
||||
// Need to compare to count here since we may have removed children since
|
||||
// the index was added to the cache.
|
||||
// We're also relying on that GetIndexFromCache returns -1 if no cached
|
||||
// index was found.
|
||||
if (cursor >= count) {
|
||||
cursor = -1;
|
||||
}
|
||||
|
||||
// Seek outward from the last found index. |inc| will change sign every
|
||||
// run through the loop. |sign| just exists to make sure the absolute
|
||||
// value of |inc| increases each time through.
|
||||
PRInt32 inc = 1, sign = 1;
|
||||
while (cursor >= 0 && cursor < count) {
|
||||
if (children[cursor] == aPossibleChild) {
|
||||
AddIndexToCache(this, cursor);
|
||||
|
||||
return cursor;
|
||||
}
|
||||
|
||||
cursor += inc;
|
||||
inc = -inc - sign;
|
||||
sign = -sign;
|
||||
}
|
||||
|
||||
// We ran into one 'edge'. Add inc to cursor once more to get back to
|
||||
// the 'side' where we still need to search, then step in the |sign|
|
||||
// direction.
|
||||
cursor += inc;
|
||||
|
||||
if (sign > 0) {
|
||||
for (; cursor < count; ++cursor) {
|
||||
if (children[cursor] == aPossibleChild) {
|
||||
AddIndexToCache(this, cursor);
|
||||
|
||||
return NS_STATIC_CAST(PRInt32, cursor);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (; cursor >= 0; --cursor) {
|
||||
if (children[cursor] == aPossibleChild) {
|
||||
AddIndexToCache(this, cursor);
|
||||
|
||||
return NS_STATIC_CAST(PRInt32, cursor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The child wasn't even in the remaining children
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < count; ++i) {
|
||||
if (children[i] == aPossibleChild) {
|
||||
return NS_STATIC_CAST(PRInt32, i);
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
PRUint32
|
||||
nsAttrAndChildArray::AttrCount() const
|
||||
{
|
||||
return NonMappedAttrCount() + MappedAttrCount();
|
||||
}
|
||||
|
||||
const nsAttrValue*
|
||||
nsAttrAndChildArray::GetAttr(nsIAtom* aLocalName, PRInt32 aNamespaceID) const
|
||||
{
|
||||
PRUint32 i, slotCount = AttrSlotCount();
|
||||
if (aNamespaceID == kNameSpaceID_None) {
|
||||
// This should be the common case so lets make an optimized loop
|
||||
for (i = 0; i < slotCount && mImpl->mBuffer[i * ATTRSIZE]; ++i) {
|
||||
if (ATTRS(mImpl)[i].mName.Equals(aLocalName)) {
|
||||
return &ATTRS(mImpl)[i].mValue;
|
||||
}
|
||||
}
|
||||
|
||||
if (mImpl && mImpl->mMappedAttrs) {
|
||||
return mImpl->mMappedAttrs->GetAttr(aLocalName);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (i = 0; i < slotCount && mImpl->mBuffer[i * ATTRSIZE]; ++i) {
|
||||
if (ATTRS(mImpl)[i].mName.Equals(aLocalName, aNamespaceID)) {
|
||||
return &ATTRS(mImpl)[i].mValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
const nsAttrValue*
|
||||
nsAttrAndChildArray::AttrAt(PRUint32 aPos) const
|
||||
{
|
||||
NS_ASSERTION(aPos < AttrCount(),
|
||||
"out-of-bounds access in nsAttrAndChildArray");
|
||||
|
||||
PRUint32 mapped = MappedAttrCount();
|
||||
if (aPos < mapped) {
|
||||
return mImpl->mMappedAttrs->AttrAt(aPos);
|
||||
}
|
||||
|
||||
return &ATTRS(mImpl)[aPos - mapped].mValue;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAttrAndChildArray::SetAttr(nsIAtom* aLocalName, const nsAString& aValue)
|
||||
{
|
||||
PRUint32 i, slotCount = AttrSlotCount();
|
||||
for (i = 0; i < slotCount && mImpl->mBuffer[i * ATTRSIZE]; ++i) {
|
||||
if (ATTRS(mImpl)[i].mName.Equals(aLocalName)) {
|
||||
ATTRS(mImpl)[i].mValue.SetTo(aValue);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_ENSURE_TRUE(slotCount < ATTRCHILD_ARRAY_MAX_ATTR_COUNT,
|
||||
NS_ERROR_FAILURE);
|
||||
|
||||
if (i == slotCount && !AddAttrSlot()) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
new (&ATTRS(mImpl)[i].mName) nsAttrName(aLocalName);
|
||||
new (&ATTRS(mImpl)[i].mValue) nsAttrValue(aValue);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAttrAndChildArray::SetAndTakeAttr(nsIAtom* aLocalName, nsAttrValue& aValue)
|
||||
{
|
||||
PRUint32 i, slotCount = AttrSlotCount();
|
||||
for (i = 0; i < slotCount && mImpl->mBuffer[i * ATTRSIZE]; ++i) {
|
||||
if (ATTRS(mImpl)[i].mName.Equals(aLocalName)) {
|
||||
ATTRS(mImpl)[i].mValue.Reset();
|
||||
ATTRS(mImpl)[i].mValue.SwapValueWith(aValue);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_ENSURE_TRUE(i < ATTRCHILD_ARRAY_MAX_ATTR_COUNT,
|
||||
NS_ERROR_FAILURE);
|
||||
|
||||
if (i == slotCount && !AddAttrSlot()) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
new (&ATTRS(mImpl)[i].mName) nsAttrName(aLocalName);
|
||||
new (&ATTRS(mImpl)[i].mValue) nsAttrValue();
|
||||
ATTRS(mImpl)[i].mValue.SwapValueWith(aValue);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAttrAndChildArray::SetAndTakeAttr(nsINodeInfo* aName, nsAttrValue& aValue)
|
||||
{
|
||||
PRInt32 namespaceID = aName->NamespaceID();
|
||||
nsIAtom* localName = aName->NameAtom();
|
||||
if (namespaceID == kNameSpaceID_None) {
|
||||
return SetAndTakeAttr(localName, aValue);
|
||||
}
|
||||
|
||||
PRUint32 i, slotCount = AttrSlotCount();
|
||||
for (i = 0; i < slotCount && mImpl->mBuffer[i * ATTRSIZE]; ++i) {
|
||||
if (ATTRS(mImpl)[i].mName.Equals(localName, namespaceID)) {
|
||||
ATTRS(mImpl)[i].mName.SetTo(aName);
|
||||
ATTRS(mImpl)[i].mValue.Reset();
|
||||
ATTRS(mImpl)[i].mValue.SwapValueWith(aValue);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_ENSURE_TRUE(i < ATTRCHILD_ARRAY_MAX_ATTR_COUNT,
|
||||
NS_ERROR_FAILURE);
|
||||
|
||||
if (i == slotCount && !AddAttrSlot()) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
new (&ATTRS(mImpl)[i].mName) nsAttrName(aName);
|
||||
new (&ATTRS(mImpl)[i].mValue) nsAttrValue();
|
||||
ATTRS(mImpl)[i].mValue.SwapValueWith(aValue);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsAttrAndChildArray::RemoveAttrAt(PRUint32 aPos)
|
||||
{
|
||||
NS_ASSERTION(aPos < AttrCount(), "out-of-bounds");
|
||||
|
||||
PRUint32 mapped = MappedAttrCount();
|
||||
if (aPos < mapped) {
|
||||
if (mapped == 1) {
|
||||
// We're removing the last mapped attribute.
|
||||
NS_RELEASE(mImpl->mMappedAttrs);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsRefPtr<nsMappedAttributes> mapped;
|
||||
nsresult rv = GetModifiableMapped(nsnull, nsnull, PR_FALSE,
|
||||
getter_AddRefs(mapped));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mapped->RemoveAttrAt(aPos);
|
||||
|
||||
return MakeMappedUnique(mapped);
|
||||
}
|
||||
|
||||
aPos -= mapped;
|
||||
ATTRS(mImpl)[aPos].~InternalAttr();
|
||||
|
||||
PRUint32 slotCount = AttrSlotCount();
|
||||
memmove(&ATTRS(mImpl)[aPos],
|
||||
&ATTRS(mImpl)[aPos + 1],
|
||||
(slotCount - aPos - 1) * sizeof(InternalAttr));
|
||||
memset(&ATTRS(mImpl)[slotCount - 1], nsnull, sizeof(InternalAttr));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
const nsAttrName*
|
||||
nsAttrAndChildArray::AttrNameAt(PRUint32 aPos) const
|
||||
{
|
||||
NS_ASSERTION(aPos < AttrCount(),
|
||||
"out-of-bounds access in nsAttrAndChildArray");
|
||||
|
||||
PRUint32 mapped = MappedAttrCount();
|
||||
if (aPos < mapped) {
|
||||
return mImpl->mMappedAttrs->NameAt(aPos);
|
||||
}
|
||||
|
||||
return &ATTRS(mImpl)[aPos - mapped].mName;
|
||||
}
|
||||
|
||||
const nsAttrName*
|
||||
nsAttrAndChildArray::GetSafeAttrNameAt(PRUint32 aPos) const
|
||||
{
|
||||
PRUint32 mapped = MappedAttrCount();
|
||||
if (aPos < mapped) {
|
||||
return mImpl->mMappedAttrs->NameAt(aPos);
|
||||
}
|
||||
|
||||
aPos -= mapped;
|
||||
if (aPos >= AttrSlotCount()) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
void** pos = mImpl->mBuffer + aPos * ATTRSIZE;
|
||||
if (!*pos) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
return &NS_REINTERPRET_CAST(InternalAttr*, pos)->mName;
|
||||
}
|
||||
|
||||
const nsAttrName*
|
||||
nsAttrAndChildArray::GetExistingAttrNameFromQName(const nsACString& aName) const
|
||||
{
|
||||
PRUint32 i, slotCount = AttrSlotCount();
|
||||
for (i = 0; i < slotCount && mImpl->mBuffer[i * ATTRSIZE]; ++i) {
|
||||
if (ATTRS(mImpl)[i].mName.QualifiedNameEquals(aName)) {
|
||||
return &ATTRS(mImpl)[i].mName;
|
||||
}
|
||||
}
|
||||
|
||||
if (mImpl && mImpl->mMappedAttrs) {
|
||||
return mImpl->mMappedAttrs->GetExistingAttrNameFromQName(aName);
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsAttrAndChildArray::IndexOfAttr(nsIAtom* aLocalName, PRInt32 aNamespaceID) const
|
||||
{
|
||||
PRInt32 idx;
|
||||
if (mImpl && mImpl->mMappedAttrs) {
|
||||
idx = mImpl->mMappedAttrs->IndexOfAttr(aLocalName, aNamespaceID);
|
||||
if (idx >= 0) {
|
||||
return idx;
|
||||
}
|
||||
}
|
||||
|
||||
PRUint32 i;
|
||||
PRUint32 mapped = MappedAttrCount();
|
||||
PRUint32 slotCount = AttrSlotCount();
|
||||
if (aNamespaceID == kNameSpaceID_None) {
|
||||
// This should be the common case so lets make an optimized loop
|
||||
for (i = 0; i < slotCount && mImpl->mBuffer[i * ATTRSIZE]; ++i) {
|
||||
if (ATTRS(mImpl)[i].mName.Equals(aLocalName)) {
|
||||
return i + mapped;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (i = 0; i < slotCount && mImpl->mBuffer[i * ATTRSIZE]; ++i) {
|
||||
if (ATTRS(mImpl)[i].mName.Equals(aLocalName, aNamespaceID)) {
|
||||
return i + mapped;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAttrAndChildArray::SetAndTakeMappedAttr(nsIAtom* aLocalName,
|
||||
nsAttrValue& aValue,
|
||||
nsGenericHTMLElement* aContent,
|
||||
nsHTMLStyleSheet* aSheet)
|
||||
{
|
||||
nsRefPtr<nsMappedAttributes> mapped;
|
||||
nsresult rv = GetModifiableMapped(aContent, aSheet, PR_TRUE,
|
||||
getter_AddRefs(mapped));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mapped->SetAndTakeAttr(aLocalName, aValue);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return MakeMappedUnique(mapped);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAttrAndChildArray::SetMappedAttrStyleSheet(nsHTMLStyleSheet* aSheet)
|
||||
{
|
||||
if (!mImpl || !mImpl->mMappedAttrs ||
|
||||
aSheet == mImpl->mMappedAttrs->GetStyleSheet()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsRefPtr<nsMappedAttributes> mapped;
|
||||
nsresult rv = GetModifiableMapped(nsnull, nsnull, PR_FALSE,
|
||||
getter_AddRefs(mapped));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mapped->SetStyleSheet(aSheet);
|
||||
|
||||
return MakeMappedUnique(mapped);
|
||||
}
|
||||
|
||||
void
|
||||
nsAttrAndChildArray::WalkMappedAttributeStyleRules(nsRuleWalker* aRuleWalker)
|
||||
{
|
||||
if (mImpl && mImpl->mMappedAttrs && aRuleWalker) {
|
||||
aRuleWalker->Forward(mImpl->mMappedAttrs);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsAttrAndChildArray::Compact()
|
||||
{
|
||||
if (!mImpl) {
|
||||
return;
|
||||
}
|
||||
|
||||
// First compress away empty attrslots
|
||||
PRUint32 slotCount = AttrSlotCount();
|
||||
PRUint32 attrCount = NonMappedAttrCount();
|
||||
PRUint32 childCount = ChildCount();
|
||||
|
||||
if (attrCount < slotCount) {
|
||||
memmove(mImpl->mBuffer + attrCount * ATTRSIZE,
|
||||
mImpl->mBuffer + slotCount * ATTRSIZE,
|
||||
childCount * sizeof(nsIContent*));
|
||||
SetAttrSlotCount(attrCount);
|
||||
}
|
||||
|
||||
// Then resize or free buffer
|
||||
PRUint32 newSize = attrCount * ATTRSIZE + childCount;
|
||||
if (!newSize && !mImpl->mMappedAttrs) {
|
||||
PR_Free(mImpl);
|
||||
mImpl = nsnull;
|
||||
}
|
||||
else if (newSize < mImpl->mBufferSize) {
|
||||
mImpl = NS_STATIC_CAST(Impl*, PR_Realloc(mImpl, (newSize + NS_IMPL_EXTRA_SIZE) * sizeof(nsIContent*)));
|
||||
NS_ASSERTION(mImpl, "failed to reallocate to smaller buffer");
|
||||
|
||||
mImpl->mBufferSize = newSize;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsAttrAndChildArray::Clear()
|
||||
{
|
||||
if (!mImpl) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mImpl->mMappedAttrs) {
|
||||
NS_RELEASE(mImpl->mMappedAttrs);
|
||||
}
|
||||
|
||||
PRUint32 i, slotCount = AttrSlotCount();
|
||||
for (i = 0; i < slotCount && mImpl->mBuffer[i * ATTRSIZE]; ++i) {
|
||||
ATTRS(mImpl)[i].~InternalAttr();
|
||||
}
|
||||
|
||||
PRUint32 end = slotCount * ATTRSIZE + ChildCount();
|
||||
for (i = slotCount * ATTRSIZE; i < end; ++i) {
|
||||
nsIContent* child = NS_STATIC_CAST(nsIContent*, mImpl->mBuffer[i]);
|
||||
// making this PR_FALSE so tree teardown doesn't end up being
|
||||
// O(N*D) (number of nodes times average depth of tree).
|
||||
child->UnbindFromTree(PR_FALSE); // XXX is it better to let the owner do this?
|
||||
NS_RELEASE(child);
|
||||
}
|
||||
|
||||
SetAttrSlotAndChildCount(0, 0);
|
||||
}
|
||||
|
||||
PRUint32
|
||||
nsAttrAndChildArray::NonMappedAttrCount() const
|
||||
{
|
||||
if (!mImpl) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
PRUint32 count = AttrSlotCount();
|
||||
while (count > 0 && !mImpl->mBuffer[(count - 1) * ATTRSIZE]) {
|
||||
--count;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
PRUint32
|
||||
nsAttrAndChildArray::MappedAttrCount() const
|
||||
{
|
||||
return mImpl && mImpl->mMappedAttrs ? (PRUint32)mImpl->mMappedAttrs->Count() : 0;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAttrAndChildArray::GetModifiableMapped(nsGenericHTMLElement* aContent,
|
||||
nsHTMLStyleSheet* aSheet,
|
||||
PRBool aWillAddAttr,
|
||||
nsMappedAttributes** aModifiable)
|
||||
{
|
||||
*aModifiable = nsnull;
|
||||
|
||||
if (mImpl && mImpl->mMappedAttrs) {
|
||||
*aModifiable = mImpl->mMappedAttrs->Clone(aWillAddAttr);
|
||||
NS_ENSURE_TRUE(*aModifiable, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
NS_ADDREF(*aModifiable);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_ASSERTION(aContent, "Trying to create modifiable without content");
|
||||
|
||||
nsMapRuleToAttributesFunc mapRuleFunc =
|
||||
aContent->GetAttributeMappingFunction();
|
||||
*aModifiable = new nsMappedAttributes(aSheet, mapRuleFunc);
|
||||
NS_ENSURE_TRUE(*aModifiable, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
NS_ADDREF(*aModifiable);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAttrAndChildArray::MakeMappedUnique(nsMappedAttributes* aAttributes)
|
||||
{
|
||||
NS_ASSERTION(aAttributes, "missing attributes");
|
||||
|
||||
if (!mImpl && !GrowBy(1)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
if (!aAttributes->GetStyleSheet()) {
|
||||
// This doesn't currently happen, but it could if we do loading right
|
||||
|
||||
nsRefPtr<nsMappedAttributes> mapped(aAttributes);
|
||||
mapped.swap(mImpl->mMappedAttrs);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsRefPtr<nsMappedAttributes> mapped =
|
||||
aAttributes->GetStyleSheet()->UniqueMappedAttributes(aAttributes);
|
||||
NS_ENSURE_TRUE(mapped, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
if (mapped != aAttributes) {
|
||||
// Reset the stylesheet of aAttributes so that it doesn't spend time
|
||||
// trying to remove itself from the hash. There is no risk that aAttributes
|
||||
// is in the hash since it will always have come from GetModifiableMapped,
|
||||
// which never returns maps that are in the hash (such hashes are by
|
||||
// nature not modifiable).
|
||||
aAttributes->DropStyleSheetReference();
|
||||
}
|
||||
mapped.swap(mImpl->mMappedAttrs);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
PRBool
|
||||
nsAttrAndChildArray::GrowBy(PRUint32 aGrowSize)
|
||||
{
|
||||
PRUint32 size = mImpl ? mImpl->mBufferSize + NS_IMPL_EXTRA_SIZE : 0;
|
||||
PRUint32 minSize = size + aGrowSize;
|
||||
|
||||
if (minSize <= ATTRCHILD_ARRAY_LINEAR_THRESHOLD) {
|
||||
do {
|
||||
size += ATTRCHILD_ARRAY_GROWSIZE;
|
||||
} while (size < minSize);
|
||||
}
|
||||
else {
|
||||
size = PR_BIT(PR_CeilingLog2(minSize));
|
||||
}
|
||||
|
||||
Impl* newImpl = NS_STATIC_CAST(Impl*,
|
||||
mImpl ? PR_Realloc(mImpl, size * sizeof(void*)) :
|
||||
PR_Malloc(size * sizeof(void*)));
|
||||
NS_ENSURE_TRUE(newImpl, PR_FALSE);
|
||||
|
||||
Impl* oldImpl = mImpl;
|
||||
mImpl = newImpl;
|
||||
|
||||
// Set initial counts if we didn't have a buffer before
|
||||
if (!oldImpl) {
|
||||
mImpl->mMappedAttrs = nsnull;
|
||||
SetAttrSlotAndChildCount(0, 0);
|
||||
}
|
||||
|
||||
mImpl->mBufferSize = size - NS_IMPL_EXTRA_SIZE;
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsAttrAndChildArray::AddAttrSlot()
|
||||
{
|
||||
PRUint32 slotCount = AttrSlotCount();
|
||||
PRUint32 childCount = ChildCount();
|
||||
|
||||
// Grow buffer if needed
|
||||
if (!(mImpl && mImpl->mBufferSize >= (slotCount + 1) * ATTRSIZE + childCount) &&
|
||||
!GrowBy(ATTRSIZE)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
void** offset = mImpl->mBuffer + slotCount * ATTRSIZE;
|
||||
|
||||
if (childCount > 0) {
|
||||
memmove(&ATTRS(mImpl)[slotCount + 1], &ATTRS(mImpl)[slotCount],
|
||||
childCount * sizeof(nsIContent*));
|
||||
}
|
||||
|
||||
SetAttrSlotCount(slotCount + 1);
|
||||
offset[0] = nsnull;
|
||||
offset[1] = nsnull;
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
@@ -1,189 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2003
|
||||
* IBM Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* IBM Corporation
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Storage of the children and attributes of a DOM node; storage for
|
||||
* the two is unified to minimize footprint.
|
||||
*/
|
||||
|
||||
#ifndef nsAttrAndChildArray_h___
|
||||
#define nsAttrAndChildArray_h___
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsAttrName.h"
|
||||
#include "nsAttrValue.h"
|
||||
|
||||
class nsINode;
|
||||
class nsIContent;
|
||||
class nsMappedAttributes;
|
||||
class nsHTMLStyleSheet;
|
||||
class nsRuleWalker;
|
||||
class nsGenericHTMLElement;
|
||||
|
||||
#define ATTRCHILD_ARRAY_GROWSIZE 8
|
||||
#define ATTRCHILD_ARRAY_LINEAR_THRESHOLD 32
|
||||
|
||||
#define ATTRCHILD_ARRAY_ATTR_SLOTS_BITS 10
|
||||
|
||||
#define ATTRCHILD_ARRAY_MAX_ATTR_COUNT \
|
||||
((1 << ATTRCHILD_ARRAY_ATTR_SLOTS_BITS) - 1)
|
||||
|
||||
#define ATTRCHILD_ARRAY_MAX_CHILD_COUNT \
|
||||
(~PtrBits(0) >> ATTRCHILD_ARRAY_ATTR_SLOTS_BITS)
|
||||
|
||||
#define ATTRCHILD_ARRAY_ATTR_SLOTS_COUNT_MASK \
|
||||
((1 << ATTRCHILD_ARRAY_ATTR_SLOTS_BITS) - 1)
|
||||
|
||||
|
||||
#define ATTRSIZE (sizeof(InternalAttr) / sizeof(void*))
|
||||
|
||||
class nsAttrAndChildArray
|
||||
{
|
||||
public:
|
||||
nsAttrAndChildArray();
|
||||
~nsAttrAndChildArray();
|
||||
|
||||
PRUint32 ChildCount() const
|
||||
{
|
||||
return mImpl ? (mImpl->mAttrAndChildCount >> ATTRCHILD_ARRAY_ATTR_SLOTS_BITS) : 0;
|
||||
}
|
||||
nsIContent* ChildAt(PRUint32 aPos) const
|
||||
{
|
||||
NS_ASSERTION(aPos < ChildCount(), "out-of-bounds access in nsAttrAndChildArray");
|
||||
return NS_REINTERPRET_CAST(nsIContent*, mImpl->mBuffer[AttrSlotsSize() + aPos]);
|
||||
}
|
||||
nsIContent* GetSafeChildAt(PRUint32 aPos) const;
|
||||
nsresult AppendChild(nsIContent* aChild)
|
||||
{
|
||||
return InsertChildAt(aChild, ChildCount());
|
||||
}
|
||||
nsresult InsertChildAt(nsIContent* aChild, PRUint32 aPos);
|
||||
void RemoveChildAt(PRUint32 aPos);
|
||||
PRInt32 IndexOfChild(nsINode* aPossibleChild) const;
|
||||
|
||||
PRUint32 AttrCount() const;
|
||||
const nsAttrValue* GetAttr(nsIAtom* aLocalName, PRInt32 aNamespaceID = kNameSpaceID_None) const;
|
||||
const nsAttrValue* AttrAt(PRUint32 aPos) const;
|
||||
nsresult SetAttr(nsIAtom* aLocalName, const nsAString& aValue);
|
||||
nsresult SetAndTakeAttr(nsIAtom* aLocalName, nsAttrValue& aValue);
|
||||
nsresult SetAndTakeAttr(nsINodeInfo* aName, nsAttrValue& aValue);
|
||||
nsresult RemoveAttrAt(PRUint32 aPos);
|
||||
|
||||
// Returns attribute name at given position, *not* out-of-bounds safe
|
||||
const nsAttrName* AttrNameAt(PRUint32 aPos) const;
|
||||
|
||||
// Returns attribute name at given position or null if aPos is out-of-bounds
|
||||
const nsAttrName* GetSafeAttrNameAt(PRUint32 aPos) const;
|
||||
|
||||
// aName is UTF-8 encoded
|
||||
const nsAttrName* GetExistingAttrNameFromQName(const nsACString& aName) const;
|
||||
PRInt32 IndexOfAttr(nsIAtom* aLocalName, PRInt32 aNamespaceID = kNameSpaceID_None) const;
|
||||
|
||||
nsresult SetAndTakeMappedAttr(nsIAtom* aLocalName, nsAttrValue& aValue,
|
||||
nsGenericHTMLElement* aContent,
|
||||
nsHTMLStyleSheet* aSheet);
|
||||
nsresult SetMappedAttrStyleSheet(nsHTMLStyleSheet* aSheet);
|
||||
void WalkMappedAttributeStyleRules(nsRuleWalker* aRuleWalker);
|
||||
|
||||
void Compact();
|
||||
|
||||
private:
|
||||
nsAttrAndChildArray(const nsAttrAndChildArray& aOther); // Not to be implemented
|
||||
nsAttrAndChildArray& operator=(const nsAttrAndChildArray& aOther); // Not to be implemented
|
||||
|
||||
void Clear();
|
||||
|
||||
PRUint32 NonMappedAttrCount() const;
|
||||
PRUint32 MappedAttrCount() const;
|
||||
|
||||
nsresult GetModifiableMapped(nsGenericHTMLElement* aContent,
|
||||
nsHTMLStyleSheet* aSheet,
|
||||
PRBool aWillAddAttr,
|
||||
nsMappedAttributes** aModifiable);
|
||||
nsresult MakeMappedUnique(nsMappedAttributes* aAttributes);
|
||||
|
||||
PRUint32 AttrSlotsSize() const
|
||||
{
|
||||
return AttrSlotCount() * ATTRSIZE;
|
||||
}
|
||||
|
||||
PRUint32 AttrSlotCount() const
|
||||
{
|
||||
return mImpl ? mImpl->mAttrAndChildCount & ATTRCHILD_ARRAY_ATTR_SLOTS_COUNT_MASK : 0;
|
||||
}
|
||||
|
||||
void SetChildCount(PRUint32 aCount)
|
||||
{
|
||||
mImpl->mAttrAndChildCount =
|
||||
(mImpl->mAttrAndChildCount & ATTRCHILD_ARRAY_ATTR_SLOTS_COUNT_MASK) |
|
||||
(aCount << ATTRCHILD_ARRAY_ATTR_SLOTS_BITS);
|
||||
}
|
||||
|
||||
void SetAttrSlotCount(PRUint32 aCount)
|
||||
{
|
||||
mImpl->mAttrAndChildCount =
|
||||
(mImpl->mAttrAndChildCount & ~ATTRCHILD_ARRAY_ATTR_SLOTS_COUNT_MASK) |
|
||||
aCount;
|
||||
}
|
||||
|
||||
void SetAttrSlotAndChildCount(PRUint32 aSlotCount, PRUint32 aChildCount)
|
||||
{
|
||||
mImpl->mAttrAndChildCount = aSlotCount |
|
||||
(aChildCount << ATTRCHILD_ARRAY_ATTR_SLOTS_BITS);
|
||||
}
|
||||
|
||||
PRBool GrowBy(PRUint32 aGrowSize);
|
||||
PRBool AddAttrSlot();
|
||||
|
||||
struct InternalAttr
|
||||
{
|
||||
nsAttrName mName;
|
||||
nsAttrValue mValue;
|
||||
};
|
||||
|
||||
struct Impl {
|
||||
PRUint32 mAttrAndChildCount;
|
||||
PRUint32 mBufferSize;
|
||||
nsMappedAttributes* mMappedAttrs;
|
||||
void* mBuffer[1];
|
||||
};
|
||||
|
||||
Impl* mImpl;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,242 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2003
|
||||
* IBM Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* IBM Corporation
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Class that represents the name (nodeinfo or atom) of an attribute;
|
||||
* using nodeinfos all the time is too slow, so we use atoms when we
|
||||
* can.
|
||||
*/
|
||||
|
||||
#ifndef nsAttrName_h___
|
||||
#define nsAttrName_h___
|
||||
|
||||
#include "nsINodeInfo.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsDOMString.h"
|
||||
|
||||
typedef unsigned long PtrBits;
|
||||
|
||||
#define NS_ATTRNAME_NODEINFO_BIT 1
|
||||
class nsAttrName
|
||||
{
|
||||
public:
|
||||
nsAttrName(const nsAttrName& aOther)
|
||||
: mBits(aOther.mBits)
|
||||
{
|
||||
AddRefInternalName();
|
||||
}
|
||||
|
||||
explicit nsAttrName(nsIAtom* aAtom)
|
||||
: mBits(NS_REINTERPRET_CAST(PtrBits, aAtom))
|
||||
{
|
||||
NS_ASSERTION(aAtom, "null atom-name in nsAttrName");
|
||||
NS_ADDREF(aAtom);
|
||||
}
|
||||
|
||||
explicit nsAttrName(nsINodeInfo* aNodeInfo)
|
||||
{
|
||||
NS_ASSERTION(aNodeInfo, "null nodeinfo-name in nsAttrName");
|
||||
if (aNodeInfo->NamespaceEquals(kNameSpaceID_None)) {
|
||||
mBits = NS_REINTERPRET_CAST(PtrBits, aNodeInfo->NameAtom());
|
||||
NS_ADDREF(aNodeInfo->NameAtom());
|
||||
}
|
||||
else {
|
||||
mBits = NS_REINTERPRET_CAST(PtrBits, aNodeInfo) |
|
||||
NS_ATTRNAME_NODEINFO_BIT;
|
||||
NS_ADDREF(aNodeInfo);
|
||||
}
|
||||
}
|
||||
|
||||
~nsAttrName()
|
||||
{
|
||||
ReleaseInternalName();
|
||||
}
|
||||
|
||||
void SetTo(nsINodeInfo* aNodeInfo)
|
||||
{
|
||||
NS_ASSERTION(aNodeInfo, "null nodeinfo-name in nsAttrName");
|
||||
|
||||
ReleaseInternalName();
|
||||
if (aNodeInfo->NamespaceEquals(kNameSpaceID_None)) {
|
||||
mBits = NS_REINTERPRET_CAST(PtrBits, aNodeInfo->NameAtom());
|
||||
NS_ADDREF(aNodeInfo->NameAtom());
|
||||
}
|
||||
else {
|
||||
mBits = NS_REINTERPRET_CAST(PtrBits, aNodeInfo) |
|
||||
NS_ATTRNAME_NODEINFO_BIT;
|
||||
NS_ADDREF(aNodeInfo);
|
||||
}
|
||||
}
|
||||
|
||||
void SetTo(nsIAtom* aAtom)
|
||||
{
|
||||
NS_ASSERTION(aAtom, "null atom-name in nsAttrName");
|
||||
|
||||
ReleaseInternalName();
|
||||
mBits = NS_REINTERPRET_CAST(PtrBits, aAtom);
|
||||
NS_ADDREF(aAtom);
|
||||
}
|
||||
|
||||
PRBool IsAtom() const
|
||||
{
|
||||
return !(mBits & NS_ATTRNAME_NODEINFO_BIT);
|
||||
}
|
||||
|
||||
nsINodeInfo* NodeInfo() const
|
||||
{
|
||||
NS_ASSERTION(!IsAtom(), "getting nodeinfo-value of atom-name");
|
||||
return NS_REINTERPRET_CAST(nsINodeInfo*, mBits & ~NS_ATTRNAME_NODEINFO_BIT);
|
||||
}
|
||||
|
||||
nsIAtom* Atom() const
|
||||
{
|
||||
NS_ASSERTION(IsAtom(), "getting atom-value of nodeinfo-name");
|
||||
return NS_REINTERPRET_CAST(nsIAtom*, mBits);
|
||||
}
|
||||
|
||||
PRBool Equals(const nsAttrName& aOther) const
|
||||
{
|
||||
return mBits == aOther.mBits;
|
||||
}
|
||||
|
||||
// Faster comparison in the case we know the namespace is null
|
||||
PRBool Equals(nsIAtom* aAtom) const
|
||||
{
|
||||
return NS_REINTERPRET_CAST(PtrBits, aAtom) == mBits;
|
||||
}
|
||||
|
||||
PRBool Equals(nsIAtom* aLocalName, PRInt32 aNamespaceID) const
|
||||
{
|
||||
if (aNamespaceID == kNameSpaceID_None) {
|
||||
return Equals(aLocalName);
|
||||
}
|
||||
return !IsAtom() && NodeInfo()->Equals(aLocalName, aNamespaceID);
|
||||
}
|
||||
|
||||
PRBool Equals(nsINodeInfo* aNodeInfo) const
|
||||
{
|
||||
return Equals(aNodeInfo->NameAtom(), aNodeInfo->NamespaceID());
|
||||
}
|
||||
|
||||
PRInt32 NamespaceID() const
|
||||
{
|
||||
return IsAtom() ? kNameSpaceID_None : NodeInfo()->NamespaceID();
|
||||
}
|
||||
|
||||
PRInt32 NamespaceEquals(PRInt32 aNamespaceID) const
|
||||
{
|
||||
return aNamespaceID == kNameSpaceID_None ?
|
||||
IsAtom() :
|
||||
(!IsAtom() && NodeInfo()->NamespaceEquals(aNamespaceID));
|
||||
}
|
||||
|
||||
nsIAtom* LocalName() const
|
||||
{
|
||||
return IsAtom() ? Atom() : NodeInfo()->NameAtom();
|
||||
}
|
||||
|
||||
nsIAtom* GetPrefix() const
|
||||
{
|
||||
return IsAtom() ? nsnull : NodeInfo()->GetPrefixAtom();
|
||||
}
|
||||
|
||||
PRBool QualifiedNameEquals(const nsACString& aName) const
|
||||
{
|
||||
return IsAtom() ? Atom()->EqualsUTF8(aName) :
|
||||
NodeInfo()->QualifiedNameEquals(aName);
|
||||
}
|
||||
|
||||
void GetQualifiedName(nsAString& aStr) const
|
||||
{
|
||||
if (IsAtom()) {
|
||||
Atom()->ToString(aStr);
|
||||
}
|
||||
else {
|
||||
NodeInfo()->GetQualifiedName(aStr);
|
||||
}
|
||||
}
|
||||
|
||||
void GetPrefix(nsAString& aStr) const
|
||||
{
|
||||
if (IsAtom()) {
|
||||
SetDOMStringToNull(aStr);
|
||||
}
|
||||
else {
|
||||
NodeInfo()->GetPrefix(aStr);
|
||||
}
|
||||
}
|
||||
|
||||
PRUint32 HashValue() const
|
||||
{
|
||||
// mBits and PRUint32 might have different size. This should silence
|
||||
// any warnings or compile-errors. This is what the implementation of
|
||||
// NS_PTR_TO_INT32 does to take care of the same problem.
|
||||
return mBits - 0;
|
||||
}
|
||||
|
||||
PRBool IsSmaller(nsIAtom* aOther) const
|
||||
{
|
||||
return mBits < NS_REINTERPRET_CAST(PtrBits, aOther);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void AddRefInternalName()
|
||||
{
|
||||
// Since both nsINodeInfo and nsIAtom inherit nsISupports as its first
|
||||
// interface we can safely assume that it's first in the vtable
|
||||
nsISupports* name = NS_REINTERPRET_CAST(nsISupports *,
|
||||
mBits & ~NS_ATTRNAME_NODEINFO_BIT);
|
||||
|
||||
NS_ADDREF(name);
|
||||
}
|
||||
|
||||
void ReleaseInternalName()
|
||||
{
|
||||
// Since both nsINodeInfo and nsIAtom inherit nsISupports as its first
|
||||
// interface we can safely assume that it's first in the vtable
|
||||
nsISupports* name = NS_REINTERPRET_CAST(nsISupports *,
|
||||
mBits & ~NS_ATTRNAME_NODEINFO_BIT);
|
||||
|
||||
NS_RELEASE(name);
|
||||
}
|
||||
|
||||
PtrBits mBits;
|
||||
};
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,427 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2003
|
||||
* IBM Corporation. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* IBM Corporation
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* A struct that represents the value (type and actual data) of an
|
||||
* attribute.
|
||||
*/
|
||||
|
||||
#ifndef nsAttrValue_h___
|
||||
#define nsAttrValue_h___
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsString.h"
|
||||
#include "nsStringBuffer.h"
|
||||
#include "nsColor.h"
|
||||
#include "nsCaseTreatment.h"
|
||||
|
||||
typedef unsigned long PtrBits;
|
||||
class nsAString;
|
||||
class nsIAtom;
|
||||
class nsICSSStyleRule;
|
||||
class nsISVGValue;
|
||||
class nsIDocument;
|
||||
template<class E> class nsCOMArray;
|
||||
class nsVoidArray;
|
||||
|
||||
#define NS_ATTRVALUE_MAX_STRINGLENGTH_ATOM 12
|
||||
|
||||
#define NS_ATTRVALUE_BASETYPE_MASK (PtrBits(3))
|
||||
#define NS_ATTRVALUE_POINTERVALUE_MASK (~NS_ATTRVALUE_BASETYPE_MASK)
|
||||
|
||||
#define NS_ATTRVALUE_INTEGERTYPE_BITS 5
|
||||
#define NS_ATTRVALUE_INTEGERTYPE_MASK (PtrBits((1 << NS_ATTRVALUE_INTEGERTYPE_BITS) - 1))
|
||||
#define NS_ATTRVALUE_INTEGERTYPE_MULTIPLIER (1 << NS_ATTRVALUE_INTEGERTYPE_BITS)
|
||||
#define NS_ATTRVALUE_INTEGERTYPE_MAXVALUE ((1 << (31 - NS_ATTRVALUE_INTEGERTYPE_BITS)) - 1)
|
||||
#define NS_ATTRVALUE_INTEGERTYPE_MINVALUE (-NS_ATTRVALUE_INTEGERTYPE_MAXVALUE - 1)
|
||||
|
||||
#define NS_ATTRVALUE_ENUMTABLEINDEX_BITS (32 - 16 - NS_ATTRVALUE_INTEGERTYPE_BITS)
|
||||
#define NS_ATTRVALUE_ENUMTABLEINDEX_MAXVALUE ((1 << NS_ATTRVALUE_ENUMTABLEINDEX_BITS) - 1)
|
||||
#define NS_ATTRVALUE_ENUMTABLEINDEX_MASK (PtrBits((1 << NS_ATTRVALUE_ENUMTABLEINDEX_BITS) - 1))
|
||||
|
||||
/**
|
||||
* A class used to construct a nsString from a nsStringBuffer (we might
|
||||
* want to move this to nsString at some point).
|
||||
*/
|
||||
class nsCheapString : public nsString {
|
||||
public:
|
||||
nsCheapString(nsStringBuffer* aBuf)
|
||||
{
|
||||
if (aBuf)
|
||||
aBuf->ToString(aBuf->StorageSize()/2 - 1, *this);
|
||||
}
|
||||
};
|
||||
|
||||
class nsAttrValue {
|
||||
public:
|
||||
nsAttrValue();
|
||||
nsAttrValue(const nsAttrValue& aOther);
|
||||
explicit nsAttrValue(const nsAString& aValue);
|
||||
explicit nsAttrValue(nsICSSStyleRule* aValue);
|
||||
#ifdef MOZ_SVG
|
||||
explicit nsAttrValue(nsISVGValue* aValue);
|
||||
#endif
|
||||
~nsAttrValue();
|
||||
|
||||
static nsresult Init();
|
||||
static void Shutdown();
|
||||
|
||||
// This has to be the same as in ValueBaseType
|
||||
enum ValueType {
|
||||
eString = 0x00, // 00
|
||||
// 01 this value indicates an 'misc' struct
|
||||
eAtom = 0x02, // 10
|
||||
eInteger = 0x03, // 00011
|
||||
eColor = 0x07, // 00111
|
||||
eProportional = 0x0B, // 01011
|
||||
eEnum = 0x0F, // 01111 This should eventually die
|
||||
ePercent = 0x13, // 10011
|
||||
// Values below here won't matter, they'll be stored in the 'misc' struct
|
||||
// anyway
|
||||
eCSSStyleRule = 0x14,
|
||||
eAtomArray = 0x15
|
||||
#ifdef MOZ_SVG
|
||||
,eSVGValue = 0x16
|
||||
#endif
|
||||
};
|
||||
|
||||
ValueType Type() const;
|
||||
|
||||
void Reset();
|
||||
|
||||
void SetTo(const nsAttrValue& aOther);
|
||||
void SetTo(const nsAString& aValue);
|
||||
void SetTo(PRInt16 aInt);
|
||||
void SetTo(nsICSSStyleRule* aValue);
|
||||
#ifdef MOZ_SVG
|
||||
void SetTo(nsISVGValue* aValue);
|
||||
#endif
|
||||
|
||||
void SwapValueWith(nsAttrValue& aOther);
|
||||
|
||||
void ToString(nsAString& aResult) const;
|
||||
|
||||
// Methods to get value. These methods do not convert so only use them
|
||||
// to retrieve the datatype that this nsAttrValue has.
|
||||
inline PRBool IsEmptyString() const;
|
||||
const nsCheapString GetStringValue() const;
|
||||
inline nsIAtom* GetAtomValue() const;
|
||||
inline PRInt32 GetIntegerValue() const;
|
||||
PRBool GetColorValue(nscolor& aColor) const;
|
||||
inline PRInt32 GetProportionalValue() const;
|
||||
inline PRInt16 GetEnumValue() const;
|
||||
inline float GetPercentValue() const;
|
||||
inline nsCOMArray<nsIAtom>* GetAtomArrayValue() const;
|
||||
inline nsICSSStyleRule* GetCSSStyleRuleValue() const;
|
||||
#ifdef MOZ_SVG
|
||||
inline nsISVGValue* GetSVGValue() const;
|
||||
#endif
|
||||
|
||||
// Methods to get access to atoms we may have
|
||||
// Returns the number of atoms we have; 0 if we have none. It's OK
|
||||
// to call this without checking the type first; it handles that.
|
||||
PRInt32 GetAtomCount() const;
|
||||
// Returns the atom at aIndex (0-based). Do not call this with
|
||||
// aIndex >= GetAtomCount().
|
||||
nsIAtom* AtomAt(PRInt32 aIndex) const;
|
||||
|
||||
PRUint32 HashValue() const;
|
||||
PRBool Equals(const nsAttrValue& aOther) const;
|
||||
PRBool Equals(const nsAString& aValue, nsCaseTreatment aCaseSensitive) const;
|
||||
PRBool Equals(nsIAtom* aValue, nsCaseTreatment aCaseSensitive) const;
|
||||
|
||||
/**
|
||||
* Returns true if this AttrValue is equal to the given atom, or is an
|
||||
* array which contains the given atom.
|
||||
*/
|
||||
PRBool Contains(nsIAtom* aValue, nsCaseTreatment aCaseSensitive) const;
|
||||
|
||||
void ParseAtom(const nsAString& aValue);
|
||||
void ParseAtomArray(const nsAString& aValue);
|
||||
void ParseStringOrAtom(const nsAString& aValue);
|
||||
|
||||
/**
|
||||
* Structure for a mapping from int (enum) values to strings. When you use
|
||||
* it you generally create an array of them.
|
||||
* Instantiate like this:
|
||||
* EnumTable myTable[] = {
|
||||
* { "string1", 1 },
|
||||
* { "string2", 2 },
|
||||
* { 0 }
|
||||
* }
|
||||
*/
|
||||
struct EnumTable {
|
||||
/** The string the value maps to */
|
||||
const char* tag;
|
||||
/** The enum value that maps to this string */
|
||||
PRInt16 value;
|
||||
};
|
||||
|
||||
/**
|
||||
* Parse into an enum value.
|
||||
*
|
||||
* @param aValue the string to find the value for
|
||||
* @param aTable the enumeration to map with
|
||||
* @param aResult the enum mapping [OUT]
|
||||
* @return whether the enum value was found or not
|
||||
*/
|
||||
PRBool ParseEnumValue(const nsAString& aValue,
|
||||
const EnumTable* aTable,
|
||||
PRBool aCaseSensitive = PR_FALSE);
|
||||
|
||||
/**
|
||||
* Parse a string into an integer. Can optionally parse percent (n%) and
|
||||
* proportional (n*). This method explicitly sets a lower bound of zero on
|
||||
* the element, whether it be proportional or percent or raw integer.
|
||||
*
|
||||
* @param aString the string to parse
|
||||
* @param aCanBePercent PR_TRUE if it can be a percent value (%)
|
||||
* @param aCanBeProportional PR_TRUE if it can be a proportional value (*)
|
||||
* @return whether the value could be parsed
|
||||
*/
|
||||
PRBool ParseSpecialIntValue(const nsAString& aString,
|
||||
PRBool aCanBePercent,
|
||||
PRBool aCanBeProportional);
|
||||
|
||||
|
||||
/**
|
||||
* Parse a string value into an integer.
|
||||
*
|
||||
* @param aString the string to parse
|
||||
* @return whether the value could be parsed
|
||||
*/
|
||||
PRBool ParseIntValue(const nsAString& aString) {
|
||||
return ParseIntWithBounds(aString, NS_ATTRVALUE_INTEGERTYPE_MINVALUE,
|
||||
NS_ATTRVALUE_INTEGERTYPE_MAXVALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a string value into an integer with minimum value and maximum value.
|
||||
*
|
||||
* @param aString the string to parse
|
||||
* @param aMin the minimum value (if value is less it will be bumped up)
|
||||
* @param aMax the maximum value (if value is greater it will be chopped down)
|
||||
* @return whether the value could be parsed
|
||||
*/
|
||||
PRBool ParseIntWithBounds(const nsAString& aString, PRInt32 aMin,
|
||||
PRInt32 aMax = NS_ATTRVALUE_INTEGERTYPE_MAXVALUE);
|
||||
|
||||
/**
|
||||
* Parse a string into a color.
|
||||
*
|
||||
* @param aString the string to parse
|
||||
* @param aDocument the document (to find out whether we're in quirks mode)
|
||||
* @return whether the value could be parsed
|
||||
*/
|
||||
PRBool ParseColor(const nsAString& aString, nsIDocument* aDocument);
|
||||
|
||||
private:
|
||||
// These have to be the same as in ValueType
|
||||
enum ValueBaseType {
|
||||
eStringBase = eString, // 00
|
||||
eOtherBase = 0x01, // 01
|
||||
eAtomBase = eAtom, // 10
|
||||
eIntegerBase = 0x03 // 11
|
||||
};
|
||||
|
||||
struct MiscContainer
|
||||
{
|
||||
ValueType mType;
|
||||
union {
|
||||
nscolor mColor;
|
||||
nsICSSStyleRule* mCSSStyleRule;
|
||||
nsCOMArray<nsIAtom>* mAtomArray;
|
||||
#ifdef MOZ_SVG
|
||||
nsISVGValue* mSVGValue;
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
inline ValueBaseType BaseType() const;
|
||||
|
||||
inline void SetPtrValueAndType(void* aValue, ValueBaseType aType);
|
||||
inline void SetIntValueAndType(PRInt32 aValue, ValueType aType);
|
||||
inline void ResetIfSet();
|
||||
|
||||
inline void* GetPtr() const;
|
||||
inline MiscContainer* GetMiscContainer() const;
|
||||
inline PRInt32 GetIntInternal() const;
|
||||
|
||||
PRBool EnsureEmptyMiscContainer();
|
||||
PRBool EnsureEmptyAtomArray();
|
||||
|
||||
static nsVoidArray* sEnumTableArray;
|
||||
|
||||
PtrBits mBits;
|
||||
};
|
||||
|
||||
/**
|
||||
* Implementation of inline methods
|
||||
*/
|
||||
|
||||
inline nsIAtom*
|
||||
nsAttrValue::GetAtomValue() const
|
||||
{
|
||||
NS_PRECONDITION(Type() == eAtom, "wrong type");
|
||||
return NS_REINTERPRET_CAST(nsIAtom*, GetPtr());
|
||||
}
|
||||
|
||||
inline PRInt32
|
||||
nsAttrValue::GetIntegerValue() const
|
||||
{
|
||||
NS_PRECONDITION(Type() == eInteger, "wrong type");
|
||||
return GetIntInternal();
|
||||
}
|
||||
|
||||
inline PRInt32
|
||||
nsAttrValue::GetProportionalValue() const
|
||||
{
|
||||
NS_PRECONDITION(Type() == eProportional, "wrong type");
|
||||
return GetIntInternal();
|
||||
}
|
||||
|
||||
inline PRInt16
|
||||
nsAttrValue::GetEnumValue() const
|
||||
{
|
||||
NS_PRECONDITION(Type() == eEnum, "wrong type");
|
||||
// We don't need to worry about sign extension here since we're
|
||||
// returning an PRInt16 which will cut away the top bits.
|
||||
return NS_STATIC_CAST(PRInt16,
|
||||
GetIntInternal() >> NS_ATTRVALUE_ENUMTABLEINDEX_BITS);
|
||||
}
|
||||
|
||||
inline float
|
||||
nsAttrValue::GetPercentValue() const
|
||||
{
|
||||
NS_PRECONDITION(Type() == ePercent, "wrong type");
|
||||
return NS_STATIC_CAST(float, GetIntInternal()) /
|
||||
100.0f;
|
||||
}
|
||||
|
||||
inline nsCOMArray<nsIAtom>*
|
||||
nsAttrValue::GetAtomArrayValue() const
|
||||
{
|
||||
NS_PRECONDITION(Type() == eAtomArray, "wrong type");
|
||||
return GetMiscContainer()->mAtomArray;
|
||||
}
|
||||
|
||||
inline nsICSSStyleRule*
|
||||
nsAttrValue::GetCSSStyleRuleValue() const
|
||||
{
|
||||
NS_PRECONDITION(Type() == eCSSStyleRule, "wrong type");
|
||||
return GetMiscContainer()->mCSSStyleRule;
|
||||
}
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
inline nsISVGValue*
|
||||
nsAttrValue::GetSVGValue() const
|
||||
{
|
||||
NS_PRECONDITION(Type() == eSVGValue, "wrong type");
|
||||
return GetMiscContainer()->mSVGValue;
|
||||
}
|
||||
#endif
|
||||
|
||||
inline nsAttrValue::ValueBaseType
|
||||
nsAttrValue::BaseType() const
|
||||
{
|
||||
return NS_STATIC_CAST(ValueBaseType, mBits & NS_ATTRVALUE_BASETYPE_MASK);
|
||||
}
|
||||
|
||||
inline void
|
||||
nsAttrValue::SetPtrValueAndType(void* aValue, ValueBaseType aType)
|
||||
{
|
||||
NS_ASSERTION(!(NS_PTR_TO_INT32(aValue) & ~NS_ATTRVALUE_POINTERVALUE_MASK),
|
||||
"pointer not properly aligned, this will crash");
|
||||
mBits = NS_REINTERPRET_CAST(PtrBits, aValue) | aType;
|
||||
}
|
||||
|
||||
inline void
|
||||
nsAttrValue::SetIntValueAndType(PRInt32 aValue, ValueType aType)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
{
|
||||
PRInt32 tmp = aValue * NS_ATTRVALUE_INTEGERTYPE_MULTIPLIER;
|
||||
NS_ASSERTION(tmp / NS_ATTRVALUE_INTEGERTYPE_MULTIPLIER == aValue,
|
||||
"Integer too big to fit");
|
||||
}
|
||||
#endif
|
||||
mBits = (aValue * NS_ATTRVALUE_INTEGERTYPE_MULTIPLIER) | aType;
|
||||
}
|
||||
|
||||
inline void
|
||||
nsAttrValue::ResetIfSet()
|
||||
{
|
||||
if (mBits) {
|
||||
Reset();
|
||||
}
|
||||
}
|
||||
|
||||
inline void*
|
||||
nsAttrValue::GetPtr() const
|
||||
{
|
||||
NS_ASSERTION(BaseType() != eIntegerBase,
|
||||
"getting pointer from non-pointer");
|
||||
return NS_REINTERPRET_CAST(void*, mBits & NS_ATTRVALUE_POINTERVALUE_MASK);
|
||||
}
|
||||
|
||||
inline nsAttrValue::MiscContainer*
|
||||
nsAttrValue::GetMiscContainer() const
|
||||
{
|
||||
NS_ASSERTION(BaseType() == eOtherBase, "wrong type");
|
||||
return NS_STATIC_CAST(MiscContainer*, GetPtr());
|
||||
}
|
||||
|
||||
inline PRInt32
|
||||
nsAttrValue::GetIntInternal() const
|
||||
{
|
||||
NS_ASSERTION(BaseType() == eIntegerBase,
|
||||
"getting integer from non-integer");
|
||||
// Make sure we get a signed value.
|
||||
// Lets hope the optimizer optimizes this into a shift. Unfortunatly signed
|
||||
// bitshift right is implementaion dependant.
|
||||
return NS_STATIC_CAST(PRInt32, mBits & ~NS_ATTRVALUE_INTEGERTYPE_MASK) /
|
||||
NS_ATTRVALUE_INTEGERTYPE_MULTIPLIER;
|
||||
}
|
||||
|
||||
inline PRBool
|
||||
nsAttrValue::IsEmptyString() const
|
||||
{
|
||||
return !mBits;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,193 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Implementations of DOM Core's nsIDOMComment node.
|
||||
*/
|
||||
|
||||
#include "nsIDOMComment.h"
|
||||
#include "nsGenericDOMDataNode.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
|
||||
class nsCommentNode : public nsGenericDOMDataNode,
|
||||
public nsIDOMComment
|
||||
{
|
||||
public:
|
||||
nsCommentNode(nsINodeInfo *aNodeInfo);
|
||||
virtual ~nsCommentNode();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIDOMNode
|
||||
NS_IMPL_NSIDOMNODE_USING_GENERIC_DOM_DATA
|
||||
|
||||
// nsIDOMCharacterData
|
||||
NS_FORWARD_NSIDOMCHARACTERDATA(nsGenericDOMDataNode::)
|
||||
|
||||
// nsIDOMComment
|
||||
// Empty interface
|
||||
|
||||
// nsIContent
|
||||
virtual PRBool MayHaveFrame() const;
|
||||
virtual PRBool IsNodeOfType(PRUint32 aFlags) const;
|
||||
|
||||
#ifdef DEBUG
|
||||
virtual void List(FILE* out, PRInt32 aIndent) const;
|
||||
virtual void DumpContent(FILE* out = stdout, PRInt32 aIndent = 0,
|
||||
PRBool aDumpAll = PR_TRUE) const
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewCommentNode(nsIContent** aInstancePtrResult,
|
||||
nsNodeInfoManager *aNodeInfoManager)
|
||||
{
|
||||
NS_PRECONDITION(aNodeInfoManager, "Missing nodeinfo manager");
|
||||
|
||||
*aInstancePtrResult = nsnull;
|
||||
|
||||
nsCOMPtr<nsINodeInfo> ni = aNodeInfoManager->GetCommentNodeInfo();
|
||||
NS_ENSURE_TRUE(ni, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsCommentNode *instance = new nsCommentNode(ni);
|
||||
if (!instance) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
NS_ADDREF(*aInstancePtrResult = instance);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCommentNode::nsCommentNode(nsINodeInfo *aNodeInfo)
|
||||
: nsGenericDOMDataNode(aNodeInfo)
|
||||
{
|
||||
}
|
||||
|
||||
nsCommentNode::~nsCommentNode()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// QueryInterface implementation for nsCommentNode
|
||||
NS_INTERFACE_MAP_BEGIN(nsCommentNode)
|
||||
NS_INTERFACE_MAP_ENTRY(nsITextContent)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMCharacterData)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMComment)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(Comment)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsGenericDOMDataNode)
|
||||
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsCommentNode, nsGenericDOMDataNode)
|
||||
NS_IMPL_RELEASE_INHERITED(nsCommentNode, nsGenericDOMDataNode)
|
||||
|
||||
|
||||
// virtual
|
||||
PRBool
|
||||
nsCommentNode::MayHaveFrame() const
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsCommentNode::IsNodeOfType(PRUint32 aFlags) const
|
||||
{
|
||||
return !(aFlags & ~(eCONTENT | eCOMMENT));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCommentNode::GetNodeName(nsAString& aNodeName)
|
||||
{
|
||||
aNodeName.AssignLiteral("#comment");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCommentNode::GetNodeValue(nsAString& aNodeValue)
|
||||
{
|
||||
return nsGenericDOMDataNode::GetNodeValue(aNodeValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCommentNode::SetNodeValue(const nsAString& aNodeValue)
|
||||
{
|
||||
return nsGenericDOMDataNode::SetNodeValue(aNodeValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCommentNode::GetNodeType(PRUint16* aNodeType)
|
||||
{
|
||||
*aNodeType = (PRUint16)nsIDOMNode::COMMENT_NODE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsGenericDOMDataNode*
|
||||
nsCommentNode::Clone(nsINodeInfo *aNodeInfo, PRBool aCloneText) const
|
||||
{
|
||||
nsCommentNode *it = new nsCommentNode(aNodeInfo);
|
||||
if (it && aCloneText) {
|
||||
it->mText = mText;
|
||||
}
|
||||
|
||||
return it;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
void
|
||||
nsCommentNode::List(FILE* out, PRInt32 aIndent) const
|
||||
{
|
||||
PRInt32 indx;
|
||||
for (indx = aIndent; --indx >= 0; ) fputs(" ", out);
|
||||
|
||||
fprintf(out, "Comment@%p refcount=%d<!--", this, mRefCnt.get());
|
||||
|
||||
nsAutoString tmp;
|
||||
ToCString(tmp, 0, mText.GetLength());
|
||||
fputs(NS_LossyConvertUTF16toASCII(tmp).get(), out);
|
||||
|
||||
fputs("-->\n", out);
|
||||
}
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,134 +0,0 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Mike Pinkerton <pinkerton@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
|
||||
#ifndef nsContentAreaDragDrop_h__
|
||||
#define nsContentAreaDragDrop_h__
|
||||
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#include "nsIDragDropHandler.h"
|
||||
#include "nsIDOMDragListener.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsITransferable.h"
|
||||
|
||||
class nsIDOMNode;
|
||||
class nsISelection;
|
||||
class nsITransferable;
|
||||
class nsIImage;
|
||||
class nsIPresShell;
|
||||
class nsPresContext;
|
||||
class nsIContent;
|
||||
class nsIDocument;
|
||||
class nsIURI;
|
||||
class nsIFile;
|
||||
class nsISimpleEnumerator;
|
||||
|
||||
// {1f34bc80-1bc7-11d6-a384-d705dd0746fc}
|
||||
#define NS_CONTENTAREADRAGDROP_CID \
|
||||
{ 0x1f34bc80, 0x1bc7, 0x11d6, \
|
||||
{ 0xa3, 0x84, 0xd7, 0x05, 0xdd, 0x07, 0x46, 0xfc } }
|
||||
|
||||
#define NS_CONTENTAREADRAGDROP_CONTRACTID "@mozilla.org:/content/content-area-dragdrop;1"
|
||||
|
||||
|
||||
//
|
||||
// class nsContentAreaDragDrop
|
||||
//
|
||||
// The class that listens to the chrome events handles anything
|
||||
// related to drag and drop. Registers itself with the DOM with
|
||||
// AddChromeListeners() and removes itself with
|
||||
// RemoveChromeListeners().
|
||||
//
|
||||
class nsContentAreaDragDrop : public nsIDOMDragListener,
|
||||
public nsIDragDropHandler,
|
||||
public nsIFlavorDataProvider
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDRAGDROPHANDLER
|
||||
NS_DECL_NSIFLAVORDATAPROVIDER
|
||||
|
||||
nsContentAreaDragDrop();
|
||||
virtual ~nsContentAreaDragDrop();
|
||||
|
||||
// nsIDOMDragListener
|
||||
NS_IMETHOD DragEnter(nsIDOMEvent* aMouseEvent);
|
||||
NS_IMETHOD DragOver(nsIDOMEvent* aMouseEvent);
|
||||
NS_IMETHOD DragExit(nsIDOMEvent* aMouseEvent);
|
||||
NS_IMETHOD DragDrop(nsIDOMEvent* aMouseEvent);
|
||||
NS_IMETHOD DragGesture(nsIDOMEvent* aMouseEvent);
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent *event);
|
||||
|
||||
private:
|
||||
|
||||
// Add/remove the relevant listeners
|
||||
nsresult AddDragListener();
|
||||
nsresult RemoveDragListener();
|
||||
|
||||
// utility routines
|
||||
static void NormalizeSelection(nsIDOMNode* inBaseNode,
|
||||
nsISelection* inSelection);
|
||||
static void GetEventDocument(nsIDOMEvent* inEvent,
|
||||
nsIDOMDocument** outDocument);
|
||||
|
||||
static nsresult SaveURIToFile(nsAString& inSourceURIString,
|
||||
nsIFile* inDestFile);
|
||||
|
||||
nsresult CreateTransferable(nsIDOMEvent* inMouseEvent,
|
||||
nsITransferable** outTrans);
|
||||
void ExtractURLFromData(const nsACString & inFlavor,
|
||||
nsISupports* inDataWrapper, PRUint32 inDataLen,
|
||||
nsAString & outURL);
|
||||
nsresult GetHookEnumeratorFromEvent(nsIDOMEvent* inEvent,
|
||||
nsISimpleEnumerator** outEnumerator);
|
||||
|
||||
PRPackedBool mListenerInstalled;
|
||||
|
||||
nsCOMPtr<nsIDOMEventReceiver> mEventReceiver;
|
||||
|
||||
// weak ref, this is probably my owning webshell
|
||||
// FIXME: we set this and never null it out. That's bad! See bug 332187.
|
||||
nsIWebNavigation* mNavigator;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* nsContentAreaDragDrop_h__ */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,405 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* nsBaseContentList is a basic list of content nodes; nsContentList
|
||||
* is a commonly used NodeList implementation (used for
|
||||
* getElementsByTagName, some properties on nsIDOMHTMLDocument, etc).
|
||||
*/
|
||||
|
||||
#ifndef nsContentList_h___
|
||||
#define nsContentList_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMHTMLCollection.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsStubDocumentObserver.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
|
||||
// This is a callback function type that can be used to implement an
|
||||
// arbitrary matching algorithm. aContent is the content that may
|
||||
// match the list, while aNamespaceID, aAtom, and aData are whatever
|
||||
// was passed to the list's constructor.
|
||||
typedef PRBool (*nsContentListMatchFunc)(nsIContent* aContent,
|
||||
PRInt32 aNamespaceID,
|
||||
nsIAtom* aAtom,
|
||||
const nsAString& aData);
|
||||
|
||||
class nsIDocument;
|
||||
class nsIDOMHTMLFormElement;
|
||||
|
||||
|
||||
class nsBaseContentList : public nsIDOMNodeList
|
||||
{
|
||||
public:
|
||||
nsBaseContentList();
|
||||
virtual ~nsBaseContentList();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMNodeList
|
||||
NS_DECL_NSIDOMNODELIST
|
||||
|
||||
virtual void AppendElement(nsIContent *aContent);
|
||||
virtual void RemoveElement(nsIContent *aContent);
|
||||
virtual PRInt32 IndexOf(nsIContent *aContent, PRBool aDoFlush);
|
||||
virtual void Reset();
|
||||
|
||||
static void Shutdown();
|
||||
|
||||
protected:
|
||||
nsAutoVoidArray mElements;
|
||||
};
|
||||
|
||||
|
||||
// This class is used only by form element code and this is a static
|
||||
// list of elements. NOTE! This list holds strong references to
|
||||
// the elements in the list.
|
||||
class nsFormContentList : public nsBaseContentList
|
||||
{
|
||||
public:
|
||||
nsFormContentList(nsIDOMHTMLFormElement *aForm,
|
||||
nsBaseContentList& aContentList);
|
||||
virtual ~nsFormContentList();
|
||||
|
||||
virtual void AppendElement(nsIContent *aContent);
|
||||
virtual void RemoveElement(nsIContent *aContent);
|
||||
|
||||
virtual void Reset();
|
||||
};
|
||||
|
||||
/**
|
||||
* Class that's used as the key to hash nsContentList implementations
|
||||
* for fast retrieval
|
||||
*/
|
||||
class nsContentListKey
|
||||
{
|
||||
public:
|
||||
nsContentListKey(nsIDocument *aDocument,
|
||||
nsIAtom* aMatchAtom,
|
||||
PRInt32 aMatchNameSpaceId,
|
||||
nsIContent* aRootContent)
|
||||
: mMatchAtom(aMatchAtom),
|
||||
mMatchNameSpaceId(aMatchNameSpaceId),
|
||||
mDocument(aDocument),
|
||||
mRootContent(aRootContent)
|
||||
{
|
||||
}
|
||||
|
||||
nsContentListKey(const nsContentListKey& aContentListKey)
|
||||
: mMatchAtom(aContentListKey.mMatchAtom),
|
||||
mMatchNameSpaceId(aContentListKey.mMatchNameSpaceId),
|
||||
mDocument(aContentListKey.mDocument),
|
||||
mRootContent(aContentListKey.mRootContent)
|
||||
{
|
||||
}
|
||||
|
||||
PRBool Equals(const nsContentListKey& aContentListKey) const
|
||||
{
|
||||
return
|
||||
mMatchAtom == aContentListKey.mMatchAtom &&
|
||||
mMatchNameSpaceId == aContentListKey.mMatchNameSpaceId &&
|
||||
mDocument == aContentListKey.mDocument &&
|
||||
mRootContent == aContentListKey.mRootContent;
|
||||
}
|
||||
inline PRUint32 GetHash(void) const
|
||||
{
|
||||
return
|
||||
NS_PTR_TO_INT32(mMatchAtom.get()) ^
|
||||
(NS_PTR_TO_INT32(mRootContent) << 8) ^
|
||||
(NS_PTR_TO_INT32(mDocument) << 16) ^
|
||||
(mMatchNameSpaceId << 24);
|
||||
}
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIAtom> mMatchAtom;
|
||||
PRInt32 mMatchNameSpaceId;
|
||||
nsIDocument* mDocument; // Weak ref
|
||||
// XXX What if the mRootContent is detached from the doc and _then_
|
||||
// goes away (so we never get notified)? Note that we work around
|
||||
// that a little by not caching lists with an mRootContent in
|
||||
// gCachedContentList. If we fix this, we can remove that check.
|
||||
nsIContent* mRootContent; // Weak ref
|
||||
};
|
||||
|
||||
/**
|
||||
* Class that implements a live NodeList that matches nodes in the
|
||||
* tree based on some criterion
|
||||
*/
|
||||
class nsContentList : public nsBaseContentList,
|
||||
protected nsContentListKey,
|
||||
public nsIDOMHTMLCollection,
|
||||
public nsStubDocumentObserver
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
/**
|
||||
* @param aDocument the document to which to add as an nsIDocumentObserver
|
||||
* @param aMatchAtom an atom whose meaning depends on aMatchNameSpaceId
|
||||
* @param aMatchNameSpaceId if kNameSpaceID_Unknown then aMatchAtom is the
|
||||
* tagName to match. Otherwise we match nodes with
|
||||
* aMatchNameSpaceId and a localName equal to
|
||||
* aMatchAtom
|
||||
* @param aRootContent The content node under which to limit our search.
|
||||
* If not null, the root is aDocument.
|
||||
* @param aDeep If false, then look only at children of the root, nothing
|
||||
* deeper. If true, then look at the whole subtree rooted at
|
||||
* our root.
|
||||
*/
|
||||
nsContentList(nsIDocument *aDocument,
|
||||
nsIAtom* aMatchAtom,
|
||||
PRInt32 aMatchNameSpaceId,
|
||||
nsIContent* aRootContent = nsnull,
|
||||
PRBool aDeep = PR_TRUE);
|
||||
|
||||
/**
|
||||
* @param aDocument the document to which to add as an nsIDocumentObserver
|
||||
* @param aFunc the function to be called to determine whether we match
|
||||
* @param aData a string that will need to be passed back to aFunc
|
||||
* @param aRootContent The content node under which to limit our search.
|
||||
* If not null, the root is aDocument.
|
||||
* @param aDeep If false, then look only at children of the root, nothing
|
||||
* deeper. If true, then look at the whole subtree rooted at
|
||||
* our root.
|
||||
* @param aMatchAtom an atom to be passed back to aFunc
|
||||
* @param aMatchNameSpaceId a namespace id to be passed back to aFunc
|
||||
* @param aFuncMayDependOnAttr a boolean that indicates whether this list is
|
||||
* sensitive to attribute changes.
|
||||
*/
|
||||
nsContentList(nsIDocument *aDocument,
|
||||
nsContentListMatchFunc aFunc,
|
||||
const nsAString& aData,
|
||||
nsIContent* aRootContent = nsnull,
|
||||
PRBool aDeep = PR_TRUE,
|
||||
nsIAtom* aMatchAtom = nsnull,
|
||||
PRInt32 aMatchNameSpaceId = kNameSpaceID_None,
|
||||
PRBool aFuncMayDependOnAttr = PR_TRUE);
|
||||
virtual ~nsContentList();
|
||||
|
||||
// nsIDOMHTMLCollection
|
||||
NS_DECL_NSIDOMHTMLCOLLECTION
|
||||
|
||||
// nsBaseContentList overrides
|
||||
virtual PRInt32 IndexOf(nsIContent *aContent, PRBool aDoFlush);
|
||||
|
||||
// nsContentList public methods
|
||||
NS_HIDDEN_(nsISupports*) GetParentObject();
|
||||
NS_HIDDEN_(PRUint32) Length(PRBool aDoFlush);
|
||||
NS_HIDDEN_(nsIContent*) Item(PRUint32 aIndex, PRBool aDoFlush);
|
||||
NS_HIDDEN_(nsIContent*) NamedItem(const nsAString& aName, PRBool aDoFlush);
|
||||
NS_HIDDEN_(void) RootDestroyed();
|
||||
|
||||
nsContentListKey* GetKey() {
|
||||
return NS_STATIC_CAST(nsContentListKey*, this);
|
||||
}
|
||||
|
||||
|
||||
// nsIDocumentObserver
|
||||
virtual void AttributeChanged(nsIDocument *aDocument, nsIContent* aContent,
|
||||
PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
||||
PRInt32 aModType);
|
||||
virtual void ContentAppended(nsIDocument *aDocument, nsIContent* aContainer,
|
||||
PRInt32 aNewIndexInContainer);
|
||||
virtual void ContentInserted(nsIDocument *aDocument, nsIContent* aContainer,
|
||||
nsIContent* aChild, PRInt32 aIndexInContainer);
|
||||
virtual void ContentRemoved(nsIDocument *aDocument, nsIContent* aContainer,
|
||||
nsIContent* aChild, PRInt32 aIndexInContainer);
|
||||
virtual void DocumentWillBeDestroyed(nsIDocument *aDocument);
|
||||
|
||||
protected:
|
||||
void Init(nsIDocument *aDocument);
|
||||
/**
|
||||
* Returns whether the content element matches our criterion
|
||||
*
|
||||
* @param aContent the content to attempt to match
|
||||
* @return whether we match
|
||||
*/
|
||||
PRBool Match(nsIContent *aContent);
|
||||
/**
|
||||
* Match recursively. See if anything in the subtree rooted at
|
||||
* aContent matches our criterion.
|
||||
*
|
||||
* @param aContent the root of the subtree to match against
|
||||
* @return whether we match something in the tree rooted at aContent
|
||||
*/
|
||||
PRBool MatchSelf(nsIContent *aContent);
|
||||
|
||||
/**
|
||||
* Add elements in the subtree rooted in aContent that match our
|
||||
* criterion to our list until we've picked up aElementsToAppend
|
||||
* elements. This function enforces the invariant that
|
||||
* |aElementsToAppend + mElements.Count()| is a constant.
|
||||
*
|
||||
* @param aContent the root of the subtree we want to traverse
|
||||
* @param aIncludeRoot whether to include the root in the traversal
|
||||
* @param aElementsToAppend how many elements to append to the list
|
||||
* before stopping
|
||||
*/
|
||||
void PopulateWith(nsIContent *aContent, PRBool aIncludeRoot,
|
||||
PRUint32 & aElementsToAppend);
|
||||
/**
|
||||
* Populate our list starting at the child of aStartRoot that comes
|
||||
* after aStartChild (if such exists) and continuing in document
|
||||
* order. Stop once we've picked up aElementsToAppend elements.
|
||||
* This function enforces the invariant that |aElementsToAppend +
|
||||
* mElements.Count()| is a constant.
|
||||
*
|
||||
* @param aStartRoot the node with whose children we want to start traversal
|
||||
* @param aStartChild the child after which we want to start
|
||||
* @param aElementsToAppend how many elements to append to the list
|
||||
* before stopping
|
||||
*/
|
||||
void PopulateWithStartingAfter(nsIContent *aStartRoot,
|
||||
nsIContent *aStartChild,
|
||||
PRUint32 & aElementsToAppend);
|
||||
/**
|
||||
* Populate our list. Stop once we have at least aNeededLength
|
||||
* elements. At the end of PopulateSelf running, either the last
|
||||
* node we examined is the last node in our array or we have
|
||||
* traversed the whole document (or both).
|
||||
*
|
||||
* @param aNeededLength the length the list should have when we are
|
||||
* done (unless it exhausts the document)
|
||||
*/
|
||||
void PopulateSelf(PRUint32 aNeededLength);
|
||||
|
||||
/**
|
||||
* Our root content has been disconnected from the document, so stop
|
||||
* observing. From this point on, if someone asks us something we
|
||||
* walk the tree rooted at mRootContent starting at the beginning
|
||||
* and going as far as we need to to answer the question.
|
||||
*/
|
||||
void DisconnectFromDocument();
|
||||
|
||||
/**
|
||||
* @param aContainer a content node which could be a descendant of
|
||||
* mRootContent
|
||||
* @return PR_TRUE if mRootContent is null, PR_FALSE if aContainer
|
||||
* is null, PR_TRUE if aContainer is a descendant of mRootContent
|
||||
* (though if mDeep is false, only aContainer == mRootContent
|
||||
* counts), PR_FALSE otherwise
|
||||
*/
|
||||
PRBool MayContainRelevantNodes(nsIContent* aContainer);
|
||||
/**
|
||||
* Does this subtree contain our mRootContent?
|
||||
*
|
||||
* @param aContainer the root of the subtree
|
||||
* @return PR_FALSE if mRootContent is null, otherwise whether
|
||||
* mRootContent is a descendant of aContainer
|
||||
*/
|
||||
PRBool ContainsRoot(nsIContent* aContent);
|
||||
/**
|
||||
* If we have no document and we have a root content, then check if
|
||||
* our content has been added to a document. If so, we'll become an
|
||||
* observer of the document.
|
||||
*/
|
||||
void CheckDocumentExistence();
|
||||
/**
|
||||
* Remove ourselves from the hashtable that caches commonly accessed
|
||||
* content lists. Generally done on destruction.
|
||||
*/
|
||||
void RemoveFromHashtable();
|
||||
/**
|
||||
* If state is not LIST_UP_TO_DATE, fully populate ourselves with
|
||||
* all the nodes we can find.
|
||||
*/
|
||||
inline void BringSelfUpToDate(PRBool aDoFlush);
|
||||
/**
|
||||
* A function to check whether aContent is anonymous from our point
|
||||
* of view. If it is, we don't care about it, since we should never
|
||||
* contain it or any of its kids.
|
||||
*/
|
||||
PRBool IsContentAnonymous(nsIContent* aContent);
|
||||
/**
|
||||
* Function to use to determine whether a piece of content matches
|
||||
* our criterion
|
||||
*/
|
||||
nsContentListMatchFunc mFunc;
|
||||
/**
|
||||
* Closure data to pass to mFunc when we call it
|
||||
*/
|
||||
const nsAFlatString* mData;
|
||||
/**
|
||||
* True if we are looking for elements named "*"
|
||||
*/
|
||||
PRPackedBool mMatchAll;
|
||||
/**
|
||||
* The current state of the list (possible values are:
|
||||
* LIST_UP_TO_DATE, LIST_LAZY, LIST_DIRTY
|
||||
*/
|
||||
PRUint8 mState;
|
||||
/**
|
||||
* Whether to actually descend the tree. If this is false, we won't
|
||||
* consider grandkids of mRootContent.
|
||||
*/
|
||||
PRPackedBool mDeep;
|
||||
/**
|
||||
* Whether the return value of mFunc could depend on the values of
|
||||
* attributes.
|
||||
*/
|
||||
PRPackedBool mFuncMayDependOnAttr;
|
||||
};
|
||||
|
||||
/**
|
||||
* LIST_UP_TO_DATE means that the list is up to date and need not do
|
||||
* any walking to be able to answer any questions anyone may have.
|
||||
*/
|
||||
#define LIST_UP_TO_DATE 0
|
||||
/**
|
||||
* LIST_DIRTY means that the list contains no useful information and
|
||||
* if anyone asks it anything it will have to populate itself before
|
||||
* answering.
|
||||
*/
|
||||
#define LIST_DIRTY 1
|
||||
/**
|
||||
* LIST_LAZY means that the list has populated itself to a certain
|
||||
* extent and that that part of the list is still valid. Requests for
|
||||
* things outside that part of the list will require walking the tree
|
||||
* some more. When a list is in this state, the last thing in
|
||||
* mElements is the last node in the tree that the list looked at.
|
||||
*/
|
||||
#define LIST_LAZY 2
|
||||
|
||||
already_AddRefed<nsContentList>
|
||||
NS_GetContentList(nsIDocument* aDocument, nsIAtom* aMatchAtom,
|
||||
PRInt32 aMatchNameSpaceId, nsIContent* aRootContent);
|
||||
|
||||
#endif // nsContentList_h___
|
||||
@@ -1,239 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
// vim: ft=cpp tw=78 sw=4 et ts=8
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Zero-Knowledge Systems, Inc.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Implementation of the "@mozilla.org/layout/content-policy;1" contract.
|
||||
*/
|
||||
|
||||
#include "prlog.h"
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsXPCOM.h"
|
||||
#include "nsContentPolicyUtils.h"
|
||||
#include "nsContentPolicy.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsCOMArray.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsContentPolicy, nsIContentPolicy)
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
static PRLogModuleInfo* gConPolLog;
|
||||
#endif
|
||||
|
||||
nsresult
|
||||
NS_NewContentPolicy(nsIContentPolicy **aResult)
|
||||
{
|
||||
*aResult = new nsContentPolicy;
|
||||
if (!*aResult)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsContentPolicy::nsContentPolicy()
|
||||
: mPolicies(NS_CONTENTPOLICY_CATEGORY)
|
||||
{
|
||||
#ifdef PR_LOGGING
|
||||
if (! gConPolLog) {
|
||||
gConPolLog = PR_NewLogModule("nsContentPolicy");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
nsContentPolicy::~nsContentPolicy()
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
#define WARN_IF_URI_UNINITIALIZED(uri,name) \
|
||||
PR_BEGIN_MACRO \
|
||||
if ((uri)) { \
|
||||
nsCAutoString spec; \
|
||||
(uri)->GetAsciiSpec(spec); \
|
||||
if (spec.IsEmpty()) { \
|
||||
NS_WARNING(name " is uninitialized, fix caller"); \
|
||||
} \
|
||||
} \
|
||||
PR_END_MACRO
|
||||
|
||||
#else // ! defined(DEBUG)
|
||||
|
||||
#define WARN_IF_URI_UNINITIALIZED(uri,name)
|
||||
|
||||
#endif // defined(DEBUG)
|
||||
|
||||
inline nsresult
|
||||
nsContentPolicy::CheckPolicy(CPMethod policyMethod,
|
||||
PRUint32 contentType,
|
||||
nsIURI *contentLocation,
|
||||
nsIURI *requestingLocation,
|
||||
nsISupports *requestingContext,
|
||||
const nsACString &mimeType,
|
||||
nsISupports *extra,
|
||||
PRInt16 *decision)
|
||||
{
|
||||
//sanity-check passed-through parameters
|
||||
NS_PRECONDITION(decision, "Null out pointer");
|
||||
WARN_IF_URI_UNINITIALIZED(contentLocation, "Request URI");
|
||||
WARN_IF_URI_UNINITIALIZED(requestingLocation, "Requesting URI");
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(requestingContext));
|
||||
nsCOMPtr<nsIDOMWindow> window(do_QueryInterface(requestingContext));
|
||||
NS_ASSERTION(!requestingContext || node || window,
|
||||
"Context should be a DOM node or a DOM window!");
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* There might not be a requestinglocation. This can happen for
|
||||
* iframes with an image as src. Get the uri from the dom node.
|
||||
* See bug 254510
|
||||
*/
|
||||
if (!requestingLocation) {
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
nsCOMPtr<nsIContent> node = do_QueryInterface(requestingContext);
|
||||
if (node) {
|
||||
doc = node->GetOwnerDoc();
|
||||
}
|
||||
if (!doc) {
|
||||
doc = do_QueryInterface(requestingContext);
|
||||
}
|
||||
if (doc) {
|
||||
requestingLocation = doc->GetDocumentURI();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Enumerate mPolicies and ask each of them, taking the logical AND of
|
||||
* their permissions.
|
||||
*/
|
||||
nsresult rv;
|
||||
const nsCOMArray<nsIContentPolicy>& entries = mPolicies.GetEntries();
|
||||
PRInt32 count = entries.Count();
|
||||
for (PRInt32 i = 0; i < count; i++) {
|
||||
/* check the appropriate policy */
|
||||
rv = (entries[i]->*policyMethod)(contentType, contentLocation,
|
||||
requestingLocation, requestingContext,
|
||||
mimeType, extra, decision);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && NS_CP_REJECTED(*decision)) {
|
||||
/* policy says no, no point continuing to check */
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// everyone returned failure, or no policies: sanitize result
|
||||
*decision = nsIContentPolicy::ACCEPT;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
|
||||
//uses the parameters from ShouldXYZ to produce and log a message
|
||||
//logType must be a literal string constant
|
||||
#define LOG_CHECK(logType) \
|
||||
PR_BEGIN_MACRO \
|
||||
/* skip all this nonsense if the call failed */ \
|
||||
if (NS_SUCCEEDED(rv)) { \
|
||||
const char *resultName; \
|
||||
if (decision) { \
|
||||
resultName = NS_CP_ResponseName(*decision); \
|
||||
} else { \
|
||||
resultName = "(null ptr)"; \
|
||||
} \
|
||||
nsCAutoString spec("None"); \
|
||||
if (contentLocation) { \
|
||||
contentLocation->GetSpec(spec); \
|
||||
} \
|
||||
nsCAutoString refSpec("None"); \
|
||||
if (requestingLocation) { \
|
||||
requestingLocation->GetSpec(refSpec); \
|
||||
} \
|
||||
PR_LOG(gConPolLog, PR_LOG_DEBUG, \
|
||||
("Content Policy: " logType ": <%s> <Ref:%s> result=%s", \
|
||||
spec.get(), refSpec.get(), resultName) \
|
||||
); \
|
||||
} \
|
||||
PR_END_MACRO
|
||||
|
||||
#else //!defined(PR_LOGGING)
|
||||
|
||||
#define LOG_CHECK(logType)
|
||||
|
||||
#endif //!defined(PR_LOGGING)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentPolicy::ShouldLoad(PRUint32 contentType,
|
||||
nsIURI *contentLocation,
|
||||
nsIURI *requestingLocation,
|
||||
nsISupports *requestingContext,
|
||||
const nsACString &mimeType,
|
||||
nsISupports *extra,
|
||||
PRInt16 *decision)
|
||||
{
|
||||
// ShouldProcess does not need a content location, but we do
|
||||
NS_PRECONDITION(contentLocation, "Must provide request location");
|
||||
nsresult rv = CheckPolicy(&nsIContentPolicy::ShouldLoad, contentType,
|
||||
contentLocation, requestingLocation,
|
||||
requestingContext, mimeType, extra, decision);
|
||||
LOG_CHECK("ShouldLoad");
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentPolicy::ShouldProcess(PRUint32 contentType,
|
||||
nsIURI *contentLocation,
|
||||
nsIURI *requestingLocation,
|
||||
nsISupports *requestingContext,
|
||||
const nsACString &mimeType,
|
||||
nsISupports *extra,
|
||||
PRInt16 *decision)
|
||||
{
|
||||
nsresult rv = CheckPolicy(&nsIContentPolicy::ShouldProcess, contentType,
|
||||
contentLocation, requestingLocation,
|
||||
requestingContext, mimeType, extra, decision);
|
||||
LOG_CHECK("ShouldProcess");
|
||||
|
||||
return rv;
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
// vim: ft=cpp ts=8 sw=4 et tw=78
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Zero-Knowledge Systems, Inc.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Tim Watt <riceman+bmo@mail.rit.edu>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __nsContentPolicy_h__
|
||||
#define __nsContentPolicy_h__
|
||||
|
||||
#include "nsIContentPolicy.h"
|
||||
#include "nsCategoryCache.h"
|
||||
|
||||
/*
|
||||
* Implementation of the "@mozilla.org/layout/content-policy;1" contract.
|
||||
*/
|
||||
|
||||
class nsContentPolicy : public nsIContentPolicy
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSICONTENTPOLICY
|
||||
|
||||
nsContentPolicy();
|
||||
virtual ~nsContentPolicy();
|
||||
private:
|
||||
//Array of policies
|
||||
nsCategoryCache<nsIContentPolicy> mPolicies;
|
||||
|
||||
//Helper type for CheckPolicy
|
||||
typedef
|
||||
NS_STDCALL_FUNCPROTO(nsresult, CPMethod, nsIContentPolicy,
|
||||
ShouldProcess,
|
||||
(PRUint32, nsIURI*, nsIURI*, nsISupports*,
|
||||
const nsACString &, nsISupports*, PRInt16*));
|
||||
|
||||
//Helper method that applies policyMethod across all policies in mPolicies
|
||||
// with the given parameters
|
||||
nsresult CheckPolicy(CPMethod policyMethod, PRUint32 contentType,
|
||||
nsIURI *aURI, nsIURI *origURI,
|
||||
nsISupports *requestingContext,
|
||||
const nsACString &mimeGuess, nsISupports *extra,
|
||||
PRInt16 *decision);
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewContentPolicy(nsIContentPolicy **aResult);
|
||||
|
||||
#endif /* __nsContentPolicy_h__ */
|
||||
@@ -1,872 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Base class for the XML and HTML content sinks, which construct a
|
||||
* DOM based on information from the parser.
|
||||
*/
|
||||
|
||||
#include "nsContentSink.h"
|
||||
#include "nsIScriptLoader.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsICSSLoader.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsStyleLinkElement.h"
|
||||
#include "nsINodeInfo.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsCPrefetchService.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIScriptElement.h"
|
||||
#include "nsIParser.h"
|
||||
#include "nsContentErrors.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsIScrollableView.h"
|
||||
#include "nsIContentViewer.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsICookieService.h"
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsParserUtils.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsEscape.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsNodeInfoManager.h"
|
||||
|
||||
|
||||
#ifdef ALLOW_ASYNCH_STYLE_SHEETS
|
||||
const PRBool kBlockByDefault = PR_FALSE;
|
||||
#else
|
||||
const PRBool kBlockByDefault = PR_TRUE;
|
||||
#endif
|
||||
|
||||
|
||||
class nsScriptLoaderObserverProxy : public nsIScriptLoaderObserver
|
||||
{
|
||||
public:
|
||||
nsScriptLoaderObserverProxy(nsIScriptLoaderObserver* aInner)
|
||||
: mInner(do_GetWeakReference(aInner))
|
||||
{
|
||||
}
|
||||
virtual ~nsScriptLoaderObserverProxy()
|
||||
{
|
||||
}
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISCRIPTLOADEROBSERVER
|
||||
|
||||
nsWeakPtr mInner;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsScriptLoaderObserverProxy, nsIScriptLoaderObserver)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptLoaderObserverProxy::ScriptAvailable(nsresult aResult,
|
||||
nsIScriptElement *aElement,
|
||||
PRBool aIsInline,
|
||||
PRBool aWasPending,
|
||||
nsIURI *aURI,
|
||||
PRInt32 aLineNo,
|
||||
const nsAString & aScript)
|
||||
{
|
||||
nsCOMPtr<nsIScriptLoaderObserver> inner = do_QueryReferent(mInner);
|
||||
|
||||
if (inner) {
|
||||
return inner->ScriptAvailable(aResult, aElement, aIsInline, aWasPending,
|
||||
aURI, aLineNo, aScript);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptLoaderObserverProxy::ScriptEvaluated(nsresult aResult,
|
||||
nsIScriptElement *aElement,
|
||||
PRBool aIsInline,
|
||||
PRBool aWasPending)
|
||||
{
|
||||
nsCOMPtr<nsIScriptLoaderObserver> inner = do_QueryReferent(mInner);
|
||||
|
||||
if (inner) {
|
||||
return inner->ScriptEvaluated(aResult, aElement, aIsInline, aWasPending);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS3(nsContentSink,
|
||||
nsICSSLoaderObserver,
|
||||
nsISupportsWeakReference,
|
||||
nsIScriptLoaderObserver)
|
||||
|
||||
nsContentSink::nsContentSink()
|
||||
: mNeedToBlockParser(PR_FALSE)
|
||||
{
|
||||
}
|
||||
|
||||
nsContentSink::~nsContentSink()
|
||||
{
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsContentSink::Init(nsIDocument* aDoc,
|
||||
nsIURI* aURI,
|
||||
nsISupports* aContainer,
|
||||
nsIChannel* aChannel)
|
||||
{
|
||||
NS_PRECONDITION(aDoc, "null ptr");
|
||||
NS_PRECONDITION(aURI, "null ptr");
|
||||
|
||||
if (!aDoc || !aURI) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
mDocument = aDoc;
|
||||
|
||||
mDocumentURI = aURI;
|
||||
mDocumentBaseURI = aURI;
|
||||
mDocShell = do_QueryInterface(aContainer);
|
||||
|
||||
// use this to avoid a circular reference sink->document->scriptloader->sink
|
||||
nsCOMPtr<nsIScriptLoaderObserver> proxy =
|
||||
new nsScriptLoaderObserverProxy(this);
|
||||
NS_ENSURE_TRUE(proxy, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsIScriptLoader *loader = mDocument->GetScriptLoader();
|
||||
NS_ENSURE_TRUE(loader, NS_ERROR_FAILURE);
|
||||
nsresult rv = loader->AddObserver(proxy);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mCSSLoader = aDoc->CSSLoader();
|
||||
|
||||
ProcessHTTPHeaders(aChannel);
|
||||
|
||||
mNodeInfoManager = aDoc->NodeInfoManager();
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentSink::StyleSheetLoaded(nsICSSStyleSheet* aSheet,
|
||||
PRBool aWasAlternate,
|
||||
nsresult aStatus)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentSink::ScriptAvailable(nsresult aResult,
|
||||
nsIScriptElement *aElement,
|
||||
PRBool aIsInline,
|
||||
PRBool aWasPending,
|
||||
nsIURI *aURI,
|
||||
PRInt32 aLineNo,
|
||||
const nsAString& aScript)
|
||||
{
|
||||
PRUint32 count = mScriptElements.Count();
|
||||
|
||||
if (count == 0) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Check if this is the element we were waiting for
|
||||
if (aElement != mScriptElements[count - 1]) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (mParser && !mParser->IsParserEnabled()) {
|
||||
// make sure to unblock the parser before evaluating the script,
|
||||
// we must unblock the parser even if loading the script failed or
|
||||
// if the script was empty, if we don't, the parser will never be
|
||||
// unblocked.
|
||||
mParser->UnblockParser();
|
||||
}
|
||||
|
||||
// Mark the current script as loaded
|
||||
mNeedToBlockParser = PR_FALSE;
|
||||
|
||||
if (NS_SUCCEEDED(aResult) && aResult != NS_CONTENT_SCRIPT_IS_EVENTHANDLER) {
|
||||
PreEvaluateScript();
|
||||
} else {
|
||||
mScriptElements.RemoveObjectAt(count - 1);
|
||||
|
||||
if (mParser && aWasPending && aResult != NS_BINDING_ABORTED) {
|
||||
// Loading external script failed!. So, resume parsing since the parser
|
||||
// got blocked when loading external script. See
|
||||
// http://bugzilla.mozilla.org/show_bug.cgi?id=94903.
|
||||
//
|
||||
// XXX We don't resume parsing if we get NS_BINDING_ABORTED from the
|
||||
// script load, assuming that that error code means that the user
|
||||
// stopped the load through some action (like clicking a link). See
|
||||
// http://bugzilla.mozilla.org/show_bug.cgi?id=243392.
|
||||
mParser->ContinueInterruptedParsing();
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentSink::ScriptEvaluated(nsresult aResult,
|
||||
nsIScriptElement *aElement,
|
||||
PRBool aIsInline,
|
||||
PRBool aWasPending)
|
||||
{
|
||||
// Check if this is the element we were waiting for
|
||||
PRInt32 count = mScriptElements.Count();
|
||||
if (count == 0) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (aElement != mScriptElements[count - 1]) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Pop the script element stack
|
||||
mScriptElements.RemoveObjectAt(count - 1);
|
||||
|
||||
if (NS_SUCCEEDED(aResult)) {
|
||||
PostEvaluateScript(aElement);
|
||||
}
|
||||
|
||||
if (mParser && mParser->IsParserEnabled() && aWasPending) {
|
||||
mParser->ContinueInterruptedParsing();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsContentSink::ProcessHTTPHeaders(nsIChannel* aChannel)
|
||||
{
|
||||
nsCOMPtr<nsIHttpChannel> httpchannel(do_QueryInterface(aChannel));
|
||||
|
||||
if (!httpchannel) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Note that the only header we care about is the "link" header, since we
|
||||
// have all the infrastructure for kicking off stylesheet loads.
|
||||
|
||||
nsCAutoString linkHeader;
|
||||
|
||||
nsresult rv = httpchannel->GetResponseHeader(NS_LITERAL_CSTRING("link"),
|
||||
linkHeader);
|
||||
if (NS_SUCCEEDED(rv) && !linkHeader.IsEmpty()) {
|
||||
ProcessHeaderData(nsHTMLAtoms::link,
|
||||
NS_ConvertASCIItoUTF16(linkHeader));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsContentSink::ProcessHeaderData(nsIAtom* aHeader, const nsAString& aValue,
|
||||
nsIContent* aContent)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
// necko doesn't process headers coming in from the parser
|
||||
|
||||
mDocument->SetHeaderData(aHeader, aValue);
|
||||
|
||||
if (aHeader == nsHTMLAtoms::setcookie) {
|
||||
// Note: Necko already handles cookies set via the channel. We can't just
|
||||
// call SetCookie on the channel because we want to do some security checks
|
||||
// here and want to use the prompt associated to our current window, not
|
||||
// the window where the channel was dispatched.
|
||||
nsCOMPtr<nsICookieService> cookieServ =
|
||||
do_GetService(NS_COOKIESERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Get a URI from the document principal
|
||||
|
||||
// We use the original codebase in case the codebase was changed
|
||||
// by SetDomain
|
||||
|
||||
// Note that a non-codebase principal (eg the system principal) will return
|
||||
// a null URI.
|
||||
nsCOMPtr<nsIURI> codebaseURI;
|
||||
rv = mDocument->NodePrincipal()->GetURI(getter_AddRefs(codebaseURI));
|
||||
NS_ENSURE_TRUE(codebaseURI, rv);
|
||||
|
||||
nsCOMPtr<nsIPrompt> prompt;
|
||||
nsCOMPtr<nsIDOMWindowInternal> window (do_QueryInterface(mDocument->GetScriptGlobalObject()));
|
||||
if (window) {
|
||||
window->GetPrompter(getter_AddRefs(prompt));
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
if (mParser) {
|
||||
mParser->GetChannel(getter_AddRefs(channel));
|
||||
}
|
||||
|
||||
rv = cookieServ->SetCookieString(codebaseURI,
|
||||
prompt,
|
||||
NS_ConvertUTF16toUTF8(aValue).get(),
|
||||
channel);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
else if (aHeader == nsHTMLAtoms::link) {
|
||||
rv = ProcessLinkHeader(aContent, aValue);
|
||||
}
|
||||
else if (aHeader == nsHTMLAtoms::msthemecompatible) {
|
||||
// Disable theming for the presshell if the value is no.
|
||||
// XXXbz don't we want to support this as an HTTP header too?
|
||||
nsAutoString value(aValue);
|
||||
if (value.LowerCaseEqualsLiteral("no")) {
|
||||
nsIPresShell* shell = mDocument->GetShellAt(0);
|
||||
if (shell) {
|
||||
shell->DisableThemeSupport();
|
||||
}
|
||||
}
|
||||
}
|
||||
// Don't report "refresh" headers back to necko, since our document handles
|
||||
// them
|
||||
else if (aHeader != nsHTMLAtoms::refresh && mParser) {
|
||||
// we also need to report back HTTP-EQUIV headers to the channel
|
||||
// so that it can process things like pragma: no-cache or other
|
||||
// cache-control headers. Ideally this should also be the way for
|
||||
// cookies to be set! But we'll worry about that in the next
|
||||
// iteration
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
if (NS_SUCCEEDED(mParser->GetChannel(getter_AddRefs(channel)))) {
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel));
|
||||
if (httpChannel) {
|
||||
const char* header;
|
||||
(void)aHeader->GetUTF8String(&header);
|
||||
(void)httpChannel->SetResponseHeader(nsDependentCString(header),
|
||||
NS_ConvertUTF16toUTF8(aValue),
|
||||
PR_TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
static const PRUnichar kSemiCh = PRUnichar(';');
|
||||
static const PRUnichar kCommaCh = PRUnichar(',');
|
||||
static const PRUnichar kEqualsCh = PRUnichar('=');
|
||||
static const PRUnichar kLessThanCh = PRUnichar('<');
|
||||
static const PRUnichar kGreaterThanCh = PRUnichar('>');
|
||||
|
||||
nsresult
|
||||
nsContentSink::ProcessLinkHeader(nsIContent* aElement,
|
||||
const nsAString& aLinkData)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// parse link content and call process style link
|
||||
nsAutoString href;
|
||||
nsAutoString rel;
|
||||
nsAutoString title;
|
||||
nsAutoString type;
|
||||
nsAutoString media;
|
||||
PRBool didBlock = PR_FALSE;
|
||||
|
||||
// copy to work buffer
|
||||
nsAutoString stringList(aLinkData);
|
||||
|
||||
// put an extra null at the end
|
||||
stringList.Append(kNullCh);
|
||||
|
||||
PRUnichar* start = stringList.BeginWriting();
|
||||
PRUnichar* end = start;
|
||||
PRUnichar* last = start;
|
||||
PRUnichar endCh;
|
||||
|
||||
while (*start != kNullCh) {
|
||||
// skip leading space
|
||||
while ((*start != kNullCh) && nsCRT::IsAsciiSpace(*start)) {
|
||||
++start;
|
||||
}
|
||||
|
||||
end = start;
|
||||
last = end - 1;
|
||||
|
||||
// look for semicolon or comma
|
||||
while (*end != kNullCh && *end != kSemiCh && *end != kCommaCh) {
|
||||
PRUnichar ch = *end;
|
||||
|
||||
if (ch == kApostrophe || ch == kQuote || ch == kLessThanCh) {
|
||||
// quoted string
|
||||
|
||||
PRUnichar quote = *end;
|
||||
if (quote == kLessThanCh) {
|
||||
quote = kGreaterThanCh;
|
||||
}
|
||||
|
||||
PRUnichar* closeQuote = (end + 1);
|
||||
|
||||
// seek closing quote
|
||||
while (*closeQuote != kNullCh && quote != *closeQuote) {
|
||||
++closeQuote;
|
||||
}
|
||||
|
||||
if (quote == *closeQuote) {
|
||||
// found closer
|
||||
|
||||
// skip to close quote
|
||||
end = closeQuote;
|
||||
|
||||
last = end - 1;
|
||||
|
||||
ch = *(end + 1);
|
||||
|
||||
if (ch != kNullCh && ch != kSemiCh && ch != kCommaCh) {
|
||||
// end string here
|
||||
*(++end) = kNullCh;
|
||||
|
||||
ch = *(end + 1);
|
||||
|
||||
// keep going until semi or comma
|
||||
while (ch != kNullCh && ch != kSemiCh && ch != kCommaCh) {
|
||||
++end;
|
||||
|
||||
ch = *end;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
++end;
|
||||
++last;
|
||||
}
|
||||
|
||||
endCh = *end;
|
||||
|
||||
// end string here
|
||||
*end = kNullCh;
|
||||
|
||||
if (start < end) {
|
||||
if ((*start == kLessThanCh) && (*last == kGreaterThanCh)) {
|
||||
*last = kNullCh;
|
||||
|
||||
if (href.IsEmpty()) { // first one wins
|
||||
href = (start + 1);
|
||||
href.StripWhitespace();
|
||||
}
|
||||
} else {
|
||||
PRUnichar* equals = start;
|
||||
|
||||
while ((*equals != kNullCh) && (*equals != kEqualsCh)) {
|
||||
equals++;
|
||||
}
|
||||
|
||||
if (*equals != kNullCh) {
|
||||
*equals = kNullCh;
|
||||
nsAutoString attr(start);
|
||||
attr.StripWhitespace();
|
||||
|
||||
PRUnichar* value = ++equals;
|
||||
while (nsCRT::IsAsciiSpace(*value)) {
|
||||
value++;
|
||||
}
|
||||
|
||||
if (((*value == kApostrophe) || (*value == kQuote)) &&
|
||||
(*value == *last)) {
|
||||
*last = kNullCh;
|
||||
value++;
|
||||
}
|
||||
|
||||
if (attr.LowerCaseEqualsLiteral("rel")) {
|
||||
if (rel.IsEmpty()) {
|
||||
rel = value;
|
||||
rel.CompressWhitespace();
|
||||
}
|
||||
} else if (attr.LowerCaseEqualsLiteral("title")) {
|
||||
if (title.IsEmpty()) {
|
||||
title = value;
|
||||
title.CompressWhitespace();
|
||||
}
|
||||
} else if (attr.LowerCaseEqualsLiteral("type")) {
|
||||
if (type.IsEmpty()) {
|
||||
type = value;
|
||||
type.StripWhitespace();
|
||||
}
|
||||
} else if (attr.LowerCaseEqualsLiteral("media")) {
|
||||
if (media.IsEmpty()) {
|
||||
media = value;
|
||||
|
||||
// HTML4.0 spec is inconsistent, make it case INSENSITIVE
|
||||
ToLowerCase(media);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (endCh == kCommaCh) {
|
||||
// hit a comma, process what we've got so far
|
||||
|
||||
if (!href.IsEmpty() && !rel.IsEmpty()) {
|
||||
rv = ProcessLink(aElement, href, rel, title, type, media);
|
||||
if (rv == NS_ERROR_HTMLPARSER_BLOCK) {
|
||||
didBlock = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
href.Truncate();
|
||||
rel.Truncate();
|
||||
title.Truncate();
|
||||
type.Truncate();
|
||||
media.Truncate();
|
||||
}
|
||||
|
||||
start = ++end;
|
||||
}
|
||||
|
||||
if (!href.IsEmpty() && !rel.IsEmpty()) {
|
||||
rv = ProcessLink(aElement, href, rel, title, type, media);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && didBlock) {
|
||||
rv = NS_ERROR_HTMLPARSER_BLOCK;
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsContentSink::ProcessLink(nsIContent* aElement,
|
||||
const nsSubstring& aHref, const nsSubstring& aRel,
|
||||
const nsSubstring& aTitle, const nsSubstring& aType,
|
||||
const nsSubstring& aMedia)
|
||||
{
|
||||
// XXX seems overkill to generate this string array
|
||||
nsStringArray linkTypes;
|
||||
nsStyleLinkElement::ParseLinkTypes(aRel, linkTypes);
|
||||
|
||||
PRBool hasPrefetch = (linkTypes.IndexOf(NS_LITERAL_STRING("prefetch")) != -1);
|
||||
// prefetch href if relation is "next" or "prefetch"
|
||||
if (hasPrefetch || linkTypes.IndexOf(NS_LITERAL_STRING("next")) != -1) {
|
||||
PrefetchHref(aHref, hasPrefetch);
|
||||
}
|
||||
|
||||
// is it a stylesheet link?
|
||||
if (linkTypes.IndexOf(NS_LITERAL_STRING("stylesheet")) == -1) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool isAlternate = linkTypes.IndexOf(NS_LITERAL_STRING("alternate")) != -1;
|
||||
return ProcessStyleLink(aElement, aHref, isAlternate, aTitle, aType,
|
||||
aMedia);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsContentSink::ProcessStyleLink(nsIContent* aElement,
|
||||
const nsSubstring& aHref,
|
||||
PRBool aAlternate,
|
||||
const nsSubstring& aTitle,
|
||||
const nsSubstring& aType,
|
||||
const nsSubstring& aMedia)
|
||||
{
|
||||
if (aAlternate && aTitle.IsEmpty()) {
|
||||
// alternates must have title return without error, for now
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsAutoString mimeType;
|
||||
nsAutoString params;
|
||||
nsParserUtils::SplitMimeType(aType, mimeType, params);
|
||||
|
||||
// see bug 18817
|
||||
if (!mimeType.IsEmpty() && !mimeType.LowerCaseEqualsLiteral("text/css")) {
|
||||
// Unknown stylesheet language
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> url;
|
||||
nsresult rv = NS_NewURI(getter_AddRefs(url), aHref, nsnull, mDocumentBaseURI);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
// The URI is bad, move along, don't propagate the error (for now)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIParser* parser = nsnull;
|
||||
if (kBlockByDefault) {
|
||||
parser = mParser;
|
||||
}
|
||||
|
||||
PRBool isAlternate;
|
||||
rv = mCSSLoader->LoadStyleLink(aElement, url, aTitle, aMedia, aAlternate,
|
||||
parser, this, &isAlternate);
|
||||
if (NS_SUCCEEDED(rv) && parser && !isAlternate) {
|
||||
rv = NS_ERROR_HTMLPARSER_BLOCK;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsContentSink::ProcessMETATag(nsIContent* aContent)
|
||||
{
|
||||
NS_ASSERTION(aContent, "missing base-element");
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// set any HTTP-EQUIV data into document's header data as well as url
|
||||
nsAutoString header;
|
||||
aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::httpEquiv, header);
|
||||
if (!header.IsEmpty()) {
|
||||
nsAutoString result;
|
||||
aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::content, result);
|
||||
if (!result.IsEmpty()) {
|
||||
ToLowerCase(header);
|
||||
nsCOMPtr<nsIAtom> fieldAtom(do_GetAtom(header));
|
||||
rv = ProcessHeaderData(fieldAtom, result, aContent);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsContentSink::PrefetchHref(const nsAString &aHref, PRBool aExplicit)
|
||||
{
|
||||
//
|
||||
// SECURITY CHECK: disable prefetching from mailnews!
|
||||
//
|
||||
// walk up the docshell tree to see if any containing
|
||||
// docshell are of type MAIL.
|
||||
//
|
||||
if (!mDocShell)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIDocShell> docshell = mDocShell;
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeItem> treeItem, parentItem;
|
||||
do {
|
||||
PRUint32 appType = 0;
|
||||
nsresult rv = docshell->GetAppType(&appType);
|
||||
if (NS_FAILED(rv) || appType == nsIDocShell::APP_TYPE_MAIL)
|
||||
return; // do not prefetch from mailnews
|
||||
if (treeItem = do_QueryInterface(docshell)) {
|
||||
treeItem->GetParent(getter_AddRefs(parentItem));
|
||||
if (parentItem) {
|
||||
treeItem = parentItem;
|
||||
docshell = do_QueryInterface(treeItem);
|
||||
if (!docshell) {
|
||||
NS_ERROR("cannot get a docshell from a treeItem!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (parentItem);
|
||||
|
||||
// OK, we passed the security check...
|
||||
|
||||
nsCOMPtr<nsIPrefetchService> prefetchService(do_GetService(NS_PREFETCHSERVICE_CONTRACTID));
|
||||
if (prefetchService) {
|
||||
// construct URI using document charset
|
||||
const nsACString &charset = mDocument->GetDocumentCharacterSet();
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
NS_NewURI(getter_AddRefs(uri), aHref,
|
||||
charset.IsEmpty() ? nsnull : PromiseFlatCString(charset).get(),
|
||||
mDocumentBaseURI);
|
||||
if (uri) {
|
||||
prefetchService->PrefetchURI(uri, mDocumentURI, aExplicit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PRBool
|
||||
nsContentSink::ScrollToRef(PRBool aReallyScroll)
|
||||
{
|
||||
if (mRef.IsEmpty()) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool didScroll = PR_FALSE;
|
||||
|
||||
char* tmpstr = ToNewCString(mRef);
|
||||
if (!tmpstr) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsUnescape(tmpstr);
|
||||
nsCAutoString unescapedRef;
|
||||
unescapedRef.Assign(tmpstr);
|
||||
nsMemory::Free(tmpstr);
|
||||
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
// We assume that the bytes are in UTF-8, as it says in the spec:
|
||||
// http://www.w3.org/TR/html4/appendix/notes.html#h-B.2.1
|
||||
NS_ConvertUTF8toUTF16 ref(unescapedRef);
|
||||
|
||||
PRInt32 i, ns = mDocument->GetNumberOfShells();
|
||||
for (i = 0; i < ns; i++) {
|
||||
nsIPresShell* shell = mDocument->GetShellAt(i);
|
||||
if (shell) {
|
||||
// Check an empty string which might be caused by the UTF-8 conversion
|
||||
if (!ref.IsEmpty()) {
|
||||
// Note that GoToAnchor will handle flushing layout as needed.
|
||||
rv = shell->GoToAnchor(ref, aReallyScroll);
|
||||
} else {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// If UTF-8 URI failed then try to assume the string as a
|
||||
// document's charset.
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
const nsACString &docCharset = mDocument->GetDocumentCharacterSet();
|
||||
|
||||
rv = nsContentUtils::ConvertStringFromCharset(docCharset, unescapedRef, ref);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && !ref.IsEmpty())
|
||||
rv = shell->GoToAnchor(ref, aReallyScroll);
|
||||
}
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
didScroll = PR_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return didScroll;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsContentSink::RefreshIfEnabled(nsIViewManager* vm)
|
||||
{
|
||||
if (!vm) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIContentViewer> contentViewer;
|
||||
mDocShell->GetContentViewer(getter_AddRefs(contentViewer));
|
||||
if (contentViewer) {
|
||||
PRBool enabled;
|
||||
contentViewer->GetEnableRendering(&enabled);
|
||||
if (enabled) {
|
||||
vm->EnableRefresh(NS_VMREFRESH_IMMEDIATE);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsContentSink::StartLayout(PRBool aIsFrameset)
|
||||
{
|
||||
PRUint32 i, ns = mDocument->GetNumberOfShells();
|
||||
for (i = 0; i < ns; i++) {
|
||||
nsIPresShell *shell = mDocument->GetShellAt(i);
|
||||
|
||||
if (shell) {
|
||||
// Make sure we don't call InitialReflow() for a shell that has
|
||||
// already called it. This can happen when the layout frame for
|
||||
// an iframe is constructed *between* the Embed() call for the
|
||||
// docshell in the iframe, and the content sink's call to OpenBody().
|
||||
// (Bug 153815)
|
||||
|
||||
PRBool didInitialReflow = PR_FALSE;
|
||||
shell->GetDidInitialReflow(&didInitialReflow);
|
||||
if (didInitialReflow) {
|
||||
// XXX: The assumption here is that if something already
|
||||
// called InitialReflow() on this shell, it also did some of
|
||||
// the setup below, so we do nothing and just move on to the
|
||||
// next shell in the list.
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// Make shell an observer for next time
|
||||
shell->BeginObservingDocument();
|
||||
|
||||
// Resize-reflow this time
|
||||
nsRect r = shell->GetPresContext()->GetVisibleArea();
|
||||
nsresult rv = shell->InitialReflow(r.width, r.height);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Now trigger a refresh
|
||||
RefreshIfEnabled(shell->GetViewManager());
|
||||
}
|
||||
}
|
||||
|
||||
// If the document we are loading has a reference or it is a
|
||||
// frameset document, disable the scroll bars on the views.
|
||||
|
||||
if (mDocumentURI) {
|
||||
nsCAutoString ref;
|
||||
|
||||
// Since all URI's that pass through here aren't URL's we can't
|
||||
// rely on the nsIURI implementation for providing a way for
|
||||
// finding the 'ref' part of the URI, we'll haveto revert to
|
||||
// string routines for finding the data past '#'
|
||||
|
||||
mDocumentURI->GetSpec(ref);
|
||||
|
||||
nsReadingIterator<char> start, end;
|
||||
|
||||
ref.BeginReading(start);
|
||||
ref.EndReading(end);
|
||||
|
||||
if (FindCharInReadable('#', start, end)) {
|
||||
++start; // Skip over the '#'
|
||||
|
||||
mRef = Substring(start, end);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,128 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Base class for the XML and HTML content sinks, which construct a
|
||||
* DOM based on information from the parser.
|
||||
*/
|
||||
|
||||
#ifndef _nsContentSink_h_
|
||||
#define _nsContentSink_h_
|
||||
|
||||
// Base class for contentsink implementations.
|
||||
|
||||
#include "nsICSSLoaderObserver.h"
|
||||
#include "nsIScriptLoaderObserver.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsString.h"
|
||||
#include "nsAutoPtr.h"
|
||||
|
||||
class nsIDocument;
|
||||
class nsIURI;
|
||||
class nsIChannel;
|
||||
class nsIDocShell;
|
||||
class nsICSSLoader;
|
||||
class nsIParser;
|
||||
class nsIAtom;
|
||||
class nsIChannel;
|
||||
class nsIContent;
|
||||
class nsIViewManager;
|
||||
class nsNodeInfoManager;
|
||||
|
||||
class nsContentSink : public nsICSSLoaderObserver,
|
||||
public nsIScriptLoaderObserver,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISCRIPTLOADEROBSERVER
|
||||
|
||||
// nsICSSLoaderObserver
|
||||
NS_IMETHOD StyleSheetLoaded(nsICSSStyleSheet* aSheet, PRBool aWasAlternate,
|
||||
nsresult aStatus);
|
||||
|
||||
nsresult ProcessMETATag(nsIContent* aContent);
|
||||
|
||||
protected:
|
||||
nsContentSink();
|
||||
virtual ~nsContentSink();
|
||||
|
||||
nsresult Init(nsIDocument* aDoc, nsIURI* aURI,
|
||||
nsISupports* aContainer, nsIChannel* aChannel);
|
||||
|
||||
nsresult ProcessHTTPHeaders(nsIChannel* aChannel);
|
||||
nsresult ProcessHeaderData(nsIAtom* aHeader, const nsAString& aValue,
|
||||
nsIContent* aContent = nsnull);
|
||||
nsresult ProcessLinkHeader(nsIContent* aElement,
|
||||
const nsAString& aLinkData);
|
||||
nsresult ProcessLink(nsIContent* aElement, const nsSubstring& aHref,
|
||||
const nsSubstring& aRel, const nsSubstring& aTitle,
|
||||
const nsSubstring& aType, const nsSubstring& aMedia);
|
||||
|
||||
virtual nsresult ProcessStyleLink(nsIContent* aElement,
|
||||
const nsSubstring& aHref,
|
||||
PRBool aAlternate,
|
||||
const nsSubstring& aTitle,
|
||||
const nsSubstring& aType,
|
||||
const nsSubstring& aMedia);
|
||||
|
||||
void PrefetchHref(const nsAString &aHref, PRBool aExplicit);
|
||||
|
||||
PRBool ScrollToRef(PRBool aReallyScroll);
|
||||
nsresult RefreshIfEnabled(nsIViewManager* vm);
|
||||
void StartLayout(PRBool aIsFrameset);
|
||||
|
||||
// Overridable hooks into script evaluation
|
||||
virtual void PreEvaluateScript() {return;}
|
||||
virtual void PostEvaluateScript(nsIScriptElement *aElement) {return;}
|
||||
|
||||
nsCOMPtr<nsIDocument> mDocument;
|
||||
nsCOMPtr<nsIParser> mParser;
|
||||
nsCOMPtr<nsIURI> mDocumentURI;
|
||||
nsCOMPtr<nsIURI> mDocumentBaseURI;
|
||||
nsCOMPtr<nsIDocShell> mDocShell;
|
||||
nsCOMPtr<nsICSSLoader> mCSSLoader;
|
||||
nsRefPtr<nsNodeInfoManager> mNodeInfoManager;
|
||||
|
||||
nsCOMArray<nsIScriptElement> mScriptElements;
|
||||
|
||||
nsCString mRef; // ScrollTo #ref
|
||||
PRBool mNeedToBlockParser;
|
||||
};
|
||||
|
||||
#endif // _nsContentSink_h_
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,544 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Kathleen Brade <brade@netscape.com>
|
||||
* David Gardiner <david.gardiner@unisa.edu.au>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsCopySupport.h"
|
||||
#include "nsIDocumentEncoder.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIClipboard.h"
|
||||
#include "nsISelection.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsXPCOM.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsIDOMRange.h"
|
||||
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIContentViewerEdit.h"
|
||||
#include "nsIClipboardDragDropHooks.h"
|
||||
#include "nsIClipboardDragDropHookList.h"
|
||||
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIHTMLDocument.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
|
||||
// image copy stuff
|
||||
#include "nsIImageLoadingContent.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIImage.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsContentCID.h"
|
||||
|
||||
static NS_DEFINE_CID(kCClipboardCID, NS_CLIPBOARD_CID);
|
||||
static NS_DEFINE_CID(kCTransferableCID, NS_TRANSFERABLE_CID);
|
||||
static NS_DEFINE_CID(kHTMLConverterCID, NS_HTMLFORMATCONVERTER_CID);
|
||||
|
||||
// private clipboard data flavors for html copy, used by editor when pasting
|
||||
#define kHTMLContext "text/_moz_htmlcontext"
|
||||
#define kHTMLInfo "text/_moz_htmlinfo"
|
||||
|
||||
// copy string data onto the transferable
|
||||
static nsresult AppendString(nsITransferable *aTransferable,
|
||||
const nsAString& aString,
|
||||
const char* aFlavor);
|
||||
|
||||
// copy HTML node data
|
||||
static nsresult AppendDOMNode(nsITransferable *aTransferable,
|
||||
nsIDOMNode *aDOMNode);
|
||||
|
||||
nsresult nsCopySupport::HTMLCopy(nsISelection *aSel, nsIDocument *aDoc, PRInt16 aClipboardID)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
PRBool bIsPlainTextContext = PR_FALSE;
|
||||
|
||||
rv = IsPlainTextContext(aSel, aDoc, &bIsPlainTextContext);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
PRBool bIsHTMLCopy = !bIsPlainTextContext;
|
||||
nsAutoString mimeType;
|
||||
|
||||
nsCOMPtr<nsIDocumentEncoder> docEncoder;
|
||||
|
||||
docEncoder = do_CreateInstance(NS_HTMLCOPY_ENCODER_CONTRACTID);
|
||||
NS_ENSURE_TRUE(docEncoder, NS_ERROR_FAILURE);
|
||||
|
||||
// We always require a plaintext version
|
||||
mimeType.AssignLiteral(kUnicodeMime);
|
||||
PRUint32 flags = nsIDocumentEncoder::OutputPreformatted;
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(aDoc);
|
||||
NS_ASSERTION(domDoc, "Need a document");
|
||||
|
||||
rv = docEncoder->Init(domDoc, mimeType, flags);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
rv = docEncoder->SetSelection(aSel);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsAutoString buffer, parents, info, textBuffer, plaintextBuffer;
|
||||
|
||||
rv = docEncoder->EncodeToString(textBuffer);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIFormatConverter> htmlConverter;
|
||||
|
||||
// sometimes we also need the HTML version
|
||||
if (bIsHTMLCopy) {
|
||||
|
||||
// this string may still contain HTML formatting, so we need to remove that too.
|
||||
htmlConverter = do_CreateInstance(kHTMLConverterCID);
|
||||
NS_ENSURE_TRUE(htmlConverter, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsISupportsString> plainHTML = do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID);
|
||||
NS_ENSURE_TRUE(plainHTML, NS_ERROR_FAILURE);
|
||||
plainHTML->SetData(textBuffer);
|
||||
|
||||
nsCOMPtr<nsISupportsString> ConvertedData;
|
||||
PRUint32 ConvertedLen;
|
||||
rv = htmlConverter->Convert(kHTMLMime, plainHTML, textBuffer.Length() * 2, kUnicodeMime, getter_AddRefs(ConvertedData), &ConvertedLen);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
ConvertedData->GetData(plaintextBuffer);
|
||||
|
||||
mimeType.AssignLiteral(kHTMLMime);
|
||||
|
||||
flags = 0;
|
||||
|
||||
rv = docEncoder->Init(domDoc, mimeType, flags);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = docEncoder->SetSelection(aSel);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// encode the selection as html with contextual info
|
||||
rv = docEncoder->EncodeToStringWithContext(parents, info, buffer);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
// Get the Clipboard
|
||||
nsCOMPtr<nsIClipboard> clipboard(do_GetService(kCClipboardCID, &rv));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
if ( clipboard )
|
||||
{
|
||||
// Create a transferable for putting data on the Clipboard
|
||||
nsCOMPtr<nsITransferable> trans = do_CreateInstance(kCTransferableCID);
|
||||
if ( trans )
|
||||
{
|
||||
if (bIsHTMLCopy)
|
||||
{
|
||||
// set up the data converter
|
||||
trans->SetConverter(htmlConverter);
|
||||
|
||||
if (!buffer.IsEmpty())
|
||||
{
|
||||
// Add the html DataFlavor to the transferable
|
||||
rv = AppendString(trans, buffer, kHTMLMime);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
{
|
||||
// Add the htmlcontext DataFlavor to the transferable
|
||||
// Even if parents is empty string, this flavor should
|
||||
// be attached to the transferable
|
||||
rv = AppendString(trans, parents, kHTMLContext);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
if (!info.IsEmpty())
|
||||
{
|
||||
// Add the htmlinfo DataFlavor to the transferable
|
||||
rv = AppendString(trans, info, kHTMLInfo);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
if (!plaintextBuffer.IsEmpty())
|
||||
{
|
||||
// unicode text
|
||||
// Add the unicode DataFlavor to the transferable
|
||||
// If we didn't have this, then nsDataObj::GetData matches text/unicode against
|
||||
// the kURLMime flavour which is not desirable (eg. when pasting into Notepad)
|
||||
rv = AppendString(trans, plaintextBuffer, kUnicodeMime);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
// Try and get source URI of the items that are being dragged
|
||||
nsIURI *uri = aDoc->GetDocumentURI();
|
||||
if (uri) {
|
||||
nsCAutoString spec;
|
||||
uri->GetSpec(spec);
|
||||
if (!spec.IsEmpty()) {
|
||||
nsAutoString shortcut;
|
||||
AppendUTF8toUTF16(spec, shortcut);
|
||||
|
||||
// Add the URL DataFlavor to the transferable. Don't use kURLMime, as it will
|
||||
// cause an unnecessary UniformResourceLocator to be added which confuses
|
||||
// some apps eg. Outlook 2000 - (See Bug 315370)
|
||||
rv = AppendString(trans, shortcut, kURLDataMime );
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!textBuffer.IsEmpty())
|
||||
{
|
||||
// Add the unicode DataFlavor to the transferable
|
||||
rv = AppendString(trans, textBuffer, kUnicodeMime);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
|
||||
PRBool doPutOnClipboard = PR_TRUE;
|
||||
DoHooks(aDoc, trans, &doPutOnClipboard);
|
||||
|
||||
// put the transferable on the clipboard
|
||||
if (doPutOnClipboard)
|
||||
clipboard->SetData(trans, nsnull, aClipboardID);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsCopySupport::DoHooks(nsIDocument *aDoc, nsITransferable *aTrans,
|
||||
PRBool *aDoPutOnClipboard)
|
||||
{
|
||||
NS_ENSURE_ARG(aDoc);
|
||||
|
||||
*aDoPutOnClipboard = PR_TRUE;
|
||||
|
||||
nsCOMPtr<nsISupports> container = aDoc->GetContainer();
|
||||
nsCOMPtr<nsIClipboardDragDropHookList> hookObj = do_GetInterface(container);
|
||||
if (!hookObj) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> enumerator;
|
||||
hookObj->GetHookEnumerator(getter_AddRefs(enumerator));
|
||||
if (!enumerator) return NS_ERROR_FAILURE;
|
||||
|
||||
// the logic here should follow the behavior specified in
|
||||
// nsIClipboardDragDropHooks.h
|
||||
|
||||
nsCOMPtr<nsIClipboardDragDropHooks> override;
|
||||
nsCOMPtr<nsISupports> isupp;
|
||||
PRBool hasMoreHooks = PR_FALSE;
|
||||
nsresult rv = NS_OK;
|
||||
while (NS_SUCCEEDED(enumerator->HasMoreElements(&hasMoreHooks))
|
||||
&& hasMoreHooks)
|
||||
{
|
||||
rv = enumerator->GetNext(getter_AddRefs(isupp));
|
||||
if (NS_FAILED(rv)) break;
|
||||
override = do_QueryInterface(isupp);
|
||||
if (override)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
nsresult hookResult =
|
||||
#endif
|
||||
override->OnCopyOrDrag(nsnull, aTrans, aDoPutOnClipboard);
|
||||
NS_ASSERTION(NS_SUCCEEDED(hookResult), "OnCopyOrDrag hook failed");
|
||||
if (!*aDoPutOnClipboard)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsCopySupport::IsPlainTextContext(nsISelection *aSel, nsIDocument *aDoc, PRBool *aIsPlainTextContext)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if (!aSel || !aIsPlainTextContext)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aIsPlainTextContext = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIDOMRange> range;
|
||||
nsCOMPtr<nsIDOMNode> commonParent;
|
||||
PRInt32 count = 0;
|
||||
|
||||
rv = aSel->GetRangeCount(&count);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// if selection is uninitialized return
|
||||
if (!count)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// we'll just use the common parent of the first range. Implicit assumption
|
||||
// here that multi-range selections are table cell selections, in which case
|
||||
// the common parent is somewhere in the table and we don't really care where.
|
||||
rv = aSel->GetRangeAt(0, getter_AddRefs(range));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (!range)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
range->GetCommonAncestorContainer(getter_AddRefs(commonParent));
|
||||
|
||||
for (nsCOMPtr<nsIContent> selContent(do_QueryInterface(commonParent));
|
||||
selContent;
|
||||
selContent = selContent->GetParent())
|
||||
{
|
||||
// checking for selection inside a plaintext form widget
|
||||
|
||||
if (!selContent->IsNodeOfType(nsINode::eHTML)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
nsIAtom *atom = selContent->Tag();
|
||||
|
||||
if (atom == nsHTMLAtoms::input ||
|
||||
atom == nsHTMLAtoms::textarea)
|
||||
{
|
||||
*aIsPlainTextContext = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (atom == nsHTMLAtoms::body)
|
||||
{
|
||||
// check for moz prewrap style on body. If it's there we are
|
||||
// in a plaintext editor. This is pretty cheezy but I haven't
|
||||
// found a good way to tell if we are in a plaintext editor.
|
||||
nsCOMPtr<nsIDOMElement> bodyElem = do_QueryInterface(selContent);
|
||||
nsAutoString wsVal;
|
||||
rv = bodyElem->GetAttribute(NS_LITERAL_STRING("style"), wsVal);
|
||||
if (NS_SUCCEEDED(rv) && (kNotFound != wsVal.Find(NS_LITERAL_STRING("-moz-pre-wrap"))))
|
||||
{
|
||||
*aIsPlainTextContext = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// also consider ourselves in a text widget if we can't find an html
|
||||
// document. Note that XHTML is not counted as HTML here, because we can't
|
||||
// copy it properly (all the copy code for non-plaintext assumes using HTML
|
||||
// serializers and parsers is OK, and those mess up XHTML).
|
||||
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(aDoc);
|
||||
if (!htmlDoc || aDoc->IsCaseSensitive())
|
||||
*aIsPlainTextContext = PR_TRUE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsCopySupport::GetContents(const nsACString& aMimeType, PRUint32 aFlags, nsISelection *aSel, nsIDocument *aDoc, nsAString& outdata)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDocumentEncoder> docEncoder;
|
||||
|
||||
nsCAutoString encoderContractID(NS_DOC_ENCODER_CONTRACTID_BASE);
|
||||
encoderContractID.Append(aMimeType);
|
||||
|
||||
docEncoder = do_CreateInstance(encoderContractID.get());
|
||||
NS_ENSURE_TRUE(docEncoder, NS_ERROR_FAILURE);
|
||||
|
||||
PRUint32 flags = aFlags;
|
||||
|
||||
if (aMimeType.Equals("text/plain"))
|
||||
flags |= nsIDocumentEncoder::OutputPreformatted;
|
||||
|
||||
NS_ConvertASCIItoUTF16 unicodeMimeType(aMimeType);
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(aDoc);
|
||||
NS_ASSERTION(domDoc, "Need a document");
|
||||
|
||||
rv = docEncoder->Init(domDoc, unicodeMimeType, flags);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (aSel)
|
||||
{
|
||||
rv = docEncoder->SetSelection(aSel);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
// encode the selection
|
||||
return docEncoder->EncodeToString(outdata);
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsCopySupport::ImageCopy(nsIImageLoadingContent* aImageElement,
|
||||
PRInt32 aCopyFlags)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// create a transferable for putting data on the Clipboard
|
||||
nsCOMPtr<nsITransferable> trans(do_CreateInstance(kCTransferableCID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (aCopyFlags & nsIContentViewerEdit::COPY_IMAGE_TEXT) {
|
||||
// get the location from the element
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
rv = aImageElement->GetCurrentURI(getter_AddRefs(uri));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(uri, NS_ERROR_FAILURE);
|
||||
|
||||
nsCAutoString location;
|
||||
rv = uri->GetSpec(location);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// append the string to the transferable
|
||||
rv = AppendString(trans, NS_ConvertUTF8toUTF16(location), kUnicodeMime);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
if (aCopyFlags & nsIContentViewerEdit::COPY_IMAGE_HTML) {
|
||||
// append HTML data to the transferable
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(aImageElement, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = AppendDOMNode(trans, node);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
if (aCopyFlags & nsIContentViewerEdit::COPY_IMAGE_DATA) {
|
||||
// get the image data from the element
|
||||
nsCOMPtr<nsIImage> image =
|
||||
nsContentUtils::GetImageFromContent(aImageElement);
|
||||
NS_ENSURE_TRUE(image, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsISupportsInterfacePointer>
|
||||
imgPtr(do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = imgPtr->SetData(image);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// copy the image data onto the transferable
|
||||
rv = trans->SetTransferData(kNativeImageMime, imgPtr,
|
||||
sizeof(nsISupports*));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
// get clipboard
|
||||
nsCOMPtr<nsIClipboard> clipboard(do_GetService(kCClipboardCID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// check whether the system supports the selection clipboard or not.
|
||||
PRBool selectionSupported;
|
||||
rv = clipboard->SupportsSelectionClipboard(&selectionSupported);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// put the transferable on the clipboard
|
||||
if (selectionSupported) {
|
||||
rv = clipboard->SetData(trans, nsnull, nsIClipboard::kSelectionClipboard);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
return clipboard->SetData(trans, nsnull, nsIClipboard::kGlobalClipboard);
|
||||
}
|
||||
|
||||
static nsresult AppendString(nsITransferable *aTransferable,
|
||||
const nsAString& aString,
|
||||
const char* aFlavor)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsISupportsString>
|
||||
data(do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = data->SetData(aString);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = aTransferable->AddDataFlavor(aFlavor);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return aTransferable->SetTransferData(aFlavor, data,
|
||||
aString.Length() * sizeof(PRUnichar));
|
||||
}
|
||||
|
||||
static nsresult AppendDOMNode(nsITransferable *aTransferable,
|
||||
nsIDOMNode *aDOMNode)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// selializer
|
||||
nsCOMPtr<nsIDocumentEncoder>
|
||||
docEncoder(do_CreateInstance(NS_HTMLCOPY_ENCODER_CONTRACTID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// get document for the encoder
|
||||
nsCOMPtr<nsIDOMDocument> domDocument;
|
||||
rv = aDOMNode->GetOwnerDocument(getter_AddRefs(domDocument));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIDocument> document(do_QueryInterface(domDocument, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Note that XHTML is not counted as HTML here, because we can't copy it
|
||||
// properly (all the copy code for non-plaintext assumes using HTML
|
||||
// serializers and parsers is OK, and those mess up XHTML).
|
||||
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(domDocument, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, NS_OK);
|
||||
|
||||
NS_ENSURE_TRUE(!(document->IsCaseSensitive()), NS_OK);
|
||||
|
||||
// init encoder with document and node
|
||||
rv = docEncoder->Init(domDocument, NS_LITERAL_STRING(kHTMLMime),
|
||||
nsIDocumentEncoder::OutputAbsoluteLinks |
|
||||
nsIDocumentEncoder::OutputEncodeW3CEntities);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = docEncoder->SetNode(aDOMNode);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// serialize to string
|
||||
nsAutoString html, context, info;
|
||||
rv = docEncoder->EncodeToStringWithContext(context, info, html);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// copy them to the transferable
|
||||
if (!html.IsEmpty()) {
|
||||
rv = AppendString(aTransferable, html, kHTMLMime);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
if (!info.IsEmpty()) {
|
||||
rv = AppendString(aTransferable, info, kHTMLInfo);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
// add a special flavor, even if we don't have html context data
|
||||
return AppendString(aTransferable, context, kHTMLContext);
|
||||
}
|
||||
@@ -1,819 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Implementation of DOM Core's nsIDOMAttr node.
|
||||
*/
|
||||
|
||||
#include "nsDOMAttribute.h"
|
||||
#include "nsGenericElement.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsITextContent.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsDOMError.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsDOMString.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOM3Attr.h"
|
||||
#include "nsIDOMUserDataHandler.h"
|
||||
#include "nsITextContent.h"
|
||||
#include "nsEventDispatcher.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsCOMArray.h"
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
PRBool nsDOMAttribute::sInitialized;
|
||||
|
||||
nsDOMAttribute::nsDOMAttribute(nsDOMAttributeMap *aAttrMap,
|
||||
nsINodeInfo *aNodeInfo,
|
||||
const nsAString &aValue)
|
||||
: nsIAttribute(aAttrMap, aNodeInfo), mValue(aValue), mChildList(nsnull)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(mNodeInfo, "We must get a nodeinfo here!");
|
||||
|
||||
|
||||
// We don't add a reference to our content. It will tell us
|
||||
// to drop our reference when it goes away.
|
||||
}
|
||||
|
||||
nsDOMAttribute::~nsDOMAttribute()
|
||||
{
|
||||
if (mChildList) {
|
||||
mChildList->DropReference();
|
||||
NS_RELEASE(mChildList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// QueryInterface implementation for nsDOMAttribute
|
||||
NS_INTERFACE_MAP_BEGIN(nsDOMAttribute)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMAttr)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIAttribute)
|
||||
NS_INTERFACE_MAP_ENTRY(nsINode)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMGCParticipant)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOM3Node)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOM3Attr)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMAttr)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(Attr)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(nsDOMAttribute)
|
||||
NS_IMPL_RELEASE(nsDOMAttribute)
|
||||
|
||||
// nsIDOMGCParticipant methods
|
||||
nsIDOMGCParticipant*
|
||||
nsDOMAttribute::GetSCCIndex()
|
||||
{
|
||||
nsIContent *owner = GetContentInternal();
|
||||
|
||||
return owner ? owner->GetSCCIndex() : this;
|
||||
}
|
||||
|
||||
void
|
||||
nsDOMAttribute::AppendReachableList(nsCOMArray<nsIDOMGCParticipant>& aArray)
|
||||
{
|
||||
NS_ASSERTION(GetContentInternal() == nsnull,
|
||||
"shouldn't be an SCC index if we're in an element");
|
||||
|
||||
// This node is the root of a subtree that's been removed from the
|
||||
// document (since AppendReachableList is only called on SCC index
|
||||
// nodes). The document is reachable from it (through
|
||||
// .ownerDocument), but it's not reachable from the document.
|
||||
aArray.AppendObject(GetOwnerDoc());
|
||||
}
|
||||
|
||||
void
|
||||
nsDOMAttribute::SetMap(nsDOMAttributeMap *aMap)
|
||||
{
|
||||
if (mAttrMap && !aMap && sInitialized) {
|
||||
// We're breaking a relationship with content and not getting a new one,
|
||||
// need to locally cache value. GetValue() does that.
|
||||
GetValue(mValue);
|
||||
}
|
||||
|
||||
mAttrMap = aMap;
|
||||
}
|
||||
|
||||
nsIContent*
|
||||
nsDOMAttribute::GetContent() const
|
||||
{
|
||||
return GetContentInternal();
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttribute::SetOwnerDocument(nsIDocument* aDocument)
|
||||
{
|
||||
NS_ASSERTION(aDocument, "Missing document");
|
||||
|
||||
nsIDocument *doc = GetOwnerDoc();
|
||||
NS_ASSERTION(doc != aDocument, "bad call to nsDOMAttribute::SetOwnerDocument");
|
||||
if (doc) {
|
||||
doc->PropertyTable()->DeleteAllPropertiesFor(this);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsINodeInfo> newNodeInfo;
|
||||
nsresult rv = aDocument->NodeInfoManager()->
|
||||
GetNodeInfo(mNodeInfo->NameAtom(), mNodeInfo->GetPrefixAtom(),
|
||||
mNodeInfo->NamespaceID(), getter_AddRefs(newNodeInfo));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ASSERTION(newNodeInfo, "GetNodeInfo lies");
|
||||
mNodeInfo.swap(newNodeInfo);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetName(nsAString& aName)
|
||||
{
|
||||
mNodeInfo->GetQualifiedName(aName);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetValue(nsAString& aValue)
|
||||
{
|
||||
nsIContent* content = GetContentInternal();
|
||||
if (content) {
|
||||
content->GetAttr(mNodeInfo->NamespaceID(), mNodeInfo->NameAtom(), aValue);
|
||||
}
|
||||
else {
|
||||
aValue = mValue;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::SetValue(const nsAString& aValue)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsIContent* content = GetContentInternal();
|
||||
if (content) {
|
||||
rv = content->SetAttr(mNodeInfo->NamespaceID(),
|
||||
mNodeInfo->NameAtom(),
|
||||
mNodeInfo->GetPrefixAtom(),
|
||||
aValue,
|
||||
PR_TRUE);
|
||||
}
|
||||
else {
|
||||
mValue = aValue;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetSpecified(PRBool* aSpecified)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aSpecified);
|
||||
|
||||
nsIContent* content = GetContentInternal();
|
||||
*aSpecified = content && content->HasAttr(mNodeInfo->NamespaceID(),
|
||||
mNodeInfo->NameAtom());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetOwnerElement(nsIDOMElement** aOwnerElement)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aOwnerElement);
|
||||
|
||||
nsIContent* content = GetContentInternal();
|
||||
if (content) {
|
||||
return CallQueryInterface(content, aOwnerElement);
|
||||
}
|
||||
|
||||
*aOwnerElement = nsnull;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetNodeName(nsAString& aNodeName)
|
||||
{
|
||||
return GetName(aNodeName);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetNodeValue(nsAString& aNodeValue)
|
||||
{
|
||||
return GetValue(aNodeValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::SetNodeValue(const nsAString& aNodeValue)
|
||||
{
|
||||
return SetValue(aNodeValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetNodeType(PRUint16* aNodeType)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aNodeType);
|
||||
|
||||
*aNodeType = (PRUint16)nsIDOMNode::ATTRIBUTE_NODE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetParentNode(nsIDOMNode** aParentNode)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aParentNode);
|
||||
|
||||
*aParentNode = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetChildNodes(nsIDOMNodeList** aChildNodes)
|
||||
{
|
||||
if (!mChildList) {
|
||||
mChildList = new nsAttributeChildList(this);
|
||||
NS_ENSURE_TRUE(mChildList, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
NS_ADDREF(mChildList);
|
||||
}
|
||||
|
||||
return CallQueryInterface(mChildList, aChildNodes);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::HasChildNodes(PRBool* aHasChildNodes)
|
||||
{
|
||||
PRBool hasChild;
|
||||
nsresult rv = EnsureChildState(PR_FALSE, hasChild);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*aHasChildNodes = hasChild;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::HasAttributes(PRBool* aHasAttributes)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aHasAttributes);
|
||||
|
||||
*aHasAttributes = PR_FALSE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetFirstChild(nsIDOMNode** aFirstChild)
|
||||
{
|
||||
*aFirstChild = nsnull;
|
||||
|
||||
PRBool hasChild;
|
||||
nsresult rv = EnsureChildState(PR_TRUE, hasChild);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (mChild) {
|
||||
CallQueryInterface(mChild, aFirstChild);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetLastChild(nsIDOMNode** aLastChild)
|
||||
{
|
||||
return GetFirstChild(aLastChild);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetPreviousSibling(nsIDOMNode** aPreviousSibling)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aPreviousSibling);
|
||||
|
||||
*aPreviousSibling = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetNextSibling(nsIDOMNode** aNextSibling)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aNextSibling);
|
||||
|
||||
*aNextSibling = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetAttributes(nsIDOMNamedNodeMap** aAttributes)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aAttributes);
|
||||
|
||||
*aAttributes = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
*aReturn = nsnull;
|
||||
|
||||
nsAutoString value;
|
||||
GetValue(value);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> newAttr = new nsDOMAttribute(nsnull, mNodeInfo, value);
|
||||
if (!newAttr) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsIDocument *document = GetOwnerDoc();
|
||||
if (document) {
|
||||
// XXX For now, nsDOMAttribute has only one child. We need to notify about
|
||||
// cloning it, so we force creation here.
|
||||
nsCOMPtr<nsIDOMNode> child;
|
||||
GetFirstChild(getter_AddRefs(child));
|
||||
nsCOMPtr<nsINode> childNode = do_QueryInterface(child);
|
||||
if (childNode && childNode->HasProperties()) {
|
||||
nsCOMPtr<nsIDOMNode> newChild;
|
||||
newAttr->GetFirstChild(getter_AddRefs(newChild));
|
||||
if (newChild) {
|
||||
nsContentUtils::CallUserDataHandler(document,
|
||||
nsIDOMUserDataHandler::NODE_CLONED,
|
||||
childNode, child, newChild);
|
||||
}
|
||||
}
|
||||
|
||||
if (HasProperties()) {
|
||||
nsContentUtils::CallUserDataHandler(document,
|
||||
nsIDOMUserDataHandler::NODE_CLONED,
|
||||
this, this, newAttr);
|
||||
}
|
||||
}
|
||||
|
||||
newAttr.swap(*aReturn);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetOwnerDocument(nsIDOMDocument** aOwnerDocument)
|
||||
{
|
||||
*aOwnerDocument = nsnull;
|
||||
|
||||
nsIDocument *document = GetOwnerDoc();
|
||||
|
||||
return document ? CallQueryInterface(document, aOwnerDocument) : NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetNamespaceURI(nsAString& aNamespaceURI)
|
||||
{
|
||||
return mNodeInfo->GetNamespaceURI(aNamespaceURI);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetPrefix(nsAString& aPrefix)
|
||||
{
|
||||
mNodeInfo->GetPrefix(aPrefix);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::SetPrefix(const nsAString& aPrefix)
|
||||
{
|
||||
// XXX: Validate the prefix string!
|
||||
|
||||
nsCOMPtr<nsINodeInfo> newNodeInfo;
|
||||
nsCOMPtr<nsIAtom> prefix;
|
||||
|
||||
if (!aPrefix.IsEmpty()) {
|
||||
prefix = do_GetAtom(aPrefix);
|
||||
if (!prefix) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
if (!nsContentUtils::IsValidNodeName(mNodeInfo->NameAtom(), prefix,
|
||||
mNodeInfo->NamespaceID())) {
|
||||
return NS_ERROR_DOM_NAMESPACE_ERR;
|
||||
}
|
||||
|
||||
nsresult rv = nsContentUtils::PrefixChanged(mNodeInfo, prefix,
|
||||
getter_AddRefs(newNodeInfo));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsIContent* content = GetContentInternal();
|
||||
if (content) {
|
||||
nsIAtom *name = mNodeInfo->NameAtom();
|
||||
PRInt32 nameSpaceID = mNodeInfo->NamespaceID();
|
||||
|
||||
nsAutoString tmpValue;
|
||||
if (content->GetAttr(nameSpaceID, name, tmpValue)) {
|
||||
content->UnsetAttr(nameSpaceID, name, PR_TRUE);
|
||||
|
||||
content->SetAttr(newNodeInfo->NamespaceID(), newNodeInfo->NameAtom(),
|
||||
newNodeInfo->GetPrefixAtom(), tmpValue, PR_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
newNodeInfo.swap(mNodeInfo);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetLocalName(nsAString& aLocalName)
|
||||
{
|
||||
mNodeInfo->GetLocalName(aLocalName);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::Normalize()
|
||||
{
|
||||
// Nothing to do here
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::IsSupported(const nsAString& aFeature,
|
||||
const nsAString& aVersion,
|
||||
PRBool* aReturn)
|
||||
{
|
||||
return nsGenericElement::InternalIsSupported(NS_STATIC_CAST(nsIDOMAttr*, this),
|
||||
aFeature, aVersion, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetBaseURI(nsAString &aURI)
|
||||
{
|
||||
aURI.Truncate();
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIDOM3Node> node(do_QueryInterface(GetContentInternal()));
|
||||
if (node)
|
||||
rv = node->GetBaseURI(aURI);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::CompareDocumentPosition(nsIDOMNode* aOther,
|
||||
PRUint16* aReturn)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aOther);
|
||||
|
||||
nsCOMPtr<nsINode> other = do_QueryInterface(aOther);
|
||||
NS_ENSURE_TRUE(other, NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
|
||||
*aReturn = nsContentUtils::ComparePosition(other, this);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::IsSameNode(nsIDOMNode* aOther,
|
||||
PRBool* aReturn)
|
||||
{
|
||||
NS_ASSERTION(aReturn, "IsSameNode() called with aReturn == nsnull!");
|
||||
|
||||
*aReturn = SameCOMIdentity(NS_STATIC_CAST(nsIDOMNode*, this), aOther);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::IsEqualNode(nsIDOMNode* aOther,
|
||||
PRBool* aReturn)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("nsDocument::IsEqualNode()");
|
||||
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::IsDefaultNamespace(const nsAString& aNamespaceURI,
|
||||
PRBool* aReturn)
|
||||
{
|
||||
*aReturn = PR_FALSE;
|
||||
nsCOMPtr<nsIDOM3Node> node(do_QueryInterface(GetContentInternal()));
|
||||
if (node) {
|
||||
return node->IsDefaultNamespace(aNamespaceURI, aReturn);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetTextContent(nsAString &aTextContent)
|
||||
{
|
||||
return GetNodeValue(aTextContent);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::SetTextContent(const nsAString& aTextContent)
|
||||
{
|
||||
return SetNodeValue(aTextContent);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetFeature(const nsAString& aFeature,
|
||||
const nsAString& aVersion,
|
||||
nsISupports** aReturn)
|
||||
{
|
||||
return nsGenericElement::InternalGetFeature(NS_STATIC_CAST(nsIDOMAttr*, this),
|
||||
aFeature, aVersion, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::SetUserData(const nsAString& aKey, nsIVariant* aData,
|
||||
nsIDOMUserDataHandler* aHandler,
|
||||
nsIVariant** aResult)
|
||||
{
|
||||
nsCOMPtr<nsIAtom> key = do_GetAtom(aKey);
|
||||
if (!key) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return nsContentUtils::SetUserData(this, key, aData, aHandler, aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetUserData(const nsAString& aKey, nsIVariant** aResult)
|
||||
{
|
||||
nsIDocument *document = GetOwnerDoc();
|
||||
NS_ENSURE_TRUE(document, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIAtom> key = do_GetAtom(aKey);
|
||||
if (!key) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
*aResult = NS_STATIC_CAST(nsIVariant*, GetProperty(DOM_USER_DATA, key));
|
||||
NS_IF_ADDREF(*aResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetIsId(PRBool* aReturn)
|
||||
{
|
||||
nsIContent* content = GetContentInternal();
|
||||
if (!content)
|
||||
{
|
||||
*aReturn = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIAtom* idAtom = content->GetIDAttributeName();
|
||||
if (!idAtom)
|
||||
{
|
||||
*aReturn = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
*aReturn = mNodeInfo->Equals(idAtom, kNameSpaceID_None);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetSchemaTypeInfo(nsIDOM3TypeInfo** aReturn)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::LookupPrefix(const nsAString& aNamespaceURI,
|
||||
nsAString& aPrefix)
|
||||
{
|
||||
nsCOMPtr<nsIDOM3Node> node(do_QueryInterface(GetContentInternal()));
|
||||
if (node)
|
||||
return node->LookupPrefix(aNamespaceURI, aPrefix);
|
||||
|
||||
SetDOMStringToNull(aPrefix);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::LookupNamespaceURI(const nsAString& aNamespacePrefix,
|
||||
nsAString& aNamespaceURI)
|
||||
{
|
||||
nsCOMPtr<nsIDOM3Node> node(do_QueryInterface(GetContentInternal()));
|
||||
if (node)
|
||||
return node->LookupNamespaceURI(aNamespacePrefix, aNamespaceURI);
|
||||
|
||||
SetDOMStringToNull(aNamespaceURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsDOMAttribute::IsNodeOfType(PRUint32 aFlags) const
|
||||
{
|
||||
return !(aFlags & ~eATTRIBUTE);
|
||||
}
|
||||
|
||||
PRUint32
|
||||
nsDOMAttribute::GetChildCount() const
|
||||
{
|
||||
PRBool hasChild;
|
||||
EnsureChildState(PR_FALSE, hasChild);
|
||||
|
||||
return hasChild ? 1 : 0;
|
||||
}
|
||||
|
||||
nsIContent *
|
||||
nsDOMAttribute::GetChildAt(PRUint32 aIndex) const
|
||||
{
|
||||
// Don't need to check result of EnsureChildState since mChild will be null.
|
||||
PRBool hasChild;
|
||||
EnsureChildState(PR_TRUE, hasChild);
|
||||
|
||||
return aIndex == 0 && hasChild ? mChild.get() : nsnull;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsDOMAttribute::IndexOf(nsINode* aPossibleChild) const
|
||||
{
|
||||
// No need to call EnsureChildState here. If we don't already have a child
|
||||
// then aPossibleChild can't possibly be our child.
|
||||
if (!aPossibleChild || aPossibleChild != mChild) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
PRBool hasChild;
|
||||
EnsureChildState(PR_FALSE, hasChild);
|
||||
return hasChild ? 0 : -1;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttribute::InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
|
||||
PRBool aNotify)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttribute::AppendChildTo(nsIContent* aKid, PRBool aNotify)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttribute::RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttribute::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
|
||||
{
|
||||
// We don't support event dispatching to attributes yet.
|
||||
aVisitor.mCanHandle = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttribute::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttribute::DispatchDOMEvent(nsEvent* aEvent, nsIDOMEvent* aDOMEvent,
|
||||
nsPresContext* aPresContext,
|
||||
nsEventStatus* aEventStatus)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttribute::EnsureChildState(PRBool aSetText, PRBool &aHasChild) const
|
||||
{
|
||||
aHasChild = PR_FALSE;
|
||||
|
||||
nsDOMAttribute* mutableThis = NS_CONST_CAST(nsDOMAttribute*, this);
|
||||
|
||||
nsAutoString value;
|
||||
mutableThis->GetValue(value);
|
||||
|
||||
if (!mChild && !value.IsEmpty()) {
|
||||
nsresult rv = NS_NewTextNode(getter_AddRefs(mutableThis->mChild),
|
||||
mNodeInfo->NodeInfoManager());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// XXX We should be setting |this| as the parent of the textnode!
|
||||
}
|
||||
|
||||
aHasChild = !value.IsEmpty();
|
||||
|
||||
if (aSetText && aHasChild) {
|
||||
mChild->SetText(value, PR_TRUE);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsDOMAttribute::Initialize()
|
||||
{
|
||||
sInitialized = PR_TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
nsDOMAttribute::Shutdown()
|
||||
{
|
||||
sInitialized = PR_FALSE;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
nsAttributeChildList::nsAttributeChildList(nsDOMAttribute* aAttribute)
|
||||
{
|
||||
// Don't increment the reference count. The attribute will tell
|
||||
// us when it's going away
|
||||
mAttribute = aAttribute;
|
||||
}
|
||||
|
||||
nsAttributeChildList::~nsAttributeChildList()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAttributeChildList::GetLength(PRUint32* aLength)
|
||||
{
|
||||
*aLength = mAttribute ? mAttribute->GetChildCount() : 0;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAttributeChildList::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
|
||||
{
|
||||
*aReturn = nsnull;
|
||||
if (mAttribute && 0 == aIndex) {
|
||||
mAttribute->GetFirstChild(aReturn);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsAttributeChildList::DropReference()
|
||||
{
|
||||
mAttribute = nsnull;
|
||||
}
|
||||
@@ -1,147 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Implementation of DOM Core's nsIDOMAttr node.
|
||||
*/
|
||||
|
||||
#ifndef nsDOMAttribute_h___
|
||||
#define nsDOMAttribute_h___
|
||||
|
||||
#include "nsIAttribute.h"
|
||||
#include "nsIDOMAttr.h"
|
||||
#include "nsIDOMText.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsGenericDOMNodeList.h"
|
||||
#include "nsString.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsINodeInfo.h"
|
||||
#include "nsIDOM3Node.h"
|
||||
#include "nsIDOM3Attr.h"
|
||||
#include "nsDOMAttributeMap.h"
|
||||
|
||||
class nsDOMAttribute;
|
||||
class nsITextContent;
|
||||
|
||||
// bogus child list for an attribute
|
||||
class nsAttributeChildList : public nsGenericDOMNodeList
|
||||
{
|
||||
public:
|
||||
nsAttributeChildList(nsDOMAttribute* aAttribute);
|
||||
virtual ~nsAttributeChildList();
|
||||
|
||||
// interface nsIDOMNodeList
|
||||
NS_IMETHOD GetLength(PRUint32* aLength);
|
||||
NS_IMETHOD Item(PRUint32 aIndex, nsIDOMNode** aReturn);
|
||||
|
||||
void DropReference();
|
||||
|
||||
protected:
|
||||
nsDOMAttribute* mAttribute;
|
||||
};
|
||||
|
||||
// Attribute helper class used to wrap up an attribute with a dom
|
||||
// object that implements nsIDOMAttr, nsIDOM3Attr, nsIDOMNode, nsIDOM3Node
|
||||
class nsDOMAttribute : public nsIDOMAttr,
|
||||
public nsIDOM3Attr,
|
||||
public nsIAttribute
|
||||
{
|
||||
public:
|
||||
nsDOMAttribute(nsDOMAttributeMap* aAttrMap, nsINodeInfo *aNodeInfo,
|
||||
const nsAString& aValue);
|
||||
virtual ~nsDOMAttribute();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMGCParticipant interface methods
|
||||
virtual nsIDOMGCParticipant* GetSCCIndex();
|
||||
virtual void AppendReachableList(nsCOMArray<nsIDOMGCParticipant>& aArray);
|
||||
|
||||
// nsIDOMNode interface
|
||||
NS_DECL_NSIDOMNODE
|
||||
|
||||
// nsIDOM3Node interface
|
||||
NS_DECL_NSIDOM3NODE
|
||||
|
||||
// nsIDOMAttr interface
|
||||
NS_DECL_NSIDOMATTR
|
||||
|
||||
// nsIDOM3Attr interface
|
||||
NS_DECL_NSIDOM3ATTR
|
||||
|
||||
// nsIAttribute interface
|
||||
void SetMap(nsDOMAttributeMap *aMap);
|
||||
nsIContent *GetContent() const;
|
||||
nsresult SetOwnerDocument(nsIDocument* aDocument);
|
||||
|
||||
// nsINode interface
|
||||
virtual PRBool IsNodeOfType(PRUint32 aFlags) const;
|
||||
virtual PRUint32 GetChildCount() const;
|
||||
virtual nsIContent *GetChildAt(PRUint32 aIndex) const;
|
||||
virtual PRInt32 IndexOf(nsINode* aPossibleChild) const;
|
||||
virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
|
||||
PRBool aNotify);
|
||||
virtual nsresult AppendChildTo(nsIContent* aKid, PRBool aNotify);
|
||||
virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
|
||||
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
|
||||
virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor);
|
||||
virtual nsresult DispatchDOMEvent(nsEvent* aEvent, nsIDOMEvent* aDOMEvent,
|
||||
nsPresContext* aPresContext,
|
||||
nsEventStatus* aEventStatus);
|
||||
static void Initialize();
|
||||
static void Shutdown();
|
||||
|
||||
protected:
|
||||
static PRBool sInitialized;
|
||||
|
||||
private:
|
||||
nsresult EnsureChildState(PRBool aSetText, PRBool &aHasChild) const;
|
||||
|
||||
nsString mValue;
|
||||
// XXX For now, there's only a single child - a text
|
||||
// element representing the value
|
||||
nsCOMPtr<nsITextContent> mChild;
|
||||
nsAttributeChildList* mChildList;
|
||||
|
||||
nsIContent *GetContentInternal() const
|
||||
{
|
||||
return mAttrMap ? mAttrMap->GetContent() : nsnull;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif /* nsDOMAttribute_h___ */
|
||||
@@ -1,464 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Allan Beaufour <allan@beaufour.dk>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Implementation of the |attributes| property of DOM Core's nsIDOMNode object.
|
||||
*/
|
||||
|
||||
#include "nsDOMAttributeMap.h"
|
||||
#include "nsDOMAttribute.h"
|
||||
#include "nsGenericElement.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsDOMError.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsNodeInfoManager.h"
|
||||
#include "nsAttrName.h"
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
nsDOMAttributeMap::nsDOMAttributeMap(nsIContent* aContent)
|
||||
: mContent(aContent)
|
||||
{
|
||||
// We don't add a reference to our content. If it goes away,
|
||||
// we'll be told to drop our reference
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsDOMAttributeMap::Init()
|
||||
{
|
||||
return mAttributeCache.Init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear map pointer for attributes.
|
||||
*/
|
||||
PLDHashOperator
|
||||
RemoveMapRef(nsAttrHashKey::KeyType aKey, nsCOMPtr<nsIDOMNode>& aData, void* aUserArg)
|
||||
{
|
||||
nsCOMPtr<nsIAttribute> attr(do_QueryInterface(aData));
|
||||
NS_ASSERTION(attr, "non-nsIAttribute somehow made it into the hashmap?!");
|
||||
attr->SetMap(nsnull);
|
||||
|
||||
return PL_DHASH_REMOVE;
|
||||
}
|
||||
|
||||
nsDOMAttributeMap::~nsDOMAttributeMap()
|
||||
{
|
||||
mAttributeCache.Enumerate(RemoveMapRef, nsnull);
|
||||
}
|
||||
|
||||
void
|
||||
nsDOMAttributeMap::DropReference()
|
||||
{
|
||||
mAttributeCache.Enumerate(RemoveMapRef, nsnull);
|
||||
mContent = nsnull;
|
||||
}
|
||||
|
||||
|
||||
// QueryInterface implementation for nsDOMAttributeMap
|
||||
NS_INTERFACE_MAP_BEGIN(nsDOMAttributeMap)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMNamedNodeMap)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(NamedNodeMap)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_ADDREF(nsDOMAttributeMap)
|
||||
NS_IMPL_RELEASE(nsDOMAttributeMap)
|
||||
|
||||
PLDHashOperator
|
||||
SetOwnerDocumentFunc(nsAttrHashKey::KeyType aKey, nsCOMPtr<nsIDOMNode>& aData,
|
||||
void* aUserArg)
|
||||
{
|
||||
nsCOMPtr<nsIAttribute> attr(do_QueryInterface(aData));
|
||||
NS_ASSERTION(attr, "non-nsIAttribute somehow made it into the hashmap?!");
|
||||
nsresult rv = attr->SetOwnerDocument(NS_STATIC_CAST(nsIDocument*, aUserArg));
|
||||
|
||||
return NS_FAILED(rv) ? PL_DHASH_STOP : PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttributeMap::SetOwnerDocument(nsIDocument* aDocument)
|
||||
{
|
||||
PRUint32 n = mAttributeCache.Enumerate(SetOwnerDocumentFunc, aDocument);
|
||||
NS_ENSURE_TRUE(n == mAttributeCache.Count(), NS_ERROR_FAILURE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsDOMAttributeMap::DropAttribute(PRInt32 aNamespaceID, nsIAtom* aLocalName)
|
||||
{
|
||||
nsAttrKey attr(aNamespaceID, aLocalName);
|
||||
nsIDOMNode *node = mAttributeCache.GetWeak(attr);
|
||||
if (node) {
|
||||
nsCOMPtr<nsIAttribute> iAttr(do_QueryInterface(node));
|
||||
NS_ASSERTION(iAttr, "non-nsIAttribute somehow made it into the hashmap?!");
|
||||
|
||||
// Break link to map
|
||||
iAttr->SetMap(nsnull);
|
||||
|
||||
// Remove from cache
|
||||
mAttributeCache.Remove(attr);
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttributeMap::GetAttribute(nsINodeInfo* aNodeInfo,
|
||||
nsIDOMNode** aReturn,
|
||||
PRBool aRemove)
|
||||
{
|
||||
NS_ASSERTION(aNodeInfo, "GetAttribute() called with aNodeInfo == nsnull!");
|
||||
NS_ASSERTION(aReturn, "GetAttribute() called with aReturn == nsnull");
|
||||
|
||||
*aReturn = nsnull;
|
||||
|
||||
nsAttrKey attr(aNodeInfo->NamespaceID(), aNodeInfo->NameAtom());
|
||||
|
||||
if (!mAttributeCache.Get(attr, aReturn)) {
|
||||
nsAutoString value;
|
||||
if (aRemove) {
|
||||
// As we are removing the attribute we need to set the current value in
|
||||
// the attribute node.
|
||||
mContent->GetAttr(aNodeInfo->NamespaceID(), aNodeInfo->NameAtom(), value);
|
||||
}
|
||||
nsCOMPtr<nsIDOMNode> newAttr = new nsDOMAttribute(aRemove ? nsnull : this,
|
||||
aNodeInfo, value);
|
||||
if (!newAttr) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
if (!aRemove && !mAttributeCache.Put(attr, newAttr)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
newAttr.swap(*aReturn);
|
||||
}
|
||||
else if (aRemove) {
|
||||
nsCOMPtr<nsIAttribute> iAttr(do_QueryInterface(*aReturn));
|
||||
NS_ASSERTION(iAttr, "non-nsIAttribute somehow made it into the hashmap?!");
|
||||
|
||||
// Break link to map
|
||||
iAttr->SetMap(nsnull);
|
||||
|
||||
// Remove from cache
|
||||
mAttributeCache.Remove(attr);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttributeMap::GetNamedItem(const nsAString& aAttrName,
|
||||
nsIDOMNode** aAttribute)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aAttribute);
|
||||
*aAttribute = nsnull;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
if (mContent) {
|
||||
nsCOMPtr<nsINodeInfo> ni =
|
||||
mContent->GetExistingAttrNameFromQName(aAttrName);
|
||||
if (ni) {
|
||||
rv = GetAttribute(ni, aAttribute);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttributeMap::SetNamedItem(nsIDOMNode *aNode, nsIDOMNode **aReturn)
|
||||
{
|
||||
return SetNamedItemInternal(aNode, aReturn, PR_FALSE);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttributeMap::SetNamedItemNS(nsIDOMNode *aNode, nsIDOMNode **aReturn)
|
||||
{
|
||||
return SetNamedItemInternal(aNode, aReturn, PR_TRUE);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttributeMap::SetNamedItemInternal(nsIDOMNode *aNode,
|
||||
nsIDOMNode **aReturn,
|
||||
PRBool aWithNS)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aNode);
|
||||
NS_ENSURE_ARG_POINTER(aReturn);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
*aReturn = nsnull;
|
||||
nsCOMPtr<nsIDOMNode> tmpReturn;
|
||||
|
||||
if (mContent) {
|
||||
// XXX should check same-origin between mContent and aNode however
|
||||
// nsContentUtils::CheckSameOrigin can't deal with attributenodes yet
|
||||
|
||||
nsCOMPtr<nsIDOMAttr> attribute(do_QueryInterface(aNode));
|
||||
nsCOMPtr<nsIAttribute> iAttribute(do_QueryInterface(aNode));
|
||||
if (!attribute || !iAttribute) {
|
||||
return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR;
|
||||
}
|
||||
|
||||
// Check that attribute is not owned by somebody else
|
||||
nsDOMAttributeMap* owner = iAttribute->GetMap();
|
||||
if (owner) {
|
||||
if (owner != this) {
|
||||
return NS_ERROR_DOM_INUSE_ATTRIBUTE_ERR;
|
||||
}
|
||||
|
||||
// setting a preexisting attribute is a no-op, just return the same
|
||||
// node.
|
||||
NS_ADDREF(*aReturn = aNode);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// update nodeinfo if needed
|
||||
nsIDocument* myDoc = mContent->GetOwnerDoc();
|
||||
if (myDoc && myDoc != iAttribute->GetOwnerDoc()) {
|
||||
rv = iAttribute->SetOwnerDocument(myDoc);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
// Get nodeinfo and preexisting attribute (if it exists)
|
||||
nsAutoString name;
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
|
||||
// SetNamedItemNS()
|
||||
if (aWithNS) {
|
||||
// Return existing attribute, if present
|
||||
ni = iAttribute->NodeInfo();
|
||||
|
||||
if (mContent->HasAttr(ni->NamespaceID(), ni->NameAtom())) {
|
||||
rv = GetAttribute(ni, getter_AddRefs(tmpReturn), PR_TRUE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
else { // SetNamedItem()
|
||||
attribute->GetName(name);
|
||||
|
||||
// get node-info of old attribute
|
||||
ni = mContent->GetExistingAttrNameFromQName(name);
|
||||
if (ni) {
|
||||
rv = GetAttribute(ni, getter_AddRefs(tmpReturn), PR_TRUE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
else {
|
||||
rv = mContent->NodeInfo()->NodeInfoManager()->
|
||||
GetNodeInfo(name, nsnull, kNameSpaceID_None, getter_AddRefs(ni));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
// value is already empty
|
||||
}
|
||||
}
|
||||
|
||||
// Set the new attribute value
|
||||
nsAutoString value;
|
||||
attribute->GetValue(value);
|
||||
if (!aWithNS && ni->NamespaceID() == kNameSpaceID_None &&
|
||||
mContent->IsNodeOfType(nsINode::eHTML)) {
|
||||
// Set via setAttribute(), which may do normalization on the
|
||||
// attribute name for HTML
|
||||
nsCOMPtr<nsIDOMElement> ourElement(do_QueryInterface(mContent));
|
||||
NS_ASSERTION(ourElement, "HTML content that's not an element?");
|
||||
rv = ourElement->SetAttribute(name, value);
|
||||
}
|
||||
else {
|
||||
// It's OK to just use SetAttr
|
||||
rv = mContent->SetAttr(ni->NamespaceID(), ni->NameAtom(),
|
||||
ni->GetPrefixAtom(), value, PR_TRUE);
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsAttrKey attrkey(ni->NamespaceID(), ni->NameAtom());
|
||||
rv = mAttributeCache.Put(attrkey, attribute);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
iAttribute->SetMap(this);
|
||||
}
|
||||
}
|
||||
|
||||
tmpReturn.swap(*aReturn); // transfers ref.
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttributeMap::RemoveNamedItem(const nsAString& aName,
|
||||
nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aReturn);
|
||||
*aReturn = nsnull;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (mContent) {
|
||||
nsCOMPtr<nsINodeInfo> ni = mContent->GetExistingAttrNameFromQName(aName);
|
||||
if (!ni) {
|
||||
return NS_ERROR_DOM_NOT_FOUND_ERR;
|
||||
}
|
||||
|
||||
rv = GetAttribute(ni, aReturn, PR_TRUE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mContent->UnsetAttr(ni->NamespaceID(), ni->NameAtom(), PR_TRUE);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttributeMap::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aReturn);
|
||||
|
||||
const nsAttrName* name;
|
||||
if (mContent && (name = mContent->GetAttrNameAt(aIndex))) {
|
||||
// Don't use the nodeinfo even if one exists since it can
|
||||
// have the wrong owner document.
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
mContent->NodeInfo()->NodeInfoManager()->
|
||||
GetNodeInfo(name->LocalName(), name->GetPrefix(), name->NamespaceID(),
|
||||
getter_AddRefs(ni));
|
||||
NS_ENSURE_TRUE(ni, NS_ERROR_FAILURE);
|
||||
|
||||
return GetAttribute(ni, aReturn);
|
||||
}
|
||||
|
||||
*aReturn = nsnull;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttributeMap::GetLength(PRUint32 *aLength)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aLength);
|
||||
|
||||
if (mContent) {
|
||||
*aLength = mContent->GetAttrCount();
|
||||
}
|
||||
else {
|
||||
*aLength = 0;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttributeMap::GetNamedItemNS(const nsAString& aNamespaceURI,
|
||||
const nsAString& aLocalName,
|
||||
nsIDOMNode** aReturn)
|
||||
{
|
||||
return GetNamedItemNSInternal(aNamespaceURI, aLocalName, aReturn);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttributeMap::GetNamedItemNSInternal(const nsAString& aNamespaceURI,
|
||||
const nsAString& aLocalName,
|
||||
nsIDOMNode** aReturn,
|
||||
PRBool aRemove)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aReturn);
|
||||
*aReturn = nsnull;
|
||||
|
||||
if (!mContent) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_ConvertUTF16toUTF8 utf8Name(aLocalName);
|
||||
PRInt32 nameSpaceID = kNameSpaceID_None;
|
||||
|
||||
if (!aNamespaceURI.IsEmpty()) {
|
||||
nameSpaceID =
|
||||
nsContentUtils::NameSpaceManager()->GetNameSpaceID(aNamespaceURI);
|
||||
|
||||
if (nameSpaceID == kNameSpaceID_Unknown) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
PRUint32 i, count = mContent->GetAttrCount();
|
||||
for (i = 0; i < count; ++i) {
|
||||
const nsAttrName* name = mContent->GetAttrNameAt(i);
|
||||
PRInt32 attrNS = name->NamespaceID();
|
||||
nsIAtom* nameAtom = name->LocalName();
|
||||
|
||||
if (nameSpaceID == attrNS &&
|
||||
nameAtom->EqualsUTF8(utf8Name)) {
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
mContent->NodeInfo()->NodeInfoManager()->
|
||||
GetNodeInfo(nameAtom, name->GetPrefix(), nameSpaceID,
|
||||
getter_AddRefs(ni));
|
||||
NS_ENSURE_TRUE(ni, NS_ERROR_FAILURE);
|
||||
|
||||
return GetAttribute(ni, aReturn, aRemove);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttributeMap::RemoveNamedItemNS(const nsAString& aNamespaceURI,
|
||||
const nsAString& aLocalName,
|
||||
nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aReturn);
|
||||
*aReturn = nsnull;
|
||||
|
||||
nsresult rv = GetNamedItemNSInternal(aNamespaceURI,
|
||||
aLocalName,
|
||||
aReturn,
|
||||
PR_TRUE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!*aReturn) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAttribute> attr = do_QueryInterface(*aReturn);
|
||||
NS_ASSERTION(attr, "attribute returned from nsDOMAttributeMap::GetNameItemNS "
|
||||
"didn't implement nsIAttribute");
|
||||
NS_ENSURE_TRUE(attr, NS_ERROR_UNEXPECTED);
|
||||
|
||||
nsINodeInfo *ni = attr->NodeInfo();
|
||||
mContent->UnsetAttr(ni->NamespaceID(), ni->NameAtom(), PR_TRUE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -1,190 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Allan Beaufour <allan@beaufour.dk>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Implementation of the |attributes| property of DOM Core's nsIDOMNode object.
|
||||
*/
|
||||
|
||||
#ifndef nsDOMAttributeMap_h___
|
||||
#define nsDOMAttributeMap_h___
|
||||
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIDOMNamedNodeMap.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsString.h"
|
||||
#include "plhash.h"
|
||||
#include "nsInterfaceHashtable.h"
|
||||
|
||||
class nsIContent;
|
||||
class nsDOMAttribute;
|
||||
class nsINodeInfo;
|
||||
class nsIDocument;
|
||||
|
||||
/**
|
||||
* Structure used as a key for caching nsDOMAttributes in nsDOMAttributeMap's mAttributeCache.
|
||||
*/
|
||||
class nsAttrKey
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* The namespace of the attribute
|
||||
*/
|
||||
PRInt32 mNamespaceID;
|
||||
|
||||
/**
|
||||
* The atom for attribute, weak ref. is fine as we only use it for the
|
||||
* hashcode, we never dereference it.
|
||||
*/
|
||||
nsIAtom* mLocalName;
|
||||
|
||||
nsAttrKey(PRInt32 aNs, nsIAtom* aName)
|
||||
: mNamespaceID(aNs), mLocalName(aName) {}
|
||||
|
||||
nsAttrKey(const nsAttrKey& aAttr)
|
||||
: mNamespaceID(aAttr.mNamespaceID), mLocalName(aAttr.mLocalName) {}
|
||||
};
|
||||
|
||||
/**
|
||||
* PLDHashEntryHdr implementation for nsAttrKey.
|
||||
*/
|
||||
class nsAttrHashKey : public PLDHashEntryHdr
|
||||
{
|
||||
public:
|
||||
typedef const nsAttrKey& KeyType;
|
||||
typedef const nsAttrKey* KeyTypePointer;
|
||||
|
||||
nsAttrHashKey(KeyTypePointer aKey) : mKey(*aKey) {}
|
||||
nsAttrHashKey(const nsAttrHashKey& aCopy) : mKey(aCopy.mKey) {}
|
||||
~nsAttrHashKey() {}
|
||||
|
||||
KeyType GetKey() const { return mKey; }
|
||||
KeyTypePointer GetKeyPointer() const { return &mKey; }
|
||||
PRBool KeyEquals(KeyTypePointer aKey) const
|
||||
{
|
||||
return mKey.mLocalName == aKey->mLocalName &&
|
||||
mKey.mNamespaceID == aKey->mNamespaceID;
|
||||
}
|
||||
|
||||
static KeyTypePointer KeyToPointer(KeyType aKey) { return &aKey; }
|
||||
static PLDHashNumber HashKey(KeyTypePointer aKey)
|
||||
{
|
||||
if (!aKey)
|
||||
return 0;
|
||||
|
||||
return (aKey->mNamespaceID >> 28) ^
|
||||
(aKey->mNamespaceID << 4) ^
|
||||
NS_PTR_TO_INT32(aKey->mLocalName);
|
||||
}
|
||||
enum { ALLOW_MEMMOVE = PR_TRUE };
|
||||
|
||||
private:
|
||||
nsAttrKey mKey;
|
||||
};
|
||||
|
||||
// Helper class that implements the nsIDOMNamedNodeMap interface.
|
||||
class nsDOMAttributeMap : public nsIDOMNamedNodeMap
|
||||
{
|
||||
public:
|
||||
nsDOMAttributeMap(nsIContent* aContent);
|
||||
virtual ~nsDOMAttributeMap();
|
||||
|
||||
/**
|
||||
* Initialize the map. Must be called before the map is used.
|
||||
*/
|
||||
PRBool Init();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMNamedNodeMap interface
|
||||
NS_DECL_NSIDOMNAMEDNODEMAP
|
||||
|
||||
void DropReference();
|
||||
|
||||
nsIContent* GetContent()
|
||||
{
|
||||
return mContent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when mContent is moved into a new document.
|
||||
* Updates the nodeinfos of all owned nodes.
|
||||
*/
|
||||
nsresult SetOwnerDocument(nsIDocument* aDocument);
|
||||
|
||||
/**
|
||||
* Drop an attribute from the map's cache (does not remove the attribute
|
||||
* from the node!)
|
||||
*/
|
||||
void DropAttribute(PRInt32 aNamespaceID, nsIAtom* aLocalName);
|
||||
|
||||
private:
|
||||
nsIContent* mContent; // Weak reference
|
||||
|
||||
/**
|
||||
* Cache of nsDOMAttributes.
|
||||
*/
|
||||
nsInterfaceHashtable<nsAttrHashKey, nsIDOMNode> mAttributeCache;
|
||||
|
||||
/**
|
||||
* SetNamedItem() (aWithNS = PR_FALSE) and SetNamedItemNS() (aWithNS =
|
||||
* PR_TRUE) implementation.
|
||||
*/
|
||||
nsresult SetNamedItemInternal(nsIDOMNode *aNode,
|
||||
nsIDOMNode **aReturn,
|
||||
PRBool aWithNS);
|
||||
|
||||
/**
|
||||
* GetNamedItemNS() implementation taking |aRemove| for GetAttribute(),
|
||||
* which is used by RemoveNamedItemNS().
|
||||
*/
|
||||
nsresult GetNamedItemNSInternal(const nsAString& aNamespaceURI,
|
||||
const nsAString& aLocalName,
|
||||
nsIDOMNode** aReturn,
|
||||
PRBool aRemove = PR_FALSE);
|
||||
|
||||
/**
|
||||
* Returns an attribute, either by retrieving it from the cache or by
|
||||
* creating a new one.
|
||||
*/
|
||||
nsresult GetAttribute(nsINodeInfo* aNodeInfo,
|
||||
nsIDOMNode** aReturn,
|
||||
PRBool aRemove = PR_FALSE);
|
||||
};
|
||||
|
||||
|
||||
#endif /* nsDOMAttributeMap_h___ */
|
||||
@@ -1,193 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Boris Zbarsky <bzbarsky@mit.edu> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* This file was part of an abortive attempt at DOM3 Load/Save; it's not built.
|
||||
*/
|
||||
|
||||
#include "nsDOMBuilder.h"
|
||||
#include "nsDOMError.h"
|
||||
#include "nsContentUtils.h" // for NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO
|
||||
#include "nsIDOMDocument.h"
|
||||
|
||||
static const char kLoadAsData[] = "loadAsData";
|
||||
|
||||
nsresult
|
||||
NS_NewDOMBuilder(nsIDOMDOMBuilder** aResult,
|
||||
PRUint16 aMode,
|
||||
const nsAString & aSchemaType,
|
||||
nsIDOMDOMImplementation* aDOMImplementation)
|
||||
{
|
||||
NS_PRECONDITION(aResult, "Null out ptr? Who do you think you are, flouting XPCOM contract?");
|
||||
NS_PRECONDITION(aDOMImplementation, "How are we supposed to create documents without a DOMImplementation?");
|
||||
|
||||
nsDOMBuilder* it = new nsDOMBuilder(aMode, aSchemaType, aDOMImplementation);
|
||||
if (!it)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
return CallQueryInterface(it, aResult);
|
||||
}
|
||||
|
||||
nsDOMBuilder::nsDOMBuilder(PRUint16 aMode,
|
||||
const nsAString& aSchemaType,
|
||||
nsIDOMDOMImplementation* aDOMImplementation)
|
||||
{
|
||||
mDOMImplementation = aDOMImplementation;
|
||||
}
|
||||
|
||||
nsDOMBuilder::~nsDOMBuilder()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsDOMBuilder)
|
||||
NS_IMPL_RELEASE(nsDOMBuilder)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsDOMBuilder)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMDOMBuilder)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMDOMBuilder)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(DOMBuilder)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
// nsIDOMDOMBuilder
|
||||
NS_IMETHODIMP
|
||||
nsDOMBuilder::GetEntityResolver(nsIDOMDOMEntityResolver** aEntityResolver)
|
||||
{
|
||||
*aEntityResolver = mEntityResolver;
|
||||
NS_IF_ADDREF(*aEntityResolver);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMBuilder::SetEntityResolver(nsIDOMDOMEntityResolver* aEntityResolver)
|
||||
{
|
||||
mEntityResolver = aEntityResolver;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMBuilder::GetErrorHandler(nsIDOMDOMErrorHandler** aErrorHandler)
|
||||
{
|
||||
*aErrorHandler = mErrorHandler;
|
||||
NS_IF_ADDREF(*aErrorHandler);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMBuilder::SetErrorHandler(nsIDOMDOMErrorHandler* aErrorHandler)
|
||||
{
|
||||
mErrorHandler = aErrorHandler;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMBuilder::GetFilter(nsIDOMDOMBuilderFilter** aFilter)
|
||||
{
|
||||
*aFilter = mFilter;
|
||||
NS_IF_ADDREF(*aFilter);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMBuilder::SetFilter(nsIDOMDOMBuilderFilter* aFilter)
|
||||
{
|
||||
mFilter = aFilter;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMBuilder::SetFeature(const nsAString& aName, PRBool aState)
|
||||
{
|
||||
// XXX We don't know about any features yet
|
||||
return NS_ERROR_DOM_NOT_FOUND_ERR;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMBuilder::CanSetFeature(const nsAString& aName, PRBool aState,
|
||||
PRBool* aCanSet)
|
||||
{
|
||||
// XXX We can't set anything
|
||||
*aCanSet = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMBuilder::GetFeature(const nsAString& aName, PRBool* aIsOn)
|
||||
{
|
||||
// XXX We don't know about any features yet
|
||||
return NS_ERROR_DOM_NOT_FOUND_ERR;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMBuilder::ParseURI(const nsAString& aURI, nsIDOMDocument** aDocument)
|
||||
{
|
||||
*aDocument = nsnull;
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
|
||||
NS_NAMED_LITERAL_STRING(emptyStr, "");
|
||||
mDOMImplementation->CreateDocument(emptyStr,
|
||||
emptyStr,
|
||||
nsnull,
|
||||
getter_AddRefs(domDoc));
|
||||
|
||||
if (!domDoc)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// XXX synchronous loading? We'd have to do something right about now.
|
||||
|
||||
|
||||
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMBuilder::Parse(nsIDOMDOMInputSource* aInputSource,
|
||||
nsIDOMDocument** aDocument)
|
||||
{
|
||||
*aDocument = nsnull;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMBuilder::ParseWithContext(nsIDOMDOMInputSource* aInputSource,
|
||||
nsIDOMNode* aContextNode,
|
||||
PRUint16 aAction)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Boris Zbarsky <bzbarsky@mit.edu> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* This file was part of an abortive attempt at DOM3 Load/Save; it's not built.
|
||||
*/
|
||||
|
||||
#ifndef nsDOMBuilder_h__
|
||||
#define nsDOMBuilder_h__
|
||||
|
||||
#include "nsIDOMDOMBuilder.h"
|
||||
#include "nsIDOMDOMEntityResolver.h"
|
||||
#include "nsIDOMDOMErrorHandler.h"
|
||||
#include "nsIDOMDOMBuilderFilter.h"
|
||||
#include "nsIDOMDOMImplementation.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsDOMBuilder : public nsIDOMDOMBuilder
|
||||
{
|
||||
public:
|
||||
nsDOMBuilder(PRUint16 aMode, const nsAString& aSchemaType,
|
||||
nsIDOMDOMImplementation* aDOMImplementation);
|
||||
virtual ~nsDOMBuilder();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDOMDOMBUILDER
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIDOMDOMEntityResolver> mEntityResolver;
|
||||
nsCOMPtr<nsIDOMDOMErrorHandler> mErrorHandler;
|
||||
nsCOMPtr<nsIDOMDOMBuilderFilter> mFilter;
|
||||
// Strong ref; make sure DOMImplementation never owns us!
|
||||
nsCOMPtr<nsIDOMDOMImplementation> mDOMImplementation;
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewDOMBuilder(nsIDOMDOMBuilder** aResult,
|
||||
PRUint16 aMode,
|
||||
const nsAString & aSchemaType,
|
||||
nsIDOMDOMImplementation* aDOMImplementation);
|
||||
|
||||
#endif // nsDOMBuilder_h__
|
||||
@@ -1,224 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Implementation of DOM Core's nsIDOMDocumentType node.
|
||||
*/
|
||||
|
||||
#include "nsDOMDocumentType.h"
|
||||
#include "nsDOMAttributeMap.h"
|
||||
#include "nsIDOMNamedNodeMap.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsDOMString.h"
|
||||
#include "nsIDOM3Node.h"
|
||||
#include "nsNodeInfoManager.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "nsIDocument.h"
|
||||
|
||||
nsresult
|
||||
NS_NewDOMDocumentType(nsIDOMDocumentType** aDocType,
|
||||
nsNodeInfoManager *aNodeInfoManager,
|
||||
nsIPrincipal *aPrincipal,
|
||||
nsIAtom *aName,
|
||||
nsIDOMNamedNodeMap *aEntities,
|
||||
nsIDOMNamedNodeMap *aNotations,
|
||||
const nsAString& aPublicId,
|
||||
const nsAString& aSystemId,
|
||||
const nsAString& aInternalSubset)
|
||||
{
|
||||
NS_PRECONDITION(aNodeInfoManager || aPrincipal,
|
||||
"Must have a principal if no nodeinfo manager.");
|
||||
NS_ENSURE_ARG_POINTER(aDocType);
|
||||
NS_ENSURE_ARG_POINTER(aName);
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsRefPtr<nsNodeInfoManager> nimgr;
|
||||
if (aNodeInfoManager) {
|
||||
nimgr = aNodeInfoManager;
|
||||
}
|
||||
else {
|
||||
nimgr = new nsNodeInfoManager();
|
||||
NS_ENSURE_TRUE(nimgr, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
rv = nimgr->Init(nsnull);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nimgr->SetDocumentPrincipal(aPrincipal);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
rv = nimgr->GetNodeInfo(nsLayoutAtoms::documentTypeNodeName, nsnull,
|
||||
kNameSpaceID_None, getter_AddRefs(ni));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*aDocType = new nsDOMDocumentType(ni, aName, aEntities, aNotations,
|
||||
aPublicId, aSystemId, aInternalSubset);
|
||||
if (!*aDocType) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
NS_ADDREF(*aDocType);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsDOMDocumentType::nsDOMDocumentType(nsINodeInfo *aNodeInfo,
|
||||
nsIAtom *aName,
|
||||
nsIDOMNamedNodeMap *aEntities,
|
||||
nsIDOMNamedNodeMap *aNotations,
|
||||
const nsAString& aPublicId,
|
||||
const nsAString& aSystemId,
|
||||
const nsAString& aInternalSubset) :
|
||||
nsGenericDOMDataNode(aNodeInfo),
|
||||
mName(aName),
|
||||
mEntities(aEntities),
|
||||
mNotations(aNotations),
|
||||
mPublicId(aPublicId),
|
||||
mSystemId(aSystemId),
|
||||
mInternalSubset(aInternalSubset)
|
||||
{
|
||||
}
|
||||
|
||||
nsDOMDocumentType::~nsDOMDocumentType()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// QueryInterface implementation for nsDOMDocumentType
|
||||
NS_INTERFACE_MAP_BEGIN(nsDOMDocumentType)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMDocumentType)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(DocumentType)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsGenericDOMDataNode)
|
||||
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsDOMDocumentType, nsGenericDOMDataNode)
|
||||
NS_IMPL_RELEASE_INHERITED(nsDOMDocumentType, nsGenericDOMDataNode)
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMDocumentType::GetName(nsAString& aName)
|
||||
{
|
||||
return mName->ToString(aName);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMDocumentType::GetEntities(nsIDOMNamedNodeMap** aEntities)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aEntities);
|
||||
|
||||
*aEntities = mEntities;
|
||||
|
||||
NS_IF_ADDREF(*aEntities);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMDocumentType::GetNotations(nsIDOMNamedNodeMap** aNotations)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aNotations);
|
||||
|
||||
*aNotations = mNotations;
|
||||
|
||||
NS_IF_ADDREF(*aNotations);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMDocumentType::GetPublicId(nsAString& aPublicId)
|
||||
{
|
||||
aPublicId = mPublicId;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMDocumentType::GetSystemId(nsAString& aSystemId)
|
||||
{
|
||||
aSystemId = mSystemId;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMDocumentType::GetInternalSubset(nsAString& aInternalSubset)
|
||||
{
|
||||
// XXX: null string
|
||||
aInternalSubset = mInternalSubset;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMDocumentType::GetNodeName(nsAString& aNodeName)
|
||||
{
|
||||
return mName->ToString(aNodeName);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMDocumentType::GetNodeValue(nsAString& aNodeValue)
|
||||
{
|
||||
SetDOMStringToNull(aNodeValue);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMDocumentType::SetNodeValue(const nsAString& aNodeValue)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMDocumentType::GetNodeType(PRUint16* aNodeType)
|
||||
{
|
||||
*aNodeType = nsIDOMNode::DOCUMENT_TYPE_NODE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsGenericDOMDataNode*
|
||||
nsDOMDocumentType::Clone(nsINodeInfo *aNodeInfo, PRBool aCloneText) const
|
||||
{
|
||||
return new nsDOMDocumentType(aNodeInfo, mName, mEntities, mNotations,
|
||||
mPublicId, mSystemId, mInternalSubset);
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Implementation of DOM Core's nsIDOMDocumentType node.
|
||||
*/
|
||||
|
||||
#ifndef nsDOMDocumentType_h___
|
||||
#define nsDOMDocumentType_h___
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDOMDocumentType.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsGenericDOMDataNode.h"
|
||||
#include "nsString.h"
|
||||
|
||||
// XXX DocumentType is currently implemented by inheriting the generic
|
||||
// CharacterData object, even though DocumentType is not character
|
||||
// data. This is done simply for convenience and should be changed if
|
||||
// this restricts what should be done for character data.
|
||||
|
||||
class nsDOMDocumentType : public nsGenericDOMDataNode,
|
||||
public nsIDOMDocumentType
|
||||
{
|
||||
public:
|
||||
nsDOMDocumentType(nsINodeInfo* aNodeInfo,
|
||||
nsIAtom *aName,
|
||||
nsIDOMNamedNodeMap *aEntities,
|
||||
nsIDOMNamedNodeMap *aNotations,
|
||||
const nsAString& aPublicId,
|
||||
const nsAString& aSystemId,
|
||||
const nsAString& aInternalSubset);
|
||||
|
||||
virtual ~nsDOMDocumentType();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIDOMNode
|
||||
NS_IMPL_NSIDOMNODE_USING_GENERIC_DOM_DATA
|
||||
|
||||
// nsIDOMDocumentType
|
||||
NS_DECL_NSIDOMDOCUMENTTYPE
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIAtom> mName;
|
||||
nsCOMPtr<nsIDOMNamedNodeMap> mEntities;
|
||||
nsCOMPtr<nsIDOMNamedNodeMap> mNotations;
|
||||
nsString mPublicId;
|
||||
nsString mSystemId;
|
||||
nsString mInternalSubset;
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewDOMDocumentType(nsIDOMDocumentType** aDocType,
|
||||
nsNodeInfoManager *aOwnerDoc,
|
||||
nsIPrincipal *aPrincipal,
|
||||
nsIAtom *aName,
|
||||
nsIDOMNamedNodeMap *aEntities,
|
||||
nsIDOMNamedNodeMap *aNotations,
|
||||
const nsAString& aPublicId,
|
||||
const nsAString& aSystemId,
|
||||
const nsAString& aInternalSubset);
|
||||
|
||||
#endif // nsDOMDocument_h___
|
||||
@@ -1,181 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2003
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Peter Van der Beken <peterv@netscape.com>
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Implementations of nsIDOMDOMStringList and nsIDOMNameList, used by various
|
||||
* DOM3 stuff and some interfaces specified by WHATWG.
|
||||
*/
|
||||
|
||||
#include "nsDOMLists.h"
|
||||
#include "nsDOMError.h"
|
||||
#include "nsIDOMClassInfo.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
nsDOMStringList::nsDOMStringList()
|
||||
{
|
||||
}
|
||||
|
||||
nsDOMStringList::~nsDOMStringList()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsDOMStringList)
|
||||
NS_IMPL_RELEASE(nsDOMStringList)
|
||||
NS_INTERFACE_MAP_BEGIN(nsDOMStringList)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMDOMStringList)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(DOMStringList)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMStringList::Item(PRUint32 aIndex, nsAString& aResult)
|
||||
{
|
||||
if (aIndex >= (PRUint32)mNames.Count()) {
|
||||
SetDOMStringToNull(aResult);
|
||||
} else {
|
||||
mNames.StringAt(aIndex, aResult);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMStringList::GetLength(PRUint32 *aLength)
|
||||
{
|
||||
*aLength = (PRUint32)mNames.Count();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMStringList::Contains(const nsAString& aString, PRBool *aResult)
|
||||
{
|
||||
*aResult = mNames.IndexOf(aString) > -1;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsNameList::nsNameList()
|
||||
{
|
||||
}
|
||||
|
||||
nsNameList::~nsNameList()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsNameList)
|
||||
NS_IMPL_RELEASE(nsNameList)
|
||||
NS_INTERFACE_MAP_BEGIN(nsNameList)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMNameList)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(NameList)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNameList::GetName(PRUint32 aIndex, nsAString& aResult)
|
||||
{
|
||||
if (aIndex >= (PRUint32)mNames.Count()) {
|
||||
SetDOMStringToNull(aResult);
|
||||
} else {
|
||||
mNames.StringAt(aIndex, aResult);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNameList::GetNamespaceURI(PRUint32 aIndex, nsAString& aResult)
|
||||
{
|
||||
if (aIndex >= (PRUint32)mNames.Count()) {
|
||||
SetDOMStringToNull(aResult);
|
||||
} else {
|
||||
mNamespaceURIs.StringAt(aIndex, aResult);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNameList::GetLength(PRUint32 *aLength)
|
||||
{
|
||||
*aLength = (PRUint32)mNames.Count();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsNameList::Add(const nsAString& aNamespaceURI, const nsAString& aName)
|
||||
{
|
||||
PRInt32 count = mNamespaceURIs.Count();
|
||||
if (mNamespaceURIs.InsertStringAt(aNamespaceURI, count)) {
|
||||
if (mNames.InsertStringAt(aName, count)) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
mNamespaceURIs.RemoveStringAt(count);
|
||||
}
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNameList::Contains(const nsAString& aName, PRBool *aResult)
|
||||
{
|
||||
*aResult = mNames.IndexOf(aName) > -1;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNameList::ContainsNS(const nsAString& aNamespaceURI, const nsAString& aName,
|
||||
PRBool *aResult)
|
||||
{
|
||||
PRInt32 index = mNames.IndexOf(aName);
|
||||
if (index > -1) {
|
||||
nsAutoString ns;
|
||||
mNamespaceURIs.StringAt(index, ns);
|
||||
|
||||
*aResult = ns.Equals(aNamespaceURI);
|
||||
}
|
||||
else {
|
||||
*aResult = PR_FALSE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Peter Van der Beken.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2003
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Peter Van der Beken <peterv@propagandism.org>
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Implementations of nsIDOMDOMStringList and nsIDOMNameList, used by various
|
||||
* DOM3 stuff and some interfaces specified by WHATWG.
|
||||
*/
|
||||
|
||||
#ifndef nsDOMLists_h___
|
||||
#define nsDOMLists_h___
|
||||
|
||||
#include "nsIDOMDOMStringList.h"
|
||||
#include "nsIDOMNameList.h"
|
||||
#include "nsVoidArray.h"
|
||||
|
||||
class nsDOMStringList : public nsIDOMDOMStringList
|
||||
{
|
||||
public:
|
||||
nsDOMStringList();
|
||||
virtual ~nsDOMStringList();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDOMDOMSTRINGLIST
|
||||
|
||||
PRBool Add(const nsAString& aName)
|
||||
{
|
||||
return mNames.AppendString(aName);
|
||||
}
|
||||
|
||||
private:
|
||||
nsStringArray mNames;
|
||||
};
|
||||
|
||||
class nsNameList : public nsIDOMNameList
|
||||
{
|
||||
public:
|
||||
nsNameList();
|
||||
virtual ~nsNameList();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDOMNAMELIST
|
||||
|
||||
PRBool Add(const nsAString& aNamespaceURI, const nsAString& aName);
|
||||
|
||||
private:
|
||||
nsStringArray mNamespaceURIs;
|
||||
nsStringArray mNames;
|
||||
};
|
||||
|
||||
#endif /* nsDOMLists_h___ */
|
||||
@@ -1,394 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "nsDOMParser.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsStringStream.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsLayoutCID.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMDOMImplementation.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIPrivateDOMImplementation.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIDOMClassInfo.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsLoadListenerProxy.h"
|
||||
#include "nsStreamUtils.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
static const char* kLoadAsData = "loadAsData";
|
||||
|
||||
static NS_DEFINE_CID(kIDOMDOMImplementationCID, NS_DOM_IMPLEMENTATION_CID);
|
||||
|
||||
// nsIDOMEventListener
|
||||
nsresult
|
||||
nsDOMParser::HandleEvent(nsIDOMEvent* aEvent)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIDOMLoadListener
|
||||
nsresult
|
||||
nsDOMParser::Load(nsIDOMEvent* aEvent)
|
||||
{
|
||||
mLoopingForSyncLoad = PR_FALSE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMParser::BeforeUnload(nsIDOMEvent* aEvent)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMParser::Unload(nsIDOMEvent* aEvent)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMParser::Abort(nsIDOMEvent* aEvent)
|
||||
{
|
||||
mLoopingForSyncLoad = PR_FALSE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMParser::Error(nsIDOMEvent* aEvent)
|
||||
{
|
||||
mLoopingForSyncLoad = PR_FALSE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsDOMParser::nsDOMParser()
|
||||
: mLoopingForSyncLoad(PR_FALSE)
|
||||
{
|
||||
}
|
||||
|
||||
nsDOMParser::~nsDOMParser()
|
||||
{
|
||||
NS_ABORT_IF_FALSE(!mLoopingForSyncLoad, "we rather crash than hang");
|
||||
mLoopingForSyncLoad = PR_FALSE;
|
||||
}
|
||||
|
||||
|
||||
// QueryInterface implementation for nsDOMParser
|
||||
NS_INTERFACE_MAP_BEGIN(nsDOMParser)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMParser)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMParser)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMLoadListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(DOMParser)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(nsDOMParser)
|
||||
NS_IMPL_RELEASE(nsDOMParser)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMParser::ParseFromString(const PRUnichar *str,
|
||||
const char *contentType,
|
||||
nsIDOMDocument **aResult)
|
||||
{
|
||||
NS_ENSURE_ARG(str);
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
NS_ConvertUTF16toUTF8 data(str);
|
||||
|
||||
// The new stream holds a reference to the buffer
|
||||
nsCOMPtr<nsIInputStream> stream;
|
||||
nsresult rv = NS_NewByteInputStream(getter_AddRefs(stream),
|
||||
data.get(), data.Length(),
|
||||
NS_ASSIGNMENT_DEPEND);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return ParseFromStream(stream, "UTF-8", data.Length(), contentType, aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMParser::ParseFromBuffer(const PRUint8 *buf,
|
||||
PRUint32 bufLen,
|
||||
const char *contentType,
|
||||
nsIDOMDocument **aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(buf);
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
// The new stream holds a reference to the buffer
|
||||
nsCOMPtr<nsIInputStream> stream;
|
||||
nsresult rv = NS_NewByteInputStream(getter_AddRefs(stream),
|
||||
NS_REINTERPRET_CAST(const char *, buf),
|
||||
bufLen, NS_ASSIGNMENT_DEPEND);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return ParseFromStream(stream, nsnull, bufLen, contentType, aResult);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMParser::ParseFromStream(nsIInputStream *stream,
|
||||
const char *charset,
|
||||
PRInt32 contentLength,
|
||||
const char *contentType,
|
||||
nsIDOMDocument **aResult)
|
||||
{
|
||||
NS_ENSURE_ARG(stream);
|
||||
NS_ENSURE_ARG(contentType);
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
*aResult = nsnull;
|
||||
|
||||
// For now, we can only create XML documents.
|
||||
if ((nsCRT::strcmp(contentType, "text/xml") != 0) &&
|
||||
(nsCRT::strcmp(contentType, "application/xml") != 0) &&
|
||||
(nsCRT::strcmp(contentType, "application/xhtml+xml") != 0))
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
||||
// Put the nsCOMPtr out here so we hold a ref to the stream as needed
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIBufferedInputStream> bufferedStream;
|
||||
if (!NS_InputStreamIsBuffered(stream)) {
|
||||
bufferedStream = do_CreateInstance(NS_BUFFEREDINPUTSTREAM_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = bufferedStream->Init(stream, 4096);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
stream = bufferedStream;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPrincipal> principal;
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan =
|
||||
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
secMan->GetSubjectPrincipal(getter_AddRefs(principal));
|
||||
}
|
||||
|
||||
// Try to find a base URI for the document we're creating.
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
|
||||
nsCOMPtr<nsIXPCNativeCallContext> cc;
|
||||
nsCOMPtr<nsIXPConnect> xpc(do_GetService(nsIXPConnect::GetCID(), &rv));
|
||||
if(NS_SUCCEEDED(rv)) {
|
||||
rv = xpc->GetCurrentNativeCallContext(getter_AddRefs(cc));
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv) && cc) {
|
||||
JSContext* cx;
|
||||
rv = cc->GetJSContext(&cx);
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
|
||||
nsIScriptContext *scriptContext = GetScriptContextFromJSContext(cx);
|
||||
if (scriptContext) {
|
||||
nsCOMPtr<nsIDOMWindow> window =
|
||||
do_QueryInterface(scriptContext->GetGlobalObject());
|
||||
|
||||
if (window) {
|
||||
nsCOMPtr<nsIDOMDocument> domdoc;
|
||||
window->GetDocument(getter_AddRefs(domdoc));
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domdoc);
|
||||
if (doc) {
|
||||
baseURI = doc->GetBaseURI();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!baseURI) {
|
||||
// No URI from script environment (we are running from command line, for example).
|
||||
// Create a dummy one.
|
||||
// XXX Is this safe? Could we get the URI from stream or something?
|
||||
if (!mBaseURI) {
|
||||
rv = NS_NewURI(getter_AddRefs(baseURI),
|
||||
"about:blank" );
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
} else {
|
||||
baseURI = mBaseURI;
|
||||
}
|
||||
}
|
||||
|
||||
// Get and initialize a DOMImplementation
|
||||
nsCOMPtr<nsIDOMDOMImplementation> implementation(do_CreateInstance(kIDOMDOMImplementationCID, &rv));
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
|
||||
if (baseURI) {
|
||||
nsCOMPtr<nsIPrivateDOMImplementation> privImpl(do_QueryInterface(implementation));
|
||||
if (privImpl) {
|
||||
// XXXbz Is this really right? Why are we setting the documentURI to
|
||||
// baseURI? But note that's what the StartDocumentLoad() below would do
|
||||
// if we let it reset. In any case, this is odd, since the caller can
|
||||
// set baseURI to anything it feels like, pretty much.
|
||||
privImpl->Init(baseURI, baseURI, principal);
|
||||
}
|
||||
}
|
||||
|
||||
// Create an empty document from it
|
||||
nsCOMPtr<nsIDOMDocument> domDocument;
|
||||
rv = implementation->CreateDocument(EmptyString(),
|
||||
EmptyString(),
|
||||
nsnull,
|
||||
getter_AddRefs(domDocument));
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
|
||||
// Register as a load listener on the document
|
||||
nsCOMPtr<nsIDOMEventReceiver> target(do_QueryInterface(domDocument));
|
||||
if (target) {
|
||||
nsWeakPtr requestWeak(do_GetWeakReference(NS_STATIC_CAST(nsIDOMParser*, this)));
|
||||
nsLoadListenerProxy* proxy = new nsLoadListenerProxy(requestWeak);
|
||||
if (!proxy) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
// This will addref the proxy
|
||||
rv = target->AddEventListenerByIID(NS_STATIC_CAST(nsIDOMEventListener*,
|
||||
proxy),
|
||||
NS_GET_IID(nsIDOMLoadListener));
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Create a fake channel
|
||||
nsCOMPtr<nsIChannel> parserChannel;
|
||||
NS_NewInputStreamChannel(getter_AddRefs(parserChannel), baseURI, nsnull,
|
||||
nsDependentCString(contentType), nsnull);
|
||||
NS_ENSURE_STATE(parserChannel);
|
||||
|
||||
// Hold a reference to it in this method
|
||||
if (principal) {
|
||||
parserChannel->SetOwner(principal);
|
||||
}
|
||||
|
||||
if (charset) {
|
||||
parserChannel->SetContentCharset(nsDependentCString(charset));
|
||||
}
|
||||
|
||||
// Tell the document to start loading
|
||||
nsCOMPtr<nsIStreamListener> listener;
|
||||
nsCOMPtr<nsIDocument> document(do_QueryInterface(domDocument));
|
||||
if (!document) return NS_ERROR_FAILURE;
|
||||
|
||||
mLoopingForSyncLoad = PR_TRUE;
|
||||
|
||||
// Have to pass PR_FALSE for reset here, else the reset will remove
|
||||
// our event listener. Should that listener addition move to later
|
||||
// than this call?
|
||||
rv = document->StartDocumentLoad(kLoadAsData, parserChannel,
|
||||
nsnull, nsnull,
|
||||
getter_AddRefs(listener),
|
||||
PR_FALSE);
|
||||
|
||||
if (principal) {
|
||||
// Make sure to give this document the right principal
|
||||
document->SetPrincipal(principal);
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv) || !listener) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Now start pumping data to the listener
|
||||
nsresult status;
|
||||
|
||||
rv = listener->OnStartRequest(parserChannel, nsnull);
|
||||
if (NS_FAILED(rv))
|
||||
parserChannel->Cancel(rv);
|
||||
parserChannel->GetStatus(&status);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(status)) {
|
||||
rv = listener->OnDataAvailable(parserChannel, nsnull, stream, 0,
|
||||
contentLength);
|
||||
if (NS_FAILED(rv))
|
||||
parserChannel->Cancel(rv);
|
||||
parserChannel->GetStatus(&status);
|
||||
}
|
||||
|
||||
rv = listener->OnStopRequest(parserChannel, nsnull, status);
|
||||
// Failure returned from OnStopRequest does not affect the final status of
|
||||
// the channel, so we do not need to call Cancel(rv) as we do above.
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Process events until we receive a load, abort, or error event for the
|
||||
// document object. That event may have already fired.
|
||||
|
||||
nsIThread *thread = NS_GetCurrentThread();
|
||||
while (mLoopingForSyncLoad) {
|
||||
if (!NS_ProcessNextEvent(thread))
|
||||
break;
|
||||
}
|
||||
|
||||
domDocument.swap(*aResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMParser::GetBaseURI(nsIURI **aBaseURI)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aBaseURI);
|
||||
|
||||
NS_IF_ADDREF(*aBaseURI = mBaseURI);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMParser::SetBaseURI(nsIURI *aBaseURI)
|
||||
{
|
||||
mBaseURI = aBaseURI;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsDOMParser_h__
|
||||
#define nsDOMParser_h__
|
||||
|
||||
#include "nsIDOMParser.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIDOMLoadListener.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
class nsDOMParser : public nsIDOMParser,
|
||||
public nsIDOMLoadListener,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
public:
|
||||
nsDOMParser();
|
||||
virtual ~nsDOMParser();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMParser
|
||||
NS_DECL_NSIDOMPARSER
|
||||
|
||||
// nsIDOMEventListener
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
|
||||
|
||||
// nsIDOMLoadListener
|
||||
NS_IMETHOD Load(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD BeforeUnload(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Unload(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Abort(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Error(nsIDOMEvent* aEvent);
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIURI> mBaseURI;
|
||||
PRBool mLoopingForSyncLoad;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,215 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsDOMSerializer.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMClassInfo.h"
|
||||
#include "nsIOutputStream.h"
|
||||
#include "nsINode.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDocumentEncoder.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIContentSerializer.h"
|
||||
#include "nsString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsContentCID.h"
|
||||
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
nsDOMSerializer::nsDOMSerializer()
|
||||
{
|
||||
}
|
||||
|
||||
nsDOMSerializer::~nsDOMSerializer()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// QueryInterface implementation for nsDOMSerializer
|
||||
NS_INTERFACE_MAP_BEGIN(nsDOMSerializer)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMSerializer)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(XMLSerializer)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(nsDOMSerializer)
|
||||
NS_IMPL_RELEASE(nsDOMSerializer)
|
||||
|
||||
|
||||
static nsresult
|
||||
SetUpEncoder(nsIDOMNode *aRoot, const nsACString& aCharset,
|
||||
nsIDocumentEncoder **aEncoder)
|
||||
{
|
||||
*aEncoder = nsnull;
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIDocumentEncoder> encoder =
|
||||
do_CreateInstance(NS_DOC_ENCODER_CONTRACTID_BASE "text/xml", &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
PRBool entireDocument = PR_TRUE;
|
||||
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(aRoot));
|
||||
if (!domDoc) {
|
||||
entireDocument = PR_FALSE;
|
||||
rv = aRoot->GetOwnerDocument(getter_AddRefs(domDoc));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
|
||||
// This method will fail if no document
|
||||
rv = encoder->Init(domDoc, NS_LITERAL_STRING("text/xml"),
|
||||
nsIDocumentEncoder::OutputEncodeBasicEntities);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCAutoString charset(aCharset);
|
||||
if (charset.IsEmpty()) {
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
|
||||
NS_ASSERTION(doc, "Need a document");
|
||||
charset = doc->GetDocumentCharacterSet();
|
||||
}
|
||||
rv = encoder->SetCharset(charset);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// If we are working on the entire document we do not need to
|
||||
// specify which part to serialize
|
||||
if (!entireDocument) {
|
||||
rv = encoder->SetNode(aRoot);
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
*aEncoder = encoder.get();
|
||||
NS_ADDREF(*aEncoder);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
static nsresult
|
||||
CheckSameOrigin(nsIDOMNode *aRoot)
|
||||
{
|
||||
// Make sure that the caller has permission to access the root
|
||||
|
||||
// Be sure to QI to nsINode to make sure we're passed a native
|
||||
// object.
|
||||
|
||||
nsCOMPtr<nsINode> node(do_QueryInterface(aRoot));
|
||||
|
||||
if (NS_UNLIKELY(!node)) {
|
||||
// We got a non-native object.
|
||||
|
||||
return NS_ERROR_INVALID_POINTER;
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan =
|
||||
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRBool ubrEnabled = PR_FALSE;
|
||||
rv = secMan->IsCapabilityEnabled("UniversalBrowserRead", &ubrEnabled);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (ubrEnabled) {
|
||||
// UniversalBrowserRead is enabled (or we're not called from
|
||||
// script), permit access.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPrincipal> subject;
|
||||
rv = secMan->GetSubjectPrincipal(getter_AddRefs(subject));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// XXXbz can we happen to not have a subject principal here?
|
||||
// nsScriptSecurityManager::IsCapabilityEnabled doesn't actually use
|
||||
// GetSubjectPrincipal, so not sure...
|
||||
// In any case, no subject principal means access is allowed.
|
||||
if (subject) {
|
||||
// Check if the caller is from the same origin that the root is from.
|
||||
return secMan->CheckSameOriginPrincipal(subject, node->NodePrincipal());
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMSerializer::SerializeToString(nsIDOMNode *aRoot, nsAString& _retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aRoot);
|
||||
|
||||
_retval.Truncate();
|
||||
|
||||
nsresult rv = CheckSameOrigin(aRoot);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIDocumentEncoder> encoder;
|
||||
rv = SetUpEncoder(aRoot, EmptyCString(), getter_AddRefs(encoder));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return encoder->EncodeToString(_retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMSerializer::SerializeToStream(nsIDOMNode *aRoot,
|
||||
nsIOutputStream *aStream,
|
||||
const nsACString& aCharset)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aRoot);
|
||||
NS_ENSURE_ARG_POINTER(aStream);
|
||||
// The charset arg can be null, in which case we get the document's
|
||||
// charset and use that when serializing.
|
||||
|
||||
nsresult rv = CheckSameOrigin(aRoot);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIDocumentEncoder> encoder;
|
||||
rv = SetUpEncoder(aRoot, aCharset, getter_AddRefs(encoder));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return encoder->EncodeToStream(aStream);
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsDOMSerializer_h__
|
||||
#define nsDOMSerializer_h__
|
||||
|
||||
#include "nsIDOMSerializer.h"
|
||||
|
||||
class nsDOMSerializer : public nsIDOMSerializer
|
||||
{
|
||||
public:
|
||||
nsDOMSerializer();
|
||||
virtual ~nsDOMSerializer();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMSerializer
|
||||
NS_DECL_NSIDOMSERIALIZER
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Boris Zbarsky <bzbarsky@mit.edu>.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Content policy implementation that prevents all loads of images,
|
||||
* subframes, etc from documents loaded as data (eg documents loaded
|
||||
* via XMLHttpRequest).
|
||||
*/
|
||||
|
||||
#include "nsDataDocumentContentPolicy.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsINode.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsDataDocumentContentPolicy, nsIContentPolicy)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDataDocumentContentPolicy::ShouldLoad(PRUint32 aContentType,
|
||||
nsIURI *aContentLocation,
|
||||
nsIURI *aRequestingLocation,
|
||||
nsISupports *aRequestingContext,
|
||||
const nsACString &aMimeGuess,
|
||||
nsISupports *aExtra,
|
||||
PRInt16 *aDecision)
|
||||
{
|
||||
*aDecision = nsIContentPolicy::ACCEPT;
|
||||
// Look for the document. In most cases, aRequestingContext is a node.
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(aRequestingContext);
|
||||
if (node) {
|
||||
doc = node->GetOwnerDoc();
|
||||
} else {
|
||||
nsCOMPtr<nsIDOMWindow> window = do_QueryInterface(aRequestingContext);
|
||||
if (window) {
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
window->GetDocument(getter_AddRefs(domDoc));
|
||||
doc = do_QueryInterface(domDoc);
|
||||
}
|
||||
}
|
||||
if (doc && doc->IsLoadedAsData()) {
|
||||
*aDecision = nsIContentPolicy::REJECT_TYPE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDataDocumentContentPolicy::ShouldProcess(PRUint32 aContentType,
|
||||
nsIURI *aContentLocation,
|
||||
nsIURI *aRequestingLocation,
|
||||
nsISupports *aRequestingContext,
|
||||
const nsACString &aMimeGuess,
|
||||
nsISupports *aExtra,
|
||||
PRInt16 *aDecision)
|
||||
{
|
||||
return ShouldLoad(aContentType, aContentLocation, aRequestingLocation,
|
||||
aRequestingContext, aMimeGuess, aExtra, aDecision);
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Boris Zbarsky <bzbarsky@mit.edu>.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Content policy implementation that prevents all loads of images,
|
||||
* subframes, etc from documents loaded as data (eg documents loaded
|
||||
* via XMLHttpRequest).
|
||||
*/
|
||||
|
||||
#ifndef nsDataDocumentContentPolicy_h__
|
||||
#define nsDataDocumentContentPolicy_h__
|
||||
|
||||
/* 1147d32c-215b-4014-b180-07fe7aedf915 */
|
||||
#define NS_DATADOCUMENTCONTENTPOLICY_CID \
|
||||
{0x1147d32c, 0x215b, 0x4014, {0xb1, 0x80, 0x07, 0xfe, 0x7a, 0xed, 0xf9, 0x15}}
|
||||
#define NS_DATADOCUMENTCONTENTPOLICY_CONTRACTID \
|
||||
"@mozilla.org/data-document-content-policy;1"
|
||||
|
||||
|
||||
#include "nsIContentPolicy.h"
|
||||
|
||||
class nsDataDocumentContentPolicy : public nsIContentPolicy
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSICONTENTPOLICY
|
||||
|
||||
nsDataDocumentContentPolicy()
|
||||
{}
|
||||
~nsDataDocumentContentPolicy()
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
#endif /* nsDataDocumentContentPolicy_h__ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,799 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Base class for all our document implementations.
|
||||
*/
|
||||
|
||||
#ifndef nsDocument_h___
|
||||
#define nsDocument_h___
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsWeakPtr.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsHashSets.h"
|
||||
#include "nsIDOMXMLDocument.h"
|
||||
#include "nsIDOM3Document.h"
|
||||
#include "nsIDOMDocumentView.h"
|
||||
#include "nsIDOMDocumentXBL.h"
|
||||
#include "nsIDOMNSDocument.h"
|
||||
#include "nsIDOMNSDocumentStyle.h"
|
||||
#include "nsIDOMDocumentRange.h"
|
||||
#include "nsIDOMDocumentTraversal.h"
|
||||
#include "nsStubDocumentObserver.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIDOM3EventTarget.h"
|
||||
#include "nsIDOMNSEventTarget.h"
|
||||
#include "nsIDOMStyleSheetList.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIEventListenerManager.h"
|
||||
#include "nsIDOM3Node.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsIParser.h"
|
||||
#include "nsIBindingManager.h"
|
||||
#include "nsINodeInfo.h"
|
||||
#include "nsIDOMDocumentEvent.h"
|
||||
#include "nsIDOM3DocumentEvent.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsInterfaceHashtable.h"
|
||||
#include "nsIBoxObject.h"
|
||||
#include "nsPIBoxObject.h"
|
||||
#include "nsIScriptObjectPrincipal.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsScriptLoader.h"
|
||||
#include "nsICSSLoader.h"
|
||||
#include "nsIRadioGroupContainer.h"
|
||||
#include "nsIScriptEventManager.h"
|
||||
#include "nsILayoutHistoryState.h"
|
||||
#include "nsIRequest.h"
|
||||
#include "nsILoadGroup.h"
|
||||
|
||||
// Put these here so all document impls get them automatically
|
||||
#include "nsHTMLStyleSheet.h"
|
||||
#include "nsIHTMLCSSStyleSheet.h"
|
||||
|
||||
#include "nsStyleSet.h"
|
||||
#include "nsXMLEventsManager.h"
|
||||
#include "pldhash.h"
|
||||
#include "nsAttrAndChildArray.h"
|
||||
|
||||
#define XML_DECLARATION_BITS_DECLARATION_EXISTS (1 << 0)
|
||||
#define XML_DECLARATION_BITS_ENCODING_EXISTS (1 << 1)
|
||||
#define XML_DECLARATION_BITS_STANDALONE_EXISTS (1 << 2)
|
||||
#define XML_DECLARATION_BITS_STANDALONE_YES (1 << 3)
|
||||
|
||||
|
||||
class nsIEventListenerManager;
|
||||
class nsDOMStyleSheetList;
|
||||
class nsIOutputStream;
|
||||
class nsDocument;
|
||||
class nsIDTD;
|
||||
class nsIRadioVisitor;
|
||||
class nsIFormControl;
|
||||
struct nsRadioGroupStruct;
|
||||
class nsOnloadBlocker;
|
||||
class nsUnblockOnloadEvent;
|
||||
struct PLEvent;
|
||||
class nsChildContentList;
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
/* Note that these typedefs declare functions, not pointer to
|
||||
functions. That's the only way in which they differ from
|
||||
PLHandleEventProc and PLDestroyEventProc. */
|
||||
typedef void*
|
||||
(PR_CALLBACK EventHandlerFunc)(PLEvent* self);
|
||||
typedef void
|
||||
(PR_CALLBACK EventDestructorFunc)(PLEvent* self);
|
||||
PR_END_EXTERN_C
|
||||
|
||||
/**
|
||||
* Hashentry using a PRUint32 key and a cheap set of nsIContent* owning
|
||||
* pointers for the value.
|
||||
*
|
||||
* @see nsTHashtable::EntryType for specification
|
||||
*/
|
||||
class nsUint32ToContentHashEntry : public PLDHashEntryHdr
|
||||
{
|
||||
public:
|
||||
typedef const PRUint32& KeyType;
|
||||
typedef const PRUint32* KeyTypePointer;
|
||||
|
||||
nsUint32ToContentHashEntry(const KeyTypePointer key) :
|
||||
mValue(*key), mValOrHash(nsnull) { }
|
||||
nsUint32ToContentHashEntry(const nsUint32ToContentHashEntry& toCopy) :
|
||||
mValue(toCopy.mValue), mValOrHash(toCopy.mValOrHash)
|
||||
{
|
||||
// Pathetic attempt to not die: clear out the other mValOrHash so we're
|
||||
// effectively stealing it. If toCopy is destroyed right after this,
|
||||
// we'll be OK.
|
||||
NS_CONST_CAST(nsUint32ToContentHashEntry&, toCopy).mValOrHash = nsnull;
|
||||
NS_ERROR("Copying not supported. Fasten your seat belt.");
|
||||
}
|
||||
~nsUint32ToContentHashEntry() { Destroy(); }
|
||||
|
||||
KeyType GetKey() const { return mValue; }
|
||||
KeyTypePointer GetKeyPointer() const { return &mValue; }
|
||||
|
||||
PRBool KeyEquals(KeyTypePointer aKey) const { return mValue == *aKey; }
|
||||
|
||||
static KeyTypePointer KeyToPointer(KeyType aKey) { return &aKey; }
|
||||
static PLDHashNumber HashKey(KeyTypePointer aKey) { return *aKey; }
|
||||
enum { ALLOW_MEMMOVE = PR_TRUE };
|
||||
|
||||
// Content set methods
|
||||
nsresult PutContent(nsIContent* aContent);
|
||||
|
||||
void RemoveContent(nsIContent* aContent);
|
||||
|
||||
struct Visitor {
|
||||
virtual void Visit(nsIContent* aContent) = 0;
|
||||
};
|
||||
void VisitContent(Visitor* aVisitor);
|
||||
|
||||
PRBool IsEmpty() { return mValOrHash == nsnull; }
|
||||
|
||||
private:
|
||||
typedef unsigned long PtrBits;
|
||||
typedef nsTHashtable<nsISupportsHashKey> HashSet;
|
||||
/** Get the hash pointer (or null if we're not a hash) */
|
||||
HashSet* GetHashSet()
|
||||
{
|
||||
return (PtrBits(mValOrHash) & 0x1) ? nsnull : (HashSet*)mValOrHash;
|
||||
}
|
||||
/** Find out whether it is an nsIContent (returns weak) */
|
||||
nsIContent* GetContent()
|
||||
{
|
||||
return (PtrBits(mValOrHash) & 0x1)
|
||||
? (nsIContent*)(PtrBits(mValOrHash) & ~0x1)
|
||||
: nsnull;
|
||||
}
|
||||
/** Set the single element, adding a reference */
|
||||
nsresult SetContent(nsIContent* aVal)
|
||||
{
|
||||
NS_IF_ADDREF(aVal);
|
||||
mValOrHash = (void*)(PtrBits(aVal) | 0x1);
|
||||
return NS_OK;
|
||||
}
|
||||
/** Initialize the hash */
|
||||
nsresult InitHashSet(HashSet** aSet);
|
||||
|
||||
void Destroy();
|
||||
|
||||
private:
|
||||
const PRUint32 mValue;
|
||||
/** A hash or nsIContent ptr, depending on the lower bit (0=hash, 1=ptr) */
|
||||
void* mValOrHash;
|
||||
};
|
||||
|
||||
|
||||
class nsDocHeaderData
|
||||
{
|
||||
public:
|
||||
nsDocHeaderData(nsIAtom* aField, const nsAString& aData)
|
||||
: mField(aField), mData(aData), mNext(nsnull)
|
||||
{
|
||||
}
|
||||
|
||||
~nsDocHeaderData(void)
|
||||
{
|
||||
delete mNext;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAtom> mField;
|
||||
nsString mData;
|
||||
nsDocHeaderData* mNext;
|
||||
};
|
||||
|
||||
class nsDOMStyleSheetList : public nsIDOMStyleSheetList,
|
||||
public nsStubDocumentObserver
|
||||
{
|
||||
public:
|
||||
nsDOMStyleSheetList(nsIDocument *aDocument);
|
||||
virtual ~nsDOMStyleSheetList();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_DECL_NSIDOMSTYLESHEETLIST
|
||||
|
||||
// nsIDocumentObserver
|
||||
virtual void DocumentWillBeDestroyed(nsIDocument *aDocument);
|
||||
virtual void StyleSheetAdded(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
PRBool aDocumentSheet);
|
||||
virtual void StyleSheetRemoved(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
PRBool aDocumentSheet);
|
||||
|
||||
protected:
|
||||
PRInt32 mLength;
|
||||
nsIDocument* mDocument;
|
||||
};
|
||||
|
||||
class nsOnloadBlocker : public nsIRequest
|
||||
{
|
||||
public:
|
||||
nsOnloadBlocker() {}
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIREQUEST
|
||||
|
||||
private:
|
||||
~nsOnloadBlocker() {}
|
||||
};
|
||||
|
||||
// Base class for our document implementations.
|
||||
//
|
||||
// Note that this class *implements* nsIDOMXMLDocument, but it's not
|
||||
// really an nsIDOMXMLDocument. The reason for implementing
|
||||
// nsIDOMXMLDocument on this class is to avoid having to duplicate all
|
||||
// its inherited methods on document classes that *are*
|
||||
// nsIDOMXMLDocument's. nsDocument's QI should *not* claim to support
|
||||
// nsIDOMXMLDocument unless someone writes a real implementation of
|
||||
// the interface.
|
||||
class nsDocument : public nsIDocument,
|
||||
public nsIDOMXMLDocument, // inherits nsIDOMDocument
|
||||
public nsIDOMNSDocument,
|
||||
public nsIDOMDocumentEvent,
|
||||
public nsIDOM3DocumentEvent,
|
||||
public nsIDOMNSDocumentStyle,
|
||||
public nsIDOMDocumentView,
|
||||
public nsIDOMDocumentRange,
|
||||
public nsIDOMDocumentTraversal,
|
||||
public nsIDOMDocumentXBL,
|
||||
public nsIDOM3Document,
|
||||
public nsSupportsWeakReference,
|
||||
public nsIDOMEventReceiver,
|
||||
public nsIDOM3EventTarget,
|
||||
public nsIDOMNSEventTarget,
|
||||
public nsIScriptObjectPrincipal,
|
||||
public nsIRadioGroupContainer
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
virtual void Reset(nsIChannel *aChannel, nsILoadGroup *aLoadGroup);
|
||||
virtual void ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup);
|
||||
|
||||
// StartDocumentLoad is pure virtual so that subclasses must override it.
|
||||
// The nsDocument StartDocumentLoad does some setup, but does NOT set
|
||||
// *aDocListener; this is the job of subclasses.
|
||||
virtual nsresult StartDocumentLoad(const char* aCommand,
|
||||
nsIChannel* aChannel,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsISupports* aContainer,
|
||||
nsIStreamListener **aDocListener,
|
||||
PRBool aReset = PR_TRUE,
|
||||
nsIContentSink* aContentSink = nsnull) = 0;
|
||||
|
||||
virtual void StopDocumentLoad();
|
||||
|
||||
virtual void SetDocumentURI(nsIURI* aURI);
|
||||
|
||||
/**
|
||||
* Set the principal responsible for this document.
|
||||
*/
|
||||
virtual void SetPrincipal(nsIPrincipal *aPrincipal);
|
||||
|
||||
/**
|
||||
* Get the Content-Type of this document.
|
||||
*/
|
||||
// NS_IMETHOD GetContentType(nsAString& aContentType);
|
||||
// Already declared in nsIDOMNSDocument
|
||||
|
||||
/**
|
||||
* Set the Content-Type of this document.
|
||||
*/
|
||||
virtual void SetContentType(const nsAString& aContentType);
|
||||
|
||||
virtual nsresult SetBaseURI(nsIURI* aURI);
|
||||
|
||||
/**
|
||||
* Get/Set the base target of a link in a document.
|
||||
*/
|
||||
virtual void GetBaseTarget(nsAString &aBaseTarget) const;
|
||||
virtual void SetBaseTarget(const nsAString &aBaseTarget);
|
||||
|
||||
/**
|
||||
* Return a standard name for the document's character set. This will
|
||||
* trigger a startDocumentLoad if necessary to answer the question.
|
||||
*/
|
||||
virtual void SetDocumentCharacterSet(const nsACString& aCharSetID);
|
||||
|
||||
/**
|
||||
* Add an observer that gets notified whenever the charset changes.
|
||||
*/
|
||||
virtual nsresult AddCharSetObserver(nsIObserver* aObserver);
|
||||
|
||||
/**
|
||||
* Remove a charset observer.
|
||||
*/
|
||||
virtual void RemoveCharSetObserver(nsIObserver* aObserver);
|
||||
|
||||
/**
|
||||
* Access HTTP header data (this may also get set from other sources, like
|
||||
* HTML META tags).
|
||||
*/
|
||||
virtual void GetHeaderData(nsIAtom* aHeaderField, nsAString& aData) const;
|
||||
virtual void SetHeaderData(nsIAtom* aheaderField,
|
||||
const nsAString& aData);
|
||||
|
||||
/**
|
||||
* Create a new presentation shell that will use aContext for
|
||||
* it's presentation context (presentation context's <b>must not</b> be
|
||||
* shared among multiple presentation shell's).
|
||||
*/
|
||||
virtual nsresult CreateShell(nsPresContext* aContext,
|
||||
nsIViewManager* aViewManager,
|
||||
nsStyleSet* aStyleSet,
|
||||
nsIPresShell** aInstancePtrResult);
|
||||
virtual PRBool DeleteShell(nsIPresShell* aShell);
|
||||
virtual PRUint32 GetNumberOfShells() const;
|
||||
virtual nsIPresShell *GetShellAt(PRUint32 aIndex) const;
|
||||
virtual void SetShellsHidden(PRBool aHide);
|
||||
|
||||
virtual nsresult SetSubDocumentFor(nsIContent *aContent,
|
||||
nsIDocument* aSubDoc);
|
||||
virtual nsIDocument* GetSubDocumentFor(nsIContent *aContent) const;
|
||||
virtual nsIContent* FindContentForSubDocument(nsIDocument *aDocument) const;
|
||||
|
||||
/**
|
||||
* Get the style sheets owned by this document.
|
||||
* These are ordered, highest priority last
|
||||
*/
|
||||
virtual PRInt32 GetNumberOfStyleSheets() const;
|
||||
virtual nsIStyleSheet* GetStyleSheetAt(PRInt32 aIndex) const;
|
||||
virtual PRInt32 GetIndexOfStyleSheet(nsIStyleSheet* aSheet) const;
|
||||
virtual void AddStyleSheet(nsIStyleSheet* aSheet);
|
||||
virtual void RemoveStyleSheet(nsIStyleSheet* aSheet);
|
||||
|
||||
virtual void UpdateStyleSheets(nsCOMArray<nsIStyleSheet>& aOldSheets,
|
||||
nsCOMArray<nsIStyleSheet>& aNewSheets);
|
||||
virtual void AddStyleSheetToStyleSets(nsIStyleSheet* aSheet);
|
||||
virtual void RemoveStyleSheetFromStyleSets(nsIStyleSheet* aSheet);
|
||||
|
||||
virtual void InsertStyleSheetAt(nsIStyleSheet* aSheet, PRInt32 aIndex);
|
||||
virtual void SetStyleSheetApplicableState(nsIStyleSheet* aSheet,
|
||||
PRBool aApplicable);
|
||||
|
||||
virtual PRInt32 GetNumberOfCatalogStyleSheets() const;
|
||||
virtual nsIStyleSheet* GetCatalogStyleSheetAt(PRInt32 aIndex) const;
|
||||
virtual void AddCatalogStyleSheet(nsIStyleSheet* aSheet);
|
||||
virtual void EnsureCatalogStyleSheet(const char *aStyleSheetURI);
|
||||
|
||||
virtual nsIChannel* GetChannel() const {
|
||||
return mChannel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get this document's attribute stylesheet. May return null if
|
||||
* there isn't one.
|
||||
*/
|
||||
virtual nsHTMLStyleSheet* GetAttributeStyleSheet() const {
|
||||
return mAttrStyleSheet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get this document's inline style sheet. May return null if there
|
||||
* isn't one
|
||||
*/
|
||||
virtual nsIHTMLCSSStyleSheet* GetInlineStyleSheet() const {
|
||||
return mStyleAttrStyleSheet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the object from which a document can get a script context.
|
||||
* This is the context within which all scripts (during document
|
||||
* creation and during event handling) will run.
|
||||
*/
|
||||
virtual nsIScriptGlobalObject* GetScriptGlobalObject() const;
|
||||
virtual void SetScriptGlobalObject(nsIScriptGlobalObject* aGlobalObject);
|
||||
|
||||
virtual nsIScriptGlobalObject* GetScopeObject();
|
||||
|
||||
/**
|
||||
* Return the window containing the document (the outer window).
|
||||
*/
|
||||
virtual nsPIDOMWindow *GetWindow();
|
||||
|
||||
/**
|
||||
* Return the inner window used as the script compilation scope for
|
||||
* this document. If you're not absolutely sure you need this, use
|
||||
* GetWindow().
|
||||
*/
|
||||
virtual nsPIDOMWindow *GetInnerWindow();
|
||||
|
||||
/**
|
||||
* Get the script loader for this document
|
||||
*/
|
||||
virtual nsIScriptLoader* GetScriptLoader();
|
||||
|
||||
/**
|
||||
* Add a new observer of document change notifications. Whenever
|
||||
* content is changed, appended, inserted or removed the observers are
|
||||
* informed.
|
||||
*/
|
||||
virtual void AddObserver(nsIDocumentObserver* aObserver);
|
||||
|
||||
/**
|
||||
* Remove an observer of document change notifications. This will
|
||||
* return false if the observer cannot be found.
|
||||
*/
|
||||
virtual PRBool RemoveObserver(nsIDocumentObserver* aObserver);
|
||||
|
||||
// Observation hooks used to propagate notifications to document
|
||||
// observers.
|
||||
virtual void BeginUpdate(nsUpdateType aUpdateType);
|
||||
virtual void EndUpdate(nsUpdateType aUpdateType);
|
||||
virtual void BeginLoad();
|
||||
virtual void EndLoad();
|
||||
virtual void CharacterDataChanged(nsIContent* aContent,
|
||||
PRBool aAppend);
|
||||
virtual void ContentStatesChanged(nsIContent* aContent1,
|
||||
nsIContent* aContent2,
|
||||
PRInt32 aStateMask);
|
||||
|
||||
virtual void AttributeWillChange(nsIContent* aChild,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aAttribute);
|
||||
virtual void AttributeChanged(nsIContent* aChild,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aModType);
|
||||
virtual void ContentAppended(nsIContent* aContainer,
|
||||
PRInt32 aNewIndexInContainer);
|
||||
virtual void ContentInserted(nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer);
|
||||
virtual void ContentRemoved(nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer);
|
||||
|
||||
virtual void StyleRuleChanged(nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aOldStyleRule,
|
||||
nsIStyleRule* aNewStyleRule);
|
||||
virtual void StyleRuleAdded(nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule);
|
||||
virtual void StyleRuleRemoved(nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule);
|
||||
|
||||
virtual void FlushPendingNotifications(mozFlushType aType);
|
||||
virtual nsIScriptEventManager* GetScriptEventManager();
|
||||
virtual void SetXMLDeclaration(const PRUnichar *aVersion,
|
||||
const PRUnichar *aEncoding,
|
||||
const PRInt32 aStandalone);
|
||||
virtual void GetXMLDeclaration(nsAString& aVersion,
|
||||
nsAString& aEncoding,
|
||||
nsAString& Standalone);
|
||||
virtual PRBool IsScriptEnabled();
|
||||
|
||||
virtual void OnPageShow(PRBool aPersisted);
|
||||
virtual void OnPageHide(PRBool aPersisted);
|
||||
|
||||
// nsINode
|
||||
virtual PRBool IsNodeOfType(PRUint32 aFlags) const;
|
||||
virtual nsIContent *GetChildAt(PRUint32 aIndex) const;
|
||||
virtual PRInt32 IndexOf(nsINode* aPossibleChild) const;
|
||||
virtual PRUint32 GetChildCount() const;
|
||||
virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
|
||||
PRBool aNotify);
|
||||
virtual nsresult AppendChildTo(nsIContent* aKid, PRBool aNotify);
|
||||
virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
|
||||
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
|
||||
virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor);
|
||||
virtual nsresult DispatchDOMEvent(nsEvent* aEvent, nsIDOMEvent* aDOMEvent,
|
||||
nsPresContext* aPresContext,
|
||||
nsEventStatus* aEventStatus);
|
||||
|
||||
// nsIRadioGroupContainer
|
||||
NS_IMETHOD WalkRadioGroup(const nsAString& aName,
|
||||
nsIRadioVisitor* aVisitor,
|
||||
PRBool aFlushContent);
|
||||
NS_IMETHOD SetCurrentRadioButton(const nsAString& aName,
|
||||
nsIDOMHTMLInputElement* aRadio);
|
||||
NS_IMETHOD GetCurrentRadioButton(const nsAString& aName,
|
||||
nsIDOMHTMLInputElement** aRadio);
|
||||
NS_IMETHOD GetPositionInGroup(nsIDOMHTMLInputElement *aRadio,
|
||||
PRInt32 *aPositionIndex,
|
||||
PRInt32 *aItemsInGroup);
|
||||
NS_IMETHOD GetNextRadioButton(const nsAString& aName,
|
||||
const PRBool aPrevious,
|
||||
nsIDOMHTMLInputElement* aFocusedRadio,
|
||||
nsIDOMHTMLInputElement** aRadioOut);
|
||||
NS_IMETHOD AddToRadioGroup(const nsAString& aName,
|
||||
nsIFormControl* aRadio);
|
||||
NS_IMETHOD RemoveFromRadioGroup(const nsAString& aName,
|
||||
nsIFormControl* aRadio);
|
||||
|
||||
// for radio group
|
||||
nsresult GetRadioGroup(const nsAString& aName,
|
||||
nsRadioGroupStruct **aRadioGroup);
|
||||
|
||||
// nsIDOMGCParticipant interface methods
|
||||
virtual nsIDOMGCParticipant* GetSCCIndex();
|
||||
virtual void AppendReachableList(nsCOMArray<nsIDOMGCParticipant>& aArray);
|
||||
|
||||
// nsIDOMNode
|
||||
NS_DECL_NSIDOMNODE
|
||||
|
||||
// nsIDOM3Node
|
||||
NS_DECL_NSIDOM3NODE
|
||||
|
||||
// nsIDOMDocument
|
||||
NS_DECL_NSIDOMDOCUMENT
|
||||
|
||||
// nsIDOM3Document
|
||||
NS_DECL_NSIDOM3DOCUMENT
|
||||
|
||||
// nsIDOMXMLDocument
|
||||
NS_DECL_NSIDOMXMLDOCUMENT
|
||||
|
||||
// nsIDOMNSDocument
|
||||
NS_DECL_NSIDOMNSDOCUMENT
|
||||
|
||||
// nsIDOMDocumentEvent
|
||||
NS_DECL_NSIDOMDOCUMENTEVENT
|
||||
|
||||
// nsIDOM3DocumentEvent
|
||||
NS_DECL_NSIDOM3DOCUMENTEVENT
|
||||
|
||||
// nsIDOMDocumentStyle
|
||||
NS_DECL_NSIDOMDOCUMENTSTYLE
|
||||
|
||||
// nsIDOMNSDocumentStyle
|
||||
NS_DECL_NSIDOMNSDOCUMENTSTYLE
|
||||
|
||||
// nsIDOMDocumentView
|
||||
NS_DECL_NSIDOMDOCUMENTVIEW
|
||||
|
||||
// nsIDOMDocumentRange
|
||||
NS_DECL_NSIDOMDOCUMENTRANGE
|
||||
|
||||
// nsIDOMDocumentTraversal
|
||||
NS_DECL_NSIDOMDOCUMENTTRAVERSAL
|
||||
|
||||
// nsIDOMDocumentXBL
|
||||
NS_DECL_NSIDOMDOCUMENTXBL
|
||||
|
||||
// nsIDOMEventReceiver interface
|
||||
NS_IMETHOD AddEventListenerByIID(nsIDOMEventListener *aListener,
|
||||
const nsIID& aIID);
|
||||
NS_IMETHOD RemoveEventListenerByIID(nsIDOMEventListener *aListener,
|
||||
const nsIID& aIID);
|
||||
NS_IMETHOD GetListenerManager(PRBool aCreateIfNotFound,
|
||||
nsIEventListenerManager** aResult);
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent *aEvent);
|
||||
NS_IMETHOD GetSystemEventGroup(nsIDOMEventGroup** aGroup);
|
||||
|
||||
// nsIDOMEventTarget
|
||||
NS_DECL_NSIDOMEVENTTARGET
|
||||
|
||||
// nsIDOM3EventTarget
|
||||
NS_DECL_NSIDOM3EVENTTARGET
|
||||
|
||||
// nsIDOMNSEventTarget
|
||||
NS_DECL_NSIDOMNSEVENTTARGET
|
||||
|
||||
// nsIScriptObjectPrincipal
|
||||
virtual nsIPrincipal* GetPrincipal();
|
||||
|
||||
virtual nsresult Init();
|
||||
|
||||
virtual nsresult AddXMLEventsContent(nsIContent * aXMLEventsElement);
|
||||
|
||||
virtual nsresult CreateElem(nsIAtom *aName, nsIAtom *aPrefix,
|
||||
PRInt32 aNamespaceID,
|
||||
PRBool aDocumentDefaultType,
|
||||
nsIContent **aResult);
|
||||
|
||||
virtual NS_HIDDEN_(nsresult) Sanitize();
|
||||
|
||||
virtual NS_HIDDEN_(void) EnumerateSubDocuments(nsSubDocEnumFunc aCallback,
|
||||
void *aData);
|
||||
|
||||
virtual NS_HIDDEN_(PRBool) CanSavePresentation(nsIRequest *aNewRequest);
|
||||
virtual NS_HIDDEN_(void) Destroy();
|
||||
virtual NS_HIDDEN_(already_AddRefed<nsILayoutHistoryState>) GetLayoutHistoryState() const;
|
||||
|
||||
virtual NS_HIDDEN_(void) BlockOnload();
|
||||
virtual NS_HIDDEN_(void) UnblockOnload(PRBool aFireSync);
|
||||
|
||||
virtual NS_HIDDEN_(void) AddStyleRelevantLink(nsIContent* aContent, nsIURI* aURI);
|
||||
virtual NS_HIDDEN_(void) ForgetLink(nsIContent* aContent);
|
||||
virtual NS_HIDDEN_(void) NotifyURIVisitednessChanged(nsIURI* aURI);
|
||||
|
||||
NS_HIDDEN_(void) ClearBoxObjectFor(nsIContent* aContent);
|
||||
|
||||
protected:
|
||||
|
||||
void DispatchContentLoadedEvents();
|
||||
|
||||
void RetrieveRelevantHeaders(nsIChannel *aChannel);
|
||||
|
||||
static PRBool TryChannelCharset(nsIChannel *aChannel,
|
||||
PRInt32& aCharsetSource,
|
||||
nsACString& aCharset);
|
||||
|
||||
void UpdateLinkMap();
|
||||
// Call this before the document does something that will unbind all content.
|
||||
// That will stop us from resolving URIs for all links as they are removed.
|
||||
void DestroyLinkMap();
|
||||
|
||||
nsresult doCreateShell(nsPresContext* aContext,
|
||||
nsIViewManager* aViewManager, nsStyleSet* aStyleSet,
|
||||
nsCompatibility aCompatMode,
|
||||
nsIPresShell** aInstancePtrResult);
|
||||
|
||||
nsresult ResetStylesheetsToURI(nsIURI* aURI);
|
||||
virtual nsStyleSet::sheetType GetAttrSheetType();
|
||||
void FillStyleSet(nsStyleSet* aStyleSet);
|
||||
|
||||
nsresult CreateElement(nsINodeInfo *aNodeInfo, PRInt32 aElementType,
|
||||
nsIContent** aResult);
|
||||
|
||||
// Return whether all the presshells for this document are safe to flush
|
||||
PRBool IsSafeToFlush() const;
|
||||
|
||||
virtual PRInt32 GetDefaultNamespaceID() const
|
||||
{
|
||||
return kNameSpaceID_None;
|
||||
};
|
||||
|
||||
// Dispatch an event to the ScriptGlobalObject for this document
|
||||
void DispatchEventToWindow(nsEvent *aEvent);
|
||||
|
||||
// Copy |mObservers| to an nsCOMArray in preparation so we can notify
|
||||
// the list of observers set up at one point in time.
|
||||
void CopyObserversTo(nsCOMArray<nsIDocumentObserver>& aDestination);
|
||||
|
||||
#define NS_DOCUMENT_NOTIFY_OBSERVERS(func_, params_) \
|
||||
do { \
|
||||
nsCOMArray<nsIDocumentObserver> observers_; \
|
||||
CopyObserversTo(observers_); \
|
||||
for (PRInt32 i_ = observers_.Count() - 1; i_ >= 0; --i_) { \
|
||||
observers_[i_] -> func_ params_ ; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#ifdef DEBUG
|
||||
void VerifyRootContentState();
|
||||
#endif
|
||||
|
||||
nsDocument(const char* aContentType);
|
||||
virtual ~nsDocument();
|
||||
|
||||
nsCString mReferrer;
|
||||
nsString mLastModified;
|
||||
|
||||
nsVoidArray mCharSetObservers;
|
||||
|
||||
PLDHashTable *mSubDocuments;
|
||||
|
||||
// Array of owning references to all children
|
||||
nsAttrAndChildArray mChildren;
|
||||
|
||||
// Pointer to our parser if we're currently in the process of being
|
||||
// parsed into.
|
||||
nsCOMPtr<nsIParser> mParser;
|
||||
|
||||
nsCOMArray<nsIStyleSheet> mStyleSheets;
|
||||
nsCOMArray<nsIStyleSheet> mCatalogSheets;
|
||||
|
||||
// Basically always has at least 1 entry
|
||||
nsAutoVoidArray mObservers;
|
||||
|
||||
// The document's script global object, the object from which the
|
||||
// document can get its script context and scope. This is the
|
||||
// *inner* window object.
|
||||
nsCOMPtr<nsIScriptGlobalObject> mScriptGlobalObject;
|
||||
|
||||
// Weak reference to the scope object (aka the script global object)
|
||||
// that, unlike mScriptGlobalObject, is never unset once set. This
|
||||
// is a weak reference to avoid leaks due to circular references.
|
||||
nsWeakPtr mScopeObject;
|
||||
|
||||
nsCOMPtr<nsIEventListenerManager> mListenerManager;
|
||||
nsCOMPtr<nsIDOMStyleSheetList> mDOMStyleSheets;
|
||||
nsCOMPtr<nsIScriptLoader> mScriptLoader;
|
||||
nsDocHeaderData* mHeaderData;
|
||||
|
||||
nsRefPtr<nsChildContentList> mChildNodes;
|
||||
|
||||
nsHashtable mRadioGroups;
|
||||
|
||||
// True if the document has been detached from its content viewer.
|
||||
PRPackedBool mIsGoingAway:1;
|
||||
// True if the document is being destroyed.
|
||||
PRPackedBool mInDestructor:1;
|
||||
// True if the document "page" is not hidden
|
||||
PRPackedBool mVisible:1;
|
||||
|
||||
PRPackedBool mShellsAreHidden:1;
|
||||
|
||||
PRUint8 mXMLDeclarationBits;
|
||||
|
||||
PRUint8 mDefaultElementType;
|
||||
|
||||
nsInterfaceHashtable<nsISupportsHashKey, nsPIBoxObject> *mBoxObjectTable;
|
||||
|
||||
// The channel that got passed to StartDocumentLoad(), if any
|
||||
nsCOMPtr<nsIChannel> mChannel;
|
||||
nsRefPtr<nsHTMLStyleSheet> mAttrStyleSheet;
|
||||
nsCOMPtr<nsIHTMLCSSStyleSheet> mStyleAttrStyleSheet;
|
||||
nsRefPtr<nsXMLEventsManager> mXMLEventsManager;
|
||||
|
||||
nsCOMPtr<nsIScriptEventManager> mScriptEventManager;
|
||||
|
||||
nsString mBaseTarget;
|
||||
|
||||
private:
|
||||
friend class nsUnblockOnloadEvent;
|
||||
|
||||
void PostUnblockOnloadEvent();
|
||||
void DoUnblockOnload();
|
||||
|
||||
// These are not implemented and not supported.
|
||||
nsDocument(const nsDocument& aOther);
|
||||
nsDocument& operator=(const nsDocument& aOther);
|
||||
|
||||
nsSmallVoidArray mPresShells;
|
||||
|
||||
nsCOMPtr<nsISupports> mXPathEvaluatorTearoff;
|
||||
|
||||
// The layout history state that should be used by nodes in this
|
||||
// document. We only actually store a pointer to it when:
|
||||
// 1) We have no script global object.
|
||||
// 2) We haven't had Destroy() called on us yet.
|
||||
nsCOMPtr<nsILayoutHistoryState> mLayoutHistoryState;
|
||||
|
||||
PRUint32 mOnloadBlockCount;
|
||||
nsCOMPtr<nsIRequest> mOnloadBlocker;
|
||||
|
||||
// A map from unvisited URI hashes to content elements
|
||||
nsTHashtable<nsUint32ToContentHashEntry> mLinkMap;
|
||||
// URIs whose visitedness has changed while we were hidden
|
||||
nsCOMArray<nsIURI> mVisitednessChangedURIs;
|
||||
};
|
||||
|
||||
|
||||
#endif /* nsDocument_h___ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,352 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Implementation of DOM Core's nsIDOMDocumentFragment.
|
||||
*/
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMDocumentFragment.h"
|
||||
#include "nsGenericElement.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsINodeInfo.h"
|
||||
#include "nsNodeInfoManager.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMAttr.h"
|
||||
#include "nsDOMError.h"
|
||||
#include "nsIDOM3Node.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "nsDOMString.h"
|
||||
#include "nsIDOMUserDataHandler.h"
|
||||
|
||||
class nsDocumentFragment : public nsGenericElement,
|
||||
public nsIDOMDocumentFragment,
|
||||
public nsIDOM3Node
|
||||
{
|
||||
public:
|
||||
nsDocumentFragment(nsINodeInfo *aNodeInfo);
|
||||
virtual ~nsDocumentFragment();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// interface nsIDOMDocumentFragment
|
||||
NS_IMETHOD GetNodeName(nsAString& aNodeName)
|
||||
{ return nsGenericElement::GetNodeName(aNodeName); }
|
||||
NS_IMETHOD GetNodeValue(nsAString& aNodeValue)
|
||||
{ return nsGenericElement::GetNodeValue(aNodeValue); }
|
||||
NS_IMETHOD SetNodeValue(const nsAString& aNodeValue)
|
||||
{ return nsGenericElement::SetNodeValue(aNodeValue); }
|
||||
NS_IMETHOD GetNodeType(PRUint16* aNodeType);
|
||||
NS_IMETHOD GetParentNode(nsIDOMNode** aParentNode)
|
||||
{ return nsGenericElement::GetParentNode(aParentNode); }
|
||||
NS_IMETHOD GetChildNodes(nsIDOMNodeList** aChildNodes)
|
||||
{ return nsGenericElement::GetChildNodes(aChildNodes); }
|
||||
NS_IMETHOD GetFirstChild(nsIDOMNode** aFirstChild)
|
||||
{ return nsGenericElement::GetFirstChild(aFirstChild); }
|
||||
NS_IMETHOD GetLastChild(nsIDOMNode** aLastChild)
|
||||
{ return nsGenericElement::GetLastChild(aLastChild); }
|
||||
NS_IMETHOD GetPreviousSibling(nsIDOMNode** aPreviousSibling)
|
||||
{ return nsGenericElement::GetPreviousSibling(aPreviousSibling); }
|
||||
NS_IMETHOD GetNextSibling(nsIDOMNode** aNextSibling)
|
||||
{ return nsGenericElement::GetNextSibling(aNextSibling); }
|
||||
NS_IMETHOD GetAttributes(nsIDOMNamedNodeMap** aAttributes)
|
||||
{
|
||||
*aAttributes = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD GetOwnerDocument(nsIDOMDocument** aOwnerDocument)
|
||||
{ return nsGenericElement::GetOwnerDocument(aOwnerDocument); }
|
||||
NS_IMETHOD InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild,
|
||||
nsIDOMNode** aReturn)
|
||||
{ return nsGenericElement::InsertBefore(aNewChild, aRefChild, aReturn); }
|
||||
NS_IMETHOD ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild,
|
||||
nsIDOMNode** aReturn)
|
||||
{ return nsGenericElement::ReplaceChild(aNewChild, aOldChild, aReturn); }
|
||||
NS_IMETHOD RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
||||
{ return nsGenericElement::RemoveChild(aOldChild, aReturn); }
|
||||
NS_IMETHOD AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn)
|
||||
{ return nsGenericElement::AppendChild(aNewChild, aReturn); }
|
||||
NS_IMETHOD HasChildNodes(PRBool* aReturn)
|
||||
{ return nsGenericElement::HasChildNodes(aReturn); }
|
||||
NS_IMETHOD HasAttributes(PRBool* aReturn)
|
||||
{ return nsGenericElement::HasAttributes(aReturn); }
|
||||
NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn);
|
||||
NS_IMETHOD GetPrefix(nsAString& aPrefix)
|
||||
{ return nsGenericElement::GetPrefix(aPrefix); }
|
||||
NS_IMETHOD SetPrefix(const nsAString& aPrefix);
|
||||
NS_IMETHOD GetNamespaceURI(nsAString& aNamespaceURI)
|
||||
{ return nsGenericElement::GetNamespaceURI(aNamespaceURI); }
|
||||
NS_IMETHOD GetLocalName(nsAString& aLocalName)
|
||||
{ return nsGenericElement::GetLocalName(aLocalName); }
|
||||
NS_IMETHOD Normalize()
|
||||
{ return nsGenericElement::Normalize(); }
|
||||
NS_IMETHOD IsSupported(const nsAString& aFeature,
|
||||
const nsAString& aVersion,
|
||||
PRBool* aReturn)
|
||||
{ return nsGenericElement::IsSupported(aFeature, aVersion, aReturn); }
|
||||
|
||||
// nsIDOM3Node
|
||||
NS_DECL_NSIDOM3NODE
|
||||
|
||||
// nsIContent
|
||||
nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
const nsAString& aValue, PRBool aNotify)
|
||||
{
|
||||
return SetAttr(aNameSpaceID, aName, nsnull, aValue, aNotify);
|
||||
}
|
||||
virtual nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
nsIAtom* aPrefix, const nsAString& aValue,
|
||||
PRBool aNotify)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
virtual PRBool GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
nsAString& aResult) const
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
||||
PRBool aNotify)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
virtual const nsAttrName* GetAttrNameAt(PRUint32 aIndex) const
|
||||
{
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
virtual PRBool IsNodeOfType(PRUint32 aFlags) const;
|
||||
|
||||
protected:
|
||||
nsresult Clone(nsINodeInfo *aNodeInfo, PRBool aDeep,
|
||||
nsIContent **aResult) const;
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewDocumentFragment(nsIDOMDocumentFragment** aInstancePtrResult,
|
||||
nsNodeInfoManager *aNodeInfoManager)
|
||||
{
|
||||
NS_ENSURE_ARG(aNodeInfoManager);
|
||||
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nsresult rv =
|
||||
aNodeInfoManager->GetNodeInfo(nsLayoutAtoms::documentFragmentNodeName,
|
||||
nsnull, kNameSpaceID_None,
|
||||
getter_AddRefs(nodeInfo));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsDocumentFragment *it = new nsDocumentFragment(nodeInfo);
|
||||
if (!it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
NS_ADDREF(*aInstancePtrResult = it);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsDocumentFragment::nsDocumentFragment(nsINodeInfo *aNodeInfo)
|
||||
: nsGenericElement(aNodeInfo)
|
||||
{
|
||||
}
|
||||
|
||||
nsDocumentFragment::~nsDocumentFragment()
|
||||
{
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsDocumentFragment::IsNodeOfType(PRUint32 aFlags) const
|
||||
{
|
||||
return !(aFlags & ~(eCONTENT | eDOCUMENT_FRAGMENT));
|
||||
}
|
||||
|
||||
// QueryInterface implementation for nsDocumentFragment
|
||||
NS_INTERFACE_MAP_BEGIN(nsDocumentFragment)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMDocumentFragment)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOM3Node)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIContent)
|
||||
NS_INTERFACE_MAP_ENTRY(nsINode)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContent)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(DocumentFragment)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(nsDocumentFragment)
|
||||
NS_IMPL_RELEASE(nsDocumentFragment)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocumentFragment::GetNodeType(PRUint16* aNodeType)
|
||||
{
|
||||
*aNodeType = (PRUint16)nsIDOMNode::DOCUMENT_FRAGMENT_NODE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocumentFragment::SetPrefix(const nsAString& aPrefix)
|
||||
{
|
||||
return NS_ERROR_DOM_NAMESPACE_ERR;
|
||||
}
|
||||
|
||||
NS_IMPL_DOM_CLONENODE(nsDocumentFragment)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocumentFragment::GetBaseURI(nsAString& aURI)
|
||||
{
|
||||
aURI.Truncate();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocumentFragment::LookupPrefix(const nsAString& aNamespaceURI,
|
||||
nsAString& aPrefix)
|
||||
{
|
||||
aPrefix.Truncate();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocumentFragment::LookupNamespaceURI(const nsAString& aNamespacePrefix,
|
||||
nsAString& aNamespaceURI)
|
||||
{
|
||||
aNamespaceURI.Truncate();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocumentFragment::IsDefaultNamespace(const nsAString& aNamespaceURI,
|
||||
PRBool* aReturn)
|
||||
{
|
||||
*aReturn = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocumentFragment::CompareDocumentPosition(nsIDOMNode* aOther,
|
||||
PRUint16* aReturn)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aOther);
|
||||
|
||||
nsCOMPtr<nsINode> other = do_QueryInterface(aOther);
|
||||
NS_ENSURE_TRUE(other, NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
|
||||
*aReturn = nsContentUtils::ComparePosition(other, this);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocumentFragment::IsSameNode(nsIDOMNode* aOther,
|
||||
PRBool* aReturn)
|
||||
{
|
||||
PRBool sameNode = PR_FALSE;
|
||||
|
||||
if (NS_STATIC_CAST(nsIDOMNode*, this) == aOther) {
|
||||
sameNode = PR_TRUE;
|
||||
}
|
||||
|
||||
*aReturn = sameNode;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocumentFragment::IsEqualNode(nsIDOMNode* aOther, PRBool* aReturn)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("nsDocumentFragment::IsEqualNode()");
|
||||
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocumentFragment::GetFeature(const nsAString& aFeature,
|
||||
const nsAString& aVersion,
|
||||
nsISupports** aReturn)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("nsDocumentFragment::GetFeature()");
|
||||
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocumentFragment::SetUserData(const nsAString& aKey,
|
||||
nsIVariant* aData,
|
||||
nsIDOMUserDataHandler* aHandler,
|
||||
nsIVariant** aResult)
|
||||
{
|
||||
nsCOMPtr<nsIAtom> key = do_GetAtom(aKey);
|
||||
if (!key) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return nsContentUtils::SetUserData(this, key, aData, aHandler, aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocumentFragment::GetUserData(const nsAString& aKey,
|
||||
nsIVariant** aResult)
|
||||
{
|
||||
nsIDocument *document = GetOwnerDoc();
|
||||
NS_ENSURE_TRUE(document, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIAtom> key = do_GetAtom(aKey);
|
||||
if (!key) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
*aResult = NS_STATIC_CAST(nsIVariant*, GetProperty(DOM_USER_DATA, key));
|
||||
NS_IF_ADDREF(*aResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocumentFragment::GetTextContent(nsAString &aTextContent)
|
||||
{
|
||||
return nsNode3Tearoff::GetTextContent(this, aTextContent);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocumentFragment::SetTextContent(const nsAString& aTextContent)
|
||||
{
|
||||
return nsNode3Tearoff::SetTextContent(this, aTextContent);
|
||||
}
|
||||
|
||||
@@ -1,550 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=2 sw=2 et tw=78: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Johnny Stenback <jst@netscape.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Class for managing loading of a subframe (creation of the docshell,
|
||||
* handling of loads in it, recursion-checking).
|
||||
*/
|
||||
|
||||
#include "nsIDOMHTMLIFrameElement.h"
|
||||
#include "nsIDOMHTMLFrameElement.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
#include "nsIChromeEventHandler.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIDocShellTreeNode.h"
|
||||
#include "nsIDocShellTreeOwner.h"
|
||||
#include "nsIDocShellLoadInfo.h"
|
||||
#include "nsIBaseWindow.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsFrameLoader.h"
|
||||
|
||||
#include "nsIURI.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
|
||||
// Bug 136580: Limit to the number of nested content frames that can have the
|
||||
// same URL. This is to stop content that is recursively loading
|
||||
// itself. Note that "#foo" on the end of URL doesn't affect
|
||||
// whether it's considered identical, but "?foo" or ";foo" are
|
||||
// considered and compared.
|
||||
// Bug 228829: Limit this to 1, like IE does.
|
||||
#define MAX_SAME_URL_CONTENT_FRAMES 1
|
||||
|
||||
// Bug 8065: Limit content frame depth to some reasonable level. This
|
||||
// does not count chrome frames when determining depth, nor does it
|
||||
// prevent chrome recursion. Number is fairly arbitrary, but meant to
|
||||
// keep number of shells to a reasonable number on accidental recursion with a
|
||||
// small (but not 1) branching factor. With large branching factors the number
|
||||
// of shells can rapidly become huge and run us out of memory. To solve that,
|
||||
// we'd need to re-institute a fixed version of bug 98158.
|
||||
#define MAX_DEPTH_CONTENT_FRAMES 10
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsFrameLoader, nsIFrameLoader)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFrameLoader::LoadFrame()
|
||||
{
|
||||
NS_ENSURE_TRUE(mOwnerContent, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
nsAutoString src;
|
||||
GetURL(src);
|
||||
|
||||
src.Trim(" \t\n\r");
|
||||
|
||||
if (src.IsEmpty()) {
|
||||
src.AssignLiteral("about:blank");
|
||||
}
|
||||
|
||||
nsIDocument* doc = mOwnerContent->GetOwnerDoc();
|
||||
if (!doc) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> base_uri = mOwnerContent->GetBaseURI();
|
||||
const nsAFlatCString &doc_charset = doc->GetDocumentCharacterSet();
|
||||
const char *charset = doc_charset.IsEmpty() ? nsnull : doc_charset.get();
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = NS_NewURI(getter_AddRefs(uri), src, charset, base_uri);
|
||||
|
||||
// If the URI was malformed, try to recover by loading about:blank.
|
||||
if (rv == NS_ERROR_MALFORMED_URI) {
|
||||
rv = NS_NewURI(getter_AddRefs(uri), NS_LITERAL_STRING("about:blank"),
|
||||
charset);
|
||||
}
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return LoadURI(uri);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFrameLoader::LoadURI(nsIURI* aURI)
|
||||
{
|
||||
NS_PRECONDITION(aURI, "Null URI?");
|
||||
if (!aURI)
|
||||
return NS_ERROR_INVALID_POINTER;
|
||||
|
||||
nsIDocument* doc = mOwnerContent->GetOwnerDoc();
|
||||
if (!doc) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult rv = EnsureDocShell();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
|
||||
mDocShell->CreateLoadInfo(getter_AddRefs(loadInfo));
|
||||
NS_ENSURE_TRUE(loadInfo, NS_ERROR_FAILURE);
|
||||
|
||||
// Check for security. The fun part is trying to figure out what principals
|
||||
// to use. The way I figure it, if we're doing a LoadFrame() accidentally
|
||||
// (eg someone created a frame/iframe node, we're being parsed, XUL iframes
|
||||
// are being reframed, etc.) then we definitely want to use the node
|
||||
// principal of mOwnerContent for security checks. If, on the other hand,
|
||||
// someone's setting the src on our owner content, or created it via script,
|
||||
// or whatever, then they can clearly access it... and we should still use
|
||||
// the principal of mOwnerContent. I don't think that leads to privilege
|
||||
// escalation, and it's reasonably guaranteed to not lead to XSS issues
|
||||
// (since caller can already access mOwnerContent in this case). So just use
|
||||
// the principal of mOwnerContent no matter what. If script wants to run
|
||||
// things with its own permissions, which differ from those of mOwnerContent
|
||||
// (which means the script is privileged in some way) it should set
|
||||
// window.location instead.
|
||||
nsIScriptSecurityManager *secMan = nsContentUtils::GetSecurityManager();
|
||||
|
||||
// Get our principal
|
||||
nsIPrincipal* principal = mOwnerContent->NodePrincipal();
|
||||
NS_ASSERTION(principal == doc->NodePrincipal(),
|
||||
"Principal mismatch. Should not happen");
|
||||
|
||||
// Check if we are allowed to load absURL
|
||||
rv = secMan->CheckLoadURIWithPrincipal(principal, aURI,
|
||||
nsIScriptSecurityManager::STANDARD);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv; // We're not
|
||||
}
|
||||
|
||||
// Bail out if this is an infinite recursion scenario
|
||||
rv = CheckForRecursiveLoad(aURI);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Is our principal the system principal?
|
||||
nsCOMPtr<nsIPrincipal> sysPrin;
|
||||
rv = secMan->GetSystemPrincipal(getter_AddRefs(sysPrin));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (principal == sysPrin) {
|
||||
// We're a chrome node. Belt and braces -- inherit the principal for this
|
||||
// load instead of just forcing the system principal. That way if we have
|
||||
// something loaded already the principal used will be that of what we
|
||||
// already have loaded.
|
||||
loadInfo->SetInheritOwner(PR_TRUE);
|
||||
|
||||
// Also, in this case we don't set a referrer, just in case.
|
||||
} else {
|
||||
// We'll use our principal, not that of the document loaded inside us.
|
||||
// This is very important; needed to prevent XSS attacks on documents
|
||||
// loaded in subframes!
|
||||
loadInfo->SetOwner(principal);
|
||||
|
||||
nsCOMPtr<nsIURI> referrer;
|
||||
rv = principal->GetURI(getter_AddRefs(referrer));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
loadInfo->SetReferrer(referrer);
|
||||
}
|
||||
|
||||
// Kick off the load...
|
||||
rv = mDocShell->LoadURI(aURI, loadInfo, nsIWebNavigation::LOAD_FLAGS_NONE,
|
||||
PR_FALSE);
|
||||
#ifdef DEBUG
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Failed to load the URL");
|
||||
}
|
||||
#endif
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFrameLoader::GetDocShell(nsIDocShell **aDocShell)
|
||||
{
|
||||
*aDocShell = nsnull;
|
||||
|
||||
// If we have an owner, make sure we have a docshell and return
|
||||
// that. If not, we're most likely in the middle of being torn down,
|
||||
// then we just return null.
|
||||
if (mOwnerContent) {
|
||||
nsresult rv = EnsureDocShell();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
*aDocShell = mDocShell;
|
||||
NS_IF_ADDREF(*aDocShell);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFrameLoader::Destroy()
|
||||
{
|
||||
if (mOwnerContent) {
|
||||
nsCOMPtr<nsIDocument> doc = mOwnerContent->GetDocument();
|
||||
|
||||
if (doc) {
|
||||
doc->SetSubDocumentFor(mOwnerContent, nsnull);
|
||||
}
|
||||
|
||||
mOwnerContent = nsnull;
|
||||
}
|
||||
|
||||
// Let the tree owner know we're gone.
|
||||
if (mIsTopLevelContent) {
|
||||
nsCOMPtr<nsIDocShellTreeItem> ourItem = do_QueryInterface(mDocShell);
|
||||
if (ourItem) {
|
||||
nsCOMPtr<nsIDocShellTreeItem> parentItem;
|
||||
ourItem->GetParent(getter_AddRefs(parentItem));
|
||||
nsCOMPtr<nsIDocShellTreeOwner> owner = do_GetInterface(parentItem);
|
||||
nsCOMPtr<nsIDocShellTreeOwner_MOZILLA_1_8_BRANCH> owner2 =
|
||||
do_QueryInterface(owner);
|
||||
if (owner2) {
|
||||
owner2->ContentShellRemoved(ourItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Let our window know that we are gone
|
||||
nsCOMPtr<nsPIDOMWindow> win_private(do_GetInterface(mDocShell));
|
||||
if (win_private) {
|
||||
win_private->SetFrameElementInternal(nsnull);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIBaseWindow> base_win(do_QueryInterface(mDocShell));
|
||||
|
||||
if (base_win) {
|
||||
base_win->Destroy();
|
||||
}
|
||||
|
||||
mDocShell = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFrameLoader::GetDepthTooGreat(PRBool* aDepthTooGreat)
|
||||
{
|
||||
*aDepthTooGreat = mDepthTooGreat;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFrameLoader::EnsureDocShell()
|
||||
{
|
||||
if (mDocShell) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Get our parent docshell off the document of mOwnerContent
|
||||
// XXXbz this is such a total hack.... We really need to have a
|
||||
// better setup for doing this.
|
||||
nsIDocument* doc = mOwnerContent->GetDocument();
|
||||
if (!doc) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWebNavigation> parentAsWebNav =
|
||||
do_GetInterface(doc->GetScriptGlobalObject());
|
||||
|
||||
// Create the docshell...
|
||||
mDocShell = do_CreateInstance("@mozilla.org/webshell;1");
|
||||
NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE);
|
||||
|
||||
// Get the frame name and tell the docshell about it.
|
||||
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
|
||||
NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE);
|
||||
nsAutoString frameName;
|
||||
|
||||
PRInt32 namespaceID = mOwnerContent->GetNameSpaceID();
|
||||
if (namespaceID == kNameSpaceID_XHTML) {
|
||||
mOwnerContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::id, frameName);
|
||||
} else {
|
||||
mOwnerContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::name, frameName);
|
||||
// XXX if no NAME then use ID, after a transition period this will be
|
||||
// changed so that XUL only uses ID too (bug 254284).
|
||||
if (frameName.IsEmpty() && namespaceID == kNameSpaceID_XUL) {
|
||||
mOwnerContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::id, frameName);
|
||||
}
|
||||
}
|
||||
|
||||
if (!frameName.IsEmpty()) {
|
||||
docShellAsItem->SetName(frameName.get());
|
||||
}
|
||||
|
||||
// If our container is a web-shell, inform it that it has a new
|
||||
// child. If it's not a web-shell then some things will not operate
|
||||
// properly.
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeNode> parentAsNode(do_QueryInterface(parentAsWebNav));
|
||||
if (parentAsNode) {
|
||||
// Note: This logic duplicates a lot of logic in
|
||||
// nsSubDocumentFrame::AttributeChanged. We should fix that.
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeItem> parentAsItem =
|
||||
do_QueryInterface(parentAsNode);
|
||||
|
||||
PRInt32 parentType;
|
||||
parentAsItem->GetItemType(&parentType);
|
||||
|
||||
nsAutoString value;
|
||||
PRBool isContent = PR_FALSE;
|
||||
|
||||
if (mOwnerContent->IsNodeOfType(nsINode::eXUL)) {
|
||||
mOwnerContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::type, value);
|
||||
}
|
||||
|
||||
// we accept "content" and "content-xxx" values.
|
||||
// at time of writing, we expect "xxx" to be "primary" or "targetable", but
|
||||
// someday it might be an integer expressing priority or something else.
|
||||
|
||||
isContent = value.LowerCaseEqualsLiteral("content") ||
|
||||
StringBeginsWith(value, NS_LITERAL_STRING("content-"),
|
||||
nsCaseInsensitiveStringComparator());
|
||||
|
||||
if (isContent) {
|
||||
// The web shell's type is content.
|
||||
|
||||
docShellAsItem->SetItemType(nsIDocShellTreeItem::typeContent);
|
||||
} else {
|
||||
// Inherit our type from our parent webshell. If it is
|
||||
// chrome, we'll be chrome. If it is content, we'll be
|
||||
// content.
|
||||
|
||||
docShellAsItem->SetItemType(parentType);
|
||||
}
|
||||
|
||||
parentAsNode->AddChild(docShellAsItem);
|
||||
|
||||
if (parentType == nsIDocShellTreeItem::typeChrome && isContent) {
|
||||
mIsTopLevelContent = PR_TRUE;
|
||||
|
||||
// XXXbz why is this in content code, exactly? We should handle
|
||||
// this some other way..... Not sure how yet.
|
||||
nsCOMPtr<nsIDocShellTreeOwner> parentTreeOwner;
|
||||
parentAsItem->GetTreeOwner(getter_AddRefs(parentTreeOwner));
|
||||
nsCOMPtr<nsIDocShellTreeOwner_MOZILLA_1_8_BRANCH> owner2 =
|
||||
do_QueryInterface(parentTreeOwner);
|
||||
|
||||
PRBool is_primary = value.LowerCaseEqualsLiteral("content-primary");
|
||||
|
||||
if (owner2) {
|
||||
PRBool is_targetable = is_primary ||
|
||||
value.LowerCaseEqualsLiteral("content-targetable");
|
||||
owner2->ContentShellAdded2(docShellAsItem, is_primary, is_targetable,
|
||||
value);
|
||||
} else if (parentTreeOwner) {
|
||||
parentTreeOwner->ContentShellAdded(docShellAsItem, is_primary,
|
||||
value.get());
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure all shells have links back to the content element
|
||||
// in the nearest enclosing chrome shell.
|
||||
nsCOMPtr<nsIChromeEventHandler> chromeEventHandler;
|
||||
|
||||
if (parentType == nsIDocShellTreeItem::typeChrome) {
|
||||
// Our parent shell is a chrome shell. It is therefore our nearest
|
||||
// enclosing chrome shell.
|
||||
|
||||
chromeEventHandler = do_QueryInterface(mOwnerContent);
|
||||
NS_ASSERTION(chromeEventHandler,
|
||||
"This mContent should implement this.");
|
||||
} else {
|
||||
nsCOMPtr<nsIDocShell> parentShell(do_QueryInterface(parentAsNode));
|
||||
|
||||
// Our parent shell is a content shell. Get the chrome event
|
||||
// handler from it and use that for our shell as well.
|
||||
|
||||
parentShell->GetChromeEventHandler(getter_AddRefs(chromeEventHandler));
|
||||
}
|
||||
|
||||
mDocShell->SetChromeEventHandler(chromeEventHandler);
|
||||
}
|
||||
|
||||
// This is nasty, this code (the do_GetInterface(mDocShell) below)
|
||||
// *must* come *after* the above call to
|
||||
// mDocShell->SetChromeEventHandler() for the global window to get
|
||||
// the right chrome event handler.
|
||||
|
||||
// Tell the window about the frame that hosts it.
|
||||
nsCOMPtr<nsIDOMElement> frame_element(do_QueryInterface(mOwnerContent));
|
||||
NS_ASSERTION(frame_element, "frame loader owner element not a DOM element!");
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> win_private(do_GetInterface(mDocShell));
|
||||
NS_ENSURE_TRUE(win_private, NS_ERROR_UNEXPECTED);
|
||||
|
||||
win_private->SetFrameElementInternal(frame_element);
|
||||
|
||||
nsCOMPtr<nsIBaseWindow> base_win(do_QueryInterface(mDocShell));
|
||||
NS_ENSURE_TRUE(base_win, NS_ERROR_UNEXPECTED);
|
||||
|
||||
// This is kinda whacky, this call doesn't really create anything,
|
||||
// but it must be called to make sure things are properly
|
||||
// initialized
|
||||
|
||||
base_win->Create();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsFrameLoader::GetURL(nsString& aURI)
|
||||
{
|
||||
aURI.Truncate();
|
||||
|
||||
if (mOwnerContent->Tag() == nsHTMLAtoms::object) {
|
||||
mOwnerContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::data, aURI);
|
||||
} else {
|
||||
mOwnerContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::src, aURI);
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFrameLoader::CheckForRecursiveLoad(nsIURI* aURI)
|
||||
{
|
||||
mDepthTooGreat = PR_FALSE;
|
||||
|
||||
NS_PRECONDITION(mDocShell, "Must have docshell here");
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeItem> treeItem = do_QueryInterface(mDocShell);
|
||||
NS_ASSERTION(treeItem, "docshell must be a treeitem!");
|
||||
|
||||
PRInt32 ourType;
|
||||
nsresult rv = treeItem->GetItemType(&ourType);
|
||||
if (NS_SUCCEEDED(rv) && ourType != nsIDocShellTreeItem::typeContent) {
|
||||
// No need to do recursion-protection here XXXbz why not?? Do we really
|
||||
// trust people not to screw up with non-content docshells?
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Bug 8065: Don't exceed some maximum depth in content frames
|
||||
// (MAX_DEPTH_CONTENT_FRAMES)
|
||||
nsCOMPtr<nsIDocShellTreeItem> parentAsItem;
|
||||
treeItem->GetSameTypeParent(getter_AddRefs(parentAsItem));
|
||||
PRInt32 depth = 0;
|
||||
while (parentAsItem) {
|
||||
++depth;
|
||||
|
||||
if (depth >= MAX_DEPTH_CONTENT_FRAMES) {
|
||||
mDepthTooGreat = PR_TRUE;
|
||||
NS_WARNING("Too many nested content frames so giving up");
|
||||
|
||||
return NS_ERROR_UNEXPECTED; // Too deep, give up! (silently?)
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeItem> temp;
|
||||
temp.swap(parentAsItem);
|
||||
temp->GetSameTypeParent(getter_AddRefs(parentAsItem));
|
||||
}
|
||||
|
||||
// Bug 136580: Check for recursive frame loading
|
||||
// pre-grab these for speed
|
||||
nsCOMPtr<nsIURI> cloneURI;
|
||||
rv = aURI->Clone(getter_AddRefs(cloneURI));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Bug 98158/193011: We need to ignore data after the #
|
||||
nsCOMPtr<nsIURL> cloneURL(do_QueryInterface(cloneURI)); // QI can fail
|
||||
if (cloneURL) {
|
||||
rv = cloneURL->SetRef(EmptyCString());
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
|
||||
PRInt32 matchCount = 0;
|
||||
treeItem->GetSameTypeParent(getter_AddRefs(parentAsItem));
|
||||
while (parentAsItem) {
|
||||
// Check the parent URI with the URI we're loading
|
||||
nsCOMPtr<nsIWebNavigation> parentAsNav(do_QueryInterface(parentAsItem));
|
||||
if (parentAsNav) {
|
||||
// Does the URI match the one we're about to load?
|
||||
nsCOMPtr<nsIURI> parentURI;
|
||||
parentAsNav->GetCurrentURI(getter_AddRefs(parentURI));
|
||||
if (parentURI) {
|
||||
nsCOMPtr<nsIURI> parentClone;
|
||||
rv = parentURI->Clone(getter_AddRefs(parentClone));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIURL> parentURL(do_QueryInterface(parentClone));
|
||||
if (parentURL) {
|
||||
rv = parentURL->SetRef(EmptyCString());
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
|
||||
PRBool equal;
|
||||
rv = cloneURI->Equals(parentClone, &equal);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (equal) {
|
||||
matchCount++;
|
||||
if (matchCount >= MAX_SAME_URL_CONTENT_FRAMES) {
|
||||
NS_WARNING("Too many nested content frames have the same url (recursion?) so giving up");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsIDocShellTreeItem> temp;
|
||||
temp.swap(parentAsItem);
|
||||
temp->GetSameTypeParent(getter_AddRefs(parentAsItem));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Johnny Stenback <jst@netscape.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Class for managing loading of a subframe (creation of the docshell,
|
||||
* handling of loads in it, recursion-checking).
|
||||
*/
|
||||
|
||||
#ifndef nsFrameLoader_h_
|
||||
#define nsFrameLoader_h_
|
||||
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsStringFwd.h"
|
||||
#include "nsIFrameLoader.h"
|
||||
|
||||
class nsIContent;
|
||||
class nsIURI;
|
||||
|
||||
class nsFrameLoader : public nsIFrameLoader
|
||||
{
|
||||
public:
|
||||
nsFrameLoader(nsIContent *aOwner) :
|
||||
mOwnerContent(aOwner),
|
||||
mDepthTooGreat(PR_FALSE),
|
||||
mIsTopLevelContent(PR_FALSE)
|
||||
{}
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIFRAMELOADER
|
||||
|
||||
private:
|
||||
~nsFrameLoader() { nsFrameLoader::Destroy(); }
|
||||
|
||||
NS_HIDDEN_(nsresult) EnsureDocShell();
|
||||
NS_HIDDEN_(void) GetURL(nsString& aURL);
|
||||
NS_HIDDEN_(nsresult) CheckForRecursiveLoad(nsIURI* aURI);
|
||||
|
||||
nsCOMPtr<nsIDocShell> mDocShell;
|
||||
|
||||
nsIContent *mOwnerContent; // WEAK
|
||||
PRPackedBool mDepthTooGreat;
|
||||
PRPackedBool mIsTopLevelContent;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,113 +0,0 @@
|
||||
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is nsGenConImageContent.
|
||||
*
|
||||
* The Initial Developer of the Original Code is the Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* L. David Baron <dbaron@dbaron.org> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/**
|
||||
* A fake content node class so that the image frame for
|
||||
* content: url(foo);
|
||||
* in CSS can have an nsIImageLoadingContent but use an
|
||||
* imgIRequest that's already been loaded from the style system.
|
||||
*/
|
||||
|
||||
#include "nsContentCreatorFunctions.h"
|
||||
#include "nsXMLElement.h"
|
||||
#include "nsImageLoadingContent.h"
|
||||
#include "imgIRequest.h"
|
||||
#include "nsIEventStateManager.h"
|
||||
|
||||
class nsGenConImageContent : public nsXMLElement,
|
||||
public nsImageLoadingContent
|
||||
{
|
||||
public:
|
||||
nsGenConImageContent(nsINodeInfo* aNodeInfo)
|
||||
: nsXMLElement(aNodeInfo)
|
||||
{
|
||||
}
|
||||
|
||||
nsresult Init(imgIRequest* aImageRequest)
|
||||
{
|
||||
// No need to notify, since we have no frame.
|
||||
return UseAsPrimaryRequest(aImageRequest, PR_FALSE);
|
||||
}
|
||||
|
||||
// nsIContent overrides
|
||||
virtual PRInt32 IntrinsicState() const;
|
||||
|
||||
private:
|
||||
virtual ~nsGenConImageContent();
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED2(nsGenConImageContent, nsXMLElement,
|
||||
nsIImageLoadingContent, imgIDecoderObserver)
|
||||
|
||||
nsresult
|
||||
NS_NewGenConImageContent(nsIContent** aResult, nsINodeInfo* aNodeInfo,
|
||||
imgIRequest* aImageRequest)
|
||||
{
|
||||
NS_PRECONDITION(aImageRequest, "Must have request!");
|
||||
nsGenConImageContent *it = new nsGenConImageContent(aNodeInfo);
|
||||
if (!it)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(*aResult = it);
|
||||
nsresult rv = it->Init(aImageRequest);
|
||||
if (NS_FAILED(rv))
|
||||
NS_RELEASE(*aResult);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsGenConImageContent::~nsGenConImageContent()
|
||||
{
|
||||
DestroyImageLoadingContent();
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsGenConImageContent::IntrinsicState() const
|
||||
{
|
||||
PRInt32 state = nsXMLElement::IntrinsicState();
|
||||
|
||||
PRInt32 imageState = nsImageLoadingContent::ImageState();
|
||||
if (imageState & NS_EVENT_STATE_BROKEN) {
|
||||
// We should never be in an error state; if the image fails to load, we
|
||||
// just go to the suppressed state.
|
||||
imageState |= NS_EVENT_STATE_SUPPRESSED;
|
||||
imageState &= ~NS_EVENT_STATE_BROKEN;
|
||||
}
|
||||
imageState &= ~NS_EVENT_STATE_LOADING;
|
||||
return state | imageState;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,430 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Base class for DOM Core's nsIDOMComment, nsIDOMDocumentType, nsIDOMText,
|
||||
* nsIDOMCDATASection, and nsIDOMProcessingInstruction nodes.
|
||||
*/
|
||||
|
||||
#ifndef nsGenericDOMDataNode_h___
|
||||
#define nsGenericDOMDataNode_h___
|
||||
|
||||
#include "nsITextContent.h"
|
||||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsTextFragment.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsDOMError.h"
|
||||
#include "nsIEventListenerManager.h"
|
||||
#include "nsGenericElement.h"
|
||||
|
||||
|
||||
class nsIDOMAttr;
|
||||
class nsIDOMEventListener;
|
||||
class nsIDOMNodeList;
|
||||
class nsIFrame;
|
||||
class nsIDOMText;
|
||||
class nsINodeInfo;
|
||||
class nsURI;
|
||||
|
||||
class nsGenericDOMDataNode : public nsITextContent
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsGenericDOMDataNode(nsINodeInfo *aNodeInfo);
|
||||
virtual ~nsGenericDOMDataNode();
|
||||
|
||||
// Implementation for nsIDOMNode
|
||||
nsresult GetNodeValue(nsAString& aNodeValue);
|
||||
nsresult SetNodeValue(const nsAString& aNodeValue);
|
||||
nsresult GetParentNode(nsIDOMNode** aParentNode);
|
||||
nsresult GetAttributes(nsIDOMNamedNodeMap** aAttributes)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aAttributes);
|
||||
*aAttributes = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult GetPreviousSibling(nsIDOMNode** aPreviousSibling);
|
||||
nsresult GetNextSibling(nsIDOMNode** aNextSibling);
|
||||
nsresult GetChildNodes(nsIDOMNodeList** aChildNodes);
|
||||
nsresult HasChildNodes(PRBool* aHasChildNodes)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aHasChildNodes);
|
||||
*aHasChildNodes = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult HasAttributes(PRBool* aHasAttributes)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aHasAttributes);
|
||||
*aHasAttributes = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult GetFirstChild(nsIDOMNode** aFirstChild)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aFirstChild);
|
||||
*aFirstChild = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult GetLastChild(nsIDOMNode** aLastChild)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aLastChild);
|
||||
*aLastChild = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
nsresult InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild,
|
||||
nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aReturn);
|
||||
*aReturn = nsnull;
|
||||
return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR;
|
||||
}
|
||||
nsresult ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild,
|
||||
nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aReturn);
|
||||
*aReturn = nsnull;
|
||||
|
||||
/*
|
||||
* Data nodes can't have children.
|
||||
*/
|
||||
return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR;
|
||||
}
|
||||
nsresult RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aReturn);
|
||||
*aReturn = nsnull;
|
||||
|
||||
/*
|
||||
* Data nodes can't have children, i.e. aOldChild can't be a child of
|
||||
* this node.
|
||||
*/
|
||||
return NS_ERROR_DOM_NOT_FOUND_ERR;
|
||||
}
|
||||
nsresult AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aReturn);
|
||||
*aReturn = nsnull;
|
||||
return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR;
|
||||
}
|
||||
nsresult GetOwnerDocument(nsIDOMDocument** aOwnerDocument);
|
||||
nsresult GetNamespaceURI(nsAString& aNamespaceURI);
|
||||
nsresult GetLocalName(nsAString& aLocalName);
|
||||
nsresult GetPrefix(nsAString& aPrefix);
|
||||
nsresult SetPrefix(const nsAString& aPrefix);
|
||||
nsresult Normalize();
|
||||
nsresult IsSupported(const nsAString& aFeature,
|
||||
const nsAString& aVersion,
|
||||
PRBool* aReturn);
|
||||
nsresult GetBaseURI(nsAString& aURI);
|
||||
|
||||
/**
|
||||
* A basic implementation of the DOM cloneNode method. Calls CloneContent to
|
||||
* do the actual cloning of the node.
|
||||
*
|
||||
* @param aDeep if true all descendants will be cloned too
|
||||
* @param aSource nsIDOMNode pointer to this node
|
||||
* @param aResult the clone
|
||||
*/
|
||||
nsresult CloneNode(PRBool aDeep, nsIDOMNode *aSource,
|
||||
nsIDOMNode **aResult) const;
|
||||
|
||||
nsresult LookupPrefix(const nsAString& aNamespaceURI,
|
||||
nsAString& aPrefix);
|
||||
nsresult LookupNamespaceURI(const nsAString& aNamespacePrefix,
|
||||
nsAString& aNamespaceURI);
|
||||
|
||||
// Implementation for nsIDOMCharacterData
|
||||
nsresult GetData(nsAString& aData) const;
|
||||
nsresult SetData(const nsAString& aData);
|
||||
nsresult GetLength(PRUint32* aLength);
|
||||
nsresult SubstringData(PRUint32 aOffset, PRUint32 aCount,
|
||||
nsAString& aReturn);
|
||||
nsresult AppendData(const nsAString& aArg);
|
||||
nsresult InsertData(PRUint32 aOffset, const nsAString& aArg);
|
||||
nsresult DeleteData(PRUint32 aOffset, PRUint32 aCount);
|
||||
nsresult ReplaceData(PRUint32 aOffset, PRUint32 aCount,
|
||||
const nsAString& aArg);
|
||||
|
||||
// nsIDOMGCParticipant interface methods
|
||||
virtual nsIDOMGCParticipant* GetSCCIndex();
|
||||
virtual void AppendReachableList(nsCOMArray<nsIDOMGCParticipant>& aArray);
|
||||
|
||||
// nsINode methods
|
||||
virtual PRUint32 GetChildCount() const;
|
||||
virtual nsIContent *GetChildAt(PRUint32 aIndex) const;
|
||||
virtual PRInt32 IndexOf(nsINode* aPossibleChild) const;
|
||||
virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
|
||||
PRBool aNotify);
|
||||
virtual nsresult AppendChildTo(nsIContent* aKid, PRBool aNotify);
|
||||
virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
|
||||
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
|
||||
virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor);
|
||||
virtual nsresult DispatchDOMEvent(nsEvent* aEvent, nsIDOMEvent* aDOMEvent,
|
||||
nsPresContext* aPresContext,
|
||||
nsEventStatus* aEventStatus);
|
||||
|
||||
// Implementation for nsIContent
|
||||
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
||||
nsIContent* aBindingParent,
|
||||
PRBool aCompileEventHandlers);
|
||||
virtual void UnbindFromTree(PRBool aDeep = PR_TRUE,
|
||||
PRBool aNullParent = PR_TRUE);
|
||||
|
||||
virtual nsIAtom *GetIDAttributeName() const;
|
||||
virtual already_AddRefed<nsINodeInfo> GetExistingAttrNameFromQName(const nsAString& aStr) const;
|
||||
nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
const nsAString& aValue, PRBool aNotify)
|
||||
{
|
||||
return SetAttr(aNameSpaceID, aName, nsnull, aValue, aNotify);
|
||||
}
|
||||
virtual nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
||||
nsIAtom* aPrefix, const nsAString& aValue,
|
||||
PRBool aNotify);
|
||||
virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
||||
PRBool aNotify);
|
||||
virtual PRBool GetAttr(PRInt32 aNameSpaceID, nsIAtom *aAttribute,
|
||||
nsAString& aResult) const;
|
||||
virtual PRBool HasAttr(PRInt32 aNameSpaceID, nsIAtom *aAttribute) const;
|
||||
virtual const nsAttrName* GetAttrNameAt(PRUint32 aIndex) const;
|
||||
virtual PRUint32 GetAttrCount() const;
|
||||
#ifdef DEBUG
|
||||
virtual void List(FILE* out, PRInt32 aIndent) const;
|
||||
virtual void DumpContent(FILE* out, PRInt32 aIndent, PRBool aDumpAll) const;
|
||||
#endif
|
||||
|
||||
virtual nsIContent *GetBindingParent() const;
|
||||
virtual PRBool IsNodeOfType(PRUint32 aFlags) const;
|
||||
|
||||
virtual already_AddRefed<nsIURI> GetBaseURI() const;
|
||||
|
||||
virtual PRBool MayHaveFrame() const;
|
||||
|
||||
/**
|
||||
* This calls Clone to do the actual cloning so that we end up with the
|
||||
* right class for the clone.
|
||||
*/
|
||||
virtual nsresult CloneContent(nsNodeInfoManager *aNodeInfoManager,
|
||||
PRBool aDeep, nsIContent **aResult) const;
|
||||
|
||||
virtual nsIAtom* GetID() const;
|
||||
virtual const nsAttrValue* GetClasses() const;
|
||||
NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker);
|
||||
virtual nsICSSStyleRule* GetInlineStyleRule();
|
||||
NS_IMETHOD SetInlineStyleRule(nsICSSStyleRule* aStyleRule, PRBool aNotify);
|
||||
NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const;
|
||||
virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,
|
||||
PRInt32 aModType) const;
|
||||
virtual nsIAtom *GetClassAttributeName() const;
|
||||
|
||||
|
||||
// nsITextContent
|
||||
virtual const nsTextFragment *Text();
|
||||
virtual PRUint32 TextLength();
|
||||
virtual void SetText(const PRUnichar* aBuffer, PRUint32 aLength,
|
||||
PRBool aNotify);
|
||||
// Need to implement this here too to avoid hiding.
|
||||
void SetText(const nsAString& aStr, PRBool aNotify)
|
||||
{
|
||||
SetText(aStr.BeginReading(), aStr.Length(), aNotify);
|
||||
}
|
||||
virtual PRBool IsOnlyWhitespace();
|
||||
virtual void AppendTextTo(nsAString& aResult);
|
||||
|
||||
//----------------------------------------
|
||||
|
||||
#ifdef DEBUG
|
||||
void ToCString(nsAString& aBuf, PRInt32 aOffset, PRInt32 aLen) const;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* There are a set of DOM- and scripting-specific instance variables
|
||||
* that may only be instantiated when a content object is accessed
|
||||
* through the DOM. Rather than burn actual slots in the content
|
||||
* objects for each of these instance variables, we put them off
|
||||
* in a side structure that's only allocated when the content is
|
||||
* accessed through the DOM.
|
||||
*/
|
||||
class nsDataSlots : public nsINode::nsSlots
|
||||
{
|
||||
public:
|
||||
nsDataSlots(PtrBits aFlags);
|
||||
~nsDataSlots();
|
||||
|
||||
/**
|
||||
* An object implementing nsIDOMNodeList for this content (childNodes)
|
||||
* @see nsIDOMNodeList
|
||||
*/
|
||||
nsRefPtr<nsChildContentList> mChildNodes;
|
||||
|
||||
/**
|
||||
* The nearest enclosing content node with a binding that created us.
|
||||
* @see nsIContent::GetBindingParent
|
||||
*/
|
||||
nsIContent* mBindingParent; // [Weak]
|
||||
};
|
||||
|
||||
nsDataSlots *GetDataSlots()
|
||||
{
|
||||
if (!HasSlots()) {
|
||||
nsDataSlots *slots = new nsDataSlots(mFlagsOrSlots);
|
||||
|
||||
if (!slots) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
SetSlots(slots);
|
||||
}
|
||||
|
||||
return NS_STATIC_CAST(nsDataSlots*, FlagsAsSlots());
|
||||
}
|
||||
|
||||
nsDataSlots *GetExistingDataSlots() const
|
||||
{
|
||||
return NS_STATIC_CAST(nsDataSlots*, GetExistingSlots());
|
||||
}
|
||||
protected:
|
||||
nsresult SplitText(PRUint32 aOffset, nsIDOMText** aReturn);
|
||||
|
||||
/**
|
||||
* Method to clone this node. This needs to be overriden by all derived
|
||||
* classes. If aCloneText is true the text content will be cloned too.
|
||||
*
|
||||
* @param aOwnerDocument the ownerDocument of the clone
|
||||
* @param aCloneText if true the text content will be cloned too
|
||||
* @return the clone
|
||||
*/
|
||||
virtual nsGenericDOMDataNode *Clone(nsINodeInfo *aNodeInfo,
|
||||
PRBool aCloneText) const = 0;
|
||||
|
||||
nsTextFragment mText;
|
||||
|
||||
private:
|
||||
void SetBidiStatus();
|
||||
|
||||
already_AddRefed<nsIAtom> GetCurrentValueAtom();
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Mostly implement the nsIDOMNode API by forwarding the methods to
|
||||
* nsGenericDOMDataNode
|
||||
*
|
||||
* Note that classes using this macro will need to implement:
|
||||
* NS_IMETHOD GetNodeType(PRUint16* aNodeType);
|
||||
* nsGenericDOMDataNode *Clone(nsINodeInfo *aNodeInfo,
|
||||
* PRBool aCloneText) const;
|
||||
*/
|
||||
#define NS_IMPL_NSIDOMNODE_USING_GENERIC_DOM_DATA \
|
||||
NS_IMETHOD GetNodeName(nsAString& aNodeName); \
|
||||
NS_IMETHOD GetLocalName(nsAString& aLocalName) { \
|
||||
return nsGenericDOMDataNode::GetLocalName(aLocalName); \
|
||||
} \
|
||||
NS_IMETHOD GetNodeValue(nsAString& aNodeValue); \
|
||||
NS_IMETHOD SetNodeValue(const nsAString& aNodeValue); \
|
||||
NS_IMETHOD GetNodeType(PRUint16* aNodeType); \
|
||||
NS_IMETHOD GetParentNode(nsIDOMNode** aParentNode) { \
|
||||
return nsGenericDOMDataNode::GetParentNode(aParentNode); \
|
||||
} \
|
||||
NS_IMETHOD GetChildNodes(nsIDOMNodeList** aChildNodes) { \
|
||||
return nsGenericDOMDataNode::GetChildNodes(aChildNodes); \
|
||||
} \
|
||||
NS_IMETHOD HasChildNodes(PRBool* aHasChildNodes) { \
|
||||
return nsGenericDOMDataNode::HasChildNodes(aHasChildNodes); \
|
||||
} \
|
||||
NS_IMETHOD HasAttributes(PRBool* aHasAttributes) { \
|
||||
return nsGenericDOMDataNode::HasAttributes(aHasAttributes); \
|
||||
} \
|
||||
NS_IMETHOD GetFirstChild(nsIDOMNode** aFirstChild) { \
|
||||
return nsGenericDOMDataNode::GetFirstChild(aFirstChild); \
|
||||
} \
|
||||
NS_IMETHOD GetLastChild(nsIDOMNode** aLastChild) { \
|
||||
return nsGenericDOMDataNode::GetLastChild(aLastChild); \
|
||||
} \
|
||||
NS_IMETHOD GetPreviousSibling(nsIDOMNode** aPreviousSibling) { \
|
||||
return nsGenericDOMDataNode::GetPreviousSibling(aPreviousSibling); \
|
||||
} \
|
||||
NS_IMETHOD GetNextSibling(nsIDOMNode** aNextSibling) { \
|
||||
return nsGenericDOMDataNode::GetNextSibling(aNextSibling); \
|
||||
} \
|
||||
NS_IMETHOD GetAttributes(nsIDOMNamedNodeMap** aAttributes) { \
|
||||
return nsGenericDOMDataNode::GetAttributes(aAttributes); \
|
||||
} \
|
||||
NS_IMETHOD InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, \
|
||||
nsIDOMNode** aReturn) { \
|
||||
return nsGenericDOMDataNode::InsertBefore(aNewChild, aRefChild, \
|
||||
aReturn); \
|
||||
} \
|
||||
NS_IMETHOD AppendChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn) { \
|
||||
return nsGenericDOMDataNode::AppendChild(aOldChild, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, \
|
||||
nsIDOMNode** aReturn) { \
|
||||
return nsGenericDOMDataNode::ReplaceChild(aNewChild, aOldChild, \
|
||||
aReturn); \
|
||||
} \
|
||||
NS_IMETHOD RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn) { \
|
||||
return nsGenericDOMDataNode::RemoveChild(aOldChild, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD GetOwnerDocument(nsIDOMDocument** aOwnerDocument) { \
|
||||
return nsGenericDOMDataNode::GetOwnerDocument(aOwnerDocument); \
|
||||
} \
|
||||
NS_IMETHOD GetNamespaceURI(nsAString& aNamespaceURI) { \
|
||||
return nsGenericDOMDataNode::GetNamespaceURI(aNamespaceURI); \
|
||||
} \
|
||||
NS_IMETHOD GetPrefix(nsAString& aPrefix) { \
|
||||
return nsGenericDOMDataNode::GetPrefix(aPrefix); \
|
||||
} \
|
||||
NS_IMETHOD SetPrefix(const nsAString& aPrefix) { \
|
||||
return nsGenericDOMDataNode::SetPrefix(aPrefix); \
|
||||
} \
|
||||
NS_IMETHOD Normalize() { \
|
||||
return NS_OK; \
|
||||
} \
|
||||
NS_IMETHOD IsSupported(const nsAString& aFeature, \
|
||||
const nsAString& aVersion, \
|
||||
PRBool* aReturn) { \
|
||||
return nsGenericDOMDataNode::IsSupported(aFeature, aVersion, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn) { \
|
||||
return nsGenericDOMDataNode::CloneNode(aDeep, this, aReturn); \
|
||||
} \
|
||||
virtual nsGenericDOMDataNode *Clone(nsINodeInfo *aNodeInfo, \
|
||||
PRBool aCloneText) const;
|
||||
|
||||
#endif /* nsGenericDOMDataNode_h___ */
|
||||
@@ -1,66 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* A base class for simple DOM NodeLists which implements nsISupports
|
||||
* and expects subclasess to implement GetLength() and Item()
|
||||
*/
|
||||
|
||||
#include "nsGenericDOMNodeList.h"
|
||||
#include "nsGenericElement.h"
|
||||
|
||||
nsGenericDOMNodeList::nsGenericDOMNodeList()
|
||||
{
|
||||
}
|
||||
|
||||
nsGenericDOMNodeList::~nsGenericDOMNodeList()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(nsGenericDOMNodeList)
|
||||
NS_IMPL_RELEASE(nsGenericDOMNodeList)
|
||||
|
||||
|
||||
// QueryInterface implementation for nsGenericDOMNodeList
|
||||
NS_INTERFACE_MAP_BEGIN(nsGenericDOMNodeList)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMNodeList)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(NodeList)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user