/* -*- 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"EditorUtils.h"
#include"EditorDOMPoint.h"// for EditorDOMPoint, EditorDOMRange, etc #include"HTMLEditHelpers.h"// for MoveNodeResult #include"HTMLEditUtils.h"// for HTMLEditUtils #include"TextEditor.h"// for TextEditor
#include"mozilla/ComputedStyle.h"// for ComputedStyle #include"mozilla/IntegerRange.h"// for IntegerRange #include"mozilla/dom/Document.h"// for dom::Document #include"mozilla/dom/Selection.h"// for dom::Selection #include"mozilla/dom/Text.h"// for dom::Text
#include"nsComponentManagerUtils.h"// for do_CreateInstance #include"nsContentUtils.h"// for nsContentUtils #include"nsComputedDOMStyle.h"// for nsComputedDOMStyle #include"nsError.h"// for NS_SUCCESS_* and NS_ERROR_* #include"nsFrameSelection.h"// for nsFrameSelection #include"nsIContent.h"// for nsIContent #include"nsINode.h"// for nsINode #include"nsITransferable.h"// for nsITransferable #include"nsRange.h"// for nsRange #include"nsStyleConsts.h"// for StyleWhiteSpace #include"nsStyleStruct.h"// for nsStyleText, etc
namespace mozilla {
usingnamespace dom;
/****************************************************************************** * some general purpose editor utils
*****************************************************************************/
// static bool EditorUtils::IsWhiteSpacePreformatted(const nsIContent& aContent) { // Look at the node (and its parent if it's not an element), and grab its // ComputedStyle.
Element* element = aContent.GetAsElementOrParentElement(); if (!element) { returnfalse;
}
RefPtr<const ComputedStyle> elementStyle =
nsComputedDOMStyle::GetComputedStyleNoFlush(element); if (!elementStyle) { // Consider nodes without a ComputedStyle to be NOT preformatted: // For instance, this is true of JS tags inside the body (which show // up as #text nodes but have no ComputedStyle). returnfalse;
}
// static bool EditorUtils::IsNewLinePreformatted(const nsIContent& aContent) { // Look at the node (and its parent if it's not an element), and grab its // ComputedStyle.
Element* element = aContent.GetAsElementOrParentElement(); if (!element) { returnfalse;
}
RefPtr<const ComputedStyle> elementStyle =
nsComputedDOMStyle::GetComputedStyleNoFlush(element); if (!elementStyle) { // Consider nodes without a ComputedStyle to be NOT preformatted: // For instance, this is true of JS tags inside the body (which show // up as #text nodes but have no ComputedStyle). returnfalse;
}
// static bool EditorUtils::IsOnlyNewLinePreformatted(const nsIContent& aContent) { // Look at the node (and its parent if it's not an element), and grab its // ComputedStyle.
Element* element = aContent.GetAsElementOrParentElement(); if (!element) { returnfalse;
}
RefPtr<const ComputedStyle> elementStyle =
nsComputedDOMStyle::GetComputedStyleNoFlush(element); if (!elementStyle) { // Consider nodes without a ComputedStyle to be NOT preformatted: // For instance, this is true of JS tags inside the body (which show // up as #text nodes but have no ComputedStyle). returnfalse;
}
template <typename PT, typename CT> bool EditorDOMPointBase<PT, CT>::IsCharCollapsibleNBSP() const { // TODO: Perhaps, we should return false if neither previous char nor // next char is collapsible white-space or NBSP. return IsCharNBSP() &&
!EditorUtils::IsWhiteSpacePreformatted(*ContainerAs<Text>());
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.