1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/parser/htmlparser/public/nsIHTMLContentSink.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,89 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 +#ifndef nsIHTMLContentSink_h___ 1.9 +#define nsIHTMLContentSink_h___ 1.10 + 1.11 +/** 1.12 + * This interface is OBSOLETE and in the process of being REMOVED. 1.13 + * Do NOT implement! 1.14 + * 1.15 + * This file declares the concrete HTMLContentSink class. 1.16 + * This class is used during the parsing process as the 1.17 + * primary interface between the parser and the content 1.18 + * model. 1.19 + * 1.20 + * After the tokenizer completes, the parser iterates over 1.21 + * the known token list. As the parser identifies valid 1.22 + * elements, it calls the contentsink interface to notify 1.23 + * the content model that a new node or child node is being 1.24 + * created and added to the content model. 1.25 + * 1.26 + * The HTMLContentSink interface assumes 4 underlying 1.27 + * containers: HTML, HEAD, BODY and FRAMESET. Before 1.28 + * accessing any these, the parser will call the appropriate 1.29 + * OpennsIHTMLContentSink method: OpenHTML,OpenHead,OpenBody,OpenFrameSet; 1.30 + * likewise, the ClosensIHTMLContentSink version will be called when the 1.31 + * parser is done with a given section. 1.32 + * 1.33 + * IMPORTANT: The parser may Open each container more than 1.34 + * once! This is due to the irregular nature of HTML files. 1.35 + * For example, it is possible to encounter plain text at 1.36 + * the start of an HTML document (that precedes the HTML tag). 1.37 + * Such text is treated as if it were part of the body. 1.38 + * In such cases, the parser will Open the body, pass the text- 1.39 + * node in and then Close the body. The body will likely be 1.40 + * re-Opened later when the actual <BODY> tag has been seen. 1.41 + * 1.42 + * Containers within the body are Opened and Closed 1.43 + * using the OpenContainer(...) and CloseContainer(...) calls. 1.44 + * It is assumed that the document or contentSink is 1.45 + * maintaining its state to manage where new content should 1.46 + * be added to the underlying document. 1.47 + * 1.48 + * NOTE: OpenHTML() and OpenBody() may get called multiple times 1.49 + * in the same document. That's fine, and it doesn't mean 1.50 + * that we have multiple bodies or HTML's. 1.51 + * 1.52 + * NOTE: I haven't figured out how sub-documents (non-frames) 1.53 + * are going to be handled. Stay tuned. 1.54 + */ 1.55 +#include "nsIContentSink.h" 1.56 +#include "nsHTMLTags.h" 1.57 + 1.58 +#define NS_IHTML_CONTENT_SINK_IID \ 1.59 + {0xefc5af86, 0x5cfd, 0x4918, {0x9d, 0xd3, 0x5f, 0x7a, 0xb2, 0x88, 0xb2, 0x68}} 1.60 + 1.61 +/** 1.62 + * This interface is OBSOLETE and in the process of being REMOVED. 1.63 + * Do NOT implement! 1.64 + */ 1.65 +class nsIHTMLContentSink : public nsIContentSink 1.66 +{ 1.67 +public: 1.68 + 1.69 + NS_DECLARE_STATIC_IID_ACCESSOR(NS_IHTML_CONTENT_SINK_IID) 1.70 + 1.71 + enum ElementType { eHTML, eBody }; 1.72 + 1.73 + /** 1.74 + * This method is used to open a generic container in the sink. 1.75 + * 1.76 + * @update 4/1/98 gess 1.77 + */ 1.78 + NS_IMETHOD OpenContainer(ElementType aNodeType) = 0; 1.79 + 1.80 + /** 1.81 + * This method gets called by the parser when a close 1.82 + * container tag has been consumed and needs to be closed. 1.83 + * 1.84 + * @param aTag - The tag to be closed. 1.85 + */ 1.86 + NS_IMETHOD CloseContainer(ElementType aTag) = 0; 1.87 +}; 1.88 + 1.89 +NS_DEFINE_STATIC_IID_ACCESSOR(nsIHTMLContentSink, NS_IHTML_CONTENT_SINK_IID) 1.90 + 1.91 +#endif /* nsIHTMLContentSink_h___ */ 1.92 +