parser/htmlparser/src/CNavDTD.cpp

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:a4d439abd67b
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set sw=2 ts=2 et tw=78: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 #include "nsISupports.h"
8 #include "nsISupportsImpl.h"
9 #include "nsIParser.h"
10 #include "CNavDTD.h"
11 #include "nsIHTMLContentSink.h"
12
13 NS_IMPL_ISUPPORTS(CNavDTD, nsIDTD);
14
15 CNavDTD::CNavDTD()
16 {
17 }
18
19 CNavDTD::~CNavDTD()
20 {
21 }
22
23 NS_IMETHODIMP
24 CNavDTD::WillBuildModel(const CParserContext& aParserContext,
25 nsITokenizer* aTokenizer,
26 nsIContentSink* aSink)
27 {
28 return NS_OK;
29 }
30
31 NS_IMETHODIMP
32 CNavDTD::BuildModel(nsITokenizer* aTokenizer,
33 nsIContentSink* aSink)
34 {
35 // NB: It is important to throw STOPPARSING if the sink is the wrong type in
36 // order to make sure nsParser cleans up properly after itself.
37 nsCOMPtr<nsIHTMLContentSink> sink = do_QueryInterface(aSink);
38 if (!sink) {
39 return NS_ERROR_HTMLPARSER_STOPPARSING;
40 }
41
42 nsresult rv = sink->OpenContainer(nsIHTMLContentSink::eHTML);
43 NS_ENSURE_SUCCESS(rv, rv);
44 rv = sink->OpenContainer(nsIHTMLContentSink::eBody);
45 NS_ENSURE_SUCCESS(rv, rv);
46
47 rv = sink->CloseContainer(nsIHTMLContentSink::eBody);
48 MOZ_ASSERT(NS_SUCCEEDED(rv));
49 rv = sink->CloseContainer(nsIHTMLContentSink::eHTML);
50 MOZ_ASSERT(NS_SUCCEEDED(rv));
51
52 return NS_OK;
53 }
54
55 NS_IMETHODIMP
56 CNavDTD::DidBuildModel(nsresult anErrorCode)
57 {
58 return NS_OK;
59 }
60
61 NS_IMETHODIMP_(void)
62 CNavDTD::Terminate()
63 {
64 }
65
66
67 NS_IMETHODIMP_(int32_t)
68 CNavDTD::GetType()
69 {
70 return NS_IPARSER_FLAG_HTML;
71 }
72
73 NS_IMETHODIMP_(nsDTDMode)
74 CNavDTD::GetMode() const
75 {
76 return eDTDMode_quirks;
77 }
78
79 NS_IMETHODIMP_(bool)
80 CNavDTD::CanContain(int32_t aParent,int32_t aChild) const
81 {
82 MOZ_CRASH("nobody calls this");
83 return false;
84 }
85
86 NS_IMETHODIMP_(bool)
87 CNavDTD::IsContainer(int32_t aTag) const
88 {
89 MOZ_CRASH("nobody calls this");
90 return false;
91 }

mercurial