2016-07-07 04:44:32 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "TextEditUtils.h"
|
|
|
|
|
|
|
|
#include "mozilla/Assertions.h"
|
2016-07-09 02:54:50 +00:00
|
|
|
#include "mozilla/TextEditor.h"
|
2016-07-07 04:44:32 +00:00
|
|
|
#include "mozilla/dom/Element.h"
|
2019-08-02 05:45:18 +00:00
|
|
|
#include "mozilla/dom/HTMLBRElement.h"
|
2016-07-07 04:44:32 +00:00
|
|
|
#include "nsAString.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsCaseTreatment.h"
|
|
|
|
#include "nsDebug.h"
|
|
|
|
#include "nsError.h"
|
|
|
|
#include "nsGkAtoms.h"
|
|
|
|
#include "nsNameSpaceManager.h"
|
|
|
|
#include "nsLiteralString.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2019-08-02 05:45:18 +00:00
|
|
|
using namespace dom;
|
|
|
|
|
2016-06-23 10:18:13 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* TextEditUtils
|
|
|
|
******************************************************************************/
|
|
|
|
|
2016-07-07 04:44:32 +00:00
|
|
|
/**
|
|
|
|
* IsBody() returns true if aNode is an html body node.
|
|
|
|
*/
|
2017-11-28 13:28:07 +00:00
|
|
|
bool TextEditUtils::IsBody(nsINode* aNode) {
|
|
|
|
MOZ_ASSERT(aNode);
|
|
|
|
return aNode->IsHTMLElement(nsGkAtoms::body);
|
|
|
|
}
|
|
|
|
|
2016-07-07 04:44:32 +00:00
|
|
|
/**
|
|
|
|
* IsBreak() returns true if aNode is an html break node.
|
|
|
|
*/
|
|
|
|
bool TextEditUtils::IsBreak(nsINode* aNode) {
|
|
|
|
MOZ_ASSERT(aNode);
|
|
|
|
return aNode->IsHTMLElement(nsGkAtoms::br);
|
|
|
|
}
|
|
|
|
|
2016-06-23 10:18:13 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* AutoEditInitRulesTrigger
|
|
|
|
******************************************************************************/
|
2016-07-07 04:44:32 +00:00
|
|
|
|
2016-07-09 02:54:50 +00:00
|
|
|
AutoEditInitRulesTrigger::AutoEditInitRulesTrigger(TextEditor* aTextEditor,
|
|
|
|
nsresult& aResult)
|
2016-06-23 10:18:13 +00:00
|
|
|
: mTextEditor(aTextEditor), mResult(aResult) {
|
|
|
|
if (mTextEditor) {
|
|
|
|
mTextEditor->BeginEditorInit();
|
|
|
|
}
|
2016-07-07 04:44:32 +00:00
|
|
|
}
|
|
|
|
|
2016-06-23 10:18:13 +00:00
|
|
|
AutoEditInitRulesTrigger::~AutoEditInitRulesTrigger() {
|
|
|
|
if (mTextEditor) {
|
2019-03-30 11:55:29 +00:00
|
|
|
mResult = MOZ_KnownLive(mTextEditor)->EndEditorInit();
|
2016-06-23 10:18:13 +00:00
|
|
|
}
|
2016-07-07 04:44:32 +00:00
|
|
|
}
|
|
|
|
|
2016-06-23 10:18:13 +00:00
|
|
|
} // namespace mozilla
|