Bug 1416038 (part 8) - Remove nsISAXLocator. r=erahm

None of our nsISAXErrorHandler implementations use the locator arguments.

--HG--
extra : rebase_source : 20e7ce91dd4b9582db6cb9b4cdcc2c04dd8fa064
This commit is contained in:
Nicholas Nethercote 2017-11-10 15:22:26 +11:00
Родитель af2d7335b8
Коммит e9e330e914
8 изменённых файлов: 8 добавлений и 222 удалений

Просмотреть файл

@ -13,7 +13,6 @@ XPIDL_SOURCES += [
'nsISAXAttributes.idl',
'nsISAXContentHandler.idl',
'nsISAXErrorHandler.idl',
'nsISAXLocator.idl',
'nsISAXXMLReader.idl',
]
@ -21,13 +20,11 @@ XPIDL_MODULE = 'saxparser'
EXPORTS += [
'nsSAXAttributes.h',
'nsSAXLocator.h',
'nsSAXXMLReader.h',
]
UNIFIED_SOURCES += [
'nsSAXAttributes.cpp',
'nsSAXLocator.cpp',
'nsSAXXMLReader.cpp',
]

Просмотреть файл

@ -5,8 +5,6 @@
#include "nsISupports.idl"
interface nsISAXLocator;
/**
* Basic interface for SAX error handlers.
*
@ -43,10 +41,9 @@ interface nsISAXErrorHandler: nsISupports {
* Filters may use this method to report other, non-XML errors as
* well.
*
* @param locator The locator object for the error (may be null).
* @param error The error message.
*/
void error(in nsISAXLocator locator, in AString error);
void error(in AString error);
/**
* Receive notification of a non-recoverable error.
@ -69,10 +66,9 @@ interface nsISAXErrorHandler: nsISupports {
* messages: in fact, SAX parsers are free to stop reporting any
* other events once this method has been invoked.
*
* @param locator The locator object for the error (may be null).
* @param error The error message.
*/
void fatalError(in nsISAXLocator locator, in AString error);
void fatalError(in AString error);
/**
* Receive notification of a warning.
@ -88,8 +84,7 @@ interface nsISAXErrorHandler: nsISupports {
* Filters may use this method to report other, non-XML warnings
* as well.
*
* @param locator The locator object for the warning (may be null).
* @param error The warning message.
*/
void ignorableWarning(in nsISAXLocator locator, in AString error);
void ignorableWarning(in AString error);
};

Просмотреть файл

@ -1,89 +0,0 @@
/* -*- 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 "nsISupports.idl"
/**
* Interface for associating a SAX event with a document location.
*
* Note that the results returned by the object will be valid only
* during the scope of each callback method: the application will
* receive unpredictable results if it attempts to use the locator at
* any other time, or after parsing completes.
*/
[scriptable, uuid(7a307c6c-6cc9-11da-be43-001422106990)]
interface nsISAXLocator: nsISupports {
/**
* Return the column number where the current document event ends.
*
* Warning: The return value from the method is intended only as an
* approximation for the sake of diagnostics; it is not intended to
* provide sufficient information to edit the character content of
* the original XML document. For example, when lines contain
* combining character sequences, wide characters, surrogate pairs,
* or bi-directional text, the value may not correspond to the
* column in a text editor's display.
*
* The return value is an approximation of the column number in the
* document entity or external parsed entity where the markup
* triggering the event appears.
*
* If possible, the SAX driver should provide the line position of
* the first character after the text associated with the document
* event. The first column in each line is column 1.
*
* @return The column number, or -1 if none is available.
*/
readonly attribute long columnNumber;
/**
* Return the line number where the current document event ends.
* Lines are delimited by line ends, which are defined in the XML
* specification.
*
* Warning: The return value from the method is intended only as an
* approximation for the sake of diagnostics; it is not intended to
* provide sufficient information to edit the character content of
* the original XML document. In some cases, these "line" numbers
* match what would be displayed as columns, and in others they may
* not match the source text due to internal entity expansion.
*
* The return value is an approximation of the line number in the
* document entity or external parsed entity where the markup
* triggering the event appears.
*
* If possible, the SAX driver should provide the line position of
* the first character after the text associated with the document
* event. The first line is line 1.
*
* @return The line number, or -1 if none is available.
*/
readonly attribute long lineNumber;
/**
* Return the public identifier for the current document event.
*
* The return value is the public identifier of the document entity
* or of the external parsed entity in which the markup triggering
* the event appears.
*
* @return A string containing the public identifier, or
* null if none is available.
*/
readonly attribute AString publicId;
/**
* Return the system identifier for the current document event.
*
* The return value is the system identifier of the document entity
* or of the external parsed entity in which the markup triggering
* the event appears.
*
* @return A string containing the system identifier, or null
* if none is available.
*/
readonly attribute AString systemId;
};

Просмотреть файл

