Compare commits
64 Commits
XSLTPROCES
...
MODULAR_NE
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c515100b8e | ||
|
|
fe0f4d855f | ||
|
|
3d4019f9c4 | ||
|
|
9d96048a4b | ||
|
|
ae5d3bac86 | ||
|
|
dd5a8c0dfa | ||
|
|
a5f43d2a13 | ||
|
|
897d60bb73 | ||
|
|
fd1359cac8 | ||
|
|
aa88ba7591 | ||
|
|
0c9f6e6d80 | ||
|
|
f635646933 | ||
|
|
74a41b1364 | ||
|
|
dddf36e52d | ||
|
|
42f1218f94 | ||
|
|
9369584965 | ||
|
|
644d7cd9c7 | ||
|
|
cac7b720c3 | ||
|
|
371d44de72 | ||
|
|
d5840939c7 | ||
|
|
2a50f93567 | ||
|
|
d2a75afae6 | ||
|
|
8f2a603835 | ||
|
|
d9babead55 | ||
|
|
daa26a48be | ||
|
|
be77d90b49 | ||
|
|
e2793376a7 | ||
|
|
6d54e5f6e3 | ||
|
|
b0db9a4acd | ||
|
|
a7a9a03946 | ||
|
|
5340ef2b1b | ||
|
|
1043bb4cc9 | ||
|
|
9cb908ce37 | ||
|
|
93cf7025ed | ||
|
|
42b35681a2 | ||
|
|
bd2471c41c | ||
|
|
3231691800 | ||
|
|
2bdd74e814 | ||
|
|
97b4b7a6d1 | ||
|
|
55369bada1 | ||
|
|
82ed1f72bb | ||
|
|
52d02fe072 | ||
|
|
11e91b2751 | ||
|
|
9c6ac35617 | ||
|
|
50054acba1 | ||
|
|
79a4c9490b | ||
|
|
c181b6d7f9 | ||
|
|
a5e5b98ad8 | ||
|
|
f453d81444 | ||
|
|
05cb725cfb | ||
|
|
46d5611628 | ||
|
|
d9a5e647f5 | ||
|
|
6c07a2ca66 | ||
|
|
3c5574eb6e | ||
|
|
fee6fe5171 | ||
|
|
46e818474a | ||
|
|
ac3fe4623e | ||
|
|
e5430a78e1 | ||
|
|
e8ecd3ec68 | ||
|
|
86e542aa90 | ||
|
|
35f45baaed | ||
|
|
e72757dc16 | ||
|
|
f7ac2222ef | ||
|
|
4099eb2ef3 |
3875
mozilla/cmd/winfe/fegui.cpp
Executable file
3875
mozilla/cmd/winfe/fegui.cpp
Executable file
File diff suppressed because it is too large
Load Diff
2031
mozilla/cmd/winfe/nsapp.cpp
Normal file
2031
mozilla/cmd/winfe/nsapp.cpp
Normal file
File diff suppressed because it is too large
Load Diff
123
mozilla/cmd/winfe/stdafx.h
Normal file
123
mozilla/cmd/winfe/stdafx.h
Normal file
@@ -0,0 +1,123 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef STDAFX_PCH
|
||||
#define STDAFX_PCH
|
||||
|
||||
#define OEMRESOURCE
|
||||
|
||||
#if defined(DEBUG_blythe)
|
||||
// Set up a flag specific to WFE developers in the client
|
||||
#define DEBUG_WFE
|
||||
#endif
|
||||
|
||||
/* Very windows specific includes.
|
||||
*/
|
||||
/* MFC, KFC, RUN DMC, whatever */
|
||||
#include <afxwin.h>
|
||||
#include <afxext.h>
|
||||
#include <afxpriv.h>
|
||||
#include <afxole.h>
|
||||
#include <afxdisp.h>
|
||||
#include <afxodlgs.h>
|
||||
#ifdef _WIN32
|
||||
#include <afxcmn.h>
|
||||
#endif
|
||||
|
||||
/* More XP than anything */
|
||||
#include "xp.h"
|
||||
#include "fe_proto.h"
|
||||
#include "fe_rgn.h"
|
||||
#include "libi18n.h"
|
||||
#include "xlate.h"
|
||||
#include "ntypes.h"
|
||||
#ifdef EDITOR
|
||||
#include "edttypes.h"
|
||||
#endif
|
||||
#include "xpassert.h"
|
||||
#include "lo_ele.h"
|
||||
#include "layers.h"
|
||||
|
||||
/* Standard C includes */
|
||||
#ifndef _WIN32
|
||||
#include <dos.h>
|
||||
#endif
|
||||
#include <malloc.h>
|
||||
#include <direct.h>
|
||||
#include <stdarg.h>
|
||||
#include <time.h>
|
||||
#include <io.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#ifdef DEBUG
|
||||
#include <assert.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/* Very windows specific includes.
|
||||
*/
|
||||
/* WFE needs a layout file */
|
||||
extern "C" {
|
||||
#include "layout.h"
|
||||
}
|
||||
|
||||
/* Some common defines. */
|
||||
#ifndef _AFXDLL
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
/* All front end forward declarations needed to compile. */
|
||||
#include "forward.h"
|
||||
|
||||
/* Front end Casting macros. */
|
||||
#include "cast.h"
|
||||
|
||||
/* General purpose utilities. */
|
||||
#include "feutil.h"
|
||||
|
||||
/* afxData/sysInfo */
|
||||
#include "sysinfo.h"
|
||||
|
||||
/* Some defines we like everywhere. */
|
||||
#include "resource.h"
|
||||
#include "defaults.h"
|
||||
|
||||
/* The application include and
|
||||
* Commonly used, rarely changed headers */
|
||||
#include "ncapiurl.h"
|
||||
#include "genedit.h"
|
||||
#include "genframe.h"
|
||||
#include "genview.h"
|
||||
#include "gendoc.h"
|
||||
#include "intlwin.h"
|
||||
#include "mozilla.h"
|
||||
#include "cxwin.h"
|
||||
#include "winproto.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef assert
|
||||
#undef assert
|
||||
#endif
|
||||
#define assert(x) ASSERT(x)
|
||||
#endif
|
||||
|
||||
#endif /* STDAFX_PCH */
|
||||
@@ -1,38 +0,0 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape 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/NPL/
|
||||
#
|
||||
# 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 Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = base html xml xul xbl xsl
|
||||
|
||||
ifdef MOZ_SVG
|
||||
DIRS += svg
|
||||
endif
|
||||
|
||||
DIRS += events shared build
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape 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/NPL/
|
||||
#
|
||||
# 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 Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = public src
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape 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/NPL/
|
||||
#
|
||||
# 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 Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..\..
|
||||
|
||||
DIRS=public src \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
@@ -1,31 +0,0 @@
|
||||
#
|
||||
# This is a list of local files which get copied to the mozilla:dist:content directory
|
||||
#
|
||||
nsContentPolicyUtils.h
|
||||
nsContentUtils.h
|
||||
nsIAnonymousContent.h
|
||||
nsIContent.h
|
||||
nsIContentIterator.h
|
||||
nsIContentSerializer.h
|
||||
nsIDocument.h
|
||||
nsIDocumentContainer.h
|
||||
nsIDocumentEncoder.h
|
||||
nsIDocumentObserver.h
|
||||
nsIDocumentViewer.h
|
||||
nsIElementFactory.h
|
||||
nsIHTMLToTextSink.h
|
||||
nsINameSpace.h
|
||||
nsINameSpaceManager.h
|
||||
nsINodeInfo.h
|
||||
nsIPrivateDOMImplementation.h
|
||||
nsIRangeUtils.h
|
||||
nsIStyledContent.h
|
||||
nsIStyleRule.h
|
||||
nsIStyleRuleProcessor.h
|
||||
nsIStyleRuleSupplier.h
|
||||
nsIStyleSheet.h
|
||||
nsIStyleSheetLinkingElement.h
|
||||
nsITextContent.h
|
||||
nsIContentList.h
|
||||
nsIFrameLoader.h
|
||||
mozISanitizingSerializer.h
|
||||
@@ -1,17 +0,0 @@
|
||||
#
|
||||
# This is a list of local files which get copied to the mozilla:dist:idl directory
|
||||
#
|
||||
|
||||
nsIContentPolicy.idl
|
||||
nsISelection.idl
|
||||
nsISelectionController.idl
|
||||
nsISelectionListener.idl
|
||||
nsISelectionPrivate.idl
|
||||
nsIScriptLoader.idl
|
||||
nsIScriptLoaderObserver.idl
|
||||
nsIPrintProgress.idl
|
||||
nsIPrintStatusFeedback.idl
|
||||
nsIPrintProgressParams.idl
|
||||
nsIDragDropHandler.idl
|
||||
nsIDragDropOverride.idl
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape 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/NPL/
|
||||
#
|
||||
# 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 Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = content
|
||||
XPIDL_MODULE = content_base
|
||||
|
||||
EXPORTS = \
|
||||
nsIContent.h \
|
||||
nsIAnonymousContent.h \
|
||||
nsIContentIterator.h \
|
||||
nsContentPolicyUtils.h \
|
||||
nsContentUtils.h \
|
||||
nsIDocument.h \
|
||||
nsIDocumentContainer.h \
|
||||
nsIDocumentEncoder.h \
|
||||
nsIDocumentObserver.h \
|
||||
nsIDocumentViewer.h \
|
||||
nsIElementFactory.h \
|
||||
nsINameSpace.h \
|
||||
nsINameSpaceManager.h \
|
||||
nsINodeInfo.h \
|
||||
nsIRangeUtils.h \
|
||||
nsIStyledContent.h \
|
||||
nsIStyleRule.h \
|
||||
nsIStyleRuleSupplier.h \
|
||||
nsIStyleSheet.h \
|
||||
nsIStyleSheetLinkingElement.h \
|
||||
nsIStyleRuleProcessor.h \
|
||||
nsITextContent.h \
|
||||
nsIPrivateDOMImplementation.h \
|
||||
nsIContentSerializer.h \
|
||||
nsIHTMLToTextSink.h \
|
||||
mozISanitizingSerializer.h \
|
||||
nsIContentList.h \
|
||||
nsIFrameLoader.h \
|
||||
$(NULL)
|
||||
|
||||
XPIDLSRCS = \
|
||||
nsIContentPolicy.idl \
|
||||
nsISelectionController.idl \
|
||||
nsISelectionDisplay.idl \
|
||||
nsISelectionListener.idl \
|
||||
nsISelection.idl \
|
||||
nsISelectionPrivate.idl \
|
||||
nsIScriptLoader.idl \
|
||||
nsIScriptLoaderObserver.idl \
|
||||
nsIPrintProgress.idl \
|
||||
nsIPrintProgressParams.idl \
|
||||
nsIPrintStatusFeedback.idl \
|
||||
nsIDragDropHandler.idl \
|
||||
nsIDragDropOverride.idl \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape 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/NPL/
|
||||
#
|
||||
# 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 Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..\..\..
|
||||
|
||||
EXPORTS = \
|
||||
nsContentPolicyUtils.h \
|
||||
nsIContent.h \
|
||||
nsIAnonymousContent.h \
|
||||
nsIContentIterator.h \
|
||||
nsIDocument.h \
|
||||
nsIDocumentContainer.h \
|
||||
nsIDocumentEncoder.h \
|
||||
nsIDocumentObserver.h \
|
||||
nsIDocumentViewer.h \
|
||||
nsIElementFactory.h \
|
||||
nsINameSpace.h \
|
||||
nsINameSpaceManager.h \
|
||||
nsINodeInfo.h \
|
||||
nsIRangeUtils.h \
|
||||
nsIStyledContent.h \
|
||||
nsIStyleRule.h \
|
||||
nsIStyleRuleSupplier.h \
|
||||
nsIStyleSheet.h \
|
||||
nsIStyleSheetLinkingElement.h \
|
||||
nsIStyleRuleProcessor.h \
|
||||
nsITextContent.h \
|
||||
nsContentUtils.h \
|
||||
nsIPrivateDOMImplementation.h \
|
||||
nsIContentSerializer.h \
|
||||
nsIHTMLToTextSink.h \
|
||||
mozISanitizingSerializer.h \
|
||||
nsIContentList.h \
|
||||
nsIFrameLoader.h \
|
||||
$(NULL)
|
||||
|
||||
MODULE=content
|
||||
XPIDL_MODULE=content_base
|
||||
|
||||
XPIDLSRCS= \
|
||||
.\nsIContentPolicy.idl \
|
||||
.\nsISelectionController.idl \
|
||||
.\nsISelectionDisplay.idl \
|
||||
.\nsISelectionListener.idl \
|
||||
.\nsISelection.idl \
|
||||
.\nsISelectionPrivate.idl \
|
||||
.\nsIScriptLoader.idl \
|
||||
.\nsIScriptLoaderObserver.idl \
|
||||
.\nsIPrintProgress.idl \
|
||||
.\nsIPrintStatusFeedback.idl \
|
||||
.\nsIPrintProgressParams.idl \
|
||||
.\nsIDragDropHandler.idl \
|
||||
.\nsIDragDropOverride.idl \
|
||||
$(NULL)
|
||||
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
@@ -1,125 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 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 NPL, 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 NPL, 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"
|
||||
#include "nsAString.h"
|
||||
|
||||
#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_DEFINE_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.
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,305 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsContentCID_h__
|
||||
#define nsContentCID_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIComponentManager.h"
|
||||
|
||||
// {1691E1F7-EE41-11d4-9885-00C04FA0CF4B}
|
||||
#define NS_STYLESET_CID \
|
||||
{ 0x1691e1f7, 0xee41, 0x11d4, { 0x98, 0x85, 0x0, 0xc0, 0x4f, 0xa0, 0xcf, 0x4b } }
|
||||
|
||||
// {96882B70-8A27-11d2-8EAF-00805F29F370}
|
||||
#define NS_HTMLSTYLESHEET_CID \
|
||||
{ 0x96882b70, 0x8a27, 0x11d2, { 0x8e, 0xaf, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
// {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}}
|
||||
|
||||
/* a6cf90fc-15b3-11d2-932e-00805f8add32 */
|
||||
#define NS_HTML_ELEMENT_FACTORY_CID \
|
||||
{ 0xa6cf90fc, 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_XML_ELEMENT_FACTORY_CID \
|
||||
{ /* CF170391-79CC-11d3-BE44-0020A6361667 */ \
|
||||
0xcf170391, 0x79cc, 0x11d3, \
|
||||
{0xbe, 0x44, 0x0, 0x20, 0xa6, 0x36, 0x16, 0x67}}
|
||||
|
||||
#define NS_IMAGEDOCUMENT_CID \
|
||||
{ /* e11a6080-4daa-11d2-b328-00805f8a3859 */ \
|
||||
0xe11a6080, 0x4daa, 0x11d2, \
|
||||
{0xb3, 0x28, 0x00, 0x80, 0x5f, 0x8a, 0x38, 0x59}}
|
||||
|
||||
// {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 } }
|
||||
|
||||
// {96882B71-8A27-11d2-8EAF-00805F29F370}
|
||||
#define NS_TEXTNODE_CID \
|
||||
{ 0x96882b71, 0x8a27, 0x11d2, { 0x8e, 0xaf, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
// {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 } }
|
||||
|
||||
// {A1FDE868-E802-11d4-9885-00C04FA0CF4B}
|
||||
#define NS_ATTRIBUTECONTENT_CID \
|
||||
{ 0xa1fde868, 0xe802, 0x11d4, { 0x98, 0x85, 0x0, 0xc0, 0x4f, 0xa0, 0xcf, 0x4b } }
|
||||
|
||||
#define NS_CONTENTITERATOR_CID \
|
||||
{/* {a6cf90e3-15b3-11d2-932e-00805f8add32}*/ \
|
||||
0xa6cf90e3, 0x15b3, 0x11d2, {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
|
||||
|
||||
#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 } }
|
||||
|
||||
// {A1FDE862-E802-11d4-9885-00C04FA0CF4B}
|
||||
#define NS_EVENTSTATEMANAGER_CID \
|
||||
{ 0xa1fde862, 0xe802, 0x11d4, { 0x98, 0x85, 0x0, 0xc0, 0x4f, 0xa0, 0xcf, 0x4b } }
|
||||
|
||||
// {64F300A1-C88C-11d3-97FB-00400553EEF0}
|
||||
#define NS_XBLSERVICE_CID \
|
||||
{ 0x64f300a1, 0xc88c, 0x11d3, { 0x97, 0xfb, 0x0, 0x40, 0x5, 0x53, 0xee, 0xf0 } }
|
||||
|
||||
// {15671AF5-39F9-4c70-8CE3-72C97111B52D}
|
||||
#define NS_BINDINGMANAGER_CID \
|
||||
{ 0x15671af5, 0x39f9, 0x4c70, { 0x8c, 0xe3, 0x72, 0xc9, 0x71, 0x11, 0xb5, 0x2d } }
|
||||
|
||||
// 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 } }
|
||||
|
||||
// {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 } }
|
||||
|
||||
// {76E92881-CDDB-11d3-BF87-00105A1B0627}
|
||||
#define NS_XULELEMENTFACTORY_CID \
|
||||
{ 0x76e92881, 0xcddb, 0x11d3, { 0xbf, 0x87, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } }
|
||||
|
||||
|
||||
// {508f5601-e09b-11d3-9f7e-cf931f9f173c}
|
||||
#define NS_CONTROLLERCOMMANDMANAGER_CID \
|
||||
{ 0x508f5601, 0xe09b, 0x11d3, { 0x9f, 0x7e, 0xcf, 0x93, 0x1f, 0x9f, 0x17, 0x3c } }
|
||||
|
||||
// {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_MATHML
|
||||
// {68b9fbda-f230-45a9-bf92-dbbbd4ac8555}
|
||||
#define NS_MATHMLELEMENTFACTORY_CID \
|
||||
{ 0x68b9fbda, 0xf230, 0x45a9, {0xbf, 0x92, 0xdb, 0xbb, 0xd4, 0xac, 0x85, 0x55 } }
|
||||
#endif // MOZ_MATHML
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
|
||||
// {4E48C00A-E20F-4061-B869-2BAC285D68E8}
|
||||
#define NS_SVGELEMENTFACTORY_DEPRECATED_CID \
|
||||
{ 0x4e48c00a, 0xe20f, 0x4061, { 0xb8, 0x69, 0x2b, 0xac, 0x28, 0x5d, 0x68, 0xe8 } }
|
||||
|
||||
|
||||
// {34D9B28A-FBFF-4bbd-8546-1822FE3FB8B5}
|
||||
#define NS_SVGELEMENTFACTORY_CID \
|
||||
{ 0x34d9b28a, 0xfbff, 0x4bbd, { 0x85, 0x46, 0x18, 0x22, 0xfe, 0x3f, 0xb8, 0xb5 } }
|
||||
|
||||
#define NS_SVGDOCUMENT_CID \
|
||||
{ /* b7f44954-1dd1-11b2-8c2e-c2feab4186bc */ \
|
||||
0xb7f44954, 0x11d1, 0x11b2, \
|
||||
{0x8c, 0x2e, 0xc2, 0xfe, 0xab, 0x41, 0x86, 0xbc}}
|
||||
|
||||
#endif // MOZ_SVG
|
||||
|
||||
#endif /* nsContentCID_h__ */
|
||||
@@ -1,69 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* 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 Zero-Knowledge are Copyright (C) 2000
|
||||
* Zero-Knowledge Systems, Inc. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
/*
|
||||
* Utility routines for checking content load/process policy settings.
|
||||
*/
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsIContentPolicy.h"
|
||||
#include "nsIMemory.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
#ifndef __nsContentPolicyUtils_h__
|
||||
#define __nsContentPolicyUtils_h__
|
||||
|
||||
class nsIDOMElement;
|
||||
|
||||
#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 }}
|
||||
|
||||
/* Takes contentType, aURI, context, and window from its "caller"'s context. */
|
||||
#define CHECK_CONTENT_POLICY(action, result) \
|
||||
nsCOMPtr<nsIContentPolicy> policy = \
|
||||
do_GetService(NS_CONTENTPOLICY_CONTRACTID); \
|
||||
if (!policy) \
|
||||
return NS_ERROR_FAILURE; \
|
||||
\
|
||||
return policy-> action (contentType, aURI, context, window, result);
|
||||
|
||||
inline nsresult
|
||||
NS_CheckContentLoadPolicy(PRInt32 contentType, nsIURI *aURI,
|
||||
nsISupports *context, nsIDOMWindow *window,
|
||||
PRBool *shouldLoad)
|
||||
{
|
||||
CHECK_CONTENT_POLICY(ShouldLoad, shouldLoad);
|
||||
}
|
||||
|
||||
inline nsresult
|
||||
NS_CheckContentProcessPolicy(PRInt32 contentType, nsIURI *aURI,
|
||||
nsISupports *context, nsIDOMWindow *window,
|
||||
PRBool *shouldProcess)
|
||||
{
|
||||
CHECK_CONTENT_POLICY(ShouldProcess, shouldProcess);
|
||||
}
|
||||
|
||||
#undef CHECK_CONTENT_POLICY
|
||||
|
||||
#endif /* __nsContentPolicyUtils_h__ */
|
||||
@@ -1,194 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the NPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the NPL or the GPL.
|
||||
*/
|
||||
|
||||
/* A namespace class for static content utilities. */
|
||||
|
||||
#ifndef nsContentUtils_h___
|
||||
#define nsContentUtils_h___
|
||||
|
||||
#include "jspubtd.h"
|
||||
#include "nsAString.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMScriptObjectFactory.h"
|
||||
|
||||
class nsIScriptContext;
|
||||
class nsIScriptGlobalObject;
|
||||
class nsIXPConnect;
|
||||
class nsIContent;
|
||||
class nsIDocument;
|
||||
|
||||
|
||||
class nsContentUtils
|
||||
{
|
||||
public:
|
||||
static nsresult Init();
|
||||
|
||||
static nsresult ReparentContentWrapper(nsIContent *aContent,
|
||||
nsIContent *aNewParent,
|
||||
nsIDocument *aNewDocument,
|
||||
nsIDocument *aOldDocument);
|
||||
|
||||
static PRBool IsCallerChrome();
|
||||
|
||||
/*
|
||||
* Returns true if the nodes are both in the same document or
|
||||
* if neither is in a document.
|
||||
* Returns false if the nodes are not in the same document.
|
||||
*/
|
||||
static PRBool InSameDoc(nsIDOMNode *aNode,
|
||||
nsIDOMNode *aOther);
|
||||
|
||||
/**
|
||||
* Do not ever pass null pointers to this method. If one of your
|
||||
* nsIContents is null, you have to decide for yourself what
|
||||
* "IsDescendantOf" really means.
|
||||
*
|
||||
* @param aPossibleDescendant node to test for being a descendant of
|
||||
* aPossibleAncestor
|
||||
* @param aPossibleAncestor node to test for being an ancestor of
|
||||
* aPossibleDescendant
|
||||
* @return PR_TRUE if aPossibleDescendant is a descendant of
|
||||
* aPossibleAncestor (or is aPossibleAncestor). PR_FALSE
|
||||
* otherwise.
|
||||
*/
|
||||
static PRBool ContentIsDescendantOf(nsIContent* aPossibleDescendant,
|
||||
nsIContent* aPossibleAncestor);
|
||||
|
||||
/*
|
||||
* This method fills the |aArray| with all ancestor nodes of |aNode|
|
||||
* including |aNode| at the zero index.
|
||||
*
|
||||
* These elements were |nsIDOMNode*|s before casting to |void*| and must
|
||||
* be cast back to |nsIDOMNode*| on usage, or bad things will happen.
|
||||
*/
|
||||
static nsresult GetAncestors(nsIDOMNode* aNode,
|
||||
nsVoidArray* aArray);
|
||||
|
||||
/*
|
||||
* This method fills |aAncestorNodes| with all ancestor nodes of |aNode|
|
||||
* including |aNode| (QI'd to nsIContent) at the zero index.
|
||||
* For each ancestor, there is a corresponding element in |aAncestorOffsets|
|
||||
* which is the IndexOf the child in relation to its parent.
|
||||
*
|
||||
* The elements of |aAncestorNodes| were |nsIContent*|s before casting to
|
||||
* |void*| and must be cast back to |nsIContent*| on usage, or bad things
|
||||
* will happen.
|
||||
*
|
||||
* This method just sucks.
|
||||
*/
|
||||
static nsresult GetAncestorsAndOffsets(nsIDOMNode* aNode,
|
||||
PRInt32 aOffset,
|
||||
nsVoidArray* aAncestorNodes,
|
||||
nsVoidArray* aAncestorOffsets);
|
||||
|
||||
/*
|
||||
* The out parameter, |aCommonAncestor| will be the closest node, if any,
|
||||
* to both |aNode| and |aOther| which is also an ancestor of each.
|
||||
*/
|
||||
static nsresult GetCommonAncestor(nsIDOMNode *aNode,
|
||||
nsIDOMNode *aOther,
|
||||
nsIDOMNode** aCommonAncestor);
|
||||
|
||||
/*
|
||||
* |aDifferentNodes| will contain up to 3 elements.
|
||||
* The first, if present, is the common ancestor of |aNode| and |aOther|.
|
||||
* The second, if present, is the ancestor node of |aNode| which is
|
||||
* closest to the common ancestor, but not an ancestor of |aOther|.
|
||||
* The third, if present, is the ancestor node of |aOther| which is
|
||||
* closest to the common ancestor, but not an ancestor of |aNode|.
|
||||
*
|
||||
* These elements were |nsIDOMNode*|s before casting to void* and must
|
||||
* be cast back to |nsIDOMNode*| on usage, or bad things will happen.
|
||||
*/
|
||||
static nsresult GetFirstDifferentAncestors(nsIDOMNode *aNode,
|
||||
nsIDOMNode *aOther,
|
||||
nsVoidArray* aDifferentNodes);
|
||||
|
||||
// These are copied from nsJSUtils.h
|
||||
|
||||
static nsresult GetStaticScriptGlobal(JSContext* aContext,
|
||||
JSObject* aObj,
|
||||
nsIScriptGlobalObject** aNativeGlobal);
|
||||
|
||||
static nsresult GetStaticScriptContext(JSContext* aContext,
|
||||
JSObject* aObj,
|
||||
nsIScriptContext** aScriptContext);
|
||||
|
||||
static nsresult GetDynamicScriptGlobal(JSContext *aContext,
|
||||
nsIScriptGlobalObject** aNativeGlobal);
|
||||
|
||||
static nsresult GetDynamicScriptContext(JSContext *aContext,
|
||||
nsIScriptContext** aScriptContext);
|
||||
|
||||
static PRUint32 CopyNewlineNormalizedUnicodeTo(const nsAString& aSource,
|
||||
PRUint32 aSrcOffset,
|
||||
PRUnichar* aDest,
|
||||
PRUint32 aLength,
|
||||
PRBool& aLastCharCR);
|
||||
|
||||
static PRUint32 CopyNewlineNormalizedUnicodeTo(nsReadingIterator<PRUnichar>& aSrcStart, const nsReadingIterator<PRUnichar>& aSrcEnd, nsAString& aDest);
|
||||
|
||||
static nsISupports *
|
||||
GetClassInfoInstance(nsDOMClassInfoID aID);
|
||||
|
||||
static const nsDependentSubstring TrimCharsInSet(const char* aSet,
|
||||
const nsAString& aValue);
|
||||
|
||||
static void Shutdown();
|
||||
|
||||
private:
|
||||
static nsresult doReparentContentWrapper(nsIContent *aChild,
|
||||
nsIDocument *aNewDocument,
|
||||
nsIDocument *aOldDocument,
|
||||
JSContext *cx,
|
||||
JSObject *parent_obj);
|
||||
|
||||
|
||||
static nsIDOMScriptObjectFactory *sDOMScriptObjectFactory;
|
||||
|
||||
static nsIXPConnect *sXPConnect;
|
||||
};
|
||||
|
||||
#define NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(_class) \
|
||||
if (aIID.Equals(NS_GET_IID(nsIClassInfo))) { \
|
||||
foundInterface = \
|
||||
nsContentUtils::GetClassInfoInstance(eDOMClassInfo_##_class##_id); \
|
||||
NS_ENSURE_TRUE(foundInterface, NS_ERROR_OUT_OF_MEMORY); \
|
||||
\
|
||||
*aInstancePtr = foundInterface; \
|
||||
\
|
||||
return NS_OK; \
|
||||
} else
|
||||
|
||||
#endif /* nsContentUtils_h___ */
|
||||
@@ -1,66 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
|
||||
#ifndef nsIAnonymousContent_h___
|
||||
#define nsIAnonymousContent_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsISupportsArray;
|
||||
class nsIAtom;
|
||||
class nsINodeInfo;
|
||||
|
||||
#define NS_IANONYMOUS_CONTENT_IID { 0x41a69e00, 0x2d6d, 0x12d3, { 0xb0, 0x33, 0xa1, 0x38, 0x71, 0x39, 0x78, 0x7c } }
|
||||
|
||||
|
||||
/**
|
||||
* If a node is anonymous. Then it should implement this interface.
|
||||
*/
|
||||
class nsIAnonymousContent : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IANONYMOUS_CONTENT_IID)
|
||||
|
||||
NS_IMETHOD Init(nsINodeInfo *aInfo) = 0;
|
||||
};
|
||||
|
||||
nsresult NS_NewAnonymousContent2(nsIContent **aNewNode);
|
||||
#endif
|
||||
|
||||
@@ -1,383 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsIContent_h___
|
||||
#define nsIContent_h___
|
||||
|
||||
#include <stdio.h>
|
||||
#include "nsISupports.h"
|
||||
#include "nsEvent.h"
|
||||
#include "nsAString.h"
|
||||
|
||||
// Forward declarations
|
||||
class nsIAtom;
|
||||
class nsIDocument;
|
||||
class nsIPresContext;
|
||||
class nsVoidArray;
|
||||
class nsIDOMEvent;
|
||||
class nsIContent;
|
||||
class nsISupportsArray;
|
||||
class nsIDOMRange;
|
||||
class nsISizeOfHandler;
|
||||
class nsINodeInfo;
|
||||
class nsIEventListenerManager;
|
||||
|
||||
// IID for the nsIContent interface
|
||||
#define NS_ICONTENT_IID \
|
||||
{ 0x78030220, 0x9447, 0x11d1, \
|
||||
{0x93, 0x23, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
|
||||
|
||||
// A node of content in a documents content model. This interface
|
||||
// is supported by all content objects.
|
||||
class nsIContent : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICONTENT_IID)
|
||||
|
||||
NS_IMETHOD GetDocument(nsIDocument*& aResult) const = 0;
|
||||
|
||||
NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep, PRBool aCompileEventHandlers) = 0;
|
||||
|
||||
NS_IMETHOD GetParent(nsIContent*& aResult) const = 0;
|
||||
|
||||
NS_IMETHOD SetParent(nsIContent* aParent) = 0;
|
||||
|
||||
/**
|
||||
* Get the namespace that this tag is defined in
|
||||
*/
|
||||
NS_IMETHOD GetNameSpaceID(PRInt32& aResult) const = 0;
|
||||
|
||||
NS_IMETHOD GetTag(nsIAtom*& aResult) const = 0;
|
||||
|
||||
NS_IMETHOD GetNodeInfo(nsINodeInfo*& aResult) const = 0;
|
||||
|
||||
NS_IMETHOD CanContainChildren(PRBool& aResult) const = 0;
|
||||
|
||||
NS_IMETHOD ChildCount(PRInt32& aResult) const = 0;
|
||||
|
||||
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent*& aResult) const = 0;
|
||||
|
||||
NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aIndex) const = 0;
|
||||
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
PRBool aNotify, PRBool aDeepSetDocument) = 0;
|
||||
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
PRBool aNotify, PRBool aDeepSetDocument) = 0;
|
||||
|
||||
NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify,
|
||||
PRBool aDeepSetDocument) = 0;
|
||||
|
||||
NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify) = 0;
|
||||
|
||||
/**
|
||||
* Normalizes an attribute string into an atom that represents the
|
||||
* qualified attribute name of the attribute. This method is intended
|
||||
* for character case conversion if the content object is case
|
||||
* insensitive (e.g. HTML).
|
||||
*
|
||||
* @param aStr the unparsed attribute string
|
||||
* @param aName out parameter representing the complete name of the
|
||||
* attribute
|
||||
*/
|
||||
NS_IMETHOD NormalizeAttrString(const nsAString& aStr,
|
||||
nsINodeInfo*& aNodeInfo) = 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 aName the name of the attribute
|
||||
|
||||
* @param aValue may legitimately be the empty string.
|
||||
*
|
||||
* @param aUpdateMask specifies how whether or not the document should be
|
||||
* notified of the attribute change.
|
||||
*/
|
||||
NS_IMETHOD SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
const nsAString& aValue,
|
||||
PRBool aNotify) = 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 aNodeInfo the node info (name, prefix, namespace id) of the
|
||||
* attribute
|
||||
* @param aValue may legitimately be the empty string.
|
||||
*
|
||||
* @param aNotify specifies whether or not the document should be
|
||||
* notified of the attribute change.
|
||||
*/
|
||||
NS_IMETHOD SetAttr(nsINodeInfo* aNodeInfo,
|
||||
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.
|
||||
*
|
||||
* <UL>
|
||||
*
|
||||
* <LI>If the attribute is not set and has no default value, return
|
||||
* NS_CONTENT_ATTR_NOT_THERE.
|
||||
*
|
||||
* <LI>If the attribute exists, but has no value, return
|
||||
* NS_CONTENT_ATTR_NO_VALUE.
|
||||
*
|
||||
* <LI>If the attribute has a non-empty value, set ret to
|
||||
* be the value, and return NS_CONTENT_ATTR_HAS_VALUE (== NS_OK).
|
||||
*
|
||||
* </UL>
|
||||
*/
|
||||
NS_IMETHOD GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
nsAString& aResult) const = 0;
|
||||
|
||||
/**
|
||||
* Get the current value and prefix of the attribute. This returns a form
|
||||
* that is suitable for passing back into SetAttr.
|
||||
*
|
||||
* <UL>
|
||||
*
|
||||
* <LI>If the attribute is not set and has no default value, return
|
||||
* NS_CONTENT_ATTR_NOT_THERE.
|
||||
*
|
||||
* <LI>If the attribute exists, but has no value, return
|
||||
* NS_CONTENT_ATTR_NO_VALUE.
|
||||
*
|
||||
* <LI>If the attribute has a non-empty value, set ret to
|
||||
* be the value, and return NS_CONTENT_ATTR_HAS_VALUE (== NS_OK).
|
||||
*
|
||||
* </UL>
|
||||
*
|
||||
* NOTE! aPrefix is an OUT parameter.
|
||||
*/
|
||||
|
||||
NS_IMETHOD GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
nsIAtom*& aPrefix, nsAString& aResult) const = 0;
|
||||
|
||||
/**
|
||||
* Determine if an attribute has been set.
|
||||
*
|
||||
* @param aNameSpaceId the namespace id of the attribute
|
||||
* @param aAttr the attribute name
|
||||
*/
|
||||
|
||||
NS_IMETHOD_(PRBool) HasAttr(PRInt32 aNameSpaceID, nsIAtom* aName) const = 0;
|
||||
|
||||
/**
|
||||
* Remove an attribute so that it is no longer explicitly specified.
|
||||
*
|
||||
* @param aAttr the name of the attribute to unset
|
||||
*
|
||||
* @param aNotify specifies whether or not the document should be
|
||||
* notified of the attribute change
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttr,
|
||||
PRBool aNotify) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Get the namespace & name of a given attribute.
|
||||
*
|
||||
* @param aIndex the index of the attribute name
|
||||
* @param aNameSpace an out param of the name space ID of the attribute name
|
||||
* @param aName an out param if the attribute name
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetAttrNameAt(PRInt32 aIndex,
|
||||
PRInt32& aNameSpaceID,
|
||||
nsIAtom*& aName,
|
||||
nsIAtom*& aPrefix) const = 0;
|
||||
|
||||
/**
|
||||
* Get the number of all specified attributes.
|
||||
*
|
||||
* @param aCountResult an out parameter to be filled in with
|
||||
* the number of attributes
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetAttrCount(PRInt32& aCountResult) const = 0;
|
||||
|
||||
/**
|
||||
* Inform content of range ownership changes. This allows content
|
||||
* to do the right thing to ranges in the face of changes to the content
|
||||
* model.
|
||||
|
||||
* RangeAdd -- informs content that it owns one or both range endpoints
|
||||
* 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
|
||||
*/
|
||||
NS_IMETHOD RangeAdd(nsIDOMRange* aRange) = 0;
|
||||
NS_IMETHOD RangeRemove(nsIDOMRange* aRange) = 0;
|
||||
NS_IMETHOD GetRangeList(nsVoidArray*& aResult) const = 0;
|
||||
|
||||
/**
|
||||
* Handle a DOM event for this piece of content.
|
||||
*/
|
||||
NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus) = 0;
|
||||
|
||||
/**
|
||||
* Get and set a unique ID for this piece of content.
|
||||
* This ID is used as a key to store state information
|
||||
* about this content object and its associated frame object.
|
||||
* The state information is stored in a dictionary that is
|
||||
* manipulated by the frame manager (nsIFrameManager) inside layout.
|
||||
* An opaque pointer to this dictionary is passed to the session
|
||||
* history as a handle associated with the current document's state
|
||||
*/
|
||||
NS_IMETHOD GetContentID(PRUint32* aID) = 0;
|
||||
NS_IMETHOD SetContentID(PRUint32 aID) = 0;
|
||||
|
||||
/**
|
||||
* All content elements are potentially focusable (according to CSS3).
|
||||
* These methods are used to set and remove the focus on the content
|
||||
* element.
|
||||
*/
|
||||
NS_IMETHOD SetFocus(nsIPresContext* aPresContext) = 0;
|
||||
NS_IMETHOD RemoveFocus(nsIPresContext* aPresContext) = 0;
|
||||
|
||||
/**
|
||||
* APIs for setting and obtaining the content node
|
||||
* with the binding responsible for our construction (and existence)
|
||||
* Used by anonymous content (XBL-generated). null for all explicit content.
|
||||
*/
|
||||
NS_IMETHOD SetBindingParent(nsIContent* aContent) = 0;
|
||||
NS_IMETHOD GetBindingParent(nsIContent** aContent) = 0;
|
||||
|
||||
/**
|
||||
* Bit-flags to pass (or'ed together) to IsContentOfType()
|
||||
*/
|
||||
enum {
|
||||
eTEXT = 0x00000001,
|
||||
eELEMENT = 0x00000002,
|
||||
eHTML = 0x00000004,
|
||||
eHTML_FORM_CONTROL = 0x00000008,
|
||||
eXUL = 0x00000010
|
||||
};
|
||||
|
||||
/**
|
||||
* API for doing a quick check if a content object is of a given
|
||||
* type, such as HTML, XUL, Text, ...
|
||||
*/
|
||||
NS_IMETHOD_(PRBool) IsContentOfType(PRUint32 aFlags) = 0;
|
||||
|
||||
NS_IMETHOD GetListenerManager(nsIEventListenerManager** aResult) = 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) * 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).
|
||||
*/
|
||||
NS_IMETHOD DoneCreatingElement() = 0;
|
||||
|
||||
#ifdef DEBUG
|
||||
/**
|
||||
* Get the size of the content object. The size value should include
|
||||
* all subordinate data referenced by the content that is not
|
||||
* accounted for by child content. However, this value should not
|
||||
* include the frame objects, style contexts, views or other data
|
||||
* that lies logically outside the content model.
|
||||
*
|
||||
* If the implementation so chooses, instead of returning the total
|
||||
* subordinate data it may instead use the sizeof handler to store
|
||||
* away subordinate data under its own key so that the subordinate
|
||||
* data may be tabulated independently of the frame itself.
|
||||
*
|
||||
* The caller is responsible for recursing over all children that
|
||||
* the content contains.
|
||||
*/
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const = 0;
|
||||
|
||||
/**
|
||||
* List the content (and anything it contains) out to the given
|
||||
* file stream. Use aIndent as the base indent during formatting.
|
||||
* Returns NS_OK unless a file error occurs.
|
||||
*/
|
||||
NS_IMETHOD 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.
|
||||
* Returns NS_OK unless a file error occurs.
|
||||
*/
|
||||
NS_IMETHOD DumpContent(FILE* out = stdout, PRInt32 aIndent = 0,PRBool aDumpAll=PR_TRUE) const = 0;
|
||||
#endif
|
||||
};
|
||||
|
||||
// nsresult codes for GetAttr
|
||||
#define NS_CONTENT_ATTR_HAS_VALUE NS_OK
|
||||
|
||||
#define NS_CONTENT_ATTR_NO_VALUE \
|
||||
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_LAYOUT,0)
|
||||
|
||||
#define NS_CONTENT_ATTR_NOT_THERE \
|
||||
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_LAYOUT,1)
|
||||
|
||||
#endif /* nsIContent_h___ */
|
||||
@@ -1,129 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __nsIContentIterator_h___
|
||||
#define __nsIContentIterator_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
|
||||
class nsIFocusTracker;
|
||||
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_DEFINE_STATIC_IID_ACCESSOR(NS_ICONTENTITERTOR_IID)
|
||||
|
||||
/* Initializes an iterator for the subtree rooted by the node aRoot
|
||||
*/
|
||||
NS_IMETHOD Init(nsIContent* aRoot)=0;
|
||||
|
||||
/* Initializes an iterator for the subtree defined by the range aRange
|
||||
*/
|
||||
NS_IMETHOD Init(nsIDOMRange* aRange)=0;
|
||||
|
||||
/** First will reset the list. will return NS_FAILED if no items
|
||||
*/
|
||||
NS_IMETHOD First()=0;
|
||||
|
||||
/** Last will reset the list to the end. will return NS_FAILED if no items
|
||||
*/
|
||||
NS_IMETHOD Last()=0;
|
||||
|
||||
/** Next will advance the list. will return failed if allready at end
|
||||
*/
|
||||
NS_IMETHOD Next()=0;
|
||||
|
||||
/** Prev will decrement the list. will return failed if allready at beginning
|
||||
*/
|
||||
NS_IMETHOD Prev()=0;
|
||||
|
||||
/** CurrentItem will return the CurrentItem item it will fail if the list is empty
|
||||
* @param aItem return value
|
||||
*/
|
||||
NS_IMETHOD CurrentNode(nsIContent **aNode)=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
|
||||
* @param aItem return value
|
||||
*/
|
||||
NS_IMETHOD IsDone()=0;
|
||||
|
||||
/** PositionAt will position the iterator to the supplied node
|
||||
*/
|
||||
NS_IMETHOD PositionAt(nsIContent* aCurNode)=0;
|
||||
|
||||
/** MakePre will make the iterator a pre-order iterator
|
||||
*/
|
||||
NS_IMETHOD MakePre()=0;
|
||||
|
||||
/** MakePost will make the iterator a post-order iterator
|
||||
*/
|
||||
NS_IMETHOD MakePost()=0;
|
||||
|
||||
};
|
||||
|
||||
class nsIPresShell;
|
||||
|
||||
class nsIGeneratedContentIterator : public nsISupports {
|
||||
public:
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IGENERATEDCONTENTITERTOR_IID)
|
||||
|
||||
/* Initializes an iterator for the subtree rooted by the node aRoot
|
||||
*/
|
||||
NS_IMETHOD Init(nsIPresShell *aShell, nsIDOMRange* aRange)=0;
|
||||
|
||||
NS_IMETHOD Init(nsIPresShell *aShell, nsIContent* aContent)=0;
|
||||
};
|
||||
|
||||
|
||||
#endif // __nsIContentIterator_h___
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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) 2001
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsIContentList_h___
|
||||
#define nsIContentList_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
// d72cb400-4b33-11d5-a041-0010a4ef48c9
|
||||
#define NS_ICONTENTLIST_IID \
|
||||
{ 0xd72cb400, 0x4b33, 0x11d5, { 0xa0, 0x41, 0x0, 0x10, 0xa4, 0xef, 0x48, 0xc9 } }
|
||||
|
||||
/**
|
||||
* Interface for content list.
|
||||
*/
|
||||
class nsIContentList : public nsISupports {
|
||||
public:
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICONTENTLIST_IID)
|
||||
|
||||
// Callers will want to pass in PR_TRUE for aDoFlush unless they
|
||||
// are explicitly avoiding an FlushPendingNotifications. The
|
||||
// flush guarantees that the list will be up to date.
|
||||
|
||||
NS_IMETHOD GetLength(PRUint32* aLength, PRBool aDoFlush) = 0;
|
||||
|
||||
NS_IMETHOD Item(PRUint32 aIndex, nsIDOMNode** aReturn,
|
||||
PRBool aDoFlush) = 0;
|
||||
|
||||
NS_IMETHOD NamedItem(const nsAString& aName, nsIDOMNode** aReturn,
|
||||
PRBool aDoFlush) = 0;
|
||||
|
||||
NS_IMETHOD IndexOf(nsIContent *aContent, PRInt32& aIndex,
|
||||
PRBool aDoFlush) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIContentList_h___ */
|
||||
@@ -1,58 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* 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 Zero-Knowledge are Copyright (C) 2000
|
||||
* Zero-Knowledge Systems, Inc. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDOMWindow;
|
||||
interface nsIURI;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
[scriptable,uuid(1cb4085d-5407-4169-bcfe-4c5ba013fa5b)]
|
||||
interface nsIContentPolicy : nsISupports
|
||||
{
|
||||
const PRInt32 OTHER = 0;
|
||||
const PRInt32 SCRIPT = 1;
|
||||
const PRInt32 IMAGE = 2;
|
||||
const PRInt32 STYLESHEET = 3;
|
||||
const PRInt32 OBJECT = 4;
|
||||
const PRInt32 SUBDOCUMENT = 5;
|
||||
const PRInt32 CONTROL_TAG = 6;
|
||||
const PRInt32 RAW_URL = 7;
|
||||
const PRInt32 DOCUMENT = 8;
|
||||
|
||||
/**
|
||||
* Should the content at this location be loaded and processed?
|
||||
*
|
||||
*/
|
||||
boolean shouldLoad(in PRInt32 contentType, in nsIURI contentLocation,
|
||||
in nsISupports ctxt, in nsIDOMWindow window);
|
||||
|
||||
/**
|
||||
* Should the contents of the element in question be processed?
|
||||
*/
|
||||
boolean shouldProcess(in PRInt32 contentType, in nsIURI documentLocation,
|
||||
in nsISupports ctxt, in nsIDOMWindow window);
|
||||
};
|
||||
@@ -1,99 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _nsIContentSerializer_h__
|
||||
#define _nsIContentSerializer_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsAString.h"
|
||||
#include "nsIAtom.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 */
|
||||
|
||||
/* starting interface: nsIContentSerializer */
|
||||
#define NS_ICONTENTSERIALIZER_IID_STR "61e9b9a3-d30c-429e-b0cf-ade73466df06"
|
||||
|
||||
#define NS_ICONTENTSERIALIZER_IID \
|
||||
{0x61e9b9a3, 0xd30c, 0x429e, \
|
||||
{ 0xb0, 0xcf, 0xad, 0xe7, 0x34, 0x66, 0xdf, 0x06 }}
|
||||
|
||||
class nsIContentSerializer : public nsISupports {
|
||||
public:
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICONTENTSERIALIZER_IID)
|
||||
|
||||
NS_IMETHOD Init(PRUint32 flags, PRUint32 aWrapColumn,
|
||||
nsIAtom* 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,
|
||||
PRBool aHasChildren,
|
||||
nsAString& aStr) = 0;
|
||||
|
||||
NS_IMETHOD AppendElementEnd(nsIDOMElement *aElement,
|
||||
nsAString& aStr) = 0;
|
||||
|
||||
NS_IMETHOD Flush(nsAString& aStr) = 0;
|
||||
};
|
||||
|
||||
#define NS_CONTENTSERIALIZER_CONTRACTID_PREFIX \
|
||||
"@mozilla.org/layout/contentserializer;1?mimetype="
|
||||
|
||||
#endif /* __gen_nsIContentSerializer_h__ */
|
||||
@@ -1,441 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsIDocument_h___
|
||||
#define nsIDocument_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsEvent.h"
|
||||
#include "nsAString.h"
|
||||
#include "nsString.h"
|
||||
|
||||
class nsIAtom;
|
||||
class nsIArena;
|
||||
class nsIContent;
|
||||
class nsIDocumentContainer;
|
||||
class nsIDocumentObserver;
|
||||
class nsIPresContext;
|
||||
class nsIPresShell;
|
||||
|
||||
class nsIStreamListener;
|
||||
class nsIStreamObserver;
|
||||
class nsIStyleSet;
|
||||
class nsIStyleSheet;
|
||||
class nsIStyleRule;
|
||||
class nsIURI;
|
||||
class nsILoadGroup;
|
||||
class nsIViewManager;
|
||||
class nsIScriptGlobalObject;
|
||||
class nsIDOMEvent;
|
||||
class nsIDeviceContext;
|
||||
class nsIParser;
|
||||
class nsIDOMNode;
|
||||
class nsINameSpaceManager;
|
||||
class nsIDOMDocumentFragment;
|
||||
class nsILineBreaker;
|
||||
class nsIWordBreaker;
|
||||
class nsISelection;
|
||||
class nsIChannel;
|
||||
class nsIPrincipal;
|
||||
class nsINodeInfoManager;
|
||||
class nsIDOMDocument;
|
||||
class nsIDOMDocumentType;
|
||||
class nsIBindingManager;
|
||||
class nsIObserver;
|
||||
class nsISupportsArray;
|
||||
class nsIScriptLoader;
|
||||
class nsString;
|
||||
class nsIFocusController;
|
||||
class nsIContentSink;
|
||||
|
||||
// IID for the nsIDocument interface
|
||||
#define NS_IDOCUMENT_IID \
|
||||
{ 0x94c6ceb0, 0x9447, 0x11d1, \
|
||||
{0x93, 0x23, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
|
||||
|
||||
// The base value for the content ID counter.
|
||||
// This counter is used by the document to
|
||||
// assign a monotonically increasing ID to each content
|
||||
// object it creates
|
||||
#define NS_CONTENT_ID_COUNTER_BASE 10000
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// Document interface
|
||||
class nsIDocument : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDOCUMENT_IID)
|
||||
|
||||
// All documents have a memory arena associated with them which is
|
||||
// used for memory allocation during document creation. This call
|
||||
// returns the arena associated with this document.
|
||||
NS_IMETHOD GetArena(nsIArena** aArena) = 0;
|
||||
|
||||
NS_IMETHOD StartDocumentLoad(const char* aCommand,
|
||||
nsIChannel* aChannel,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsISupports* aContainer,
|
||||
nsIStreamListener **aDocListener,
|
||||
PRBool aReset,
|
||||
nsIContentSink* aSink = nsnull) = 0;
|
||||
|
||||
NS_IMETHOD StopDocumentLoad() = 0;
|
||||
|
||||
/**
|
||||
* Return the title of the document. May return null.
|
||||
*/
|
||||
virtual const nsString* GetDocumentTitle() const = 0;
|
||||
|
||||
/**
|
||||
* Return the URL for the document. May return null.
|
||||
*/
|
||||
NS_IMETHOD GetDocumentURL(nsIURI** aURL) const = 0;
|
||||
NS_IMETHOD SetDocumentURL(nsIURI* aURL) = 0;
|
||||
|
||||
/**
|
||||
* Return the principal responsible for this document.
|
||||
*/
|
||||
NS_IMETHOD GetPrincipal(nsIPrincipal **aPrincipal) = 0;
|
||||
|
||||
/**
|
||||
* Update principal responsible for this document to the intersection
|
||||
* of its previous value and aPrincipal.
|
||||
*/
|
||||
NS_IMETHOD AddPrincipal(nsIPrincipal *aPrincipal) = 0;
|
||||
|
||||
/**
|
||||
* Return the LoadGroup for the document. May return null.
|
||||
*/
|
||||
NS_IMETHOD GetDocumentLoadGroup(nsILoadGroup** aGroup) const = 0;
|
||||
|
||||
/**
|
||||
* Return the base URL for relative URLs in the document. May return null (or the document URL).
|
||||
*/
|
||||
NS_IMETHOD GetBaseURL(nsIURI*& aURL) const = 0;
|
||||
NS_IMETHOD SetBaseURL(nsIURI* aURL) = 0;
|
||||
|
||||
/**
|
||||
* Get/Set the base target of a link in a document.
|
||||
*/
|
||||
NS_IMETHOD GetBaseTarget(nsAString &aBaseTarget)=0;
|
||||
NS_IMETHOD 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.
|
||||
*/
|
||||
NS_IMETHOD GetDocumentCharacterSet(nsAString& oCharSetID) = 0;
|
||||
NS_IMETHOD SetDocumentCharacterSet(const nsAString& aCharSetID) = 0;
|
||||
|
||||
NS_IMETHOD GetDocumentCharacterSetSource(PRInt32* aCharsetSource) = 0;
|
||||
NS_IMETHOD SetDocumentCharacterSetSource(PRInt32 aCharsetSource) = 0;
|
||||
/**
|
||||
* Add an observer that gets notified whenever the charset changes.
|
||||
*/
|
||||
NS_IMETHOD AddCharSetObserver(nsIObserver* aObserver) = 0;
|
||||
|
||||
/**
|
||||
* Remove a charset observer.
|
||||
*/
|
||||
NS_IMETHOD RemoveCharSetObserver(nsIObserver* aObserver) = 0;
|
||||
|
||||
/**
|
||||
* Return the language of this document.
|
||||
*/
|
||||
NS_IMETHOD GetContentLanguage(nsAString& aContentLanguage) const = 0;
|
||||
|
||||
#ifdef IBMBIDI
|
||||
// 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.
|
||||
*/
|
||||
NS_IMETHOD GetBidiEnabled(PRBool* aBidiEnabled) const = 0;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
NS_IMETHOD SetBidiEnabled(PRBool aBidiEnabled) = 0;
|
||||
#endif // IBMBIDI
|
||||
|
||||
/**
|
||||
* Return the Line Breaker for the document
|
||||
*/
|
||||
NS_IMETHOD GetLineBreaker(nsILineBreaker** aResult) = 0;
|
||||
NS_IMETHOD SetLineBreaker(nsILineBreaker* aLineBreaker) = 0;
|
||||
NS_IMETHOD GetWordBreaker(nsIWordBreaker** aResult) = 0;
|
||||
NS_IMETHOD SetWordBreaker(nsIWordBreaker* aWordBreaker) = 0;
|
||||
|
||||
/**
|
||||
* Access HTTP header data (this may also get set from other sources, like
|
||||
* HTML META tags).
|
||||
*/
|
||||
NS_IMETHOD GetHeaderData(nsIAtom* aHeaderField, nsAString& aData) const = 0;
|
||||
NS_IMETHOD SetHeaderData(nsIAtom* aheaderField, const nsAString& aData) = 0;
|
||||
|
||||
/**
|
||||
* 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).
|
||||
*/
|
||||
NS_IMETHOD CreateShell(nsIPresContext* aContext,
|
||||
nsIViewManager* aViewManager,
|
||||
nsIStyleSet* aStyleSet,
|
||||
nsIPresShell** aInstancePtrResult) = 0;
|
||||
virtual PRBool DeleteShell(nsIPresShell* aShell) = 0;
|
||||
virtual PRInt32 GetNumberOfShells() = 0;
|
||||
NS_IMETHOD GetShellAt(PRInt32 aIndex, nsIPresShell** aShell) = 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.
|
||||
*/
|
||||
NS_IMETHOD GetParentDocument(nsIDocument** aParent) = 0;
|
||||
|
||||
/**
|
||||
* Set the parent document of this document.
|
||||
*/
|
||||
NS_IMETHOD SetParentDocument(nsIDocument* aParent) = 0;
|
||||
|
||||
/**
|
||||
* Set the sub document for aContent to aSubDoc.
|
||||
*/
|
||||
NS_IMETHOD SetSubDocumentFor(nsIContent *aContent, nsIDocument* aSubDoc) = 0;
|
||||
|
||||
/**
|
||||
* Get the sub document for aContent
|
||||
*/
|
||||
NS_IMETHOD GetSubDocumentFor(nsIContent *aContent,
|
||||
nsIDocument** aSubDoc) = 0;
|
||||
|
||||
/**
|
||||
* Find the content node for which aDocument is a sub document.
|
||||
*/
|
||||
NS_IMETHOD FindContentForSubDocument(nsIDocument *aDocument,
|
||||
nsIContent **aContent) = 0;
|
||||
|
||||
/**
|
||||
* Return the root content object for this document.
|
||||
*/
|
||||
NS_IMETHOD GetRootContent(nsIContent** aRoot) = 0;
|
||||
NS_IMETHOD SetRootContent(nsIContent* aRoot) = 0;
|
||||
|
||||
/**
|
||||
* Get the direct children of the document - content in
|
||||
* the prolog, the root content and content in the epilog.
|
||||
*/
|
||||
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent*& aResult) const = 0;
|
||||
NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aIndex) const = 0;
|
||||
NS_IMETHOD GetChildCount(PRInt32& aCount) = 0;
|
||||
|
||||
/**
|
||||
* Get the style sheets owned by this document.
|
||||
* Style sheets are ordered, most significant last.
|
||||
*/
|
||||
NS_IMETHOD GetNumberOfStyleSheets(PRInt32* aCount) = 0;
|
||||
NS_IMETHOD GetStyleSheetAt(PRInt32 aIndex, nsIStyleSheet** aSheet) = 0;
|
||||
NS_IMETHOD GetIndexOfStyleSheet(nsIStyleSheet* aSheet, PRInt32* aIndex) = 0;
|
||||
virtual void AddStyleSheet(nsIStyleSheet* aSheet, PRUint32 aFlags) = 0;
|
||||
virtual void RemoveStyleSheet(nsIStyleSheet* aSheet) = 0;
|
||||
NS_IMETHOD UpdateStyleSheets(nsISupportsArray* aOldSheets, nsISupportsArray* aNewSheets) = 0;
|
||||
|
||||
NS_IMETHOD InsertStyleSheetAt(nsIStyleSheet* aSheet, PRInt32 aIndex, PRBool aNotify) = 0;
|
||||
virtual void SetStyleSheetDisabledState(nsIStyleSheet* aSheet,
|
||||
PRBool aDisabled) = 0;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
NS_IMETHOD GetScriptGlobalObject(nsIScriptGlobalObject** aGlobalObject) = 0;
|
||||
NS_IMETHOD SetScriptGlobalObject(nsIScriptGlobalObject* aGlobalObject) = 0;
|
||||
|
||||
/**
|
||||
* Get the name space manager for this document
|
||||
*/
|
||||
NS_IMETHOD GetNameSpaceManager(nsINameSpaceManager*& aManager) = 0;
|
||||
|
||||
/**
|
||||
* Get the script loader for this document
|
||||
*/
|
||||
NS_IMETHOD GetScriptLoader(nsIScriptLoader** aScriptLoader) = 0;
|
||||
|
||||
/**
|
||||
* Get the focus controller for this document
|
||||
* This can usually be gotten through the ScriptGlobalObject, but
|
||||
* it is set to null during document destruction, when we still might
|
||||
* need to fire focus events.
|
||||
*/
|
||||
NS_IMETHOD GetFocusController(nsIFocusController** aFocusController) = 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 by content nodes to propagate
|
||||
// notifications to document observers.
|
||||
NS_IMETHOD BeginUpdate() = 0;
|
||||
NS_IMETHOD EndUpdate() = 0;
|
||||
NS_IMETHOD BeginLoad() = 0;
|
||||
NS_IMETHOD EndLoad() = 0;
|
||||
NS_IMETHOD ContentChanged(nsIContent* aContent,
|
||||
nsISupports* aSubContent) = 0;
|
||||
// notify that one or two content nodes changed state
|
||||
// either may be nsnull, but not both
|
||||
NS_IMETHOD ContentStatesChanged(nsIContent* aContent1,
|
||||
nsIContent* aContent2,
|
||||
PRInt32 aStateMask) = 0;
|
||||
NS_IMETHOD AttributeWillChange(nsIContent* aChild,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aAttribute) = 0;
|
||||
NS_IMETHOD AttributeChanged(nsIContent* aChild,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aModType,
|
||||
PRInt32 aHint) = 0; // See nsStyleConsts fot hint values
|
||||
NS_IMETHOD ContentAppended(nsIContent* aContainer,
|
||||
PRInt32 aNewIndexInContainer) = 0;
|
||||
NS_IMETHOD ContentInserted(nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer) = 0;
|
||||
NS_IMETHOD ContentReplaced(nsIContent* aContainer,
|
||||
nsIContent* aOldChild,
|
||||
nsIContent* aNewChild,
|
||||
PRInt32 aIndexInContainer) = 0;
|
||||
NS_IMETHOD ContentRemoved(nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer) = 0;
|
||||
|
||||
// Observation hooks for style data to propagate notifications
|
||||
// to document observers
|
||||
NS_IMETHOD StyleRuleChanged(nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule,
|
||||
PRInt32 aHint) = 0; // See nsStyleConsts fot hint values
|
||||
NS_IMETHOD StyleRuleAdded(nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule) = 0;
|
||||
NS_IMETHOD StyleRuleRemoved(nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule) = 0;
|
||||
|
||||
NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus) = 0;
|
||||
|
||||
NS_IMETHOD_(PRBool) EventCaptureRegistration(PRInt32 aCapturerIncrement) = 0;
|
||||
|
||||
NS_IMETHOD FlushPendingNotifications(PRBool aFlushReflows=PR_TRUE,
|
||||
PRBool aUpdateViews=PR_FALSE) = 0;
|
||||
|
||||
NS_IMETHOD GetAndIncrementContentID(PRInt32* aID) = 0;
|
||||
|
||||
NS_IMETHOD GetBindingManager(nsIBindingManager** aResult) = 0;
|
||||
|
||||
NS_IMETHOD GetNodeInfoManager(nsINodeInfoManager*& aNodeInfoManager) = 0;
|
||||
|
||||
NS_IMETHOD Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup) = 0;
|
||||
NS_IMETHOD ResetToURI(nsIURI *aURI, nsILoadGroup* aLoadGroup) = 0;
|
||||
|
||||
NS_IMETHOD AddReference(void *aKey, nsISupports *aReference) = 0;
|
||||
NS_IMETHOD RemoveReference(void *aKey, nsISupports **aOldReference) = 0;
|
||||
|
||||
/**
|
||||
* Set the container (docshell) for this document.
|
||||
*/
|
||||
NS_IMETHOD SetContainer(nsISupports *aContainer) = 0;
|
||||
|
||||
/**
|
||||
* Get the container (docshell) for this document.
|
||||
*/
|
||||
NS_IMETHOD GetContainer(nsISupports **aContainer) = 0;
|
||||
};
|
||||
|
||||
|
||||
// XXX These belong somewhere else
|
||||
extern NS_EXPORT nsresult
|
||||
NS_NewHTMLDocument(nsIDocument** aInstancePtrResult);
|
||||
|
||||
extern NS_EXPORT nsresult
|
||||
NS_NewXMLDocument(nsIDocument** aInstancePtrResult);
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
extern NS_EXPORT nsresult
|
||||
NS_NewSVGDocument(nsIDocument** aInstancePtrResult);
|
||||
#endif
|
||||
|
||||
extern NS_EXPORT nsresult
|
||||
NS_NewImageDocument(nsIDocument** aInstancePtrResult);
|
||||
|
||||
extern NS_EXPORT nsresult
|
||||
NS_NewDocumentFragment(nsIDOMDocumentFragment** aInstancePtrResult,
|
||||
nsIDocument* aOwnerDocument);
|
||||
extern NS_EXPORT nsresult
|
||||
NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
|
||||
const nsAString& aNamespaceURI,
|
||||
const nsAString& aQualifiedName,
|
||||
nsIDOMDocumentType* aDoctype,
|
||||
nsIURI* aBaseURI);
|
||||
|
||||
// Note: The buffer passed into NewPostData(...) becomes owned by the IPostData
|
||||
// instance and is freed when the instance is destroyed...
|
||||
//
|
||||
#if 0
|
||||
extern NS_EXPORT nsresult
|
||||
NS_NewPostData(PRBool aIsFile, char *aData, nsIPostData** aInstancePtrResult);
|
||||
#endif
|
||||
|
||||
#endif /* nsIDocument_h___ */
|
||||
@@ -1,91 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsIDocumentContainer_h___
|
||||
#define nsIDocumentContainer_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
class nsIScriptable;
|
||||
class nsIScriptEnvironment;
|
||||
class nsIURI;
|
||||
|
||||
#define NS_IDOCUMENT_CONTAINER_IID \
|
||||
{ 0x8efd4470, 0x944d, 0x11d1, \
|
||||
{0x93, 0x23, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
|
||||
|
||||
class nIDocumentContainer : public nsISupports {
|
||||
public:
|
||||
/**
|
||||
* Display the specified URL with the given connection.
|
||||
*
|
||||
* @param url the URL to display
|
||||
* @param connection the connection to use.
|
||||
*/
|
||||
virtual void Display(nsIURI* aURL) = 0;
|
||||
|
||||
/**
|
||||
* Returns a script environment for the specified language and version.
|
||||
* The expectation is that the script environment already has been
|
||||
* set up with a container object. If a script environment has already
|
||||
* been requested for the given language, the same instance should
|
||||
* be returned.
|
||||
*
|
||||
* @param language the scripting language for the environment. If this
|
||||
* is null, returns the default scripting environment.
|
||||
* @param majorVersion the major version number of the language
|
||||
* @param minorVersion the minor version number of the language
|
||||
* @return the script environment for the language
|
||||
* @see mg.magellan.script.IScriptEnvrionment
|
||||
*/
|
||||
virtual nsIScriptEnvironment*
|
||||
GetScriptEnvironment(nsString* aLanguage,
|
||||
PRInt32 aMajorVersion,
|
||||
PRInt32 aMinorVersion) = 0;
|
||||
|
||||
/**
|
||||
* Returns the scriptable container object for the document container.
|
||||
* The scriptable object will be used as the scoping object in the
|
||||
* definition of scriptable classes used in the Document Object Model.
|
||||
*
|
||||
* @return the scriptable container for the application
|
||||
* @see mg.magellan.script.IScriptable
|
||||
* @see mg.magellan.script.IScriptEnvrionment
|
||||
*/
|
||||
virtual nsIScriptable* GetScriptableContainer() = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIDocumentContainer_h___ */
|
||||
@@ -1,237 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsIDocumentEncoder_h__
|
||||
#define nsIDocumentEncoder_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
|
||||
class nsIDocumentEncoder;
|
||||
class nsIDocument;
|
||||
class nsIDOMRange;
|
||||
class nsISelection;
|
||||
class nsIOutputStream;
|
||||
class nsISupportsArray;
|
||||
class nsIDOMNode;
|
||||
|
||||
|
||||
#define NS_IDOCUMENT_ENCODER_IID \
|
||||
{ /* a6cf9103-15b3-11d2-932e-00805f8add32 */ \
|
||||
0xa6cf9103, \
|
||||
0x15b3, \
|
||||
0x11d2, \
|
||||
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} \
|
||||
}
|
||||
|
||||
#define NS_TEXT_ENCODER_CID \
|
||||
{ /* e7ba1480-1dea-11d3-830f-00104bed045e */ \
|
||||
0xe7ba1480, \
|
||||
0x1dea, \
|
||||
0x11d3, \
|
||||
{0x83, 0x0f, 0x00, 0x10, 0x4b, 0xed, 0x04, 0x5e} \
|
||||
}
|
||||
|
||||
#define NS_DOC_ENCODER_CONTRACTID_BASE "@mozilla.org/layout/documentEncoder;1?type="
|
||||
|
||||
// {7f915b01-98fc-11d4-8eb0-a803f80ff1bc}
|
||||
#define NS_HTMLCOPY_TEXT_ENCODER_CID \
|
||||
{ 0x7f915b01, 0x98fc, 0x11d4, { 0x8e, 0xb0, 0xa8, 0x03, 0xf8, 0x0f, 0xf1, 0xbc } }
|
||||
|
||||
// {0BC1FAC0-B710-11d4-959F-0020183BF181}
|
||||
#define NS_IDOCUMENTENCODERNODEFIXUP_IID \
|
||||
{ 0xbc1fac0, 0xb710, 0x11d4, { 0x95, 0x9f, 0x0, 0x20, 0x18, 0x3b, 0xf1, 0x81 } }
|
||||
|
||||
#define NS_HTMLCOPY_ENCODER_CONTRACTID "@mozilla.org/layout/htmlCopyEncoder;1"
|
||||
|
||||
class nsIDocumentEncoderNodeFixup : public nsISupports
|
||||
{
|
||||
public:
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDOCUMENTENCODERNODEFIXUP_IID)
|
||||
|
||||
/**
|
||||
* 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 nsnull.
|
||||
*/
|
||||
NS_IMETHOD FixupNode(nsIDOMNode *aNode, nsIDOMNode **aOutNode) = 0;
|
||||
};
|
||||
|
||||
class nsIDocumentEncoder : public nsISupports
|
||||
{
|
||||
public:
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDOCUMENT_ENCODER_IID)
|
||||
|
||||
/**
|
||||
* Output methods flag bits.
|
||||
*
|
||||
* There are a frightening number of these,
|
||||
* because everyone wants something a little bit different!
|
||||
*
|
||||
* These should move to an idl file so that Javascript can
|
||||
* have access to the symbols, not just the constants.
|
||||
*/
|
||||
enum {
|
||||
// Output only the selection (as opposed to the whole document).
|
||||
OutputSelectionOnly = 1,
|
||||
|
||||
// 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.)
|
||||
OutputFormatted = 2,
|
||||
|
||||
// OutputRaw is used by copying text from widgets
|
||||
OutputRaw = 4,
|
||||
|
||||
// No html head tags
|
||||
OutputBodyOnly = 8,
|
||||
|
||||
// Wrap even if we're not doing formatted output (e.g. for text fields)
|
||||
OutputPreformatted = 16,
|
||||
|
||||
// Output as though the content is preformatted
|
||||
// (e.g. maybe it's wrapped in a MOZ_PRE or MOZ_PRE_WRAP style tag)
|
||||
OutputWrap = 32,
|
||||
|
||||
// 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.
|
||||
OutputFormatFlowed = 64,
|
||||
|
||||
// Convert links, image src, and script src to absolute URLs when possible
|
||||
OutputAbsoluteLinks = 128,
|
||||
|
||||
// Encode entities when outputting to a string.
|
||||
// E.g. If set, we'll output if clear, we'll output 0xa0.
|
||||
OutputEncodeEntities = 256,
|
||||
|
||||
// LineBreak processing: we can do either platform line breaks,
|
||||
// CR, LF, or CRLF. If neither of these flags is set, then we
|
||||
// will use platform line breaks.
|
||||
OutputCRLineBreak = 512,
|
||||
OutputLFLineBreak = 1024,
|
||||
|
||||
// Output the content of noscript elements (only for serializing
|
||||
// to plaintext).
|
||||
OutputNoScriptContent = 2048,
|
||||
|
||||
// Output the content of noframes elements (only for serializing
|
||||
// to plaintext).
|
||||
OutputNoFramesContent = 4096,
|
||||
|
||||
// Don't allow any formatting nodes (e.g. <br>, <b>) inside a <pre>.
|
||||
// This is used primarily by mail.
|
||||
OutputNoFormattingInPre = 8192
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize with a pointer to the document and the mime type.
|
||||
*/
|
||||
NS_IMETHOD Init(nsIDocument* aDocument, const nsAString& aMimeType,
|
||||
PRUint32 flags) = 0;
|
||||
|
||||
/**
|
||||
* If the selection is set to a non-null value, then the
|
||||
* selection is used for encoding, otherwise the entire
|
||||
* document is encoded.
|
||||
*/
|
||||
NS_IMETHOD SetSelection(nsISelection* aSelection) = 0;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
NS_IMETHOD SetRange(nsIDOMRange* aRange) = 0;
|
||||
|
||||
/**
|
||||
* Documents typically have an intrinsic character set.
|
||||
* If no intrinsic value is found, the platform character set
|
||||
* is used.
|
||||
* aCharset overrides the both the intrinsic or platform
|
||||
* character set when encoding the document.
|
||||
*
|
||||
* Possible result codes: NS_ERROR_NO_CHARSET_CONVERTER
|
||||
*/
|
||||
NS_IMETHOD SetCharset(const nsAString& aCharset) = 0;
|
||||
|
||||
/**
|
||||
* Set a wrap column. This may have no effect in some types of encoders.
|
||||
*/
|
||||
NS_IMETHOD SetWrapColumn(PRUint32 aWC) = 0;
|
||||
|
||||
/**
|
||||
* Get 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.
|
||||
*/
|
||||
NS_IMETHOD GetMimeType(nsAString& aMimeType) = 0;
|
||||
|
||||
/**
|
||||
* The document is encoded, the result is sent to the
|
||||
* to nsIOutputStream.
|
||||
*
|
||||
* Possible result codes are passing along whatever stream errors
|
||||
* might have been encountered.
|
||||
*/
|
||||
NS_IMETHOD EncodeToStream(nsIOutputStream* aStream) = 0;
|
||||
NS_IMETHOD EncodeToString(nsAString& aOutputString) = 0;
|
||||
|
||||
/**
|
||||
* The document is encoded, the result is sent to the
|
||||
* to aEncodedString. Parent heirarchy information is encoded
|
||||
* to aContextString. Extra context info is encoded in aInfoString.
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD EncodeToStringWithContext(nsAString& aEncodedString,
|
||||
nsAString& aContextString,
|
||||
nsAString& aInfoString) = 0;
|
||||
|
||||
/**
|
||||
* Set the fixup object associated with node persistence.
|
||||
*/
|
||||
NS_IMETHOD SetNodeFixup(nsIDocumentEncoderNodeFixup *aFixup) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIDocumentEncoder_h__ */
|
||||
|
||||
@@ -1,333 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, 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 \
|
||||
{ 0xb3f92460, 0x944c, 0x11d1, {0x93, 0x23, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
// Document observer interface
|
||||
class nsIDocumentObserver : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDOCUMENT_OBSERVER_IID)
|
||||
|
||||
/**
|
||||
* Notify that a content model update is beginning. This call can be
|
||||
* nested.
|
||||
*/
|
||||
NS_IMETHOD BeginUpdate(nsIDocument *aDocument) = 0;
|
||||
|
||||
/**
|
||||
* Notify that a content model update is finished. This call can be
|
||||
* nested.
|
||||
*/
|
||||
NS_IMETHOD EndUpdate(nsIDocument *aDocument) = 0;
|
||||
|
||||
/**
|
||||
* Notify the observer that a document load is beginning.
|
||||
*/
|
||||
NS_IMETHOD 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.
|
||||
*/
|
||||
NS_IMETHOD EndLoad(nsIDocument *aDocument) = 0;
|
||||
|
||||
/**
|
||||
* Notify the observer that the document is being reflowed in
|
||||
* the given presentation shell.
|
||||
*/
|
||||
NS_IMETHOD BeginReflow(nsIDocument *aDocument, nsIPresShell* aShell) = 0;
|
||||
|
||||
/**
|
||||
* Notify the observer that the document is done being reflowed in
|
||||
* the given presentation shell.
|
||||
*/
|
||||
NS_IMETHOD EndReflow(nsIDocument *aDocument, nsIPresShell* aShell) = 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 aSubContent subrange information about the piece of content
|
||||
* that changed
|
||||
*/
|
||||
NS_IMETHOD ContentChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
nsISupports* aSubContent) = 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
|
||||
*/
|
||||
NS_IMETHOD 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.
|
||||
* @param aHint The style hint.
|
||||
*/
|
||||
NS_IMETHOD AttributeChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aModType,
|
||||
PRInt32 aHint) = 0; // See nsStyleConsts fot hint values
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
NS_IMETHOD 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
|
||||
*/
|
||||
NS_IMETHOD ContentInserted(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer) = 0;
|
||||
|
||||
/**
|
||||
* Notification that content has been replaced. This method is called
|
||||
* automatically by the content container objects when a content object
|
||||
* is replaced 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 aOldChild the child that was replaced
|
||||
* @param aNewChild the child that replaced aOldChild
|
||||
* @param aIndexInContainer the index of the old and new child in the
|
||||
* container
|
||||
*/
|
||||
NS_IMETHOD ContentReplaced(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aOldChild,
|
||||
nsIContent* aNewChild,
|
||||
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
|
||||
*/
|
||||
NS_IMETHOD 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. 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
|
||||
*/
|
||||
NS_IMETHOD StyleSheetAdded(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet) = 0;
|
||||
|
||||
/**
|
||||
* A StyleSheet has just been removed from the document.
|
||||
* This method is called automatically when a StyleSheet gets removed
|
||||
* from 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 removed
|
||||
*/
|
||||
NS_IMETHOD StyleSheetRemoved(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet) = 0;
|
||||
|
||||
/**
|
||||
* A StyleSheet has just disabled or enabled.
|
||||
* This method is called automatically when the disabled 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 been added
|
||||
* @param aDisabled PR_TRUE if the sheet is disabled, PR_FALSE if
|
||||
* it is enabled
|
||||
*/
|
||||
NS_IMETHOD StyleSheetDisabledStateChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
PRBool aDisabled) = 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.
|
||||
*
|
||||
* @param aDocument The document being observed
|
||||
* @param aStyleSheet the StyleSheet that contians the rule
|
||||
* @param aStyleRule the rule that was modified
|
||||
* @param aHint some possible info about the nature of the change
|
||||
*/
|
||||
NS_IMETHOD StyleRuleChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule,
|
||||
PRInt32 aHint) = 0; // See nsStyleConsts fot hint values
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
NS_IMETHOD 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
|
||||
*/
|
||||
NS_IMETHOD 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
|
||||
*/
|
||||
NS_IMETHOD DocumentWillBeDestroyed(nsIDocument *aDocument) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIDocumentObserver_h___ */
|
||||
@@ -1,72 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsIDocumentViewer_h___
|
||||
#define nsIDocumentViewer_h___
|
||||
|
||||
#include "nsIContentViewer.h"
|
||||
|
||||
class nsIDocument;
|
||||
class nsIPresContext;
|
||||
class nsIPresShell;
|
||||
class nsIStyleSheet;
|
||||
|
||||
#define NS_IDOCUMENT_VIEWER_IID \
|
||||
{ 0xa6cf9057, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
/**
|
||||
* A document viewer is a kind of content viewer that uses NGLayout
|
||||
* to manage the presentation of the content.
|
||||
*/
|
||||
class nsIDocumentViewer : public nsIContentViewer
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDOCUMENT_VIEWER_IID)
|
||||
|
||||
NS_IMETHOD SetUAStyleSheet(nsIStyleSheet* aUAStyleSheet) = 0;
|
||||
|
||||
NS_IMETHOD GetDocument(nsIDocument*& aResult) = 0;
|
||||
|
||||
NS_IMETHOD GetPresShell(nsIPresShell*& aResult) = 0;
|
||||
|
||||
NS_IMETHOD GetPresContext(nsIPresContext*& aResult) = 0;
|
||||
|
||||
NS_IMETHOD CreateDocumentViewerUsing(nsIPresContext* aPresContext,
|
||||
nsIDocumentViewer*& aResult) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIDocumentViewer_h___ */
|
||||
@@ -1,82 +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;
|
||||
interface nsIOverrideDragSource;
|
||||
interface nsIOverrideDropSite;
|
||||
|
||||
|
||||
/**
|
||||
* @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.
|
||||
* @param overrideDrag callback to client to override portions of the
|
||||
* drag start action. Can be NULL.
|
||||
* @param overrideDrop callback to client to override portions of the
|
||||
* drop action. Can be NULL.
|
||||
*/
|
||||
void hookupTo(in nsIDOMEventTarget attachPoint, in nsIWebNavigation navigator,
|
||||
in nsIOverrideDragSource overrideDrag,
|
||||
in nsIOverrideDropSite overrideDrop);
|
||||
|
||||
/**
|
||||
* Unregister all handlers related to drag&drop
|
||||
*/
|
||||
void detach();
|
||||
};
|
||||
@@ -1,122 +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;
|
||||
interface nsITransferable;
|
||||
interface nsIDragSession;
|
||||
interface nsIDOMEvent;
|
||||
|
||||
|
||||
/**
|
||||
* @status UNDER_REVIEW
|
||||
*/
|
||||
|
||||
/**
|
||||
* Interfaces for overriding the built-in drag and drop
|
||||
* implementation in the content area. Use this to do things
|
||||
* such as prevent a drag from starting, adding or removing
|
||||
* data and flavors, or preventing the drop.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Overrides operations at the source of a drag. Can prevent
|
||||
* drag from starting and can modify what flavors/data are
|
||||
* presented to the OS.
|
||||
*/
|
||||
[scriptable,uuid(e03e6c5e-0d84-4c0b-8739-e6b8d51922de)]
|
||||
interface nsIOverrideDragSource : nsISupports
|
||||
{
|
||||
/**
|
||||
* Prevents the drag from starting
|
||||
*
|
||||
* @param event DOM event (drag gesture)
|
||||
*
|
||||
* @return TRUE drag can proceed
|
||||
* @return FALSE drag is cancelled, does not go to OS
|
||||
*/
|
||||
boolean allowStart(in nsIDOMEvent event);
|
||||
|
||||
/**
|
||||
* Alter the flavors or data presented to the OS
|
||||
*
|
||||
* @param trans the transferable holding the list of flavors
|
||||
* and the data for each flavor
|
||||
*/
|
||||
void modify(in nsITransferable trans);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Overrides operations at the destination of a drag. Can prevent
|
||||
* drag from completing and provide an alternative action than
|
||||
* the built-in behavior for a drop.
|
||||
*/
|
||||
[scriptable,uuid(a0ea9862-e2e6-4fd7-8cab-72afeb53c793)]
|
||||
interface nsIOverrideDropSite : nsISupports
|
||||
{
|
||||
/**
|
||||
* Tells the OS a drop is not allowed on this browser
|
||||
*
|
||||
* @param event DOM event (drag over)
|
||||
* @param session the drag session from which client can get
|
||||
* the flavors present or the actual data
|
||||
*
|
||||
* @return TRUE indicates to OS that if a drop does happen on this
|
||||
* browser, it will be accepted.
|
||||
* @return FALSE indicates to OS drop is not allowed. On win32, this
|
||||
* will change the cursor to "reject".
|
||||
*/
|
||||
boolean allowDrop(in nsIDOMEvent event, in nsIDragSession session);
|
||||
|
||||
/**
|
||||
* Provide an alternative action to the built-in behavior when
|
||||
* something is dropped on the browser
|
||||
*
|
||||
* @param event DOM event (drag drop)
|
||||
* @param trans the transferable holding the list of flavors
|
||||
* and the data for each flavor
|
||||
*
|
||||
* @return TRUE action was handled, do not perform built-in
|
||||
* behavior
|
||||
* @return FALSE action was not overridden, do built-in behavior
|
||||
*/
|
||||
boolean dropAction(in nsIDOMEvent event, in nsITransferable trans);
|
||||
};
|
||||
@@ -1,85 +0,0 @@
|
||||
/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsIElementFactory_h___
|
||||
#define nsIElementFactory_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIContent;
|
||||
class nsINodeInfo;
|
||||
|
||||
/* a6cf90fb-15b3-11d2-932e-00805f8add32 */
|
||||
#define NS_IELEMENT_FACTORY_IID \
|
||||
{ 0xa6cf90fb, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
/**
|
||||
* An API for creating html content objects
|
||||
*/
|
||||
class nsIElementFactory : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IELEMENT_FACTORY_IID)
|
||||
|
||||
NS_IMETHOD CreateInstanceByTag(nsINodeInfo *aNodeInfo,
|
||||
nsIContent** aResult) = 0;
|
||||
};
|
||||
|
||||
// ContractIDs for element factory registration
|
||||
#define NS_ELEMENT_FACTORY_CONTRACTID "@mozilla.org/layout/element-factory;1"
|
||||
#define NS_ELEMENT_FACTORY_CONTRACTID_PREFIX NS_ELEMENT_FACTORY_CONTRACTID "?namespace="
|
||||
|
||||
#define NS_HTML_NAMESPACE "http://www.w3.org/1999/xhtml"
|
||||
#define NS_XML_NAMESPACE "http://www.w3.org/XML/1998/namespace"
|
||||
|
||||
#define NS_HTML_ELEMENT_FACTORY_CONTRACTID NS_ELEMENT_FACTORY_CONTRACTID_PREFIX NS_HTML_NAMESPACE
|
||||
#define NS_XML_ELEMENT_FACTORY_CONTRACTID NS_ELEMENT_FACTORY_CONTRACTID_PREFIX NS_XML_NAMESPACE
|
||||
|
||||
#ifdef MOZ_MATHML
|
||||
#define NS_MATHML_NAMESPACE "http://www.w3.org/1998/Math/MathML"
|
||||
#define NS_MATHML_ELEMENT_FACTORY_CONTRACTID NS_ELEMENT_FACTORY_CONTRACTID_PREFIX NS_MATHML_NAMESPACE
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
#define NS_SVG_DEPRECATED_NAMESPACE "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.svg"
|
||||
#define NS_SVG_DEPRECATED_ELEMENT_FACTORY_CONTRACTID \
|
||||
NS_ELEMENT_FACTORY_CONTRACTID_PREFIX NS_SVG_DEPRECATED_NAMESPACE
|
||||
|
||||
#define NS_SVG_NAMESPACE "http://www.w3.org/2000/svg"
|
||||
#define NS_SVG_ELEMENT_FACTORY_CONTRACTID NS_ELEMENT_FACTORY_CONTRACTID_PREFIX NS_SVG_NAMESPACE
|
||||
#endif
|
||||
|
||||
#endif /* nsIElementFactory_h___ */
|
||||
@@ -1,114 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsIFrameLoader_h___
|
||||
#define nsIFrameLoader_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsAString.h"
|
||||
|
||||
// Forward declarations
|
||||
class nsIContent;
|
||||
class nsIDocShell;
|
||||
class nsIURI;
|
||||
|
||||
// IID for the nsIFrameLoader interface
|
||||
#define NS_IFRAMELOADER_IID \
|
||||
{ 0x51e2b6df, 0xdaf2, 0x4a2f, \
|
||||
{0x80, 0xe5, 0xed, 0x69, 0x5b, 0x8c, 0x67, 0x4f} }
|
||||
|
||||
// IID for the nsIFrameLoaderOwner interface
|
||||
#define NS_IFRAMELOADEROWNER_IID \
|
||||
{ 0x0080d493, 0x96b4, 0x4606, \
|
||||
{0xa7, 0x43, 0x0f, 0x47, 0xee, 0x87, 0x14, 0xd1} }
|
||||
|
||||
// CID for the nsIFrameLoader implementation
|
||||
#define NS_FRAMELOADER_CID \
|
||||
{ 0x712603da, 0xf245, 0x4503, \
|
||||
{0xa5, 0x41, 0xb0, 0x49, 0xcb, 0x06, 0x81, 0xae} }
|
||||
|
||||
#define NS_FRAMELOADER_CONTRACTID "@mozilla.org/content/frameloader"
|
||||
|
||||
class nsIFrameLoader : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFRAMELOADER_IID)
|
||||
|
||||
/**
|
||||
* Initialize the frame loader, hand it the owner content. Note that
|
||||
* the owner content reference is a weak reference, if the owner
|
||||
* content is destroyed before the frame loader goes away the owner
|
||||
* content must call the Destroy() method to clear the owner content
|
||||
* reference.
|
||||
*/
|
||||
NS_IMETHOD Init(nsIContent *aOwner) = 0;
|
||||
|
||||
/**
|
||||
* Start loading the frame. This method figures out what to load
|
||||
* from the owner content in the frame loader.
|
||||
*/
|
||||
NS_IMETHOD LoadFrame() = 0;
|
||||
|
||||
/**
|
||||
* Get the docshell from the frame loader.
|
||||
*/
|
||||
NS_IMETHOD GetDocShell(nsIDocShell **aDocShell) = 0;
|
||||
|
||||
/**
|
||||
* Destroy the frame loader and everything inside it. This will
|
||||
* clear the weak owner content reference. */
|
||||
NS_IMETHOD Destroy() = 0;
|
||||
};
|
||||
|
||||
|
||||
class nsIFrameLoaderOwner : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFRAMELOADEROWNER_IID)
|
||||
|
||||
/**
|
||||
* Get the frame loader from the frame loader owner.
|
||||
*/
|
||||
NS_IMETHOD GetFrameLoader(nsIFrameLoader **aFrameLoader) = 0;
|
||||
};
|
||||
|
||||
|
||||
nsresult
|
||||
NS_NewFrameLoader(nsIFrameLoader **aFrameLoader);
|
||||
|
||||
#endif /* nsIFrameLoader_h___ */
|
||||
@@ -1,65 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, 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_DEFINE_STATIC_IID_ACCESSOR(NS_IHTMLTOTEXTSINK_IID)
|
||||
|
||||
NS_IMETHOD Initialize(nsAString* aOutString,
|
||||
PRUint32 aFlags, PRUint32 aWrapCol) = 0;
|
||||
// This function violates string ownership rules, see impl.
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,91 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsINameSpace_h___
|
||||
#define nsINameSpace_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIAtom;
|
||||
class nsString;
|
||||
class nsINameSpaceManager;
|
||||
|
||||
#define NS_INAMESPACE_IID \
|
||||
{ 0xa6cf90d4, 0x15b3, 0x11d2, \
|
||||
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
|
||||
/**
|
||||
* A nsINameSpace registers the NameSpace URI with the NameSpaceManager
|
||||
* (creating or finding an ID), and manages the relationship between
|
||||
* the NameSpace ID and the (optional) Prefix.
|
||||
*
|
||||
* New NameSpaces are created as a child of an existing NameSpace. Searches
|
||||
* for NameSpaces based on prefix search up the chain of nested NameSpaces
|
||||
*
|
||||
* Each NameSpace keeps a live reference on its parent and its Manager.
|
||||
*
|
||||
*/
|
||||
class nsINameSpace : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_INAMESPACE_IID)
|
||||
|
||||
NS_IMETHOD GetNameSpaceManager(nsINameSpaceManager*& aManager) const = 0;
|
||||
|
||||
// Get data of this name space
|
||||
NS_IMETHOD GetNameSpaceID(PRInt32& aID) const = 0;
|
||||
NS_IMETHOD GetNameSpaceURI(nsAString& aURI) const = 0;
|
||||
NS_IMETHOD GetNameSpacePrefix(nsIAtom*& aPrefix) const = 0;
|
||||
|
||||
NS_IMETHOD GetParentNameSpace(nsINameSpace*& aParent) const = 0;
|
||||
|
||||
// find name space within self and parents (not children)
|
||||
NS_IMETHOD FindNameSpace(nsIAtom* aPrefix, nsINameSpace*& aNameSpace) const = 0;
|
||||
NS_IMETHOD FindNameSpaceID(nsIAtom* aPrefix, PRInt32& aNameSpaceID) const = 0;
|
||||
NS_IMETHOD FindNameSpacePrefix(PRInt32 aNameSpaceID, nsIAtom*& aPrefix) const = 0;
|
||||
|
||||
// create new child name space
|
||||
NS_IMETHOD CreateChildNameSpace(nsIAtom* aPrefix,
|
||||
const nsAString& aURI,
|
||||
nsINameSpace*& aChildNameSpace) = 0;
|
||||
|
||||
NS_IMETHOD CreateChildNameSpace(nsIAtom* aPrefix, PRInt32 aNameSpaceID,
|
||||
nsINameSpace*& aChildNameSpace) = 0;
|
||||
};
|
||||
|
||||
#endif // nsINameSpace_h___
|
||||
@@ -1,114 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsINameSpaceManager_h___
|
||||
#define nsINameSpaceManager_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsAString.h"
|
||||
|
||||
class nsIAtom;
|
||||
class nsString;
|
||||
class nsINameSpace;
|
||||
class nsIElementFactory;
|
||||
|
||||
#define kNameSpaceID_Unknown -1
|
||||
#define 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
|
||||
|
||||
// 'html' is by definition bound to the namespace name "urn:w3-org-ns:HTML" XXX ???
|
||||
// 'xml' is by definition bound to the namespace name "urn:Connolly:input:required" XXX
|
||||
|
||||
#define NS_INAMESPACEMANAGER_IID \
|
||||
{ 0xa6cf90d5, 0x15b3, 0x11d2, \
|
||||
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
/**
|
||||
* 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. Generally, a document keeps a reference to
|
||||
* a nsINameSpaceManager. Also, each nsINameSpace that comes from the manager
|
||||
* keeps a reference to it.
|
||||
*
|
||||
* To create a stack of NameSpaces, call CreateRootNameSpace, and then create
|
||||
* child NameSpaces from the root.
|
||||
*
|
||||
* The "html" and "xml" namespaces come "pre-canned" from the root.
|
||||
*
|
||||
*/
|
||||
|
||||
class nsINameSpaceManager : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_INAMESPACEMANAGER_IID)
|
||||
|
||||
NS_IMETHOD CreateRootNameSpace(nsINameSpace*& aRootNameSpace) = 0;
|
||||
|
||||
NS_IMETHOD RegisterNameSpace(const nsAString& aURI,
|
||||
PRInt32& aNameSpaceID) = 0;
|
||||
|
||||
NS_IMETHOD GetNameSpaceURI(PRInt32 aNameSpaceID,
|
||||
nsAString& aURI) = 0;
|
||||
NS_IMETHOD GetNameSpaceID(const nsAString& aURI,
|
||||
PRInt32& aNameSpaceID) = 0;
|
||||
|
||||
NS_IMETHOD GetElementFactory(PRInt32 aNameSpaceID,
|
||||
nsIElementFactory **aElementFactory) = 0;
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewNameSpaceManager(nsINameSpaceManager** aInstancePtrResult);
|
||||
|
||||
void
|
||||
NS_NameSpaceManagerShutdown();
|
||||
|
||||
|
||||
#endif // nsINameSpaceManager_h___
|
||||
@@ -1,372 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 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 NPL, 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 NPL, 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.
|
||||
*
|
||||
* nsINodeInfoManager is an interface to an object that manages a list of
|
||||
* nsINodeInfo's, every document object should hold a strong reference to
|
||||
* a nsINodeInfoManager 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 nsINodeInfoManager and all external
|
||||
* references are released the nsINodeInfoManager deletes itself.
|
||||
*
|
||||
* -- jst@netscape.com
|
||||
*/
|
||||
|
||||
#ifndef nsINodeInfo_h___
|
||||
#define nsINodeInfo_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsAString.h"
|
||||
#include "domstubs.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
|
||||
// Forward declarations
|
||||
class nsINodeInfoManager;
|
||||
class nsINameSpaceManager;
|
||||
class nsIDocument;
|
||||
|
||||
|
||||
// IID for the nsINodeInfo interface
|
||||
#define NS_INODEINFO_IID \
|
||||
{ 0x93dbfd8c, 0x2fb3, 0x4ef5, \
|
||||
{0xa2, 0xa0, 0xcf, 0xf2, 0x69, 0x6f, 0x07, 0x88} }
|
||||
|
||||
// IID for the nsINodeInfoManager interface
|
||||
#define NS_INODEINFOMANAGER_IID \
|
||||
{ 0xb622469b, 0x4dcf, 0x45c4, \
|
||||
{0xb0, 0xb9, 0xa7, 0x32, 0xbc, 0xee, 0xa5, 0xcc} }
|
||||
|
||||
#define NS_NODEINFOMANAGER_CONTRACTID "@mozilla.org/layout/nodeinfomanager;1"
|
||||
|
||||
|
||||
class nsINodeInfo : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_INODEINFO_IID)
|
||||
|
||||
nsINodeInfo()
|
||||
: mInner(nsnull, nsnull, kNameSpaceID_None)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* 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".
|
||||
*/
|
||||
nsresult GetName(nsAString& aName) const
|
||||
{
|
||||
mInner.mName->ToString(aName);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
nsresult GetNameAtom(nsIAtom*& aAtom) const
|
||||
{
|
||||
aAtom = mInner.mName;
|
||||
NS_ADDREF(aAtom);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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".
|
||||
*/
|
||||
NS_IMETHOD 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".
|
||||
*/
|
||||
NS_IMETHOD 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".
|
||||
*/
|
||||
nsresult GetPrefix(nsAString& aPrefix) const
|
||||
{
|
||||
if (mInner.mPrefix) {
|
||||
mInner.mPrefix->ToString(aPrefix);
|
||||
} else {
|
||||
SetDOMStringToNull(aPrefix);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
nsresult GetPrefixAtom(nsIAtom*& aAtom) const
|
||||
{
|
||||
aAtom = mInner.mPrefix;
|
||||
NS_IF_ADDREF(aAtom);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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".
|
||||
*/
|
||||
NS_IMETHOD 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".
|
||||
*/
|
||||
nsresult GetNamespaceID(PRInt32& aNameSpaceID) const
|
||||
{
|
||||
aNameSpaceID = mInner.mNamespaceID;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetIDAttributeAtom(nsIAtom** aResult) const = 0;
|
||||
NS_IMETHOD SetIDAttributeAtom(nsIAtom* aResult) = 0;
|
||||
|
||||
/*
|
||||
* Get the owning node info manager, this will never return null.
|
||||
*/
|
||||
NS_IMETHOD GetNodeInfoManager(nsINodeInfoManager*& aNodeInfoManager) const = 0;
|
||||
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
|
||||
NS_IMETHOD_(PRBool) Equals(const nsAString& aName) const = 0;
|
||||
NS_IMETHOD_(PRBool) Equals(const nsAString& aName,
|
||||
const nsAString& aPrefix) const = 0;
|
||||
NS_IMETHOD_(PRBool) Equals(const nsAString& aName,
|
||||
PRInt32 aNamespaceID) const = 0;
|
||||
NS_IMETHOD_(PRBool) Equals(const nsAString& aName,
|
||||
const nsAString& aPrefix,
|
||||
PRInt32 aNamespaceID) const = 0;
|
||||
NS_IMETHOD_(PRBool) NamespaceEquals(const nsAString& aNamespaceURI) const = 0;
|
||||
NS_IMETHOD_(PRBool) QualifiedNameEquals(const nsAString& aQualifiedName) const = 0;
|
||||
|
||||
/*
|
||||
* This is a convinience method that creates a new nsINodeInfo that differs
|
||||
* only by name from the one this is called on.
|
||||
*/
|
||||
NS_IMETHOD NameChanged(nsIAtom *aName, nsINodeInfo*& aResult) = 0;
|
||||
|
||||
/*
|
||||
* This is a convinience method that creates a new nsINodeInfo that differs
|
||||
* only by prefix from the one this is called on.
|
||||
*/
|
||||
NS_IMETHOD PrefixChanged(nsIAtom *aPrefix, nsINodeInfo*& aResult) = 0;
|
||||
|
||||
/*
|
||||
* Retrieve a pointer to the document that owns this node info.
|
||||
*/
|
||||
NS_IMETHOD GetDocument(nsIDocument*& aDocument) const = 0;
|
||||
|
||||
protected:
|
||||
/*
|
||||
* 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;
|
||||
};
|
||||
|
||||
|
||||
class nsINodeInfoManager : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_INODEINFOMANAGER_IID)
|
||||
|
||||
/*
|
||||
* Initialize the nodeinfo manager with a namespace manager, this should
|
||||
* allways be done.
|
||||
*/
|
||||
NS_IMETHOD Init(nsIDocument *aDocument,
|
||||
nsINameSpaceManager *aNameSpaceManager) = 0;
|
||||
|
||||
/*
|
||||
* Release the reference to the document, this will be called when
|
||||
* the document is going away.
|
||||
*/
|
||||
NS_IMETHOD DropDocumentReference() = 0;
|
||||
|
||||
/*
|
||||
* Methods for creating nodeinfo's from atoms and/or strings.
|
||||
*/
|
||||
NS_IMETHOD GetNodeInfo(nsIAtom *aName, nsIAtom *aPrefix,
|
||||
PRInt32 aNamespaceID, nsINodeInfo*& aNodeInfo) = 0;
|
||||
NS_IMETHOD GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix,
|
||||
PRInt32 aNamespaceID, nsINodeInfo*& aNodeInfo) = 0;
|
||||
NS_IMETHOD GetNodeInfo(const nsAString& aName, const nsAString& aPrefix,
|
||||
PRInt32 aNamespaceID, nsINodeInfo*& aNodeInfo) = 0;
|
||||
NS_IMETHOD GetNodeInfo(const nsAString& aName, const nsAString& aPrefix,
|
||||
const nsAString& aNamespaceURI,
|
||||
nsINodeInfo*& aNodeInfo) = 0;
|
||||
NS_IMETHOD GetNodeInfo(const nsAString& aQualifiedName,
|
||||
const nsAString& aNamespaceURI,
|
||||
nsINodeInfo*& aNodeInfo) = 0;
|
||||
|
||||
/*
|
||||
* Getter for the namespace manager used by this nodeinfo manager.
|
||||
*/
|
||||
NS_IMETHOD GetNamespaceManager(nsINameSpaceManager*& aNameSpaceManager) = 0;
|
||||
|
||||
/*
|
||||
* Retrieve a pointer to the document that owns this node info
|
||||
* manager.
|
||||
*/
|
||||
NS_IMETHOD GetDocument(nsIDocument*& aDocument) = 0;
|
||||
};
|
||||
|
||||
extern nsresult NS_NewNodeInfoManager(nsINodeInfoManager** aResult);
|
||||
|
||||
#endif /* nsINodeInfo_h___ */
|
||||
@@ -1,78 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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):
|
||||
* Jean-Francois Ducarroz <ducarroz@netscape.com>
|
||||
* Rod Spears <rods@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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIWebProgressListener.idl"
|
||||
|
||||
interface nsIDOMWindowInternal;
|
||||
interface nsIObserver;
|
||||
interface nsIPrompt;
|
||||
|
||||
[scriptable, uuid(7E46BC35-FB7D-4b45-AB35-82FD61015380)]
|
||||
interface nsIPrintProgress: nsIWebProgressListener {
|
||||
|
||||
/* Open the progress dialog
|
||||
you can specify parameters through an xpcom object
|
||||
*/
|
||||
void openProgressDialog(in nsIDOMWindowInternal parent,
|
||||
in string dialogURL,
|
||||
in nsISupports parameters,
|
||||
in nsIObserver openDialogObserver,
|
||||
out boolean notifyOnOpen);
|
||||
|
||||
/* Close the progress dialog */
|
||||
void closeProgressDialog(in boolean forceClose);
|
||||
|
||||
/* Register a Web Progress Listener */
|
||||
void registerListener(in nsIWebProgressListener listener);
|
||||
|
||||
/* Unregister a Web Progress Listener */
|
||||
void unregisterListener(in nsIWebProgressListener listener);
|
||||
|
||||
/* This method is called after the dialog that shows the progress has been shown
|
||||
*/
|
||||
void doneIniting();
|
||||
|
||||
/* Retrive the prompter, needed to display modal dialog on top of progress dialog */
|
||||
nsIPrompt getPrompter();
|
||||
|
||||
/* Indicated if the user asked to cancel the current process */
|
||||
attribute boolean processCanceledByUser;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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):
|
||||
* Jean-Francois Ducarroz <ducarroz@netscaape.com>
|
||||
* Rod Spears <rods@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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(CA89B55B-6FAF-4051-9645-1C03EF5108F8)]
|
||||
interface nsIPrintProgressParams: nsISupports {
|
||||
|
||||
/* message subject */
|
||||
attribute wstring docTitle;
|
||||
attribute wstring docURL;
|
||||
|
||||
};
|
||||
@@ -1,53 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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) 1999
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDocShell;
|
||||
interface nsIDOMWindowInternal;
|
||||
|
||||
[scriptable, uuid(19855DFF-3248-4902-B196-93EE4C477880)]
|
||||
interface nsIPrintStatusFeedback : nsISupports {
|
||||
|
||||
void showStatusString(in wstring status);
|
||||
void startMeteors();
|
||||
void stopMeteors();
|
||||
void showProgress(in long percent);
|
||||
[noscript] void setDocShell(in nsIDocShell shell, in nsIDOMWindowInternal window);
|
||||
void closeWindow();
|
||||
};
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsIPrivateDOMImplementation_h__
|
||||
#define nsIPrivateDOMImplementation_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIURI;
|
||||
|
||||
/*
|
||||
* Event listener manager interface.
|
||||
*/
|
||||
#define NS_IPRIVATEDOMIMPLEMENTATION_IID \
|
||||
{ /* d3205fb8-2652-11d4-ba06-0060b0fc76dd */ \
|
||||
0xd3205fb8, 0x2652, 0x11d4, \
|
||||
{0xba, 0x06, 0x00, 0x60, 0xb0, 0xfc, 0x76, 0xdd} }
|
||||
|
||||
class nsIPrivateDOMImplementation : public nsISupports {
|
||||
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPRIVATEDOMIMPLEMENTATION_IID)
|
||||
|
||||
NS_IMETHOD Init(nsIURI* aBaseURI) = 0;
|
||||
};
|
||||
|
||||
NS_EXPORT nsresult
|
||||
NS_NewDOMImplementation(nsIDOMDOMImplementation** aInstancePtrResult);
|
||||
|
||||
#endif // nsIPrivateDOMImplementation_h__
|
||||
@@ -1,67 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the NPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the NPL or the GPL.
|
||||
*/
|
||||
|
||||
/* 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_DEFINE_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;
|
||||
};
|
||||
|
||||
#endif /* nsIRangeUtils_h___ */
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* 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 Netscape Communications are
|
||||
* Copyright (C) 2001 by Netscape Communications. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vidur Apparao <vidur@netscape.com> (original author)
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDocument;
|
||||
interface nsIDOMHTMLScriptElement;
|
||||
interface nsIScriptLoaderObserver;
|
||||
|
||||
[scriptable, uuid(501209d3-7edf-437d-9948-3c6d1c08ef7a)]
|
||||
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 nsIDOMHTMLScriptElement aElement,
|
||||
in nsIScriptLoaderObserver aObserver);
|
||||
|
||||
/**
|
||||
* Suspend processing of new script elements. Any call to
|
||||
* processScriptElement() will fail with a return code of
|
||||
* NS_ERROR_NOT_AVAILABLE. Note that this DOES NOT suspend
|
||||
* currently loading or executing scripts. All calls to
|
||||
* suspend() must be matched with an equal number of calls
|
||||
* to resume() before processing of new script elements
|
||||
* continues.
|
||||
*/
|
||||
void suspend();
|
||||
|
||||
/**
|
||||
* Resume processing of new script elements.
|
||||
*/
|
||||
void resume();
|
||||
};
|
||||
@@ -1,77 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* 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 Netscape Communications are
|
||||
* Copyright (C) 2001 by Netscape Communications. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vidur Apparao <vidur@netscape.com> (original author)
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDOMHTMLScriptElement;
|
||||
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 nsIDOMHTMLScriptElement 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 nsIDOMHTMLScriptElement aElement,
|
||||
in boolean aIsInline,
|
||||
in boolean aWasPending);
|
||||
|
||||
};
|
||||
@@ -1,171 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, 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
|
||||
{
|
||||
/**
|
||||
* The node representing one end of the selection.
|
||||
*/
|
||||
readonly attribute nsIDOMNode anchorNode;
|
||||
|
||||
/**
|
||||
* The offset within the (text) node where the selection begins.
|
||||
*/
|
||||
readonly attribute long anchorOffset;
|
||||
|
||||
/**
|
||||
* The node with keyboard focus.
|
||||
*/
|
||||
readonly attribute nsIDOMNode focusNode;
|
||||
|
||||
/**
|
||||
* The offset within the (text) node where focus starts.
|
||||
*/
|
||||
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 focus to the specified node and offset,
|
||||
* preserving the anchor postion. The new selection end result will always
|
||||
* be from the anchor to the new focus, 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 focused node
|
||||
*/
|
||||
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();
|
||||
|
||||
/**
|
||||
* The value of entirelyContained determines the detail of the search to determine if
|
||||
* the selection contains the node. If entirelyContained is set to PR_TRUE, t
|
||||
* or false if
|
||||
* @param node The node where the selection will be extended to
|
||||
* @param entirelyContained Whether
|
||||
*/
|
||||
boolean containsNode(in nsIDOMNode node, in boolean entirelyContained);
|
||||
|
||||
/**
|
||||
* 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,225 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Sammy Ford
|
||||
*/
|
||||
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsISelection.idl"
|
||||
#include "nsISelectionDisplay.idl"
|
||||
|
||||
%{C++
|
||||
|
||||
class nsISelection;
|
||||
typedef short SelectionType;
|
||||
typedef short SelectionRegion;
|
||||
%}
|
||||
|
||||
interface nsIDOMNode;
|
||||
interface nsISelectionDisplay;
|
||||
|
||||
[scriptable, uuid(D2D1D179-85A7-11d3-9932-00108301233C)]
|
||||
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 NUM_SELECTIONTYPES=6;
|
||||
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 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 carets width
|
||||
* Can be called any time.
|
||||
* @param pixels, the width of the caret in pixels
|
||||
* @return always NS_OK if successful, NS_ERROR_FAILURE if not.
|
||||
*/
|
||||
void setCaretWidth(in short pixels);
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
/** 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,53 +0,0 @@
|
||||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 Netscape are
|
||||
* Copyright (C) 1999, Mozilla. All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#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,57 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, 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,88 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsISelectionListener.idl"
|
||||
#include "nsIEnumerator.idl"
|
||||
|
||||
interface nsIDOMRange;
|
||||
interface nsISelectionListener;
|
||||
|
||||
|
||||
[scriptable, uuid(2d5535e2-1dd2-11b2-8e38-d53ec833adf6)]
|
||||
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 nsIFrameSelection 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);
|
||||
};
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsIStyleRule_h___
|
||||
#define nsIStyleRule_h___
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsISizeOfHandler;
|
||||
|
||||
class nsIStyleSheet;
|
||||
class nsIPresContext;
|
||||
class nsIContent;
|
||||
struct nsRuleData;
|
||||
|
||||
// IID for the nsIStyleRule interface {40ae5c90-ad6a-11d1-8031-006008159b5a}
|
||||
#define NS_ISTYLE_RULE_IID \
|
||||
{0x40ae5c90, 0xad6a, 0x11d1, {0x80, 0x31, 0x00, 0x60, 0x08, 0x15, 0x9b, 0x5a}}
|
||||
|
||||
class nsIStyleRule : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISTYLE_RULE_IID)
|
||||
|
||||
NS_IMETHOD GetStyleSheet(nsIStyleSheet*& aSheet) const = 0;
|
||||
|
||||
// Strength is an out-of-band weighting, useful for mapping CSS ! important
|
||||
NS_IMETHOD GetStrength(PRInt32& aStrength) const = 0;
|
||||
|
||||
// The new mapping function.
|
||||
NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData)=0;
|
||||
|
||||
#ifdef DEBUG
|
||||
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const = 0;
|
||||
|
||||
virtual void SizeOf(nsISizeOfHandler *aSizeOfHandler, PRUint32 &aSize) = 0;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
#endif /* nsIStyleRule_h___ */
|
||||
@@ -1,178 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsIStyleRuleProcessor_h___
|
||||
#define nsIStyleRuleProcessor_h___
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIPresContext.h" // for nsCompatability
|
||||
#include "nsILinkHandler.h"
|
||||
|
||||
class nsISizeOfHandler;
|
||||
|
||||
class nsIStyleSheet;
|
||||
class nsIStyleContext;
|
||||
class nsIPresContext;
|
||||
class nsIContent;
|
||||
class nsIStyledContent;
|
||||
class nsISupportsArray;
|
||||
class nsIAtom;
|
||||
class nsICSSPseudoComparator;
|
||||
class nsRuleWalker;
|
||||
|
||||
// The implementation of the constructor and destructor are currently in
|
||||
// nsCSSStyleSheet.cpp.
|
||||
|
||||
struct RuleProcessorData {
|
||||
RuleProcessorData(nsIPresContext* aPresContext,
|
||||
nsIContent* aContent,
|
||||
nsRuleWalker* aRuleWalker,
|
||||
nsCompatibility* aCompat = nsnull);
|
||||
|
||||
// NOTE: not |virtual|
|
||||
~RuleProcessorData();
|
||||
|
||||
void* operator new(size_t sz, nsIPresContext* aContext) {
|
||||
void* result = nsnull;
|
||||
aContext->AllocateFromShell(sz, &result);
|
||||
return result;
|
||||
}
|
||||
void Destroy(nsIPresContext* aContext) {
|
||||
this->~RuleProcessorData();
|
||||
aContext->FreeToShell(sizeof(RuleProcessorData), this);
|
||||
};
|
||||
|
||||
nsIPresContext* mPresContext;
|
||||
nsIContent* mContent;
|
||||
nsIContent* mParentContent; // if content, content->GetParent()
|
||||
nsRuleWalker* mRuleWalker; // Used to add rules to our results.
|
||||
nsIContent* mScopedRoot; // Root of scoped stylesheet (set and unset by the supplier of the scoped stylesheet
|
||||
|
||||
nsIAtom* mContentTag; // if content, then content->GetTag()
|
||||
nsIAtom* mContentID; // if styled content, then styledcontent->GetID()
|
||||
nsIStyledContent* mStyledContent; // if content, content->QI(nsIStyledContent)
|
||||
PRPackedBool mIsHTMLContent; // if content, then does QI on HTMLContent, true or false
|
||||
PRPackedBool mIsHTMLLink; // if content, calls nsStyleUtil::IsHTMLLink
|
||||
PRPackedBool mIsSimpleXLink; // if content, calls nsStyleUtil::IsSimpleXLink
|
||||
nsCompatibility mCompatMode; // Possibly remove use of this in SelectorMatches?
|
||||
PRPackedBool mHasAttributes; // if content, content->GetAttrCount() > 0
|
||||
PRPackedBool mIsChecked; // checked/selected attribute for option and select elements
|
||||
nsLinkState mLinkState; // if a link, this is the state, otherwise unknown
|
||||
PRInt32 mEventState; // if content, eventStateMgr->GetContentState()
|
||||
PRInt32 mNameSpaceID; // if content, content->GetNameSapce()
|
||||
RuleProcessorData* mPreviousSiblingData;
|
||||
RuleProcessorData* mParentData;
|
||||
};
|
||||
|
||||
struct ElementRuleProcessorData : public RuleProcessorData {
|
||||
ElementRuleProcessorData(nsIPresContext* aPresContext,
|
||||
nsIContent* aContent,
|
||||
nsRuleWalker* aRuleWalker)
|
||||
: RuleProcessorData(aPresContext,aContent,aRuleWalker)
|
||||
{
|
||||
NS_PRECONDITION(aContent, "null pointer");
|
||||
NS_PRECONDITION(aRuleWalker, "null pointer");
|
||||
}
|
||||
};
|
||||
|
||||
struct PseudoRuleProcessorData : public RuleProcessorData {
|
||||
PseudoRuleProcessorData(nsIPresContext* aPresContext,
|
||||
nsIContent* aParentContent,
|
||||
nsIAtom* aPseudoTag,
|
||||
nsICSSPseudoComparator* aComparator,
|
||||
nsRuleWalker* aRuleWalker)
|
||||
: RuleProcessorData(aPresContext, aParentContent, aRuleWalker)
|
||||
{
|
||||
NS_PRECONDITION(aPseudoTag, "null pointer");
|
||||
NS_PRECONDITION(aRuleWalker, "null pointer");
|
||||
mPseudoTag = aPseudoTag;
|
||||
mComparator = aComparator;
|
||||
}
|
||||
|
||||
nsIAtom* mPseudoTag;
|
||||
nsICSSPseudoComparator* mComparator;
|
||||
};
|
||||
|
||||
struct StateRuleProcessorData : public RuleProcessorData {
|
||||
StateRuleProcessorData(nsIPresContext* aPresContext,
|
||||
nsIContent* aContent,
|
||||
PRInt32 aStateMask)
|
||||
: RuleProcessorData(aPresContext, aContent, nsnull),
|
||||
mStateMask(aStateMask)
|
||||
{
|
||||
NS_PRECONDITION(aContent, "null pointer");
|
||||
}
|
||||
const PRInt32 mStateMask; // |HasStateDependentStyle| for which state(s)?
|
||||
// Constants defined in nsIEventStateManager.h .
|
||||
};
|
||||
|
||||
|
||||
// IID for the nsIStyleRuleProcessor interface {015575fe-7b6c-11d3-ba05-001083023c2b}
|
||||
#define NS_ISTYLE_RULE_PROCESSOR_IID \
|
||||
{0x015575fe, 0x7b6c, 0x11d3, {0xba, 0x05, 0x00, 0x10, 0x83, 0x02, 0x3c, 0x2b}}
|
||||
|
||||
/* The style rule processor interface is a mechanism to seperate the matching
|
||||
* of style rules from style sheet instances.
|
||||
* Simple style sheets can and will act as their own processor.
|
||||
* Sheets where rule ordering interlaces between multiple sheets, will need to
|
||||
* share a single rule processor between them (CSS sheets do this for cascading order)
|
||||
*/
|
||||
class nsIStyleRuleProcessor : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISTYLE_RULE_PROCESSOR_IID)
|
||||
|
||||
// populate rule node tree with nsIStyleRule*
|
||||
// rules are ordered, those with higher precedence are farthest from the root of the tree
|
||||
NS_IMETHOD RulesMatching(ElementRuleProcessorData* aData,
|
||||
nsIAtom* aMedium) = 0;
|
||||
|
||||
NS_IMETHOD RulesMatching(PseudoRuleProcessorData* aData,
|
||||
nsIAtom* aMedium) = 0;
|
||||
|
||||
// Test if style is dependent on content state
|
||||
NS_IMETHOD HasStateDependentStyle(StateRuleProcessorData* aData,
|
||||
nsIAtom* aMedium,
|
||||
PRBool* aResult) = 0;
|
||||
|
||||
#ifdef DEBUG
|
||||
virtual void SizeOf(nsISizeOfHandler *aSizeofHandler, PRUint32 &aSize) = 0;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif /* nsIStyleRuleProcessor_h___ */
|
||||
@@ -1,30 +0,0 @@
|
||||
#ifndef _nsIStyleRuleSupplier_h
|
||||
#define _nsIStyleRuleSupplier_h
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsIStyleRuleProcessor.h"
|
||||
|
||||
// {2D77A45B-4F3A-4203-A7D2-F4B84D0C1EE4}
|
||||
#define NS_ISTYLERULESUPPLIER_IID \
|
||||
{ 0x2d77a45b, 0x4f3a, 0x4203, { 0xa7, 0xd2, 0xf4, 0xb8, 0x4d, 0xc, 0x1e, 0xe4 } }
|
||||
|
||||
class nsIContent;
|
||||
class nsIStyleSet;
|
||||
|
||||
class nsIStyleRuleSupplier : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISTYLERULESUPPLIER_IID)
|
||||
|
||||
NS_IMETHOD UseDocumentRules(nsIContent* aContent, PRBool* aResult)=0;
|
||||
NS_IMETHOD WalkRules(nsIStyleSet* aStyleSet,
|
||||
nsISupportsArrayEnumFunc aFunc,
|
||||
RuleProcessorData* aData)=0;
|
||||
|
||||
NS_IMETHOD AttributeAffectsStyle(nsISupportsArrayEnumFunc aFunc,
|
||||
void* aData,
|
||||
nsIContent* aContent,
|
||||
PRBool* aAffects)=0;
|
||||
};
|
||||
|
||||
#endif /* _nsIStyleRuleSupplier_h */
|
||||
@@ -1,100 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsIStyleSheet_h___
|
||||
#define nsIStyleSheet_h___
|
||||
|
||||
#include <stdio.h>
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsISizeOfHandler;
|
||||
|
||||
class nsIAtom;
|
||||
class nsString;
|
||||
class nsIURI;
|
||||
class nsIStyleRule;
|
||||
class nsISupportsArray;
|
||||
class nsIPresContext;
|
||||
class nsIContent;
|
||||
class nsIDocument;
|
||||
class nsIStyleContext;
|
||||
class nsIStyleRuleProcessor;
|
||||
|
||||
// IID for the nsIStyleSheet interface {8c4a80a0-ad6a-11d1-8031-006008159b5a}
|
||||
#define NS_ISTYLE_SHEET_IID \
|
||||
{0x8c4a80a0, 0xad6a, 0x11d1, {0x80, 0x31, 0x00, 0x60, 0x08, 0x15, 0x9b, 0x5a}}
|
||||
|
||||
class nsIStyleSheet : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISTYLE_SHEET_IID)
|
||||
|
||||
// basic style sheet data
|
||||
NS_IMETHOD GetURL(nsIURI*& aURL) const = 0;
|
||||
NS_IMETHOD GetTitle(nsString& aTitle) const = 0;
|
||||
NS_IMETHOD GetType(nsString& aType) const = 0;
|
||||
NS_IMETHOD GetMediumCount(PRInt32& aCount) const = 0;
|
||||
NS_IMETHOD GetMediumAt(PRInt32 aIndex, nsIAtom*& aMedium) const = 0;
|
||||
NS_IMETHOD_(PRBool) UseForMedium(nsIAtom* aMedium) const = 0;
|
||||
|
||||
NS_IMETHOD GetEnabled(PRBool& aEnabled) const = 0;
|
||||
NS_IMETHOD SetEnabled(PRBool aEnabled) = 0;
|
||||
|
||||
// style sheet owner info
|
||||
NS_IMETHOD GetParentSheet(nsIStyleSheet*& aParent) const = 0; // may be null
|
||||
NS_IMETHOD GetOwningDocument(nsIDocument*& aDocument) const = 0; // may be null
|
||||
NS_IMETHOD SetOwningDocument(nsIDocument* aDocument) = 0;
|
||||
|
||||
// style rule processor access
|
||||
NS_IMETHOD GetStyleRuleProcessor(nsIStyleRuleProcessor*& aProcessor,
|
||||
nsIStyleRuleProcessor* aPrevProcessor) = 0;
|
||||
|
||||
// XXX style rule enumerations
|
||||
|
||||
// If changing the given attribute cannot affect style context, aAffects
|
||||
// will be PR_FALSE on return.
|
||||
NS_IMETHOD AttributeAffectsStyle(nsIAtom *aAttribute, nsIContent *aContent,
|
||||
PRBool &aAffects) = 0;
|
||||
|
||||
#ifdef DEBUG
|
||||
virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const = 0;
|
||||
|
||||
virtual void SizeOf(nsISizeOfHandler *aSizeofHandler, PRUint32 &aSize) = 0;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
#endif /* nsIStyleSheet_h___ */
|
||||
@@ -1,114 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsIStyleSheetLinkingElement_h__
|
||||
#define nsIStyleSheetLinkingElement_h__
|
||||
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIParser;
|
||||
class nsIDocument;
|
||||
|
||||
#define NS_ISTYLESHEETLINKINGELEMENT_IID \
|
||||
{0xa6cf90e9, 0x15b3, 0x11d2, \
|
||||
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
class nsIStyleSheet;
|
||||
|
||||
class nsIStyleSheetLinkingElement : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_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 aDocIndex index of the stylesheet in the document's
|
||||
* stylesheet list. -1 means we'll look up the
|
||||
* index from the position of the element.
|
||||
*/
|
||||
NS_IMETHOD UpdateStyleSheet(nsIDocument *aOldDocument,
|
||||
PRInt32 aDocIndex) = 0;
|
||||
|
||||
/**
|
||||
* Tells this element wether 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;
|
||||
};
|
||||
|
||||
#endif // nsILinkingElement_h__
|
||||
@@ -1,78 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsIStyledContent_h___
|
||||
#define nsIStyledContent_h___
|
||||
|
||||
#include "nsIContent.h"
|
||||
|
||||
class nsString;
|
||||
class nsIStyleRule;
|
||||
class nsIStyleContext;
|
||||
class nsISupportsArray;
|
||||
class nsRuleWalker;
|
||||
|
||||
// IID for the nsIStyledContent class
|
||||
#define NS_ISTYLEDCONTENT_IID \
|
||||
{ 0xc1e84e01, 0xcd15, 0x11d2, { 0x96, 0xed, 0x0, 0x10, 0x4b, 0x7b, 0x7d, 0xeb } }
|
||||
|
||||
// Abstract interface for all styled content (that supports ID, CLASS, STYLE, and
|
||||
// the ability to specify style hints on an attribute change).
|
||||
class nsIStyledContent : public nsIContent {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISTYLEDCONTENT_IID)
|
||||
|
||||
NS_IMETHOD GetID(nsIAtom*& aResult) const = 0;
|
||||
NS_IMETHOD GetClasses(nsVoidArray& aArray) const = 0;
|
||||
NS_IMETHOD HasClass(nsIAtom* aClass, PRBool aCaseSensitive) const = 0;
|
||||
|
||||
NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker) = 0;
|
||||
NS_IMETHOD WalkInlineStyleRules(nsRuleWalker* aRuleWalker) = 0;
|
||||
|
||||
/** NRA ***
|
||||
* Get a hint that tells the style system what to do when
|
||||
* an attribute on this node changes.
|
||||
* This only applies to attributes that map their value
|
||||
* DIRECTLY into style contexts via NON-CSS style rules
|
||||
* All other attributes return NS_STYLE_HINT_CONTENT
|
||||
*/
|
||||
NS_IMETHOD GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType,
|
||||
PRInt32& aHint) const = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif /* nsIStyledContent_h___ */
|
||||
@@ -1,150 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsITextContent_h___
|
||||
#define nsITextContent_h___
|
||||
|
||||
#include "nsIContent.h"
|
||||
class nsString;
|
||||
class nsTextFragment;
|
||||
|
||||
// IID for the nsITextContent interface
|
||||
#define NS_ITEXT_CONTENT_IID \
|
||||
{0xa6cf9065, 0x15b3, 0x11d2, {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
/**
|
||||
* Interface for textual content. This interface is used to provide
|
||||
* an efficient access to text content.
|
||||
*/
|
||||
class nsITextContent : public nsIContent {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ITEXT_CONTENT_IID)
|
||||
|
||||
/**
|
||||
* Get direct access (but read only) to the text in the text content.
|
||||
*/
|
||||
NS_IMETHOD GetText(const nsTextFragment** aFragmentsResult) = 0;
|
||||
|
||||
/**
|
||||
* Get the length of the text content.
|
||||
*/
|
||||
NS_IMETHOD GetTextLength(PRInt32* aLengthResult) = 0;
|
||||
|
||||
/**
|
||||
* Make a copy of the text content in aResult.
|
||||
*/
|
||||
NS_IMETHOD CopyText(nsAString& aResult) = 0;
|
||||
|
||||
/**
|
||||
* Set the text to the given value. If aNotify is PR_TRUE then
|
||||
* the document is notified of the content change.
|
||||
*/
|
||||
NS_IMETHOD SetText(const PRUnichar* aBuffer,
|
||||
PRInt32 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.
|
||||
*/
|
||||
NS_IMETHOD SetText(const nsAString& aStr,
|
||||
PRBool aNotify) = 0;
|
||||
|
||||
/**
|
||||
* Set the text to the given value. If aNotify is PR_TRUE then
|
||||
* the document is notified of the content change.
|
||||
*/
|
||||
NS_IMETHOD SetText(const char* aBuffer,
|
||||
PRInt32 aLength,
|
||||
PRBool aNotify) = 0;
|
||||
|
||||
/**
|
||||
* Query method to see if the frame is nothing but whitespace
|
||||
*/
|
||||
NS_IMETHOD IsOnlyWhitespace(PRBool* aResult) = 0;
|
||||
|
||||
/**
|
||||
* Clone this content node. Unlike the nsIDOMNode equivalent, this
|
||||
* method allows you to specify whether to copy the text as well.
|
||||
*/
|
||||
NS_IMETHOD CloneContent(PRBool aCloneText, nsITextContent** aClone) = 0;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/* a6cf905e-15b3-11d2-932e-00805f8add32 */
|
||||
#define NS_ITEXT_CONTENT_CHANGE_DATA_IID \
|
||||
{0xa6cf905e, 0x15b3, 0x11d2, {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
// Simple interface for encapsulating change data for a ContentChanged
|
||||
// notification.
|
||||
class nsITextContentChangeData : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ITEXT_CONTENT_CHANGE_DATA_IID);
|
||||
|
||||
enum ChangeType {
|
||||
Insert,
|
||||
Append,
|
||||
Replace
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the type of change associated with the ContentChanged
|
||||
* notification.
|
||||
*/
|
||||
NS_IMETHOD GetChangeType(ChangeType* aResult) = 0;
|
||||
|
||||
NS_IMETHOD GetInsertData(PRInt32* aOffset,
|
||||
PRInt32* aInsertLength) = 0;
|
||||
|
||||
NS_IMETHOD GetAppendData(PRInt32* aOffset,
|
||||
PRInt32* aAppendLength) = 0;
|
||||
|
||||
NS_IMETHOD GetReplaceData(PRInt32* aOffset,
|
||||
PRInt32* aSourceLength,
|
||||
PRInt32* aReplaceLength) = 0;
|
||||
};
|
||||
|
||||
// XXX These belong elsewhere
|
||||
extern nsresult
|
||||
NS_NewTextNode(nsIContent** aResult);
|
||||
|
||||
extern nsresult
|
||||
NS_NewCommentNode(nsIContent** aResult);
|
||||
|
||||
|
||||
#endif /* nsITextContent_h___ */
|
||||
@@ -1,7 +0,0 @@
|
||||
#
|
||||
# This is a list of local files which get copied to the mozilla:dist:content directory
|
||||
#
|
||||
nsContentList.h
|
||||
nsDocument.h
|
||||
nsGenericDOMNodeList.h
|
||||
nsGenericElement.h
|
||||
@@ -1,125 +0,0 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape 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/NPL/
|
||||
#
|
||||
# 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 Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = content
|
||||
LIBRARY_NAME = gkconbase_s
|
||||
REQUIRES = xpcom \
|
||||
string \
|
||||
dom \
|
||||
gfx \
|
||||
layout \
|
||||
widget \
|
||||
view \
|
||||
locale \
|
||||
htmlparser \
|
||||
js \
|
||||
webshell \
|
||||
necko \
|
||||
caps \
|
||||
lwbrk \
|
||||
uconv \
|
||||
chrome \
|
||||
docshell \
|
||||
pref \
|
||||
xpconnect \
|
||||
util \
|
||||
unicharutil \
|
||||
xuldoc \
|
||||
intl \
|
||||
windowwatcher \
|
||||
imglib2 \
|
||||
gfx2 \
|
||||
uriloader \
|
||||
webbrwsr \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
nsPrintPreviewListener.cpp \
|
||||
nsCommentNode.cpp \
|
||||
nsContentIterator.cpp \
|
||||
nsContentList.cpp \
|
||||
nsContentPolicy.cpp \
|
||||
nsDocument.cpp \
|
||||
nsDocumentEncoder.cpp \
|
||||
nsDocumentFragment.cpp \
|
||||
nsDocumentViewer.cpp \
|
||||
nsDOMAttribute.cpp \
|
||||
nsDOMAttributeMap.cpp \
|
||||
nsDOMDocumentType.cpp \
|
||||
nsGeneratedIterator.cpp \
|
||||
nsGenericDOMDataNode.cpp \
|
||||
nsGenericDOMNodeList.cpp \
|
||||
nsGenericElement.cpp \
|
||||
nsContentUtils.cpp \
|
||||
nsNameSpaceManager.cpp \
|
||||
nsNodeInfo.cpp \
|
||||
nsNodeInfoManager.cpp \
|
||||
nsRange.cpp \
|
||||
nsRuleNode.cpp \
|
||||
nsSelection.cpp \
|
||||
nsStyleContext.cpp \
|
||||
nsStyleSet.cpp \
|
||||
nsTextContentChangeData.cpp \
|
||||
nsTextNode.cpp \
|
||||
nsTreeWalker.cpp \
|
||||
nsXMLContentSerializer.cpp \
|
||||
nsHTMLContentSerializer.cpp \
|
||||
nsParserUtils.cpp \
|
||||
nsPlainTextSerializer.cpp \
|
||||
mozSanitizingSerializer.cpp \
|
||||
nsScriptLoader.cpp \
|
||||
nsStyleLinkElement.cpp \
|
||||
nsContentAreaDragDrop.cpp \
|
||||
nsFrameLoader.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
|
||||
|
||||
DEFINES += -D_IMPL_NS_LAYOUT
|
||||
|
||||
ifdef XP_NEW_SELECTION
|
||||
DEFINES += -DXP_NEW_SELECTION
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
DEFINES += -DWIN32_LEAN_AND_MEAN
|
||||
endif
|
||||
|
||||
INCLUDES += \
|
||||
-I$(srcdir)/../../events/src \
|
||||
-I$(srcdir)/../../html/base/src \
|
||||
-I$(srcdir)/../../html/style/src \
|
||||
-I$(srcdir)/../../xul/base/src \
|
||||
-I$(srcdir)/../../xul/content/src \
|
||||
-I$(srcdir)/../../html/content/src \
|
||||
-I$(srcdir)/../../base/src \
|
||||
$(NULL)
|
||||
@@ -1,119 +0,0 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape 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/NPL/
|
||||
#
|
||||
# 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 Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..\..\..
|
||||
|
||||
LIBRARY_NAME=contentbase_s
|
||||
DEFINES=-D_IMPL_NS_LAYOUT -DWIN32_LEAN_AND_MEAN
|
||||
!if defined(XP_NEW_SELECTION)
|
||||
DEFINES = $(DEFINES) -DXP_NEW_SELECTION
|
||||
!endif
|
||||
|
||||
MODULE=content
|
||||
REQUIRES = xpcom \
|
||||
string \
|
||||
dom \
|
||||
widget \
|
||||
view \
|
||||
locale \
|
||||
htmlparser \
|
||||
js \
|
||||
webshell \
|
||||
necko \
|
||||
caps \
|
||||
lwbrk \
|
||||
uconv \
|
||||
chrome \
|
||||
docshell \
|
||||
uriloader \
|
||||
pref \
|
||||
xpconnect \
|
||||
util \
|
||||
unicharutil \
|
||||
layout \
|
||||
gfx \
|
||||
layout_xul \
|
||||
content_xul \
|
||||
windowwatcher \
|
||||
intl \
|
||||
imglib2 \
|
||||
gfx2 \
|
||||
uriloader \
|
||||
webBrowser_core\
|
||||
$(NULL)
|
||||
|
||||
CPP_OBJS= \
|
||||
.\$(OBJDIR)\nsPrintPreviewListener.obj \
|
||||
.\$(OBJDIR)\nsStyleContext.obj \
|
||||
.\$(OBJDIR)\nsStyleSet.obj \
|
||||
.\$(OBJDIR)\nsCommentNode.obj \
|
||||
.\$(OBJDIR)\nsGenericDOMDataNode.obj \
|
||||
.\$(OBJDIR)\nsGenericDOMNodeList.obj \
|
||||
.\$(OBJDIR)\nsGenericElement.obj \
|
||||
.\$(OBJDIR)\nsContentList.obj \
|
||||
.\$(OBJDIR)\nsContentIterator.obj \
|
||||
.\$(OBJDIR)\nsContentPolicy.obj \
|
||||
.\$(OBJDIR)\nsDocument.obj \
|
||||
.\$(OBJDIR)\nsDocumentEncoder.obj \
|
||||
.\$(OBJDIR)\nsDocumentFragment.obj \
|
||||
.\$(OBJDIR)\nsDocumentViewer.obj \
|
||||
.\$(OBJDIR)\nsDOMAttribute.obj \
|
||||
.\$(OBJDIR)\nsDOMAttributeMap.obj \
|
||||
.\$(OBJDIR)\nsDOMDocumentType.obj \
|
||||
.\$(OBJDIR)\nsGeneratedIterator.obj \
|
||||
.\$(OBJDIR)\nsNameSpaceManager.obj \
|
||||
.\$(OBJDIR)\nsNodeInfo.obj \
|
||||
.\$(OBJDIR)\nsNodeInfoManager.obj \
|
||||
.\$(OBJDIR)\nsSelection.obj \
|
||||
.\$(OBJDIR)\nsRange.obj \
|
||||
.\$(OBJDIR)\nsRuleNode.obj \
|
||||
.\$(OBJDIR)\nsTextContentChangeData.obj \
|
||||
.\$(OBJDIR)\nsTextNode.obj \
|
||||
.\$(OBJDIR)\nsTreeWalker.obj \
|
||||
.\$(OBJDIR)\nsXMLContentSerializer.obj \
|
||||
.\$(OBJDIR)\nsHTMLContentSerializer.obj \
|
||||
.\$(OBJDIR)\nsParserUtils.obj \
|
||||
.\$(OBJDIR)\nsPlainTextSerializer.obj \
|
||||
.\$(OBJDIR)\mozSanitizingSerializer.obj \
|
||||
.\$(OBJDIR)\nsContentUtils.obj \
|
||||
.\$(OBJDIR)\nsScriptLoader.obj \
|
||||
.\$(OBJDIR)\nsStyleLinkElement.obj \
|
||||
.\$(OBJDIR)\nsContentAreaDragDrop.obj \
|
||||
.\$(OBJDIR)\nsFrameLoader.obj \
|
||||
$(NULL)
|
||||
|
||||
LINCS=-I..\..\html\base\src -I..\..\html\style\src \
|
||||
-I..\..\xul\base\src -I..\..\xul\content\src \
|
||||
-I..\..\events\src -I..\..\html\content\src
|
||||
|
||||
LCFLAGS = \
|
||||
$(LCFLAGS) \
|
||||
$(DEFINES) \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
libs:: $(LIBRARY)
|
||||
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\lib\$(LIBRARY_NAME).lib
|
||||
rm -f $(PDBFILE).pdb
|
||||
@@ -1,835 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/* 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 :-).
|
||||
|
||||
I am moderately concerned about methods to obfuscate HTML, which the
|
||||
parser can decode during execution.
|
||||
E.g. there are these dreaded data: and javascript URLs and
|
||||
base64 encoding (which I don't really understand how it alloies
|
||||
*/
|
||||
|
||||
#include "mozSanitizingSerializer.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsIDOMText.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsITextContent.h"
|
||||
#include "nsTextFragment.h"
|
||||
#include "nsParserCIID.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "plstr.h"
|
||||
//#include "nsDependentString.h"
|
||||
#include "nsIProperties.h"
|
||||
|
||||
//#define DEBUG_BenB
|
||||
|
||||
/* 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).
|
||||
*/
|
||||
|
||||
static NS_DEFINE_CID(kParserServiceCID, NS_PARSERSERVICE_CID);
|
||||
|
||||
#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()
|
||||
: mAllowedTags(30) // Just some initial buffer size
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
|
||||
mOutputString = nsnull;
|
||||
}
|
||||
|
||||
mozSanitizingHTMLSerializer::~mozSanitizingHTMLSerializer()
|
||||
{
|
||||
mAllowedTags.Enumerate(ReleaseProperties);
|
||||
}
|
||||
|
||||
//<copied 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;
|
||||
}
|
||||
//</copied>
|
||||
|
||||
NS_IMPL_ISUPPORTS4(mozSanitizingHTMLSerializer,
|
||||
nsIContentSerializer,
|
||||
nsIContentSink,
|
||||
nsIHTMLContentSink,
|
||||
mozISanitizingHTMLSerializer)
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSanitizingHTMLSerializer::Init(PRUint32 aFlags, PRUint32 dummy,
|
||||
nsIAtom* aCharSet, PRBool aIsCopying)
|
||||
{
|
||||
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)
|
||||
{
|
||||
#if DEBUG_BenB
|
||||
printf("Flush: -%s-", NS_LossyConvertUCS2toASCII(aString).get());
|
||||
#endif
|
||||
Write(aStr);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
mozSanitizingHTMLSerializer::Write(const nsAString& aString)
|
||||
{
|
||||
// printf("%s", NS_LossyConvertUCS2toASCII(aString).get());
|
||||
mOutputString->Append(aString);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSanitizingHTMLSerializer::GetPref(PRInt32 aTag, PRBool& aPref)
|
||||
{
|
||||
aPref = PR_FALSE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
mozSanitizingHTMLSerializer::GetParserService(
|
||||
nsIParserService** aParserService)
|
||||
{
|
||||
if (!mParserService) {
|
||||
nsresult rv;
|
||||
mParserService = do_GetService(kParserServiceCID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
|
||||
*aParserService = mParserService;
|
||||
NS_ADDREF(*aParserService);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true, if the id represents a container
|
||||
*/
|
||||
PRBool
|
||||
mozSanitizingHTMLSerializer::IsContainer(PRInt32 aId)
|
||||
{
|
||||
PRBool isContainer = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIParserService> parserService;
|
||||
GetParserService(getter_AddRefs(parserService));
|
||||
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?" */
|
||||
|
||||
nsresult
|
||||
mozSanitizingHTMLSerializer::GetIdForContent(nsIContent* aContent,
|
||||
PRInt32* aID)
|
||||
{
|
||||
nsCOMPtr<nsIHTMLContent> htmlcontent = do_QueryInterface(aContent);
|
||||
if (!htmlcontent) {
|
||||
*aID = eHTMLTag_unknown;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAtom> tagname;
|
||||
mContent->GetTag(*getter_AddRefs(tagname));
|
||||
if (!tagname)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIParserService> parserService;
|
||||
rv = GetParserService(getter_AddRefs(parserService));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = parserService->HTMLAtomTagToId(tagname, aID);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
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,
|
||||
PRBool aHasChildren,
|
||||
nsAString& aStr)
|
||||
{
|
||||
NS_ENSURE_ARG(aElement);
|
||||
|
||||
mContent = do_QueryInterface(aElement);
|
||||
if (!mContent) return NS_ERROR_FAILURE;
|
||||
|
||||
mOutputString = &aStr;
|
||||
|
||||
nsresult rv;
|
||||
PRInt32 id;
|
||||
rv = GetIdForContent(mContent, &id);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PRBool isContainer = IsContainer(id);
|
||||
|
||||
if (isContainer) {
|
||||
rv = DoOpenContainer(id);
|
||||
}
|
||||
else {
|
||||
nsAutoString empty;
|
||||
rv = DoAddLeaf(id, empty);
|
||||
}
|
||||
|
||||
mContent = 0;
|
||||
mOutputString = nsnull;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSanitizingHTMLSerializer::AppendElementEnd(nsIDOMElement *aElement,
|
||||
nsAString& aStr)
|
||||
{
|
||||
NS_ENSURE_ARG(aElement);
|
||||
|
||||
mContent = do_QueryInterface(aElement);
|
||||
if (!mContent) return NS_ERROR_FAILURE;
|
||||
|
||||
mOutputString = &aStr;
|
||||
|
||||
nsresult rv;
|
||||
PRInt32 id;
|
||||
rv = GetIdForContent(mContent, &id);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
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 nsIParserNode& aNode)
|
||||
{
|
||||
PRInt32 type = aNode.GetNodeType();
|
||||
const nsAString& namestr = aNode.GetText();
|
||||
nsCOMPtr<nsIAtom> name = dont_AddRef(NS_NewAtom(namestr));
|
||||
|
||||
mParserNode = NS_CONST_CAST(nsIParserNode*, &aNode);
|
||||
return DoCloseContainer(type);
|
||||
}
|
||||
|
||||
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::OpenHTML(const nsIParserNode& aNode)
|
||||
{
|
||||
return OpenContainer(aNode);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSanitizingHTMLSerializer::CloseHTML(const nsIParserNode& aNode)
|
||||
{
|
||||
return CloseContainer(aNode);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSanitizingHTMLSerializer::SetTitle(const nsString& aValue)
|
||||
{
|
||||
if (IsAllowedTag(eHTMLTag_title))
|
||||
{
|
||||
//Write(NS_LITERAL_STRING("<title>")); -- aValue already contains that
|
||||
Write(aValue);
|
||||
//Write(NS_LITERAL_STRING("</title>"));
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSanitizingHTMLSerializer::AddDocTypeDecl(const nsIParserNode& aNode)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSanitizingHTMLSerializer::SetDocumentCharset(nsAString& 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! */
|
||||
+ aCharset + NS_LITERAL_STRING("\">\n"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSanitizingHTMLSerializer::OpenHead(const nsIParserNode& aNode)
|
||||
{
|
||||
return OpenContainer(aNode);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSanitizingHTMLSerializer::CloseHead(const nsIParserNode& aNode)
|
||||
{
|
||||
return CloseContainer(aNode);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSanitizingHTMLSerializer::OpenBody(const nsIParserNode& aNode)
|
||||
{
|
||||
return OpenContainer(aNode);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSanitizingHTMLSerializer::CloseBody(const nsIParserNode& aNode)
|
||||
{
|
||||
return CloseContainer(aNode);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSanitizingHTMLSerializer::OpenForm(const nsIParserNode& aNode)
|
||||
{
|
||||
return OpenContainer(aNode);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSanitizingHTMLSerializer::CloseForm(const nsIParserNode& aNode)
|
||||
{
|
||||
return CloseContainer(aNode);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSanitizingHTMLSerializer::OpenMap(const nsIParserNode& aNode)
|
||||
{
|
||||
return OpenContainer(aNode);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSanitizingHTMLSerializer::CloseMap(const nsIParserNode& aNode)
|
||||
{
|
||||
return CloseContainer(aNode);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSanitizingHTMLSerializer::OpenFrameset(const nsIParserNode& aNode)
|
||||
{
|
||||
return OpenContainer(aNode);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSanitizingHTMLSerializer::CloseFrameset(const nsIParserNode& aNode)
|
||||
{
|
||||
return CloseContainer(aNode);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSanitizingHTMLSerializer::DoFragment(PRBool aFlag)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Here comes the actual code...
|
||||
|
||||
nsresult
|
||||
mozSanitizingHTMLSerializer::DoOpenContainer(PRInt32 aTag)
|
||||
{
|
||||
eHTMLTags type = (eHTMLTags)aTag;
|
||||
|
||||
if (IsAllowedTag(type))
|
||||
{
|
||||
nsCOMPtr<nsIParserService> parserService;
|
||||
nsresult rv = GetParserService(getter_AddRefs(parserService));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
const PRUnichar* tag_name;
|
||||
parserService->HTMLIdToStringTag(aTag, &tag_name);
|
||||
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
|
||||
Write(NS_LITERAL_STRING(" "));
|
||||
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
nsresult
|
||||
mozSanitizingHTMLSerializer::DoCloseContainer(PRInt32 aTag)
|
||||
{
|
||||
eHTMLTags type = (eHTMLTags)aTag;
|
||||
|
||||
if (IsAllowedTag(type)) {
|
||||
nsCOMPtr<nsIParserService> parserService;
|
||||
nsresult rv = GetParserService(getter_AddRefs(parserService));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
const PRUnichar* tag_name;
|
||||
parserService->HTMLIdToStringTag(aTag, &tag_name);
|
||||
NS_ENSURE_TRUE(tag_name, NS_ERROR_INVALID_POINTER);
|
||||
|
||||
Write(NS_LITERAL_STRING("</") + nsDependentString(tag_name)
|
||||
+ NS_LITERAL_STRING(">"));
|
||||
}
|
||||
else
|
||||
Write(NS_LITERAL_STRING(" "));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
mozSanitizingHTMLSerializer::DoAddLeaf(PRInt32 aTag,
|
||||
const nsAString& aText)
|
||||
{
|
||||
eHTMLTags type = (eHTMLTags)aTag;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (type == eHTMLTag_whitespace ||
|
||||
type == eHTMLTag_newline)
|
||||
{
|
||||
Write(aText);
|
||||
}
|
||||
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)
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
else if (type == eHTMLTag_entity)
|
||||
{
|
||||
Write(NS_LITERAL_STRING("&"));
|
||||
Write(aText);
|
||||
// using + operator here might give an infinitive loop, see above.
|
||||
}
|
||||
else
|
||||
{
|
||||
DoOpenContainer(type);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Similar to SanitizeAttrValue.
|
||||
*/
|
||||
nsresult
|
||||
mozSanitizingHTMLSerializer::SanitizeTextNode(nsString& aText /*inout*/)
|
||||
{
|
||||
nsString& text = aText; // alias
|
||||
|
||||
PRInt32 pos;
|
||||
if ((pos = text.Find("base64")) != kNotFound)
|
||||
// Probably useless, not sure, but perfhit
|
||||
// return NS_ERROR_ILLEGAL_VALUE; -- this is too extreme
|
||||
text.Insert(NS_LITERAL_STRING(TEXT_BREAKER), pos + 1);
|
||||
/* Insert some other text after the first char of the problematic
|
||||
text, so we prevent the processing by Gecko.
|
||||
No idea, if that is needed, but better do it than being sorry.
|
||||
Somebody who knows all the dangers and how they are reflected
|
||||
in Gecko please jump in. */
|
||||
|
||||
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 |value| 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 |value|, but output nothing.
|
||||
*/
|
||||
nsresult
|
||||
mozSanitizingHTMLSerializer::SanitizeAttrValue(nsHTMLTag aTag,
|
||||
const nsAString& attr_name,
|
||||
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. */
|
||||
nsAutoString value(Substring(aValue, 0, 1000));
|
||||
//value.Truncate(1000); //-- this cuts half of the document !!?!!
|
||||
|
||||
#ifdef DEBUG_BenB
|
||||
printf("7: %s\n", ToNewUTF8String(value));
|
||||
#endif
|
||||
|
||||
value.StripChars("\"'"); /* This will break javascript attributes,
|
||||
but who wants javascript in
|
||||
sanitized HTML? */
|
||||
|
||||
/* 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 (value.Find("javascript:") != kNotFound ||
|
||||
value.Find("data:") != kNotFound ||
|
||||
value.Find("base64") != kNotFound)
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
|
||||
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_LossyConvertUCS2toASCII(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_LossyConvertUCS2toASCII(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)
|
||||
{
|
||||
nsCOMPtr<nsIParserService> parserService;
|
||||
nsresult rv = GetParserService(getter_AddRefs(parserService));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
char* pref = ToNewCString(aPref);
|
||||
#ifdef DEBUG_BenB
|
||||
printf("pref: -%s-\n", pref);
|
||||
#endif
|
||||
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)
|
||||
{
|
||||
nsCOMPtr<nsIParserService> parserService;
|
||||
nsresult rv = GetParserService(getter_AddRefs(parserService));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// Parsing tag
|
||||
#ifdef DEBUG_BenB
|
||||
printf("Processing tag pref -%s-\n", tagpref.get());
|
||||
#endif
|
||||
PRInt32 bracket = tagpref.Find("(");
|
||||
nsCAutoString tag = tagpref;
|
||||
if (bracket != kNotFound)
|
||||
tag.Truncate(bracket);
|
||||
#ifdef DEBUG_BenB
|
||||
printf( "Tag -%s-\n", tag.get());
|
||||
#endif
|
||||
if (tag.Equals(""))
|
||||
{
|
||||
printf(" malformed pref: %s\n", tagpref.get());
|
||||
return NS_ERROR_CANNOT_CONVERT_DATA;
|
||||
}
|
||||
|
||||
// Create key
|
||||
NS_ConvertASCIItoUCS2 tag_widestr(tag);
|
||||
PRInt32 tag_id;
|
||||
parserService->HTMLStringTagToId(tag_widestr, &tag_id);
|
||||
#ifdef DEBUG_BenB
|
||||
printf(" Have tag %d\n", tag_id);
|
||||
const PRUnichar* tag_back;
|
||||
parserService->HTMLIdToStringTag(tag_id, &tag_back);
|
||||
printf(" Equals -%s-\n", tag_back
|
||||
? NS_ConvertUCS2toUTF8(tag_back).get()
|
||||
: "");
|
||||
#endif
|
||||
if (tag_id == eHTMLTag_userdefined ||
|
||||
tag_id == eHTMLTag_unknown)
|
||||
{
|
||||
printf(" unknown tag <%s>, won't add.\n", tag.get());
|
||||
return NS_ERROR_CANNOT_CONVERT_DATA;
|
||||
}
|
||||
nsPRUint32Key tag_key(tag_id);
|
||||
|
||||
if (mAllowedTags.Exists(&tag_key))
|
||||
{
|
||||
printf(" duplicate tag: %s\n", 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));
|
||||
#ifdef DEBUG_BenB
|
||||
printf(" Attr list: -%s-\n", attrList.get());
|
||||
#endif
|
||||
char* attrs_lasts;
|
||||
for (char* iAttr = PL_strtok_r(NS_CONST_CAST(char*, attrList.get()),
|
||||
",", &attrs_lasts);
|
||||
iAttr;
|
||||
iAttr = PL_strtok_r(NULL, ",", &attrs_lasts))
|
||||
{
|
||||
#ifdef DEBUG_BenB
|
||||
printf(" Processing attr -%s-\n", iAttr);
|
||||
#endif
|
||||
attr_bag->Define(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,166 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#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 "nsIDocumentEncoder.h"
|
||||
#include "nsString.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, nsIAtom* 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, PRBool aHasChildren,
|
||||
nsAString& aStr);
|
||||
NS_IMETHOD AppendElementEnd(nsIDOMElement *aElement, nsAString& aStr);
|
||||
NS_IMETHOD Flush(nsAString& aStr);
|
||||
|
||||
// nsIContentSink
|
||||
NS_IMETHOD WillBuildModel(void) { return NS_OK; }
|
||||
NS_IMETHOD DidBuildModel(PRInt32 aQualityLevel) { 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 nsIParserNode& aNode);
|
||||
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);
|
||||
NS_IMETHOD FlushPendingNotifications() { return NS_OK; }
|
||||
NS_IMETHOD SetDocumentCharset(nsAString& aCharset);
|
||||
NS_IMETHOD NotifyTagObservers(nsIParserNode* aNode) { return NS_OK; }
|
||||
|
||||
// nsIHTMLContentSink
|
||||
NS_IMETHOD OpenHTML(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseHTML(const nsIParserNode& aNode);
|
||||
NS_IMETHOD OpenHead(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseHead(const nsIParserNode& aNode);
|
||||
NS_IMETHOD SetTitle(const nsString& aValue);
|
||||
NS_IMETHOD OpenBody(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseBody(const nsIParserNode& aNode);
|
||||
NS_IMETHOD OpenForm(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseForm(const nsIParserNode& aNode);
|
||||
NS_IMETHOD OpenMap(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseMap(const nsIParserNode& aNode);
|
||||
NS_IMETHOD OpenFrameset(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseFrameset(const nsIParserNode& aNode);
|
||||
NS_IMETHOD GetPref(PRInt32 aTag,PRBool& aPref);
|
||||
NS_IMETHOD_(PRBool) IsFormOnStack() { return PR_FALSE; }
|
||||
NS_IMETHOD DoFragment(PRBool aFlag);
|
||||
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);
|
||||
nsresult GetIdForContent(nsIContent* aContent, PRInt32* aID);
|
||||
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;
|
||||
nsHashtable mAllowedTags;
|
||||
|
||||
nsCOMPtr<nsIContent> mContent;
|
||||
nsAString* mOutputString;
|
||||
nsIParserNode* mParserNode;
|
||||
nsCOMPtr<nsIParserService> mParserService;
|
||||
};
|
||||
|
||||
extern nsresult NS_NewSanitizingHTMLSerializer(
|
||||
nsIContentSerializer** aSerializer);
|
||||
|
||||
#endif
|
||||
@@ -1,183 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#include "nsIDOMComment.h"
|
||||
#include "nsGenericDOMDataNode.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
|
||||
class nsCommentNode : public nsGenericDOMDataNode,
|
||||
public nsIDOMComment
|
||||
{
|
||||
public:
|
||||
nsCommentNode();
|
||||
virtual ~nsCommentNode();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIDOMNode
|
||||
NS_IMPL_NSIDOMNODE_USING_GENERIC_DOM_DATA
|
||||
|
||||
// nsIDOMCharacterData
|
||||
NS_FORWARD_NSIDOMCHARACTERDATA(nsGenericDOMDataNode::)
|
||||
|
||||
// nsIDOMComment
|
||||
// Empty interface
|
||||
|
||||
// nsIContent
|
||||
NS_IMETHOD GetTag(nsIAtom*& aResult) const;
|
||||
|
||||
#ifdef DEBUG
|
||||
NS_IMETHOD List(FILE* out, PRInt32 aIndent) const;
|
||||
NS_IMETHOD DumpContent(FILE* out = stdout, PRInt32 aIndent = 0,
|
||||
PRBool aDumpAll = PR_TRUE) const
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
// nsITextContent
|
||||
NS_IMETHOD CloneContent(PRBool aCloneText, nsITextContent** aClone);
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewCommentNode(nsIContent** aInstancePtrResult)
|
||||
{
|
||||
*aInstancePtrResult = new nsCommentNode();
|
||||
NS_ENSURE_TRUE(*aInstancePtrResult, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
NS_ADDREF(*aInstancePtrResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCommentNode::nsCommentNode()
|
||||
{
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCommentNode::GetTag(nsIAtom*& aResult) const
|
||||
{
|
||||
aResult = nsLayoutAtoms::commentTagName;
|
||||
NS_ADDREF(aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCommentNode::GetNodeName(nsAString& aNodeName)
|
||||
{
|
||||
aNodeName.Assign(NS_LITERAL_STRING("#comment"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCommentNode::GetNodeType(PRUint16* aNodeType)
|
||||
{
|
||||
*aNodeType = (PRUint16)nsIDOMNode::COMMENT_NODE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCommentNode::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
nsCOMPtr<nsITextContent> textContent;
|
||||
nsresult rv = CloneContent(PR_TRUE, getter_AddRefs(textContent));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return CallQueryInterface(textContent, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCommentNode::CloneContent(PRBool aCloneText, nsITextContent** aReturn)
|
||||
{
|
||||
nsCommentNode* it = new nsCommentNode();
|
||||
NS_ENSURE_TRUE(it, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsCOMPtr<nsIContent> kungFuDeathGrip(it);
|
||||
|
||||
if (aCloneText) {
|
||||
it->mText = mText;
|
||||
}
|
||||
|
||||
*aReturn = it;
|
||||
NS_ADDREF(*aReturn);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
NS_IMETHODIMP
|
||||
nsCommentNode::List(FILE* out, PRInt32 aIndent) const
|
||||
{
|
||||
NS_PRECONDITION(mDocument, "bad content");
|
||||
|
||||
PRInt32 indx;
|
||||
for (indx = aIndent; --indx >= 0; ) fputs(" ", out);
|
||||
|
||||
fprintf(out, "Comment@%p refcount=%d<!--", this, mRefCnt);
|
||||
|
||||
nsAutoString tmp;
|
||||
ToCString(tmp, 0, mText.GetLength());
|
||||
fputs(NS_LossyConvertUCS2toASCII(tmp).get(), out);
|
||||
|
||||
fputs("-->\n", out);
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,132 +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"
|
||||
|
||||
class nsIDOMNode;
|
||||
class nsISelection;
|
||||
class nsITransferable;
|
||||
class nsIOverrideDragSource;
|
||||
class nsIOverrideDropSite;
|
||||
class nsIImage;
|
||||
class nsIPresShell;
|
||||
class nsIPresContext;
|
||||
class nsIImageFrame;
|
||||
class nsIContent;
|
||||
class nsIDocument;
|
||||
|
||||
|
||||
// {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:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDRAGDROPHANDLER
|
||||
|
||||
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
|
||||
NS_IMETHOD AddDragListener();
|
||||
NS_IMETHOD RemoveDragListener();
|
||||
|
||||
// utility routines
|
||||
static void FindFirstAnchor(nsIDOMNode* inNode, nsIDOMNode** outAnchor);
|
||||
static void FindParentLinkNode(nsIDOMNode* inNode, nsIDOMNode** outParent);
|
||||
static void GetAnchorURL(nsIDOMNode* inNode, nsAString& outURL);
|
||||
static void CreateLinkText(const nsAString& inURL, const nsAString & inText,
|
||||
nsAString& outLinkText);
|
||||
static void GetNodeString(nsIDOMNode* inNode, nsAString & outNodeString);
|
||||
static void NormalizeSelection(nsIDOMNode* inBaseNode, nsISelection* inSelection);
|
||||
static void GetEventDocument(nsIDOMEvent* inEvent, nsIDOMDocument** outDocument);
|
||||
static nsresult GetImageFromDOMNode(nsIDOMNode* inNode, nsIImage** outImage);
|
||||
static nsresult GetImageFrame(nsIContent* aContent, nsIDocument *aDocument, nsIPresContext *aPresContext,
|
||||
nsIPresShell *aPresShell, nsIImageFrame** aImageFrame);
|
||||
|
||||
PRBool BuildDragData(nsIDOMEvent* inMouseEvent, nsAString & outURLString, nsAString & outTitleString,
|
||||
nsAString & outHTMLString, nsIImage** outImage, PRBool* outIsAnchor);
|
||||
nsresult CreateTransferable(const nsAString & inURLString, const nsAString & inTitleString,
|
||||
const nsAString & inHTMLString, nsIImage* inImage, PRBool inIsAnchor,
|
||||
nsITransferable** outTrans);
|
||||
void ExtractURLFromData(const nsACString & inFlavor, nsISupports* inDataWrapper, PRUint32 inDataLen,
|
||||
nsAString & outURL);
|
||||
|
||||
PRPackedBool mListenerInstalled;
|
||||
|
||||
nsCOMPtr<nsIDOMEventReceiver> mEventReceiver;
|
||||
nsIWebNavigation* mNavigator; // weak ref, this is probably my owning webshell
|
||||
nsIOverrideDragSource* mOverrideDrag; // weak, these could own us but probably will outlive us
|
||||
nsIOverrideDropSite* mOverrideDrop;
|
||||
|
||||
}; // class nsContentAreaDragDrop
|
||||
|
||||
|
||||
|
||||
#endif /* nsContentAreaDragDrop_h__ */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,980 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsContentList.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOM3Node.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsGenericElement.h"
|
||||
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "nsHTMLAtoms.h" // XXX until atoms get factored into nsLayoutAtoms
|
||||
|
||||
// Form related includes
|
||||
#include "nsIDOMHTMLFormElement.h"
|
||||
#include "nsIContentList.h"
|
||||
|
||||
#include "pldhash.h"
|
||||
|
||||
nsBaseContentList::nsBaseContentList()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsBaseContentList::~nsBaseContentList()
|
||||
{
|
||||
// mElements only has weak references to the content objects so we
|
||||
// don't need to do any cleanup here.
|
||||
}
|
||||
|
||||
|
||||
// QueryInterface implementation for nsBaseContentList
|
||||
NS_INTERFACE_MAP_BEGIN(nsBaseContentList)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMNodeList)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMNodeList)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(NodeList)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(nsBaseContentList)
|
||||
NS_IMPL_RELEASE(nsBaseContentList)
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseContentList::GetLength(PRUint32* aLength)
|
||||
{
|
||||
*aLength = mElements.Count();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseContentList::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
|
||||
{
|
||||
nsISupports *tmp = NS_REINTERPRET_CAST(nsISupports *,
|
||||
mElements.SafeElementAt(aIndex));
|
||||
if (!tmp) {
|
||||
*aReturn = nsnull;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return CallQueryInterface(tmp, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseContentList::AppendElement(nsIContent *aContent)
|
||||
{
|
||||
// Shouldn't hold a reference since we'll be told when the content
|
||||
// leaves the document or the document will be destroyed.
|
||||
mElements.AppendElement(aContent);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseContentList::RemoveElement(nsIContent *aContent)
|
||||
{
|
||||
mElements.RemoveElement(aContent);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseContentList::IndexOf(nsIContent *aContent, PRInt32& aIndex)
|
||||
{
|
||||
aIndex = mElements.IndexOf(aContent);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseContentList::Reset()
|
||||
{
|
||||
mElements.Clear();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsFormContentList
|
||||
|
||||
// This helper function checks if aContent is in some way associated
|
||||
// with aForm, this check is only successful if the form is a
|
||||
// container (and a form is a container as long as the document is
|
||||
// wellformed). If the form is a container the only elements that are
|
||||
// considerd to be associated with a form are the elements that are
|
||||
// contained within the form. If the form is a leaf element then all
|
||||
// the elements will be accepted into this list.
|
||||
|
||||
static PRBool BelongsInForm(nsIDOMHTMLFormElement *aForm,
|
||||
nsIContent *aContent)
|
||||
{
|
||||
nsCOMPtr<nsIContent> form(do_QueryInterface(aForm));
|
||||
|
||||
if (!form) {
|
||||
NS_WARNING("This should not happen, form is not an nsIContent!");
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
if (form.get() == aContent) {
|
||||
// The list for aForm contains the form itself, forms should not
|
||||
// be reachable by name in the form namespace, so we return false
|
||||
// here.
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> content;
|
||||
|
||||
aContent->GetParent(*getter_AddRefs(content));
|
||||
|
||||
while (content) {
|
||||
if (content == form) {
|
||||
// aContent is contained within the form so we return true.
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
|
||||
content->GetTag(*getter_AddRefs(tag));
|
||||
|
||||
if (tag.get() == nsHTMLAtoms::form) {
|
||||
// The child is contained within a form, but not the right form
|
||||
// so we ignore it.
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsIContent *tmp = content;
|
||||
|
||||
tmp->GetParent(*getter_AddRefs(content));
|
||||
}
|
||||
|
||||
PRInt32 count = 0;
|
||||
|
||||
form->ChildCount(count);
|
||||
|
||||
if (!count) {
|
||||
// The form is a leaf and aContent wasn't inside any other form so
|
||||
// we return true
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
// The form is a container but aContent wasn't inside the form,
|
||||
// return false
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsFormContentList::nsFormContentList(nsIDOMHTMLFormElement *aForm,
|
||||
nsBaseContentList& aContentList)
|
||||
: nsBaseContentList()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
// move elements that belong to mForm into this content list
|
||||
|
||||
PRUint32 i, length = 0;
|
||||
nsCOMPtr<nsIDOMNode> item;
|
||||
|
||||
aContentList.GetLength(&length);
|
||||
|
||||
for (i = 0; i < length; i++) {
|
||||
aContentList.Item(i, getter_AddRefs(item));
|
||||
|
||||
nsCOMPtr<nsIContent> c(do_QueryInterface(item));
|
||||
|
||||
if (c && BelongsInForm(aForm, c)) {
|
||||
AppendElement(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsFormContentList::~nsFormContentList()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFormContentList::AppendElement(nsIContent *aContent)
|
||||
{
|
||||
NS_ADDREF(aContent);
|
||||
|
||||
return nsBaseContentList::AppendElement(aContent);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFormContentList::RemoveElement(nsIContent *aContent)
|
||||
{
|
||||
PRInt32 i = mElements.IndexOf(aContent);
|
||||
|
||||
if (i >= 0) {
|
||||
nsIContent *content = NS_STATIC_CAST(nsIContent *, mElements.ElementAt(i));
|
||||
|
||||
NS_RELEASE(content);
|
||||
|
||||
mElements.RemoveElementAt(i);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFormContentList::Reset()
|
||||
{
|
||||
PRInt32 i, length = mElements.Count();
|
||||
|
||||
for (i = 0; i < length; i++) {
|
||||
nsIContent *content = NS_STATIC_CAST(nsIContent *, mElements.ElementAt(i));
|
||||
|
||||
NS_RELEASE(content);
|
||||
}
|
||||
|
||||
return nsBaseContentList::Reset();
|
||||
}
|
||||
|
||||
// Hashtable for storing nsContentLists
|
||||
static PLDHashTable gContentListHashTable;
|
||||
|
||||
struct ContentListHashEntry : public PLDHashEntryHdr
|
||||
{
|
||||
nsContentList* mContentList;
|
||||
};
|
||||
|
||||
PR_STATIC_CALLBACK(const void *)
|
||||
ContentListHashtableGetKey(PLDHashTable *table, PLDHashEntryHdr *entry)
|
||||
{
|
||||
ContentListHashEntry *e = NS_STATIC_CAST(ContentListHashEntry *, entry);
|
||||
return e->mContentList->GetKey();
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(PLDHashNumber)
|
||||
ContentListHashtableHashKey(PLDHashTable *table, const void *key)
|
||||
{
|
||||
const nsContentListKey* list = NS_STATIC_CAST(const nsContentListKey *, key);
|
||||
return list->GetHash();
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(PRBool)
|
||||
ContentListHashtableMatchEntry(PLDHashTable *table,
|
||||
const PLDHashEntryHdr *entry,
|
||||
const void *key)
|
||||
{
|
||||
const ContentListHashEntry *e =
|
||||
NS_STATIC_CAST(const ContentListHashEntry *, entry);
|
||||
const nsContentListKey* list1 = e->mContentList->GetKey();
|
||||
const nsContentListKey* list2 = NS_STATIC_CAST(const nsContentListKey *, key);
|
||||
|
||||
return list1->Equals(*list2);
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_GetContentList(nsIDocument* aDocument, nsIAtom* aMatchAtom,
|
||||
PRInt32 aMatchNameSpaceId, nsIContent* aRootContent,
|
||||
nsIContentList** aInstancePtrResult)
|
||||
{
|
||||
*aInstancePtrResult = nsnull;
|
||||
nsContentList* list = nsnull;
|
||||
|
||||
static PLDHashTableOps hash_table_ops =
|
||||
{
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
ContentListHashtableGetKey,
|
||||
ContentListHashtableHashKey,
|
||||
ContentListHashtableMatchEntry,
|
||||
PL_DHashMoveEntryStub,
|
||||
PL_DHashClearEntryStub,
|
||||
PL_DHashFinalizeStub
|
||||
};
|
||||
|
||||
// Initialize the hashtable if needed.
|
||||
if (!gContentListHashTable.ops) {
|
||||
PRBool success = PL_DHashTableInit(&gContentListHashTable,
|
||||
&hash_table_ops, nsnull,
|
||||
sizeof(ContentListHashEntry),
|
||||
16);
|
||||
|
||||
if (!success) {
|
||||
gContentListHashTable.ops = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
ContentListHashEntry *entry = nsnull;
|
||||
// First we look in our hashtable. Then we create a content list if needed
|
||||
if (gContentListHashTable.ops) {
|
||||
nsContentListKey hashKey(aDocument, aMatchAtom,
|
||||
aMatchNameSpaceId, aRootContent);
|
||||
|
||||
// A PL_DHASH_ADD is equivalent to a PL_DHASH_LOOKUP for cases
|
||||
// when the entry is already in the hashtable.
|
||||
entry = NS_STATIC_CAST(ContentListHashEntry *,
|
||||
PL_DHashTableOperate(&gContentListHashTable,
|
||||
&hashKey,
|
||||
PL_DHASH_ADD));
|
||||
if (entry)
|
||||
list = entry->mContentList;
|
||||
}
|
||||
|
||||
if (!list) {
|
||||
// We need to create a ContentList and add it to our new entry, if
|
||||
// we have an entry
|
||||
list = new nsContentList(aDocument, aMatchAtom,
|
||||
aMatchNameSpaceId, aRootContent);
|
||||
if (entry) {
|
||||
if (list)
|
||||
entry->mContentList = list;
|
||||
else
|
||||
PL_DHashTableRawRemove(&gContentListHashTable, entry);
|
||||
}
|
||||
}
|
||||
|
||||
NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
*aInstancePtrResult = list;
|
||||
NS_ADDREF(*aInstancePtrResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// nsContentList implementation
|
||||
|
||||
nsContentList::nsContentList(nsIDocument *aDocument,
|
||||
nsIAtom* aMatchAtom,
|
||||
PRInt32 aMatchNameSpaceId,
|
||||
nsIContent* aRootContent)
|
||||
: nsBaseContentList(), nsContentListKey(aDocument, aMatchAtom, aMatchNameSpaceId, aRootContent)
|
||||
{
|
||||
if (nsLayoutAtoms::wildcard == mMatchAtom) {
|
||||
mMatchAll = PR_TRUE;
|
||||
}
|
||||
else {
|
||||
mMatchAll = PR_FALSE;
|
||||
}
|
||||
mFunc = nsnull;
|
||||
mData = nsnull;
|
||||
mState = LIST_DIRTY;
|
||||
Init(aDocument);
|
||||
}
|
||||
|
||||
nsContentList::nsContentList(nsIDocument *aDocument,
|
||||
nsContentListMatchFunc aFunc,
|
||||
const nsAString& aData,
|
||||
nsIContent* aRootContent)
|
||||
: nsBaseContentList(), nsContentListKey(aDocument, nsnull, kNameSpaceID_Unknown, aRootContent)
|
||||
{
|
||||
mFunc = aFunc;
|
||||
if (!aData.IsEmpty()) {
|
||||
mData = new nsString(aData);
|
||||
// If this fails, fail silently
|
||||
}
|
||||
else {
|
||||
mData = nsnull;
|
||||
}
|
||||
mMatchAtom = nsnull;
|
||||
mRootContent = aRootContent;
|
||||
mMatchAll = PR_FALSE;
|
||||
mState = LIST_DIRTY;
|
||||
Init(aDocument);
|
||||
}
|
||||
|
||||
void nsContentList::Init(nsIDocument *aDocument)
|
||||
{
|
||||
// We don't reference count the reference to the document
|
||||
// If the document goes away first, we'll be informed and we
|
||||
// can drop our reference.
|
||||
// If we go away first, we'll get rid of ourselves from the
|
||||
// document's observer list.
|
||||
mDocument = aDocument;
|
||||
if (mDocument) {
|
||||
mDocument->AddObserver(this);
|
||||
}
|
||||
}
|
||||
|
||||
nsContentList::~nsContentList()
|
||||
{
|
||||
RemoveFromHashtable();
|
||||
if (mDocument) {
|
||||
mDocument->RemoveObserver(this);
|
||||
}
|
||||
|
||||
delete mData;
|
||||
}
|
||||
|
||||
|
||||
// QueryInterface implementation for nsContentList
|
||||
NS_INTERFACE_MAP_BEGIN(nsContentList)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMHTMLCollection)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIContentList)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(HTMLCollection)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsBaseContentList)
|
||||
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsContentList, nsBaseContentList)
|
||||
NS_IMPL_RELEASE_INHERITED(nsContentList, nsBaseContentList)
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentList::GetLength(PRUint32* aLength, PRBool aDoFlush)
|
||||
{
|
||||
nsresult result = CheckDocumentExistence();
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
BringSelfUpToDate(aDoFlush);
|
||||
|
||||
*aLength = mElements.Count();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentList::Item(PRUint32 aIndex, nsIDOMNode** aReturn, PRBool aDoFlush)
|
||||
{
|
||||
nsresult result = CheckDocumentExistence();
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
if (mDocument && aDoFlush) {
|
||||
// Flush pending content changes Bug 4891
|
||||
mDocument->FlushPendingNotifications(PR_FALSE);
|
||||
}
|
||||
|
||||
if (mState != LIST_UP_TO_DATE)
|
||||
PopulateSelf(aIndex+1);
|
||||
|
||||
NS_ASSERTION(!mDocument || mState != LIST_DIRTY,
|
||||
"PopulateSelf left the list in a dirty (useless) state!");
|
||||
|
||||
nsIContent *element = NS_STATIC_CAST(nsIContent *,
|
||||
mElements.SafeElementAt(aIndex));
|
||||
|
||||
if (element) {
|
||||
result = CallQueryInterface(element, aReturn);
|
||||
}
|
||||
else {
|
||||
*aReturn = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentList::NamedItem(const nsAString& aName, nsIDOMNode** aReturn, PRBool aDoFlush)
|
||||
{
|
||||
nsresult result = CheckDocumentExistence();
|
||||
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
BringSelfUpToDate(aDoFlush);
|
||||
|
||||
PRInt32 i, count = mElements.Count();
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
nsIContent *content = NS_STATIC_CAST(nsIContent *,
|
||||
mElements.ElementAt(i));
|
||||
if (content) {
|
||||
nsAutoString name;
|
||||
// XXX Should it be an EqualsIgnoreCase?
|
||||
if (((content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::name,
|
||||
name) == NS_CONTENT_ATTR_HAS_VALUE) &&
|
||||
aName.Equals(name)) ||
|
||||
((content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::id,
|
||||
name) == NS_CONTENT_ATTR_HAS_VALUE) &&
|
||||
aName.Equals(name))) {
|
||||
return CallQueryInterface(content, aReturn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*aReturn = nsnull;
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentList::IndexOf(nsIContent *aContent, PRInt32& aIndex, PRBool aDoFlush)
|
||||
{
|
||||
nsresult result = CheckDocumentExistence();
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
BringSelfUpToDate(aDoFlush);
|
||||
|
||||
aIndex = mElements.IndexOf(aContent);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentList::GetLength(PRUint32* aLength)
|
||||
{
|
||||
return GetLength(aLength, PR_TRUE);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentList::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
|
||||
{
|
||||
return Item(aIndex, aReturn, PR_TRUE);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentList::NamedItem(const nsAString& aName, nsIDOMNode** aReturn)
|
||||
{
|
||||
return NamedItem(aName, aReturn, PR_TRUE);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentList::ContentAppended(nsIDocument *aDocument, nsIContent* aContainer,
|
||||
PRInt32 aNewIndexInContainer)
|
||||
{
|
||||
/*
|
||||
* If the state is LIST_DIRTY then we have no useful information in
|
||||
* our list and we want to put off doing work as much as possible.
|
||||
*/
|
||||
if (mState == LIST_DIRTY)
|
||||
return NS_OK;
|
||||
|
||||
PRInt32 count;
|
||||
aContainer->ChildCount(count);
|
||||
|
||||
/*
|
||||
* We want to handle the case of ContentAppended by sometimes
|
||||
* appending the content to our list, not just setting state to
|
||||
* LIST_DIRTY, since most of our ContentAppended notifications
|
||||
* should come during pageload and be at the end of the document.
|
||||
* Do a bit of work to see whether we could just append to what we
|
||||
* already have.
|
||||
*/
|
||||
|
||||
if ((count > 0) && IsDescendantOfRoot(aContainer)) {
|
||||
PRInt32 ourCount = mElements.Count();
|
||||
PRBool appendToList = PR_FALSE;
|
||||
if (ourCount == 0) {
|
||||
appendToList = PR_TRUE;
|
||||
} else {
|
||||
nsIContent* ourLastContent =
|
||||
NS_STATIC_CAST(nsIContent*, mElements.ElementAt(ourCount - 1));
|
||||
/*
|
||||
* We want to append instead of invalidating in two cases:
|
||||
* 1) aContainer is an ancestor of ourLastContent (this case
|
||||
covers aContainer == ourLastContent)
|
||||
* 2) aContainer comes after ourLastContent in document order
|
||||
*/
|
||||
if (nsContentUtils::ContentIsDescendantOf(ourLastContent, aContainer)) {
|
||||
appendToList = PR_TRUE;
|
||||
} else {
|
||||
nsCOMPtr<nsIDOM3Node> ourLastDOM3Node(do_QueryInterface(ourLastContent));
|
||||
nsCOMPtr<nsIDOMNode> newNodeContainer(do_QueryInterface(aContainer));
|
||||
if (ourLastDOM3Node && newNodeContainer) {
|
||||
PRUint16 comparisonFlags;
|
||||
nsresult rv = ourLastDOM3Node->CompareTreePosition(newNodeContainer,
|
||||
&comparisonFlags);
|
||||
if (NS_SUCCEEDED(rv) &&
|
||||
(comparisonFlags & nsIDOMNode::TREE_POSITION_FOLLOWING)) {
|
||||
appendToList = PR_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PRInt32 i;
|
||||
|
||||
if (!appendToList) {
|
||||
// The new stuff is somewhere in the middle of our list; check
|
||||
// whether we need to invalidate
|
||||
nsCOMPtr<nsIContent> content;
|
||||
for (i = aNewIndexInContainer; i <= count-1; ++i) {
|
||||
aContainer->ChildAt(i, *getter_AddRefs(content));
|
||||
if (MatchSelf(content)) {
|
||||
// Uh-oh. We're gonna have to add elements into the middle
|
||||
// of our list. That's not worth the effort.
|
||||
mState = LIST_DIRTY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* At this point we know we could append. If we're not up to
|
||||
* date, however, that would be a bad idea -- it could miss some
|
||||
* content that we never picked up due to being lazy. Further, we
|
||||
* may never get asked for this content... so don't grab it yet.
|
||||
*/
|
||||
if (mState == LIST_LAZY) // be lazy
|
||||
return NS_OK;
|
||||
|
||||
/*
|
||||
* We're up to date. That means someone's actively using us; we
|
||||
* may as well grab this content....
|
||||
*/
|
||||
nsCOMPtr<nsIContent> content;
|
||||
for (i = aNewIndexInContainer; i <= count-1; ++i) {
|
||||
aContainer->ChildAt(i, *getter_AddRefs(content));
|
||||
PRUint32 limit = PRUint32(-1);
|
||||
PopulateWith(content, PR_TRUE, limit);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentList::ContentInserted(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
{
|
||||
if (mState == LIST_DIRTY)
|
||||
return NS_OK;
|
||||
|
||||
if (IsDescendantOfRoot(aContainer) && MatchSelf(aChild))
|
||||
mState = LIST_DIRTY;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentList::ContentReplaced(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aOldChild,
|
||||
nsIContent* aNewChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
{
|
||||
if (mState == LIST_DIRTY)
|
||||
return NS_OK;
|
||||
|
||||
if (IsDescendantOfRoot(aContainer)) {
|
||||
if (MatchSelf(aOldChild) || MatchSelf(aNewChild)) {
|
||||
mState = LIST_DIRTY;
|
||||
}
|
||||
}
|
||||
else if (ContainsRoot(aOldChild)) {
|
||||
DisconnectFromDocument();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentList::ContentRemoved(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer)
|
||||
{
|
||||
if (IsDescendantOfRoot(aContainer)) {
|
||||
if (MatchSelf(aChild)) {
|
||||
mState = LIST_DIRTY;
|
||||
}
|
||||
}
|
||||
else if (ContainsRoot(aChild)) {
|
||||
DisconnectFromDocument();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentList::DocumentWillBeDestroyed(nsIDocument *aDocument)
|
||||
{
|
||||
DisconnectFromDocument();
|
||||
Reset();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsContentList::Match(nsIContent *aContent)
|
||||
{
|
||||
if (!aContent)
|
||||
return PR_FALSE;
|
||||
|
||||
if (mMatchAtom) {
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
aContent->GetNodeInfo(*getter_AddRefs(ni));
|
||||
|
||||
if (!ni)
|
||||
return PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(aContent));
|
||||
|
||||
if (!node)
|
||||
return PR_FALSE;
|
||||
|
||||
PRUint16 type;
|
||||
node->GetNodeType(&type);
|
||||
|
||||
if (type != nsIDOMNode::ELEMENT_NODE)
|
||||
return PR_FALSE;
|
||||
|
||||
if (mMatchNameSpaceId == kNameSpaceID_Unknown) {
|
||||
return (mMatchAll || ni->Equals(mMatchAtom));
|
||||
}
|
||||
|
||||
return ((mMatchAll && ni->NamespaceEquals(mMatchNameSpaceId)) ||
|
||||
ni->Equals(mMatchAtom, mMatchNameSpaceId));
|
||||
}
|
||||
else if (mFunc) {
|
||||
return (*mFunc)(aContent, mData);
|
||||
}
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsContentList::CheckDocumentExistence()
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
if (!mDocument && mRootContent) {
|
||||
result = mRootContent->GetDocument(mDocument);
|
||||
if (mDocument) {
|
||||
mDocument->AddObserver(this);
|
||||
mState = LIST_DIRTY;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsContentList::MatchSelf(nsIContent *aContent)
|
||||
{
|
||||
|
||||
if (Match(aContent))
|
||||
return PR_TRUE;
|
||||
|
||||
PRInt32 i, count = -1;
|
||||
|
||||
aContent->ChildCount(count);
|
||||
nsCOMPtr<nsIContent> child;
|
||||
for (i = 0; i < count; i++) {
|
||||
aContent->ChildAt(i, *getter_AddRefs(child));
|
||||
if (MatchSelf(child)) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
nsContentList::PopulateWith(nsIContent *aContent, PRBool aIncludeRoot,
|
||||
PRUint32 & aElementsToAppend)
|
||||
{
|
||||
if (aIncludeRoot) {
|
||||
if (Match(aContent)) {
|
||||
mElements.AppendElement(aContent);
|
||||
--aElementsToAppend;
|
||||
if (aElementsToAppend == 0)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
PRInt32 i, count;
|
||||
aContent->ChildCount(count);
|
||||
nsCOMPtr<nsIContent> child;
|
||||
for (i = 0; i < count; i++) {
|
||||
aContent->ChildAt(i, *getter_AddRefs(child));
|
||||
PopulateWith(child, PR_TRUE, aElementsToAppend);
|
||||
if (aElementsToAppend == 0)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsContentList::PopulateWithStartingAfter(nsIContent *aStartRoot,
|
||||
nsIContent *aStartChild,
|
||||
PRUint32 & aElementsToAppend)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
PRUint32 invariant = aElementsToAppend + mElements.Count();
|
||||
#endif
|
||||
PRInt32 i = 0;
|
||||
if (aStartChild) {
|
||||
aStartRoot->IndexOf(aStartChild, i);
|
||||
NS_ASSERTION(i >= 0, "The start child must be a child of the start root!");
|
||||
++i; // move to one past
|
||||
}
|
||||
|
||||
PRInt32 childCount;
|
||||
aStartRoot->ChildCount(childCount);
|
||||
nsCOMPtr<nsIContent> child;
|
||||
for ( ; i < childCount; ++i) {
|
||||
aStartRoot->ChildAt(i, *getter_AddRefs(child));
|
||||
PopulateWith(child, PR_TRUE, aElementsToAppend);
|
||||
NS_ASSERTION(aElementsToAppend + mElements.Count() == invariant,
|
||||
"Something is awry in PopulateWith!");
|
||||
if (aElementsToAppend == 0)
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> parent;
|
||||
aStartRoot->GetParent(*getter_AddRefs(parent));
|
||||
|
||||
if (parent)
|
||||
PopulateWithStartingAfter(parent, aStartRoot, aElementsToAppend);
|
||||
}
|
||||
|
||||
void
|
||||
nsContentList::PopulateSelf(PRUint32 aNeededLength)
|
||||
{
|
||||
if (mState == LIST_DIRTY) {
|
||||
Reset();
|
||||
}
|
||||
PRUint32 count = mElements.Count();
|
||||
|
||||
if (count >= aNeededLength) // We're all set
|
||||
return;
|
||||
|
||||
PRUint32 elementsToAppend = aNeededLength - count;
|
||||
#ifdef DEBUG
|
||||
PRUint32 invariant = elementsToAppend + mElements.Count();
|
||||
#endif
|
||||
if (count != 0) {
|
||||
PopulateWithStartingAfter(NS_STATIC_CAST(nsIContent*,
|
||||
mElements.ElementAt(count - 1)),
|
||||
nsnull,
|
||||
elementsToAppend);
|
||||
NS_ASSERTION(elementsToAppend + mElements.Count() == invariant,
|
||||
"Something is awry in PopulateWithStartingAfter!");
|
||||
} else if (mRootContent) {
|
||||
PopulateWith(mRootContent, PR_FALSE, elementsToAppend);
|
||||
NS_ASSERTION(elementsToAppend + mElements.Count() == invariant,
|
||||
"Something is awry in PopulateWith!");
|
||||
}
|
||||
else if (mDocument) {
|
||||
nsCOMPtr<nsIContent> root;
|
||||
mDocument->GetRootContent(getter_AddRefs(root));
|
||||
if (root) {
|
||||
PopulateWith(root, PR_TRUE, elementsToAppend);
|
||||
NS_ASSERTION(elementsToAppend + mElements.Count() == invariant,
|
||||
"Something is awry in PopulateWith!");
|
||||
}
|
||||
}
|
||||
|
||||
if (mDocument) {
|
||||
if (elementsToAppend != 0)
|
||||
mState = LIST_UP_TO_DATE;
|
||||
else
|
||||
mState = LIST_LAZY;
|
||||
} else {
|
||||
// No document means we have to stay on our toes since we don't
|
||||
// get content notifications.
|
||||
mState = LIST_DIRTY;
|
||||
}
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsContentList::IsDescendantOfRoot(nsIContent* aContainer)
|
||||
{
|
||||
if (!mRootContent) {
|
||||
#ifdef DEBUG
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
aContainer->GetDocument(*getter_AddRefs(doc));
|
||||
NS_ASSERTION(doc == mDocument, "We should not get in here if aContainer is appended to some _other_ document!");
|
||||
#endif
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
if (!aContainer) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
return nsContentUtils::ContentIsDescendantOf(aContainer, mRootContent);
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsContentList::ContainsRoot(nsIContent* aContent)
|
||||
{
|
||||
if (!mRootContent || !aContent) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
return nsContentUtils::ContentIsDescendantOf(mRootContent, aContent);
|
||||
}
|
||||
|
||||
void
|
||||
nsContentList::DisconnectFromDocument()
|
||||
{
|
||||
if (mDocument) {
|
||||
// Our key will change... Best remove ourselves before that happens.
|
||||
RemoveFromHashtable();
|
||||
mDocument->RemoveObserver(this);
|
||||
mDocument = nsnull;
|
||||
}
|
||||
|
||||
// We will get no more updates, so we can never know we're up to
|
||||
// date
|
||||
mState = LIST_DIRTY;
|
||||
}
|
||||
|
||||
void
|
||||
nsContentList::RemoveFromHashtable()
|
||||
{
|
||||
if (!gContentListHashTable.ops)
|
||||
return;
|
||||
|
||||
PL_DHashTableOperate(&gContentListHashTable,
|
||||
GetKey(),
|
||||
PL_DHASH_REMOVE);
|
||||
|
||||
if (gContentListHashTable.entryCount == 0) {
|
||||
PL_DHashTableFinish(&gContentListHashTable);
|
||||
gContentListHashTable.ops = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsContentList::BringSelfUpToDate(PRBool aDoFlush)
|
||||
{
|
||||
if (mDocument && aDoFlush) {
|
||||
mDocument->FlushPendingNotifications(PR_FALSE); // Flush pending content changes Bug 4891
|
||||
}
|
||||
|
||||
if (mState != LIST_UP_TO_DATE)
|
||||
PopulateSelf(PRUint32(-1));
|
||||
|
||||
NS_ASSERTION(!mDocument || mState == LIST_UP_TO_DATE,
|
||||
"PopulateSelf dod not bring content list up to date!");
|
||||
}
|
||||
@@ -1,379 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsContentList_h___
|
||||
#define nsContentList_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMHTMLCollection.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIDocumentObserver.h"
|
||||
#include "nsIContentList.h"
|
||||
|
||||
typedef PRBool (*nsContentListMatchFunc)(nsIContent* aContent,
|
||||
nsString* aData);
|
||||
|
||||
class nsIDocument;
|
||||
class nsIDOMHTMLFormElement;
|
||||
|
||||
|
||||
class nsBaseContentList : public nsIDOMNodeList
|
||||
{
|
||||
public:
|
||||
nsBaseContentList();
|
||||
virtual ~nsBaseContentList();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMNodeList
|
||||
NS_DECL_NSIDOMNODELIST
|
||||
|
||||
NS_IMETHOD AppendElement(nsIContent *aContent);
|
||||
NS_IMETHOD RemoveElement(nsIContent *aContent);
|
||||
NS_IMETHOD IndexOf(nsIContent *aContent, PRInt32& aIndex);
|
||||
NS_IMETHOD Reset();
|
||||
|
||||
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();
|
||||
|
||||
NS_IMETHOD AppendElement(nsIContent *aContent);
|
||||
NS_IMETHOD RemoveElement(nsIContent *aContent);
|
||||
|
||||
NS_IMETHOD 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)?
|
||||
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 nsIDocumentObserver,
|
||||
public nsIContentList
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
nsContentList(nsIDocument *aDocument,
|
||||
nsIAtom* aMatchAtom,
|
||||
PRInt32 aMatchNameSpaceId,
|
||||
nsIContent* aRootContent=nsnull);
|
||||
nsContentList(nsIDocument *aDocument,
|
||||
nsContentListMatchFunc aFunc,
|
||||
const nsAString& aData,
|
||||
nsIContent* aRootContent=nsnull);
|
||||
virtual ~nsContentList();
|
||||
|
||||
// nsIDOMHTMLCollection
|
||||
NS_IMETHOD GetLength(PRUint32* aLength);
|
||||
NS_IMETHOD Item(PRUint32 aIndex, nsIDOMNode** aReturn);
|
||||
NS_IMETHOD NamedItem(const nsAString& aName, nsIDOMNode** aReturn);
|
||||
|
||||
/// nsIContentList
|
||||
NS_IMETHOD GetLength(PRUint32* aLength, PRBool aDoFlush);
|
||||
NS_IMETHOD Item(PRUint32 aIndex, nsIDOMNode** aReturn,
|
||||
PRBool aDoFlush);
|
||||
NS_IMETHOD NamedItem(const nsAString& aName, nsIDOMNode** aReturn,
|
||||
PRBool aDoFlush);
|
||||
NS_IMETHOD IndexOf(nsIContent *aContent, PRInt32& aIndex,
|
||||
PRBool aDoFlush);
|
||||
|
||||
// nsIDocumentObserver
|
||||
NS_IMETHOD BeginUpdate(nsIDocument *aDocument) { return NS_OK; }
|
||||
NS_IMETHOD EndUpdate(nsIDocument *aDocument) { return NS_OK; }
|
||||
NS_IMETHOD BeginLoad(nsIDocument *aDocument) { return NS_OK; }
|
||||
NS_IMETHOD EndLoad(nsIDocument *aDocument) { return NS_OK; }
|
||||
NS_IMETHOD BeginReflow(nsIDocument *aDocument,
|
||||
nsIPresShell* aShell) { return NS_OK; }
|
||||
NS_IMETHOD EndReflow(nsIDocument *aDocument,
|
||||
nsIPresShell* aShell) { return NS_OK; }
|
||||
NS_IMETHOD ContentChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
nsISupports* aSubContent) { return NS_OK; }
|
||||
NS_IMETHOD ContentStatesChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2,
|
||||
PRInt32 aStateMask) { return NS_OK; }
|
||||
NS_IMETHOD AttributeChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aModType,
|
||||
PRInt32 aHint) { return NS_OK; }
|
||||
NS_IMETHOD ContentAppended(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
PRInt32 aNewIndexInContainer);
|
||||
NS_IMETHOD ContentInserted(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer);
|
||||
NS_IMETHOD ContentReplaced(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aOldChild,
|
||||
nsIContent* aNewChild,
|
||||
PRInt32 aIndexInContainer);
|
||||
NS_IMETHOD ContentRemoved(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer);
|
||||
NS_IMETHOD StyleSheetAdded(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet) { return NS_OK; }
|
||||
NS_IMETHOD StyleSheetRemoved(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet) { return NS_OK; }
|
||||
NS_IMETHOD StyleSheetDisabledStateChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
PRBool aDisabled) { return NS_OK; }
|
||||
NS_IMETHOD StyleRuleChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule,
|
||||
PRInt32 aHint) { return NS_OK; }
|
||||
NS_IMETHOD StyleRuleAdded(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule) { return NS_OK; }
|
||||
NS_IMETHOD StyleRuleRemoved(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule) { return NS_OK; }
|
||||
NS_IMETHOD DocumentWillBeDestroyed(nsIDocument *aDocument);
|
||||
|
||||
// Other public methods
|
||||
nsContentListKey* GetKey() {
|
||||
return NS_STATIC_CAST(nsContentListKey*, this);
|
||||
}
|
||||
|
||||
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,
|
||||
* PR_FALSE otherwise
|
||||
*/
|
||||
PRBool IsDescendantOfRoot(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.
|
||||
*/
|
||||
nsresult CheckDocumentExistence();
|
||||
void RemoveFromHashtable();
|
||||
inline void BringSelfUpToDate(PRBool aDoFlush);
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
nsString* 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;
|
||||
};
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
||||
extern nsresult
|
||||
NS_GetContentList(nsIDocument* aDocument, nsIAtom* aMatchAtom,
|
||||
PRInt32 aMatchNameSpaceId, nsIContent* aRootContent,
|
||||
nsIContentList** aInstancePtrResult);
|
||||
|
||||
#endif // nsContentList_h___
|
||||
@@ -1,177 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* 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 Zero-Knowledge are Copyright (C) 2000
|
||||
* Zero-Knowledge Systems, Inc. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsContentPolicyUtils.h"
|
||||
#include "nsContentPolicy.h"
|
||||
#include "nsICategoryManager.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsContentPolicy, nsIContentPolicy)
|
||||
|
||||
nsresult
|
||||
NS_NewContentPolicy(nsIContentPolicy **aResult)
|
||||
{
|
||||
*aResult = new nsContentPolicy;
|
||||
if (!*aResult)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* This constructor does far too much. I wish there was a way to get
|
||||
* an Init method called by the service manager after the factory
|
||||
* returned the new object, so that errors could be propagated back to
|
||||
* the caller correctly.
|
||||
*/
|
||||
nsContentPolicy::nsContentPolicy()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICategoryManager> catman =
|
||||
do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
/* log an error? */
|
||||
return;
|
||||
|
||||
/*
|
||||
* I'd like to use GetCategoryContents, so that I can size the array
|
||||
* correctly on the first go and avoid the enumerator overhead, but it's
|
||||
* not yet implemented (see nsCategoryManager.cpp). No biggie, I guess.
|
||||
*/
|
||||
nsCOMPtr<nsISimpleEnumerator> catEnum;
|
||||
if (NS_FAILED(catman->EnumerateCategory(NS_CONTENTPOLICY_CATEGORY,
|
||||
getter_AddRefs(catEnum)))) {
|
||||
/* no category, no problem */
|
||||
return;
|
||||
}
|
||||
|
||||
PRBool hasMore;
|
||||
if (NS_FAILED(catEnum->HasMoreElements(&hasMore)) || !hasMore ||
|
||||
NS_FAILED(NS_NewISupportsArray(getter_AddRefs(mPolicies)))) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Populate mPolicies with policy services named by contractids in the
|
||||
* "content-policy" category.
|
||||
*/
|
||||
nsCOMPtr<nsISupports> item;
|
||||
while (NS_SUCCEEDED(catEnum->GetNext(getter_AddRefs(item)))) {
|
||||
nsCOMPtr<nsISupportsString> string = do_QueryInterface(item, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
continue;
|
||||
|
||||
nsXPIDLCString contractid;
|
||||
if (NS_FAILED(string->GetData(getter_Copies(contractid))))
|
||||
continue;
|
||||
|
||||
#ifdef DEBUG_shaver
|
||||
fprintf(stderr, "POLICY: loading %s\n", (const char *)contractid);
|
||||
#endif
|
||||
/*
|
||||
* Create this policy service and add to mPolicies.
|
||||
*
|
||||
* Should we try to parse as a CID, in case the component prefers to be
|
||||
* registered that way?
|
||||
*/
|
||||
nsCOMPtr<nsISupports> policy = do_GetService(contractid, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
mPolicies->AppendElement(policy);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
nsContentPolicy::~nsContentPolicy()
|
||||
{
|
||||
}
|
||||
|
||||
#define POLICY_LOAD (PRInt32)0
|
||||
#define POLICY_PROCESS (PRInt32)1
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentPolicy::CheckPolicy(PRInt32 policyType, PRInt32 contentType,
|
||||
nsIURI *contentLocation, nsISupports *context,
|
||||
nsIDOMWindow *window, PRBool *shouldProceed)
|
||||
{
|
||||
*shouldProceed = PR_TRUE;
|
||||
if (!mPolicies)
|
||||
return NS_OK;
|
||||
|
||||
/*
|
||||
* Enumerate mPolicies and ask each of them, taking the logical AND of
|
||||
* their permissions.
|
||||
*/
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIContentPolicy> policy;
|
||||
PRUint32 count;
|
||||
if (NS_FAILED(rv = mPolicies->Count(&count)))
|
||||
return NS_OK;
|
||||
|
||||
for (PRUint32 i = 0; i < count; i++) {
|
||||
rv = mPolicies->QueryElementAt(i, NS_GET_IID(nsIContentPolicy),
|
||||
getter_AddRefs(policy));
|
||||
if (NS_FAILED(rv))
|
||||
continue;
|
||||
|
||||
/* check the appropriate policy */
|
||||
if (policyType == POLICY_LOAD) {
|
||||
rv = policy->ShouldLoad(contentType, contentLocation, context,
|
||||
window, shouldProceed);
|
||||
} else {
|
||||
rv = policy->ShouldProcess(contentType, contentLocation, context,
|
||||
window, shouldProceed);
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv) && !*shouldProceed)
|
||||
/* policy says no, no point continuing to check */
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* One of the policy objects might be misbehaving and setting shouldProceed
|
||||
* to PR_FALSE before returning an error, so force it back to PR_TRUE
|
||||
* here.
|
||||
*/
|
||||
*shouldProceed = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentPolicy::ShouldLoad(PRInt32 contentType, nsIURI *contentLocation,
|
||||
nsISupports *context, nsIDOMWindow *window,
|
||||
PRBool *shouldLoad)
|
||||
{
|
||||
return CheckPolicy(POLICY_LOAD, contentType, contentLocation, context,
|
||||
window, shouldLoad);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentPolicy::ShouldProcess(PRInt32 contentType, nsIURI *contentLocation,
|
||||
nsISupports *context, nsIDOMWindow *window,
|
||||
PRBool *shouldProcess)
|
||||
{
|
||||
return CheckPolicy(POLICY_PROCESS, contentType, contentLocation, context,
|
||||
window, shouldProcess);
|
||||
}
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* 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 Zero-Knowledge are Copyright (C) 2000
|
||||
* Zero-Knowledge Systems, Inc. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsIContentPolicy.h"
|
||||
#include "nsISupportsArray.h"
|
||||
|
||||
#ifndef __nsContentPolicy_h__
|
||||
#define __nsContentPolicy_h__
|
||||
|
||||
class nsContentPolicy : public nsIContentPolicy
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSICONTENTPOLICY
|
||||
nsContentPolicy();
|
||||
virtual ~nsContentPolicy();
|
||||
private:
|
||||
nsCOMPtr<nsISupportsArray> mPolicies;
|
||||
NS_IMETHOD CheckPolicy(PRInt32 policyType, PRInt32 contentType,
|
||||
nsIURI *aURI, nsISupports *context,
|
||||
nsIDOMWindow *window, PRBool *shouldProceed);
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewContentPolicy(nsIContentPolicy **aResult);
|
||||
|
||||
#endif /* __nsContentPolicy_h__ */
|
||||
@@ -1,813 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Johnny Stenback <jst@netscape.com>
|
||||
* Christopher A. Aillon <christopher@aillon.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* terms of the GNU Public License (the "GPL"), in which case the
|
||||
* provisions of the GPL are applicable instead of those above.
|
||||
* If you wish to allow use of your version of this file only
|
||||
* under the terms of the GPL and not to allow others to use your
|
||||
* version of this file under the NPL, indicate your decision by
|
||||
* deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this
|
||||
* file under either the NPL or the GPL.
|
||||
*/
|
||||
|
||||
/* A namespace class for static layout utilities. */
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIDOMScriptObjectFactory.h"
|
||||
#include "nsDOMCID.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsINodeInfo.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
|
||||
static const char *sJSStackContractID = "@mozilla.org/js/xpc/ContextStack;1";
|
||||
|
||||
nsIDOMScriptObjectFactory *nsContentUtils::sDOMScriptObjectFactory = nsnull;
|
||||
nsIXPConnect *nsContentUtils::sXPConnect = nsnull;
|
||||
|
||||
// static
|
||||
nsresult
|
||||
nsContentUtils::Init()
|
||||
{
|
||||
NS_ENSURE_TRUE(!sXPConnect, NS_ERROR_ALREADY_INITIALIZED);
|
||||
|
||||
nsresult rv = nsServiceManager::GetService(nsIXPConnect::GetCID(),
|
||||
nsIXPConnect::GetIID(),
|
||||
(nsISupports **)&sXPConnect);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
// static
|
||||
nsresult
|
||||
nsContentUtils::GetStaticScriptGlobal(JSContext* aContext, JSObject* aObj,
|
||||
nsIScriptGlobalObject** aNativeGlobal)
|
||||
{
|
||||
if (!sXPConnect) {
|
||||
*aNativeGlobal = nsnull;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
JSObject* parent;
|
||||
JSObject* glob = aObj; // starting point for search
|
||||
|
||||
if (!glob)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
while (nsnull != (parent = JS_GetParent(aContext, glob))) {
|
||||
glob = parent;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIXPConnectWrappedNative> wrapped_native;
|
||||
|
||||
nsresult rv =
|
||||
sXPConnect->GetWrappedNativeOfJSObject(aContext, glob,
|
||||
getter_AddRefs(wrapped_native));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsISupports> native;
|
||||
rv = wrapped_native->GetNative(getter_AddRefs(native));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return CallQueryInterface(native, aNativeGlobal);
|
||||
}
|
||||
|
||||
//static
|
||||
nsresult
|
||||
nsContentUtils::GetStaticScriptContext(JSContext* aContext,
|
||||
JSObject* aObj,
|
||||
nsIScriptContext** aScriptContext)
|
||||
{
|
||||
nsCOMPtr<nsIScriptGlobalObject> nativeGlobal;
|
||||
GetStaticScriptGlobal(aContext, aObj, getter_AddRefs(nativeGlobal));
|
||||
if (!nativeGlobal)
|
||||
return NS_ERROR_FAILURE;
|
||||
nsIScriptContext* scriptContext = nsnull;
|
||||
nativeGlobal->GetContext(&scriptContext);
|
||||
*aScriptContext = scriptContext;
|
||||
return scriptContext ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
//static
|
||||
nsresult
|
||||
nsContentUtils::GetDynamicScriptGlobal(JSContext* aContext,
|
||||
nsIScriptGlobalObject** aNativeGlobal)
|
||||
{
|
||||
nsCOMPtr<nsIScriptContext> scriptCX;
|
||||
GetDynamicScriptContext(aContext, getter_AddRefs(scriptCX));
|
||||
if (!scriptCX) {
|
||||
*aNativeGlobal = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return scriptCX->GetGlobalObject(aNativeGlobal);
|
||||
}
|
||||
|
||||
//static
|
||||
nsresult
|
||||
nsContentUtils::GetDynamicScriptContext(JSContext *aContext,
|
||||
nsIScriptContext** aScriptContext)
|
||||
{
|
||||
*aScriptContext = nsnull;
|
||||
|
||||
// XXX We rely on the rule that if any JSContext in our JSRuntime has a
|
||||
// private set then that private *must* be a pointer to an nsISupports.
|
||||
nsISupports *supports = (nsIScriptContext*)JS_GetContextPrivate(aContext);
|
||||
if (!supports) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return CallQueryInterface(supports, aScriptContext);
|
||||
}
|
||||
|
||||
template <class OutputIterator>
|
||||
struct NormalizeNewlinesCharTraits {
|
||||
public:
|
||||
typedef typename OutputIterator::value_type value_type;
|
||||
|
||||
public:
|
||||
NormalizeNewlinesCharTraits(OutputIterator& aIterator) : mIterator(aIterator) { }
|
||||
void writechar(typename OutputIterator::value_type aChar) {
|
||||
*mIterator++ = aChar;
|
||||
}
|
||||
|
||||
private:
|
||||
OutputIterator mIterator;
|
||||
};
|
||||
|
||||
#ifdef HAVE_CPP_PARTIAL_SPECIALIZATION
|
||||
|
||||
template <class CharT>
|
||||
struct NormalizeNewlinesCharTraits<CharT*> {
|
||||
public:
|
||||
typedef CharT value_type;
|
||||
|
||||
public:
|
||||
NormalizeNewlinesCharTraits(CharT* aCharPtr) : mCharPtr(aCharPtr) { }
|
||||
void writechar(CharT aChar) {
|
||||
*mCharPtr++ = aChar;
|
||||
}
|
||||
|
||||
private:
|
||||
CharT* mCharPtr;
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
NS_SPECIALIZE_TEMPLATE
|
||||
struct NormalizeNewlinesCharTraits<char*> {
|
||||
public:
|
||||
typedef char value_type;
|
||||
|
||||
public:
|
||||
NormalizeNewlinesCharTraits(char* aCharPtr) : mCharPtr(aCharPtr) { }
|
||||
void writechar(char aChar) {
|
||||
*mCharPtr++ = aChar;
|
||||
}
|
||||
|
||||
private:
|
||||
char* mCharPtr;
|
||||
};
|
||||
|
||||
NS_SPECIALIZE_TEMPLATE
|
||||
struct NormalizeNewlinesCharTraits<PRUnichar*> {
|
||||
public:
|
||||
typedef PRUnichar value_type;
|
||||
|
||||
public:
|
||||
NormalizeNewlinesCharTraits(PRUnichar* aCharPtr) : mCharPtr(aCharPtr) { }
|
||||
void writechar(PRUnichar aChar) {
|
||||
*mCharPtr++ = aChar;
|
||||
}
|
||||
|
||||
private:
|
||||
PRUnichar* mCharPtr;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
template <class OutputIterator>
|
||||
class CopyNormalizeNewlines
|
||||
{
|
||||
public:
|
||||
typedef typename OutputIterator::value_type value_type;
|
||||
|
||||
public:
|
||||
CopyNormalizeNewlines(OutputIterator* aDestination,PRBool aLastCharCR=PR_FALSE) :
|
||||
mLastCharCR(aLastCharCR),
|
||||
mDestination(aDestination),
|
||||
mWritten(0)
|
||||
{ }
|
||||
|
||||
PRUint32 GetCharsWritten() {
|
||||
return mWritten;
|
||||
}
|
||||
|
||||
PRBool IsLastCharCR() {
|
||||
return mLastCharCR;
|
||||
}
|
||||
|
||||
PRUint32 write(const typename OutputIterator::value_type* aSource, PRUint32 aSourceLength) {
|
||||
|
||||
const typename OutputIterator::value_type* done_writing = aSource + aSourceLength;
|
||||
|
||||
// If the last source buffer ended with a CR...
|
||||
if (mLastCharCR) {
|
||||
// ..and if the next one is a LF, then skip it since
|
||||
// we've already written out a newline
|
||||
if (aSourceLength && (*aSource == value_type('\n'))) {
|
||||
++aSource;
|
||||
}
|
||||
mLastCharCR = PR_FALSE;
|
||||
}
|
||||
|
||||
PRUint32 num_written = 0;
|
||||
while ( aSource < done_writing ) {
|
||||
if (*aSource == value_type('\r')) {
|
||||
mDestination->writechar('\n');
|
||||
++aSource;
|
||||
// If we've reached the end of the buffer, record
|
||||
// that we wrote out a CR
|
||||
if (aSource == done_writing) {
|
||||
mLastCharCR = PR_TRUE;
|
||||
}
|
||||
// If the next character is a LF, skip it
|
||||
else if (*aSource == value_type('\n')) {
|
||||
++aSource;
|
||||
}
|
||||
}
|
||||
else {
|
||||
mDestination->writechar(*aSource++);
|
||||
}
|
||||
++num_written;
|
||||
}
|
||||
|
||||
mWritten += num_written;
|
||||
return aSourceLength;
|
||||
}
|
||||
|
||||
private:
|
||||
PRBool mLastCharCR;
|
||||
OutputIterator* mDestination;
|
||||
PRUint32 mWritten;
|
||||
};
|
||||
|
||||
// static
|
||||
PRUint32
|
||||
nsContentUtils::CopyNewlineNormalizedUnicodeTo(const nsAString& aSource,
|
||||
PRUint32 aSrcOffset,
|
||||
PRUnichar* aDest,
|
||||
PRUint32 aLength,
|
||||
PRBool& aLastCharCR)
|
||||
{
|
||||
typedef NormalizeNewlinesCharTraits<PRUnichar*> sink_traits;
|
||||
|
||||
sink_traits dest_traits(aDest);
|
||||
CopyNormalizeNewlines<sink_traits> normalizer(&dest_traits,aLastCharCR);
|
||||
nsReadingIterator<PRUnichar> fromBegin, fromEnd;
|
||||
copy_string(aSource.BeginReading(fromBegin).advance( PRInt32(aSrcOffset) ),
|
||||
aSource.BeginReading(fromEnd).advance( PRInt32(aSrcOffset+aLength) ),
|
||||
normalizer);
|
||||
aLastCharCR = normalizer.IsLastCharCR();
|
||||
return normalizer.GetCharsWritten();
|
||||
}
|
||||
|
||||
// static
|
||||
PRUint32
|
||||
nsContentUtils::CopyNewlineNormalizedUnicodeTo(nsReadingIterator<PRUnichar>& aSrcStart, const nsReadingIterator<PRUnichar>& aSrcEnd, nsAString& aDest)
|
||||
{
|
||||
typedef nsWritingIterator<PRUnichar> WritingIterator;
|
||||
typedef NormalizeNewlinesCharTraits<WritingIterator> sink_traits;
|
||||
|
||||
WritingIterator iter;
|
||||
aDest.BeginWriting(iter);
|
||||
sink_traits dest_traits(iter);
|
||||
CopyNormalizeNewlines<sink_traits> normalizer(&dest_traits);
|
||||
copy_string(aSrcStart, aSrcEnd, normalizer);
|
||||
return normalizer.GetCharsWritten();
|
||||
}
|
||||
|
||||
// static
|
||||
void
|
||||
nsContentUtils::Shutdown()
|
||||
{
|
||||
NS_IF_RELEASE(sDOMScriptObjectFactory);
|
||||
NS_IF_RELEASE(sXPConnect);
|
||||
}
|
||||
|
||||
// static
|
||||
nsISupports *
|
||||
nsContentUtils::GetClassInfoInstance(nsDOMClassInfoID aID)
|
||||
{
|
||||
if (!sDOMScriptObjectFactory) {
|
||||
static NS_DEFINE_CID(kDOMScriptObjectFactoryCID,
|
||||
NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
|
||||
|
||||
nsServiceManager::GetService(kDOMScriptObjectFactoryCID,
|
||||
NS_GET_IID(nsIDOMScriptObjectFactory),
|
||||
(nsISupports **)&sDOMScriptObjectFactory);
|
||||
|
||||
if (!sDOMScriptObjectFactory) {
|
||||
return nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
return sDOMScriptObjectFactory->GetClassInfoInstance(aID);
|
||||
}
|
||||
|
||||
// static
|
||||
nsresult
|
||||
nsContentUtils::doReparentContentWrapper(nsIContent *aChild,
|
||||
nsIDocument *aNewDocument,
|
||||
nsIDocument *aOldDocument,
|
||||
JSContext *cx,
|
||||
JSObject *parent_obj)
|
||||
{
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> old_wrapper;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
rv = sXPConnect->ReparentWrappedNativeIfFound(cx, ::JS_GetGlobalObject(cx),
|
||||
parent_obj, aChild,
|
||||
getter_AddRefs(old_wrapper));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!old_wrapper) {
|
||||
// If aChild isn't wrapped none of it's children are wrapped so
|
||||
// there's no need to walk into aChild's children.
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (aOldDocument) {
|
||||
nsCOMPtr<nsISupports> old_ref;
|
||||
|
||||
aOldDocument->RemoveReference(aChild, getter_AddRefs(old_ref));
|
||||
|
||||
if (old_ref) {
|
||||
// Transfer the reference from aOldDocument to aNewDocument
|
||||
|
||||
aNewDocument->AddReference(aChild, old_ref);
|
||||
}
|
||||
}
|
||||
|
||||
JSObject *old;
|
||||
|
||||
rv = old_wrapper->GetJSObject(&old);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIContent> child;
|
||||
PRInt32 count = 0, i;
|
||||
|
||||
aChild->ChildCount(count);
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
aChild->ChildAt(i, *getter_AddRefs(child));
|
||||
NS_ENSURE_TRUE(child, NS_ERROR_UNEXPECTED);
|
||||
|
||||
rv = doReparentContentWrapper(child, aNewDocument, aOldDocument, cx, old);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
static
|
||||
nsresult GetContextFromDocument(nsIDocument *aDocument, JSContext **cx)
|
||||
{
|
||||
*cx = nsnull;
|
||||
|
||||
nsCOMPtr<nsIScriptGlobalObject> sgo;
|
||||
aDocument->GetScriptGlobalObject(getter_AddRefs(sgo));
|
||||
|
||||
if (!sgo) {
|
||||
// No script global, no context.
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIScriptContext> scx;
|
||||
sgo->GetContext(getter_AddRefs(scx));
|
||||
|
||||
if (!scx) {
|
||||
// No context left in the old scope...
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
*cx = (JSContext *)scx->GetNativeContext();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// static
|
||||
nsresult
|
||||
nsContentUtils::ReparentContentWrapper(nsIContent *aContent,
|
||||
nsIContent *aNewParent,
|
||||
nsIDocument *aNewDocument,
|
||||
nsIDocument *aOldDocument)
|
||||
{
|
||||
if (!aNewDocument || aNewDocument == aOldDocument) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocument> old_doc(aOldDocument);
|
||||
|
||||
if (!old_doc) {
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
|
||||
aContent->GetNodeInfo(*getter_AddRefs(ni));
|
||||
|
||||
if (ni) {
|
||||
ni->GetDocument(*getter_AddRefs(old_doc));
|
||||
}
|
||||
|
||||
if (!aOldDocument) {
|
||||
// If we can't find our old document we don't know what our old
|
||||
// scope was so there's no way to find the old wrapper
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_ENSURE_TRUE(sXPConnect, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
nsCOMPtr<nsISupports> new_parent;
|
||||
|
||||
if (!aNewParent) {
|
||||
nsCOMPtr<nsIContent> root;
|
||||
old_doc->GetRootContent(getter_AddRefs(root));
|
||||
|
||||
if (root.get() == aContent) {
|
||||
new_parent = old_doc;
|
||||
}
|
||||
} else {
|
||||
new_parent = aNewParent;
|
||||
}
|
||||
|
||||
JSContext *cx = nsnull;
|
||||
|
||||
GetContextFromDocument(old_doc, &cx);
|
||||
|
||||
if (!cx) {
|
||||
// No JSContext left in the old scope, can't find the old wrapper
|
||||
// w/o the old context.
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
rv = sXPConnect->GetWrappedNativeOfNativeObject(cx, ::JS_GetGlobalObject(cx),
|
||||
aContent,
|
||||
NS_GET_IID(nsISupports),
|
||||
getter_AddRefs(wrapper));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!wrapper) {
|
||||
// aContent is not wrapped (and thus none of it's children are
|
||||
// wrapped) so there's no need to reparent anything.
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Wrap the new parent and reparent aContent
|
||||
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
||||
rv = sXPConnect->WrapNative(cx, ::JS_GetGlobalObject(cx), new_parent,
|
||||
NS_GET_IID(nsISupports),
|
||||
getter_AddRefs(holder));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
JSObject *obj;
|
||||
rv = holder->GetJSObject(&obj);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return doReparentContentWrapper(aContent, aNewDocument, aOldDocument, cx,
|
||||
obj);
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsContentUtils::IsCallerChrome()
|
||||
{
|
||||
nsCOMPtr<nsIDocShell> docShell;
|
||||
nsCOMPtr<nsIThreadJSContextStack> stack(do_GetService(sJSStackContractID));
|
||||
|
||||
if (stack) {
|
||||
JSContext *cx = nsnull;
|
||||
stack->Peek(&cx);
|
||||
|
||||
if (cx) {
|
||||
nsCOMPtr<nsIScriptGlobalObject> sgo;
|
||||
nsContentUtils::GetDynamicScriptGlobal(cx, getter_AddRefs(sgo));
|
||||
|
||||
if (sgo) {
|
||||
sgo->GetDocShell(getter_AddRefs(docShell));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeItem> item(do_QueryInterface(docShell));
|
||||
if (item) {
|
||||
PRInt32 callerType = nsIDocShellTreeItem::typeChrome;
|
||||
item->GetItemType(&callerType);
|
||||
|
||||
if (callerType != nsIDocShellTreeItem::typeChrome) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
// static
|
||||
PRBool
|
||||
nsContentUtils::InSameDoc(nsIDOMNode* aNode, nsIDOMNode* aOther)
|
||||
{
|
||||
if (!aNode || !aOther) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(aNode));
|
||||
nsCOMPtr<nsIContent> other(do_QueryInterface(aOther));
|
||||
|
||||
if (content && other) {
|
||||
nsCOMPtr<nsIDocument> contentDoc;
|
||||
nsCOMPtr<nsIDocument> otherDoc;
|
||||
content->GetDocument(*getter_AddRefs(contentDoc));
|
||||
other->GetDocument(*getter_AddRefs(otherDoc));
|
||||
// XXXcaa Don't bother to check that either node is in a
|
||||
// document. Editor relies on us returning true if neither
|
||||
// node is in a document. See bug 154401.
|
||||
if (contentDoc == otherDoc) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// static
|
||||
PRBool
|
||||
nsContentUtils::ContentIsDescendantOf(nsIContent* aPossibleDescendant,
|
||||
nsIContent* aPossibleAncestor)
|
||||
{
|
||||
NS_PRECONDITION(aPossibleDescendant, "The possible descendant is null!");
|
||||
NS_PRECONDITION(aPossibleAncestor, "The possible ancestor is null!");
|
||||
|
||||
nsCOMPtr<nsIContent> parent;
|
||||
do {
|
||||
if (aPossibleDescendant == aPossibleAncestor)
|
||||
return PR_TRUE;
|
||||
aPossibleDescendant->GetParent(*getter_AddRefs(parent));
|
||||
aPossibleDescendant = parent;
|
||||
} while (aPossibleDescendant);
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
|
||||
// static
|
||||
nsresult
|
||||
nsContentUtils::GetAncestors(nsIDOMNode* aNode,
|
||||
nsVoidArray* aArray)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aNode);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> node(aNode);
|
||||
nsCOMPtr<nsIDOMNode> ancestor;
|
||||
|
||||
do {
|
||||
aArray->AppendElement(node.get());
|
||||
node->GetParentNode(getter_AddRefs(ancestor));
|
||||
node = ancestor;
|
||||
} while (node);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// static
|
||||
nsresult
|
||||
nsContentUtils::GetAncestorsAndOffsets(nsIDOMNode* aNode,
|
||||
PRInt32 aOffset,
|
||||
nsVoidArray* aAncestorNodes,
|
||||
nsVoidArray* aAncestorOffsets)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aNode);
|
||||
|
||||
PRInt32 offset = 0;
|
||||
nsCOMPtr<nsIContent> ancestor;
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(aNode));
|
||||
|
||||
if (!content) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (aAncestorNodes->Count() != 0) {
|
||||
NS_WARNING("aAncestorNodes is not empty");
|
||||
aAncestorNodes->Clear();
|
||||
}
|
||||
|
||||
if (aAncestorOffsets->Count() != 0) {
|
||||
NS_WARNING("aAncestorOffsets is not empty");
|
||||
aAncestorOffsets->Clear();
|
||||
}
|
||||
|
||||
// insert the node itself
|
||||
aAncestorNodes->AppendElement(content.get());
|
||||
aAncestorOffsets->AppendElement(NS_INT32_TO_PTR(aOffset));
|
||||
|
||||
// insert all the ancestors
|
||||
content->GetParent(*getter_AddRefs(ancestor));
|
||||
while (ancestor) {
|
||||
ancestor->IndexOf(content, offset);
|
||||
aAncestorNodes->AppendElement(ancestor.get());
|
||||
aAncestorOffsets->AppendElement(NS_INT32_TO_PTR(offset));
|
||||
content = ancestor;
|
||||
content->GetParent(*getter_AddRefs(ancestor));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// static
|
||||
nsresult
|
||||
nsContentUtils::GetCommonAncestor(nsIDOMNode *aNode,
|
||||
nsIDOMNode *aOther,
|
||||
nsIDOMNode** aCommonAncestor)
|
||||
{
|
||||
*aCommonAncestor = nsnull;
|
||||
|
||||
nsAutoVoidArray nodeArray;
|
||||
nsresult rv = GetFirstDifferentAncestors(aNode, aOther, &nodeArray);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsIDOMNode *common =
|
||||
NS_STATIC_CAST(nsIDOMNode*, nodeArray.ElementAt(0));
|
||||
|
||||
NS_ASSERTION(common, "The common ancestor is null! Very bad!");
|
||||
|
||||
*aCommonAncestor = common;
|
||||
NS_IF_ADDREF(*aCommonAncestor);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// static
|
||||
nsresult
|
||||
nsContentUtils::GetFirstDifferentAncestors(nsIDOMNode *aNode,
|
||||
nsIDOMNode *aOther,
|
||||
nsVoidArray* aDifferentNodes)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aNode);
|
||||
NS_ENSURE_ARG_POINTER(aOther);
|
||||
|
||||
if (aDifferentNodes->Count() != 0) {
|
||||
NS_WARNING("The aDifferentNodes array passed in is not empty!");
|
||||
aDifferentNodes->Clear();
|
||||
}
|
||||
|
||||
// Test if both are the same node.
|
||||
if (aNode == aOther) {
|
||||
aDifferentNodes->AppendElement(NS_STATIC_CAST(void*, aNode));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsAutoVoidArray nodeAncestors;
|
||||
nsAutoVoidArray otherAncestors;
|
||||
|
||||
// Insert all the ancestors of |aNode|
|
||||
nsCOMPtr<nsIDOMNode> node(aNode);
|
||||
nsCOMPtr<nsIDOMNode> ancestor(node);
|
||||
do {
|
||||
nodeAncestors.AppendElement(node.get());
|
||||
node->GetParentNode(getter_AddRefs(ancestor));
|
||||
if (ancestor == aOther) {
|
||||
aDifferentNodes->AppendElement(NS_STATIC_CAST(void*, aOther));
|
||||
return NS_OK;
|
||||
}
|
||||
node = ancestor;
|
||||
} while (ancestor);
|
||||
|
||||
// Insert all the ancestors of |aOther|
|
||||
nsCOMPtr<nsIDOMNode> other(aOther);
|
||||
ancestor = other;
|
||||
do {
|
||||
otherAncestors.AppendElement(other.get());
|
||||
other->GetParentNode(getter_AddRefs(ancestor));
|
||||
if (ancestor == aNode) {
|
||||
aDifferentNodes->AppendElement(NS_STATIC_CAST(void*, aNode));
|
||||
return NS_OK;
|
||||
}
|
||||
other = ancestor;
|
||||
} while (ancestor);
|
||||
|
||||
PRInt32 nodeIdx = nodeAncestors.Count() - 1;
|
||||
PRInt32 otherIdx = otherAncestors.Count() - 1;
|
||||
|
||||
if (nodeAncestors.ElementAt(nodeIdx) != otherAncestors.ElementAt(otherIdx)) {
|
||||
NS_ERROR("This function was called on two disconnected nodes!");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Go back through the ancestors, starting from the root,
|
||||
// until the first different ancestor found.
|
||||
do {
|
||||
--nodeIdx;
|
||||
--otherIdx;
|
||||
} while (nodeAncestors.ElementAt(nodeIdx) == otherAncestors.ElementAt(otherIdx));
|
||||
|
||||
NS_ASSERTION(nodeIdx >= 0 && otherIdx >= 0,
|
||||
"Something's wrong: our indices should not be negative here!");
|
||||
|
||||
aDifferentNodes->AppendElement(nodeAncestors.ElementAt(nodeIdx + 1));
|
||||
aDifferentNodes->AppendElement(nodeAncestors.ElementAt(nodeIdx));
|
||||
aDifferentNodes->AppendElement(otherAncestors.ElementAt(otherIdx));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
inline PRBool
|
||||
IsCharInSet(const char* aSet,
|
||||
const PRUnichar aChar)
|
||||
{
|
||||
PRUnichar ch;
|
||||
while ((ch = *aSet)) {
|
||||
if (aChar == PRUnichar(ch)) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
++aSet;
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method strips leading/trailing chars, in given set, from string.
|
||||
*/
|
||||
const nsDependentSubstring
|
||||
nsContentUtils::TrimCharsInSet(const char* aSet,
|
||||
const nsAString& aValue)
|
||||
{
|
||||
nsAString::const_iterator valueCurrent, valueEnd;
|
||||
|
||||
aValue.BeginReading(valueCurrent);
|
||||
aValue.EndReading(valueEnd);
|
||||
|
||||
// Skip charaters in the beginning
|
||||
while (valueCurrent != valueEnd) {
|
||||
if (!IsCharInSet(aSet, *valueCurrent)) {
|
||||
break;
|
||||
}
|
||||
++valueCurrent;
|
||||
}
|
||||
|
||||
if (valueCurrent != valueEnd) {
|
||||
for (;;) {
|
||||
--valueEnd;
|
||||
if (!IsCharInSet(aSet, *valueEnd)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
++valueEnd; // Step beyond the last character we want in the value.
|
||||
}
|
||||
|
||||
// valueEnd should point to the char after the last to copy
|
||||
return Substring(valueCurrent, valueEnd);
|
||||
}
|
||||
@@ -1,663 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsDOMAttribute.h"
|
||||
#include "nsGenericElement.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsITextContent.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsDOMError.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
nsDOMAttribute::nsDOMAttribute(nsIContent* aContent, nsINodeInfo *aNodeInfo,
|
||||
const nsAString& aValue)
|
||||
: mContent(aContent), mNodeInfo(aNodeInfo), mValue(aValue), mChild(nsnull),
|
||||
mChildList(nsnull)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(mNodeInfo, "We must get a nodeinfo here!");
|
||||
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
// We don't add a reference to our content. It will tell us
|
||||
// to drop our reference when it goes away.
|
||||
}
|
||||
|
||||
nsDOMAttribute::~nsDOMAttribute()
|
||||
{
|
||||
NS_IF_RELEASE(mChild);
|
||||
NS_IF_RELEASE(mChildList);
|
||||
}
|
||||
|
||||
|
||||
// QueryInterface implementation for nsDOMAttribute
|
||||
NS_INTERFACE_MAP_BEGIN(nsDOMAttribute)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMAttr)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMAttributePrivate)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOM3Node)
|
||||
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)
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::DropReference()
|
||||
{
|
||||
mContent = nsnull;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::SetContent(nsIContent* aContent)
|
||||
{
|
||||
mContent = aContent;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetContent(nsIContent** aContent)
|
||||
{
|
||||
*aContent = mContent;
|
||||
NS_IF_ADDREF(*aContent);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttribute::GetName(nsAString& aName)
|
||||
{
|
||||
NS_ENSURE_TRUE(mNodeInfo, NS_ERROR_FAILURE);
|
||||
|
||||
return mNodeInfo->GetQualifiedName(aName);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttribute::GetValue(nsAString& aValue)
|
||||
{
|
||||
NS_ENSURE_TRUE(mNodeInfo, NS_ERROR_FAILURE);
|
||||
|
||||
nsresult result = NS_OK;
|
||||
if (mContent) {
|
||||
nsresult attrResult;
|
||||
PRInt32 nameSpaceID;
|
||||
nsCOMPtr<nsIAtom> name;
|
||||
|
||||
mNodeInfo->GetNameAtom(*getter_AddRefs(name));
|
||||
mNodeInfo->GetNamespaceID(nameSpaceID);
|
||||
|
||||
nsAutoString tmpValue;
|
||||
attrResult = mContent->GetAttr(nameSpaceID, name, tmpValue);
|
||||
if (NS_CONTENT_ATTR_NOT_THERE != attrResult) {
|
||||
mValue = tmpValue;
|
||||
}
|
||||
}
|
||||
aValue=mValue;
|
||||
return result;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttribute::SetValue(const nsAString& aValue)
|
||||
{
|
||||
NS_ENSURE_TRUE(mNodeInfo, NS_ERROR_FAILURE);
|
||||
|
||||
nsresult result = NS_OK;
|
||||
if (mContent) {
|
||||
result = mContent->SetAttr(mNodeInfo, aValue, PR_TRUE);
|
||||
}
|
||||
mValue=aValue;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttribute::GetSpecified(PRBool* aSpecified)
|
||||
{
|
||||
NS_ENSURE_TRUE(mNodeInfo, NS_ERROR_FAILURE);
|
||||
NS_ENSURE_ARG_POINTER(aSpecified);
|
||||
|
||||
nsresult result = NS_OK;
|
||||
if (nsnull == mContent) {
|
||||
*aSpecified = PR_FALSE;
|
||||
} else {
|
||||
nsAutoString value;
|
||||
nsresult attrResult;
|
||||
PRInt32 nameSpaceID;
|
||||
nsCOMPtr<nsIAtom> name;
|
||||
|
||||
mNodeInfo->GetNameAtom(*getter_AddRefs(name));
|
||||
mNodeInfo->GetNamespaceID(nameSpaceID);
|
||||
|
||||
attrResult = mContent->GetAttr(nameSpaceID, name, value);
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == attrResult) {
|
||||
*aSpecified = PR_TRUE;
|
||||
}
|
||||
else {
|
||||
*aSpecified = PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetOwnerElement(nsIDOMElement** aOwnerElement)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aOwnerElement);
|
||||
|
||||
if (mContent) {
|
||||
return mContent->QueryInterface(NS_GET_IID(nsIDOMElement),
|
||||
(void **)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)
|
||||
{
|
||||
*aHasChildNodes = PR_FALSE;
|
||||
if (mChild) {
|
||||
*aHasChildNodes = PR_TRUE;
|
||||
}
|
||||
else if (mContent) {
|
||||
nsAutoString value;
|
||||
|
||||
GetValue(value);
|
||||
if (!value.IsEmpty()) {
|
||||
*aHasChildNodes = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
nsAutoString value;
|
||||
nsresult result;
|
||||
|
||||
result = GetValue(value);
|
||||
if (NS_OK != result) {
|
||||
return result;
|
||||
}
|
||||
if (!value.IsEmpty()) {
|
||||
if (!mChild) {
|
||||
nsIContent* content;
|
||||
|
||||
result = NS_NewTextNode(&content);
|
||||
if (NS_OK != result) {
|
||||
return result;
|
||||
}
|
||||
result = content->QueryInterface(NS_GET_IID(nsIDOMText), (void**)&mChild);
|
||||
NS_RELEASE(content);
|
||||
}
|
||||
mChild->SetData(value);
|
||||
result = mChild->QueryInterface(NS_GET_IID(nsIDOMNode), (void**)aFirstChild);
|
||||
}
|
||||
else {
|
||||
*aFirstChild = nsnull;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
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_DOM_NO_MODIFICATION_ALLOWED_ERR;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
nsDOMAttribute* newAttr;
|
||||
|
||||
if (mContent) {
|
||||
nsAutoString value;
|
||||
PRInt32 nameSpaceID;
|
||||
nsCOMPtr<nsIAtom> name;
|
||||
|
||||
mNodeInfo->GetNameAtom(*getter_AddRefs(name));
|
||||
mNodeInfo->GetNamespaceID(nameSpaceID);
|
||||
|
||||
mContent->GetAttr(nameSpaceID, name, value);
|
||||
newAttr = new nsDOMAttribute(nsnull, mNodeInfo, value);
|
||||
}
|
||||
else {
|
||||
newAttr = new nsDOMAttribute(nsnull, mNodeInfo, mValue);
|
||||
}
|
||||
|
||||
if (!newAttr) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return newAttr->QueryInterface(NS_GET_IID(nsIDOMNode), (void**)aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetOwnerDocument(nsIDOMDocument** aOwnerDocument)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
if (mContent) {
|
||||
nsIDOMNode* node;
|
||||
result = mContent->QueryInterface(NS_GET_IID(nsIDOMNode), (void**)&node);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
result = node->GetOwnerDocument(aOwnerDocument);
|
||||
NS_RELEASE(node);
|
||||
}
|
||||
}
|
||||
else {
|
||||
*aOwnerDocument = nsnull;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetNamespaceURI(nsAString& aNamespaceURI)
|
||||
{
|
||||
NS_ENSURE_TRUE(mNodeInfo, NS_ERROR_FAILURE);
|
||||
|
||||
return mNodeInfo->GetNamespaceURI(aNamespaceURI);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetPrefix(nsAString& aPrefix)
|
||||
{
|
||||
NS_ENSURE_TRUE(mNodeInfo, NS_ERROR_FAILURE);
|
||||
|
||||
return mNodeInfo->GetPrefix(aPrefix);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::SetPrefix(const nsAString& aPrefix)
|
||||
{
|
||||
NS_ENSURE_TRUE(mNodeInfo, NS_ERROR_FAILURE);
|
||||
nsCOMPtr<nsINodeInfo> newNodeInfo;
|
||||
nsCOMPtr<nsIAtom> prefix;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (!aPrefix.IsEmpty() && !DOMStringIsNull(aPrefix))
|
||||
prefix = dont_AddRef(NS_NewAtom(aPrefix));
|
||||
|
||||
rv = mNodeInfo->PrefixChanged(prefix, *getter_AddRefs(newNodeInfo));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (mContent) {
|
||||
nsCOMPtr<nsIAtom> name;
|
||||
PRInt32 nameSpaceID;
|
||||
nsAutoString tmpValue;
|
||||
|
||||
mNodeInfo->GetNameAtom(*getter_AddRefs(name));
|
||||
mNodeInfo->GetNamespaceID(nameSpaceID);
|
||||
|
||||
rv = mContent->GetAttr(nameSpaceID, name, tmpValue);
|
||||
if (rv == NS_CONTENT_ATTR_HAS_VALUE) {
|
||||
mContent->UnsetAttr(nameSpaceID, name, PR_TRUE);
|
||||
|
||||
mContent->SetAttr(newNodeInfo, tmpValue, PR_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
mNodeInfo = newNodeInfo;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetLocalName(nsAString& aLocalName)
|
||||
{
|
||||
NS_ENSURE_TRUE(mNodeInfo, NS_ERROR_FAILURE);
|
||||
|
||||
return mNodeInfo->GetLocalName(aLocalName);
|
||||
}
|
||||
|
||||
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(aFeature, aVersion, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::GetBaseURI(nsAString &aURI)
|
||||
{
|
||||
aURI.Truncate();
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIDOM3Node> node(do_QueryInterface(mContent));
|
||||
if (node)
|
||||
rv = node->GetBaseURI(aURI);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::CompareTreePosition(nsIDOMNode* aOther,
|
||||
PRUint16* aReturn)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aOther);
|
||||
PRUint16 mask = nsIDOMNode::TREE_POSITION_DISCONNECTED;
|
||||
|
||||
nsCOMPtr<nsIDOMElement> el;
|
||||
GetOwnerElement(getter_AddRefs(el));
|
||||
if (el) {
|
||||
// Check to see if the other node is also an attribute
|
||||
PRUint16 nodeType = 0;
|
||||
aOther->GetNodeType(&nodeType);
|
||||
if (nodeType == nsIDOMNode::ATTRIBUTE_NODE) {
|
||||
nsCOMPtr<nsIDOMAttr> otherAttr(do_QueryInterface(aOther));
|
||||
nsCOMPtr<nsIDOMElement> otherEl;
|
||||
otherAttr->GetOwnerElement(getter_AddRefs(otherEl));
|
||||
if (el == otherEl) {
|
||||
// same parent node, the two attributes have equivalent position
|
||||
mask |= nsIDOMNode::TREE_POSITION_EQUIVALENT;
|
||||
PRBool sameNode = PR_FALSE;
|
||||
IsSameNode(aOther, &sameNode);
|
||||
if (sameNode) {
|
||||
mask |= nsIDOMNode::TREE_POSITION_SAME_NODE;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// The other node isn't an attribute.
|
||||
// Compare position relative to this attribute's owner element.
|
||||
nsCOMPtr<nsIDOM3Node> parent(do_QueryInterface(el));
|
||||
PRUint16 parentMask;
|
||||
parent->CompareTreePosition(aOther, &parentMask);
|
||||
if (parentMask & nsIDOMNode::TREE_POSITION_SAME_NODE) {
|
||||
mask |= nsIDOMNode::TREE_POSITION_PRECEDING;
|
||||
}
|
||||
else {
|
||||
mask |= parentMask & (nsIDOMNode::TREE_POSITION_FOLLOWING |
|
||||
nsIDOMNode::TREE_POSITION_PRECEDING);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*aReturn = mask;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::IsSameNode(nsIDOMNode* aOther,
|
||||
PRBool* aReturn)
|
||||
{
|
||||
PRBool sameNode = PR_FALSE;
|
||||
|
||||
// XXXcaa Comparing pointers on two attributes is not yet reliable.
|
||||
// When bug 93614 is fixed, this should be changed to simple pointer
|
||||
// comparisons. But for now, check owner elements and node names.
|
||||
PRUint16 otherType = 0;
|
||||
aOther->GetNodeType(&otherType);
|
||||
if (nsIDOMNode::ATTRIBUTE_NODE == otherType) {
|
||||
nsCOMPtr<nsIDOMElement> nodeOwner;
|
||||
GetOwnerElement(getter_AddRefs(nodeOwner));
|
||||
nsCOMPtr<nsIDOMAttr> other(do_QueryInterface(aOther));
|
||||
nsCOMPtr<nsIDOMElement> otherOwner;
|
||||
other->GetOwnerElement(getter_AddRefs(otherOwner));
|
||||
nsCOMPtr<nsIDOM3Node> owner(do_QueryInterface(nodeOwner));
|
||||
PRBool sameOwners = PR_FALSE;
|
||||
owner->IsSameNode(otherOwner, &sameOwners);
|
||||
|
||||
// Do these attributes belong to the same element?
|
||||
if (sameOwners) {
|
||||
PRBool ci = PR_FALSE;
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(nodeOwner));
|
||||
// Check to see if we're in HTML.
|
||||
if (content->IsContentOfType(nsIContent::eHTML)) {
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
content->GetNodeInfo(*getter_AddRefs(ni));
|
||||
if (ni) {
|
||||
// If there is no namespace, we're in HTML (as opposed to XHTML)
|
||||
// and we'll need to compare node names case insensitively.
|
||||
ci = ni->NamespaceEquals(kNameSpaceID_None);
|
||||
}
|
||||
}
|
||||
|
||||
nsAutoString nodeName;
|
||||
nsAutoString otherName;
|
||||
GetNodeName(nodeName);
|
||||
aOther->GetNodeName(otherName);
|
||||
// Compare node names
|
||||
sameNode = ci ? nodeName.Equals(otherName,
|
||||
nsCaseInsensitiveStringComparator())
|
||||
: nodeName.Equals(otherName);
|
||||
}
|
||||
}
|
||||
|
||||
*aReturn = sameNode;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::LookupNamespacePrefix(const nsAString& aNamespaceURI,
|
||||
nsAString& aPrefix)
|
||||
{
|
||||
aPrefix.Truncate();
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIDOM3Node> node(do_QueryInterface(mContent));
|
||||
if (node)
|
||||
rv = node->LookupNamespacePrefix(aNamespaceURI, aPrefix);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMAttribute::LookupNamespaceURI(const nsAString& aNamespacePrefix,
|
||||
nsAString& aNamespaceURI)
|
||||
{
|
||||
aNamespaceURI.Truncate();
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIDOM3Node> node(do_QueryInterface(mContent));
|
||||
if (node)
|
||||
rv = node->LookupNamespaceURI(aNamespacePrefix, aNamespaceURI);
|
||||
return rv;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
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 = 0;
|
||||
if (mAttribute) {
|
||||
nsAutoString value;
|
||||
mAttribute->GetValue(value);
|
||||
if (!value.IsEmpty()) {
|
||||
*aLength = 1;
|
||||
}
|
||||
}
|
||||
|
||||
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,120 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsDOMAttribute_h___
|
||||
#define nsDOMAttribute_h___
|
||||
|
||||
#include "nsIDOMAttr.h"
|
||||
#include "nsIDOMText.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsGenericDOMNodeList.h"
|
||||
#include "nsString.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsINodeInfo.h"
|
||||
|
||||
class nsIContent;
|
||||
class nsDOMAttribute;
|
||||
|
||||
#define NS_IDOMATTRIBUTEPRIVATE_IID \
|
||||
{0xa6cf90dd, 0x15b3, 0x11d2, \
|
||||
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
class nsIDOMAttributePrivate : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDOMATTRIBUTEPRIVATE_IID)
|
||||
|
||||
NS_IMETHOD DropReference() = 0;
|
||||
NS_IMETHOD SetContent(nsIContent* aContent) = 0;
|
||||
NS_IMETHOD GetContent(nsIContent** aContent) = 0;
|
||||
};
|
||||
|
||||
// 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 and nsIDOMNode
|
||||
class nsDOMAttribute : public nsIDOMAttr,
|
||||
public nsIDOM3Node,
|
||||
public nsIDOMAttributePrivate
|
||||
{
|
||||
public:
|
||||
nsDOMAttribute(nsIContent* aContent, nsINodeInfo *aNodeInfo,
|
||||
const nsAString& aValue);
|
||||
virtual ~nsDOMAttribute();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMNode interface
|
||||
NS_DECL_NSIDOMNODE
|
||||
|
||||
// nsIDOM3Node interface
|
||||
NS_DECL_NSIDOM3NODE
|
||||
|
||||
// nsIDOMAttr interface
|
||||
NS_DECL_NSIDOMATTR
|
||||
|
||||
// nsIDOMAttributePrivate interface
|
||||
NS_IMETHOD DropReference();
|
||||
NS_IMETHOD SetContent(nsIContent* aContent);
|
||||
NS_IMETHOD GetContent(nsIContent** aContent);
|
||||
|
||||
private:
|
||||
nsIContent* mContent;
|
||||
nsCOMPtr<nsINodeInfo> mNodeInfo;
|
||||
nsString mValue;
|
||||
// XXX For now, there's only a single child - a text
|
||||
// element representing the value
|
||||
nsIDOMText* mChild;
|
||||
nsAttributeChildList* mChildList;
|
||||
};
|
||||
|
||||
|
||||
#endif /* nsDOMAttribute_h___ */
|
||||
@@ -1,462 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsDOMAttributeMap.h"
|
||||
#include "nsDOMAttribute.h"
|
||||
#include "nsGenericElement.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsDOMError.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
nsDOMAttributeMap::nsDOMAttributeMap(nsIContent* aContent)
|
||||
: mContent(aContent)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
// We don't add a reference to our content. If it goes away,
|
||||
// we'll be told to drop our reference
|
||||
}
|
||||
|
||||
nsDOMAttributeMap::~nsDOMAttributeMap()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
nsDOMAttributeMap::DropReference()
|
||||
{
|
||||
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)
|
||||
|
||||
nsresult
|
||||
nsDOMAttributeMap::GetNamedItem(const nsAString& aAttrName,
|
||||
nsIDOMNode** aAttribute)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aAttribute);
|
||||
*aAttribute = nsnull;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
if (mContent) {
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
mContent->NormalizeAttrString(aAttrName, *getter_AddRefs(ni));
|
||||
NS_ENSURE_TRUE(ni, NS_ERROR_FAILURE);
|
||||
|
||||
PRInt32 nsid;
|
||||
nsCOMPtr<nsIAtom> nameAtom;
|
||||
|
||||
ni->GetNamespaceID(nsid);
|
||||
ni->GetNameAtom(*getter_AddRefs(nameAtom));
|
||||
|
||||
nsresult attrResult;
|
||||
|
||||
nsAutoString value;
|
||||
attrResult = mContent->GetAttr(nsid, nameAtom, value);
|
||||
|
||||
if (NS_CONTENT_ATTR_NOT_THERE != attrResult && NS_SUCCEEDED(attrResult)) {
|
||||
nsDOMAttribute* domAttribute;
|
||||
domAttribute = new nsDOMAttribute(mContent, ni, value);
|
||||
NS_ENSURE_TRUE(domAttribute, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
rv = domAttribute->QueryInterface(NS_GET_IID(nsIDOMAttr),
|
||||
(void **)aAttribute);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttributeMap::SetNamedItem(nsIDOMNode *aNode, nsIDOMNode **aReturn)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aReturn);
|
||||
|
||||
if (!aNode) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
*aReturn = nsnull;
|
||||
|
||||
if (mContent) {
|
||||
nsCOMPtr<nsIDOMAttr> attribute(do_QueryInterface(aNode));
|
||||
|
||||
if (!attribute) {
|
||||
return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR;
|
||||
}
|
||||
|
||||
nsAutoString name, value;
|
||||
|
||||
attribute->GetName(name);
|
||||
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
mContent->NormalizeAttrString(name, *getter_AddRefs(ni));
|
||||
NS_ENSURE_TRUE(ni, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIAtom> nameAtom;
|
||||
PRInt32 nsid;
|
||||
|
||||
ni->GetNamespaceID(nsid);
|
||||
ni->GetNameAtom(*getter_AddRefs(nameAtom));
|
||||
|
||||
nsresult attrResult = mContent->GetAttr(nsid, nameAtom, value);
|
||||
|
||||
if (NS_CONTENT_ATTR_NOT_THERE != attrResult && NS_SUCCEEDED(attrResult)) {
|
||||
nsDOMAttribute* domAttribute;
|
||||
// We pass a null content here since the attr node we return isn't
|
||||
// tied to this content anymore.
|
||||
domAttribute = new nsDOMAttribute(nsnull, ni, value);
|
||||
if (!domAttribute) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
rv = domAttribute->QueryInterface(NS_GET_IID(nsIDOMAttr),
|
||||
(void **)aReturn);
|
||||
}
|
||||
|
||||
attribute->GetValue(value);
|
||||
|
||||
rv = mContent->SetAttr(ni, value, PR_TRUE);
|
||||
}
|
||||
|
||||
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->NormalizeAttrString(aName, *getter_AddRefs(ni));
|
||||
NS_ENSURE_TRUE(ni, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIAtom> nameAtom;
|
||||
PRInt32 nsid;
|
||||
|
||||
ni->GetNamespaceID(nsid);
|
||||
ni->GetNameAtom(*getter_AddRefs(nameAtom));
|
||||
|
||||
nsCOMPtr<nsIDOMNode> attribute;
|
||||
|
||||
nsresult attrResult;
|
||||
nsAutoString value;
|
||||
attrResult = mContent->GetAttr(nsid, nameAtom, value);
|
||||
|
||||
if (NS_CONTENT_ATTR_NOT_THERE != attrResult && NS_SUCCEEDED(attrResult)) {
|
||||
nsDOMAttribute* domAttribute;
|
||||
domAttribute = new nsDOMAttribute(nsnull, ni, value);
|
||||
if (!domAttribute) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
rv = domAttribute->QueryInterface(NS_GET_IID(nsIDOMAttr),
|
||||
(void **)aReturn);
|
||||
} else {
|
||||
return NS_ERROR_DOM_NOT_FOUND_ERR;
|
||||
}
|
||||
|
||||
rv = mContent->UnsetAttr(nsid, nameAtom, PR_TRUE);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsDOMAttributeMap::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aReturn);
|
||||
PRInt32 nameSpaceID;
|
||||
nsCOMPtr<nsIAtom> nameAtom, prefix;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
if (mContent &&
|
||||
NS_SUCCEEDED(mContent->GetAttrNameAt(aIndex,
|
||||
nameSpaceID,
|
||||
*getter_AddRefs(nameAtom),
|
||||
*getter_AddRefs(prefix)))) {
|
||||
nsAutoString value, name;
|
||||
mContent->GetAttr(nameSpaceID, nameAtom, value);
|
||||
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
mContent->GetNodeInfo(*getter_AddRefs(ni));
|
||||
NS_ENSURE_TRUE(ni, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsINodeInfoManager> nimgr;
|
||||
ni->GetNodeInfoManager(*getter_AddRefs(nimgr));
|
||||
NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE);
|
||||
|
||||
nimgr->GetNodeInfo(nameAtom, prefix, nameSpaceID, *getter_AddRefs(ni));
|
||||
NS_ENSURE_TRUE(ni, NS_ERROR_FAILURE);
|
||||
|
||||
nsDOMAttribute* domAttribute = new nsDOMAttribute(mContent, ni, value);
|
||||
NS_ENSURE_TRUE(domAttribute, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
rv = domAttribute->QueryInterface(NS_GET_IID(nsIDOMAttr),
|
||||
(void **)aReturn);
|
||||
}
|
||||
else {
|
||||
*aReturn = nsnull;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttributeMap::GetLength(PRUint32 *aLength)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aLength);
|
||||
|
||||
PRInt32 n;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (nsnull != mContent) {
|
||||
rv = mContent->GetAttrCount(n);
|
||||
*aLength = PRUint32(n);
|
||||
} else {
|
||||
*aLength = 0;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttributeMap::GetNamedItemNS(const nsAString& aNamespaceURI,
|
||||
const nsAString& aLocalName,
|
||||
nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aReturn);
|
||||
*aReturn = nsnull;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
if (mContent) {
|
||||
nsCOMPtr<nsIAtom> nameAtom(dont_AddRef(NS_NewAtom(aLocalName)));
|
||||
PRInt32 nameSpaceID = kNameSpaceID_None;
|
||||
nsCOMPtr<nsIAtom> prefix;
|
||||
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
mContent->GetNodeInfo(*getter_AddRefs(ni));
|
||||
NS_ENSURE_TRUE(ni, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsINodeInfoManager> nimgr;
|
||||
ni->GetNodeInfoManager(*getter_AddRefs(nimgr));
|
||||
NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE);
|
||||
|
||||
if (aNamespaceURI.Length()) {
|
||||
nsCOMPtr<nsINameSpaceManager> nsmgr;
|
||||
nimgr->GetNamespaceManager(*getter_AddRefs(nsmgr));
|
||||
NS_ENSURE_TRUE(nsmgr, NS_ERROR_FAILURE);
|
||||
|
||||
nsmgr->GetNameSpaceID(aNamespaceURI, nameSpaceID);
|
||||
|
||||
if (nameSpaceID == kNameSpaceID_Unknown)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult attrResult;
|
||||
nsAutoString value;
|
||||
|
||||
attrResult = mContent->GetAttr(nameSpaceID, nameAtom,
|
||||
*getter_AddRefs(prefix), value);
|
||||
|
||||
if (NS_CONTENT_ATTR_NOT_THERE != attrResult && NS_SUCCEEDED(attrResult)) {
|
||||
nimgr->GetNodeInfo(nameAtom, prefix, nameSpaceID, *getter_AddRefs(ni));
|
||||
NS_ENSURE_TRUE(ni, NS_ERROR_FAILURE);
|
||||
|
||||
nsDOMAttribute* domAttribute;
|
||||
domAttribute = new nsDOMAttribute(mContent, ni, value);
|
||||
NS_ENSURE_TRUE(domAttribute, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
rv = domAttribute->QueryInterface(NS_GET_IID(nsIDOMAttr),
|
||||
(void **)aReturn);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttributeMap::SetNamedItemNS(nsIDOMNode* aArg, nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aReturn);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
*aReturn = nsnull;
|
||||
|
||||
if (mContent) {
|
||||
nsCOMPtr<nsIDOMAttr> attribute(do_QueryInterface(aArg));
|
||||
|
||||
if (!attribute) {
|
||||
return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR;
|
||||
}
|
||||
|
||||
nsAutoString name, nsURI, value;
|
||||
nsCOMPtr<nsIAtom> nameAtom;
|
||||
PRInt32 nameSpaceID;
|
||||
|
||||
attribute->GetName(name);
|
||||
attribute->GetPrefix(name);
|
||||
attribute->GetNamespaceURI(nsURI);
|
||||
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
mContent->GetNodeInfo(*getter_AddRefs(ni));
|
||||
NS_ENSURE_TRUE(ni, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsINodeInfoManager> nimgr;
|
||||
ni->GetNodeInfoManager(*getter_AddRefs(nimgr));
|
||||
NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE);
|
||||
|
||||
nimgr->GetNodeInfo(name, nsURI, *getter_AddRefs(ni));
|
||||
NS_ENSURE_TRUE(ni, NS_ERROR_FAILURE);
|
||||
|
||||
ni->GetNameAtom(*getter_AddRefs(nameAtom));
|
||||
ni->GetNamespaceID(nameSpaceID);
|
||||
|
||||
nsresult attrResult = mContent->GetAttr(nameSpaceID, nameAtom, value);
|
||||
|
||||
if (NS_CONTENT_ATTR_NOT_THERE != attrResult && NS_SUCCEEDED(attrResult)) {
|
||||
nsDOMAttribute* domAttribute;
|
||||
// We pass a null content here since the attr node we return isn't
|
||||
// tied to this content anymore.
|
||||
domAttribute = new nsDOMAttribute(nsnull, ni, value);
|
||||
if (!domAttribute) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
rv = domAttribute->QueryInterface(NS_GET_IID(nsIDOMAttr),
|
||||
(void **)aReturn);
|
||||
}
|
||||
|
||||
attribute->GetValue(value);
|
||||
|
||||
rv = mContent->SetAttr(ni, value, PR_TRUE);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMAttributeMap::RemoveNamedItemNS(const nsAString& aNamespaceURI,
|
||||
const nsAString& aLocalName,
|
||||
nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aReturn);
|
||||
*aReturn = nsnull;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (mContent) {
|
||||
nsCOMPtr<nsIAtom> nameAtom(dont_AddRef(NS_NewAtom(aLocalName)));
|
||||
PRInt32 nameSpaceID = kNameSpaceID_None;
|
||||
nsCOMPtr<nsIDOMNode> attribute;
|
||||
nsCOMPtr<nsIAtom> prefix;
|
||||
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
mContent->GetNodeInfo(*getter_AddRefs(ni));
|
||||
NS_ENSURE_TRUE(ni, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsINodeInfoManager> nimgr;
|
||||
ni->GetNodeInfoManager(*getter_AddRefs(nimgr));
|
||||
NS_ENSURE_TRUE(nimgr, NS_ERROR_FAILURE);
|
||||
|
||||
if (aNamespaceURI.Length()) {
|
||||
nsCOMPtr<nsINameSpaceManager> nsmgr;
|
||||
nimgr->GetNamespaceManager(*getter_AddRefs(nsmgr));
|
||||
NS_ENSURE_TRUE(nsmgr, NS_ERROR_FAILURE);
|
||||
|
||||
nsmgr->GetNameSpaceID(aNamespaceURI, nameSpaceID);
|
||||
|
||||
if (nameSpaceID == kNameSpaceID_Unknown)
|
||||
return NS_ERROR_DOM_NOT_FOUND_ERR;
|
||||
}
|
||||
|
||||
nsresult attrResult;
|
||||
nsAutoString value;
|
||||
attrResult = mContent->GetAttr(nameSpaceID, nameAtom,
|
||||
*getter_AddRefs(prefix), value);
|
||||
|
||||
if (NS_CONTENT_ATTR_NOT_THERE != attrResult && NS_SUCCEEDED(attrResult)) {
|
||||
nimgr->GetNodeInfo(nameAtom, prefix, nameSpaceID, *getter_AddRefs(ni));
|
||||
NS_ENSURE_TRUE(ni, NS_ERROR_FAILURE);
|
||||
|
||||
nsDOMAttribute* domAttribute;
|
||||
domAttribute = new nsDOMAttribute(nsnull, ni, value);
|
||||
if (!domAttribute) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
rv = domAttribute->QueryInterface(NS_GET_IID(nsIDOMAttr),
|
||||
(void **)aReturn);
|
||||
} else {
|
||||
return NS_ERROR_DOM_NOT_FOUND_ERR;
|
||||
}
|
||||
|
||||
rv = mContent->UnsetAttr(nameSpaceID, nameAtom, PR_TRUE);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
nsresult
|
||||
nsDOMAttributeMap::SizeOfNamedNodeMap(nsIDOMNamedNodeMap* aMap,
|
||||
nsISizeOfHandler* aSizer,
|
||||
PRUint32* aResult)
|
||||
{
|
||||
if (!aResult) return NS_ERROR_NULL_POINTER;
|
||||
*aResult = sizeof(nsDOMAttributeMap);
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
@@ -1,73 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsDOMAttributeMap_h___
|
||||
#define nsDOMAttributeMap_h___
|
||||
|
||||
#include "nsIDOMNamedNodeMap.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsString.h"
|
||||
#include "plhash.h"
|
||||
|
||||
class nsIContent;
|
||||
|
||||
// Helper class that implements the nsIDOMNamedNodeMap interface.
|
||||
class nsDOMAttributeMap : public nsIDOMNamedNodeMap
|
||||
{
|
||||
public:
|
||||
nsDOMAttributeMap(nsIContent* aContent);
|
||||
virtual ~nsDOMAttributeMap();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMNamedNodeMap interface
|
||||
NS_DECL_NSIDOMNAMEDNODEMAP
|
||||
|
||||
void DropReference();
|
||||
|
||||
#ifdef DEBUG
|
||||
static nsresult SizeOfNamedNodeMap(nsIDOMNamedNodeMap* aMap,
|
||||
nsISizeOfHandler* aSizer,
|
||||
PRUint32* aResult);
|
||||
#endif
|
||||
|
||||
private:
|
||||
nsIContent* mContent; // Weak reference
|
||||
};
|
||||
|
||||
|
||||
#endif /* nsDOMAttributeMap_h___ */
|
||||
@@ -1,239 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsDOMDocumentType.h"
|
||||
#include "nsDOMAttributeMap.h"
|
||||
#include "nsIDOMNamedNodeMap.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
|
||||
nsresult
|
||||
NS_NewDOMDocumentType(nsIDOMDocumentType** aDocType,
|
||||
const nsAString& aName,
|
||||
nsIDOMNamedNodeMap *aEntities,
|
||||
nsIDOMNamedNodeMap *aNotations,
|
||||
const nsAString& aPublicId,
|
||||
const nsAString& aSystemId,
|
||||
const nsAString& aInternalSubset)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aDocType);
|
||||
|
||||
*aDocType = new nsDOMDocumentType(aName, aEntities, aNotations, aPublicId,
|
||||
aSystemId, aInternalSubset);
|
||||
if (!*aDocType) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
NS_ADDREF(*aDocType);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsDOMDocumentType::nsDOMDocumentType(const nsAString& aName,
|
||||
nsIDOMNamedNodeMap *aEntities,
|
||||
nsIDOMNamedNodeMap *aNotations,
|
||||
const nsAString& aPublicId,
|
||||
const nsAString& aSystemId,
|
||||
const nsAString& aInternalSubset) :
|
||||
mName(aName),
|
||||
mPublicId(aPublicId),
|
||||
mSystemId(aSystemId),
|
||||
mInternalSubset(aInternalSubset)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
mEntities = aEntities;
|
||||
mNotations = aNotations;
|
||||
|
||||
NS_IF_ADDREF(mEntities);
|
||||
NS_IF_ADDREF(mNotations);
|
||||
}
|
||||
|
||||
nsDOMDocumentType::~nsDOMDocumentType()
|
||||
{
|
||||
NS_IF_RELEASE(mEntities);
|
||||
NS_IF_RELEASE(mNotations);
|
||||
}
|
||||
|
||||
|
||||
// QueryInterface implementation for nsDOMDocumentType
|
||||
NS_INTERFACE_MAP_BEGIN(nsDOMDocumentType)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIContent)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMDocumentType)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContent)
|
||||
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOM3Node, nsNode3Tearoff(this))
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(DocumentType)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(nsDOMDocumentType)
|
||||
NS_IMPL_RELEASE(nsDOMDocumentType)
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMDocumentType::GetName(nsAString& aName)
|
||||
{
|
||||
aName=mName;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
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::GetTag(nsIAtom*& aResult) const
|
||||
{
|
||||
aResult = NS_NewAtom(mName.get());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMDocumentType::GetNodeName(nsAString& aNodeName)
|
||||
{
|
||||
aNodeName=mName;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMDocumentType::GetNodeType(PRUint16* aNodeType)
|
||||
{
|
||||
*aNodeType = nsIDOMNode::DOCUMENT_TYPE_NODE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMDocumentType::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
nsDOMDocumentType* it = new nsDOMDocumentType(mName,
|
||||
mEntities,
|
||||
mNotations,
|
||||
mPublicId,
|
||||
mSystemId,
|
||||
mInternalSubset);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return it->QueryInterface(NS_GET_IID(nsIDOMNode), (void**) aReturn);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
NS_IMETHODIMP
|
||||
nsDOMDocumentType::SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
PRUint32 sum;
|
||||
nsGenericDOMDataNode::SizeOf(aSizer, &sum);
|
||||
PRUint32 ssize;
|
||||
mName.SizeOf(aSizer, &ssize);
|
||||
sum = sum - sizeof(mName) + ssize;
|
||||
if (mEntities) {
|
||||
PRBool recorded;
|
||||
aSizer->RecordObject((void*) mEntities, &recorded);
|
||||
if (!recorded) {
|
||||
PRUint32 size;
|
||||
nsDOMAttributeMap::SizeOfNamedNodeMap(mEntities, aSizer, &size);
|
||||
aSizer->AddSize(nsLayoutAtoms::xml_document_entities, size);
|
||||
}
|
||||
}
|
||||
if (mNotations) {
|
||||
PRBool recorded;
|
||||
aSizer->RecordObject((void*) mNotations, &recorded);
|
||||
if (!recorded) {
|
||||
PRUint32 size;
|
||||
nsDOMAttributeMap::SizeOfNamedNodeMap(mNotations, aSizer, &size);
|
||||
aSizer->AddSize(nsLayoutAtoms::xml_document_notations, size);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsDOMDocumentType_h___
|
||||
#define nsDOMDocumentType_h___
|
||||
|
||||
#include "nsIDOMDocumentType.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsGenericDOMDataNode.h"
|
||||
#include "nsString.h"
|
||||
#include "nsISizeOfHandler.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(const nsAString& 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
|
||||
|
||||
// nsIContent
|
||||
NS_IMETHOD GetTag(nsIAtom*& aResult) const;
|
||||
|
||||
#ifdef DEBUG
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
nsString mName;
|
||||
nsIDOMNamedNodeMap* mEntities;
|
||||
nsIDOMNamedNodeMap* mNotations;
|
||||
nsString mPublicId;
|
||||
nsString mSystemId;
|
||||
nsString mInternalSubset;
|
||||
};
|
||||
|
||||
extern nsresult
|
||||
NS_NewDOMDocumentType(nsIDOMDocumentType** aDocType,
|
||||
const nsAString& aName,
|
||||
nsIDOMNamedNodeMap *aEntities,
|
||||
nsIDOMNamedNodeMap *aNotations,
|
||||
const nsAString& aPublicId,
|
||||
const nsAString& aSystemId,
|
||||
const nsAString& aInternalSubset);
|
||||
|
||||
#endif // nsDOMDocument_h___
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,673 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsDocument_h___
|
||||
#define nsDocument_h___
|
||||
|
||||
#include "nsIDocument.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsWeakPtr.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsIDOMXMLDocument.h"
|
||||
#include "nsIDOMDocumentView.h"
|
||||
#include "nsIDOMDocumentXBL.h"
|
||||
#include "nsIDOMNSDocument.h"
|
||||
#include "nsIDOMDocumentStyle.h"
|
||||
#include "nsIDOMDocumentRange.h"
|
||||
#include "nsIDOMDocumentTraversal.h"
|
||||
#include "nsIDocumentObserver.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIDOMStyleSheetList.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsGenericDOMNodeList.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsIBindingManager.h"
|
||||
#include "nsINodeInfo.h"
|
||||
#include "nsIDOMDocumentEvent.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsIWordBreakerFactory.h"
|
||||
#include "nsILineBreakerFactory.h"
|
||||
#include "nsIScriptObjectPrincipal.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsScriptLoader.h"
|
||||
#include "nsICSSLoader.h"
|
||||
#include "nsIDOMXPathEvaluator.h"
|
||||
|
||||
#include "pldhash.h"
|
||||
|
||||
class nsIEventListenerManager;
|
||||
class nsDOMStyleSheetList;
|
||||
class nsIOutputStream;
|
||||
class nsDocument;
|
||||
class nsIDTD;
|
||||
class nsXPathDocumentTearoff;
|
||||
|
||||
|
||||
#if 0
|
||||
class nsPostData : public nsIPostData {
|
||||
public:
|
||||
nsPostData(PRBool aIsFile, char* aData);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
virtual PRBool IsFile();
|
||||
virtual const char* GetData();
|
||||
virtual PRInt32 GetDataLength();
|
||||
|
||||
protected:
|
||||
virtual ~nsPostData();
|
||||
|
||||
PRBool mIsFile;
|
||||
char* mData;
|
||||
PRInt32 mDataLen;
|
||||
};
|
||||
#endif
|
||||
|
||||
class nsDocHeaderData
|
||||
{
|
||||
public:
|
||||
nsDocHeaderData(nsIAtom* aField, const nsAString& aData)
|
||||
{
|
||||
mField = aField;
|
||||
NS_IF_ADDREF(mField);
|
||||
mData.Assign(aData);
|
||||
mNext = nsnull;
|
||||
}
|
||||
~nsDocHeaderData(void)
|
||||
{
|
||||
NS_IF_RELEASE(mField);
|
||||
if (nsnull != mNext) {
|
||||
delete mNext;
|
||||
mNext = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
nsIAtom* mField;
|
||||
nsString mData;
|
||||
nsDocHeaderData* mNext;
|
||||
};
|
||||
|
||||
// Represents the children of a document (prolog, epilog and
|
||||
// document element)
|
||||
class nsDocumentChildNodes : public nsGenericDOMNodeList
|
||||
{
|
||||
public:
|
||||
nsDocumentChildNodes(nsIDocument* aDocument);
|
||||
~nsDocumentChildNodes();
|
||||
|
||||
NS_IMETHOD GetLength(PRUint32* aLength);
|
||||
NS_IMETHOD Item(PRUint32 aIndex, nsIDOMNode** aReturn);
|
||||
|
||||
void DropReference();
|
||||
|
||||
protected:
|
||||
nsIDocument* mDocument;
|
||||
};
|
||||
|
||||
|
||||
class nsDOMStyleSheetList : public nsIDOMStyleSheetList,
|
||||
public nsIDocumentObserver
|
||||
{
|
||||
public:
|
||||
nsDOMStyleSheetList(nsIDocument *aDocument);
|
||||
virtual ~nsDOMStyleSheetList();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_DECL_NSIDOMSTYLESHEETLIST
|
||||
|
||||
NS_IMETHOD BeginUpdate(nsIDocument *aDocument) { return NS_OK; }
|
||||
NS_IMETHOD EndUpdate(nsIDocument *aDocument) { return NS_OK; }
|
||||
NS_IMETHOD BeginLoad(nsIDocument *aDocument) { return NS_OK; }
|
||||
NS_IMETHOD EndLoad(nsIDocument *aDocument) { return NS_OK; }
|
||||
NS_IMETHOD BeginReflow(nsIDocument *aDocument,
|
||||
nsIPresShell* aShell) { return NS_OK; }
|
||||
NS_IMETHOD EndReflow(nsIDocument *aDocument,
|
||||
nsIPresShell* aShell) { return NS_OK; }
|
||||
NS_IMETHOD ContentChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
nsISupports* aSubContent) { return NS_OK; }
|
||||
NS_IMETHOD ContentStatesChanged(nsIDocument* aDocument,
|
||||
nsIContent* aContent1,
|
||||
nsIContent* aContent2,
|
||||
PRInt32 aStateMask) { return NS_OK; }
|
||||
NS_IMETHOD AttributeChanged(nsIDocument *aDocument,
|
||||
nsIContent* aContent,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aModType,
|
||||
PRInt32 aHint) { return NS_OK; }
|
||||
NS_IMETHOD ContentAppended(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
PRInt32 aNewIndexInContainer)
|
||||
{ return NS_OK; }
|
||||
NS_IMETHOD ContentInserted(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer) { return NS_OK; }
|
||||
NS_IMETHOD ContentReplaced(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aOldChild,
|
||||
nsIContent* aNewChild,
|
||||
PRInt32 aIndexInContainer) { return NS_OK; }
|
||||
NS_IMETHOD ContentRemoved(nsIDocument *aDocument,
|
||||
nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer) { return NS_OK; }
|
||||
NS_IMETHOD StyleSheetAdded(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet);
|
||||
NS_IMETHOD StyleSheetRemoved(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet);
|
||||
NS_IMETHOD StyleSheetDisabledStateChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
PRBool aDisabled) { return NS_OK; }
|
||||
NS_IMETHOD StyleRuleChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule,
|
||||
PRInt32 aHint) { return NS_OK; }
|
||||
NS_IMETHOD StyleRuleAdded(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule) { return NS_OK; }
|
||||
NS_IMETHOD StyleRuleRemoved(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule) { return NS_OK; }
|
||||
NS_IMETHOD DocumentWillBeDestroyed(nsIDocument *aDocument);
|
||||
|
||||
protected:
|
||||
PRInt32 mLength;
|
||||
nsIDocument* mDocument;
|
||||
void* mScriptObject;
|
||||
};
|
||||
|
||||
|
||||
// Helper structs for the content->subdoc map
|
||||
|
||||
class SubDocMapEntry : public PLDHashEntryHdr
|
||||
{
|
||||
public:
|
||||
// Both of these are strong references
|
||||
nsIContent *mKey; // must be first, to look like PLDHashEntryStub
|
||||
nsIDocument *mSubDocument;
|
||||
};
|
||||
|
||||
struct FindContentData
|
||||
{
|
||||
FindContentData(nsIDocument *aSubDoc)
|
||||
: mSubDocument(aSubDoc), mResult(nsnull)
|
||||
{
|
||||
}
|
||||
|
||||
nsISupports *mSubDocument;
|
||||
nsIContent *mResult;
|
||||
};
|
||||
|
||||
|
||||
// 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 nsIDOMDocumentStyle,
|
||||
public nsIDOMDocumentView,
|
||||
public nsIDOMDocumentRange,
|
||||
public nsIDOMDocumentTraversal,
|
||||
public nsIDOMDocumentXBL,
|
||||
public nsIDOM3Node,
|
||||
public nsSupportsWeakReference,
|
||||
public nsIDOMEventReceiver,
|
||||
public nsIScriptObjectPrincipal
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD GetArena(nsIArena** aArena);
|
||||
|
||||
NS_IMETHOD Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup);
|
||||
NS_IMETHOD ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup);
|
||||
|
||||
NS_IMETHOD StartDocumentLoad(const char* aCommand,
|
||||
nsIChannel* aChannel,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsISupports* aContainer,
|
||||
nsIStreamListener **aDocListener,
|
||||
PRBool aReset = PR_TRUE,
|
||||
nsIContentSink* aContentSink = nsnull);
|
||||
|
||||
NS_IMETHOD StopDocumentLoad();
|
||||
|
||||
/**
|
||||
* Return the title of the document. May return null.
|
||||
*/
|
||||
virtual const nsString* GetDocumentTitle() const;
|
||||
|
||||
/**
|
||||
* Return the URL for the document. May return null.
|
||||
*/
|
||||
NS_IMETHOD GetDocumentURL(nsIURI** aURI) const;
|
||||
|
||||
/**
|
||||
* Return the principal responsible for this document.
|
||||
*/
|
||||
NS_IMETHOD GetPrincipal(nsIPrincipal **aPrincipal);
|
||||
|
||||
/**
|
||||
* Update principal responsible for this document to the intersection
|
||||
* of its previous value and aPrincipal, and return its new value.
|
||||
*/
|
||||
NS_IMETHOD AddPrincipal(nsIPrincipal *aPrincipal);
|
||||
|
||||
/**
|
||||
* Return the content language of this document.
|
||||
*/
|
||||
NS_IMETHOD GetContentLanguage(nsAString& aContentLanguage) const;
|
||||
|
||||
/**
|
||||
* Return the LoadGroup for the document. May return null.
|
||||
*/
|
||||
NS_IMETHOD GetDocumentLoadGroup(nsILoadGroup **aGroup) const;
|
||||
|
||||
/**
|
||||
* Return the base URL for relative URLs in the document. May return null (or the document URL).
|
||||
*/
|
||||
NS_IMETHOD GetBaseURL(nsIURI*& aURL) const;
|
||||
NS_IMETHOD SetBaseURL(nsIURI* aURL);
|
||||
|
||||
/**
|
||||
* Get/Set the base target of a link in a document.
|
||||
*/
|
||||
NS_IMETHOD GetBaseTarget(nsAString &aBaseTarget);
|
||||
NS_IMETHOD 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.
|
||||
*/
|
||||
NS_IMETHOD GetDocumentCharacterSet(nsAString& oCharsetID);
|
||||
NS_IMETHOD SetDocumentCharacterSet(const nsAString& aCharSetID);
|
||||
|
||||
NS_IMETHOD GetDocumentCharacterSetSource(PRInt32* aCharsetSource);
|
||||
NS_IMETHOD SetDocumentCharacterSetSource(PRInt32 aCharsetSource);
|
||||
|
||||
/**
|
||||
* Add an observer that gets notified whenever the charset changes.
|
||||
*/
|
||||
NS_IMETHOD AddCharSetObserver(nsIObserver* aObserver);
|
||||
|
||||
/**
|
||||
* Remove a charset observer.
|
||||
*/
|
||||
NS_IMETHOD RemoveCharSetObserver(nsIObserver* aObserver);
|
||||
|
||||
#ifdef IBMBIDI
|
||||
/**
|
||||
* Check if the document contains bidi data.
|
||||
* If so, we have to apply the Unicode Bidi Algorithm.
|
||||
*/
|
||||
NS_IMETHOD GetBidiEnabled(PRBool* aBidiEnabled) const;
|
||||
/**
|
||||
* Indicate the document contains RTL characters.
|
||||
*/
|
||||
NS_IMETHOD SetBidiEnabled(PRBool aBidiEnabled);
|
||||
#endif // IBMBIDI
|
||||
|
||||
/**
|
||||
* Return the Line Breaker for the document
|
||||
*/
|
||||
NS_IMETHOD GetLineBreaker(nsILineBreaker** aResult) ;
|
||||
NS_IMETHOD SetLineBreaker(nsILineBreaker* aLineBreaker) ;
|
||||
NS_IMETHOD GetWordBreaker(nsIWordBreaker** aResult) ;
|
||||
NS_IMETHOD SetWordBreaker(nsIWordBreaker* aWordBreaker) ;
|
||||
|
||||
/**
|
||||
* Access HTTP header data (this may also get set from other sources, like
|
||||
* HTML META tags).
|
||||
*/
|
||||
NS_IMETHOD GetHeaderData(nsIAtom* aHeaderField,
|
||||
nsAString& aData) const;
|
||||
NS_IMETHOD 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).
|
||||
*/
|
||||
#if 0
|
||||
// XXX Temp hack: moved to nsMarkupDocument
|
||||
NS_IMETHOD CreateShell(nsIPresContext* aContext,
|
||||
nsIViewManager* aViewManager,
|
||||
nsIStyleSet* aStyleSet,
|
||||
nsIPresShell** aInstancePtrResult);
|
||||
#endif
|
||||
virtual PRBool DeleteShell(nsIPresShell* aShell);
|
||||
virtual PRInt32 GetNumberOfShells();
|
||||
NS_IMETHOD GetShellAt(PRInt32 aIndex, nsIPresShell** aShell);
|
||||
|
||||
/**
|
||||
* Return the parent document of this document. Will return null
|
||||
* unless this document is within a compound document and has a parent.
|
||||
*/
|
||||
NS_IMETHOD GetParentDocument(nsIDocument** aParent);
|
||||
NS_IMETHOD SetParentDocument(nsIDocument* aParent);
|
||||
|
||||
NS_IMETHOD SetSubDocumentFor(nsIContent *aContent, nsIDocument* aSubDoc);
|
||||
NS_IMETHOD GetSubDocumentFor(nsIContent *aContent, nsIDocument** aSubDoc);
|
||||
NS_IMETHOD FindContentForSubDocument(nsIDocument *aDocument,
|
||||
nsIContent **aContent);
|
||||
|
||||
/**
|
||||
* Return the root content object for this document.
|
||||
*/
|
||||
NS_IMETHOD GetRootContent(nsIContent** aRoot);
|
||||
NS_IMETHOD SetRootContent(nsIContent* aRoot);
|
||||
|
||||
/**
|
||||
* Get the direct children of the document - content in
|
||||
* the prolog, the root content and content in the epilog.
|
||||
*/
|
||||
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent*& aResult) const;
|
||||
NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aIndex) const;
|
||||
NS_IMETHOD GetChildCount(PRInt32& aCount);
|
||||
|
||||
/**
|
||||
* Get the style sheets owned by this document.
|
||||
* These are ordered, highest priority last
|
||||
*/
|
||||
NS_IMETHOD GetNumberOfStyleSheets(PRInt32* aCount);
|
||||
NS_IMETHOD GetStyleSheetAt(PRInt32 aIndex, nsIStyleSheet** aSheet);
|
||||
NS_IMETHOD GetIndexOfStyleSheet(nsIStyleSheet* aSheet, PRInt32* aIndex);
|
||||
virtual void AddStyleSheet(nsIStyleSheet* aSheet, PRUint32 aFlags);
|
||||
virtual void RemoveStyleSheet(nsIStyleSheet* aSheet);
|
||||
|
||||
NS_IMETHOD UpdateStyleSheets(nsISupportsArray* aOldSheets,
|
||||
nsISupportsArray* aNewSheets);
|
||||
virtual void AddStyleSheetToStyleSets(nsIStyleSheet* aSheet);
|
||||
virtual void RemoveStyleSheetFromStyleSets(nsIStyleSheet* aSheet);
|
||||
|
||||
NS_IMETHOD InsertStyleSheetAt(nsIStyleSheet* aSheet, PRInt32 aIndex,
|
||||
PRBool aNotify);
|
||||
virtual void SetStyleSheetDisabledState(nsIStyleSheet* aSheet,
|
||||
PRBool mDisabled);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
NS_IMETHOD GetScriptGlobalObject(nsIScriptGlobalObject** aGlobalObject);
|
||||
NS_IMETHOD SetScriptGlobalObject(nsIScriptGlobalObject* aGlobalObject);
|
||||
|
||||
/**
|
||||
* Get the name space manager for this document
|
||||
*/
|
||||
NS_IMETHOD GetNameSpaceManager(nsINameSpaceManager*& aManager);
|
||||
|
||||
/**
|
||||
* Get the script loader for this document
|
||||
*/
|
||||
NS_IMETHOD GetScriptLoader(nsIScriptLoader** aScriptLoader);
|
||||
|
||||
/**
|
||||
* Get the focus controller for this document
|
||||
* This can usually be gotten through the ScriptGlobalObject, but
|
||||
* it is set to null during document destruction, when we still might
|
||||
* need to fire focus events.
|
||||
*/
|
||||
NS_IMETHOD GetFocusController(nsIFocusController** aFocusController);
|
||||
|
||||
/**
|
||||
* 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 by content nodes to propagate
|
||||
// notifications to document observers.
|
||||
NS_IMETHOD BeginUpdate();
|
||||
NS_IMETHOD EndUpdate();
|
||||
NS_IMETHOD BeginLoad();
|
||||
NS_IMETHOD EndLoad();
|
||||
NS_IMETHOD ContentChanged(nsIContent* aContent,
|
||||
nsISupports* aSubContent);
|
||||
NS_IMETHOD ContentStatesChanged(nsIContent* aContent1,
|
||||
nsIContent* aContent2,
|
||||
PRInt32 aStateMask);
|
||||
|
||||
NS_IMETHOD AttributeWillChange(nsIContent* aChild,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aAttribute);
|
||||
NS_IMETHOD AttributeChanged(nsIContent* aChild,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
PRInt32 aModType,
|
||||
PRInt32 aHint);
|
||||
NS_IMETHOD ContentAppended(nsIContent* aContainer,
|
||||
PRInt32 aNewIndexInContainer);
|
||||
NS_IMETHOD ContentInserted(nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer);
|
||||
NS_IMETHOD ContentReplaced(nsIContent* aContainer,
|
||||
nsIContent* aOldChild,
|
||||
nsIContent* aNewChild,
|
||||
PRInt32 aIndexInContainer);
|
||||
NS_IMETHOD ContentRemoved(nsIContent* aContainer,
|
||||
nsIContent* aChild,
|
||||
PRInt32 aIndexInContainer);
|
||||
|
||||
NS_IMETHOD StyleRuleChanged(nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule,
|
||||
PRInt32 aHint); // See nsStyleConsts fot hint values
|
||||
NS_IMETHOD StyleRuleAdded(nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule);
|
||||
NS_IMETHOD StyleRuleRemoved(nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule);
|
||||
|
||||
NS_IMETHOD FlushPendingNotifications(PRBool aFlushReflows = PR_TRUE,
|
||||
PRBool aUpdateViews = PR_FALSE);
|
||||
NS_IMETHOD GetAndIncrementContentID(PRInt32* aID);
|
||||
NS_IMETHOD GetBindingManager(nsIBindingManager** aResult);
|
||||
NS_IMETHOD GetNodeInfoManager(nsINodeInfoManager*& aNodeInfoManager);
|
||||
NS_IMETHOD AddReference(void *aKey, nsISupports *aReference);
|
||||
NS_IMETHOD RemoveReference(void *aKey, nsISupports **aOldReference);
|
||||
NS_IMETHOD SetContainer(nsISupports *aContainer);
|
||||
NS_IMETHOD GetContainer(nsISupports **aContainer);
|
||||
|
||||
// nsIDOMNode
|
||||
NS_DECL_NSIDOMNODE
|
||||
|
||||
// nsIDOM3Node
|
||||
NS_DECL_NSIDOM3NODE
|
||||
|
||||
// nsIDOMDocument
|
||||
NS_DECL_NSIDOMDOCUMENT
|
||||
|
||||
// nsIDOMXMLDocument
|
||||
NS_DECL_NSIDOMXMLDOCUMENT
|
||||
|
||||
// nsIDOMNSDocument
|
||||
NS_DECL_NSIDOMNSDOCUMENT
|
||||
|
||||
// nsIDOMDocumentEvent
|
||||
NS_DECL_NSIDOMDOCUMENTEVENT
|
||||
|
||||
// nsIDOMDocumentStyle
|
||||
NS_DECL_NSIDOMDOCUMENTSTYLE
|
||||
|
||||
// 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(nsIEventListenerManager** aInstancePtrResult);
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent *aEvent);
|
||||
|
||||
// nsIDOMEventTarget interface
|
||||
NS_IMETHOD AddEventListener(const nsAString& aType,
|
||||
nsIDOMEventListener* aListener,
|
||||
PRBool aUseCapture);
|
||||
NS_IMETHOD RemoveEventListener(const nsAString& aType,
|
||||
nsIDOMEventListener* aListener,
|
||||
PRBool aUseCapture);
|
||||
NS_IMETHOD DispatchEvent(nsIDOMEvent* aEvent, PRBool *_retval);
|
||||
|
||||
|
||||
NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus);
|
||||
|
||||
NS_IMETHOD_(PRBool) EventCaptureRegistration(PRInt32 aCapturerIncrement);
|
||||
|
||||
|
||||
NS_IMETHOD SetDocumentURL(nsIURI* aURI);
|
||||
|
||||
virtual nsresult Init();
|
||||
|
||||
protected:
|
||||
// subclass hooks for sheet ordering
|
||||
virtual void InternalAddStyleSheet(nsIStyleSheet* aSheet,
|
||||
PRUint32 aFlags);
|
||||
virtual void InternalInsertStyleSheetAt(nsIStyleSheet* aSheet,
|
||||
PRInt32 aIndex);
|
||||
|
||||
nsDocument();
|
||||
virtual ~nsDocument();
|
||||
|
||||
nsIArena* mArena;
|
||||
nsString mDocumentTitle;
|
||||
nsIURI* mDocumentURL;
|
||||
nsCOMPtr<nsIURI> mDocumentBaseURL;
|
||||
nsIPrincipal* mPrincipal;
|
||||
nsWeakPtr mDocumentLoadGroup;
|
||||
nsWeakPtr mDocumentContainer;
|
||||
|
||||
nsString mCharacterSet;
|
||||
PRInt32 mCharacterSetSource;
|
||||
|
||||
nsVoidArray mCharSetObservers;
|
||||
nsIDocument* mParentDocument;
|
||||
|
||||
PLDHashTable *mSubDocuments;
|
||||
|
||||
nsVoidArray mPresShells;
|
||||
nsCOMPtr<nsISupportsArray> mChildren; // contains owning references
|
||||
nsIContent* mRootContent; // a weak reference to the only element in
|
||||
// mChildren, or null if no such element exists.
|
||||
nsAutoVoidArray mStyleSheets;
|
||||
nsAutoVoidArray mObservers; // basically always has at least 1 entry
|
||||
nsCOMPtr<nsIScriptGlobalObject> mScriptGlobalObject;
|
||||
nsIEventListenerManager* mListenerManager;
|
||||
PRBool mInDestructor;
|
||||
nsCOMPtr<nsIDOMStyleSheetList> mDOMStyleSheets;
|
||||
nsINameSpaceManager* mNameSpaceManager;
|
||||
nsCOMPtr<nsIScriptLoader> mScriptLoader;
|
||||
nsDocHeaderData* mHeaderData;
|
||||
nsCOMPtr<nsILineBreaker> mLineBreaker;
|
||||
nsCOMPtr<nsIWordBreaker> mWordBreaker;
|
||||
nsDocumentChildNodes* mChildNodes;
|
||||
// A content ID counter used to give a monotonically increasing ID to the content
|
||||
// objects in the document's content model
|
||||
PRInt32 mNextContentID;
|
||||
|
||||
#ifdef IBMBIDI
|
||||
PRBool mBidiEnabled;
|
||||
#endif // IBMBIDI
|
||||
|
||||
// disk file members
|
||||
nsCOMPtr<nsIURI> mDocumentURI;
|
||||
PRInt32 mModCount;
|
||||
|
||||
nsIDTD* mDTD;
|
||||
|
||||
nsCOMPtr<nsIBindingManager> mBindingManager;
|
||||
nsCOMPtr<nsINodeInfoManager> mNodeInfoManager; // OWNER
|
||||
|
||||
PRBool mIsGoingAway; // True if the document is being destroyed.
|
||||
|
||||
nsSupportsHashtable* mBoxObjectTable;
|
||||
PRInt32 mNumCapturers; //Number of capturing event handlers in doc. Used to optimize event delivery.
|
||||
|
||||
nsSupportsHashtable mContentWrapperHash;
|
||||
|
||||
nsCOMPtr<nsICSSLoader> mCSSLoader;
|
||||
nsWeakPtr mFocusController;
|
||||
|
||||
nsString mContentLanguage;
|
||||
nsString mContentType;
|
||||
|
||||
private:
|
||||
// These are not implemented and not supported.
|
||||
nsDocument(const nsDocument& aOther);
|
||||
nsDocument& operator=(const nsDocument& aOther);
|
||||
|
||||
nsXPathDocumentTearoff* mXPathDocument;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* nsDocument_h___ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,445 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#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 "nsDOMError.h"
|
||||
|
||||
|
||||
class nsDocumentFragment : public nsGenericContainerElement,
|
||||
public nsIDocumentFragment,
|
||||
public nsIDOM3Node
|
||||
{
|
||||
public:
|
||||
nsDocumentFragment(nsIDocument* aOwnerDocument);
|
||||
virtual ~nsDocumentFragment();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// interface nsIDocumentFragment
|
||||
NS_IMETHOD DisconnectChildren();
|
||||
NS_IMETHOD ReconnectChildren();
|
||||
NS_IMETHOD DropChildReferences();
|
||||
|
||||
// interface nsIDOMDocumentFragment
|
||||
NS_IMETHOD GetNodeName(nsAString& aNodeName)
|
||||
{ return nsGenericContainerElement::GetNodeName(aNodeName); }
|
||||
NS_IMETHOD GetNodeValue(nsAString& aNodeValue)
|
||||
{ return nsGenericContainerElement::GetNodeValue(aNodeValue); }
|
||||
NS_IMETHOD SetNodeValue(const nsAString& aNodeValue)
|
||||
{ return nsGenericContainerElement::SetNodeValue(aNodeValue); }
|
||||
NS_IMETHOD GetNodeType(PRUint16* aNodeType);
|
||||
NS_IMETHOD GetParentNode(nsIDOMNode** aParentNode)
|
||||
{ return nsGenericContainerElement::GetParentNode(aParentNode); }
|
||||
NS_IMETHOD GetChildNodes(nsIDOMNodeList** aChildNodes)
|
||||
{ return nsGenericContainerElement::GetChildNodes(aChildNodes); }
|
||||
NS_IMETHOD GetFirstChild(nsIDOMNode** aFirstChild)
|
||||
{ return nsGenericContainerElement::GetFirstChild(aFirstChild); }
|
||||
NS_IMETHOD GetLastChild(nsIDOMNode** aLastChild)
|
||||
{ return nsGenericContainerElement::GetLastChild(aLastChild); }
|
||||
NS_IMETHOD GetPreviousSibling(nsIDOMNode** aPreviousSibling)
|
||||
{ return nsGenericContainerElement::GetPreviousSibling(aPreviousSibling); }
|
||||
NS_IMETHOD GetNextSibling(nsIDOMNode** aNextSibling)
|
||||
{ return nsGenericContainerElement::GetNextSibling(aNextSibling); }
|
||||
NS_IMETHOD GetAttributes(nsIDOMNamedNodeMap** aAttributes)
|
||||
{
|
||||
*aAttributes = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD GetOwnerDocument(nsIDOMDocument** aOwnerDocument);
|
||||
NS_IMETHOD InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild,
|
||||
nsIDOMNode** aReturn)
|
||||
{ return nsGenericContainerElement::InsertBefore(aNewChild, aRefChild,
|
||||
aReturn); }
|
||||
NS_IMETHOD ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild,
|
||||
nsIDOMNode** aReturn)
|
||||
{ return nsGenericContainerElement::ReplaceChild(aNewChild, aOldChild,
|
||||
aReturn); }
|
||||
NS_IMETHOD RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
||||
{ return nsGenericContainerElement::RemoveChild(aOldChild, aReturn); }
|
||||
NS_IMETHOD AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn)
|
||||
{ return nsGenericContainerElement::AppendChild(aNewChild, aReturn); }
|
||||
NS_IMETHOD HasChildNodes(PRBool* aReturn)
|
||||
{ return nsGenericContainerElement::HasChildNodes(aReturn); }
|
||||
NS_IMETHOD HasAttributes(PRBool* aReturn)
|
||||
{ return nsGenericContainerElement::HasAttributes(aReturn); }
|
||||
NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn);
|
||||
NS_IMETHOD GetPrefix(nsAString& aPrefix)
|
||||
{ return nsGenericContainerElement::GetPrefix(aPrefix); }
|
||||
NS_IMETHOD SetPrefix(const nsAString& aPrefix);
|
||||
NS_IMETHOD GetNamespaceURI(nsAString& aNamespaceURI)
|
||||
{ return nsGenericContainerElement::GetNamespaceURI(aNamespaceURI); }
|
||||
NS_IMETHOD GetLocalName(nsAString& aLocalName)
|
||||
{ return nsGenericContainerElement::GetLocalName(aLocalName); }
|
||||
NS_IMETHOD Normalize()
|
||||
{ return nsGenericContainerElement::Normalize(); }
|
||||
NS_IMETHOD IsSupported(const nsAString& aFeature,
|
||||
const nsAString& aVersion,
|
||||
PRBool* aReturn)
|
||||
{ return nsGenericContainerElement::IsSupported(aFeature, aVersion,
|
||||
aReturn); }
|
||||
|
||||
// nsIDOM3Node
|
||||
NS_IMETHOD GetBaseURI(nsAString& aURI)
|
||||
{ aURI.Truncate(); return NS_OK; }
|
||||
NS_IMETHOD CompareTreePosition(nsIDOMNode *aOther, PRUint16* aReturn);
|
||||
NS_IMETHOD IsSameNode(nsIDOMNode *aOther, PRBool* aReturn);
|
||||
NS_IMETHOD LookupNamespacePrefix(const nsAString& aNamespaceURI,
|
||||
nsAString& aPrefix) {
|
||||
aPrefix.Truncate(); return NS_OK;
|
||||
}
|
||||
NS_IMETHOD LookupNamespaceURI(const nsAString& aNamespacePrefix,
|
||||
nsAString& aNamespaceURI) {
|
||||
aNamespaceURI.Truncate(); return NS_OK;
|
||||
}
|
||||
|
||||
// nsIContent
|
||||
NS_IMETHOD SetParent(nsIContent* aParent)
|
||||
{ return NS_OK; }
|
||||
NS_IMETHOD SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
const nsAString& aValue,
|
||||
PRBool aNotify)
|
||||
{ return NS_OK; }
|
||||
NS_IMETHOD SetAttr(nsINodeInfo* aNodeInfo,
|
||||
const nsAString& aValue,
|
||||
PRBool aNotify)
|
||||
{ return NS_OK; }
|
||||
NS_IMETHOD GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
nsAString& aResult) const
|
||||
{ return NS_CONTENT_ATTR_NOT_THERE; }
|
||||
NS_IMETHOD GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
nsIAtom*& aPrefix, nsAString& aResult) const
|
||||
{ return NS_CONTENT_ATTR_NOT_THERE; }
|
||||
NS_IMETHOD UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
||||
PRBool aNotify)
|
||||
{ return NS_OK; }
|
||||
NS_IMETHOD GetAttrNameAt(PRInt32 aIndex,
|
||||
PRInt32& aNameSpaceID,
|
||||
nsIAtom*& aName,
|
||||
nsIAtom*& aPrefix) const
|
||||
{
|
||||
aName = nsnull;
|
||||
aPrefix = nsnull;
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aEventStatus);
|
||||
*aEventStatus = nsEventStatus_eIgnore;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const {
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
*aResult = sizeof(*this);
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIDocument> mOwnerDocument;
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewDocumentFragment(nsIDOMDocumentFragment** aInstancePtrResult,
|
||||
nsIDocument* aOwnerDocument)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aInstancePtrResult);
|
||||
|
||||
nsCOMPtr<nsINodeInfoManager> nimgr;
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
if (aOwnerDocument) {
|
||||
rv = aOwnerDocument->GetNodeInfoManager(*getter_AddRefs(nimgr));
|
||||
} else {
|
||||
rv = nsNodeInfoManager::GetAnonymousManager(*getter_AddRefs(nimgr));
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = nimgr->GetNodeInfo(NS_LITERAL_STRING("#document-fragment"),
|
||||
nsnull, kNameSpaceID_None,
|
||||
*getter_AddRefs(nodeInfo));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsDocumentFragment* it = new nsDocumentFragment(aOwnerDocument);
|
||||
if (!it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
rv = it->Init(nodeInfo);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
delete it;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
*aInstancePtrResult = NS_STATIC_CAST(nsIDOMDocumentFragment *, it);
|
||||
|
||||
NS_ADDREF(*aInstancePtrResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsDocumentFragment::nsDocumentFragment(nsIDocument* aOwnerDocument)
|
||||
{
|
||||
mOwnerDocument = aOwnerDocument;
|
||||
}
|
||||
|
||||
nsDocumentFragment::~nsDocumentFragment()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// QueryInterface implementation for nsDocumentFragment
|
||||
NS_INTERFACE_MAP_BEGIN(nsDocumentFragment)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDocumentFragment)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMDocumentFragment)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOM3Node)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIContent)
|
||||
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::DisconnectChildren()
|
||||
{
|
||||
nsCOMPtr<nsIContent> child;
|
||||
PRInt32 i, count;
|
||||
|
||||
ChildCount(count);
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
ChildAt(i, *getter_AddRefs(child));
|
||||
NS_ASSERTION(child, "Bad content container");
|
||||
|
||||
child->SetParent(nsnull);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocumentFragment::ReconnectChildren()
|
||||
{
|
||||
nsCOMPtr<nsIContent> child, parent;
|
||||
PRInt32 i, count = 0;
|
||||
|
||||
ChildCount(count);
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
ChildAt(i, *getter_AddRefs(child));
|
||||
NS_ASSERTION(child, "Bad content container");
|
||||
|
||||
child->GetParent(*getter_AddRefs(parent));
|
||||
|
||||
if (parent) {
|
||||
PRInt32 indx = -1;
|
||||
|
||||
// This is potentially a O(n**2) operation, but it should only
|
||||
// happen in error cases (such as out of memory or something
|
||||
// similar) so we don't care for now.
|
||||
|
||||
parent->IndexOf(child, indx);
|
||||
|
||||
if (indx >= 0) {
|
||||
parent->RemoveChildAt(indx, PR_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
child->SetParent(this);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocumentFragment::DropChildReferences()
|
||||
{
|
||||
mChildren.Clear();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocumentFragment::GetNodeType(PRUint16* aNodeType)
|
||||
{
|
||||
*aNodeType = (PRUint16)nsIDOMNode::DOCUMENT_FRAGMENT_NODE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocumentFragment::GetOwnerDocument(nsIDOMDocument** aOwnerDocument)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aOwnerDocument);
|
||||
|
||||
if (!mOwnerDocument) {
|
||||
*aOwnerDocument = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return mOwnerDocument->QueryInterface(NS_GET_IID(nsIDOMDocument),
|
||||
(void **)aOwnerDocument);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocumentFragment::SetPrefix(const nsAString& aPrefix)
|
||||
{
|
||||
return NS_ERROR_DOM_NAMESPACE_ERR;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocumentFragment::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aReturn);
|
||||
*aReturn = nsnull;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIDOMDocumentFragment> newFragment;
|
||||
|
||||
rv = NS_NewDocumentFragment(getter_AddRefs(newFragment), mOwnerDocument);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (aDeep) {
|
||||
nsCOMPtr<nsIDOMNodeList> childNodes;
|
||||
|
||||
GetChildNodes(getter_AddRefs(childNodes));
|
||||
if (childNodes) {
|
||||
PRUint32 index, count;
|
||||
childNodes->GetLength(&count);
|
||||
|
||||
for (index = 0; index < count; ++index) {
|
||||
nsCOMPtr<nsIDOMNode> child;
|
||||
childNodes->Item(index, getter_AddRefs(child));
|
||||
if (child) {
|
||||
nsCOMPtr<nsIDOMNode> newChild;
|
||||
rv = child->CloneNode(PR_TRUE, getter_AddRefs(newChild));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> dummyNode;
|
||||
rv = newFragment->AppendChild(newChild,
|
||||
getter_AddRefs(dummyNode));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
} // End of for loop
|
||||
} // if (childNodes)
|
||||
} // if (aDeep)
|
||||
|
||||
return CallQueryInterface(newFragment, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocumentFragment::CompareTreePosition(nsIDOMNode* aOther,
|
||||
PRUint16* aReturn)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aOther);
|
||||
PRUint32 mask = nsIDOMNode::TREE_POSITION_DISCONNECTED;
|
||||
|
||||
PRBool sameNode = PR_FALSE;
|
||||
IsSameNode(aOther, &sameNode);
|
||||
if (sameNode) {
|
||||
mask |= nsIDOMNode::TREE_POSITION_SAME_NODE;
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIDOMNode> other(aOther);
|
||||
while (other) {
|
||||
IsSameNode(other, &sameNode);
|
||||
if (sameNode) {
|
||||
mask |= nsIDOMNode::TREE_POSITION_DESCENDANT;
|
||||
break;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMNode> tmp(other);
|
||||
tmp->GetParentNode(getter_AddRefs(other));
|
||||
if (!other) {
|
||||
// No parent. Check to see if we're at an attribute node.
|
||||
PRUint16 nodeType = 0;
|
||||
tmp->GetNodeType(&nodeType);
|
||||
if (nodeType == nsIDOMNode::ATTRIBUTE_NODE) {
|
||||
// If we are, let's get the owner element and continue up the tree
|
||||
nsCOMPtr<nsIDOMAttr> attr(do_QueryInterface(tmp));
|
||||
nsCOMPtr<nsIDOMElement> owner;
|
||||
attr->GetOwnerElement(getter_AddRefs(owner));
|
||||
other = do_QueryInterface(owner);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*aReturn = mask;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocumentFragment::IsSameNode(nsIDOMNode* aOther,
|
||||
PRBool* aReturn)
|
||||
{
|
||||
PRBool sameNode = PR_FALSE;
|
||||
|
||||
if (this == aOther) {
|
||||
sameNode = PR_TRUE;
|
||||
}
|
||||
|
||||
*aReturn = sameNode;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,507 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsIFrameLoader.h"
|
||||
#include "nsIDOMHTMLIFrameElement.h"
|
||||
#include "nsIDOMHTMLFrameElement.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIPresContext.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 "nsIWebShell.h"
|
||||
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsICodebasePrincipal.h"
|
||||
|
||||
#include "nsIURI.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
|
||||
|
||||
// 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.
|
||||
#define MAX_DEPTH_CONTENT_FRAMES 8
|
||||
|
||||
|
||||
class nsFrameLoader : public nsIFrameLoader
|
||||
{
|
||||
public:
|
||||
nsFrameLoader();
|
||||
virtual ~nsFrameLoader();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIFrameLoader
|
||||
NS_IMETHOD Init(nsIContent *aOwner);
|
||||
NS_IMETHOD LoadFrame();
|
||||
NS_IMETHOD GetDocShell(nsIDocShell **aDocShell);
|
||||
NS_IMETHOD Destroy();
|
||||
|
||||
protected:
|
||||
nsresult GetPresContext(nsIPresContext **aPresContext);
|
||||
nsresult EnsureDocShell();
|
||||
void GetURL(nsAString& aURL);
|
||||
|
||||
nsCOMPtr<nsIDocShell> mDocShell;
|
||||
|
||||
nsIContent *mOwnerContent; // WEAK
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewFrameLoader(nsIFrameLoader **aFrameLoader)
|
||||
{
|
||||
*aFrameLoader = new nsFrameLoader();
|
||||
NS_ENSURE_TRUE(*aFrameLoader, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
NS_ADDREF(*aFrameLoader);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsFrameLoader::nsFrameLoader()
|
||||
: mOwnerContent(nsnull)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
nsFrameLoader::~nsFrameLoader()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
|
||||
// QueryInterface implementation for nsFrameLoader
|
||||
NS_INTERFACE_MAP_BEGIN(nsFrameLoader)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIFrameLoader)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(nsFrameLoader);
|
||||
NS_IMPL_RELEASE(nsFrameLoader);
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFrameLoader::Init(nsIContent *aOwner)
|
||||
{
|
||||
mOwnerContent = aOwner; // WEAK
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFrameLoader::LoadFrame()
|
||||
{
|
||||
NS_ENSURE_TRUE(mOwnerContent, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
nsresult rv = EnsureDocShell();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
mOwnerContent->GetDocument(*getter_AddRefs(doc));
|
||||
if (!doc) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsAutoString src;
|
||||
GetURL(src);
|
||||
|
||||
src.Trim(" \t\n\r");
|
||||
|
||||
if (src.IsEmpty()) {
|
||||
src.Assign(NS_LITERAL_STRING("about:blank"));
|
||||
}
|
||||
|
||||
// Make an absolute URI
|
||||
nsCOMPtr<nsIURI> base_uri;
|
||||
doc->GetBaseURL(*getter_AddRefs(base_uri));
|
||||
|
||||
nsAutoString doc_charset;
|
||||
doc->GetDocumentCharacterSet(doc_charset);
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
rv = NS_NewURI(getter_AddRefs(uri), src,
|
||||
doc_charset.IsEmpty() ? nsnull :
|
||||
NS_ConvertUCS2toUTF8(doc_charset).get(), base_uri);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Check for security
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan =
|
||||
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
|
||||
mDocShell->CreateLoadInfo(getter_AddRefs(loadInfo));
|
||||
NS_ENSURE_TRUE(loadInfo, NS_ERROR_FAILURE);
|
||||
|
||||
// Get referring URL
|
||||
nsCOMPtr<nsIURI> referrer;
|
||||
nsCOMPtr<nsIPrincipal> principal;
|
||||
rv = secMan->GetSubjectPrincipal(getter_AddRefs(principal));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// If we were called from script, get the referring URL from the script
|
||||
|
||||
if (principal) {
|
||||
nsCOMPtr<nsICodebasePrincipal> codebase(do_QueryInterface(principal));
|
||||
|
||||
if (codebase) {
|
||||
rv = codebase->GetURI(getter_AddRefs(referrer));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
// Pass the script principal to the docshell
|
||||
|
||||
loadInfo->SetOwner(principal);
|
||||
}
|
||||
|
||||
if (!referrer) {
|
||||
// We're not being called form script, tell the docshell
|
||||
// to inherit an owner from the current document.
|
||||
|
||||
loadInfo->SetInheritOwner(PR_TRUE);
|
||||
|
||||
referrer = base_uri;
|
||||
}
|
||||
|
||||
loadInfo->SetReferrer(referrer);
|
||||
|
||||
// Check if we are allowed to load absURL
|
||||
rv = secMan->CheckLoadURI(referrer, uri,
|
||||
nsIScriptSecurityManager::STANDARD);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv; // We're not
|
||||
}
|
||||
|
||||
// Kick off the load...
|
||||
rv = mDocShell->LoadURI(uri, loadInfo, nsIWebNavigation::LOAD_FLAGS_NONE,
|
||||
PR_FALSE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to load URL");
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFrameLoader::GetDocShell(nsIDocShell **aDocShell)
|
||||
{
|
||||
*aDocShell = nsnull;
|
||||
|
||||
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(*getter_AddRefs(doc));
|
||||
|
||||
if (doc) {
|
||||
doc->SetSubDocumentFor(mOwnerContent, nsnull);
|
||||
}
|
||||
|
||||
mOwnerContent = nsnull;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIBaseWindow> base_win(do_QueryInterface(mDocShell));
|
||||
|
||||
if (base_win) {
|
||||
base_win->Destroy();
|
||||
}
|
||||
|
||||
mDocShell = nsnull;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFrameLoader::GetPresContext(nsIPresContext **aPresContext)
|
||||
{
|
||||
*aPresContext = nsnull;
|
||||
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
mOwnerContent->GetDocument(*getter_AddRefs(doc));
|
||||
|
||||
while (doc) {
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
doc->GetShellAt(0, getter_AddRefs(presShell));
|
||||
|
||||
if (presShell) {
|
||||
presShell->GetPresContext(aPresContext);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocument> parent;
|
||||
doc->GetParentDocument(getter_AddRefs(parent));
|
||||
|
||||
doc = parent;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFrameLoader::EnsureDocShell()
|
||||
{
|
||||
if (mDocShell) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPresContext> presContext;
|
||||
GetPresContext(getter_AddRefs(presContext));
|
||||
NS_ENSURE_TRUE(presContext, NS_ERROR_UNEXPECTED);
|
||||
|
||||
// Bug 8065: Don't exceed some maximum depth in content frames
|
||||
// (MAX_DEPTH_CONTENT_FRAMES)
|
||||
PRInt32 depth = 0;
|
||||
nsCOMPtr<nsISupports> parentAsSupports;
|
||||
presContext->GetContainer(getter_AddRefs(parentAsSupports));
|
||||
|
||||
if (parentAsSupports) {
|
||||
nsCOMPtr<nsIDocShellTreeItem> parentAsItem =
|
||||
do_QueryInterface(parentAsSupports);
|
||||
|
||||
while (parentAsItem) {
|
||||
++depth;
|
||||
|
||||
if (MAX_DEPTH_CONTENT_FRAMES < depth) {
|
||||
NS_WARNING("Too many nested content frames so giving up");
|
||||
|
||||
return NS_ERROR_UNEXPECTED; // Too deep, give up! (silently?)
|
||||
}
|
||||
|
||||
// Only count depth on content, not chrome.
|
||||
// If we wanted to limit total depth, skip the following check:
|
||||
PRInt32 parentType;
|
||||
parentAsItem->GetItemType(&parentType);
|
||||
|
||||
if (nsIDocShellTreeItem::typeContent == parentType) {
|
||||
nsIDocShellTreeItem* temp = parentAsItem;
|
||||
temp->GetParent(getter_AddRefs(parentAsItem));
|
||||
} else {
|
||||
break; // we have exited content, stop counting, depth is OK!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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;
|
||||
mOwnerContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::name, 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<nsISupports> container;
|
||||
presContext->GetContainer(getter_AddRefs(container));
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeNode> parentAsNode(do_QueryInterface(container));
|
||||
if (parentAsNode) {
|
||||
nsCOMPtr<nsIDocShellTreeItem> parentAsItem =
|
||||
do_QueryInterface(parentAsNode);
|
||||
|
||||
PRInt32 parentType;
|
||||
parentAsItem->GetItemType(&parentType);
|
||||
|
||||
nsAutoString value;
|
||||
PRBool isContent;
|
||||
|
||||
isContent = PR_FALSE;
|
||||
|
||||
if (mOwnerContent->IsContentOfType(nsIContent::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", but
|
||||
// someday it might be an integer expressing priority
|
||||
|
||||
if (value.Length() >= 7) {
|
||||
// Lowercase the value, ContentShellAdded() further down relies
|
||||
// on it being lowercased.
|
||||
ToLowerCase(value);
|
||||
|
||||
nsAutoString::const_iterator start, end;
|
||||
value.BeginReading(start);
|
||||
value.EndReading(end);
|
||||
|
||||
nsAutoString::const_iterator iter(start);
|
||||
iter.advance(7);
|
||||
|
||||
const nsAString& valuePiece = Substring(start, iter);
|
||||
|
||||
if (valuePiece.Equals(NS_LITERAL_STRING("content")) &&
|
||||
(iter == end || *iter == '-')) {
|
||||
isContent = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
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 (isContent) {
|
||||
nsCOMPtr<nsIDocShellTreeOwner> parentTreeOwner;
|
||||
parentAsItem->GetTreeOwner(getter_AddRefs(parentTreeOwner));
|
||||
|
||||
if(parentTreeOwner) {
|
||||
PRBool is_primary = value.Equals(NS_LITERAL_STRING("content-primary"));
|
||||
|
||||
parentTreeOwner->ContentShellAdded(docShellAsItem, is_primary,
|
||||
value.get());
|
||||
}
|
||||
}
|
||||
|
||||
// connect the container...
|
||||
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(mDocShell));
|
||||
nsCOMPtr<nsIWebShellContainer> outerContainer =
|
||||
do_QueryInterface(container);
|
||||
|
||||
if (outerContainer) {
|
||||
webShell->SetContainer(outerContainer);
|
||||
}
|
||||
|
||||
// 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_WARN_IF_FALSE(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<nsIDOMWindow> win(do_GetInterface(mDocShell));
|
||||
nsCOMPtr<nsPIDOMWindow> win_private(do_QueryInterface(win));
|
||||
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(nsAString& aURI)
|
||||
{
|
||||
aURI.Truncate();
|
||||
|
||||
nsCOMPtr<nsIAtom> type;
|
||||
mOwnerContent->GetTag(*getter_AddRefs(type));
|
||||
|
||||
if (type == nsHTMLAtoms::object) {
|
||||
mOwnerContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::data, aURI);
|
||||
} else {
|
||||
mOwnerContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::src, aURI);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,22 +0,0 @@
|
||||
|
||||
|
||||
#include "nscore.h"
|
||||
|
||||
#include "nsCaretProperties.h"
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
nsCaretProperties::nsCaretProperties()
|
||||
: mCaretWidth(eDefaultCaretWidth)
|
||||
, mBlinkRate(eDefaulBlinkRate)
|
||||
{
|
||||
// in your platform-specific class, get data from the OS in your constructor
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
nsCaretProperties* NewCaretProperties()
|
||||
{
|
||||
return new nsCaretProperties();
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,409 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#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;
|
||||
|
||||
#define PARENT_BIT_RANGELISTS ((PtrBits)0x1 << 0)
|
||||
#define PARENT_BIT_LISTENERMANAGER ((PtrBits)0x1 << 1)
|
||||
#define PARENT_BIT_MASK (PARENT_BIT_RANGELISTS | \
|
||||
PARENT_BIT_LISTENERMANAGER)
|
||||
|
||||
class nsGenericDOMDataNode : public nsITextContent
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsGenericDOMDataNode();
|
||||
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);
|
||||
nsresult LookupNamespacePrefix(const nsAString& aNamespaceURI,
|
||||
nsAString& aPrefix);
|
||||
nsresult LookupNamespaceURI(const nsAString& aNamespacePrefix,
|
||||
nsAString& aNamespaceURI);
|
||||
|
||||
// Implementation for nsIDOMCharacterData
|
||||
nsresult GetData(nsAString& aData);
|
||||
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);
|
||||
|
||||
// Implementation for nsIContent
|
||||
NS_IMETHOD GetDocument(nsIDocument*& aResult) const;
|
||||
NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
||||
PRBool aCompileEventHandlers);
|
||||
NS_IMETHOD GetParent(nsIContent*& aResult) const;
|
||||
NS_IMETHOD SetParent(nsIContent* aParent);
|
||||
NS_IMETHOD GetNameSpaceID(PRInt32& aID) const;
|
||||
NS_IMETHOD NormalizeAttrString(const nsAString& aStr,
|
||||
nsINodeInfo*& aNodeInfo);
|
||||
NS_IMETHOD SetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
||||
const nsAString& aValue, PRBool aNotify);
|
||||
NS_IMETHOD SetAttr(nsINodeInfo *aNodeInfo,
|
||||
const nsAString& aValue, PRBool aNotify);
|
||||
NS_IMETHOD UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
||||
PRBool aNotify);
|
||||
NS_IMETHOD GetAttr(PRInt32 aNameSpaceID, nsIAtom *aAttribute,
|
||||
nsAString& aResult) const;
|
||||
NS_IMETHOD GetAttr(PRInt32 aNameSpaceID, nsIAtom *aAttribute,
|
||||
nsIAtom*& aPrefix, nsAString& aResult) const;
|
||||
NS_IMETHOD_(PRBool) HasAttr(PRInt32 aNameSpaceID, nsIAtom *aAttribute) const;
|
||||
NS_IMETHOD GetAttrNameAt(PRInt32 aIndex, PRInt32& aNameSpaceID,
|
||||
nsIAtom*& aName, nsIAtom*& aPrefix) const;
|
||||
NS_IMETHOD GetAttrCount(PRInt32& aResult) const;
|
||||
#ifdef DEBUG
|
||||
NS_IMETHOD List(FILE* out, PRInt32 aIndent) const;
|
||||
NS_IMETHOD DumpContent(FILE* out, PRInt32 aIndent, PRBool aDumpAll) const;
|
||||
#endif
|
||||
NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent, PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus);
|
||||
NS_IMETHOD GetContentID(PRUint32* aID);
|
||||
NS_IMETHOD SetContentID(PRUint32 aID);
|
||||
NS_IMETHOD RangeAdd(nsIDOMRange* aRange);
|
||||
NS_IMETHOD RangeRemove(nsIDOMRange* aRange);
|
||||
NS_IMETHOD GetRangeList(nsVoidArray*& aResult) const;
|
||||
NS_IMETHOD SetFocus(nsIPresContext *aPresContext);
|
||||
NS_IMETHOD RemoveFocus(nsIPresContext *aPresContext);
|
||||
|
||||
NS_IMETHOD GetBindingParent(nsIContent** aContent);
|
||||
NS_IMETHOD SetBindingParent(nsIContent* aParent);
|
||||
NS_IMETHOD_(PRBool) IsContentOfType(PRUint32 aFlags);
|
||||
|
||||
NS_IMETHOD GetListenerManager(nsIEventListenerManager** aInstancePtrResult);
|
||||
NS_IMETHOD DoneCreatingElement();
|
||||
|
||||
#ifdef DEBUG
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const;
|
||||
#endif
|
||||
|
||||
NS_IMETHOD GetNodeInfo(nsINodeInfo*& aResult) const;
|
||||
NS_IMETHOD CanContainChildren(PRBool& aResult) const;
|
||||
NS_IMETHOD ChildCount(PRInt32& aResult) const;
|
||||
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent*& aResult) const;
|
||||
NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const;
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify);
|
||||
|
||||
// nsITextContent
|
||||
NS_IMETHOD SplitText(PRUint32 aOffset, nsIDOMText** aReturn);
|
||||
|
||||
NS_IMETHOD GetText(const nsTextFragment** aFragmentsResult);
|
||||
NS_IMETHOD GetTextLength(PRInt32* aLengthResult);
|
||||
NS_IMETHOD CopyText(nsAString& aResult);
|
||||
NS_IMETHOD SetText(const PRUnichar* aBuffer, PRInt32 aLength,
|
||||
PRBool aNotify);
|
||||
NS_IMETHOD SetText(const nsAString& aStr, PRBool aNotify);
|
||||
NS_IMETHOD SetText(const char* aBuffer, PRInt32 aLength, PRBool aNotify);
|
||||
NS_IMETHOD IsOnlyWhitespace(PRBool* aResult);
|
||||
NS_IMETHOD CloneContent(PRBool aCloneText, nsITextContent** aClone);
|
||||
|
||||
//----------------------------------------
|
||||
|
||||
#ifdef DEBUG
|
||||
void ToCString(nsAString& aBuf, PRInt32 aOffset, PRInt32 aLen) const;
|
||||
#endif
|
||||
|
||||
static void Shutdown();
|
||||
|
||||
protected:
|
||||
nsIContent *GetParentWeak() const
|
||||
{
|
||||
PtrBits bits = mParentPtrBits & ~PARENT_BIT_MASK;
|
||||
|
||||
return NS_REINTERPRET_CAST(nsIContent *, bits);
|
||||
}
|
||||
|
||||
nsTextFragment mText;
|
||||
nsIDocument* mDocument; // WEAK
|
||||
|
||||
private:
|
||||
void LookupListenerManager(nsIEventListenerManager **aListenerManager) const;
|
||||
nsVoidArray *LookupRangeList() const;
|
||||
|
||||
#ifdef IBMBIDI
|
||||
void SetBidiStatus();
|
||||
#endif
|
||||
|
||||
|
||||
typedef long PtrBits;
|
||||
|
||||
void SetHasRangeList(PRBool aHasRangeList)
|
||||
{
|
||||
if (aHasRangeList) {
|
||||
mParentPtrBits |= PARENT_BIT_RANGELISTS;
|
||||
} else {
|
||||
mParentPtrBits &= ~PARENT_BIT_RANGELISTS;
|
||||
}
|
||||
}
|
||||
|
||||
void SetHasEventListenerManager(PRBool aHasRangeList)
|
||||
{
|
||||
if (aHasRangeList) {
|
||||
mParentPtrBits |= PARENT_BIT_LISTENERMANAGER;
|
||||
} else {
|
||||
mParentPtrBits &= ~PARENT_BIT_LISTENERMANAGER;
|
||||
}
|
||||
}
|
||||
|
||||
PRBool HasRangeList() const
|
||||
{
|
||||
return mParentPtrBits & PARENT_BIT_RANGELISTS;
|
||||
}
|
||||
|
||||
PRBool HasEventListenerManager() const
|
||||
{
|
||||
return mParentPtrBits & PARENT_BIT_LISTENERMANAGER;
|
||||
}
|
||||
|
||||
// Weak parent pointer (nsIContent *) and bits for knowing if
|
||||
// there's a rangelist or listener manager for this node
|
||||
PtrBits mParentPtrBits;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Mostly implement the nsIDOMNode API by forwarding the methods to a
|
||||
* generic content object (either nsGenericHTMLLeafElement or
|
||||
* nsGenericHTMLContainerContent)
|
||||
*
|
||||
* Note that classes using this macro will need to implement:
|
||||
* NS_IMETHOD GetNodeType(PRUint16* aNodeType);
|
||||
* NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn);
|
||||
*/
|
||||
#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) { \
|
||||
return nsGenericDOMDataNode::GetNodeValue(aNodeValue); \
|
||||
} \
|
||||
NS_IMETHOD SetNodeValue(const nsAString& aNodeValue) { \
|
||||
return nsGenericDOMDataNode::SetNodeValue(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 GetBaseURI(nsAString& aURI) { \
|
||||
return nsGenericDOMDataNode::GetBaseURI(aURI); \
|
||||
} \
|
||||
NS_IMETHOD LookupNamespacePrefix(const nsAString& aNamespaceURI, \
|
||||
nsAString& aPrefix) { \
|
||||
return nsGenericDOMDataNode::LookupNamespacePrefix(aNamespaceURI, \
|
||||
aPrefix); \
|
||||
} \
|
||||
NS_IMETHOD LookupNamespaceURI(const nsAString& aNamespacePrefix, \
|
||||
nsAString& aNamespaceURI) { \
|
||||
return nsGenericDOMDataNode::LookupNamespaceURI(aNamespacePrefix, \
|
||||
aNamespaceURI); \
|
||||
} \
|
||||
NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn);
|
||||
|
||||
#endif /* nsGenericDOMDataNode_h___ */
|
||||
@@ -1,63 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsGenericDOMNodeList.h"
|
||||
#include "nsGenericElement.h"
|
||||
|
||||
nsGenericDOMNodeList::nsGenericDOMNodeList()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsGenericDOMNodeList_h__
|
||||
#define nsGenericDOMNodeList_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
|
||||
/**
|
||||
* This is a base class for a generic DOM Node List. The base class
|
||||
* provides implementations for nsISupports, it is up to the subclass
|
||||
* to implement the core node list methods:
|
||||
*
|
||||
* GetLength
|
||||
* Item
|
||||
* */
|
||||
class nsGenericDOMNodeList : public nsIDOMNodeList
|
||||
{
|
||||
public:
|
||||
nsGenericDOMNodeList();
|
||||
virtual ~nsGenericDOMNodeList();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// The following need to be defined in the subclass
|
||||
// nsIDOMNodeList interface
|
||||
NS_IMETHOD GetLength(PRUint32* aLength)=0;
|
||||
NS_IMETHOD Item(PRUint32 aIndex, nsIDOMNode** aReturn)=0;
|
||||
};
|
||||
|
||||
#endif // nsGenericDOMNodeList_h__
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,603 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#ifndef nsGenericElement_h___
|
||||
#define nsGenericElement_h___
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsIDOMAttr.h"
|
||||
#include "nsIDOMNamedNodeMap.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMDocumentFragment.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIDOMLinkStyle.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIStyleSheetLinkingElement.h"
|
||||
#include "nsICSSStyleSheet.h"
|
||||
#include "nsICSSLoaderObserver.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsILinkHandler.h"
|
||||
#include "nsGenericDOMNodeList.h"
|
||||
#include "nsIEventListenerManager.h"
|
||||
#include "nsINodeInfo.h"
|
||||
#include "nsIParser.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
class nsIDOMAttr;
|
||||
class nsIDOMEventListener;
|
||||
class nsIFrame;
|
||||
class nsISupportsArray;
|
||||
class nsDOMCSSDeclaration;
|
||||
class nsIDOMCSSStyleDeclaration;
|
||||
class nsDOMAttributeMap;
|
||||
class nsIURI;
|
||||
class nsINodeInfo;
|
||||
|
||||
// Class that holds the child list of a content element and also
|
||||
// implements the nsIDOMNodeList interface.
|
||||
class nsChildContentList : public nsGenericDOMNodeList
|
||||
{
|
||||
public:
|
||||
nsChildContentList(nsIContent *aContent);
|
||||
virtual ~nsChildContentList();
|
||||
|
||||
// nsIDOMNodeList interface
|
||||
NS_DECL_NSIDOMNODELIST
|
||||
|
||||
void DropReference();
|
||||
|
||||
private:
|
||||
nsIContent *mContent;
|
||||
};
|
||||
|
||||
// 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.
|
||||
struct nsDOMSlots
|
||||
{
|
||||
nsChildContentList *mChildNodes;
|
||||
nsDOMCSSDeclaration *mStyle;
|
||||
nsDOMAttributeMap* mAttributeMap;
|
||||
nsVoidArray *mRangeList;
|
||||
nsIEventListenerManager* mListenerManager;
|
||||
nsIContent* mBindingParent; // The nearest enclosing content node with a
|
||||
// binding that created us. [Weak]
|
||||
};
|
||||
|
||||
|
||||
class nsNode3Tearoff : public nsIDOM3Node
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_DECL_NSIDOM3NODE
|
||||
|
||||
nsNode3Tearoff(nsIContent *aContent) : mContent(aContent)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
virtual ~nsNode3Tearoff() {};
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIContent> mContent;
|
||||
};
|
||||
|
||||
|
||||
// nsDOMEventRTTearoff is a tearoff class used by nsGenericElement and
|
||||
// nsGenericDOMDataNode classes for implemeting the interfaces
|
||||
// nsIDOMEventReceiver and nsIDOMEventTarget
|
||||
|
||||
#define NS_EVENT_TEAROFF_CACHE_SIZE 4
|
||||
|
||||
class nsDOMEventRTTearoff : public nsIDOMEventReceiver
|
||||
{
|
||||
private:
|
||||
// This class uses a caching scheme so we don't let users of this
|
||||
// class create new instances with 'new', in stead the callers
|
||||
// should use the static method
|
||||
// nsDOMEventRTTearoff::Create(). That's why the constructor and
|
||||
// destrucor of this class is private.
|
||||
|
||||
nsDOMEventRTTearoff(nsIContent *aContent);
|
||||
|
||||
static nsDOMEventRTTearoff *mCachedEventTearoff[NS_EVENT_TEAROFF_CACHE_SIZE];
|
||||
static PRUint32 mCachedEventTearoffCount;
|
||||
|
||||
// This method gets called by Release() when it's time to delete the
|
||||
// this object, in stead of always deleting the object we'll put the
|
||||
// object in the cache if unless the cache is already full.
|
||||
void LastRelease();
|
||||
|
||||
nsresult GetEventReceiver(nsIDOMEventReceiver **aReceiver);
|
||||
|
||||
public:
|
||||
virtual ~nsDOMEventRTTearoff();
|
||||
|
||||
// Use this static method to create instances of this tearoff class.
|
||||
static nsDOMEventRTTearoff *Create(nsIContent *aContent);
|
||||
|
||||
static void Shutdown();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMEventTarget
|
||||
NS_DECL_NSIDOMEVENTTARGET
|
||||
|
||||
// nsIDOMEventReceiver
|
||||
NS_IMETHOD AddEventListenerByIID(nsIDOMEventListener *aListener,
|
||||
const nsIID& aIID);
|
||||
NS_IMETHOD RemoveEventListenerByIID(nsIDOMEventListener *aListener,
|
||||
const nsIID& aIID);
|
||||
NS_IMETHOD GetListenerManager(nsIEventListenerManager** aResult);
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent *aEvent);
|
||||
|
||||
private:
|
||||
// Strong reference back to the content object from where an
|
||||
// instance of this class was 'torn off'
|
||||
nsCOMPtr<nsIContent> mContent;
|
||||
};
|
||||
|
||||
|
||||
class nsGenericElement : public nsIHTMLContent
|
||||
{
|
||||
public:
|
||||
nsGenericElement();
|
||||
virtual ~nsGenericElement();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsresult Init(nsINodeInfo *aNodeInfo);
|
||||
|
||||
// If QI fails on an element, call this method to let the binding
|
||||
// manager have a chance...
|
||||
nsresult PostQueryInterface(REFNSIID aIID, void** aInstancePtr);
|
||||
|
||||
// Free globals, to be called from module destructor
|
||||
static void Shutdown();
|
||||
|
||||
// nsIContent interface methods
|
||||
NS_IMETHOD GetDocument(nsIDocument*& aResult) const;
|
||||
NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
||||
PRBool aCompileEventHandlers);
|
||||
NS_IMETHOD GetParent(nsIContent*& aResult) const;
|
||||
NS_IMETHOD SetParent(nsIContent* aParent);
|
||||
NS_IMETHOD GetNameSpaceID(PRInt32& aNameSpaceID) const;
|
||||
NS_IMETHOD GetTag(nsIAtom*& aResult) const;
|
||||
NS_IMETHOD GetNodeInfo(nsINodeInfo*& aResult) const;
|
||||
// NS_IMETHOD CanContainChildren(PRBool& aResult) const;
|
||||
// NS_IMETHOD ChildCount(PRInt32& aResult) const;
|
||||
// NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent*& aResult) const;
|
||||
// NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const;
|
||||
// NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
// PRBool aNotify);
|
||||
// NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
// PRBool aNotify);
|
||||
// NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify);
|
||||
// NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify);
|
||||
// NS_IMETHOD NormalizeAttrString(const nsAString& aStr,
|
||||
// nsINodeInfo*& aNodeInfo);
|
||||
// NS_IMETHOD SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
// const nsAString& aValue,
|
||||
// PRBool aNotify);
|
||||
// NS_IMETHOD SetAttr(nsINodeInfo* aNodeInfo,
|
||||
// const nsAString& aValue,
|
||||
// PRBool aNotify);
|
||||
// NS_IMETHOD GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
// nsAString& aResult) const;
|
||||
// NS_IMETHOD GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
// nsIAtom*& aPrefix,
|
||||
// nsAString& aResult) const;
|
||||
// NS_IMETHOD UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
||||
// PRBool aNotify);
|
||||
// NS_IMETHOD GetAttrNameAt(PRInt32 aIndex,
|
||||
// PRInt32& aNameSpaceID,
|
||||
// nsIAtom*& aName,
|
||||
// nsIAtom*& aPrefix) const;
|
||||
// NS_IMETHOD GetAttrCount(PRInt32& aResult) const;
|
||||
#ifdef DEBUG
|
||||
// NS_IMETHOD List(FILE* out, PRInt32 aIndent) const;
|
||||
// NS_IMETHOD DumpContent(FILE* out, PRInt32 aIndent,PRBool aDumpAll) const;
|
||||
#endif
|
||||
NS_IMETHOD RangeAdd(nsIDOMRange* aRange);
|
||||
NS_IMETHOD RangeRemove(nsIDOMRange* aRange);
|
||||
NS_IMETHOD GetRangeList(nsVoidArray*& aResult) const;
|
||||
NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus);
|
||||
NS_IMETHOD GetContentID(PRUint32* aID);
|
||||
NS_IMETHOD SetContentID(PRUint32 aID);
|
||||
NS_IMETHOD SetFocus(nsIPresContext* aContext);
|
||||
NS_IMETHOD RemoveFocus(nsIPresContext* aContext);
|
||||
NS_IMETHOD GetBindingParent(nsIContent** aContent);
|
||||
NS_IMETHOD SetBindingParent(nsIContent* aParent);
|
||||
NS_IMETHOD_(PRBool) IsContentOfType(PRUint32 aFlags);
|
||||
NS_IMETHOD GetListenerManager(nsIEventListenerManager** aInstancePtrResult);
|
||||
NS_IMETHOD DoneCreatingElement();
|
||||
|
||||
|
||||
// nsIStyledContent interface methods
|
||||
NS_IMETHOD GetID(nsIAtom*& aResult) const;
|
||||
NS_IMETHOD GetClasses(nsVoidArray& aArray) const;
|
||||
NS_IMETHOD HasClass(nsIAtom* aClass, PRBool aCaseSensitive) const;
|
||||
NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker);
|
||||
NS_IMETHOD WalkInlineStyleRules(nsRuleWalker* aRuleWalker);
|
||||
NS_IMETHOD GetMappedAttributeImpact(const nsIAtom* aAttribute,
|
||||
PRInt32 aModType, PRInt32& aHint) const;
|
||||
|
||||
// nsIXMLContent interface methods
|
||||
NS_IMETHOD SetContainingNameSpace(nsINameSpace* aNameSpace);
|
||||
NS_IMETHOD GetContainingNameSpace(nsINameSpace*& aNameSpace) const;
|
||||
NS_IMETHOD MaybeTriggerAutoLink(nsIWebShell *aShell);
|
||||
NS_IMETHOD GetXMLBaseURI(nsIURI **aURI);
|
||||
|
||||
// nsIHTMLContent interface methods
|
||||
NS_IMETHOD Compact();
|
||||
NS_IMETHOD SetHTMLAttribute(nsIAtom* aAttribute,
|
||||
const nsHTMLValue& aValue,
|
||||
PRBool aNotify);
|
||||
NS_IMETHOD GetHTMLAttribute(nsIAtom* aAttribute,
|
||||
nsHTMLValue& aValue) const;
|
||||
NS_IMETHOD GetAttributeMappingFunction(nsMapRuleToAttributesFunc& aMapRuleFunc) const;
|
||||
NS_IMETHOD AttributeToString(nsIAtom* aAttribute,
|
||||
const nsHTMLValue& aValue,
|
||||
nsAString& aResult) const;
|
||||
NS_IMETHOD StringToAttribute(nsIAtom* aAttribute,
|
||||
const nsAString& aValue,
|
||||
nsHTMLValue& aResult);
|
||||
NS_IMETHOD GetBaseURL(nsIURI*& aBaseURL) const;
|
||||
NS_IMETHOD GetBaseTarget(nsAString& aBaseTarget) const;
|
||||
|
||||
// nsIDOMNode method implementation
|
||||
NS_IMETHOD GetNodeName(nsAString& aNodeName);
|
||||
NS_IMETHOD GetLocalName(nsAString& aLocalName);
|
||||
NS_IMETHOD GetNodeValue(nsAString& aNodeValue);
|
||||
NS_IMETHOD SetNodeValue(const nsAString& aNodeValue);
|
||||
NS_IMETHOD GetNodeType(PRUint16* aNodeType);
|
||||
NS_IMETHOD GetParentNode(nsIDOMNode** aParentNode);
|
||||
NS_IMETHOD GetAttributes(nsIDOMNamedNodeMap** aAttributes);
|
||||
NS_IMETHOD GetPreviousSibling(nsIDOMNode** aPreviousSibling);
|
||||
NS_IMETHOD GetNextSibling(nsIDOMNode** aNextSibling);
|
||||
NS_IMETHOD GetOwnerDocument(nsIDOMDocument** aOwnerDocument);
|
||||
NS_IMETHOD GetNamespaceURI(nsAString& aNamespaceURI);
|
||||
NS_IMETHOD GetPrefix(nsAString& aPrefix);
|
||||
NS_IMETHOD SetPrefix(const nsAString& aPrefix);
|
||||
NS_IMETHOD Normalize();
|
||||
NS_IMETHOD IsSupported(const nsAString& aFeature,
|
||||
const nsAString& aVersion, PRBool* aReturn);
|
||||
NS_IMETHOD HasAttributes(PRBool* aHasAttributes);
|
||||
|
||||
// nsIDOMElement method implementation
|
||||
NS_IMETHOD GetTagName(nsAString& aTagName);
|
||||
NS_IMETHOD GetAttribute(const nsAString& aName,
|
||||
nsAString& aReturn);
|
||||
NS_IMETHOD SetAttribute(const nsAString& aName,
|
||||
const nsAString& aValue);
|
||||
NS_IMETHOD RemoveAttribute(const nsAString& aName);
|
||||
NS_IMETHOD GetAttributeNode(const nsAString& aName,
|
||||
nsIDOMAttr** aReturn);
|
||||
NS_IMETHOD SetAttributeNode(nsIDOMAttr* aNewAttr, nsIDOMAttr** aReturn);
|
||||
NS_IMETHOD RemoveAttributeNode(nsIDOMAttr* aOldAttr, nsIDOMAttr** aReturn);
|
||||
NS_IMETHOD GetElementsByTagName(const nsAString& aTagname,
|
||||
nsIDOMNodeList** aReturn);
|
||||
NS_IMETHOD GetAttributeNS(const nsAString& aNamespaceURI,
|
||||
const nsAString& aLocalName,
|
||||
nsAString& aReturn);
|
||||
NS_IMETHOD SetAttributeNS(const nsAString& aNamespaceURI,
|
||||
const nsAString& aQualifiedName,
|
||||
const nsAString& aValue);
|
||||
NS_IMETHOD RemoveAttributeNS(const nsAString& aNamespaceURI,
|
||||
const nsAString& aLocalName);
|
||||
NS_IMETHOD GetAttributeNodeNS(const nsAString& aNamespaceURI,
|
||||
const nsAString& aLocalName,
|
||||
nsIDOMAttr** aReturn);
|
||||
NS_IMETHOD SetAttributeNodeNS(nsIDOMAttr* aNewAttr, nsIDOMAttr** aReturn);
|
||||
NS_IMETHOD GetElementsByTagNameNS(const nsAString& aNamespaceURI,
|
||||
const nsAString& aLocalName,
|
||||
nsIDOMNodeList** aReturn);
|
||||
NS_IMETHOD HasAttribute(const nsAString& aName, PRBool* aReturn);
|
||||
NS_IMETHOD HasAttributeNS(const nsAString& aNamespaceURI,
|
||||
const nsAString& aLocalName,
|
||||
PRBool* aReturn);
|
||||
|
||||
// Generic DOMNode implementations
|
||||
nsresult doInsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild,
|
||||
nsIDOMNode** aReturn);
|
||||
nsresult doReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild,
|
||||
nsIDOMNode** aReturn);
|
||||
nsresult doRemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn);
|
||||
|
||||
//----------------------------------------
|
||||
|
||||
nsresult RenderFrame(nsIPresContext*);
|
||||
|
||||
nsresult AddScriptEventListener(nsIAtom* aAttribute,
|
||||
const nsAString& aValue);
|
||||
|
||||
nsresult TriggerLink(nsIPresContext* aPresContext,
|
||||
nsLinkVerb aVerb,
|
||||
nsIURI* aBaseURL,
|
||||
const nsString& aURLSpec,
|
||||
const nsString& aTargetSpec,
|
||||
PRBool aClick);
|
||||
|
||||
nsresult JoinTextNodes(nsIContent* aFirst,
|
||||
nsIContent* aSecond);
|
||||
|
||||
static void SetDocumentInChildrenOf(nsIContent* aContent,
|
||||
nsIDocument* aDocument, PRBool aCompileEventHandlers);
|
||||
|
||||
static nsresult InternalIsSupported(const nsAString& aFeature,
|
||||
const nsAString& aVersion,
|
||||
PRBool* aReturn);
|
||||
|
||||
static PRBool HasMutationListeners(nsIContent* aContent,
|
||||
PRUint32 aType);
|
||||
|
||||
protected:
|
||||
#ifdef DEBUG
|
||||
virtual PRUint32 BaseSizeOf(nsISizeOfHandler *aSizer) const;
|
||||
#endif
|
||||
|
||||
nsDOMSlots *GetDOMSlots();
|
||||
void MaybeClearDOMSlots();
|
||||
|
||||
nsIDocument* mDocument; // WEAK
|
||||
nsIContent* mParent; // WEAK
|
||||
|
||||
nsINodeInfo* mNodeInfo; // OWNER
|
||||
nsDOMSlots *mDOMSlots; // OWNER
|
||||
PRUint32 mContentID;
|
||||
};
|
||||
|
||||
class nsGenericContainerElement : public nsGenericElement {
|
||||
public:
|
||||
nsGenericContainerElement();
|
||||
virtual ~nsGenericContainerElement();
|
||||
|
||||
NS_IMETHOD CopyInnerTo(nsIContent* aSrcContent,
|
||||
nsGenericContainerElement* aDest,
|
||||
PRBool aDeep);
|
||||
|
||||
// nsIDOMElement methods
|
||||
NS_METHOD GetAttribute(const nsAString& aName,
|
||||
nsAString& aReturn)
|
||||
{
|
||||
return nsGenericElement::GetAttribute(aName, aReturn);
|
||||
}
|
||||
NS_METHOD SetAttribute(const nsAString& aName,
|
||||
const nsAString& aValue)
|
||||
{
|
||||
return nsGenericElement::SetAttribute(aName, aValue);
|
||||
}
|
||||
|
||||
// Remainder of nsIDOMHTMLElement (and nsIDOMNode)
|
||||
NS_IMETHOD GetChildNodes(nsIDOMNodeList** aChildNodes);
|
||||
NS_IMETHOD HasChildNodes(PRBool* aHasChildNodes);
|
||||
NS_IMETHOD GetFirstChild(nsIDOMNode** aFirstChild);
|
||||
NS_IMETHOD GetLastChild(nsIDOMNode** aLastChild);
|
||||
|
||||
NS_IMETHOD InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild,
|
||||
nsIDOMNode** aReturn)
|
||||
{
|
||||
return nsGenericElement::doInsertBefore(aNewChild, aRefChild, aReturn);
|
||||
}
|
||||
NS_IMETHOD ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild,
|
||||
nsIDOMNode** aReturn)
|
||||
{
|
||||
return nsGenericElement::doReplaceChild(aNewChild, aOldChild, aReturn);
|
||||
}
|
||||
NS_IMETHOD RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
return nsGenericElement::doRemoveChild(aOldChild, aReturn);
|
||||
}
|
||||
NS_IMETHOD AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn)
|
||||
{
|
||||
return nsGenericElement::doInsertBefore(aNewChild, nsnull, aReturn);
|
||||
}
|
||||
|
||||
// Remainder of nsIContent
|
||||
NS_IMETHOD NormalizeAttrString(const nsAString& aStr,
|
||||
nsINodeInfo*& aNodeInfo);
|
||||
NS_IMETHOD SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
const nsAString& aValue,
|
||||
PRBool aNotify);
|
||||
NS_IMETHOD SetAttr(nsINodeInfo* aNodeInfo,
|
||||
const nsAString& aValue,
|
||||
PRBool aNotify);
|
||||
NS_IMETHOD GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
nsAString& aResult) const;
|
||||
NS_IMETHOD GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
nsIAtom*& aPrefix, nsAString& aResult) const;
|
||||
NS_IMETHOD_(PRBool) HasAttr(PRInt32 aNameSpaceID, nsIAtom* aName) const;
|
||||
NS_IMETHOD UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
||||
PRBool aNotify);
|
||||
NS_IMETHOD GetAttrNameAt(PRInt32 aIndex,
|
||||
PRInt32& aNameSpaceID,
|
||||
nsIAtom*& aName,
|
||||
nsIAtom*& aPrefix) const;
|
||||
NS_IMETHOD GetAttrCount(PRInt32& aResult) const;
|
||||
#ifdef DEBUG
|
||||
NS_IMETHOD List(FILE* out, PRInt32 aIndent) const;
|
||||
NS_IMETHOD DumpContent(FILE* out, PRInt32 aIndent,PRBool aDumpAll) const;
|
||||
#endif
|
||||
NS_IMETHOD CanContainChildren(PRBool& aResult) const;
|
||||
NS_IMETHOD ChildCount(PRInt32& aResult) const;
|
||||
NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent*& aResult) const;
|
||||
NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const;
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify);
|
||||
|
||||
#ifdef DEBUG
|
||||
void ListAttributes(FILE* out) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
#ifdef DEBUG
|
||||
virtual PRUint32 BaseSizeOf(nsISizeOfHandler *aSizer) const;
|
||||
#endif
|
||||
|
||||
nsVoidArray* mAttributes;
|
||||
nsSmallVoidArray mChildren;
|
||||
};
|
||||
|
||||
|
||||
// Internal non-public interface
|
||||
|
||||
// IID for the nsIDocumentFragment interface
|
||||
#define NS_IDOCUMENTFRAGMENT_IID \
|
||||
{ 0xd8fb2853, 0xf6d6, 0x4499, \
|
||||
{0x9c, 0x60, 0x6c, 0xa2, 0x75, 0x35, 0x09, 0xeb} }
|
||||
|
||||
// nsIDocumentFragment interface
|
||||
class nsIDocumentFragment : public nsIDOMDocumentFragment
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDOCUMENTFRAGMENT_IID)
|
||||
|
||||
// These methods are supposed to be used when *all* children of a
|
||||
// document fragment are moved at once into a new parent w/o
|
||||
// changing the relationship between the children. If the moving
|
||||
// operation fails and some children were moved to a new parent and
|
||||
// some weren't, ReconnectChildren() should be called to remove the
|
||||
// children from their possible new parent and re-insert the
|
||||
// children into the document fragment. Once the operation is
|
||||
// complete and all children are successfully moved into their new
|
||||
// parent DropChildReferences() should be called so that the
|
||||
// document fragment will loose its references to the children.
|
||||
|
||||
NS_IMETHOD DisconnectChildren() = 0;
|
||||
NS_IMETHOD ReconnectChildren() = 0;
|
||||
NS_IMETHOD DropChildReferences() = 0;
|
||||
};
|
||||
|
||||
|
||||
#define NS_FORWARD_NSIDOMNODE_NO_CLONENODE(_to) \
|
||||
NS_IMETHOD GetNodeName(nsAString& aNodeName) { \
|
||||
return _to GetNodeName(aNodeName); \
|
||||
} \
|
||||
NS_IMETHOD GetNodeValue(nsAString& aNodeValue) { \
|
||||
return _to GetNodeValue(aNodeValue); \
|
||||
} \
|
||||
NS_IMETHOD SetNodeValue(const nsAString& aNodeValue) { \
|
||||
return _to SetNodeValue(aNodeValue); \
|
||||
} \
|
||||
NS_IMETHOD GetNodeType(PRUint16* aNodeType) { \
|
||||
return _to GetNodeType(aNodeType); \
|
||||
} \
|
||||
NS_IMETHOD GetParentNode(nsIDOMNode** aParentNode) { \
|
||||
return _to GetParentNode(aParentNode); \
|
||||
} \
|
||||
NS_IMETHOD GetChildNodes(nsIDOMNodeList** aChildNodes) { \
|
||||
return _to GetChildNodes(aChildNodes); \
|
||||
} \
|
||||
NS_IMETHOD GetFirstChild(nsIDOMNode** aFirstChild) { \
|
||||
return _to GetFirstChild(aFirstChild); \
|
||||
} \
|
||||
NS_IMETHOD GetLastChild(nsIDOMNode** aLastChild) { \
|
||||
return _to GetLastChild(aLastChild); \
|
||||
} \
|
||||
NS_IMETHOD GetPreviousSibling(nsIDOMNode** aPreviousSibling) { \
|
||||
return _to GetPreviousSibling(aPreviousSibling); \
|
||||
} \
|
||||
NS_IMETHOD GetNextSibling(nsIDOMNode** aNextSibling) { \
|
||||
return _to GetNextSibling(aNextSibling); \
|
||||
} \
|
||||
NS_IMETHOD GetAttributes(nsIDOMNamedNodeMap** aAttributes) { \
|
||||
return _to GetAttributes(aAttributes); \
|
||||
} \
|
||||
NS_IMETHOD GetOwnerDocument(nsIDOMDocument** aOwnerDocument) { \
|
||||
return _to GetOwnerDocument(aOwnerDocument); \
|
||||
} \
|
||||
NS_IMETHOD GetNamespaceURI(nsAString& aNamespaceURI) { \
|
||||
return _to GetNamespaceURI(aNamespaceURI); \
|
||||
} \
|
||||
NS_IMETHOD GetPrefix(nsAString& aPrefix) { \
|
||||
return _to GetPrefix(aPrefix); \
|
||||
} \
|
||||
NS_IMETHOD SetPrefix(const nsAString& aPrefix) { \
|
||||
return _to SetPrefix(aPrefix); \
|
||||
} \
|
||||
NS_IMETHOD GetLocalName(nsAString& aLocalName) { \
|
||||
return _to GetLocalName(aLocalName); \
|
||||
} \
|
||||
NS_IMETHOD InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, \
|
||||
nsIDOMNode** aReturn) { \
|
||||
return _to InsertBefore(aNewChild, aRefChild, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, \
|
||||
nsIDOMNode** aReturn) { \
|
||||
return _to ReplaceChild(aNewChild, aOldChild, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn) { \
|
||||
return _to RemoveChild(aOldChild, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aReturn) { \
|
||||
return _to AppendChild(aNewChild, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD HasChildNodes(PRBool* aReturn) { \
|
||||
return _to HasChildNodes(aReturn); \
|
||||
} \
|
||||
NS_IMETHOD Normalize() { \
|
||||
return _to Normalize(); \
|
||||
} \
|
||||
NS_IMETHOD IsSupported(const nsAString& aFeature, \
|
||||
const nsAString& aVersion, PRBool* aReturn) { \
|
||||
return _to IsSupported(aFeature, aVersion, aReturn); \
|
||||
} \
|
||||
NS_IMETHOD HasAttributes(PRBool* aReturn) { \
|
||||
return _to HasAttributes(aReturn); \
|
||||
} \
|
||||
NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn);
|
||||
|
||||
#define NS_INTERFACE_MAP_ENTRY_TEAROFF(_iid, _tearoff) \
|
||||
if (aIID.Equals(NS_GET_IID(_iid))) { \
|
||||
foundInterface = new _tearoff; \
|
||||
NS_ENSURE_TRUE(foundInterface, NS_ERROR_OUT_OF_MEMORY); \
|
||||
} else
|
||||
|
||||
#endif /* nsGenericElement_h___ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,154 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsHTMLContentSerializer_h__
|
||||
#define nsHTMLContentSerializer_h__
|
||||
|
||||
#include "nsXMLContentSerializer.h"
|
||||
#include "nsIParserService.h"
|
||||
#include "nsIEntityConverter.h"
|
||||
|
||||
class nsIContent;
|
||||
class nsIAtom;
|
||||
|
||||
class nsHTMLContentSerializer : public nsXMLContentSerializer {
|
||||
public:
|
||||
nsHTMLContentSerializer();
|
||||
virtual ~nsHTMLContentSerializer();
|
||||
|
||||
NS_IMETHOD Init(PRUint32 flags, PRUint32 aWrapColumn,
|
||||
nsIAtom* aCharSet, PRBool aIsCopying);
|
||||
|
||||
NS_IMETHOD AppendText(nsIDOMText* aText,
|
||||
PRInt32 aStartOffset,
|
||||
PRInt32 aEndOffset,
|
||||
nsAString& aStr);
|
||||
NS_IMETHOD AppendElementStart(nsIDOMElement *aElement,
|
||||
PRBool aHasChildren,
|
||||
nsAString& aStr);
|
||||
|
||||
NS_IMETHOD AppendElementEnd(nsIDOMElement *aElement,
|
||||
nsAString& aStr);
|
||||
protected:
|
||||
PRBool HasDirtyAttr(nsIContent* aContent);
|
||||
PRBool LineBreakBeforeOpen(nsIAtom* aName, PRBool aHasDirtyAttr);
|
||||
PRBool LineBreakAfterOpen(nsIAtom* aName, PRBool aHasDirtyAttr);
|
||||
PRBool LineBreakBeforeClose(nsIAtom* aName, PRBool aHasDirtyAttr);
|
||||
PRBool LineBreakAfterClose(nsIAtom* aName, PRBool aHasDirtyAttr);
|
||||
PRBool IsFirstChildOfOL(nsIDOMElement* aElement);
|
||||
void StartIndentation(nsIAtom* aName,
|
||||
PRBool aHasDirtyAttr,
|
||||
nsAString& aStr);
|
||||
void EndIndentation(nsIAtom* aName,
|
||||
PRBool aHasDirtyAttr,
|
||||
nsAString& aStr);
|
||||
nsresult GetEntityConverter(nsIEntityConverter** aConverter);
|
||||
nsresult GetParserService(nsIParserService** aParserService);
|
||||
void SerializeAttributes(nsIContent* aContent,
|
||||
nsIAtom* aTagName,
|
||||
nsAString& aStr);
|
||||
void SerializeLIValueAttribute(nsIDOMElement* aElement,
|
||||
nsAString& aStr);
|
||||
virtual void AppendToString(const PRUnichar* aStr,
|
||||
PRInt32 aLength,
|
||||
nsAString& aOutputStr);
|
||||
virtual void AppendToString(const PRUnichar aChar,
|
||||
nsAString& aOutputStr);
|
||||
virtual void AppendToString(const nsAString& aStr,
|
||||
nsAString& aOutputStr,
|
||||
PRBool aTranslateEntities = PR_FALSE,
|
||||
PRBool aIncrColumn = PR_TRUE);
|
||||
virtual void AppendToStringConvertLF(const nsAString& aStr,
|
||||
nsAString& aOutputStr);
|
||||
virtual void AppendToStringWrapped(const nsAString& aStr,
|
||||
nsAString& aOutputStr,
|
||||
PRBool aTranslateEntities);
|
||||
PRBool HasLongLines(const nsString& text, PRInt32& aLastNewlineOffset);
|
||||
nsresult EscapeURI(const nsAString& aURI, nsAString& aEscapedURI);
|
||||
PRBool IsJavaScript(nsIAtom* aAttrNameAtom, const nsAString& aAttrValueString);
|
||||
|
||||
nsCOMPtr<nsIParserService> mParserService;
|
||||
nsCOMPtr<nsIEntityConverter> mEntityConverter;
|
||||
|
||||
PRInt32 mIndent;
|
||||
PRInt32 mColPos;
|
||||
PRUint32 mFlags;
|
||||
PRPackedBool mInBody;
|
||||
|
||||
PRPackedBool mDoFormat;
|
||||
PRPackedBool mDoHeader;
|
||||
PRPackedBool mBodyOnly;
|
||||
PRPackedBool mIsCopying; // Set to PR_TRUE only while copying
|
||||
|
||||
// To keep track of First LI child of OL in selected range
|
||||
PRPackedBool mIsFirstChildOfOL;
|
||||
PRInt32 mPreLevel;
|
||||
|
||||
/*
|
||||
* mInCDATA is set to PR_TRUE while the serializer is serializing
|
||||
* the content of a element whose content is considerd CDATA by the
|
||||
* serializer (such elements are 'script', 'style', 'noscript' and
|
||||
* possibly others) This doesn't have anything to do with if the
|
||||
* element is defined as CDATA in the DTD, it simply means we'll
|
||||
* output the content of the element without doing any entity encoding
|
||||
* what so ever.
|
||||
*/
|
||||
PRPackedBool mInCDATA;
|
||||
PRPackedBool mIsLatin1;
|
||||
|
||||
PRInt32 mMaxColumn;
|
||||
|
||||
nsString mLineBreak;
|
||||
|
||||
nsCOMPtr<nsIAtom> mCharSet;
|
||||
|
||||
// To keep track of startvalue of OL and first list item for nested lists
|
||||
struct olState {
|
||||
olState(PRInt32 aStart, PRBool aIsFirst):startVal(aStart),isFirstListItem(aIsFirst)
|
||||
{
|
||||
}
|
||||
PRInt32 startVal;
|
||||
PRBool isFirstListItem;
|
||||
};
|
||||
|
||||
nsAutoVoidArray mOLStateStack;// Stack to store one olState struct per <OL>.
|
||||
};
|
||||
|
||||
extern nsresult NS_NewHTMLContentSerializer(nsIContentSerializer** aSerializer);
|
||||
|
||||
#endif
|
||||
@@ -1,577 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#include "nscore.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsINameSpace.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsIElementFactory.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "nsString.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsContentCID.h"
|
||||
|
||||
|
||||
extern nsresult NS_NewXMLElementFactory(nsIElementFactory** aResult);
|
||||
|
||||
static const char kXMLNSNameSpaceURI[] = "http://www.w3.org/2000/xmlns/";
|
||||
static const char kXMLNameSpaceURI[] = "http://www.w3.org/XML/1998/namespace";
|
||||
static const char kXHTMLNameSpaceURI[] = "http://www.w3.org/1999/xhtml";
|
||||
static const char kXLinkNameSpaceURI[] = "http://www.w3.org/1999/xlink";
|
||||
static const char kXSLTNameSpaceURI[] = "http://www.w3.org/1999/XSL/Transform";
|
||||
static const char kXBLNameSpaceURI[] = "http://www.mozilla.org/xbl";
|
||||
static const char kMathMLNameSpaceURI[] = "http://www.w3.org/1998/Math/MathML";
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Name Space ID table support
|
||||
|
||||
static PRBool gNameSpaceManagerIsInitialized = PR_FALSE;
|
||||
static nsHashtable* gURIToIDTable;
|
||||
static nsVoidArray* gURIArray;
|
||||
static nsISupportsArray* gElementFactoryArray;
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
static PRBool gNameSpaceManagerWasShutDown = PR_FALSE;
|
||||
#endif
|
||||
|
||||
static void InitializeNameSpaceManager()
|
||||
{
|
||||
if (gNameSpaceManagerIsInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
NS_ASSERTION(!gURIToIDTable, "already have URI table");
|
||||
NS_ASSERTION(!gURIArray, "already have URI array");
|
||||
|
||||
gURIToIDTable = new nsHashtable();
|
||||
gURIArray = new nsVoidArray();
|
||||
|
||||
nsString* xmlns = new nsString(NS_ConvertASCIItoUCS2(kXMLNSNameSpaceURI));
|
||||
nsString* xml = new nsString(NS_ConvertASCIItoUCS2(kXMLNameSpaceURI));
|
||||
nsString* xhtml = new nsString(NS_ConvertASCIItoUCS2(kXHTMLNameSpaceURI));
|
||||
nsString* xlink = new nsString(NS_ConvertASCIItoUCS2(kXLinkNameSpaceURI));
|
||||
nsString* xslt = new nsString(NS_ConvertASCIItoUCS2(kXSLTNameSpaceURI));
|
||||
nsString* xbl = new nsString(NS_ConvertASCIItoUCS2(kXBLNameSpaceURI));
|
||||
nsString* mathml = new nsString(NS_ConvertASCIItoUCS2(kMathMLNameSpaceURI));
|
||||
|
||||
gURIArray->AppendElement(xmlns); // ordering here needs to match IDs
|
||||
gURIArray->AppendElement(xml);
|
||||
gURIArray->AppendElement(xhtml);
|
||||
gURIArray->AppendElement(xlink);
|
||||
gURIArray->AppendElement(xslt);
|
||||
gURIArray->AppendElement(xbl);
|
||||
gURIArray->AppendElement(mathml);
|
||||
|
||||
nsStringKey xmlnsKey(*xmlns);
|
||||
nsStringKey xmlKey(*xml);
|
||||
nsStringKey xhtmlKey(*xhtml);
|
||||
nsStringKey xlinkKey(*xlink);
|
||||
nsStringKey xsltKey(*xslt);
|
||||
nsStringKey xblKey(*xbl);
|
||||
nsStringKey mathmlKey(*mathml);
|
||||
|
||||
gURIToIDTable->Put(&xmlnsKey, NS_INT32_TO_PTR(kNameSpaceID_XMLNS));
|
||||
gURIToIDTable->Put(&xmlKey, NS_INT32_TO_PTR(kNameSpaceID_XML));
|
||||
gURIToIDTable->Put(&xhtmlKey, NS_INT32_TO_PTR(kNameSpaceID_XHTML));
|
||||
gURIToIDTable->Put(&xlinkKey, NS_INT32_TO_PTR(kNameSpaceID_XLink));
|
||||
gURIToIDTable->Put(&xsltKey, NS_INT32_TO_PTR(kNameSpaceID_XSLT));
|
||||
gURIToIDTable->Put(&xblKey, NS_INT32_TO_PTR(kNameSpaceID_XBL));
|
||||
gURIToIDTable->Put(&mathmlKey, NS_INT32_TO_PTR(kNameSpaceID_MathML));
|
||||
|
||||
NS_NewISupportsArray(&gElementFactoryArray);
|
||||
|
||||
NS_ASSERTION(gURIToIDTable, "no URI table");
|
||||
NS_ASSERTION(gURIArray, "no URI array");
|
||||
NS_ASSERTION(gElementFactoryArray, "no element factory array");
|
||||
|
||||
gNameSpaceManagerIsInitialized = PR_TRUE;
|
||||
}
|
||||
|
||||
void NS_NameSpaceManagerShutdown()
|
||||
{
|
||||
delete gURIToIDTable;
|
||||
PRInt32 index = gURIArray->Count();
|
||||
while (0 < index--) {
|
||||
nsString* str = (nsString*)gURIArray->ElementAt(index);
|
||||
delete str;
|
||||
}
|
||||
delete gURIArray;
|
||||
gURIToIDTable = nsnull;
|
||||
gURIArray = nsnull;
|
||||
|
||||
NS_IF_RELEASE(gElementFactoryArray);
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
gNameSpaceManagerWasShutDown = PR_TRUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
static PRInt32 FindNameSpaceID(const nsAString& aURI)
|
||||
{
|
||||
NS_ASSERTION(gURIToIDTable, "no URI table");
|
||||
const nsPromiseFlatString& flatString = PromiseFlatString(aURI);
|
||||
nsStringKey key(flatString);
|
||||
void* value = gURIToIDTable->Get(&key);
|
||||
if (value) {
|
||||
return NS_PTR_TO_INT32(value);
|
||||
}
|
||||
return kNameSpaceID_Unknown;
|
||||
}
|
||||
|
||||
static const nsString* FindNameSpaceURI(PRInt32 aID)
|
||||
{
|
||||
NS_ASSERTION(gURIArray, "no URI array");
|
||||
return (const nsString*)gURIArray->SafeElementAt(aID - 1);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Name Space
|
||||
|
||||
class NameSpaceImpl : public nsINameSpace {
|
||||
public:
|
||||
NameSpaceImpl(nsINameSpaceManager* aManager,
|
||||
NameSpaceImpl* aParent,
|
||||
nsIAtom* aPrefix,
|
||||
const nsAString& aURI);
|
||||
NameSpaceImpl(nsINameSpaceManager* aManager,
|
||||
NameSpaceImpl* aParent,
|
||||
nsIAtom* aPrefix,
|
||||
PRInt32 aNameSpaceID);
|
||||
virtual ~NameSpaceImpl();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD GetNameSpaceManager(nsINameSpaceManager*& aManager) const;
|
||||
|
||||
NS_IMETHOD GetNameSpaceID(PRInt32& aID) const;
|
||||
NS_IMETHOD GetNameSpaceURI(nsAString& aURI) const;
|
||||
NS_IMETHOD GetNameSpacePrefix(nsIAtom*& aPrefix) const;
|
||||
|
||||
NS_IMETHOD GetParentNameSpace(nsINameSpace*& aParent) const;
|
||||
|
||||
NS_IMETHOD FindNameSpace(nsIAtom* aPrefix, nsINameSpace*& aNameSpace) const;
|
||||
NS_IMETHOD FindNameSpaceID(nsIAtom* aPrefix, PRInt32& aNameSpaceID) const;
|
||||
NS_IMETHOD FindNameSpacePrefix(PRInt32 aNameSpaceID, nsIAtom*& aPrefix) const;
|
||||
|
||||
NS_IMETHOD CreateChildNameSpace(nsIAtom* aPrefix, const nsAString& aURI,
|
||||
nsINameSpace*& aChildNameSpace);
|
||||
NS_IMETHOD CreateChildNameSpace(nsIAtom* aPrefix, PRInt32 aNameSpaceID,
|
||||
nsINameSpace*& aChildNameSpace);
|
||||
|
||||
private:
|
||||
// These are not supported and are not implemented!
|
||||
NameSpaceImpl(const NameSpaceImpl& aCopy);
|
||||
NameSpaceImpl& operator=(const NameSpaceImpl& aCopy);
|
||||
|
||||
public:
|
||||
nsINameSpaceManager* mManager;
|
||||
NameSpaceImpl* mParent;
|
||||
nsIAtom* mPrefix;
|
||||
PRInt32 mID;
|
||||
};
|
||||
|
||||
NameSpaceImpl::NameSpaceImpl(nsINameSpaceManager* aManager,
|
||||
NameSpaceImpl* aParent,
|
||||
nsIAtom* aPrefix,
|
||||
const nsAString& aURI)
|
||||
: mManager(aManager),
|
||||
mParent(aParent),
|
||||
mPrefix(aPrefix)
|
||||
{
|
||||
NS_ASSERTION(aManager, "null namespace manager");
|
||||
NS_INIT_REFCNT();
|
||||
NS_ADDREF(mManager);
|
||||
NS_IF_ADDREF(mParent);
|
||||
NS_IF_ADDREF(mPrefix);
|
||||
mManager->RegisterNameSpace(aURI, mID);
|
||||
}
|
||||
|
||||
NameSpaceImpl::NameSpaceImpl(nsINameSpaceManager* aManager,
|
||||
NameSpaceImpl* aParent,
|
||||
nsIAtom* aPrefix,
|
||||
PRInt32 aNameSpaceID)
|
||||
: mManager(aManager),
|
||||
mParent(aParent),
|
||||
mPrefix(aPrefix),
|
||||
mID(aNameSpaceID)
|
||||
{
|
||||
NS_ASSERTION(aManager, "null namespace manager");
|
||||
NS_INIT_REFCNT();
|
||||
NS_ADDREF(mManager);
|
||||
NS_IF_ADDREF(mParent);
|
||||
NS_IF_ADDREF(mPrefix);
|
||||
}
|
||||
|
||||
NameSpaceImpl::~NameSpaceImpl()
|
||||
{
|
||||
NS_RELEASE(mManager);
|
||||
NS_IF_RELEASE(mParent);
|
||||
NS_IF_RELEASE(mPrefix);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(NameSpaceImpl, nsINameSpace)
|
||||
|
||||
NS_IMETHODIMP
|
||||
NameSpaceImpl::GetNameSpaceManager(nsINameSpaceManager*& aManager) const
|
||||
{
|
||||
NS_ASSERTION(aManager, "null namespace manager");
|
||||
aManager = mManager;
|
||||
NS_ADDREF(aManager);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NameSpaceImpl::GetNameSpaceID(PRInt32& aID) const
|
||||
{
|
||||
aID = mID;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NameSpaceImpl::GetNameSpaceURI(nsAString& aURI) const
|
||||
{
|
||||
NS_ASSERTION(mManager, "null namespace manager");
|
||||
return mManager->GetNameSpaceURI(mID, aURI);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NameSpaceImpl::GetNameSpacePrefix(nsIAtom*& aPrefix) const
|
||||
{
|
||||
aPrefix = mPrefix;
|
||||
NS_IF_ADDREF(aPrefix);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NameSpaceImpl::GetParentNameSpace(nsINameSpace*& aParent) const
|
||||
{
|
||||
aParent = mParent;
|
||||
NS_IF_ADDREF(aParent);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NameSpaceImpl::FindNameSpace(nsIAtom* aPrefix, nsINameSpace*& aNameSpace) const
|
||||
{
|
||||
const NameSpaceImpl* nameSpace = this;
|
||||
|
||||
do {
|
||||
if (aPrefix == nameSpace->mPrefix) {
|
||||
aNameSpace = (nsINameSpace*)nameSpace;
|
||||
NS_ADDREF(aNameSpace);
|
||||
return NS_OK;
|
||||
}
|
||||
nameSpace = nameSpace->mParent;
|
||||
} while (nameSpace);
|
||||
|
||||
aNameSpace = nsnull;
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NameSpaceImpl::FindNameSpaceID(nsIAtom* aPrefix, PRInt32& aNameSpaceID) const
|
||||
{
|
||||
const NameSpaceImpl* nameSpace = this;
|
||||
do {
|
||||
if (aPrefix == nameSpace->mPrefix) {
|
||||
aNameSpaceID = nameSpace->mID;
|
||||
return NS_OK;
|
||||
}
|
||||
nameSpace = nameSpace->mParent;
|
||||
} while (nameSpace);
|
||||
|
||||
if (!aPrefix) {
|
||||
aNameSpaceID = kNameSpaceID_None;
|
||||
}
|
||||
else {
|
||||
aNameSpaceID = kNameSpaceID_Unknown;
|
||||
}
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NameSpaceImpl::FindNameSpacePrefix(PRInt32 aNameSpaceID, nsIAtom*& aPrefix) const
|
||||
{
|
||||
const NameSpaceImpl* nameSpace = this;
|
||||
|
||||
do {
|
||||
if (aNameSpaceID == nameSpace->mID) {
|
||||
aPrefix = nameSpace->mPrefix;
|
||||
NS_IF_ADDREF(aPrefix);
|
||||
return NS_OK;
|
||||
}
|
||||
nameSpace = nameSpace->mParent;
|
||||
} while (nameSpace);
|
||||
|
||||
aPrefix = nsnull;
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NameSpaceImpl::CreateChildNameSpace(nsIAtom* aPrefix, const nsAString& aURI,
|
||||
nsINameSpace*& aChildNameSpace)
|
||||
{
|
||||
NameSpaceImpl* child = new NameSpaceImpl(mManager, this, aPrefix, aURI);
|
||||
|
||||
if (child) {
|
||||
return child->QueryInterface(NS_GET_IID(nsINameSpace), (void**)&aChildNameSpace);
|
||||
}
|
||||
aChildNameSpace = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NameSpaceImpl::CreateChildNameSpace(nsIAtom* aPrefix, PRInt32 aNameSpaceID,
|
||||
nsINameSpace*& aChildNameSpace)
|
||||
{
|
||||
if (FindNameSpaceURI(aNameSpaceID)) {
|
||||
NameSpaceImpl* child = new NameSpaceImpl(mManager, this, aPrefix, aNameSpaceID);
|
||||
|
||||
if (child) {
|
||||
return child->QueryInterface(NS_GET_IID(nsINameSpace), (void**)&aChildNameSpace);
|
||||
}
|
||||
aChildNameSpace = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
aChildNameSpace = nsnull;
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Name Space Manager
|
||||
|
||||
class NameSpaceManagerImpl : public nsINameSpaceManager {
|
||||
public:
|
||||
NameSpaceManagerImpl();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD CreateRootNameSpace(nsINameSpace*& aRootNameSpace);
|
||||
|
||||
NS_IMETHOD RegisterNameSpace(const nsAString& aURI,
|
||||
PRInt32& aNameSpaceID);
|
||||
|
||||
NS_IMETHOD GetNameSpaceURI(PRInt32 aNameSpaceID, nsAString& aURI);
|
||||
NS_IMETHOD GetNameSpaceID(const nsAString& aURI,
|
||||
PRInt32& aNameSpaceID);
|
||||
NS_IMETHOD GetElementFactory(PRInt32 aNameSpaceID,
|
||||
nsIElementFactory **aElementFactory);
|
||||
private:
|
||||
// These are not supported and are not implemented!
|
||||
NameSpaceManagerImpl(const NameSpaceManagerImpl& aCopy);
|
||||
NameSpaceManagerImpl& operator=(const NameSpaceManagerImpl& aCopy);
|
||||
|
||||
protected:
|
||||
virtual ~NameSpaceManagerImpl();
|
||||
|
||||
};
|
||||
|
||||
NameSpaceManagerImpl::NameSpaceManagerImpl()
|
||||
{
|
||||
NS_ASSERTION(!gNameSpaceManagerWasShutDown,
|
||||
"Namespace manager used past content module shutdown!!!");
|
||||
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
InitializeNameSpaceManager();
|
||||
}
|
||||
|
||||
NameSpaceManagerImpl::~NameSpaceManagerImpl()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(NameSpaceManagerImpl, nsINameSpaceManager)
|
||||
|
||||
NS_IMETHODIMP
|
||||
NameSpaceManagerImpl::CreateRootNameSpace(nsINameSpace*& aRootNameSpace)
|
||||
{
|
||||
NS_ASSERTION(!gNameSpaceManagerWasShutDown,
|
||||
"Namespace manager used past content module shutdown!!!");
|
||||
|
||||
nsresult rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
aRootNameSpace = nsnull;
|
||||
|
||||
NameSpaceImpl* xmlns = new NameSpaceImpl(this, nsnull,
|
||||
nsLayoutAtoms::xmlnsNameSpace,
|
||||
kNameSpaceID_XMLNS);
|
||||
if (nsnull != xmlns) {
|
||||
NameSpaceImpl* xml = new NameSpaceImpl(this, xmlns,
|
||||
nsLayoutAtoms::xmlNameSpace,
|
||||
kNameSpaceID_XML);
|
||||
if (xml) {
|
||||
rv = CallQueryInterface(xml, &aRootNameSpace);
|
||||
}
|
||||
else {
|
||||
delete xmlns;
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NameSpaceManagerImpl::RegisterNameSpace(const nsAString& aURI,
|
||||
PRInt32& aNameSpaceID)
|
||||
{
|
||||
NS_ASSERTION(!gNameSpaceManagerWasShutDown,
|
||||
"Namespace manager used past content module shutdown!!!");
|
||||
|
||||
PRInt32 id = FindNameSpaceID(aURI);
|
||||
|
||||
if (kNameSpaceID_Unknown == id) {
|
||||
if (aURI.IsEmpty()) {
|
||||
id = kNameSpaceID_None; // xmlns="", see bug 75700 for details
|
||||
} else {
|
||||
nsString* uri = new nsString(aURI);
|
||||
if (!uri)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
gURIArray->AppendElement(uri);
|
||||
id = gURIArray->Count(); // id is index + 1
|
||||
nsStringKey key(*uri);
|
||||
gURIToIDTable->Put(&key, (void*)id);
|
||||
}
|
||||
}
|
||||
aNameSpaceID = id;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NameSpaceManagerImpl::GetNameSpaceURI(PRInt32 aNameSpaceID, nsAString& aURI)
|
||||
{
|
||||
NS_ASSERTION(!gNameSpaceManagerWasShutDown,
|
||||
"Namespace manager used past content module shutdown!!!");
|
||||
|
||||
const nsString* result = FindNameSpaceURI(aNameSpaceID);
|
||||
if (result) {
|
||||
aURI = *result;
|
||||
return NS_OK;
|
||||
}
|
||||
aURI.Truncate();
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NameSpaceManagerImpl::GetNameSpaceID(const nsAString& aURI, PRInt32& aNameSpaceID)
|
||||
{
|
||||
NS_ASSERTION(!gNameSpaceManagerWasShutDown,
|
||||
"Namespace manager used past content module shutdown!!!");
|
||||
|
||||
aNameSpaceID = FindNameSpaceID(aURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NameSpaceManagerImpl::GetElementFactory(PRInt32 aNameSpaceID,
|
||||
nsIElementFactory **aElementFactory)
|
||||
{
|
||||
NS_ASSERTION(!gNameSpaceManagerWasShutDown,
|
||||
"Namespace manager used past content module shutdown!!!");
|
||||
|
||||
*aElementFactory = nsnull;
|
||||
|
||||
NS_ENSURE_TRUE(gElementFactoryArray, NS_ERROR_NOT_INITIALIZED);
|
||||
NS_ENSURE_TRUE(aNameSpaceID >= 0, NS_ERROR_ILLEGAL_VALUE);
|
||||
|
||||
gElementFactoryArray->QueryElementAt(aNameSpaceID,
|
||||
NS_GET_IID(nsIElementFactory),
|
||||
(void **)aElementFactory);
|
||||
|
||||
if (*aElementFactory) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsAutoString uri;
|
||||
|
||||
GetNameSpaceURI(aNameSpaceID, uri);
|
||||
|
||||
nsCOMPtr<nsIElementFactory> ef;
|
||||
|
||||
if (!uri.IsEmpty()) {
|
||||
nsCAutoString contract_id(NS_ELEMENT_FACTORY_CONTRACTID_PREFIX);
|
||||
contract_id.Append(NS_ConvertUCS2toUTF8(uri));
|
||||
|
||||
ef = do_GetService(contract_id.get());
|
||||
}
|
||||
|
||||
if (!ef) {
|
||||
nsresult rv = NS_NewXMLElementFactory(getter_AddRefs(ef));
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
PRUint32 count = 0;
|
||||
gElementFactoryArray->Count(&count);
|
||||
|
||||
if ((PRUint32)aNameSpaceID < count) {
|
||||
gElementFactoryArray->ReplaceElementAt(ef, aNameSpaceID);
|
||||
} else {
|
||||
// This sucks, simply doing an InsertElementAt() should IMNSHO
|
||||
// automatically grow the array and insert null's as needed to
|
||||
// fill up the array!?!!
|
||||
|
||||
for (PRInt32 i = count; i < aNameSpaceID; i++) {
|
||||
gElementFactoryArray->AppendElement(nsnull);
|
||||
}
|
||||
|
||||
gElementFactoryArray->AppendElement(ef);
|
||||
}
|
||||
|
||||
*aElementFactory = ef;
|
||||
NS_ADDREF(*aElementFactory);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewNameSpaceManager(nsINameSpaceManager** aInstancePtrResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aInstancePtrResult);
|
||||
|
||||
*aInstancePtrResult = new NameSpaceManagerImpl();
|
||||
|
||||
if (!*aInstancePtrResult) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
NS_ADDREF(*aInstancePtrResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -1,327 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsNodeInfo.h"
|
||||
#include "nsNodeInfoManager.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "domstubs.h" // for SetDOMStringToNull();
|
||||
#include "nsCRT.h"
|
||||
|
||||
|
||||
nsNodeInfo::nsNodeInfo()
|
||||
: nsINodeInfo(), mOwnerManager(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
|
||||
nsNodeInfo::~nsNodeInfo()
|
||||
{
|
||||
if (mOwnerManager) {
|
||||
mOwnerManager->RemoveNodeInfo(this);
|
||||
NS_RELEASE(mOwnerManager);
|
||||
}
|
||||
|
||||
NS_IF_RELEASE(mInner.mName);
|
||||
NS_IF_RELEASE(mInner.mPrefix);
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsNodeInfo::Init(nsIAtom *aName, nsIAtom *aPrefix, PRInt32 aNamespaceID,
|
||||
nsNodeInfoManager *aOwnerManager)
|
||||
{
|
||||
NS_ENSURE_TRUE(!mInner.mName && !mInner.mPrefix && !mOwnerManager,
|
||||
NS_ERROR_ALREADY_INITIALIZED);
|
||||
NS_ENSURE_ARG_POINTER(aName);
|
||||
NS_ENSURE_ARG_POINTER(aOwnerManager);
|
||||
|
||||
mInner.mName = aName;
|
||||
NS_ADDREF(mInner.mName);
|
||||
|
||||
mInner.mPrefix = aPrefix;
|
||||
NS_IF_ADDREF(mInner.mPrefix);
|
||||
|
||||
mInner.mNamespaceID = aNamespaceID;
|
||||
|
||||
mOwnerManager = aOwnerManager;
|
||||
NS_ADDREF(mOwnerManager);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// nsISupports
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsNodeInfo, nsINodeInfo);
|
||||
|
||||
|
||||
// nsINodeInfo
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNodeInfo::GetQualifiedName(nsAString& aQualifiedName) const
|
||||
{
|
||||
if (mInner.mPrefix) {
|
||||
mInner.mPrefix->ToString(aQualifiedName);
|
||||
|
||||
aQualifiedName.Append(PRUnichar(':'));
|
||||
} else {
|
||||
aQualifiedName.Truncate();
|
||||
}
|
||||
|
||||
const PRUnichar *name;
|
||||
mInner.mName->GetUnicode(&name);
|
||||
|
||||
aQualifiedName.Append(name);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNodeInfo::GetLocalName(nsAString& aLocalName) const
|
||||
{
|
||||
#ifdef STRICT_DOM_LEVEL2_LOCALNAME
|
||||
if (mInner.mNamespaceID > 0) {
|
||||
return mInner.mName->ToString(aLocalName);
|
||||
}
|
||||
|
||||
SetDOMStringToNull(aLocalName);
|
||||
|
||||
return NS_OK;
|
||||
#else
|
||||
return mInner.mName->ToString(aLocalName);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNodeInfo::GetNamespaceURI(nsAString& aNameSpaceURI) const
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (mInner.mNamespaceID > 0) {
|
||||
nsCOMPtr<nsINameSpaceManager> nsm;
|
||||
|
||||
mOwnerManager->GetNamespaceManager(*getter_AddRefs(nsm));
|
||||
NS_ENSURE_TRUE(nsm, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
rv = nsm->GetNameSpaceURI(mInner.mNamespaceID, aNameSpaceURI);
|
||||
} else {
|
||||
SetDOMStringToNull(aNameSpaceURI);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNodeInfo::GetIDAttributeAtom(nsIAtom** aResult) const
|
||||
{
|
||||
*aResult = mIDAttributeAtom;
|
||||
NS_IF_ADDREF(*aResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNodeInfo::SetIDAttributeAtom(nsIAtom* aID)
|
||||
{
|
||||
NS_ENSURE_ARG(aID);
|
||||
mIDAttributeAtom = aID;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNodeInfo::GetNodeInfoManager(nsINodeInfoManager*& aNodeInfoManager) const
|
||||
{
|
||||
aNodeInfoManager = mOwnerManager;
|
||||
|
||||
NS_ADDREF(aNodeInfoManager);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsNodeInfo::Equals(const nsAString& aName) const
|
||||
{
|
||||
const PRUnichar *name;
|
||||
mInner.mName->GetUnicode(&name);
|
||||
|
||||
return aName.Equals(name);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsNodeInfo::Equals(const nsAString& aName, const nsAString& aPrefix) const
|
||||
{
|
||||
const PRUnichar *name;
|
||||
mInner.mName->GetUnicode(&name);
|
||||
|
||||
if (!aName.Equals(name)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
if (!mInner.mPrefix) {
|
||||
return aPrefix.IsEmpty();
|
||||
}
|
||||
|
||||
mInner.mPrefix->GetUnicode(&name);
|
||||
|
||||
return aPrefix.Equals(name);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsNodeInfo::Equals(const nsAString& aName, PRInt32 aNamespaceID) const
|
||||
{
|
||||
const PRUnichar *name;
|
||||
mInner.mName->GetUnicode(&name);
|
||||
|
||||
return aName.Equals(name) && (mInner.mNamespaceID == aNamespaceID);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsNodeInfo::Equals(const nsAString& aName, const nsAString& aPrefix,
|
||||
PRInt32 aNamespaceID) const
|
||||
{
|
||||
PRUnichar nullChar = '\0';
|
||||
const PRUnichar *name, *prefix = &nullChar;
|
||||
mInner.mName->GetUnicode(&name);
|
||||
|
||||
if (mInner.mPrefix) {
|
||||
mInner.mPrefix->GetUnicode(&prefix);
|
||||
}
|
||||
|
||||
return ((mInner.mNamespaceID == aNamespaceID) && aName.Equals(name) &&
|
||||
aPrefix.Equals(prefix));
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsNodeInfo::NamespaceEquals(const nsAString& aNamespaceURI) const
|
||||
{
|
||||
nsCOMPtr<nsINameSpaceManager> nsmgr;
|
||||
|
||||
NS_ENSURE_SUCCESS(mOwnerManager->GetNamespaceManager(*getter_AddRefs(nsmgr)),
|
||||
NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
PRInt32 nsid;
|
||||
nsmgr->GetNameSpaceID(aNamespaceURI, nsid);
|
||||
|
||||
return nsINodeInfo::NamespaceEquals(nsid);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsNodeInfo::QualifiedNameEquals(const nsAString& aQualifiedName) const
|
||||
{
|
||||
const PRUnichar *name;
|
||||
mInner.mName->GetUnicode(&name);
|
||||
|
||||
if (!mInner.mPrefix) {
|
||||
return aQualifiedName.Equals(name);
|
||||
}
|
||||
|
||||
nsAString::const_iterator start;
|
||||
aQualifiedName.BeginReading(start);
|
||||
|
||||
nsAString::const_iterator colon(start);
|
||||
|
||||
const PRUnichar *prefix;
|
||||
mInner.mPrefix->GetUnicode(&prefix);
|
||||
|
||||
PRUint32 len = nsCRT::strlen(prefix);
|
||||
|
||||
if (len >= aQualifiedName.Length()) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
colon.advance(len);
|
||||
|
||||
// If the character at the prefix length index is not a colon,
|
||||
// aQualifiedName is not equal to this string.
|
||||
if (*colon != ':') {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// Compare the prefix to the string from the start to the colon
|
||||
if (!Substring(start, colon).Equals(prefix)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
++colon; // Skip the ':'
|
||||
|
||||
nsAString::const_iterator end;
|
||||
aQualifiedName.EndReading(end);
|
||||
|
||||
// Compare the local name to the string between the colon and the
|
||||
// end of aQualifiedName
|
||||
return Substring(colon, end).Equals(name);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNodeInfo::NameChanged(nsIAtom *aName, nsINodeInfo*& aResult)
|
||||
{
|
||||
return mOwnerManager->GetNodeInfo(aName, mInner.mPrefix, mInner.mNamespaceID,
|
||||
aResult);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNodeInfo::PrefixChanged(nsIAtom *aPrefix, nsINodeInfo*& aResult)
|
||||
{
|
||||
return mOwnerManager->GetNodeInfo(mInner.mName, aPrefix, mInner.mNamespaceID,
|
||||
aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNodeInfo::GetDocument(nsIDocument*& aDocument) const
|
||||
{
|
||||
return mOwnerManager->GetDocument(aDocument);
|
||||
}
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsNodeInfo_h___
|
||||
#define nsNodeInfo_h___
|
||||
|
||||
#include "nsINodeInfo.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "plhash.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsNodeInfoManager;
|
||||
|
||||
class nsNodeInfo : public nsINodeInfo
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsINodeInfo
|
||||
NS_IMETHOD GetQualifiedName(nsAString &aQualifiedName) const;
|
||||
NS_IMETHOD GetLocalName(nsAString& aLocalName) const;
|
||||
NS_IMETHOD GetNamespaceURI(nsAString& aNameSpaceURI) const;
|
||||
NS_IMETHOD GetIDAttributeAtom(nsIAtom** aResult) const;
|
||||
NS_IMETHOD SetIDAttributeAtom(nsIAtom* aResult);
|
||||
NS_IMETHOD GetNodeInfoManager(nsINodeInfoManager*& aNodeInfoManager) const;
|
||||
NS_IMETHOD_(PRBool) Equals(const nsAString& aName) const;
|
||||
NS_IMETHOD_(PRBool) Equals(const nsAString& aName,
|
||||
const nsAString& aPrefix) const;
|
||||
NS_IMETHOD_(PRBool) Equals(const nsAString& aName,
|
||||
PRInt32 aNamespaceID) const;
|
||||
NS_IMETHOD_(PRBool) Equals(const nsAString& aName, const nsAString& aPrefix,
|
||||
PRInt32 aNamespaceID) const;
|
||||
NS_IMETHOD_(PRBool) NamespaceEquals(const nsAString& aNamespaceURI) const;
|
||||
NS_IMETHOD_(PRBool) QualifiedNameEquals(const nsAString& aQualifiedName) const;
|
||||
|
||||
NS_IMETHOD NameChanged(nsIAtom *aName, nsINodeInfo*& aResult);
|
||||
NS_IMETHOD PrefixChanged(nsIAtom *aPrefix, nsINodeInfo*& aResult);
|
||||
NS_IMETHOD GetDocument(nsIDocument*& aDocument) const;
|
||||
|
||||
// nsNodeInfo
|
||||
nsNodeInfo();
|
||||
virtual ~nsNodeInfo();
|
||||
|
||||
/*
|
||||
* Note! Init() must be called exactly once on every nsNodeInfo before
|
||||
* the object is used, if Init() returns an error code the nsNodeInfo
|
||||
* should not be used.
|
||||
*
|
||||
* aName and aOwnerManager may not be null.
|
||||
*/
|
||||
nsresult Init(nsIAtom *aName, nsIAtom *aPrefix, PRInt32 aNamespaceID,
|
||||
nsNodeInfoManager *aOwnerManager);
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIAtom> mIDAttributeAtom;
|
||||
|
||||
nsNodeInfoManager* mOwnerManager; // Strong reference!
|
||||
};
|
||||
|
||||
#endif /* nsNodeInfo_h___ */
|
||||
@@ -1,378 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsNodeInfoManager.h"
|
||||
#include "nsNodeInfo.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIDocument.h"
|
||||
|
||||
nsNodeInfoManager* nsNodeInfoManager::gAnonymousNodeInfoManager = nsnull;
|
||||
PRUint32 nsNodeInfoManager::gNodeManagerCount = 0;
|
||||
|
||||
|
||||
nsresult NS_NewNodeInfoManager(nsINodeInfoManager** aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
*aResult = new nsNodeInfoManager;
|
||||
NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
NS_ADDREF(*aResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
PLHashNumber
|
||||
nsNodeInfoManager::GetNodeInfoInnerHashValue(const void *key)
|
||||
{
|
||||
NS_ASSERTION(key, "Null key passed to nsNodeInfo::GetHashValue!");
|
||||
|
||||
const nsINodeInfo::nsNodeInfoInner *node =
|
||||
NS_REINTERPRET_CAST(const nsINodeInfo::nsNodeInfoInner *, key);
|
||||
|
||||
// Is this an acceptable hash value?
|
||||
return (PLHashNumber(NS_PTR_TO_INT32(node->mName)) & 0xffff) >> 8;
|
||||
}
|
||||
|
||||
|
||||
PRIntn
|
||||
nsNodeInfoManager::NodeInfoInnerKeyCompare(const void *key1, const void *key2)
|
||||
{
|
||||
NS_ASSERTION(key1 && key2, "Null key passed to NodeInfoInnerKeyCompare!");
|
||||
|
||||
const nsINodeInfo::nsNodeInfoInner *node1 =
|
||||
NS_REINTERPRET_CAST(const nsINodeInfo::nsNodeInfoInner *, key1);
|
||||
const nsINodeInfo::nsNodeInfoInner *node2 =
|
||||
NS_REINTERPRET_CAST(const nsINodeInfo::nsNodeInfoInner *, key2);
|
||||
|
||||
return (node1->mName == node2->mName &&
|
||||
node1->mPrefix == node2->mPrefix &&
|
||||
node1->mNamespaceID == node2->mNamespaceID);
|
||||
}
|
||||
|
||||
|
||||
nsNodeInfoManager::nsNodeInfoManager()
|
||||
: mDocument(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
if (gNodeManagerCount == 1 && gAnonymousNodeInfoManager) {
|
||||
/*
|
||||
* If we get here the global nodeinfo manager was the first one created,
|
||||
* in that case we're not holding a strong reference to the global nodeinfo
|
||||
* manager. Now we're creating one more nodeinfo manager so we'll grab
|
||||
* a strong reference to the global nodeinfo manager so that it's
|
||||
* lifetime will be longer than the lifetime of the other node managers.
|
||||
*/
|
||||
NS_ADDREF(gAnonymousNodeInfoManager);
|
||||
}
|
||||
|
||||
gNodeManagerCount++;
|
||||
|
||||
mNodeInfoHash = PL_NewHashTable(32, GetNodeInfoInnerHashValue,
|
||||
NodeInfoInnerKeyCompare,
|
||||
PL_CompareValues, nsnull, nsnull);
|
||||
|
||||
#ifdef DEBUG_jst
|
||||
printf ("Creating NodeInfoManager, gcount = %d\n", gNodeManagerCount);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
nsNodeInfoManager::~nsNodeInfoManager()
|
||||
{
|
||||
gNodeManagerCount--;
|
||||
|
||||
if (gNodeManagerCount == 1 && gAnonymousNodeInfoManager) {
|
||||
NS_RELEASE(gAnonymousNodeInfoManager);
|
||||
} else if (!gNodeManagerCount) {
|
||||
/*
|
||||
* Here we just make sure that we don't leave a dangling pointer to
|
||||
* the global nodeinfo manager after it's deleted.
|
||||
*/
|
||||
gAnonymousNodeInfoManager = nsnull;
|
||||
}
|
||||
|
||||
if (mNodeInfoHash)
|
||||
PL_HashTableDestroy(mNodeInfoHash);
|
||||
|
||||
#ifdef DEBUG_jst
|
||||
printf ("Removing NodeInfoManager, gcount = %d\n", gNodeManagerCount);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(nsNodeInfoManager, nsINodeInfoManager);
|
||||
|
||||
|
||||
// nsINodeInfoManager
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNodeInfoManager::Init(nsIDocument *aDocument,
|
||||
nsINameSpaceManager *aNameSpaceManager)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aNameSpaceManager);
|
||||
NS_ENSURE_TRUE(mNodeInfoHash, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
mDocument = aDocument;
|
||||
mNameSpaceManager = aNameSpaceManager;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNodeInfoManager::DropDocumentReference()
|
||||
{
|
||||
mDocument = nsnull;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNodeInfoManager::GetNodeInfo(nsIAtom *aName, nsIAtom *aPrefix,
|
||||
PRInt32 aNamespaceID, nsINodeInfo*& aNodeInfo)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aName);
|
||||
|
||||
nsINodeInfo::nsNodeInfoInner tmpKey(aName, aPrefix, aNamespaceID);
|
||||
|
||||
void *node = PL_HashTableLookup(mNodeInfoHash, &tmpKey);
|
||||
|
||||
if (node) {
|
||||
aNodeInfo = NS_STATIC_CAST(nsINodeInfo *, node);
|
||||
|
||||
NS_ADDREF(aNodeInfo);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsNodeInfo *newNodeInfo = new nsNodeInfo();
|
||||
NS_ENSURE_TRUE(newNodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
NS_ADDREF(newNodeInfo);
|
||||
|
||||
nsresult rv = newNodeInfo->Init(aName, aPrefix, aNamespaceID, this);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PLHashEntry *he;
|
||||
he = PL_HashTableAdd(mNodeInfoHash, &newNodeInfo->mInner, newNodeInfo);
|
||||
NS_ENSURE_TRUE(he, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
aNodeInfo = newNodeInfo;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNodeInfoManager::GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix,
|
||||
PRInt32 aNamespaceID, nsINodeInfo*& aNodeInfo)
|
||||
{
|
||||
NS_ENSURE_ARG(!aName.IsEmpty());
|
||||
|
||||
nsCOMPtr<nsIAtom> name(dont_AddRef(NS_NewAtom(aName)));
|
||||
NS_ENSURE_TRUE(name, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return GetNodeInfo(name, aPrefix, aNamespaceID, aNodeInfo);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNodeInfoManager::GetNodeInfo(const nsAString& aName,
|
||||
const nsAString& aPrefix, PRInt32 aNamespaceID,
|
||||
nsINodeInfo*& aNodeInfo)
|
||||
{
|
||||
NS_ENSURE_ARG(!aName.IsEmpty());
|
||||
|
||||
nsCOMPtr<nsIAtom> name(dont_AddRef(NS_NewAtom(aName)));
|
||||
NS_ENSURE_TRUE(name, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsCOMPtr<nsIAtom> prefix;
|
||||
|
||||
if (!aPrefix.IsEmpty()) {
|
||||
prefix = dont_AddRef(NS_NewAtom(aPrefix));
|
||||
NS_ENSURE_TRUE(prefix, NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
return GetNodeInfo(name, prefix, aNamespaceID, aNodeInfo);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNodeInfoManager::GetNodeInfo(const nsAString& aName,
|
||||
const nsAString& aPrefix,
|
||||
const nsAString& aNamespaceURI,
|
||||
nsINodeInfo*& aNodeInfo)
|
||||
{
|
||||
NS_ENSURE_ARG(!aName.IsEmpty());
|
||||
|
||||
nsCOMPtr<nsIAtom> name(dont_AddRef(NS_NewAtom(aName)));
|
||||
NS_ENSURE_TRUE(name, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsCOMPtr<nsIAtom> prefix;
|
||||
|
||||
if (!aPrefix.IsEmpty()) {
|
||||
prefix = dont_AddRef(NS_NewAtom(aPrefix));
|
||||
NS_ENSURE_TRUE(prefix, NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
if (!mNameSpaceManager) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
PRInt32 nsid;
|
||||
nsresult rv = mNameSpaceManager->RegisterNameSpace(aNamespaceURI, nsid);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return GetNodeInfo(name, prefix, nsid, aNodeInfo);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNodeInfoManager::GetNodeInfo(const nsAString& aQualifiedName,
|
||||
const nsAString& aNamespaceURI,
|
||||
nsINodeInfo*& aNodeInfo)
|
||||
{
|
||||
NS_ENSURE_ARG(!aQualifiedName.IsEmpty());
|
||||
|
||||
nsAutoString name(aQualifiedName);
|
||||
nsAutoString prefix;
|
||||
PRInt32 nsoffset = name.FindChar(':');
|
||||
if (-1 != nsoffset) {
|
||||
name.Left(prefix, nsoffset);
|
||||
name.Cut(0, nsoffset+1);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAtom> nameAtom(dont_AddRef(NS_NewAtom(name)));
|
||||
NS_ENSURE_TRUE(nameAtom, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsCOMPtr<nsIAtom> prefixAtom;
|
||||
|
||||
if (!prefix.IsEmpty()) {
|
||||
prefixAtom = dont_AddRef(NS_NewAtom(prefix));
|
||||
NS_ENSURE_TRUE(prefixAtom, NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
PRInt32 nsid = kNameSpaceID_None;
|
||||
|
||||
if (!aNamespaceURI.IsEmpty()) {
|
||||
NS_ENSURE_TRUE(mNameSpaceManager, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
nsresult rv = mNameSpaceManager->RegisterNameSpace(aNamespaceURI, nsid);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
return GetNodeInfo(nameAtom, prefixAtom, nsid, aNodeInfo);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNodeInfoManager::GetNamespaceManager(nsINameSpaceManager*& aNameSpaceManager)
|
||||
{
|
||||
NS_ENSURE_TRUE(mNameSpaceManager, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
aNameSpaceManager = mNameSpaceManager;
|
||||
NS_ADDREF(aNameSpaceManager);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNodeInfoManager::GetDocument(nsIDocument*& aDocument)
|
||||
{
|
||||
aDocument = mDocument;
|
||||
|
||||
NS_IF_ADDREF(aDocument);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsNodeInfoManager::RemoveNodeInfo(nsNodeInfo *aNodeInfo)
|
||||
{
|
||||
NS_WARN_IF_FALSE(aNodeInfo, "Trying to remove null nodeinfo from manager!");
|
||||
|
||||
if (aNodeInfo) {
|
||||
PRBool ret = PL_HashTableRemove(mNodeInfoHash, &aNodeInfo->mInner);
|
||||
|
||||
NS_WARN_IF_FALSE(ret, "Can't find nsINodeInfo to remove!!!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsNodeInfoManager::GetAnonymousManager(nsINodeInfoManager*& aNodeInfoManager)
|
||||
{
|
||||
if (!gAnonymousNodeInfoManager) {
|
||||
gAnonymousNodeInfoManager = new nsNodeInfoManager;
|
||||
|
||||
if (!gAnonymousNodeInfoManager)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(gAnonymousNodeInfoManager);
|
||||
|
||||
nsresult rv = NS_NewNameSpaceManager(getter_AddRefs(gAnonymousNodeInfoManager->mNameSpaceManager));
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(gAnonymousNodeInfoManager);
|
||||
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
aNodeInfoManager = gAnonymousNodeInfoManager;
|
||||
|
||||
/*
|
||||
* If the only nodeinfo manager is the global one we don't hold a ref
|
||||
* since the global nodeinfo manager should be destroyed when it's released,
|
||||
* even if it's the last one arround.
|
||||
*/
|
||||
if (gNodeManagerCount > 1) {
|
||||
NS_ADDREF(aNodeInfoManager);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -1,108 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsNodeInfoManager_h___
|
||||
#define nsNodeInfoManager_h___
|
||||
|
||||
#include "nsINodeInfo.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "plhash.h"
|
||||
|
||||
class nsNodeInfo;
|
||||
|
||||
|
||||
class nsNodeInfoManager : public nsINodeInfoManager
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsINodeInfoManager
|
||||
NS_IMETHOD Init(nsIDocument *aDocument,
|
||||
nsINameSpaceManager *aNameSpaceManager);
|
||||
NS_IMETHOD DropDocumentReference();
|
||||
NS_IMETHOD GetNodeInfo(nsIAtom *aName, nsIAtom *aPrefix,
|
||||
PRInt32 aNamespaceID, nsINodeInfo*& aNodeInfo);
|
||||
NS_IMETHOD GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix,
|
||||
PRInt32 aNamespaceID, nsINodeInfo*& aNodeInfo);
|
||||
NS_IMETHOD GetNodeInfo(const nsAString& aName, const nsAString& aPrefix,
|
||||
PRInt32 aNamespaceID, nsINodeInfo*& aNodeInfo);
|
||||
NS_IMETHOD GetNodeInfo(const nsAString& aName, const nsAString& aPrefix,
|
||||
const nsAString& aNamespaceURI,
|
||||
nsINodeInfo*& aNodeInfo);
|
||||
NS_IMETHOD GetNodeInfo(const nsAString& aQualifiedName,
|
||||
const nsAString& aNamespaceURI,
|
||||
nsINodeInfo*& aNodeInfo);
|
||||
NS_IMETHOD GetNamespaceManager(nsINameSpaceManager*& aNameSpaceManager);
|
||||
NS_IMETHOD GetDocument(nsIDocument*& aDocument);
|
||||
|
||||
// nsNodeInfoManager
|
||||
nsNodeInfoManager();
|
||||
virtual ~nsNodeInfoManager();
|
||||
|
||||
void RemoveNodeInfo(nsNodeInfo *aNodeInfo);
|
||||
|
||||
static nsresult GetAnonymousManager(nsINodeInfoManager*& aNodeInfoManager);
|
||||
|
||||
private:
|
||||
static PRIntn PR_CALLBACK NodeInfoInnerKeyCompare(const void *key1,
|
||||
const void *key2);
|
||||
static PLHashNumber PR_CALLBACK GetNodeInfoInnerHashValue(const void *key);
|
||||
|
||||
|
||||
PLHashTable *mNodeInfoHash;
|
||||
nsCOMPtr<nsINameSpaceManager> mNameSpaceManager;
|
||||
nsIDocument *mDocument; // WEAK
|
||||
|
||||
/*
|
||||
* gAnonymousNodeInfoManager is a global nodeinfo manager used for nodes
|
||||
* that are no longer part of a document and for nodes that are created
|
||||
* where no document is accessible.
|
||||
*
|
||||
* gAnonymousNodeInfoManager is allocated when requested for the first time
|
||||
* and once the last nodeinfo manager (appart from gAnonymousNodeInfoManager)
|
||||
* is destroyed gAnonymousNodeInfoManager is destroyed. If the global
|
||||
* nodeinfo manager is the only nodeinfo manager used it can be deleted
|
||||
* and later reallocated if all users of the nodeinfo manager drops the
|
||||
* referernces to it.
|
||||
*/
|
||||
static nsNodeInfoManager *gAnonymousNodeInfoManager;
|
||||
static PRUint32 gNodeManagerCount;
|
||||
};
|
||||
|
||||
#endif /* nsNodeInfoManager_h___ */
|
||||
@@ -1,161 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsParserUtils.h"
|
||||
#include "nsIParser.h" // for kQuote et. al.
|
||||
#include "jsapi.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
PRBool
|
||||
nsParserUtils::GetQuotedAttributeValue(const nsAString& aSource,
|
||||
const nsAString& aAttribute,
|
||||
nsAString& aValue)
|
||||
{
|
||||
aValue.Truncate();
|
||||
nsAString::const_iterator start, end;
|
||||
aSource.BeginReading(start);
|
||||
aSource.EndReading(end);
|
||||
nsAString::const_iterator iter(end);
|
||||
|
||||
while (start != end) {
|
||||
if (FindInReadable(aAttribute, start, iter)) {
|
||||
// walk past any whitespace
|
||||
while (iter != end && nsCRT::IsAsciiSpace(*iter)) {
|
||||
++iter;
|
||||
}
|
||||
|
||||
if (iter == end)
|
||||
break;
|
||||
|
||||
// valid name="value" pair?
|
||||
if (*iter != '=') {
|
||||
start = iter;
|
||||
iter = end;
|
||||
continue;
|
||||
}
|
||||
// move past the =
|
||||
++iter;
|
||||
|
||||
while (iter != end && nsCRT::IsAsciiSpace(*iter)) {
|
||||
++iter;
|
||||
}
|
||||
|
||||
if (iter == end)
|
||||
break;
|
||||
|
||||
PRUnichar q = *iter;
|
||||
if (q != '"' && q != '\'') {
|
||||
start = iter;
|
||||
iter = end;
|
||||
continue;
|
||||
}
|
||||
|
||||
// point to the first char of the value
|
||||
++iter;
|
||||
start = iter;
|
||||
if (FindCharInReadable(q, iter, end)) {
|
||||
aValue = Substring(start, iter);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
// we've run out of string. Just return...
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
|
||||
// XXX Stolen from nsHTMLContentSink. Needs to be shared.
|
||||
// XXXbe share also with nsRDFParserUtils.cpp and nsHTMLContentSink.cpp
|
||||
// Returns PR_TRUE if the language name is a version of JavaScript and
|
||||
// PR_FALSE otherwise
|
||||
PRBool
|
||||
nsParserUtils::IsJavaScriptLanguage(const nsString& aName, const char* *aVersion)
|
||||
{
|
||||
JSVersion version = JSVERSION_UNKNOWN;
|
||||
|
||||
if (aName.EqualsIgnoreCase("JavaScript") ||
|
||||
aName.EqualsIgnoreCase("LiveScript") ||
|
||||
aName.EqualsIgnoreCase("Mocha")) {
|
||||
version = JSVERSION_DEFAULT;
|
||||
}
|
||||
else if (aName.EqualsIgnoreCase("JavaScript1.0")) {
|
||||
version = JSVERSION_1_0;
|
||||
}
|
||||
else if (aName.EqualsIgnoreCase("JavaScript1.1")) {
|
||||
version = JSVERSION_1_1;
|
||||
}
|
||||
else if (aName.EqualsIgnoreCase("JavaScript1.2")) {
|
||||
version = JSVERSION_1_2;
|
||||
}
|
||||
else if (aName.EqualsIgnoreCase("JavaScript1.3")) {
|
||||
version = JSVERSION_1_3;
|
||||
}
|
||||
else if (aName.EqualsIgnoreCase("JavaScript1.4")) {
|
||||
version = JSVERSION_1_4;
|
||||
}
|
||||
else if (aName.EqualsIgnoreCase("JavaScript1.5")) {
|
||||
version = JSVERSION_1_5;
|
||||
}
|
||||
if (version == JSVERSION_UNKNOWN)
|
||||
return PR_FALSE;
|
||||
*aVersion = JS_VersionToString(version);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
nsParserUtils::SplitMimeType(const nsAString& aValue, nsString& aType,
|
||||
nsString& aParams)
|
||||
{
|
||||
aType.Truncate();
|
||||
aParams.Truncate();
|
||||
PRInt32 semiIndex = aValue.FindChar(PRUnichar(';'));
|
||||
if (-1 != semiIndex) {
|
||||
aType = Substring(aValue, 0, semiIndex);
|
||||
aParams = Substring(aValue, semiIndex + 1,
|
||||
aValue.Length() - (semiIndex + 1));
|
||||
aParams.StripWhitespace();
|
||||
}
|
||||
else {
|
||||
aType = aValue;
|
||||
}
|
||||
aType.StripWhitespace();
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsParserUtils_h__
|
||||
#define nsParserUtils_h__
|
||||
|
||||
#include "nsString.h"
|
||||
|
||||
class nsParserUtils {
|
||||
public:
|
||||
static PRBool
|
||||
GetQuotedAttributeValue(const nsAString& aSource,
|
||||
const nsAString& aAttribute,
|
||||
nsAString& aValue);
|
||||
|
||||
static PRBool
|
||||
IsJavaScriptLanguage(const nsString& aName, const char* *aVersion);
|
||||
|
||||
static void
|
||||
SplitMimeType(const nsAString& aValue, nsString& aType,
|
||||
nsString& aParams);
|
||||
};
|
||||
|
||||
#endif // nsParserUtils_h__
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,260 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsPlainTextSerializer_h__
|
||||
#define nsPlainTextSerializer_h__
|
||||
|
||||
#include "nsIContentSerializer.h"
|
||||
#include "nsIHTMLContentSink.h"
|
||||
#include "nsHTMLTags.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsILineBreaker.h"
|
||||
#include "nsIParserService.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIHTMLToTextSink.h"
|
||||
#include "nsIDocumentEncoder.h"
|
||||
|
||||
|
||||
class nsPlainTextSerializer : public nsIContentSerializer,
|
||||
public nsIHTMLContentSink,
|
||||
public nsIHTMLToTextSink
|
||||
{
|
||||
public:
|
||||
nsPlainTextSerializer();
|
||||
virtual ~nsPlainTextSerializer();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIContentSerializer
|
||||
NS_IMETHOD Init(PRUint32 flags, PRUint32 aWrapColumn,
|
||||
nsIAtom* 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,
|
||||
PRBool aHasChildren,
|
||||
nsAString& aStr);
|
||||
NS_IMETHOD AppendElementEnd(nsIDOMElement *aElement,
|
||||
nsAString& aStr);
|
||||
NS_IMETHOD Flush(nsAString& aStr);
|
||||
|
||||
// nsIContentSink
|
||||
NS_IMETHOD WillBuildModel(void) { return NS_OK; }
|
||||
NS_IMETHOD DidBuildModel(PRInt32 aQualityLevel) { 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 nsIParserNode& aNode);
|
||||
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) { return NS_OK; }
|
||||
NS_IMETHOD FlushPendingNotifications() { return NS_OK; }
|
||||
NS_IMETHOD SetDocumentCharset(nsAString& aCharset) { return NS_OK; }
|
||||
NS_IMETHOD NotifyTagObservers(nsIParserNode* aNode) { return NS_OK; }
|
||||
|
||||
// nsIHTMLContentSink
|
||||
NS_IMETHOD SetTitle(const nsString& aValue) { return NS_OK; }
|
||||
NS_IMETHOD OpenHTML(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseHTML(const nsIParserNode& aNode);
|
||||
NS_IMETHOD OpenHead(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseHead(const nsIParserNode& aNode);
|
||||
NS_IMETHOD OpenBody(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseBody(const nsIParserNode& aNode);
|
||||
NS_IMETHOD OpenForm(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseForm(const nsIParserNode& aNode);
|
||||
NS_IMETHOD OpenMap(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseMap(const nsIParserNode& aNode);
|
||||
NS_IMETHOD OpenFrameset(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseFrameset(const nsIParserNode& aNode);
|
||||
NS_IMETHOD GetPref(PRInt32 aTag,PRBool& aPref);
|
||||
NS_IMETHOD_(PRBool) IsFormOnStack() { return PR_FALSE; }
|
||||
|
||||
NS_IMETHOD DoFragment(PRBool aFlag);
|
||||
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; }
|
||||
|
||||
// nsIHTMLToTextSink
|
||||
NS_IMETHOD Initialize(nsAString* aOutString,
|
||||
PRUint32 aFlags, PRUint32 aWrapCol);
|
||||
|
||||
protected:
|
||||
nsresult GetAttributeValue(nsIAtom* aName, nsString& aValueRet);
|
||||
void AddToLine(const PRUnichar* aStringToAdd, PRInt32 aLength);
|
||||
void EndLine(PRBool softlinebreak);
|
||||
void EnsureVerticalSpace(PRInt32 noOfRows);
|
||||
void FlushLine();
|
||||
void OutputQuotesAndIndent(PRBool stripTrailingSpaces=PR_FALSE);
|
||||
void Output(nsString& aString);
|
||||
void Write(const nsAString& aString);
|
||||
PRBool IsBlockLevel(PRInt32 aId);
|
||||
PRBool IsContainer(PRInt32 aId);
|
||||
PRBool IsInPre();
|
||||
PRBool IsCurrentNodeConverted();
|
||||
nsresult GetIdForContent(nsIContent* aContent, PRInt32* aID);
|
||||
nsresult GetParserService(nsIParserService** aParserService);
|
||||
nsresult DoOpenContainer(PRInt32 aTag);
|
||||
nsresult DoCloseContainer(PRInt32 aTag);
|
||||
nsresult DoAddLeaf(PRInt32 aTag, const nsAString& aText);
|
||||
|
||||
// Inlined functions
|
||||
inline PRBool MayWrap()
|
||||
{
|
||||
return mWrapColumn &&
|
||||
((mFlags & nsIDocumentEncoder::OutputFormatted) ||
|
||||
(mFlags & nsIDocumentEncoder::OutputWrap));
|
||||
}
|
||||
|
||||
inline PRBool DoOutput()
|
||||
{
|
||||
return !mInHead;
|
||||
}
|
||||
|
||||
protected:
|
||||
nsString mCurrentLine;
|
||||
|
||||
PRPackedBool mInHead;
|
||||
PRPackedBool mAtFirstColumn;
|
||||
|
||||
// Handling of quoted text (for mail):
|
||||
// Quotes need to be wrapped differently from non-quoted text,
|
||||
// because quoted text has a few extra characters (e.g. ">> ")
|
||||
// which makes the line length longer.
|
||||
// Mail can represent quotes in different ways: it can wrap
|
||||
// quotes in a <pre> (if editor.quotesPreformatted is set),
|
||||
// or not wrapped in any special tag (if mail.compose.wrap_to_window_width)
|
||||
// or in a <span> (if neither of the above are set).
|
||||
PRPackedBool mQuotesPreformatted; // expect quotes wrapped in <pre>
|
||||
PRPackedBool mDontWrapAnyQuotes; // no special quote markers
|
||||
|
||||
PRPackedBool mStructs; // Output structs (pref)
|
||||
|
||||
PRInt32 mIndent;
|
||||
// mInIndentString keeps a header that has to be written in the indent.
|
||||
// That could be, for instance, the bullet in a bulleted list.
|
||||
nsString mInIndentString;
|
||||
PRInt32 mCiteQuoteLevel;
|
||||
PRInt32 mFlags;
|
||||
PRInt32 mFloatingLines; // To store the number of lazy line breaks
|
||||
|
||||
// The wrap column is how many standard sized chars (western languages)
|
||||
// should be allowed on a line. There could be less chars if the chars
|
||||
// are wider than latin chars of more if the chars are more narrow.
|
||||
PRUint32 mWrapColumn;
|
||||
|
||||
// The width of the line as it will appear on the screen (approx.)
|
||||
PRUint32 mCurrentLineWidth;
|
||||
|
||||
// Treat quoted text as though it's preformatted -- don't wrap it.
|
||||
// Having it on a pref is a temporary measure, See bug 69638.
|
||||
PRInt32 mSpanLevel;
|
||||
|
||||
|
||||
PRInt32 mEmptyLines; // Will be the number of empty lines before
|
||||
// the current. 0 if we are starting a new
|
||||
// line and -1 if we are in a line.
|
||||
|
||||
PRPackedBool mInWhitespace;
|
||||
PRPackedBool mPreFormatted;
|
||||
PRPackedBool mStartedOutput; // we've produced at least a character
|
||||
|
||||
// While handling a new tag, this variable should remind if any line break
|
||||
// is due because of a closing tag. Setting it to "TRUE" while closing the tags.
|
||||
// Hence opening tags are guaranteed to start with appropriate line breaks.
|
||||
PRPackedBool mLineBreakDue;
|
||||
|
||||
nsString mURL;
|
||||
PRInt32 mHeaderStrategy; /* Header strategy (pref)
|
||||
0 = no indention
|
||||
1 = indention, increased with
|
||||
header level (default)
|
||||
2 = numbering and slight indention */
|
||||
PRInt32 mHeaderCounter[7]; /* For header-numbering:
|
||||
Number of previous headers of
|
||||
the same depth and in the same
|
||||
section.
|
||||
mHeaderCounter[1] for <h1> etc. */
|
||||
|
||||
nsCOMPtr<nsIContent> mContent;
|
||||
nsIParserNode* mParserNode;
|
||||
|
||||
nsAString* mOutputString;
|
||||
|
||||
// The tag stack: the stack of tags we're operating on, so we can nest:
|
||||
nsHTMLTag *mTagStack;
|
||||
PRUint32 mTagStackIndex;
|
||||
|
||||
// Content in the stack above this index should be ignored:
|
||||
PRUint32 mIgnoreAboveIndex;
|
||||
|
||||
// The stack for ordered lists:
|
||||
PRInt32 *mOLStack;
|
||||
PRUint32 mOLStackIndex;
|
||||
|
||||
PRUint32 mULCount;
|
||||
|
||||
nsString mLineBreak;
|
||||
nsCOMPtr<nsILineBreaker> mLineBreaker;
|
||||
nsCOMPtr<nsIParserService> mParserService;
|
||||
|
||||
// Conveniance constant. It would be nice to have it as a const static
|
||||
// variable, but that causes issues with OpenBSD and module unloading.
|
||||
const nsString kSpace;
|
||||
};
|
||||
|
||||
extern nsresult NS_NewPlainTextSerializer(nsIContentSerializer** aSerializer);
|
||||
|
||||
#endif
|
||||
@@ -1,189 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 Netscape are
|
||||
* Copyright (C) 1999, Mozilla. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*/
|
||||
|
||||
#include "nsPrintPreviewListener.h"
|
||||
#include "nsIDOMKeyEvent.h"
|
||||
|
||||
NS_IMPL_ADDREF(nsPrintPreviewListener)
|
||||
NS_IMPL_RELEASE(nsPrintPreviewListener)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsPrintPreviewListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMContextMenuListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMKeyListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMMouseListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMMouseMotionListener)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIDOMEventListener, nsIDOMContextMenuListener)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMContextMenuListener)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
||||
//
|
||||
// nsPrintPreviewListener ctor
|
||||
//
|
||||
nsPrintPreviewListener::nsPrintPreviewListener (nsIDOMEventReceiver* aEVRec)
|
||||
: mEventReceiver(aEVRec),
|
||||
mRegFlags(REG_NONE_LISTENER)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
NS_ADDREF_THIS();
|
||||
} // ctor
|
||||
|
||||
|
||||
//-------------------------------------------------------
|
||||
//
|
||||
// AddListeners
|
||||
//
|
||||
// Subscribe to the events that will allow us to track various events.
|
||||
//
|
||||
nsresult
|
||||
nsPrintPreviewListener::AddListeners()
|
||||
{
|
||||
if (mRegFlags != REG_NONE_LISTENER) return NS_ERROR_FAILURE;
|
||||
|
||||
if (mEventReceiver) {
|
||||
nsIDOMContextMenuListener *pListener = NS_STATIC_CAST(nsIDOMContextMenuListener *, this);
|
||||
NS_ASSERTION(pListener, "Cast can't fail!");
|
||||
|
||||
nsresult rv = mEventReceiver->AddEventListenerByIID(pListener, NS_GET_IID(nsIDOMContextMenuListener));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mRegFlags |= REG_CONTEXTMENU_LISTENER;
|
||||
|
||||
rv = mEventReceiver->AddEventListenerByIID(pListener, NS_GET_IID(nsIDOMKeyListener));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mRegFlags |= REG_KEY_LISTENER;
|
||||
|
||||
rv = mEventReceiver->AddEventListenerByIID(pListener, NS_GET_IID(nsIDOMMouseListener));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mRegFlags |= REG_MOUSE_LISTENER;
|
||||
|
||||
rv = mEventReceiver->AddEventListenerByIID(pListener, NS_GET_IID(nsIDOMMouseMotionListener));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mRegFlags |= REG_MOUSEMOTION_LISTENER;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------
|
||||
//
|
||||
// RemoveListeners
|
||||
//
|
||||
// Unsubscribe from all the various events that we were listening to.
|
||||
//
|
||||
nsresult
|
||||
nsPrintPreviewListener::RemoveListeners()
|
||||
{
|
||||
if (mEventReceiver && mRegFlags != REG_NONE_LISTENER) {
|
||||
nsIDOMContextMenuListener *pListener = NS_STATIC_CAST(nsIDOMContextMenuListener *, this);
|
||||
NS_ASSERTION(pListener, "Cast can't fail!");
|
||||
|
||||
// ignore return values, so we can try to unregister the other listeners
|
||||
if (mRegFlags & REG_CONTEXTMENU_LISTENER) {
|
||||
mEventReceiver->RemoveEventListenerByIID(pListener, NS_GET_IID(nsIDOMContextMenuListener));
|
||||
}
|
||||
if (mRegFlags & REG_KEY_LISTENER) {
|
||||
mEventReceiver->RemoveEventListenerByIID(pListener, NS_GET_IID(nsIDOMKeyListener));
|
||||
}
|
||||
if (mRegFlags & REG_MOUSE_LISTENER) {
|
||||
mEventReceiver->RemoveEventListenerByIID(pListener, NS_GET_IID(nsIDOMMouseListener));
|
||||
}
|
||||
if (mRegFlags & REG_MOUSEMOTION_LISTENER) {
|
||||
mEventReceiver->RemoveEventListenerByIID(pListener, NS_GET_IID(nsIDOMMouseMotionListener));
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------
|
||||
//
|
||||
// IsKeyOK
|
||||
//
|
||||
// Helper function to let certain key events thru
|
||||
//
|
||||
static PRBool IsKeyOK(nsIDOMEvent* aEvent)
|
||||
{
|
||||
const PRUint32 kOKKeyCodes[] = {nsIDOMKeyEvent::DOM_VK_PAGE_UP, nsIDOMKeyEvent::DOM_VK_PAGE_DOWN,
|
||||
nsIDOMKeyEvent::DOM_VK_UP, nsIDOMKeyEvent::DOM_VK_DOWN,
|
||||
nsIDOMKeyEvent::DOM_VK_HOME, nsIDOMKeyEvent::DOM_VK_END,
|
||||
nsIDOMKeyEvent::DOM_VK_TAB, 0};
|
||||
|
||||
nsCOMPtr<nsIDOMKeyEvent> keyEvent(do_QueryInterface(aEvent));
|
||||
if (keyEvent) {
|
||||
PRBool b;
|
||||
keyEvent->GetAltKey(&b);
|
||||
if (b) return PR_FALSE;
|
||||
keyEvent->GetCtrlKey(&b);
|
||||
if (b) return PR_FALSE;
|
||||
keyEvent->GetShiftKey(&b);
|
||||
if (b) return PR_FALSE;
|
||||
|
||||
PRUint32 keyCode;
|
||||
keyEvent->GetKeyCode(&keyCode);
|
||||
PRInt32 i = 0;
|
||||
while (kOKKeyCodes[i] != 0) {
|
||||
if (keyCode == kOKKeyCodes[i]) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------
|
||||
//
|
||||
// KeyDown
|
||||
//
|
||||
NS_IMETHODIMP nsPrintPreviewListener::KeyDown(nsIDOMEvent* aKeyEvent)
|
||||
{
|
||||
if (!IsKeyOK(aKeyEvent)) {
|
||||
aKeyEvent->PreventDefault();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------
|
||||
//
|
||||
// KeyUp
|
||||
//
|
||||
NS_IMETHODIMP nsPrintPreviewListener::KeyUp(nsIDOMEvent* aKeyEvent)
|
||||
{
|
||||
if (!IsKeyOK(aKeyEvent)) {
|
||||
aKeyEvent->PreventDefault();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------
|
||||
//
|
||||
// KeyPress
|
||||
//
|
||||
NS_IMETHODIMP nsPrintPreviewListener::KeyPress(nsIDOMEvent* aKeyEvent)
|
||||
{
|
||||
if (!IsKeyOK(aKeyEvent)) {
|
||||
aKeyEvent->PreventDefault();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 Netscape are
|
||||
* Copyright (C) 1999, Mozilla. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef nsPrintPreviewListener_h__
|
||||
#define nsPrintPreviewListener_h__
|
||||
|
||||
// Interfaces needed to be included
|
||||
#include "nsIDOMContextMenuListener.h"
|
||||
#include "nsIDOMKeyListener.h"
|
||||
#include "nsIDOMMouseListener.h"
|
||||
#include "nsIDOMMouseMotionListener.h"
|
||||
// Helper Classes
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#define REG_NONE_LISTENER 0x00
|
||||
#define REG_CONTEXTMENU_LISTENER 0x01
|
||||
#define REG_KEY_LISTENER 0x02
|
||||
#define REG_MOUSE_LISTENER 0x04
|
||||
#define REG_MOUSEMOTION_LISTENER 0x08
|
||||
|
||||
//
|
||||
// class nsPrintPreviewListener
|
||||
//
|
||||
// The class that listens to the chrome events and tells the embedding
|
||||
// chrome to show context menus, as appropriate. Handles registering itself
|
||||
// with the DOM with AddChromeListeners() and removing itself with
|
||||
// RemoveChromeListeners().
|
||||
//
|
||||
class nsPrintPreviewListener : public nsIDOMContextMenuListener,
|
||||
public nsIDOMKeyListener,
|
||||
public nsIDOMMouseListener,
|
||||
public nsIDOMMouseMotionListener
|
||||
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsPrintPreviewListener(nsIDOMEventReceiver* aEVRec);
|
||||
virtual ~nsPrintPreviewListener()
|
||||
{
|
||||
}
|
||||
|
||||
// nsIDOMContextMenuListener
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
NS_IMETHOD ContextMenu (nsIDOMEvent* aEvent) { aEvent->PreventDefault(); return NS_OK; }
|
||||
|
||||
// nsIDOMKeyListener
|
||||
NS_IMETHOD KeyDown(nsIDOMEvent* aKeyEvent);
|
||||
NS_IMETHOD KeyUp(nsIDOMEvent* aKeyEvent);
|
||||
NS_IMETHOD KeyPress(nsIDOMEvent* aKeyEvent);
|
||||
|
||||
// nsIDOMMouseListener
|
||||
NS_IMETHOD MouseDown(nsIDOMEvent* aMouseEvent) { aMouseEvent->StopPropagation();aMouseEvent->PreventDefault(); return NS_OK; }
|
||||
NS_IMETHOD MouseUp(nsIDOMEvent* aMouseEvent) { aMouseEvent->StopPropagation();aMouseEvent->PreventDefault(); return NS_OK; }
|
||||
NS_IMETHOD MouseClick(nsIDOMEvent* aMouseEvent) { aMouseEvent->StopPropagation();aMouseEvent->PreventDefault(); return NS_OK; }
|
||||
NS_IMETHOD MouseDblClick(nsIDOMEvent* aMouseEvent) { aMouseEvent->StopPropagation();aMouseEvent->PreventDefault(); return NS_OK; }
|
||||
NS_IMETHOD MouseOver(nsIDOMEvent* aMouseEvent) { aMouseEvent->StopPropagation();aMouseEvent->PreventDefault(); return NS_OK; }
|
||||
NS_IMETHOD MouseOut(nsIDOMEvent* aMouseEvent) { aMouseEvent->StopPropagation();aMouseEvent->PreventDefault(); return NS_OK; }
|
||||
|
||||
// nsIDOMMouseMotionListener
|
||||
NS_IMETHOD DragMove(nsIDOMEvent* aMouseEvent) { return NS_OK; };
|
||||
NS_IMETHOD MouseMove(nsIDOMEvent* aMouseEvent) { aMouseEvent->PreventDefault(); return NS_OK; }
|
||||
|
||||
// Add/remove the relevant listeners, based on what interfaces
|
||||
// the embedding chrome implements.
|
||||
nsresult AddListeners();
|
||||
nsresult RemoveListeners();
|
||||
|
||||
private:
|
||||
|
||||
nsCOMPtr<nsIDOMEventReceiver> mEventReceiver;
|
||||
PRInt8 mRegFlags;
|
||||
|
||||
}; // class nsPrintPreviewListener
|
||||
|
||||
|
||||
|
||||
#endif /* nsPrintPreviewListener_h__ */
|
||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user