Fix bugs in and clean up handleUnbalancedTableTags DOM post-pass.

* handleUnbalancedTableTags was buggy -- it wasn't keeping track
  of open templates properly while walking the DOM.  Plus, it was
  keeping track of all tpls encountered which wasn't being used
  anymore.

* Fixed bugs, cleaned up code and improved documentation in the
  process.

* No change in parser tests.

* Eliminates sole RT failure in en:First-degree burn.

* The problem snippet is below:
-------------------------
[[Image:Foo.jpg|thumb|This is a caption.
{{Multicol}}
{{legend|#b3b3b3|no data}}
{{legend|#ffff65|<&nbsp;50}}
{{legend|#fff200|50-100}}
{{legend|#ffdc00|100-150}}
{{legend|#ffc600|150-200}}
{{legend|#ffb000|200-250}}
{{legend|#ff9a00|250-300}}
{{Multicol-break}}
{{legend|#ff8400|300-350}}
{{legend|#ff6e00|350-400}}
{{legend|#ff5800|400-450}}
{{legend|#ff4200|450-500}}
{{legend|#ff2c00|500-600}}
{{legend|#cb0000|>&nbsp;600}}
{{Multicol-end}}
]]
-------------------------

* In this page, the RT failure was in a multi-col table found in
  an image caption.  The table constructed by multi-col and legend
  templates (over 10 tpl transclusions) had some unbalanced
  td and other tags internally which would have normally been
  balanced out by the tree-builder.  This table in the caption
  exposed three independent problems -- fixing any of the three
  would have fixed the RTing of this template.  The RT-ing of
  this snippet failed because of all 3 bugs getting triggered at
  the same time.  Discussion below.

  1. Since this particular use showed up in an image caption
     context and had unbalanced tags, it tripped up the image
     caption partial-dom-building code which artifically added
     an excess closing table tag in an attempt to keep the caption
     a fully-balanced DOM.  Of course, the tree-builder throws
     this out, and so, despite the image caption code's boondoggle,
     the final DOM is unproblematic.

  2. But, the stray table-end-tag-meta-marker triggers the
     handledUnbalancedTableTags DOM post-pass and exposed bugs
     there -- it was incorrectly identifying a problem template
     where there was none to be found.  This commit fixes this
     particular problem.

  3. This also uncovered an unrelated DSR fix that can be made in
     DSR code when handling DSR on meta-tags during RTL propagation.
     dsr[1] on a meta-end-tag is not being set which then tripped
     up the template encapsulation code -- wont describe the problem
     in more detail here, but will make a fix in another patch.

Change-Id: Id126d66f6937d64dc9bc6d94e6292cac2d833148