@ -1,47 +0,0 @@
/* -*- 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 "nsSAXLocator.h"
NS_IMPL_ISUPPORTS(nsSAXLocator, nsISAXLocator)
nsSAXLocator::nsSAXLocator(nsString& aPublicId,
nsString& aSystemId,
int32_t aLineNumber,
int32_t aColumnNumber) :
mPublicId(aPublicId),
mSystemId(aSystemId),
mLineNumber(aLineNumber),
mColumnNumber(aColumnNumber)
{
}
NS_IMETHODIMP
nsSAXLocator::GetColumnNumber(int32_t *aColumnNumber)
{
*aColumnNumber = mColumnNumber;
return NS_OK;
}
NS_IMETHODIMP
nsSAXLocator::GetLineNumber(int32_t *aLineNumber)
{
*aLineNumber = mLineNumber;
return NS_OK;
}
NS_IMETHODIMP
nsSAXLocator::GetPublicId(nsAString &aPublicId)
{
aPublicId = mPublicId;
return NS_OK;
}
NS_IMETHODIMP
nsSAXLocator::GetSystemId(nsAString &aSystemId)
{
aSystemId = mSystemId;
return NS_OK;
}

Просмотреть файл

@ -1,33 +0,0 @@
/* -*- 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/. */
#ifndef nsSAXLocator_h__
#define nsSAXLocator_h__
#include "nsISAXLocator.h"
#include "nsString.h"
#include "mozilla/Attributes.h"
class nsSAXLocator final : public nsISAXLocator
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSISAXLOCATOR
nsSAXLocator(nsString& aPublicId,
nsString& aSystemId,
int32_t aLineNumber,
int32_t aColumnNumber);
private:
~nsSAXLocator() {}
nsString mPublicId;
nsString mSystemId;
int32_t mLineNumber;
int32_t mColumnNumber;
};
#endif //nsSAXLocator_h__

Просмотреть файл

@ -16,7 +16,6 @@
#include "nsStringStream.h"
#include "nsIScriptError.h"
#include "nsSAXAttributes.h"
#include "nsSAXLocator.h"
#include "nsCharsetSource.h"
using mozilla::Encoding;
@ -139,17 +138,6 @@ nsSAXXMLReader::HandleStartDTD(const char16_t *aName,
const char16_t *aSystemId,
const char16_t *aPublicId)
{
char16_t nullChar = char16_t(0);
if (!aName)
aName = &nullChar;
if (!aSystemId)
aSystemId = &nullChar;
if (!aPublicId)
aPublicId = &nullChar;
mSystemId = aSystemId;
mPublicId = aPublicId;
return NS_OK;
}
@ -238,22 +226,7 @@ nsSAXXMLReader::ReportError(const char16_t* aErrorText,
*_retval = true;
if (mErrorHandler) {
uint32_t lineNumber;
nsresult rv = aError->GetLineNumber(&lineNumber);
NS_ENSURE_SUCCESS(rv, rv);
uint32_t columnNumber;
rv = aError->GetColumnNumber(&columnNumber);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsISAXLocator> locator = new nsSAXLocator(mPublicId,
mSystemId,
lineNumber,
columnNumber);
if (!locator)
return NS_ERROR_OUT_OF_MEMORY;
rv = mErrorHandler->FatalError(locator, nsDependentString(aErrorText));
nsresult rv = mErrorHandler->FatalError(nsDependentString(aErrorText));
if (NS_SUCCEEDED(rv)) {
// The error handler has handled the script error. Don't log to console.
*_retval = false;
@ -375,17 +348,9 @@ nsSAXXMLReader::ParseFromStream(nsIInputStream *aStreamPtr,
if (NS_FAILED(rv))
parserChannel->Cancel(rv);
/* When parsing a new document, we need to clear the XML identifiers.
HandleStartDTD will set these values from the DTD declaration tag.
We won't have them, of course, if there's a well-formedness error
before the DTD tag (such as a space before an XML declaration).
*/
mSystemId.Truncate();
mPublicId.Truncate();
nsresult status;
parserChannel->GetStatus(&status);
uint64_t offset = 0;
while (NS_SUCCEEDED(rv) && NS_SUCCEEDED(status)) {
uint64_t available;

Просмотреть файл

@ -89,8 +89,6 @@ private:
nsString &aURI,
nsString &aLocalName,
nsString &aQName);
nsString mPublicId;
nsString mSystemId;
};
#endif // nsSAXXMLReader_h__

Просмотреть файл

@ -60,15 +60,15 @@ function updateDocumentSourceMaps(source) {
};
var errorHandler = {
error: function error(aLocator, aError) {
error: function error(aError) {
do_parse_check(!aError, "XML error");
},
fatalError: function fatalError(aLocator, aError) {
fatalError: function fatalError(aError) {
do_parse_check(!aError, "XML fatal error");
},
ignorableWarning: function ignorableWarning(aLocator, aError) {
ignorableWarning: function ignorableWarning(aError) {
do_parse_check(!aError, "XML ignorable warning");
}
};