1. 02 Mar, 2022 1 commit
    • Robert Knight's avatar
      Preserve scroll position when toggling sidebar in VitalSource PDFs · c1abf185
      Robert Knight authored
      Use the `preserveScrollPosition` utility that was created for HTML / EPUB
      side-by-side mode to preserve scroll position when side-by-side mode is toggled
      in VitalSource PDFs.
      
       - Add a way to synchronously update the hidden text layer in VS PDFs
      
       - Wrap image size updates in VS PDFs in `preserveScrollPosition`
      c1abf185
  2. 01 Mar, 2022 5 commits
    • Robert Knight's avatar
      Limit VitalSource iframe height in PDFs · bfe0e9a7
      Robert Knight authored
      VitalSource PDF books currently create very tall iframes. When a user
      scrolls through a PDF page, they are scrolling the _parent_ frame rather
      than the iframe itself. The bucket bar and scrolling logic in the client
      don't support this. The result is that:
      
       - Bucket bar buckets are in the wrong location and don't scroll as the
         user scrolls the parent frame
       - Clicking on an annotation / bucket tries to scroll only the iframe,
         not the parent frame.
      
      To resolve this we need to do at least one of:
      
      1. Support these tall iframes in the client generally
      2. Forcibly change the height of the iframe and enable the iframe to scroll
      3. Persuade VitalSource to change the iframe layout so that the content frame
         scrolls, rather than the parent frame. They previously did this for EPUBs
         already.
      
      This commit implements a version of (2). If VS later apply (3) then we can
      remove this workaround.
      bfe0e9a7
    • Robert Knight's avatar
      Add missing parameter and variable types in src/annotator/ · 24b65649
      Robert Knight authored
      Add missing types found while trying to typecheck src/annotator with
      `noImplicitAny` enabled.
      24b65649
    • Lyza Danger Gardner's avatar
    • Robert Knight's avatar
      Reduce nesting of some tests and revise descriptions · 1c76a6d4
      Robert Knight authored
       - Use "contains" rather than "returns" to describe tests of objects or
         object properties
      
       - Avoid deeply nested `describe` blocks that only contain a single test. This
         is just a preference not to have too many levels of nesting unless
         there are tests that benefit from grouping.
      
       - Revise description of tests for link properties (`link`,
         `documentFingerprint`, `favicon`) since these cover properties other
         than just `link`.
      1c76a6d4
    • Eduardo Sanz García's avatar
      Rearrange tests in `html-metadata.js` · 295a8886
      Eduardo Sanz García authored
      I have created a few additional `describe` sub-sections and re-grouped
      tests by the resulting metadata property. This allow for a more atomic
      testing.
      295a8886
  3. 28 Feb, 2022 20 commits
  4. 25 Feb, 2022 12 commits
    • Robert Knight's avatar
      Support side-by-side mode in VitalSource PDF books · c037edd0
      Robert Knight authored
      Support side-by-side mode in PDF books by simply resizing the content of
      the page. This is similar to how side-by-side mode works in PDFs.
      
      The width of the page in the VS PDF demo has been increased so that it
      better matches the actual VS viewer, and also so that it triggers the
      heuristics in the Guest class for detecting an iframe that fills the
      parent frame.
      c037edd0
    • Robert Knight's avatar
      Use ResizeObserver to detect PDF image size changes · d0e2ab41
      Robert Knight authored
      This allows the client to detect, in most supported browsers, changes in the
      size and position of the PDF book image which don't affect the window
      size. This will be needed to support side-by-side mode for VS PDF books.
      It may also help if VS resizes the book image for any other reason.
      
      For Safari < 13.4, we fall back to using window resize events.
      d0e2ab41
    • Robert Knight's avatar
      Expand comments for `linesOverlap` · b0492327
      Robert Knight authored
      b0492327
    • Robert Knight's avatar
      Revise a comment per code review feedback · d07daebb
      Robert Knight authored
      d07daebb
    • Robert Knight's avatar
      Preserve scroll position after toggling side-by-side mode in web pages · a3d50a93
      Robert Knight authored
      Toggling side-by-side mode in a web page reflows the content. If the absolute
      scroll position stays the same, the logical position in the document will change
      and the user would have to scroll to find the content they were
      previously reading.
      
      To avoid this add logic which picks content in the viewport to use as a _scroll
      anchor_, before the document is resized. After the document is resized, the
      scroll position is changed so that the vertical position of the scroll anchor in
      the viewport is the same as before. This keeps most of the content on screen.
      
      The scroll anchor is currently chosen by picking the first _word_
      (non-whitespace substring of a text node) which is visible in the viewport,
      represented as a DOM Range. This fine-grained scroll anchor is chosen rather
      than eg. just a DOM element, because long paragraphs may change in size
      substantially relative to the viewport after resizing the document, so just
      preserving the location of the paragraph element would not preserve the content
      that is on screen.
      
       - Add `preserveScrollPosition` helper in html-side-by-side.js which
         picks a scroll anchor, invokes a callback and then restores the
         position of the scroll anchor.
      
       - Make the HTML integration use `preserveScrollPosition` to preserve
         the scroll position after activating and de-activating side-by-side
         mode
      
       - Add helper functions in src/annotator/util/geometry for comparing
         DOMRect objects
      a3d50a93
    • Robert Knight's avatar
    • Robert Knight's avatar
      Take into account padding when computing free space · 974c4c0b
      Robert Knight authored
      When computing the amount of free space between the right edge of the
      main content and the edge of the sidebar, allow for the padding
      allocated between the sidebar and the content. This fixes an issue where
      the main content would touch the sidebar exactly instead of having a
      margin between it and the content.
      
      Also tweak the padding value slightly to be a multiple of the 4px grid
      cell size used in the design system.
      974c4c0b
    • Robert Knight's avatar
      Add missing calls to `act` in `useStoreProxy` tests · afd62649
      Robert Knight authored
      Add calls to `act` around proxy method calls that trigger store changes
      which in turn schedule deferred updates within Preact components. This
      should hopefully fix an issue with flakey tests due to updates being
      flushed after the tests have finished executing.
      afd62649
    • Robert Knight's avatar
      Make content frame in VitalSource EPUB fill full width of window · 818a6159
      Robert Knight authored
      This makes the VS EPUB test page more accurately reflect the real VitalSource
      viewer. More importantly, it also triggers the heuristic that the Guest class
      uses to decide whether to enable side-by-side mode for an iframed guest.
      818a6159
    • Robert Knight's avatar
      Enable side-by-side mode for iframe guests that fill the host page · eefac00b
      Robert Knight authored
      To make side-by-side mode work for VitalSource EPUB books, the guest in
      the VS content iframe needs to invoke the integration's `fitSideBySide`
      method. This is done in a generic way by making guests in iframes call
      this method, but only if they know that the iframe fills the host frame.
      eefac00b
    • Robert Knight's avatar
      Implement side-by-side mode for VitalSource EPUB books · 1a15838c
      Robert Knight authored
      In the VitalSource integration, enable the side-by-side mode in the
      underlying HTML document integration.
      1a15838c
    • Robert Knight's avatar
      Implement side-by-side mode for HTML documents · d81b73af
      Robert Knight authored
      Implement side-by-side mode for HTML documents, disabled by default by a
      a `HTMLIntegration.sideBySideEnabled` feature flag.
      
      For ease of testing, some helpers have been split into a separate
      html-side-by-side.js module.
      d81b73af
  5. 24 Feb, 2022 2 commits