diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/libeditor/EditorBase.cpp | 4 | ||||
-rw-r--r-- | editor/libeditor/HTMLEditor.cpp | 78 |
2 files changed, 9 insertions, 73 deletions
diff --git a/editor/libeditor/EditorBase.cpp b/editor/libeditor/EditorBase.cpp index 27983df31..3f419a74e 100644 --- a/editor/libeditor/EditorBase.cpp +++ b/editor/libeditor/EditorBase.cpp @@ -107,16 +107,12 @@ #include "prtime.h" // for PR_Now class nsIOutputStream; -class nsIParserService; class nsITransferable; #ifdef DEBUG #include "nsIDOMHTMLDocument.h" // for nsIDOMHTMLDocument #endif -// Defined in nsEditorRegistration.cpp -extern nsIParserService *sParserService; - namespace mozilla { using namespace dom; diff --git a/editor/libeditor/HTMLEditor.cpp b/editor/libeditor/HTMLEditor.cpp index 766ab81cf..04a710cde 100644 --- a/editor/libeditor/HTMLEditor.cpp +++ b/editor/libeditor/HTMLEditor.cpp @@ -63,13 +63,13 @@ #include "nsIWidget.h" #include "nsIFrame.h" -#include "nsIParserService.h" #include "mozilla/dom/Selection.h" #include "mozilla/dom/DocumentFragment.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/Event.h" #include "mozilla/dom/EventTarget.h" #include "mozilla/dom/HTMLBodyElement.h" +#include "nsElementTable.h" #include "nsTextFragment.h" #include "nsContentList.h" #include "mozilla/StyleSheet.h" @@ -690,49 +690,6 @@ HTMLEditor::HandleKeyPressEvent(nsIDOMKeyEvent* aKeyEvent) return TypedText(str, eTypedText); } -static void -AssertParserServiceIsCorrect(nsIAtom* aTag, bool aIsBlock) -{ -#ifdef DEBUG - // Check this against what we would have said with the old code: - if (aTag == nsGkAtoms::p || - aTag == nsGkAtoms::div || - aTag == nsGkAtoms::blockquote || - aTag == nsGkAtoms::h1 || - aTag == nsGkAtoms::h2 || - aTag == nsGkAtoms::h3 || - aTag == nsGkAtoms::h4 || - aTag == nsGkAtoms::h5 || - aTag == nsGkAtoms::h6 || - aTag == nsGkAtoms::ul || - aTag == nsGkAtoms::ol || - aTag == nsGkAtoms::dl || - aTag == nsGkAtoms::noscript || - aTag == nsGkAtoms::form || - aTag == nsGkAtoms::hr || - aTag == nsGkAtoms::table || - aTag == nsGkAtoms::fieldset || - aTag == nsGkAtoms::address || - aTag == nsGkAtoms::col || - aTag == nsGkAtoms::colgroup || - aTag == nsGkAtoms::li || - aTag == nsGkAtoms::dt || - aTag == nsGkAtoms::dd || - aTag == nsGkAtoms::legend) { - if (!aIsBlock) { - nsAutoString assertmsg (NS_LITERAL_STRING("Parser and editor disagree on blockness: ")); - - nsAutoString tagName; - aTag->ToString(tagName); - assertmsg.Append(tagName); - char* assertstr = ToNewCString(assertmsg); - NS_ASSERTION(aIsBlock, assertstr); - free(assertstr); - } - } -#endif // DEBUG -} - /** * Returns true if the id represents an element of block type. * Can be used to determine if a new paragraph should be started. @@ -742,8 +699,8 @@ HTMLEditor::NodeIsBlockStatic(const nsINode* aElement) { MOZ_ASSERT(aElement); - // Nodes we know we want to treat as block - // even though the parser says they're not: + // We want to treat these as block nodes even though nsHTMLElement says + // they're not. if (aElement->IsAnyOfHTMLElements(nsGkAtoms::body, nsGkAtoms::head, nsGkAtoms::tbody, @@ -752,27 +709,13 @@ HTMLEditor::NodeIsBlockStatic(const nsINode* aElement) nsGkAtoms::tr, nsGkAtoms::th, nsGkAtoms::td, - nsGkAtoms::li, nsGkAtoms::dt, - nsGkAtoms::dd, - nsGkAtoms::pre)) { + nsGkAtoms::dd)) { return true; } - bool isBlock; -#ifdef DEBUG - // XXX we can't use DebugOnly here because VC++ is stupid (bug 802884) - nsresult rv = -#endif - nsContentUtils::GetParserService()-> - IsBlock(nsContentUtils::GetParserService()->HTMLAtomTagToId( - aElement->NodeInfo()->NameAtom()), - isBlock); - MOZ_ASSERT(rv == NS_OK); - - AssertParserServiceIsCorrect(aElement->NodeInfo()->NameAtom(), isBlock); - - return isBlock; + return nsHTMLElement::IsBlock( + nsHTMLTags::AtomTagToId(aElement->NodeInfo()->NameAtom())); } nsresult @@ -3538,17 +3481,15 @@ bool HTMLEditor::TagCanContainTag(nsIAtom& aParentTag, nsIAtom& aChildTag) { - nsIParserService* parserService = nsContentUtils::GetParserService(); - int32_t childTagEnum; // XXX Should this handle #cdata-section too? if (&aChildTag == nsGkAtoms::textTagName) { childTagEnum = eHTMLTag_text; } else { - childTagEnum = parserService->HTMLAtomTagToId(&aChildTag); + childTagEnum = nsHTMLTags::AtomTagToId(&aChildTag); } - int32_t parentTagEnum = parserService->HTMLAtomTagToId(&aParentTag); + int32_t parentTagEnum = nsHTMLTags::AtomTagToId(&aParentTag); return HTMLEditUtils::CanContain(parentTagEnum, childTagEnum); } @@ -3562,8 +3503,7 @@ HTMLEditor::IsContainer(nsINode* aNode) if (aNode->IsNodeOfType(nsINode::eTEXT)) { tagEnum = eHTMLTag_text; } else { - tagEnum = - nsContentUtils::GetParserService()->HTMLStringTagToId(aNode->NodeName()); + tagEnum = nsHTMLTags::StringTagToId(aNode->NodeName()); } return HTMLEditUtils::IsContainer(tagEnum); |