Bug 1528824 - [wpt-sync] Update web-platform-tests to f8a1bfbe5454352d3f5b58845829968...
[gecko.git] / editor / spellchecker / nsComposeTxtSrvFilter.cpp
blobf01aaddb97af949c09b88c9b95ad2ee3c3e55bff
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/. */
6 #include "nsComposeTxtSrvFilter.h"
7 #include "nsError.h" // for NS_OK
8 #include "nsIContent.h" // for nsIContent
9 #include "nsLiteralString.h" // for NS_LITERAL_STRING
10 #include "mozilla/dom/Element.h" // for nsIContent
12 using namespace mozilla;
14 bool nsComposeTxtSrvFilter::Skip(nsINode* aNode) const {
15 if (NS_WARN_IF(!aNode)) {
16 return false;
19 // Check to see if we can skip this node
21 if (aNode->IsAnyOfHTMLElements(nsGkAtoms::script, nsGkAtoms::textarea,
22 nsGkAtoms::select, nsGkAtoms::style,
23 nsGkAtoms::map)) {
24 return true;
27 if (!mIsForMail) {
28 return false;
31 // For nodes that are blockquotes, we must make sure
32 // their type is "cite"
33 if (aNode->IsHTMLElement(nsGkAtoms::blockquote)) {
34 return aNode->AsElement()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
35 nsGkAtoms::cite, eIgnoreCase);
38 if (aNode->IsHTMLElement(nsGkAtoms::span)) {
39 if (aNode->AsElement()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::mozquote,
40 nsGkAtoms::_true, eIgnoreCase)) {
41 return true;
44 return aNode->AsElement()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::_class,
45 nsGkAtoms::mozsignature,
46 eCaseMatters);
49 if (aNode->IsHTMLElement(nsGkAtoms::table)) {
50 return aNode->AsElement()->AttrValueIs(
51 kNameSpaceID_None, nsGkAtoms::_class,
52 NS_LITERAL_STRING("moz-email-headers-table"), eCaseMatters);
55 return false;
58 // static
59 UniquePtr<nsComposeTxtSrvFilter> nsComposeTxtSrvFilter::CreateHelper(
60 bool aIsForMail) {
61 auto filter = MakeUnique<nsComposeTxtSrvFilter>();
62 filter->Init(aIsForMail);
63 return filter;