Bug 1288084 - Expose a line number for each attribute, v2; r=wchen

This commit is contained in:
Henri Sivonen
2016-09-20 16:31:57 +02:00
parent b5d811849f
commit a6fb532484
12 changed files with 87 additions and 27 deletions

View File

@@ -4452,7 +4452,7 @@ class MOZ_STACK_CLASS Debugger::ScriptQuery
return; return;
} }
if (hasSource && !(source.is<ScriptSourceObject*>() && if (hasSource && !(source.is<ScriptSourceObject*>() &&
source.as<ScriptSourceObject*>() == script->sourceObject())) source.as<ScriptSourceObject*>()->source() == script->scriptSource()))
{ {
return; return;
} }

View File

@@ -63,6 +63,8 @@ public final class HtmlAttributes implements Attributes {
private @Auto String[] values; // XXX perhaps make this @NoLength? private @Auto String[] values; // XXX perhaps make this @NoLength?
// CPPONLY: private @Auto int[] lines; // XXX perhaps make this @NoLength?
// [NOCPP[ // [NOCPP[
private String idValue; private String idValue;
@@ -80,10 +82,12 @@ public final class HtmlAttributes implements Attributes {
this.length = 0; this.length = 0;
/* /*
* The length of 5 covers covers 98.3% of elements * The length of 5 covers covers 98.3% of elements
* according to Hixie * according to Hixie, but lets round to the next power of two for
* jemalloc.
*/ */
this.names = new AttributeName[5]; this.names = new AttributeName[8];
this.values = new String[5]; this.values = new String[8];
// CPPONLY: this.lines = new int[8];
// [NOCPP[ // [NOCPP[
@@ -199,6 +203,16 @@ public final class HtmlAttributes implements Attributes {
return names[index]; return names[index];
} }
// CPPONLY: /**
// CPPONLY: * Obtains a line number without bounds check.
// CPPONLY: * @param index a valid attribute index
// CPPONLY: * @return the line number at index or -1 if unknown
// CPPONLY: */
// CPPONLY: public int getLineNoBoundsCheck(int index) {
// CPPONLY: assert index < length && index >= 0: "Index out of bounds";
// CPPONLY: return lines[index];
// CPPONLY: }
// [NOCPP[ // [NOCPP[
/** /**
@@ -393,7 +407,8 @@ public final class HtmlAttributes implements Attributes {
void addAttribute(AttributeName name, String value void addAttribute(AttributeName name, String value
// [NOCPP[ // [NOCPP[
, XmlViolationPolicy xmlnsPolicy , XmlViolationPolicy xmlnsPolicy
// ]NOCPP] // ]NOCPP]
// CPPONLY: , int line
) throws SAXException { ) throws SAXException {
// [NOCPP[ // [NOCPP[
if (name == AttributeName.ID) { if (name == AttributeName.ID) {
@@ -436,9 +451,13 @@ public final class HtmlAttributes implements Attributes {
String[] newValues = new String[newLen]; String[] newValues = new String[newLen];
System.arraycopy(values, 0, newValues, 0, values.length); System.arraycopy(values, 0, newValues, 0, values.length);
values = newValues; values = newValues;
// CPPONLY: int[] newLines = new int[newLen];
// CPPONLY: System.arraycopy(lines, 0, newLines, 0, lines.length);
// CPPONLY: lines = newLines;
} }
names[length] = name; names[length] = name;
values[length] = value; values[length] = value;
// CPPONLY: lines[length] = line;
length++; length++;
} }
@@ -520,6 +539,7 @@ public final class HtmlAttributes implements Attributes {
// [NOCPP[ // [NOCPP[
, XmlViolationPolicy.ALLOW , XmlViolationPolicy.ALLOW
// ]NOCPP] // ]NOCPP]
// CPPONLY: , lines[i]
); );
} }
// [NOCPP[ // [NOCPP[

View File

@@ -493,6 +493,13 @@ public class Tokenizer implements Locator {
private int line; private int line;
/*
* The line number of the current attribute. First set to the line of the
* attribute name and if there is a value, set to the line the value
* started on.
*/
// CPPONLY: private int attributeLine;
private Interner interner; private Interner interner;
// CPPONLY: private boolean viewingXmlSource; // CPPONLY: private boolean viewingXmlSource;
@@ -747,6 +754,7 @@ public class Tokenizer implements Locator {
* For C++ use only. * For C++ use only.
*/ */
public void setLineNumber(int line) { public void setLineNumber(int line) {
// CPPONLY: this.attributeLine = line; // XXX is this needed?
this.line = line; this.line = line;
} }
@@ -1175,6 +1183,7 @@ public class Tokenizer implements Locator {
// [NOCPP[ // [NOCPP[
, xmlnsPolicy , xmlnsPolicy
// ]NOCPP] // ]NOCPP]
// CPPONLY: , attributeLine
); );
// [NOCPP[ // [NOCPP[
} }
@@ -1207,6 +1216,7 @@ public class Tokenizer implements Locator {
// [NOCPP[ // [NOCPP[
, xmlnsPolicy , xmlnsPolicy
// ]NOCPP] // ]NOCPP]
// CPPONLY: , attributeLine
); );
attributeName = null; // attributeName has been adopted by the attributeName = null; // attributeName has been adopted by the
// |attributes| object // |attributes| object
@@ -1753,6 +1763,7 @@ public class Tokenizer implements Locator {
*/ */
c += 0x20; c += 0x20;
} }
// CPPONLY: attributeLine = line;
/* /*
* Set that attribute's name to the current * Set that attribute's name to the current
* input character, * input character,
@@ -1902,6 +1913,7 @@ public class Tokenizer implements Locator {
* U+0022 QUOTATION MARK (") Switch to the * U+0022 QUOTATION MARK (") Switch to the
* attribute value (double-quoted) state. * attribute value (double-quoted) state.
*/ */
// CPPONLY: attributeLine = line;
clearStrBuf(); clearStrBuf();
state = transition(state, Tokenizer.ATTRIBUTE_VALUE_DOUBLE_QUOTED, reconsume, pos); state = transition(state, Tokenizer.ATTRIBUTE_VALUE_DOUBLE_QUOTED, reconsume, pos);
break beforeattributevalueloop; break beforeattributevalueloop;
@@ -1912,6 +1924,7 @@ public class Tokenizer implements Locator {
* value (unquoted) state and reconsume this * value (unquoted) state and reconsume this
* input character. * input character.
*/ */
// CPPONLY: attributeLine = line;
clearStrBuf(); clearStrBuf();
reconsume = true; reconsume = true;
state = transition(state, Tokenizer.ATTRIBUTE_VALUE_UNQUOTED, reconsume, pos); state = transition(state, Tokenizer.ATTRIBUTE_VALUE_UNQUOTED, reconsume, pos);
@@ -1922,6 +1935,7 @@ public class Tokenizer implements Locator {
* U+0027 APOSTROPHE (') Switch to the attribute * U+0027 APOSTROPHE (') Switch to the attribute
* value (single-quoted) state. * value (single-quoted) state.
*/ */
// CPPONLY: attributeLine = line;
clearStrBuf(); clearStrBuf();
state = transition(state, Tokenizer.ATTRIBUTE_VALUE_SINGLE_QUOTED, reconsume, pos); state = transition(state, Tokenizer.ATTRIBUTE_VALUE_SINGLE_QUOTED, reconsume, pos);
continue stateloop; continue stateloop;
@@ -1965,6 +1979,7 @@ public class Tokenizer implements Locator {
* Anything else Append the current input * Anything else Append the current input
* character to the current attribute's value. * character to the current attribute's value.
*/ */
// CPPONLY: attributeLine = line;
clearStrBufAndAppend(c); clearStrBufAndAppend(c);
/* /*
* Switch to the attribute value (unquoted) * Switch to the attribute value (unquoted)
@@ -6737,6 +6752,7 @@ public class Tokenizer implements Locator {
confident = false; confident = false;
strBuf = null; strBuf = null;
line = 1; line = 1;
// CPPONLY: attributeLine = 1;
// [NOCPP[ // [NOCPP[
html4 = false; html4 = false;
metaBoundaryPassed = false; metaBoundaryPassed = false;

View File

@@ -2346,6 +2346,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
// [NOCPP[ // [NOCPP[
, XmlViolationPolicy.ALLOW , XmlViolationPolicy.ALLOW
// ]NOCPP] // ]NOCPP]
// CPPONLY: , attributes.getLineNoBoundsCheck(actionIndex)
); );
} }
appendToCurrentNodeAndPushFormElementMayFoster(formAttrs); appendToCurrentNodeAndPushFormElementMayFoster(formAttrs);
@@ -2371,6 +2372,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
// [NOCPP[ // [NOCPP[
, XmlViolationPolicy.ALLOW , XmlViolationPolicy.ALLOW
// ]NOCPP] // ]NOCPP]
// CPPONLY: , tokenizer.getLineNumber()
); );
for (int i = 0; i < attributes.getLength(); i++) { for (int i = 0; i < attributes.getLength(); i++) {
AttributeName attributeQName = attributes.getAttributeNameNoBoundsCheck(i); AttributeName attributeQName = attributes.getAttributeNameNoBoundsCheck(i);
@@ -2384,7 +2386,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
// [NOCPP[ // [NOCPP[
, XmlViolationPolicy.ALLOW , XmlViolationPolicy.ALLOW
// ]NOCPP] // ]NOCPP]
// CPPONLY: , attributes.getLineNoBoundsCheck(i)
); );
} }
} }

View File

@@ -106,7 +106,7 @@ nsHtml5Highlighter::Start(const nsAutoString& aTitle)
nsHtml5HtmlAttributes* preAttrs = new nsHtml5HtmlAttributes(0); nsHtml5HtmlAttributes* preAttrs = new nsHtml5HtmlAttributes(0);
nsString* preId = new nsString(NS_LITERAL_STRING("line1")); nsString* preId = new nsString(NS_LITERAL_STRING("line1"));
preAttrs->addAttribute(nsHtml5AttributeName::ATTR_ID, preId); preAttrs->addAttribute(nsHtml5AttributeName::ATTR_ID, preId, -1);
Push(nsGkAtoms::pre, preAttrs); Push(nsGkAtoms::pre, preAttrs);
StartCharacters(); StartCharacters();

View File

@@ -60,8 +60,9 @@ nsHtml5HtmlAttributes* nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES = nullptr;
nsHtml5HtmlAttributes::nsHtml5HtmlAttributes(int32_t mode) nsHtml5HtmlAttributes::nsHtml5HtmlAttributes(int32_t mode)
: mode(mode), : mode(mode),
length(0), length(0),
names(jArray<nsHtml5AttributeName*,int32_t>::newJArray(5)), names(jArray<nsHtml5AttributeName*,int32_t>::newJArray(8)),
values(jArray<nsString*,int32_t>::newJArray(5)) values(jArray<nsString*,int32_t>::newJArray(8)),
lines(jArray<int32_t,int32_t>::newJArray(8))
{ {
MOZ_COUNT_CTOR(nsHtml5HtmlAttributes); MOZ_COUNT_CTOR(nsHtml5HtmlAttributes);
} }
@@ -136,8 +137,15 @@ nsHtml5HtmlAttributes::getAttributeNameNoBoundsCheck(int32_t index)
return names[index]; return names[index];
} }
int32_t
nsHtml5HtmlAttributes::getLineNoBoundsCheck(int32_t index)
{
MOZ_ASSERT(index < length && index >= 0, "Index out of bounds");
return lines[index];
}
void void
nsHtml5HtmlAttributes::addAttribute(nsHtml5AttributeName* name, nsString* value) nsHtml5HtmlAttributes::addAttribute(nsHtml5AttributeName* name, nsString* value, int32_t line)
{ {
if (names.length == length) { if (names.length == length) {
int32_t newLen = length << 1; int32_t newLen = length << 1;
@@ -147,9 +155,13 @@ nsHtml5HtmlAttributes::addAttribute(nsHtml5AttributeName* name, nsString* value)
jArray<nsString*,int32_t> newValues = jArray<nsString*,int32_t>::newJArray(newLen); jArray<nsString*,int32_t> newValues = jArray<nsString*,int32_t>::newJArray(newLen);
nsHtml5ArrayCopy::arraycopy(values, newValues, values.length); nsHtml5ArrayCopy::arraycopy(values, newValues, values.length);
values = newValues; values = newValues;
jArray<int32_t,int32_t> newLines = jArray<int32_t,int32_t>::newJArray(newLen);
nsHtml5ArrayCopy::arraycopy(lines, newLines, lines.length);
lines = newLines;
} }
names[length] = name; names[length] = name;
values[length] = value; values[length] = value;
lines[length] = line;
length++; length++;
} }
@@ -211,7 +223,7 @@ nsHtml5HtmlAttributes::cloneAttributes(nsHtml5AtomTable* interner)
MOZ_ASSERT((!length) || !mode || mode == 3); MOZ_ASSERT((!length) || !mode || mode == 3);
nsHtml5HtmlAttributes* clone = new nsHtml5HtmlAttributes(0); nsHtml5HtmlAttributes* clone = new nsHtml5HtmlAttributes(0);
for (int32_t i = 0; i < length; i++) { for (int32_t i = 0; i < length; i++) {
clone->addAttribute(names[i]->cloneAttributeName(interner), nsHtml5Portability::newStringFromString(values[i])); clone->addAttribute(names[i]->cloneAttributeName(interner), nsHtml5Portability::newStringFromString(values[i]), lines[i]);
} }
return clone; return clone;
} }

View File

@@ -65,6 +65,7 @@ class nsHtml5HtmlAttributes
int32_t length; int32_t length;
autoJArray<nsHtml5AttributeName*,int32_t> names; autoJArray<nsHtml5AttributeName*,int32_t> names;
autoJArray<nsString*,int32_t> values; autoJArray<nsString*,int32_t> values;
autoJArray<int32_t,int32_t> lines;
public: public:
explicit nsHtml5HtmlAttributes(int32_t mode); explicit nsHtml5HtmlAttributes(int32_t mode);
~nsHtml5HtmlAttributes(); ~nsHtml5HtmlAttributes();
@@ -76,7 +77,8 @@ class nsHtml5HtmlAttributes
nsIAtom* getPrefixNoBoundsCheck(int32_t index); nsIAtom* getPrefixNoBoundsCheck(int32_t index);
nsString* getValueNoBoundsCheck(int32_t index); nsString* getValueNoBoundsCheck(int32_t index);
nsHtml5AttributeName* getAttributeNameNoBoundsCheck(int32_t index); nsHtml5AttributeName* getAttributeNameNoBoundsCheck(int32_t index);
void addAttribute(nsHtml5AttributeName* name, nsString* value); int32_t getLineNoBoundsCheck(int32_t index);
void addAttribute(nsHtml5AttributeName* name, nsString* value, int32_t line);
void clear(int32_t m); void clear(int32_t m);
void releaseValue(int32_t i); void releaseValue(int32_t i);
void clearWithoutReleasingContents(); void clearWithoutReleasingContents();

View File

@@ -15,12 +15,12 @@ nsHtml5PlainTextUtils::NewLinkAttributes()
{ {
nsHtml5HtmlAttributes* linkAttrs = new nsHtml5HtmlAttributes(0); nsHtml5HtmlAttributes* linkAttrs = new nsHtml5HtmlAttributes(0);
nsString* rel = new nsString(NS_LITERAL_STRING("alternate stylesheet")); nsString* rel = new nsString(NS_LITERAL_STRING("alternate stylesheet"));
linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_REL, rel); linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_REL, rel, -1);
nsString* type = new nsString(NS_LITERAL_STRING("text/css")); nsString* type = new nsString(NS_LITERAL_STRING("text/css"));
linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_TYPE, type); linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_TYPE, type, -1);
nsString* href = new nsString( nsString* href = new nsString(
NS_LITERAL_STRING("resource://gre-resources/plaintext.css")); NS_LITERAL_STRING("resource://gre-resources/plaintext.css"));
linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_HREF, href); linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_HREF, href, -1);
nsresult rv; nsresult rv;
nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv); nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
@@ -35,6 +35,6 @@ nsHtml5PlainTextUtils::NewLinkAttributes()
} }
nsString* titleCopy = new nsString(title); nsString* titleCopy = new nsString(title);
linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_TITLE, titleCopy); linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_TITLE, titleCopy, -1);
return linkAttrs; return linkAttrs;
} }

View File

@@ -199,6 +199,7 @@ nsHtml5Tokenizer::endTagExpectationToArray()
void void
nsHtml5Tokenizer::setLineNumber(int32_t line) nsHtml5Tokenizer::setLineNumber(int32_t line)
{ {
this->attributeLine = line;
this->line = line; this->line = line;
} }
@@ -335,7 +336,7 @@ nsHtml5Tokenizer::addAttributeWithoutValue()
{ {
if (attributeName) { if (attributeName) {
attributes->addAttribute(attributeName, nsHtml5Portability::newEmptyString()); attributes->addAttribute(attributeName, nsHtml5Portability::newEmptyString(), attributeLine);
attributeName = nullptr; attributeName = nullptr;
} }
} }
@@ -348,7 +349,7 @@ nsHtml5Tokenizer::addAttributeWithValue()
if (mViewSource) { if (mViewSource) {
mViewSource->MaybeLinkifyAttributeValue(attributeName, val); mViewSource->MaybeLinkifyAttributeValue(attributeName, val);
} }
attributes->addAttribute(attributeName, val); attributes->addAttribute(attributeName, val, attributeLine);
attributeName = nullptr; attributeName = nullptr;
} }
} }
@@ -620,6 +621,7 @@ nsHtml5Tokenizer::stateLoop(int32_t state, char16_t c, int32_t pos, char16_t* bu
if (c >= 'A' && c <= 'Z') { if (c >= 'A' && c <= 'Z') {
c += 0x20; c += 0x20;
} }
attributeLine = line;
clearStrBufAndAppend(c); clearStrBufAndAppend(c);
state = P::transition(mViewSource, NS_HTML5TOKENIZER_ATTRIBUTE_NAME, reconsume, pos); state = P::transition(mViewSource, NS_HTML5TOKENIZER_ATTRIBUTE_NAME, reconsume, pos);
NS_HTML5_BREAK(beforeattributenameloop); NS_HTML5_BREAK(beforeattributenameloop);
@@ -712,11 +714,13 @@ nsHtml5Tokenizer::stateLoop(int32_t state, char16_t c, int32_t pos, char16_t* bu
continue; continue;
} }
case '\"': { case '\"': {
attributeLine = line;
clearStrBuf(); clearStrBuf();
state = P::transition(mViewSource, NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_DOUBLE_QUOTED, reconsume, pos); state = P::transition(mViewSource, NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_DOUBLE_QUOTED, reconsume, pos);
NS_HTML5_BREAK(beforeattributevalueloop); NS_HTML5_BREAK(beforeattributevalueloop);
} }
case '&': { case '&': {
attributeLine = line;
clearStrBuf(); clearStrBuf();
reconsume = true; reconsume = true;
state = P::transition(mViewSource, NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_UNQUOTED, reconsume, pos); state = P::transition(mViewSource, NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_UNQUOTED, reconsume, pos);
@@ -724,6 +728,7 @@ nsHtml5Tokenizer::stateLoop(int32_t state, char16_t c, int32_t pos, char16_t* bu
NS_HTML5_CONTINUE(stateloop); NS_HTML5_CONTINUE(stateloop);
} }
case '\'': { case '\'': {
attributeLine = line;
clearStrBuf(); clearStrBuf();
state = P::transition(mViewSource, NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_SINGLE_QUOTED, reconsume, pos); state = P::transition(mViewSource, NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_SINGLE_QUOTED, reconsume, pos);
NS_HTML5_CONTINUE(stateloop); NS_HTML5_CONTINUE(stateloop);
@@ -750,6 +755,7 @@ nsHtml5Tokenizer::stateLoop(int32_t state, char16_t c, int32_t pos, char16_t* bu
} }
} }
default: { default: {
attributeLine = line;
clearStrBufAndAppend(c); clearStrBufAndAppend(c);
state = P::transition(mViewSource, NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_UNQUOTED, reconsume, pos); state = P::transition(mViewSource, NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_UNQUOTED, reconsume, pos);
@@ -4043,6 +4049,7 @@ nsHtml5Tokenizer::initializeWithoutStarting()
confident = false; confident = false;
strBuf = nullptr; strBuf = nullptr;
line = 1; line = 1;
attributeLine = 1;
resetToDataState(); resetToDataState();
} }

View File

@@ -135,6 +135,7 @@ class nsHtml5Tokenizer
bool confident; bool confident;
private: private:
int32_t line; int32_t line;
int32_t attributeLine;
nsHtml5AtomTable* interner; nsHtml5AtomTable* interner;
bool viewingXmlSource; bool viewingXmlSource;
public: public:

View File

@@ -1243,7 +1243,7 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
nsHtml5HtmlAttributes* formAttrs = new nsHtml5HtmlAttributes(0); nsHtml5HtmlAttributes* formAttrs = new nsHtml5HtmlAttributes(0);
int32_t actionIndex = attributes->getIndex(nsHtml5AttributeName::ATTR_ACTION); int32_t actionIndex = attributes->getIndex(nsHtml5AttributeName::ATTR_ACTION);
if (actionIndex > -1) { if (actionIndex > -1) {
formAttrs->addAttribute(nsHtml5AttributeName::ATTR_ACTION, attributes->getValueNoBoundsCheck(actionIndex)); formAttrs->addAttribute(nsHtml5AttributeName::ATTR_ACTION, attributes->getValueNoBoundsCheck(actionIndex), attributes->getLineNoBoundsCheck(actionIndex));
} }
appendToCurrentNodeAndPushFormElementMayFoster(formAttrs); appendToCurrentNodeAndPushFormElementMayFoster(formAttrs);
appendVoidElementToCurrentMayFoster(nsHtml5ElementName::ELT_HR, nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES); appendVoidElementToCurrentMayFoster(nsHtml5ElementName::ELT_HR, nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES);
@@ -1256,13 +1256,13 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
appendIsindexPrompt(stack[currentPtr]->node); appendIsindexPrompt(stack[currentPtr]->node);
} }
nsHtml5HtmlAttributes* inputAttributes = new nsHtml5HtmlAttributes(0); nsHtml5HtmlAttributes* inputAttributes = new nsHtml5HtmlAttributes(0);
inputAttributes->addAttribute(nsHtml5AttributeName::ATTR_NAME, nsHtml5Portability::newStringFromLiteral("isindex")); inputAttributes->addAttribute(nsHtml5AttributeName::ATTR_NAME, nsHtml5Portability::newStringFromLiteral("isindex"), tokenizer->getLineNumber());
for (int32_t i = 0; i < attributes->getLength(); i++) { for (int32_t i = 0; i < attributes->getLength(); i++) {
nsHtml5AttributeName* attributeQName = attributes->getAttributeNameNoBoundsCheck(i); nsHtml5AttributeName* attributeQName = attributes->getAttributeNameNoBoundsCheck(i);
if (nsHtml5AttributeName::ATTR_NAME == attributeQName || nsHtml5AttributeName::ATTR_PROMPT == attributeQName) { if (nsHtml5AttributeName::ATTR_NAME == attributeQName || nsHtml5AttributeName::ATTR_PROMPT == attributeQName) {
attributes->releaseValue(i); attributes->releaseValue(i);
} else if (nsHtml5AttributeName::ATTR_ACTION != attributeQName) { } else if (nsHtml5AttributeName::ATTR_ACTION != attributeQName) {
inputAttributes->addAttribute(attributeQName, attributes->getValueNoBoundsCheck(i)); inputAttributes->addAttribute(attributeQName, attributes->getValueNoBoundsCheck(i), attributes->getLineNoBoundsCheck(i));
} }
} }
attributes->clearWithoutReleasingContents(); attributes->clearWithoutReleasingContents();

View File

@@ -14,7 +14,7 @@ nsHtml5ViewSourceUtils::NewBodyAttributes()
{ {
nsHtml5HtmlAttributes* bodyAttrs = new nsHtml5HtmlAttributes(0); nsHtml5HtmlAttributes* bodyAttrs = new nsHtml5HtmlAttributes(0);
auto id = MakeUnique<nsString>(NS_LITERAL_STRING("viewsource")); auto id = MakeUnique<nsString>(NS_LITERAL_STRING("viewsource"));
bodyAttrs->addAttribute(nsHtml5AttributeName::ATTR_ID, id.release()); bodyAttrs->addAttribute(nsHtml5AttributeName::ATTR_ID, id.release(), -1);
auto klass = MakeUnique<nsString>(); auto klass = MakeUnique<nsString>();
if (mozilla::Preferences::GetBool("view_source.wrap_long_lines", true)) { if (mozilla::Preferences::GetBool("view_source.wrap_long_lines", true)) {
@@ -24,14 +24,14 @@ nsHtml5ViewSourceUtils::NewBodyAttributes()
klass->Append(NS_LITERAL_STRING("highlight")); klass->Append(NS_LITERAL_STRING("highlight"));
} }
if (!klass->IsEmpty()) { if (!klass->IsEmpty()) {
bodyAttrs->addAttribute(nsHtml5AttributeName::ATTR_CLASS, klass.release()); bodyAttrs->addAttribute(nsHtml5AttributeName::ATTR_CLASS, klass.release(), -1);
} }
int32_t tabSize = mozilla::Preferences::GetInt("view_source.tab_size", 4); int32_t tabSize = mozilla::Preferences::GetInt("view_source.tab_size", 4);
if (tabSize > 0) { if (tabSize > 0) {
auto style = MakeUnique<nsString>(NS_LITERAL_STRING("-moz-tab-size: ")); auto style = MakeUnique<nsString>(NS_LITERAL_STRING("-moz-tab-size: "));
style->AppendInt(tabSize); style->AppendInt(tabSize);
bodyAttrs->addAttribute(nsHtml5AttributeName::ATTR_STYLE, style.release()); bodyAttrs->addAttribute(nsHtml5AttributeName::ATTR_STYLE, style.release(), -1);
} }
return bodyAttrs; return bodyAttrs;
@@ -43,11 +43,11 @@ nsHtml5ViewSourceUtils::NewLinkAttributes()
{ {
nsHtml5HtmlAttributes* linkAttrs = new nsHtml5HtmlAttributes(0); nsHtml5HtmlAttributes* linkAttrs = new nsHtml5HtmlAttributes(0);
nsString* rel = new nsString(NS_LITERAL_STRING("stylesheet")); nsString* rel = new nsString(NS_LITERAL_STRING("stylesheet"));
linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_REL, rel); linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_REL, rel, -1);
nsString* type = new nsString(NS_LITERAL_STRING("text/css")); nsString* type = new nsString(NS_LITERAL_STRING("text/css"));
linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_TYPE, type); linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_TYPE, type, -1);
nsString* href = new nsString( nsString* href = new nsString(
NS_LITERAL_STRING("resource://gre-resources/viewsource.css")); NS_LITERAL_STRING("resource://gre-resources/viewsource.css"));
linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_HREF, href); linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_HREF, href, -1);
return linkAttrs; return linkAttrs;
} }