 
   # ===== Private methods (never call from outside the module) =======
 
-  # There is some weird, bogus behaviour in Chrome,
-  # triggered by whitespaces between the table tag and it's children.
-  # See the select-tbody-problem described here:
-  #    https://github.com/hypothesis/h/issues/280
-  # And the WebKit bug report here:
-  #    https://bugs.webkit.org/show_bug.cgi?id=110595
-  # 
-  # To work around this, we have to do two things.
-  # 
-  # 1. We remove all the text elements created from those whitespaces.
-  # (Text elements are not allowed to be children of the table tag, anyway.)
-  # That fixes the problem with selecting the whole table, when trying te select
-  #  an empty text element.
-  #
-  # The second part of the trick is implemented in the selectNode method.
- 
-  purgeDebris: ->
-    @debris = []
-    @collectDebris @pathStartNode
-    console.log "Dropping " + @debris.length + " debris elements."
-    for node in @debris
-#      console.log "Dropping debris text element: " + @getPathTo node
-      node.remove()
-
-  # Go through this sub-tree, and collect all immadiate tech children of the tables
-  collectDebris: (node) ->
-    # If this node has no children, don't bother
-    unless node.hasChildNodes() then return
-
-    # Check if this is a table
-    inTable = node.nodeType is Node.ELEMENT_NODE and node.tagName.toLowerCase() is "table"
-
-    # Go through all the children
-    for child in node.childNodes
-      if inTable and child.nodeType is Node.TEXT_NODE
-        # Found a text that should be dropped
-        @debris.push child
-      else
-        # Do this to the child, recursively
-        @collectDebris child
-
   timestamp: -> new Date().getTime()
 
   stringStartsWith: (string, prefix) -> prefix is string.substr 0, prefix.length

class window.DomTextMapper

  USE_TH_TBODY_WORKAROUND = true

  constructor: ->
    @setRealRoot()

#      console.log mappings

    mappings

  getContentForPath: (path = null) -> 
    path ?= @getDefaultPath()       
    @allPaths[path].content

  getLengthForPath: (path = null) ->
    path ?= @getDefaultPath()
    @allPaths[path].length

  getContentForRange: (start, end, path = null) ->
    @getContentForPath(path).substr start, end - start

  # Get the context that encompasses the given text range
  getContextForRange: (start, end) ->
    content = @getContentForPath()
    prefixStart = Math.max 0, start - CONTEXT_LEN
    prefixLen = start - prefixStart
    prefix = content.substr prefixStart, prefixLen
    suffix = content.substr end, prefixLen
    [prefix, suffix]
        

  # Get the matching DOM elements for a given text range
  # 
