mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
4544b7feb6
--HG-- rename : parser/xml/public/nsIMozSAXXMLDeclarationHandler.idl => parser/xml/nsIMozSAXXMLDeclarationHandler.idl rename : parser/xml/public/nsISAXAttributes.idl => parser/xml/nsISAXAttributes.idl rename : parser/xml/public/nsISAXContentHandler.idl => parser/xml/nsISAXContentHandler.idl rename : parser/xml/public/nsISAXDTDHandler.idl => parser/xml/nsISAXDTDHandler.idl rename : parser/xml/public/nsISAXErrorHandler.idl => parser/xml/nsISAXErrorHandler.idl rename : parser/xml/public/nsISAXLexicalHandler.idl => parser/xml/nsISAXLexicalHandler.idl rename : parser/xml/public/nsISAXLocator.idl => parser/xml/nsISAXLocator.idl rename : parser/xml/public/nsISAXMutableAttributes.idl => parser/xml/nsISAXMutableAttributes.idl rename : parser/xml/public/nsISAXXMLFilter.idl => parser/xml/nsISAXXMLFilter.idl rename : parser/xml/public/nsISAXXMLReader.idl => parser/xml/nsISAXXMLReader.idl rename : parser/xml/src/nsSAXAttributes.cpp => parser/xml/nsSAXAttributes.cpp rename : parser/xml/src/nsSAXAttributes.h => parser/xml/nsSAXAttributes.h rename : parser/xml/src/nsSAXLocator.cpp => parser/xml/nsSAXLocator.cpp rename : parser/xml/src/nsSAXLocator.h => parser/xml/nsSAXLocator.h rename : parser/xml/src/nsSAXXMLReader.cpp => parser/xml/nsSAXXMLReader.cpp rename : parser/xml/src/nsSAXXMLReader.h => parser/xml/nsSAXXMLReader.h
333 lines
7.0 KiB
C++
333 lines
7.0 KiB
C++
/* -*- 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 "nsSAXAttributes.h"
|
|
|
|
NS_IMPL_ISUPPORTS(nsSAXAttributes, nsISAXAttributes, nsISAXMutableAttributes)
|
|
|
|
NS_IMETHODIMP
|
|
nsSAXAttributes::GetIndexFromName(const nsAString &aURI,
|
|
const nsAString &aLocalName,
|
|
int32_t *aResult)
|
|
{
|
|
int32_t len = mAttrs.Length();
|
|
int32_t i;
|
|
for (i = 0; i < len; ++i) {
|
|
const SAXAttr &att = mAttrs[i];
|
|
if (att.localName.Equals(aLocalName) && att.uri.Equals(aURI)) {
|
|
*aResult = i;
|
|
return NS_OK;
|
|
}
|
|
}
|
|
*aResult = -1;
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsSAXAttributes::GetIndexFromQName(const nsAString &aQName, int32_t *aResult)
|
|
{
|
|
int32_t len = mAttrs.Length();
|
|
int32_t i;
|
|
for (i = 0; i < len; ++i) {
|
|
const SAXAttr &att = mAttrs[i];
|
|
if (att.qName.Equals(aQName)) {
|
|
*aResult = i;
|
|
return NS_OK;
|
|
}
|
|
}
|
|
*aResult = -1;
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsSAXAttributes::GetLength(int32_t *aResult)
|
|
{
|
|
*aResult = mAttrs.Length();
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsSAXAttributes::GetLocalName(uint32_t aIndex, nsAString &aResult)
|
|
{
|
|
uint32_t len = mAttrs.Length();
|
|
if (aIndex >= len) {
|
|
aResult.SetIsVoid(true);
|
|
} else {
|
|
const SAXAttr &att = mAttrs[aIndex];
|
|
aResult = att.localName;
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsSAXAttributes::GetQName(uint32_t aIndex, nsAString &aResult)
|
|
{
|
|
uint32_t len = mAttrs.Length();
|
|
if (aIndex >= len) {
|
|
aResult.SetIsVoid(true);
|
|
} else {
|
|
const SAXAttr &att = mAttrs[aIndex];
|
|
aResult = att.qName;
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsSAXAttributes::GetType(uint32_t aIndex, nsAString &aResult)
|
|
{
|
|
uint32_t len = mAttrs.Length();
|
|
if (aIndex >= len) {
|
|
aResult.SetIsVoid(true);
|
|
} else {
|
|
const SAXAttr &att = mAttrs[aIndex];
|
|
aResult = att.type;
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsSAXAttributes::GetTypeFromName(const nsAString &aURI,
|
|
const nsAString &aLocalName,
|
|
nsAString &aResult)
|
|
{
|
|
int32_t index = -1;
|
|
GetIndexFromName(aURI, aLocalName, &index);
|
|
if (index >= 0) {
|
|
aResult = mAttrs[index].type;
|
|
} else {
|
|
aResult.SetIsVoid(true);
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsSAXAttributes::GetTypeFromQName(const nsAString &aQName, nsAString &aResult)
|
|
{
|
|
int32_t index = -1;
|
|
GetIndexFromQName(aQName, &index);
|
|
if (index >= 0) {
|
|
aResult = mAttrs[index].type;
|
|
} else {
|
|
aResult.SetIsVoid(true);
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsSAXAttributes::GetURI(uint32_t aIndex, nsAString &aResult)
|
|
{
|
|
uint32_t len = mAttrs.Length();
|
|
if (aIndex >= len) {
|
|
aResult.SetIsVoid(true);
|
|
} else {
|
|
const SAXAttr &att = mAttrs[aIndex];
|
|
aResult = att.uri;
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsSAXAttributes::GetValue(uint32_t aIndex, nsAString &aResult)
|
|
{
|
|
uint32_t len = mAttrs.Length();
|
|
if (aIndex >= len) {
|
|
aResult.SetIsVoid(true);
|
|
} else {
|
|
const SAXAttr &att = mAttrs[aIndex];
|
|
aResult = att.value;
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsSAXAttributes::GetValueFromName(const nsAString &aURI,
|
|
const nsAString &aLocalName,
|
|
nsAString &aResult)
|
|
{
|
|
int32_t index = -1;
|
|
GetIndexFromName(aURI, aLocalName, &index);
|
|
if (index >= 0) {
|
|
aResult = mAttrs[index].value;
|
|
} else {
|
|
aResult.SetIsVoid(true);
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsSAXAttributes::GetValueFromQName(const nsAString &aQName,
|
|
nsAString &aResult)
|
|
{
|
|
int32_t index = -1;
|
|
GetIndexFromQName(aQName, &index);
|
|
if (index >= 0) {
|
|
aResult = mAttrs[index].value;
|
|
} else {
|
|
aResult.SetIsVoid(true);
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsSAXAttributes::AddAttribute(const nsAString &aURI,
|
|
const nsAString &aLocalName,
|
|
const nsAString &aQName,
|
|
const nsAString &aType,
|
|
const nsAString &aValue)
|
|
{
|
|
SAXAttr *att = mAttrs.AppendElement();
|
|
if (!att) {
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
}
|
|
|
|
att->uri = aURI;
|
|
att->localName = aLocalName;
|
|
att->qName = aQName;
|
|
att->type = aType;
|
|
att->value = aValue;
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsSAXAttributes::Clear()
|
|
{
|
|
mAttrs.Clear();
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsSAXAttributes::RemoveAttribute(uint32_t aIndex)
|
|
{
|
|
if (aIndex >= mAttrs.Length()) {
|
|
return NS_ERROR_FAILURE;
|
|
}
|
|
mAttrs.RemoveElementAt(aIndex);
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsSAXAttributes::SetAttributes(nsISAXAttributes *aAttributes)
|
|
{
|
|
NS_ENSURE_ARG(aAttributes);
|
|
|
|
nsresult rv;
|
|
int32_t len;
|
|
rv = aAttributes->GetLength(&len);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
mAttrs.Clear();
|
|
SAXAttr *att;
|
|
int32_t i;
|
|
for (i = 0; i < len; ++i) {
|
|
att = mAttrs.AppendElement();
|
|
if (!att) {
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
}
|
|
rv = aAttributes->GetURI(i, att->uri);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
rv = aAttributes->GetLocalName(i, att->localName);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
rv = aAttributes->GetQName(i, att->qName);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
rv = aAttributes->GetType(i, att->type);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
rv = aAttributes->GetValue(i, att->value);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsSAXAttributes::SetAttribute(uint32_t aIndex,
|
|
const nsAString &aURI,
|
|
const nsAString &aLocalName,
|
|
const nsAString &aQName,
|
|
const nsAString &aType,
|
|
const nsAString &aValue)
|
|
{
|
|
if (aIndex >= mAttrs.Length()) {
|
|
return NS_ERROR_FAILURE;
|
|
}
|
|
|
|
SAXAttr &att = mAttrs[aIndex];
|
|
att.uri = aURI;
|
|
att.localName = aLocalName;
|
|
att.qName = aQName;
|
|
att.type = aType;
|
|
att.value = aValue;
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsSAXAttributes::SetLocalName(uint32_t aIndex, const nsAString &aLocalName)
|
|
{
|
|
if (aIndex >= mAttrs.Length()) {
|
|
return NS_ERROR_FAILURE;
|
|
}
|
|
mAttrs[aIndex].localName = aLocalName;
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsSAXAttributes::SetQName(uint32_t aIndex, const nsAString &aQName)
|
|
{
|
|
if (aIndex >= mAttrs.Length()) {
|
|
return NS_ERROR_FAILURE;
|
|
}
|
|
mAttrs[aIndex].qName = aQName;
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsSAXAttributes::SetType(uint32_t aIndex, const nsAString &aType)
|
|
{
|
|
if (aIndex >= mAttrs.Length()) {
|
|
return NS_ERROR_FAILURE;
|
|
}
|
|
mAttrs[aIndex].type = aType;
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsSAXAttributes::SetURI(uint32_t aIndex, const nsAString &aURI)
|
|
{
|
|
if (aIndex >= mAttrs.Length()) {
|
|
return NS_ERROR_FAILURE;
|
|
}
|
|
mAttrs[aIndex].uri = aURI;
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsSAXAttributes::SetValue(uint32_t aIndex, const nsAString &aValue)
|
|
{
|
|
if (aIndex >= mAttrs.Length()) {
|
|
return NS_ERROR_FAILURE;
|
|
}
|
|
mAttrs[aIndex].value = aValue;
|
|
|
|
return NS_OK;
|
|
}
|