Bug 53287: More robust in-table state tracking in the paragraph wrapper

From the bug report:

Unbalanced table tokens in pages like http://fi.wikipedia.org/wiki/Kypros throw
off the in-table tracking in the paragraph wrapper. This causes newlines in
fosterable position to be paragraph-wrapped, which is then fostered out.

Broken behavior:

echo -ne '{|\n<td><td>fo</td>\n\n\n\n|}' | node parse
WARNING: DSR inconsistency: cs/s mismatch for node: BODY s: 0; cs: -1
<body><p data-parsoid='{"autoInsertedEnd":true,"dsr":[-1,-1,0,0]}'><br
data-parsoid='{"dsr":[-1,-1,0,0]}'></p>
<table data-parsoid='{"dsr":[0,24,2,2]}'>
<tbody data-parsoid='{"dsr":[3,22,0,0]}'><tr
data-parsoid='{"dsr":[3,19,0,0]}'><td
data-parsoid='{"stx":"html","autoInsertedEnd":true,"dsr":[3,7,4,0]}'></td><td
data-parsoid='{"stx":"html","dsr":[7,18,4,5]}'>fo</td></tr>

</tbody></table></body>

Correct behavior:

echo -ne '{|\n<td><td>fo</td>\n\n\n\n|}' | node parse
<body data-parsoid='{"dsr":[0,24,0,0]}'><table
data-parsoid='{"dsr":[0,24,2,2]}'>
<tbody data-parsoid='{"dsr":[3,22,0,0]}'><tr
data-parsoid='{"autoInsertedEnd":true,"dsr":[3,18,0,0]}'><td
data-parsoid='{"stx":"html","autoInsertedEnd":true,"dsr":[3,7,4,0]}'></td><td
data-parsoid='{"stx":"html","dsr":[7,18,4,5]}'>fo</td></tr>

</tbody></table></body>

Change-Id: I4c607885ad52be3f39a1f72eb5ead9239e014820
Merge "Bug 53287: More robust in-table state tracking in the paragraph wrapper"