summaryrefslogtreecommitdiffstats
path: root/dom/base/nsDocumentEncoder.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dom/base/nsDocumentEncoder.cpp')
-rw-r--r--dom/base/nsDocumentEncoder.cpp40
1 files changed, 16 insertions, 24 deletions
diff --git a/dom/base/nsDocumentEncoder.cpp b/dom/base/nsDocumentEncoder.cpp
index 34eb6ed38..55050f1ee 100644
--- a/dom/base/nsDocumentEncoder.cpp
+++ b/dom/base/nsDocumentEncoder.cpp
@@ -1,5 +1,4 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
@@ -32,7 +31,6 @@
#include "nsIDOMDocument.h"
#include "nsGkAtoms.h"
#include "nsIContent.h"
-#include "nsIParserService.h"
#include "nsIScriptContext.h"
#include "nsIScriptGlobalObject.h"
#include "nsIScriptSecurityManager.h"
@@ -40,6 +38,7 @@
#include "nsISelectionPrivate.h"
#include "nsITransferable.h" // for kUnicodeMime
#include "nsContentUtils.h"
+#include "nsElementTable.h"
#include "nsNodeUtils.h"
#include "nsUnicharUtils.h"
#include "nsReadableUtils.h"
@@ -1588,10 +1587,13 @@ nsHTMLCopyEncoder::IncludeInContext(nsINode *aNode)
nsresult
nsHTMLCopyEncoder::PromoteRange(nsIDOMRange *inRange)
{
- if (!inRange) return NS_ERROR_NULL_POINTER;
+ RefPtr<nsRange> range = static_cast<nsRange*>(inRange);
+ if (!range) {
+ return NS_ERROR_NULL_POINTER;
+ }
nsresult rv;
nsCOMPtr<nsIDOMNode> startNode, endNode, common;
- int32_t startOffset, endOffset;
+ uint32_t startOffset, endOffset;
rv = inRange->GetCommonAncestorContainer(getter_AddRefs(common));
NS_ENSURE_SUCCESS(rv, rv);
@@ -1609,9 +1611,11 @@ nsHTMLCopyEncoder::PromoteRange(nsIDOMRange *inRange)
int32_t opStartOffset, opEndOffset;
// examine range endpoints.
- rv = GetPromotedPoint( kStart, startNode, startOffset, address_of(opStartNode), &opStartOffset, common);
+ rv = GetPromotedPoint(kStart, startNode, static_cast<int32_t>(startOffset),
+ address_of(opStartNode), &opStartOffset, common);
NS_ENSURE_SUCCESS(rv, rv);
- rv = GetPromotedPoint( kEnd, endNode, endOffset, address_of(opEndNode), &opEndOffset, common);
+ rv = GetPromotedPoint(kEnd, endNode, static_cast<int32_t>(endOffset),
+ address_of(opEndNode), &opEndOffset, common);
NS_ENSURE_SUCCESS(rv, rv);
// if both range endpoints are at the common ancestor, check for possible inclusion of ancestors
@@ -1623,9 +1627,9 @@ nsHTMLCopyEncoder::PromoteRange(nsIDOMRange *inRange)
}
// set the range to the new values
- rv = inRange->SetStart(opStartNode, opStartOffset);
+ rv = inRange->SetStart(opStartNode, static_cast<uint32_t>(opStartOffset));
NS_ENSURE_SUCCESS(rv, rv);
- rv = inRange->SetEnd(opEndNode, opEndOffset);
+ rv = inRange->SetEnd(opEndNode, static_cast<uint32_t>(opEndOffset));
return rv;
}
@@ -1736,9 +1740,6 @@ nsHTMLCopyEncoder::GetPromotedPoint(Endpoint aWhere, nsIDOMNode *aNode, int32_t
rv = GetNodeLocation(node, address_of(parent), &offset);
NS_ENSURE_SUCCESS(rv, rv);
if (offset == -1) return NS_OK; // we hit generated content; STOP
- nsIParserService *parserService = nsContentUtils::GetParserService();
- if (!parserService)
- return NS_ERROR_OUT_OF_MEMORY;
while ((IsFirstNode(node)) && (!IsRoot(parent)) && (parent != common))
{
if (bResetPromotion)
@@ -1746,11 +1747,8 @@ nsHTMLCopyEncoder::GetPromotedPoint(Endpoint aWhere, nsIDOMNode *aNode, int32_t
nsCOMPtr<nsIContent> content = do_QueryInterface(parent);
if (content && content->IsHTMLElement())
{
- bool isBlock = false;
- parserService->IsBlock(parserService->HTMLAtomTagToId(
- content->NodeInfo()->NameAtom()), isBlock);
- if (isBlock)
- {
+ if (nsHTMLElement::IsBlock(nsHTMLTags::AtomTagToId(
+ content->NodeInfo()->NameAtom()))) {
bResetPromotion = false;
}
}
@@ -1819,9 +1817,6 @@ nsHTMLCopyEncoder::GetPromotedPoint(Endpoint aWhere, nsIDOMNode *aNode, int32_t
rv = GetNodeLocation(node, address_of(parent), &offset);
NS_ENSURE_SUCCESS(rv, rv);
if (offset == -1) return NS_OK; // we hit generated content; STOP
- nsIParserService *parserService = nsContentUtils::GetParserService();
- if (!parserService)
- return NS_ERROR_OUT_OF_MEMORY;
while ((IsLastNode(node)) && (!IsRoot(parent)) && (parent != common))
{
if (bResetPromotion)
@@ -1829,11 +1824,8 @@ nsHTMLCopyEncoder::GetPromotedPoint(Endpoint aWhere, nsIDOMNode *aNode, int32_t
nsCOMPtr<nsIContent> content = do_QueryInterface(parent);
if (content && content->IsHTMLElement())
{
- bool isBlock = false;
- parserService->IsBlock(parserService->HTMLAtomTagToId(
- content->NodeInfo()->NameAtom()), isBlock);
- if (isBlock)
- {
+ if (nsHTMLElement::IsBlock(nsHTMLTags::AtomTagToId(
+ content->NodeInfo()->NameAtom()))) {
bResetPromotion = false;
}
}