mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-08 08:48:39 +09:00
Issue #1375 - Stop largely using the parser service
This is based on Bug 1395828 * Add nsHTMLElement::IsBlock() * Rename nsHTMLTags methods * Remove AssertParserServiceIsCorrect() * Remove most uses of nsIParserService/nsParserService
This commit is contained in:
parent
cc649173d2
commit
9928baf912
18 changed files with 77 additions and 193 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue