• dpapad's avatar
    PDF Viewer: Make Viewport class work with HTMLElement instead of Window. · a9c2e27e
    dpapad authored
    This is necessary in order to have the Viewport class work for both
    PDFViewerUpdate=false/true codepaths. Previously the Viewport
    constructor was expecting a Window instance to be passed as the
    scrolling container, but that is no longer the case in the
    PDFViewerUpdate UI.
    
    This CL modifies the code such that the scrolling container passed to
    the Viewport constructor is:
     - the <html> element for PDFViewerUpdate=false
     - the #main element for PDFViewerUpdate=true
    
    In order to do so
     - the <html> element is given a height of 100%, so that offsetHeight
       has a meaningful non-zero value.
     - innerHeight/innerWidth is replaced with offsetHeight/offsetWidth.
     - pageXOffset/pageYOffset is replaced with scrollLeft/scrollTop
     - a new MockElement class is introduced to replace MockWindow in some
       tests (MockWindow is still used in toolbar_manager_tests.js)
    
    Bug: 1101598
    Change-Id: I0d3fa1a8a0146c97ef636b01954911750b5be942
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2308865
    Commit-Queue: dpapad <dpapad@chromium.org>
    Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#791686}
    a9c2e27e
index.html 574 Bytes