utils/contentcollector: use jshint

This commit is contained in:
booo 2011-12-22 13:34:16 +01:00
parent 554ed186e9
commit 6985b93013

View file

@ -173,7 +173,7 @@ function makeContentCollector(collectStyles, browser, apool, domInterface, class
function _isEmpty(node, state)
{
// consider clean blank lines pasted in IE to be empty
if (dom.nodeNumChildren(node) == 0) return true;
if (dom.nodeNumChildren(node) === 0) return true;
if (dom.nodeNumChildren(node) == 1 && getAssoc(node, "shouldBeEmpty") && dom.optNodeInnerHTML(node) == " " && !getAssoc(node, "unpasted"))
{
if (state)
@ -191,7 +191,7 @@ function makeContentCollector(collectStyles, browser, apool, domInterface, class
{
var ln = lines.length() - 1;
var chr = lines.textOfLine(ln).length;
if (chr == 0 && state.listType && state.listType != 'none')
if (chr === 0 && state.listType && state.listType != 'none')
{
chr += 1; // listMarker
}
@ -218,11 +218,11 @@ function makeContentCollector(collectStyles, browser, apool, domInterface, class
cc.incrementFlag = function(state, flagName)
{
state.flags[flagName] = (state.flags[flagName] || 0) + 1;
}
};
cc.decrementFlag = function(state, flagName)
{
state.flags[flagName]--;
}
};
cc.incrementAttrib = function(state, attribName)
{
if (!state.attribs[attribName])
@ -234,12 +234,12 @@ function makeContentCollector(collectStyles, browser, apool, domInterface, class
state.attribs[attribName]++;
}
_recalcAttribString(state);
}
};
cc.decrementAttrib = function(state, attribName)
{
state.attribs[attribName]--;
_recalcAttribString(state);
}
};
function _enterList(state, listType)
{
@ -315,14 +315,14 @@ function makeContentCollector(collectStyles, browser, apool, domInterface, class
{
if (state)
{
var atBeginningOfLine = lines.textOfLine(lines.length() - 1).length == 0;
var atBeginningOfLine = lines.textOfLine(lines.length() - 1).length === 0;
if (atBeginningOfLine && state.listType && state.listType != 'none')
{
_produceListMarker(state);
}
}
lines.startNew();
}
};
cc.notifySelection = function(sel)
{
if (sel)
@ -363,7 +363,7 @@ function makeContentCollector(collectStyles, browser, apool, domInterface, class
var txt = dom.nodeValue(node);
var rest = '';
var x = 0; // offset into original text
if (txt.length == 0)
if (txt.length === 0)
{
if (startPoint && node == startPoint.node)
{
@ -404,7 +404,7 @@ function makeContentCollector(collectStyles, browser, apool, domInterface, class
// removing "\n" from pasted HTML will collapse words together.
txt2 = "";
}
var atBeginningOfLine = lines.textOfLine(lines.length() - 1).length == 0;
var atBeginningOfLine = lines.textOfLine(lines.length() - 1).length === 0;
if (atBeginningOfLine)
{
// newlines in the source mustn't become spaces at beginning of line box
@ -472,9 +472,9 @@ function makeContentCollector(collectStyles, browser, apool, domInterface, class
{
cc.doAttrib(state, "strikethrough");
}
var type;
if (tname == "ul")
{
var type;
var rr = cls && /(?:^| )list-(bullet[12345678])\b/.exec(cls);
type = rr && rr[1] || "bullet" + String(Math.min(_MAX_LIST_LEVEL, (state.listNesting || 0) + 1));
oldListTypeOrNull = (_enterList(state, type) || 'none');
@ -612,6 +612,30 @@ function makeContentCollector(collectStyles, browser, apool, domInterface, class
var buffer = 10; // chars allowed over before wrapping
var linesWrapped = 0;
var numLinesAfter = 0;
var fixLineNumber = function fixLineNumber(lineChar)
{
if (lineChar[0] < 0) return;
var n = lineChar[0];
var c = lineChar[1];
if (n > i)
{
n += (newStrings.length - 1);
}
else if (n == i)
{
var a = 0;
while (c > newStrings[a].length)
{
c -= newStrings[a].length;
a++;
}
n += a;
}
lineChar[0] = n;
lineChar[1] = c;
};
for (var i = lineStrings.length - 1; i >= 0; i--)
{
var oldString = lineStrings[i];
@ -620,6 +644,8 @@ function makeContentCollector(collectStyles, browser, apool, domInterface, class
{
var newStrings = [];
var newAttribStrings = [];
while (oldString.length > lineLimit)
{
//var semiloc = oldString.lastIndexOf(';', lineLimit-1);
@ -636,28 +662,6 @@ function makeContentCollector(collectStyles, browser, apool, domInterface, class
newAttribStrings.push(oldAttribString);
}
function fixLineNumber(lineChar)
{
if (lineChar[0] < 0) return;
var n = lineChar[0];
var c = lineChar[1];
if (n > i)
{
n += (newStrings.length - 1);
}
else if (n == i)
{
var a = 0;
while (c > newStrings[a].length)
{
c -= newStrings[a].length;
a++;
}
n += a;
}
lineChar[0] = n;
lineChar[1] = c;
}
fixLineNumber(ss);
fixLineNumber(se);
linesWrapped++;
@ -684,7 +688,7 @@ function makeContentCollector(collectStyles, browser, apool, domInterface, class
lines: lineStrings,
lineAttribs: lineAttribs
};
}
};
return cc;
}