(refs #310)Convert all CRLF to LF

This commit is contained in:
Naoki Takezoe
2014-06-29 04:16:37 +09:00
parent 1c99b57709
commit fd09058a7d
37 changed files with 93251 additions and 57107 deletions

View File

@@ -59,6 +59,8 @@ var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var DiffHighlightRules = function() { var DiffHighlightRules = function() {
this.$rules = { this.$rules = {
"start" : [{ "start" : [{
regex: "^(?:\\*{15}|={67}|-{3}|\\+{3})$", regex: "^(?:\\*{15}|={67}|-{3}|\\+{3})$",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -2128,12 +2128,14 @@ function isSelectScopeMarker(node) {
return !(node.namespaceURI === "http://www.w3.org/1999/xhtml" && node.localName === 'optgroup') return !(node.namespaceURI === "http://www.w3.org/1999/xhtml" && node.localName === 'optgroup')
&& !(node.namespaceURI === "http://www.w3.org/1999/xhtml" && node.localName === 'option'); && !(node.namespaceURI === "http://www.w3.org/1999/xhtml" && node.localName === 'option');
} }
function ElementStack() { function ElementStack() {
this.elements = []; this.elements = [];
this.rootNode = null; this.rootNode = null;
this.headElement = null; this.headElement = null;
this.bodyElement = null; this.bodyElement = null;
} }
ElementStack.prototype._inScope = function(localName, isMarker) { ElementStack.prototype._inScope = function(localName, isMarker) {
for (var i = this.elements.length - 1; i >= 0; i--) { for (var i = this.elements.length - 1; i >= 0; i--) {
var node = this.elements[i]; var node = this.elements[i];
@@ -2334,8 +2336,14 @@ EntityParser.consumeEntity = function(buffer, tokenizer, additionalAllowedCharac
code = replacement; code = replacement;
} }
if (code > 0xFFFF && code <= 0x10FFFF) { if (code > 0xFFFF && code <= 0x10FFFF) {
code -= 0x10000; code -= 0x10000;
var first = ((0xffc00 & code) >> 10) + 0xD800; var first = ((0xffc00 & code) >> 10) + 0xD800;
var second = (0x3ff & code) + 0xDC00; var second = (0x3ff & code) + 0xDC00;
decodedCharacter = String.fromCharCode(first, second); decodedCharacter = String.fromCharCode(first, second);
} else } else
@@ -2663,6 +2671,7 @@ function StackItem(namespaceURI, localName, attributes, node) {
this.attributes = attributes; this.attributes = attributes;
this.node = node; this.node = node;
} }
StackItem.prototype.isSpecial = function() { StackItem.prototype.isSpecial = function() {
return this.namespaceURI in SpecialElements && return this.namespaceURI in SpecialElements &&
SpecialElements[this.namespaceURI].indexOf(this.localName) > -1; SpecialElements[this.namespaceURI].indexOf(this.localName) > -1;
@@ -4388,11 +4397,16 @@ function TreeBuilder() {
tree.parseError('expected-closing-tag-but-got-eof'); tree.parseError('expected-closing-tag-but-got-eof');
} else if (tree.openElements.length == 2 && } else if (tree.openElements.length == 2 &&
tree.openElements.item(1).localName != 'body') { tree.openElements.item(1).localName != 'body') {
tree.parseError('expected-closing-tag-but-got-eof'); tree.parseError('expected-closing-tag-but-got-eof');
} else if (tree.context && tree.openElements.length > 1) { } else if (tree.context && tree.openElements.length > 1) {
} }
}, },
processComment: function(data) { processComment: function(data) {
tree.insertComment(data, tree.currentStackItem().node); tree.insertComment(data, tree.currentStackItem().node);
}, },
processDoctype: function(name, publicId, systemId, forceQuirks) { processDoctype: function(name, publicId, systemId, forceQuirks) {
@@ -4535,6 +4549,8 @@ function TreeBuilder() {
|| (publicId == "-//W3C//DTD XHTML 1.0 Strict//EN" && (systemId == "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd")) || (publicId == "-//W3C//DTD XHTML 1.0 Strict//EN" && (systemId == "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"))
|| (publicId == "-//W3C//DTD XHTML 1.1//EN" && (systemId == "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd")) || (publicId == "-//W3C//DTD XHTML 1.1//EN" && (systemId == "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"))
) { ) {
} else if (!((systemId == null || systemId == "about:legacy-compat") && publicId == null)) { } else if (!((systemId == null || systemId == "about:legacy-compat") && publicId == null)) {
tree.parseError("unknown-doctype"); tree.parseError("unknown-doctype");
} }
@@ -4663,6 +4679,8 @@ function TreeBuilder() {
}; };
modes.afterBody.processComment = function(data) { modes.afterBody.processComment = function(data) {
tree.insertComment(data, tree.openElements.rootNode); tree.insertComment(data, tree.openElements.rootNode);
}; };
@@ -4685,6 +4703,11 @@ function TreeBuilder() {
if (tree.context) { if (tree.context) {
tree.parseError('end-html-in-innerhtml'); tree.parseError('end-html-in-innerhtml');
} else { } else {
tree.setInsertionMode('afterAfterBody'); tree.setInsertionMode('afterAfterBody');
} }
}; };
@@ -4855,6 +4878,7 @@ function TreeBuilder() {
}; };
modes.inHead.startTagNoFramesStyle = function(name, attributes) { modes.inHead.startTagNoFramesStyle = function(name, attributes) {
tree.processGenericRawTextStartTag(name, attributes); tree.processGenericRawTextStartTag(name, attributes);
}; };
@@ -4871,6 +4895,7 @@ function TreeBuilder() {
modes.inHead.startTagMeta = function(name, attributes) { modes.inHead.startTagMeta = function(name, attributes) {
tree.insertSelfClosingElement(name, attributes); tree.insertSelfClosingElement(name, attributes);
}; };
modes.inHead.startTagOther = function(name, attributes, selfClosing) { modes.inHead.startTagOther = function(name, attributes, selfClosing) {
@@ -4911,6 +4936,7 @@ function TreeBuilder() {
link: 'startTagFromHead', link: 'startTagFromHead',
meta: 'startTagFromHead', meta: 'startTagFromHead',
script: 'startTagFromHead', script: 'startTagFromHead',
style: 'startTagFromHead', style: 'startTagFromHead',
title: 'startTagFromHead', title: 'startTagFromHead',
"-default": 'startTagOther' "-default": 'startTagOther'
@@ -4955,6 +4981,7 @@ function TreeBuilder() {
modes.afterHead.startTagFromHead = function(name, attributes, selfClosing) { modes.afterHead.startTagFromHead = function(name, attributes, selfClosing) {
tree.parseError("unexpected-start-tag-out-of-my-head", {name: name}); tree.parseError("unexpected-start-tag-out-of-my-head", {name: name});
tree.openElements.push(tree.head); tree.openElements.push(tree.head);
modes.inHead.processStartTag(name, attributes, selfClosing); modes.inHead.processStartTag(name, attributes, selfClosing);
tree.openElements.remove(tree.head); tree.openElements.remove(tree.head);
@@ -5161,6 +5188,7 @@ function TreeBuilder() {
tree.reconstructActiveFormattingElements(); tree.reconstructActiveFormattingElements();
var characters = buffer.takeRemaining(); var characters = buffer.takeRemaining();
characters = characters.replace(/\u0000/g, function(match, index){ characters = characters.replace(/\u0000/g, function(match, index){
tree.parseError("invalid-codepoint"); tree.parseError("invalid-codepoint");
return ''; return '';
}); });
@@ -5241,6 +5269,7 @@ function TreeBuilder() {
}; };
modes.inBody.startTagListItem = function(name, attributes) { modes.inBody.startTagListItem = function(name, attributes) {
var stopNames = {li: ['li'], dd: ['dd', 'dt'], dt: ['dd', 'dt']}; var stopNames = {li: ['li'], dd: ['dd', 'dt'], dt: ['dd', 'dt']};
var stopName = stopNames[name]; var stopName = stopNames[name];
@@ -5251,11 +5280,13 @@ function TreeBuilder() {
tree.insertionMode.processEndTag(node.localName); tree.insertionMode.processEndTag(node.localName);
break; break;
} }
if (node.isSpecial() && node.localName !== 'p' && node.localName !== 'address' && node.localName !== 'div') if (node.isSpecial() && node.localName !== 'p' && node.localName !== 'address' && node.localName !== 'div')
break; break;
} }
if (tree.openElements.inButtonScope('p')) if (tree.openElements.inButtonScope('p'))
this.endTagP('p'); this.endTagP('p');
tree.insertElement(name, attributes); tree.insertElement(name, attributes);
tree.framesetOk = false; tree.framesetOk = false;
}; };
@@ -5300,6 +5331,7 @@ function TreeBuilder() {
if (tree.openElements.inScope('nobr')) { if (tree.openElements.inScope('nobr')) {
tree.parseError("unexpected-start-tag-implies-end-tag", {startName: 'nobr', endName: 'nobr'}); tree.parseError("unexpected-start-tag-implies-end-tag", {startName: 'nobr', endName: 'nobr'});
this.processEndTag('nobr'); this.processEndTag('nobr');
tree.reconstructActiveFormattingElements(); tree.reconstructActiveFormattingElements();
} }
tree.insertFormattingElement(name, attributes); tree.insertFormattingElement(name, attributes);
@@ -5372,6 +5404,7 @@ function TreeBuilder() {
}; };
modes.inBody.startTagImage = function(name, attributes) { modes.inBody.startTagImage = function(name, attributes) {
tree.parseError('unexpected-start-tag-treated-as', {originalName: 'image', newName: 'img'}); tree.parseError('unexpected-start-tag-treated-as', {originalName: 'image', newName: 'img'});
this.processStartTag('img', attributes); this.processStartTag('img', attributes);
}; };
@@ -5380,6 +5413,7 @@ function TreeBuilder() {
var currentFramesetOk = tree.framesetOk; var currentFramesetOk = tree.framesetOk;
this.startTagVoidFormatting(name, attributes); this.startTagVoidFormatting(name, attributes);
for (var key in attributes) { for (var key in attributes) {
if (attributes[key].nodeName == 'type') { if (attributes[key].nodeName == 'type') {
if (attributes[key].nodeValue.toLowerCase() == 'hidden') if (attributes[key].nodeValue.toLowerCase() == 'hidden')
tree.framesetOk = currentFramesetOk; tree.framesetOk = currentFramesetOk;
@@ -5424,6 +5458,7 @@ function TreeBuilder() {
}; };
modes.inBody.startTagTextarea = function(name, attributes) { modes.inBody.startTagTextarea = function(name, attributes) {
tree.insertElement(name, attributes); tree.insertElement(name, attributes);
tree.tokenizer.setState(Tokenizer.RCDATA); tree.tokenizer.setState(Tokenizer.RCDATA);
tree.originalInsertionMode = tree.insertionModeName; tree.originalInsertionMode = tree.insertionModeName;
@@ -5463,6 +5498,7 @@ function TreeBuilder() {
}; };
modes.inBody.endTagMisplaced = function(name) { modes.inBody.endTagMisplaced = function(name) {
tree.parseError("unexpected-end-tag", {name: name}); tree.parseError("unexpected-end-tag", {name: name});
}; };
@@ -5493,6 +5529,7 @@ function TreeBuilder() {
tree.generateImpliedEndTags(name); tree.generateImpliedEndTags(name);
if (tree.currentStackItem().localName != name) if (tree.currentStackItem().localName != name)
tree.parseError('unexpected-end-tag', {name: name}); tree.parseError('unexpected-end-tag', {name: name});
tree.openElements.remove_openElements_until(function(x) {return x === node;}); tree.openElements.remove_openElements_until(function(x) {return x === node;});
break; break;
} }
@@ -5508,6 +5545,8 @@ function TreeBuilder() {
attributes = tree.adjustMathMLAttributes(attributes); attributes = tree.adjustMathMLAttributes(attributes);
attributes = tree.adjustForeignAttributes(attributes); attributes = tree.adjustForeignAttributes(attributes);
tree.insertForeignElement(name, attributes, "http://www.w3.org/1998/Math/MathML", selfClosing); tree.insertForeignElement(name, attributes, "http://www.w3.org/1998/Math/MathML", selfClosing);
}; };
modes.inBody.startTagSVG = function(name, attributes, selfClosing) { modes.inBody.startTagSVG = function(name, attributes, selfClosing) {
@@ -5515,6 +5554,8 @@ function TreeBuilder() {
attributes = tree.adjustSVGAttributes(attributes); attributes = tree.adjustSVGAttributes(attributes);
attributes = tree.adjustForeignAttributes(attributes); attributes = tree.adjustForeignAttributes(attributes);
tree.insertForeignElement(name, attributes, "http://www.w3.org/2000/svg", selfClosing); tree.insertForeignElement(name, attributes, "http://www.w3.org/2000/svg", selfClosing);
}; };
modes.inBody.endTagP = function(name) { modes.inBody.endTagP = function(name) {
@@ -5535,6 +5576,8 @@ function TreeBuilder() {
tree.parseError('unexpected-end-tag', {name: name}); tree.parseError('unexpected-end-tag', {name: name});
return; return;
} }
if (tree.currentStackItem().localName != 'body') { if (tree.currentStackItem().localName != 'body') {
tree.parseError('expected-one-end-tag-but-got-another', { tree.parseError('expected-one-end-tag-but-got-another', {
expectedName: tree.currentStackItem().localName, expectedName: tree.currentStackItem().localName,
@@ -5549,6 +5592,8 @@ function TreeBuilder() {
tree.parseError('unexpected-end-tag', {name: name}); tree.parseError('unexpected-end-tag', {name: name});
return; return;
} }
if (tree.currentStackItem().localName != 'body') { if (tree.currentStackItem().localName != 'body') {
tree.parseError('expected-one-end-tag-but-got-another', { tree.parseError('expected-one-end-tag-but-got-another', {
expectedName: tree.currentStackItem().localName, expectedName: tree.currentStackItem().localName,
@@ -5662,11 +5707,14 @@ function TreeBuilder() {
modes.inCaption.endTagCaption = function(name) { modes.inCaption.endTagCaption = function(name) {
if (!tree.openElements.inTableScope('caption')) { if (!tree.openElements.inTableScope('caption')) {
assert.ok(tree.context); assert.ok(tree.context);
tree.parseError('unexpected-end-tag', {name: name}); tree.parseError('unexpected-end-tag', {name: name});
} else { } else {
tree.generateImpliedEndTags(); tree.generateImpliedEndTags();
if (tree.currentStackItem().localName != 'caption') { if (tree.currentStackItem().localName != 'caption') {
tree.parseError('expected-one-end-tag-but-got-another', { tree.parseError('expected-one-end-tag-but-got-another', {
gotName: "caption", gotName: "caption",
expectedName: tree.currentStackItem().localName expectedName: tree.currentStackItem().localName
@@ -5734,6 +5782,7 @@ function TreeBuilder() {
this.closeCell(); this.closeCell();
tree.insertionMode.processStartTag(name, attributes, selfClosing); tree.insertionMode.processStartTag(name, attributes, selfClosing);
} else { } else {
tree.parseError('unexpected-start-tag', {name: name}); tree.parseError('unexpected-start-tag', {name: name});
} }
}; };
@@ -5767,6 +5816,7 @@ function TreeBuilder() {
this.closeCell(); this.closeCell();
tree.insertionMode.processEndTag(name); tree.insertionMode.processEndTag(name);
} else { } else {
tree.parseError('unexpected-end-tag', {name: name}); tree.parseError('unexpected-end-tag', {name: name});
} }
}; };
@@ -5825,6 +5875,7 @@ function TreeBuilder() {
modes.inColumnGroup.endTagColgroup = function(name) { modes.inColumnGroup.endTagColgroup = function(name) {
if (this.ignoreEndTagColgroup()) { if (this.ignoreEndTagColgroup()) {
assert.ok(tree.context); assert.ok(tree.context);
tree.parseError('unexpected-end-tag', {name: name}); tree.parseError('unexpected-end-tag', {name: name});
} else { } else {
@@ -5895,6 +5946,7 @@ function TreeBuilder() {
modes.inForeignContent.processCharacters = function(buffer) { modes.inForeignContent.processCharacters = function(buffer) {
var characters = buffer.takeRemaining(); var characters = buffer.takeRemaining();
characters = characters.replace(/\u0000/g, function(match, index){ characters = characters.replace(/\u0000/g, function(match, index){
tree.parseError('invalid-codepoint'); tree.parseError('invalid-codepoint');
return '\uFFFD'; return '\uFFFD';
}); });
@@ -5930,6 +5982,7 @@ function TreeBuilder() {
tree.insertText(leadingWhitespace); tree.insertText(leadingWhitespace);
if (!buffer.length) if (!buffer.length)
return; return;
tree.parseError("unexpected-char-in-frameset"); tree.parseError("unexpected-char-in-frameset");
this.anythingElse(); this.anythingElse();
tree.insertionMode.processCharacters(buffer); tree.insertionMode.processCharacters(buffer);
@@ -5944,16 +5997,19 @@ function TreeBuilder() {
}; };
modes.inHeadNoscript.startTagHeadNoscript = function(name, attributes) { modes.inHeadNoscript.startTagHeadNoscript = function(name, attributes) {
tree.parseError("unexpected-start-tag-in-frameset", {name: name}); tree.parseError("unexpected-start-tag-in-frameset", {name: name});
}; };
modes.inHeadNoscript.startTagOther = function(name, attributes) { modes.inHeadNoscript.startTagOther = function(name, attributes) {
tree.parseError("unexpected-start-tag-in-frameset", {name: name}); tree.parseError("unexpected-start-tag-in-frameset", {name: name});
this.anythingElse(); this.anythingElse();
tree.insertionMode.processStartTag(name, attributes); tree.insertionMode.processStartTag(name, attributes);
}; };
modes.inHeadNoscript.endTagBr = function(name, attributes) { modes.inHeadNoscript.endTagBr = function(name, attributes) {
tree.parseError("unexpected-end-tag-in-frameset", {name: name}); tree.parseError("unexpected-end-tag-in-frameset", {name: name});
this.anythingElse(); this.anythingElse();
tree.insertionMode.processEndTag(name, attributes); tree.insertionMode.processEndTag(name, attributes);
@@ -5965,6 +6021,7 @@ function TreeBuilder() {
}; };
modes.inHeadNoscript.endTagOther = function(name, attributes) { modes.inHeadNoscript.endTagOther = function(name, attributes) {
tree.parseError("unexpected-end-tag-in-frameset", {name: name}); tree.parseError("unexpected-end-tag-in-frameset", {name: name});
}; };
@@ -6012,12 +6069,14 @@ function TreeBuilder() {
modes.inFrameset.endTagFrameset = function(name, attributes) { modes.inFrameset.endTagFrameset = function(name, attributes) {
if (tree.currentStackItem().localName == 'html') { if (tree.currentStackItem().localName == 'html') {
tree.parseError("unexpected-frameset-in-frameset-innerhtml"); tree.parseError("unexpected-frameset-in-frameset-innerhtml");
} else { } else {
tree.popElement(); tree.popElement();
} }
if (!tree.context && tree.currentStackItem().localName != 'frameset') { if (!tree.context && tree.currentStackItem().localName != 'frameset') {
tree.setInsertionMode('afterFrameset'); tree.setInsertionMode('afterFrameset');
} }
}; };
@@ -6126,6 +6185,7 @@ function TreeBuilder() {
if (attributes[key].nodeValue.toLowerCase() == 'hidden') { if (attributes[key].nodeValue.toLowerCase() == 'hidden') {
tree.parseError("unexpected-hidden-input-in-table"); tree.parseError("unexpected-hidden-input-in-table");
tree.insertElement(name, attributes); tree.insertElement(name, attributes);
tree.openElements.pop(); tree.openElements.pop();
return; return;
} }
@@ -6172,7 +6232,9 @@ function TreeBuilder() {
modes.inTable.endTagOther = function(name) { modes.inTable.endTagOther = function(name) {
tree.parseError("unexpected-end-tag-implies-table-voodoo", {name: name}); tree.parseError("unexpected-end-tag-implies-table-voodoo", {name: name});
tree.redirectAttachToFosterParent = true; tree.redirectAttachToFosterParent = true;
modes.inBody.processEndTag(name); modes.inBody.processEndTag(name);
tree.redirectAttachToFosterParent = false; tree.redirectAttachToFosterParent = false;
}; };
@@ -6208,6 +6270,7 @@ function TreeBuilder() {
modes.inTableText.processCharacters = function(buffer) { modes.inTableText.processCharacters = function(buffer) {
var characters = buffer.takeRemaining(); var characters = buffer.takeRemaining();
characters = characters.replace(/\u0000/g, function(match, index){ characters = characters.replace(/\u0000/g, function(match, index){
tree.parseError("invalid-codepoint"); tree.parseError("invalid-codepoint");
return ''; return '';
}); });
@@ -6277,11 +6340,13 @@ function TreeBuilder() {
}; };
modes.inTableBody.startTagTableOther = function(name, attributes) { modes.inTableBody.startTagTableOther = function(name, attributes) {
if (tree.openElements.inTableScope('tbody') || tree.openElements.inTableScope('thead') || tree.openElements.inTableScope('tfoot')) { if (tree.openElements.inTableScope('tbody') || tree.openElements.inTableScope('thead') || tree.openElements.inTableScope('tfoot')) {
tree.openElements.popUntilTableBodyScopeMarker(); tree.openElements.popUntilTableBodyScopeMarker();
this.endTagTableRowGroup(tree.currentStackItem().localName); this.endTagTableRowGroup(tree.currentStackItem().localName);
tree.insertionMode.processStartTag(name, attributes); tree.insertionMode.processStartTag(name, attributes);
} else { } else {
tree.parseError('unexpected-start-tag', {name: name}); tree.parseError('unexpected-start-tag', {name: name});
} }
}; };
@@ -6306,6 +6371,7 @@ function TreeBuilder() {
this.endTagTableRowGroup(tree.currentStackItem().localName); this.endTagTableRowGroup(tree.currentStackItem().localName);
tree.insertionMode.processEndTag(name); tree.insertionMode.processEndTag(name);
} else { } else {
tree.parseError('unexpected-end-tag', {name: name}); tree.parseError('unexpected-end-tag', {name: name});
} }
}; };
@@ -6350,6 +6416,7 @@ function TreeBuilder() {
modes.inSelect.processCharacters = function(buffer) { modes.inSelect.processCharacters = function(buffer) {
var data = buffer.takeRemaining(); var data = buffer.takeRemaining();
data = data.replace(/\u0000/g, function(match, index){ data = data.replace(/\u0000/g, function(match, index){
tree.parseError("invalid-codepoint"); tree.parseError("invalid-codepoint");
return ''; return '';
}); });
@@ -6359,6 +6426,7 @@ function TreeBuilder() {
}; };
modes.inSelect.startTagOption = function(name, attributes) { modes.inSelect.startTagOption = function(name, attributes) {
if (tree.currentStackItem().localName == 'option') if (tree.currentStackItem().localName == 'option')
tree.popElement(); tree.popElement();
tree.insertElement(name, attributes); tree.insertElement(name, attributes);
@@ -6381,12 +6449,15 @@ function TreeBuilder() {
}; };
modes.inSelect.endTagOptgroup = function(name) { modes.inSelect.endTagOptgroup = function(name) {
if (tree.currentStackItem().localName == 'option' && tree.openElements.item(tree.openElements.length - 2).localName == 'optgroup') { if (tree.currentStackItem().localName == 'option' && tree.openElements.item(tree.openElements.length - 2).localName == 'optgroup') {
tree.popElement(); tree.popElement();
} }
if (tree.currentStackItem().localName == 'optgroup') { if (tree.currentStackItem().localName == 'optgroup') {
tree.popElement(); tree.popElement();
} else { } else {
tree.parseError('unexpected-end-tag-in-select', {name: 'optgroup'}); tree.parseError('unexpected-end-tag-in-select', {name: 'optgroup'});
} }
}; };
@@ -6401,6 +6472,7 @@ function TreeBuilder() {
tree.openElements.popUntilPopped('select'); tree.openElements.popUntilPopped('select');
tree.resetInsertionMode(); tree.resetInsertionMode();
} else { } else {
tree.parseError('unexpected-end-tag', {name: name}); tree.parseError('unexpected-end-tag', {name: name});
} }
}; };
@@ -6531,6 +6603,7 @@ function TreeBuilder() {
modes.inRow.startTagTableOther = function(name, attributes) { modes.inRow.startTagTableOther = function(name, attributes) {
var ignoreEndTag = this.ignoreEndTagTr(); var ignoreEndTag = this.ignoreEndTagTr();
this.endTagTr('tr'); this.endTagTr('tr');
if (!ignoreEndTag) tree.insertionMode.processStartTag(name, attributes); if (!ignoreEndTag) tree.insertionMode.processStartTag(name, attributes);
}; };
@@ -6552,6 +6625,8 @@ function TreeBuilder() {
modes.inRow.endTagTable = function(name) { modes.inRow.endTagTable = function(name) {
var ignoreEndTag = this.ignoreEndTagTr(); var ignoreEndTag = this.ignoreEndTagTr();
this.endTagTr('tr'); this.endTagTr('tr');
if (!ignoreEndTag) tree.insertionMode.processEndTag(name); if (!ignoreEndTag) tree.insertionMode.processEndTag(name);
}; };
@@ -6560,6 +6635,7 @@ function TreeBuilder() {
this.endTagTr('tr'); this.endTagTr('tr');
tree.insertionMode.processEndTag(name); tree.insertionMode.processEndTag(name);
} else { } else {
tree.parseError('unexpected-end-tag', {name: name}); tree.parseError('unexpected-end-tag', {name: name});
} }
}; };
@@ -6680,6 +6756,7 @@ TreeBuilder.prototype.adoptionAgencyEndTag = function(name) {
var outerLoopCounter = 0; var outerLoopCounter = 0;
while (outerLoopCounter++ < outerIterationLimit) { while (outerLoopCounter++ < outerIterationLimit) {
formattingElement = this.elementInActiveFormattingElements(name); formattingElement = this.elementInActiveFormattingElements(name);
if (!formattingElement || (this.openElements.contains(formattingElement) && !this.openElements.inScope(formattingElement.localName))) { if (!formattingElement || (this.openElements.contains(formattingElement) && !this.openElements.inScope(formattingElement.localName))) {
@@ -6698,6 +6775,8 @@ TreeBuilder.prototype.adoptionAgencyEndTag = function(name) {
if (formattingElement != this.currentStackItem()) { if (formattingElement != this.currentStackItem()) {
this.parseError('adoption-agency-1.3', {name: name}); this.parseError('adoption-agency-1.3', {name: name});
} }
var furthestBlock = this.openElements.furthestBlockForFormattingElement(formattingElement.node); var furthestBlock = this.openElements.furthestBlockForFormattingElement(formattingElement.node);
if (!furthestBlock) { if (!furthestBlock) {
@@ -6802,6 +6881,7 @@ TreeBuilder.prototype.startTokenization = function(tokenizer) {
} }
this.insertHtmlElement(); this.insertHtmlElement();
this.resetInsertionMode(); this.resetInsertionMode();
} else { } else {
this.setInsertionMode('initial'); this.setInsertionMode('initial');
} }
@@ -6959,6 +7039,7 @@ TreeBuilder.prototype.shouldFosterParent = function() {
return this.redirectAttachToFosterParent && this.currentStackItem().isFosterParenting(); return this.redirectAttachToFosterParent && this.currentStackItem().isFosterParenting();
}; };
TreeBuilder.prototype.generateImpliedEndTags = function(exclude) { TreeBuilder.prototype.generateImpliedEndTags = function(exclude) {
var name = this.openElements.top.localName; var name = this.openElements.top.localName;
if (['dd', 'dt', 'li', 'option', 'optgroup', 'p', 'rp', 'rt'].indexOf(name) != -1 && name != exclude) { if (['dd', 'dt', 'li', 'option', 'optgroup', 'p', 'rp', 'rt'].indexOf(name) != -1 && name != exclude) {
this.popElement(); this.popElement();
@@ -6966,8 +7047,13 @@ TreeBuilder.prototype.generateImpliedEndTags = function(exclude) {
} }
}; };
TreeBuilder.prototype.reconstructActiveFormattingElements = function() { TreeBuilder.prototype.reconstructActiveFormattingElements = function() {
if (this.activeFormattingElements.length === 0) if (this.activeFormattingElements.length === 0)
return; return;
var i = this.activeFormattingElements.length - 1; var i = this.activeFormattingElements.length - 1;
var entry = this.activeFormattingElements[i]; var entry = this.activeFormattingElements[i];
if (entry == Marker || this.openElements.contains(entry)) if (entry == Marker || this.openElements.contains(entry))
@@ -7026,6 +7112,9 @@ TreeBuilder.prototype.ensureNoahsArkCondition = function(item) {
candidates = remainingCandidates; candidates = remainingCandidates;
remainingCandidates = []; remainingCandidates = [];
} }
for (var i = kNoahsArkCapacity - 1; i < candidates.length; i++) for (var i = kNoahsArkCapacity - 1; i < candidates.length; i++)
this.removeElementFromActiveFormattingElements(candidates[i]); this.removeElementFromActiveFormattingElements(candidates[i]);
}; };
@@ -7056,9 +7145,15 @@ TreeBuilder.prototype.reparentChildren = function(oldParent, newParent) {
throw new Error("Not implemented"); throw new Error("Not implemented");
}; };
TreeBuilder.prototype.setFragmentContext = function(context) { TreeBuilder.prototype.setFragmentContext = function(context) {
this.context = context; this.context = context;
}; };
TreeBuilder.prototype.parseError = function(code, args) { TreeBuilder.prototype.parseError = function(code, args) {
if (!this.errorHandler) if (!this.errorHandler)
return; return;
var message = formatMessage(messages[code], args); var message = formatMessage(messages[code], args);
@@ -7076,7 +7171,9 @@ TreeBuilder.prototype.resetInsertionMode = function() {
} }
if (node.namespaceURI === "http://www.w3.org/1999/xhtml") { if (node.namespaceURI === "http://www.w3.org/1999/xhtml") {
if (node.localName === 'select') if (node.localName === 'select')
return this.setInsertionMode('inSelect'); return this.setInsertionMode('inSelect');
if (node.localName === 'td' || node.localName === 'th') if (node.localName === 'td' || node.localName === 'th')
return this.setInsertionMode('inCell'); return this.setInsertionMode('inCell');
@@ -7712,16 +7809,27 @@ SAXTreeBuilder.prototype.addAttributesToElement = function(element, attributes)
}; };
var NodeType = { var NodeType = {
CDATA: 1, CDATA: 1,
CHARACTERS: 2, CHARACTERS: 2,
COMMENT: 3, COMMENT: 3,
DOCUMENT: 4, DOCUMENT: 4,
DOCUMENT_FRAGMENT: 5, DOCUMENT_FRAGMENT: 5,
DTD: 6, DTD: 6,
ELEMENT: 7, ELEMENT: 7,
ENTITY: 8, ENTITY: 8,
IGNORABLE_WHITESPACE: 9, IGNORABLE_WHITESPACE: 9,
PROCESSING_INSTRUCTION: 10, PROCESSING_INSTRUCTION: 10,
SKIPPED_ENTITY: 11 SKIPPED_ENTITY: 11
}; };
function Node(locator) { function Node(locator) {
@@ -7736,12 +7844,16 @@ function Node(locator) {
this.nextSibling = null; this.nextSibling = null;
this.firstChild = null; this.firstChild = null;
} }
Node.prototype.visit = function(treeParser) { Node.prototype.visit = function(treeParser) {
throw new Error("Not Implemented"); throw new Error("Not Implemented");
}; };
Node.prototype.revisit = function(treeParser) { Node.prototype.revisit = function(treeParser) {
return; return;
}; };
Node.prototype.detach = function() { Node.prototype.detach = function() {
if (this.parentNode !== null) { if (this.parentNode !== null) {
this.parentNode.removeChild(this); this.parentNode.removeChild(this);
@@ -7772,6 +7884,7 @@ function ParentNode(locator) {
ParentNode.prototype = Object.create(Node.prototype); ParentNode.prototype = Object.create(Node.prototype);
ParentNode.prototype.insertBefore = function(child, sibling) { ParentNode.prototype.insertBefore = function(child, sibling) {
if (!sibling) { if (!sibling) {
return this.appendChild(child); return this.appendChild(child);
} }
@@ -7794,6 +7907,11 @@ ParentNode.prototype.insertBefore = function(child, sibling) {
}; };
ParentNode.prototype.insertBetween = function(child, prev, next) { ParentNode.prototype.insertBetween = function(child, prev, next) {
if (!next) { if (!next) {
return this.appendChild(child); return this.appendChild(child);
} }
@@ -7837,6 +7955,7 @@ ParentNode.prototype.appendChildren = function(parent) {
another.lastChild = null; another.lastChild = null;
}; };
ParentNode.prototype.removeChild = function(node) { ParentNode.prototype.removeChild = function(node) {
if (this.firstChild == node) { if (this.firstChild == node) {
this.firstChild = node.nextSibling; this.firstChild = node.nextSibling;
if (this.lastChild == node) { if (this.lastChild == node) {
@@ -7881,6 +8000,7 @@ Document.prototype.visit = function(treeParser) {
Document.prototype.revisit = function(treeParser) { Document.prototype.revisit = function(treeParser) {
treeParser.endDocument(this.endLocator); treeParser.endDocument(this.endLocator);
}; };
function DocumentFragment() { function DocumentFragment() {
ParentNode.call(this, new Locator()); ParentNode.call(this, new Locator());
this.nodeType = NodeType.DOCUMENT_FRAGMENT; this.nodeType = NodeType.DOCUMENT_FRAGMENT;
@@ -7888,6 +8008,7 @@ function DocumentFragment() {
DocumentFragment.prototype = Object.create(ParentNode.prototype); DocumentFragment.prototype = Object.create(ParentNode.prototype);
DocumentFragment.prototype.visit = function(treeParser) { DocumentFragment.prototype.visit = function(treeParser) {
}; };
function Element(locator, uri, localName, qName, atts, prefixMappings) { function Element(locator, uri, localName, qName, atts, prefixMappings) {
ParentNode.call(this, locator); ParentNode.call(this, locator);
@@ -7939,6 +8060,7 @@ IgnorableWhitespace.prototype = Object.create(Node.prototype);
IgnorableWhitespace.prototype.visit = function(treeParser) { IgnorableWhitespace.prototype.visit = function(treeParser) {
treeParser.ignorableWhitespace(this.data, 0, this.data.length, this); treeParser.ignorableWhitespace(this.data, 0, this.data.length, this);
}; };
function Comment(locator, data) { function Comment(locator, data) {
Node.call(this, locator); Node.call(this, locator);
this.data = data; this.data = data;
@@ -7949,6 +8071,7 @@ Comment.prototype = Object.create(Node.prototype);
Comment.prototype.visit = function(treeParser) { Comment.prototype.visit = function(treeParser) {
treeParser.comment(this.data, 0, this.data.length, this); treeParser.comment(this.data, 0, this.data.length, this);
}; };
function CDATA(locator) { function CDATA(locator) {
ParentNode.call(this, locator); ParentNode.call(this, locator);
this.nodeType = NodeType.CDATA; this.nodeType = NodeType.CDATA;
@@ -7961,6 +8084,7 @@ CDATA.prototype.visit = function(treeParser) {
CDATA.prototype.revisit = function(treeParser) { CDATA.prototype.revisit = function(treeParser) {
treeParser.endCDATA(this.endLocator); treeParser.endCDATA(this.endLocator);
}; };
function Entity(name) { function Entity(name) {
ParentNode.call(this); ParentNode.call(this);
this.name = name; this.name = name;
@@ -7975,6 +8099,7 @@ Entity.prototype.revisit = function(treeParser) {
treeParser.endEntity(this.name); treeParser.endEntity(this.name);
}; };
function SkippedEntity(name) { function SkippedEntity(name) {
Node.call(this); Node.call(this);
this.name = name; this.name = name;
@@ -7985,6 +8110,11 @@ SkippedEntity.prototype = Object.create(Node.prototype);
SkippedEntity.prototype.visit = function(treeParser) { SkippedEntity.prototype.visit = function(treeParser) {
treeParser.skippedEntity(this.name, this); treeParser.skippedEntity(this.name, this);
}; };
function ProcessingInstruction(target, data) { function ProcessingInstruction(target, data) {
Node.call(this); Node.call(this);
this.target = target; this.target = target;
@@ -8019,7 +8149,9 @@ exports.SAXTreeBuilder = SAXTreeBuilder;
}, },
{"../TreeBuilder":6,"util":20}], {"../TreeBuilder":6,"util":20}],
11:[function(_dereq_,module,exports){ 11:[function(_dereq_,module,exports){
function TreeParser(contentHandler, lexicalHandler){ function TreeParser(contentHandler, lexicalHandler){
this.contentHandler; this.contentHandler;
this.lexicalHandler; this.lexicalHandler;
this.locatorDelegate; this.locatorDelegate;
@@ -8034,6 +8166,7 @@ function TreeParser(contentHandler, lexicalHandler){
this.lexicalHandler = lexicalHandler; this.lexicalHandler = lexicalHandler;
} }
} }
TreeParser.prototype.parse = function(node) { TreeParser.prototype.parse = function(node) {
this.contentHandler.documentLocator = this; this.contentHandler.documentLocator = this;
var current = node; var current = node;
@@ -8143,6 +8276,7 @@ Object.defineProperty(TreeParser.prototype, 'lineNumber', {
return this.locatorDelegate.lineNumber; return this.locatorDelegate.lineNumber;
} }
}); });
function NullLexicalHandler() { function NullLexicalHandler() {
} }

File diff suppressed because one or more lines are too long