1. 26 Nov, 2021 4 commits
    • Robert Knight's avatar
      Treat new lines rather than spaces as line separators in tests · d5f4c295
      Robert Knight authored
      Mapping each line in the text data in the test to a line in the
      generated bounding boxes is more natural and also lets us test multiple
      words on a single line.
      d5f4c295
    • Robert Knight's avatar
      Use fractions instead of percentages for metrics · df5ae027
      Robert Knight authored
      Use fractions instead of percentages for the character and line metrics
      in ImageTextLayer tests, for consistency with the ImageTextLayer API.
      df5ae027
    • Robert Knight's avatar
      Support fixed layout / PDF-based books in VitalSource integration · 4b2dc699
      Robert Knight authored
      Support VitalSource books which are created from PDFs rather than EPUBs.
      These books have the same frame structure as EPUBs, but use one HTML
      page per PDF page in the inner frame, rather than one HTML page per
      chapter as is more common for EPUBs.
      
      VS PDFs do not contain a selectable text layer. Instead they consist of
      a high-resolution rendered image of the current page plus data about the
      content and location of text characters embedded in a script tag in the
      page which sets a `window.innerPageData` variable.
      
      To support this in Hypothesis, we generate a hidden text layer from the
      `innerPageData` data and overlay it on top of the rendered image. This
      hidden text layer is similar to what PDF.js creates for us in our
      standard PDF viewer.
      4b2dc699
    • Robert Knight's avatar
      Add ImageTextLayer class · 41db2a37
      Robert Knight authored
      Implement a class that creates a transparent text layer on top of an
      image containing text. This is useful for supporting annotation in
      documents which are rendered images or canvases that don't have
      browser-accessible text in them, such as VitalSource.
      
      It is the caller's responsibility to determine the location and
      character value of text in the image.
      41db2a37
  2. 25 Nov, 2021 9 commits
  3. 24 Nov, 2021 3 commits
    • Robert Knight's avatar
      Revise `PortProvider._channels` data structure · 82541f3a
      Robert Knight authored
      The `PortProvider._channels` map was used only to keep track of which
      channel requests have been handled for a particular frame. The
      `WeakMap<Window, MessageChannel>` was in fact used as a set rather than
      a map. Only the presence of entries affected behavior, not the stored
      MessageChannel values.
      
      Change the data structure and comments to make its purpose clearer.
      82541f3a
    • Robert Knight's avatar
      Remove a misplaced comment · 20567b07
      Robert Knight authored
      This comment provides general information about how MessagePorts work,
      but isn't directly related to any of the surrounding code.
      
      Of the two comments here, the second one is the most useful information
      to consumers of the PortProvider and PortFinder interfaces, but it is
      well covered by eg. MDN's documentation on MessagePort.
      20567b07
    • Robert Knight's avatar
      Streamline code for responding to port requests · 625bdb9d
      Robert Knight authored
      Rework the code to make the code path for the sidebar-host channel more
      similar to other channels. As a result the `_sendPorts` helper was only
      called in one place and can be inlined where it is called to make the
      overall logic easier to follow.
      625bdb9d
  4. 23 Nov, 2021 16 commits
  5. 22 Nov, 2021 7 commits
  6. 19 Nov, 2021 1 commit
    • Eduardo Sanz García's avatar
      Use `WeakMap` to store `MessageChannel` · 0c0a639b
      Eduardo Sanz García authored
      We use `Window` objects as keys on a map. Windows can be removed.
      `WeakMap` has the characteristic that keys that are claimed by the
      garbage collector are removed from the map. In this way, we are memory
      friendly and don't retain any defunct object.
      0c0a639b