Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #include "nsComposeTxtSrvFilter.h"
7 : #include "nsError.h" // for NS_OK
8 : #include "nsIContent.h" // for nsIContent
9 : #include "nsIDOMNode.h" // for nsIDOMNode
10 : #include "nsNameSpaceManager.h" // for kNameSpaceID_None
11 : #include "nsLiteralString.h" // for NS_LITERAL_STRING
12 : #include "nscore.h" // for NS_IMETHODIMP
13 :
14 0 : nsComposeTxtSrvFilter::nsComposeTxtSrvFilter() :
15 0 : mIsForMail(false)
16 : {
17 0 : }
18 :
19 0 : NS_IMPL_ISUPPORTS(nsComposeTxtSrvFilter, nsITextServicesFilter)
20 :
21 : NS_IMETHODIMP
22 0 : nsComposeTxtSrvFilter::Skip(nsIDOMNode* aNode, bool *_retval)
23 : {
24 0 : *_retval = false;
25 :
26 : // Check to see if we can skip this node
27 : // For nodes that are blockquotes, we must make sure
28 : // their type is "cite"
29 0 : nsCOMPtr<nsIContent> content(do_QueryInterface(aNode));
30 0 : if (content) {
31 0 : if (content->IsHTMLElement(nsGkAtoms::blockquote)) {
32 0 : if (mIsForMail) {
33 0 : *_retval = content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
34 : nsGkAtoms::cite, eIgnoreCase);
35 : }
36 0 : } else if (content->IsHTMLElement(nsGkAtoms::span)) {
37 0 : if (mIsForMail) {
38 0 : *_retval = content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::mozquote,
39 : nsGkAtoms::_true, eIgnoreCase);
40 0 : if (!*_retval) {
41 0 : *_retval = content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::_class,
42 : nsGkAtoms::mozsignature, eCaseMatters);
43 : }
44 : }
45 0 : } else if (content->IsAnyOfHTMLElements(nsGkAtoms::script,
46 : nsGkAtoms::textarea,
47 : nsGkAtoms::select,
48 : nsGkAtoms::style,
49 : nsGkAtoms::map)) {
50 0 : *_retval = true;
51 0 : } else if (content->IsHTMLElement(nsGkAtoms::table)) {
52 0 : if (mIsForMail) {
53 0 : *_retval =
54 0 : content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::_class,
55 0 : NS_LITERAL_STRING("moz-email-headers-table"),
56 0 : eCaseMatters);
57 : }
58 : }
59 : }
60 :
61 0 : return NS_OK;
62 : }
|