зеркало из https://github.com/mozilla/gecko-dev.git
Bug 650784 part 0 - Fold nsParserUtils into nsContentUtils. r=smaug.
This commit is contained in:
Родитель
e18d363012
Коммит
60b9bb42d0
|
@ -1941,6 +1941,32 @@ public:
|
|||
*/
|
||||
static bool URIIsChromeOrInPref(nsIURI *aURI, const char *aPref);
|
||||
|
||||
/**
|
||||
* This will parse aSource, to extract the value of the pseudo attribute
|
||||
* with the name specified in aName. See
|
||||
* http://www.w3.org/TR/xml-stylesheet/#NT-StyleSheetPI for the specification
|
||||
* which is used to parse aSource.
|
||||
*
|
||||
* @param aSource the string to parse
|
||||
* @param aName the name of the attribute to get the value for
|
||||
* @param aValue [out] the value for the attribute with name specified in
|
||||
* aAttribute. Empty if the attribute isn't present.
|
||||
* @return true if the attribute exists and was successfully parsed.
|
||||
* false if the attribute doesn't exist, or has a malformed
|
||||
* value, such as an unknown or unterminated entity.
|
||||
*/
|
||||
static bool GetPseudoAttributeValue(const nsString& aSource, nsIAtom *aName,
|
||||
nsAString& aValue);
|
||||
|
||||
/**
|
||||
* Returns true if the language name is a version of JavaScript and
|
||||
* false otherwise
|
||||
*/
|
||||
static bool IsJavaScriptLanguage(const nsString& aName, PRUint32 *aVerFlags);
|
||||
|
||||
static void SplitMimeType(const nsAString& aValue, nsString& aType,
|
||||
nsString& aParams);
|
||||
|
||||
private:
|
||||
static bool InitializeEventTable();
|
||||
|
||||
|
|
|
@ -127,7 +127,6 @@ CPPSRCS = \
|
|||
nsNodeIterator.cpp \
|
||||
nsNodeUtils.cpp \
|
||||
nsObjectLoadingContent.cpp \
|
||||
nsParserUtils.cpp \
|
||||
nsPlainTextSerializer.cpp \
|
||||
nsPropertyTable.cpp \
|
||||
nsRange.cpp \
|
||||
|
|
|
@ -80,7 +80,6 @@
|
|||
#include "nsIPrompt.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsParserUtils.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsEscape.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
@ -712,7 +711,7 @@ nsContentSink::ProcessStyleLink(nsIContent* aElement,
|
|||
|
||||
nsAutoString mimeType;
|
||||
nsAutoString params;
|
||||
nsParserUtils::SplitMimeType(aType, mimeType, params);
|
||||
nsContentUtils::SplitMimeType(aType, mimeType, params);
|
||||
|
||||
// see bug 18817
|
||||
if (!mimeType.IsEmpty() && !mimeType.LowerCaseEqualsLiteral("text/css")) {
|
||||
|
|
|
@ -180,6 +180,7 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_XTFSERVICE_CID);
|
|||
#include "nsIViewManager.h"
|
||||
#include "nsEventStateManager.h"
|
||||
#include "nsIDOMHTMLInputElement.h"
|
||||
#include "nsParserConstants.h"
|
||||
|
||||
#ifdef IBMBIDI
|
||||
#include "nsIBidiKeyboard.h"
|
||||
|
@ -720,6 +721,185 @@ nsContentUtils::URIIsChromeOrInPref(nsIURI *aURI, const char *aPref)
|
|||
return false;
|
||||
}
|
||||
|
||||
#define SKIP_WHITESPACE(iter, end_iter, end_res) \
|
||||
while ((iter) != (end_iter) && nsCRT::IsAsciiSpace(*(iter))) { \
|
||||
++(iter); \
|
||||
} \
|
||||
if ((iter) == (end_iter)) { \
|
||||
return (end_res); \
|
||||
}
|
||||
|
||||
#define SKIP_ATTR_NAME(iter, end_iter) \
|
||||
while ((iter) != (end_iter) && !nsCRT::IsAsciiSpace(*(iter)) && \
|
||||
*(iter) != '=') { \
|
||||
++(iter); \
|
||||
}
|
||||
|
||||
bool
|
||||
nsContentUtils::GetPseudoAttributeValue(const nsString& aSource, nsIAtom *aName,
|
||||
nsAString& aValue)
|
||||
{
|
||||
aValue.Truncate();
|
||||
|
||||
const PRUnichar *start = aSource.get();
|
||||
const PRUnichar *end = start + aSource.Length();
|
||||
const PRUnichar *iter;
|
||||
|
||||
while (start != end) {
|
||||
SKIP_WHITESPACE(start, end, false)
|
||||
iter = start;
|
||||
SKIP_ATTR_NAME(iter, end)
|
||||
|
||||
if (start == iter) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remember the attr name.
|
||||
const nsDependentSubstring & attrName = Substring(start, iter);
|
||||
|
||||
// Now check whether this is a valid name="value" pair.
|
||||
start = iter;
|
||||
SKIP_WHITESPACE(start, end, false)
|
||||
if (*start != '=') {
|
||||
// No '=', so this is not a name="value" pair. We don't know
|
||||
// what it is, and we have no way to handle it.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Have to skip the value.
|
||||
++start;
|
||||
SKIP_WHITESPACE(start, end, false)
|
||||
PRUnichar q = *start;
|
||||
if (q != kQuote && q != kApostrophe) {
|
||||
// Not a valid quoted value, so bail.
|
||||
return false;
|
||||
}
|
||||
|
||||
++start; // Point to the first char of the value.
|
||||
iter = start;
|
||||
|
||||
while (iter != end && *iter != q) {
|
||||
++iter;
|
||||
}
|
||||
|
||||
if (iter == end) {
|
||||
// Oops, unterminated quoted string.
|
||||
return false;
|
||||
}
|
||||
|
||||
// At this point attrName holds the name of the "attribute" and
|
||||
// the value is between start and iter.
|
||||
|
||||
if (aName->Equals(attrName)) {
|
||||
nsIParserService* parserService = nsContentUtils::GetParserService();
|
||||
NS_ENSURE_TRUE(parserService, false);
|
||||
|
||||
// We'll accumulate as many characters as possible (until we hit either
|
||||
// the end of the string or the beginning of an entity). Chunks will be
|
||||
// delimited by start and chunkEnd.
|
||||
const PRUnichar *chunkEnd = start;
|
||||
while (chunkEnd != iter) {
|
||||
if (*chunkEnd == kLessThan) {
|
||||
aValue.Truncate();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (*chunkEnd == kAmpersand) {
|
||||
aValue.Append(start, chunkEnd - start);
|
||||
|
||||
// Point to first character after the ampersand.
|
||||
++chunkEnd;
|
||||
|
||||
const PRUnichar *afterEntity;
|
||||
PRUnichar result[2];
|
||||
PRUint32 count =
|
||||
parserService->DecodeEntity(chunkEnd, iter, &afterEntity, result);
|
||||
if (count == 0) {
|
||||
aValue.Truncate();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
aValue.Append(result, count);
|
||||
|
||||
// Advance to after the entity and begin a new chunk.
|
||||
start = chunkEnd = afterEntity;
|
||||
}
|
||||
else {
|
||||
++chunkEnd;
|
||||
}
|
||||
}
|
||||
|
||||
// Append remainder.
|
||||
aValue.Append(start, iter - start);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Resume scanning after the end of the attribute value (past the quote
|
||||
// char).
|
||||
start = iter + 1;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
nsContentUtils::IsJavaScriptLanguage(const nsString& aName, PRUint32 *aFlags)
|
||||
{
|
||||
JSVersion version = JSVERSION_UNKNOWN;
|
||||
|
||||
if (aName.LowerCaseEqualsLiteral("javascript") ||
|
||||
aName.LowerCaseEqualsLiteral("livescript") ||
|
||||
aName.LowerCaseEqualsLiteral("mocha")) {
|
||||
version = JSVERSION_DEFAULT;
|
||||
} else if (aName.LowerCaseEqualsLiteral("javascript1.0")) {
|
||||
version = JSVERSION_1_0;
|
||||
} else if (aName.LowerCaseEqualsLiteral("javascript1.1")) {
|
||||
version = JSVERSION_1_1;
|
||||
} else if (aName.LowerCaseEqualsLiteral("javascript1.2")) {
|
||||
version = JSVERSION_1_2;
|
||||
} else if (aName.LowerCaseEqualsLiteral("javascript1.3")) {
|
||||
version = JSVERSION_1_3;
|
||||
} else if (aName.LowerCaseEqualsLiteral("javascript1.4")) {
|
||||
version = JSVERSION_1_4;
|
||||
} else if (aName.LowerCaseEqualsLiteral("javascript1.5")) {
|
||||
version = JSVERSION_1_5;
|
||||
} else if (aName.LowerCaseEqualsLiteral("javascript1.6")) {
|
||||
version = JSVERSION_1_6;
|
||||
} else if (aName.LowerCaseEqualsLiteral("javascript1.7")) {
|
||||
version = JSVERSION_1_7;
|
||||
} else if (aName.LowerCaseEqualsLiteral("javascript1.8")) {
|
||||
version = JSVERSION_1_8;
|
||||
}
|
||||
|
||||
if (version == JSVERSION_UNKNOWN) {
|
||||
return false;
|
||||
}
|
||||
*aFlags = version;
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
nsContentUtils::SplitMimeType(const nsAString& aValue, nsString& aType,
|
||||
nsString& aParams)
|
||||
{
|
||||
aType.Truncate();
|
||||
aParams.Truncate();
|
||||
PRInt32 semiIndex = aValue.FindChar(PRUnichar(';'));
|
||||
if (-1 != semiIndex) {
|
||||
aType = Substring(aValue, 0, semiIndex);
|
||||
aParams = Substring(aValue, semiIndex + 1,
|
||||
aValue.Length() - (semiIndex + 1));
|
||||
aParams.StripWhitespace();
|
||||
}
|
||||
else {
|
||||
aType = aValue;
|
||||
}
|
||||
aType.StripWhitespace();
|
||||
}
|
||||
|
||||
/**
|
||||
* Access a cached parser service. Don't addref. We need only one
|
||||
* reference to it and this class has that one.
|
||||
|
|
|
@ -48,7 +48,6 @@
|
|||
#include "nsMimeTypes.h"
|
||||
#include "nsIStreamConverterService.h"
|
||||
#include "nsStringStream.h"
|
||||
#include "nsParserUtils.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsWhitespaceTokenizer.h"
|
||||
#include "nsIChannelEventSink.h"
|
||||
|
|
|
@ -1,236 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Namespace class for some static parsing-related methods.
|
||||
*/
|
||||
|
||||
#include "nsParserUtils.h"
|
||||
#include "jsapi.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIParserService.h"
|
||||
#include "nsParserConstants.h"
|
||||
|
||||
#define SKIP_WHITESPACE(iter, end_iter, end_res) \
|
||||
while ((iter) != (end_iter) && nsCRT::IsAsciiSpace(*(iter))) { \
|
||||
++(iter); \
|
||||
} \
|
||||
if ((iter) == (end_iter)) { \
|
||||
return (end_res); \
|
||||
}
|
||||
|
||||
#define SKIP_ATTR_NAME(iter, end_iter) \
|
||||
while ((iter) != (end_iter) && !nsCRT::IsAsciiSpace(*(iter)) && \
|
||||
*(iter) != '=') { \
|
||||
++(iter); \
|
||||
}
|
||||
|
||||
bool
|
||||
nsParserUtils::GetQuotedAttributeValue(const nsString& aSource, nsIAtom *aName,
|
||||
nsAString& aValue)
|
||||
{
|
||||
aValue.Truncate();
|
||||
|
||||
const PRUnichar *start = aSource.get();
|
||||
const PRUnichar *end = start + aSource.Length();
|
||||
const PRUnichar *iter;
|
||||
|
||||
while (start != end) {
|
||||
SKIP_WHITESPACE(start, end, false)
|
||||
iter = start;
|
||||
SKIP_ATTR_NAME(iter, end)
|
||||
|
||||
if (start == iter) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remember the attr name.
|
||||
const nsDependentSubstring & attrName = Substring(start, iter);
|
||||
|
||||
// Now check whether this is a valid name="value" pair.
|
||||
start = iter;
|
||||
SKIP_WHITESPACE(start, end, false)
|
||||
if (*start != '=') {
|
||||
// No '=', so this is not a name="value" pair. We don't know
|
||||
// what it is, and we have no way to handle it.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Have to skip the value.
|
||||
++start;
|
||||
SKIP_WHITESPACE(start, end, false)
|
||||
PRUnichar q = *start;
|
||||
if (q != kQuote && q != kApostrophe) {
|
||||
// Not a valid quoted value, so bail.
|
||||
return false;
|
||||
}
|
||||
|
||||
++start; // Point to the first char of the value.
|
||||
iter = start;
|
||||
|
||||
while (iter != end && *iter != q) {
|
||||
++iter;
|
||||
}
|
||||
|
||||
if (iter == end) {
|
||||
// Oops, unterminated quoted string.
|
||||
return false;
|
||||
}
|
||||
|
||||
// At this point attrName holds the name of the "attribute" and
|
||||
// the value is between start and iter.
|
||||
|
||||
if (aName->Equals(attrName)) {
|
||||
nsIParserService* parserService = nsContentUtils::GetParserService();
|
||||
NS_ENSURE_TRUE(parserService, false);
|
||||
|
||||
// We'll accumulate as many characters as possible (until we hit either
|
||||
// the end of the string or the beginning of an entity). Chunks will be
|
||||
// delimited by start and chunkEnd.
|
||||
const PRUnichar *chunkEnd = start;
|
||||
while (chunkEnd != iter) {
|
||||
if (*chunkEnd == kLessThan) {
|
||||
aValue.Truncate();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (*chunkEnd == kAmpersand) {
|
||||
aValue.Append(start, chunkEnd - start);
|
||||
|
||||
// Point to first character after the ampersand.
|
||||
++chunkEnd;
|
||||
|
||||
const PRUnichar *afterEntity;
|
||||
PRUnichar result[2];
|
||||
PRUint32 count =
|
||||
parserService->DecodeEntity(chunkEnd, iter, &afterEntity, result);
|
||||
if (count == 0) {
|
||||
aValue.Truncate();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
aValue.Append(result, count);
|
||||
|
||||
// Advance to after the entity and begin a new chunk.
|
||||
start = chunkEnd = afterEntity;
|
||||
}
|
||||
else {
|
||||
++chunkEnd;
|
||||
}
|
||||
}
|
||||
|
||||
// Append remainder.
|
||||
aValue.Append(start, iter - start);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Resume scanning after the end of the attribute value (past the quote
|
||||
// char).
|
||||
start = iter + 1;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Returns true if the language name is a version of JavaScript and
|
||||
// false otherwise
|
||||
bool
|
||||
nsParserUtils::IsJavaScriptLanguage(const nsString& aName, PRUint32 *aFlags)
|
||||
{
|
||||
JSVersion version = JSVERSION_UNKNOWN;
|
||||
|
||||
if (aName.LowerCaseEqualsLiteral("javascript") ||
|
||||
aName.LowerCaseEqualsLiteral("livescript") ||
|
||||
aName.LowerCaseEqualsLiteral("mocha")) {
|
||||
version = JSVERSION_DEFAULT;
|
||||
}
|
||||
else if (aName.LowerCaseEqualsLiteral("javascript1.0")) {
|
||||
version = JSVERSION_1_0;
|
||||
}
|
||||
else if (aName.LowerCaseEqualsLiteral("javascript1.1")) {
|
||||
version = JSVERSION_1_1;
|
||||
}
|
||||
else if (aName.LowerCaseEqualsLiteral("javascript1.2")) {
|
||||
version = JSVERSION_1_2;
|
||||
}
|
||||
else if (aName.LowerCaseEqualsLiteral("javascript1.3")) {
|
||||
version = JSVERSION_1_3;
|
||||
}
|
||||
else if (aName.LowerCaseEqualsLiteral("javascript1.4")) {
|
||||
version = JSVERSION_1_4;
|
||||
}
|
||||
else if (aName.LowerCaseEqualsLiteral("javascript1.5")) {
|
||||
version = JSVERSION_1_5;
|
||||
}
|
||||
else if (aName.LowerCaseEqualsLiteral("javascript1.6")) {
|
||||
version = JSVERSION_1_6;
|
||||
}
|
||||
else if (aName.LowerCaseEqualsLiteral("javascript1.7")) {
|
||||
version = JSVERSION_1_7;
|
||||
}
|
||||
else if (aName.LowerCaseEqualsLiteral("javascript1.8")) {
|
||||
version = JSVERSION_1_8;
|
||||
}
|
||||
if (version == JSVERSION_UNKNOWN)
|
||||
return false;
|
||||
*aFlags = version;
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
nsParserUtils::SplitMimeType(const nsAString& aValue, nsString& aType,
|
||||
nsString& aParams)
|
||||
{
|
||||
aType.Truncate();
|
||||
aParams.Truncate();
|
||||
PRInt32 semiIndex = aValue.FindChar(PRUnichar(';'));
|
||||
if (-1 != semiIndex) {
|
||||
aType = Substring(aValue, 0, semiIndex);
|
||||
aParams = Substring(aValue, semiIndex + 1,
|
||||
aValue.Length() - (semiIndex + 1));
|
||||
aParams.StripWhitespace();
|
||||
}
|
||||
else {
|
||||
aType = aValue;
|
||||
}
|
||||
aType.StripWhitespace();
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Namespace class for some static parsing-related methods.
|
||||
*/
|
||||
|
||||
#ifndef nsParserUtils_h__
|
||||
#define nsParserUtils_h__
|
||||
|
||||
#include "nsString.h"
|
||||
class nsIAtom;
|
||||
|
||||
class nsParserUtils {
|
||||
public:
|
||||
/**
|
||||
* This will parse aSource, to extract the value of the pseudo attribute
|
||||
* with the name specified in aName. See
|
||||
* http://www.w3.org/TR/xml-stylesheet/#NT-StyleSheetPI for the specification
|
||||
* which is used to parse aSource.
|
||||
*
|
||||
* @param aSource the string to parse
|
||||
* @param aName the name of the attribute to get the value for
|
||||
* @param aValue [out] the value for the attribute with name specified in
|
||||
* aAttribute. Empty if the attribute isn't present.
|
||||
* @return true if the attribute exists and was successfully parsed.
|
||||
* false if the attribute doesn't exist, or has a malformed
|
||||
* value, such as an unknown or unterminated entity.
|
||||
*/
|
||||
static bool
|
||||
GetQuotedAttributeValue(const nsString& aSource, nsIAtom *aName,
|
||||
nsAString& aValue);
|
||||
|
||||
static bool
|
||||
IsJavaScriptLanguage(const nsString& aName, PRUint32 *aVerFlags);
|
||||
|
||||
static void
|
||||
SplitMimeType(const nsAString& aValue, nsString& aType,
|
||||
nsString& aParams);
|
||||
};
|
||||
|
||||
#endif // nsParserUtils_h__
|
||||
|
||||
|
||||
|
|
@ -44,7 +44,6 @@
|
|||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "nsScriptLoader.h"
|
||||
#include "nsParserUtils.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsIUnicodeDecoder.h"
|
||||
#include "nsIContent.h"
|
||||
|
@ -509,14 +508,14 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
|
|||
if (scriptContent->IsHTML()) {
|
||||
scriptContent->GetAttr(kNameSpaceID_None, nsGkAtoms::language, language);
|
||||
if (!language.IsEmpty()) {
|
||||
if (nsParserUtils::IsJavaScriptLanguage(language, &version))
|
||||
if (nsContentUtils::IsJavaScriptLanguage(language, &version))
|
||||
typeID = nsIProgrammingLanguage::JAVASCRIPT;
|
||||
else
|
||||
typeID = nsIProgrammingLanguage::UNKNOWN;
|
||||
// IE, Opera, etc. do not respect language version, so neither should
|
||||
// we at this late date in the browser wars saga. Note that this change
|
||||
// affects HTML but not XUL or SVG (but note also that XUL has its own
|
||||
// code to check nsParserUtils::IsJavaScriptLanguage -- that's probably
|
||||
// code to check nsContentUtils::IsJavaScriptLanguage -- that's probably
|
||||
// a separate bug, one we may not be able to fix short of XUL2). See
|
||||
// bug 255895 (https://bugzilla.mozilla.org/show_bug.cgi?id=255895).
|
||||
NS_ASSERTION(JSVERSION_DEFAULT == 0,
|
||||
|
|
|
@ -52,7 +52,6 @@
|
|||
#include "nsIDOMEvent.h"
|
||||
#include "nsIPrivateDOMEvent.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsParserUtils.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsAsyncDOMEvent.h"
|
||||
|
@ -439,7 +438,7 @@ nsHTMLLinkElement::GetStyleSheetInfo(nsAString& aTitle,
|
|||
nsAutoString mimeType;
|
||||
nsAutoString notUsed;
|
||||
GetAttr(kNameSpaceID_None, nsGkAtoms::type, aType);
|
||||
nsParserUtils::SplitMimeType(aType, mimeType, notUsed);
|
||||
nsContentUtils::SplitMimeType(aType, mimeType, notUsed);
|
||||
if (!mimeType.IsEmpty() && !mimeType.LowerCaseEqualsLiteral("text/css")) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -47,7 +47,6 @@
|
|||
#include "nsNetUtil.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsParserUtils.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
|
@ -347,7 +346,7 @@ nsHTMLStyleElement::GetStyleSheetInfo(nsAString& aTitle,
|
|||
|
||||
nsAutoString mimeType;
|
||||
nsAutoString notUsed;
|
||||
nsParserUtils::SplitMimeType(aType, mimeType, notUsed);
|
||||
nsContentUtils::SplitMimeType(aType, mimeType, notUsed);
|
||||
if (!mimeType.IsEmpty() && !mimeType.LowerCaseEqualsLiteral("text/css")) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -50,7 +50,6 @@
|
|||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIParser.h"
|
||||
#include "nsParserUtils.h"
|
||||
#include "nsScriptLoader.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
|
|
@ -39,8 +39,8 @@
|
|||
#include "nsGkAtoms.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsXMLProcessingInstruction.h"
|
||||
#include "nsParserUtils.h"
|
||||
#include "nsContentCreatorFunctions.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
nsresult
|
||||
NS_NewXMLProcessingInstruction(nsIContent** aInstancePtrResult,
|
||||
|
@ -129,7 +129,7 @@ nsXMLProcessingInstruction::GetAttrValue(nsIAtom *aName, nsAString& aValue)
|
|||
nsAutoString data;
|
||||
|
||||
GetData(data);
|
||||
return nsParserUtils::GetQuotedAttributeValue(data, aName, aValue);
|
||||
return nsContentUtils::GetPseudoAttributeValue(data, aName, aValue);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -45,7 +45,6 @@
|
|||
#include "nsNetUtil.h"
|
||||
#include "nsXMLProcessingInstruction.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsParserUtils.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
@ -209,10 +208,12 @@ nsXMLStylesheetPI::GetStyleSheetInfo(nsAString& aTitle,
|
|||
nsAutoString data;
|
||||
GetData(data);
|
||||
|
||||
nsParserUtils::GetQuotedAttributeValue(data, nsGkAtoms::title, aTitle);
|
||||
nsContentUtils::GetPseudoAttributeValue(data, nsGkAtoms::title, aTitle);
|
||||
|
||||
nsAutoString alternate;
|
||||
nsParserUtils::GetQuotedAttributeValue(data, nsGkAtoms::alternate, alternate);
|
||||
nsContentUtils::GetPseudoAttributeValue(data,
|
||||
nsGkAtoms::alternate,
|
||||
alternate);
|
||||
|
||||
// if alternate, does it have title?
|
||||
if (alternate.EqualsLiteral("yes")) {
|
||||
|
@ -223,13 +224,13 @@ nsXMLStylesheetPI::GetStyleSheetInfo(nsAString& aTitle,
|
|||
*aIsAlternate = true;
|
||||
}
|
||||
|
||||
nsParserUtils::GetQuotedAttributeValue(data, nsGkAtoms::media, aMedia);
|
||||
nsContentUtils::GetPseudoAttributeValue(data, nsGkAtoms::media, aMedia);
|
||||
|
||||
nsAutoString type;
|
||||
nsParserUtils::GetQuotedAttributeValue(data, nsGkAtoms::type, type);
|
||||
nsContentUtils::GetPseudoAttributeValue(data, nsGkAtoms::type, type);
|
||||
|
||||
nsAutoString mimeType, notUsed;
|
||||
nsParserUtils::SplitMimeType(type, mimeType, notUsed);
|
||||
nsContentUtils::SplitMimeType(type, mimeType, notUsed);
|
||||
if (!mimeType.IsEmpty() && !mimeType.LowerCaseEqualsLiteral("text/css")) {
|
||||
aType.Assign(type);
|
||||
return;
|
||||
|
|
|
@ -68,7 +68,6 @@
|
|||
#include "prtime.h"
|
||||
#include "prlog.h"
|
||||
#include "prmem.h"
|
||||
#include "nsParserUtils.h"
|
||||
#include "nsRect.h"
|
||||
#include "nsGenericElement.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
|
@ -265,11 +264,11 @@ CheckXSLTParamPI(nsIDOMProcessingInstruction* aPi,
|
|||
if (target.EqualsLiteral("xslt-param-namespace")) {
|
||||
aPi->GetData(data);
|
||||
nsAutoString prefix, namespaceAttr;
|
||||
nsParserUtils::GetQuotedAttributeValue(data, nsGkAtoms::prefix,
|
||||
prefix);
|
||||
nsContentUtils::GetPseudoAttributeValue(data, nsGkAtoms::prefix,
|
||||
prefix);
|
||||
if (!prefix.IsEmpty() &&
|
||||
nsParserUtils::GetQuotedAttributeValue(data, nsGkAtoms::_namespace,
|
||||
namespaceAttr)) {
|
||||
nsContentUtils::GetPseudoAttributeValue(data, nsGkAtoms::_namespace,
|
||||
namespaceAttr)) {
|
||||
aProcessor->AddXSLTParamNamespace(prefix, namespaceAttr);
|
||||
}
|
||||
}
|
||||
|
@ -278,14 +277,14 @@ CheckXSLTParamPI(nsIDOMProcessingInstruction* aPi,
|
|||
else if (target.EqualsLiteral("xslt-param")) {
|
||||
aPi->GetData(data);
|
||||
nsAutoString name, namespaceAttr, select, value;
|
||||
nsParserUtils::GetQuotedAttributeValue(data, nsGkAtoms::name,
|
||||
name);
|
||||
nsParserUtils::GetQuotedAttributeValue(data, nsGkAtoms::_namespace,
|
||||
namespaceAttr);
|
||||
if (!nsParserUtils::GetQuotedAttributeValue(data, nsGkAtoms::select, select)) {
|
||||
nsContentUtils::GetPseudoAttributeValue(data, nsGkAtoms::name,
|
||||
name);
|
||||
nsContentUtils::GetPseudoAttributeValue(data, nsGkAtoms::_namespace,
|
||||
namespaceAttr);
|
||||
if (!nsContentUtils::GetPseudoAttributeValue(data, nsGkAtoms::select, select)) {
|
||||
select.SetIsVoid(true);
|
||||
}
|
||||
if (!nsParserUtils::GetQuotedAttributeValue(data, nsGkAtoms::value, value)) {
|
||||
if (!nsContentUtils::GetPseudoAttributeValue(data, nsGkAtoms::value, value)) {
|
||||
value.SetIsVoid(true);
|
||||
}
|
||||
if (!name.IsEmpty()) {
|
||||
|
@ -1340,7 +1339,7 @@ nsXMLContentSink::HandleProcessingInstruction(const PRUnichar *aTarget,
|
|||
|
||||
// If it's not a CSS stylesheet PI...
|
||||
nsAutoString type;
|
||||
nsParserUtils::GetQuotedAttributeValue(data, nsGkAtoms::type, type);
|
||||
nsContentUtils::GetPseudoAttributeValue(data, nsGkAtoms::type, type);
|
||||
|
||||
if (mState != eXMLContentSinkState_InProlog ||
|
||||
!target.EqualsLiteral("xml-stylesheet") ||
|
||||
|
@ -1368,16 +1367,18 @@ nsXMLContentSink::ParsePIData(const nsString &aData, nsString &aHref,
|
|||
bool &aIsAlternate)
|
||||
{
|
||||
// If there was no href, we can't do anything with this PI
|
||||
if (!nsParserUtils::GetQuotedAttributeValue(aData, nsGkAtoms::href, aHref)) {
|
||||
if (!nsContentUtils::GetPseudoAttributeValue(aData, nsGkAtoms::href, aHref)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsParserUtils::GetQuotedAttributeValue(aData, nsGkAtoms::title, aTitle);
|
||||
nsContentUtils::GetPseudoAttributeValue(aData, nsGkAtoms::title, aTitle);
|
||||
|
||||
nsParserUtils::GetQuotedAttributeValue(aData, nsGkAtoms::media, aMedia);
|
||||
nsContentUtils::GetPseudoAttributeValue(aData, nsGkAtoms::media, aMedia);
|
||||
|
||||
nsAutoString alternate;
|
||||
nsParserUtils::GetQuotedAttributeValue(aData, nsGkAtoms::alternate, alternate);
|
||||
nsContentUtils::GetPseudoAttributeValue(aData,
|
||||
nsGkAtoms::alternate,
|
||||
alternate);
|
||||
|
||||
aIsAlternate = alternate.EqualsLiteral("yes");
|
||||
|
||||
|
|
|
@ -74,7 +74,6 @@
|
|||
#include "nsLayoutCID.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsParserUtils.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsXULElement.h"
|
||||
|
@ -1079,7 +1078,7 @@ XULContentSinkImpl::OpenScript(const PRUnichar** aAttributes,
|
|||
// various version strings anyway. So we make no attempt to support
|
||||
// languages other than JS for language=
|
||||
nsAutoString lang(aAttributes[1]);
|
||||
if (nsParserUtils::IsJavaScriptLanguage(lang, &version)) {
|
||||
if (nsContentUtils::IsJavaScriptLanguage(lang, &version)) {
|
||||
langID = nsIProgrammingLanguage::JAVASCRIPT;
|
||||
|
||||
// Even when JS version < 1.6 is specified, E4X is
|
||||
|
|
|
@ -84,7 +84,6 @@
|
|||
#include "nsXULContentUtils.h"
|
||||
#include "nsIXULOverlayProvider.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsParserUtils.h"
|
||||
#include "nsParserCIID.h"
|
||||
#include "nsPIBoxObject.h"
|
||||
#include "nsRDFCID.h"
|
||||
|
@ -2545,9 +2544,9 @@ nsXULDocument::InsertXULOverlayPI(const nsXULPrototypePI* aProtoPI,
|
|||
}
|
||||
|
||||
nsAutoString href;
|
||||
nsParserUtils::GetQuotedAttributeValue(aProtoPI->mData,
|
||||
nsGkAtoms::href,
|
||||
href);
|
||||
nsContentUtils::GetPseudoAttributeValue(aProtoPI->mData,
|
||||
nsGkAtoms::href,
|
||||
href);
|
||||
|
||||
// If there was no href, we can't do anything with this PI
|
||||
if (href.IsEmpty()) {
|
||||
|
|
|
@ -85,6 +85,7 @@
|
|||
#include "nsISHEntry.h"
|
||||
#include "nsIWebPageDescriptor.h"
|
||||
#include "nsIFormControl.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
#include "nsIDOMNodeFilter.h"
|
||||
#include "nsIDOMProcessingInstruction.h"
|
||||
|
@ -2604,72 +2605,6 @@ nsWebBrowserPersist::EnumCleanupUploadList(nsHashKey *aKey, void *aData, void* c
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
nsWebBrowserPersist::GetQuotedAttributeValue(
|
||||
const nsAString &aSource, const nsAString &aAttribute, nsAString &aValue)
|
||||
{
|
||||
// NOTE: This code was lifted verbatim from nsParserUtils.cpp
|
||||
aValue.Truncate();
|
||||
nsAString::const_iterator start, end;
|
||||
aSource.BeginReading(start);
|
||||
aSource.EndReading(end);
|
||||
nsAString::const_iterator iter(end);
|
||||
|
||||
while (start != end) {
|
||||
if (FindInReadable(aAttribute, start, iter))
|
||||
{
|
||||
// walk past any whitespace
|
||||
while (iter != end && nsCRT::IsAsciiSpace(*iter))
|
||||
{
|
||||
++iter;
|
||||
}
|
||||
|
||||
if (iter == end)
|
||||
break;
|
||||
|
||||
// valid name="value" pair?
|
||||
if (*iter != '=')
|
||||
{
|
||||
start = iter;
|
||||
iter = end;
|
||||
continue;
|
||||
}
|
||||
// move past the =
|
||||
++iter;
|
||||
|
||||
while (iter != end && nsCRT::IsAsciiSpace(*iter))
|
||||
{
|
||||
++iter;
|
||||
}
|
||||
|
||||
if (iter == end)
|
||||
break;
|
||||
|
||||
PRUnichar q = *iter;
|
||||
if (q != '"' && q != '\'')
|
||||
{
|
||||
start = iter;
|
||||
iter = end;
|
||||
continue;
|
||||
}
|
||||
|
||||
// point to the first char of the value
|
||||
++iter;
|
||||
start = iter;
|
||||
if (FindCharInReadable(q, iter, end))
|
||||
{
|
||||
aValue = Substring(start, iter);
|
||||
return true;
|
||||
}
|
||||
|
||||
// we've run out of string. Just return...
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
nsresult nsWebBrowserPersist::FixupXMLStyleSheetLink(nsIDOMProcessingInstruction *aPI, const nsAString &aHref)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aPI);
|
||||
|
@ -2680,7 +2615,9 @@ nsresult nsWebBrowserPersist::FixupXMLStyleSheetLink(nsIDOMProcessingInstruction
|
|||
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
|
||||
|
||||
nsAutoString href;
|
||||
GetQuotedAttributeValue(data, NS_LITERAL_STRING("href"), href);
|
||||
nsContentUtils::GetPseudoAttributeValue(data,
|
||||
nsGkAtoms::href,
|
||||
href);
|
||||
|
||||
// Construct and set a new data value for the xml-stylesheet
|
||||
if (!aHref.IsEmpty() && !href.IsEmpty())
|
||||
|
@ -2691,11 +2628,21 @@ nsresult nsWebBrowserPersist::FixupXMLStyleSheetLink(nsIDOMProcessingInstruction
|
|||
nsAutoString type;
|
||||
nsAutoString media;
|
||||
|
||||
GetQuotedAttributeValue(data, NS_LITERAL_STRING("alternate"), alternate);
|
||||
GetQuotedAttributeValue(data, NS_LITERAL_STRING("charset"), charset);
|
||||
GetQuotedAttributeValue(data, NS_LITERAL_STRING("title"), title);
|
||||
GetQuotedAttributeValue(data, NS_LITERAL_STRING("type"), type);
|
||||
GetQuotedAttributeValue(data, NS_LITERAL_STRING("media"), media);
|
||||
nsContentUtils::GetPseudoAttributeValue(data,
|
||||
nsGkAtoms::alternate,
|
||||
alternate);
|
||||
nsContentUtils::GetPseudoAttributeValue(data,
|
||||
nsGkAtoms::charset,
|
||||
charset);
|
||||
nsContentUtils::GetPseudoAttributeValue(data,
|
||||
nsGkAtoms::title,
|
||||
title);
|
||||
nsContentUtils::GetPseudoAttributeValue(data,
|
||||
nsGkAtoms::type,
|
||||
type);
|
||||
nsContentUtils::GetPseudoAttributeValue(data,
|
||||
nsGkAtoms::media,
|
||||
media);
|
||||
|
||||
NS_NAMED_LITERAL_STRING(kCloseAttr, "\" ");
|
||||
nsAutoString newData;
|
||||
|
@ -2736,7 +2683,7 @@ nsresult nsWebBrowserPersist::GetXMLStyleSheetLink(nsIDOMProcessingInstruction *
|
|||
rv = aPI->GetData(data);
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
|
||||
|
||||
GetQuotedAttributeValue(data, NS_LITERAL_STRING("href"), aHref);
|
||||
nsContentUtils::GetPseudoAttributeValue(data, nsGkAtoms::href, aHref);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -152,8 +152,6 @@ private:
|
|||
{
|
||||
return StoreURIAttributeNS(aNode, "", aAttribute, aNeedsPersisting, aData);
|
||||
}
|
||||
bool GetQuotedAttributeValue(
|
||||
const nsAString &aSource, const nsAString &aAttribute, nsAString &aValue);
|
||||
bool DocumentEncoderExists(const PRUnichar *aContentType);
|
||||
|
||||
nsresult GetNodeToFixup(nsIDOMNode *aNodeIn, nsIDOMNode **aNodeOut);
|
||||
|
|
Загрузка…
Ссылка в новой задаче