New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 615377 link

Starred by 2 users

Issue metadata

Status: Duplicate
Merged: issue 638522
Owner:
Not on Chrome anymore
Closed: Aug 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

Chrome Print Preview doesn't wait for reflow to complete from dom modifications made from window.matchMedia Listener before printing

Reported by jjfranko...@gmail.com, May 27 2016

Issue description

Chrome Version       : 50.0.2661.102 (Official Build) m (32-bit)
URLs (if applicable) :
Other browsers tested:
  Add OK or FAIL, along with the version, after other browsers where you
have tested this issue:
     Safari: 
    Firefox: OK
         IE: OK

What steps will reproduce the problem?
(1) I have an 100% height iframe that has contents that scroll inside the iframe and I want to print just the iframe and all its content (without scrollbars), so I use the following code to make the iframe the body of the page:

(function() {
  var beforePrint = function() {

    console.log('Functionality to run before printing:' + window.printOnce);

    if(window.printOnce){
      return;
    }
    else{
      window.printOnce=true;
    }
    var $ = jQuery;
    var iFrame = $('iframe[name=printMe]');
    var iFrameBody = $(iFrame[0].contentDocument.getElementsByTagName('body')[0]);

    var div = iFrameBody.find(".hx-fullscreen");
    div.css("bottom", "inherit");
    iFrameBody.find("form").css("bottom", "inherit");

    var iFrameChildren = iFrameBody.children();
    var body = $('body');
    body.css("height", "inherit");
    body.css("display", "none");
    var originalChildren = body.children();
    originalChildren.remove();

    body.append(iFrameChildren);

    //try to force Reflow?
    body.css("display", "");

  };
  var afterPrint = function() {
    console.log('Functionality to run after printing');
  };

  if (window.matchMedia) {
    var mediaQueryList = window.matchMedia('print');
    mediaQueryList.addListener(function(mql) {
      if (mql.matches) {
        beforePrint();
      } else {
        afterPrint();
      }
    });
  }

  window.onbeforeprint = beforePrint;
  window.onafterprint = afterPrint;
}());


What is the expected result?

The print preview should show the full contents of the iframe without a scrollbar


What happens instead?

The first print preview shows the contents of the iframe with scrollbars so I don't see the entire contents of the iframe

If I Cancel the print preview and press print a second time, the full contents of the iframe is displayed. It seems that if the print preview waited a little longer, then the first print would work fine.


Please provide any additional information below. Attach a screenshot if
possible.

1) pageBeforePrint shows the state of the page before I press print
2) notice the firstPrintPreview has 1 page (wrong)
3) notice the secondPrintPreview has 15 pages (right)

 
pageBeforePrint.png
220 KB View Download
firstPrintPreview.png
282 KB View Download
secondPrintPreview.png
287 KB View Download
Cc: msrchandra@chromium.org
Labels: Needs-Feedback
@jjfrankovic -- Could you please provide us any specific html file or URL where the issue is reproducible which would help us triage further.
Thanks in Advance.
Components: UI>Browser>PrintPreview
Cc: nainar@chromium.org

Comment 4 by nainar@chromium.org, Aug 25 2016

Cc: -nainar@chromium.org
Owner: nainar@chromium.org
Going to wait on the feedback asked for in the first comment

Comment 5 by nainar@chromium.org, Aug 26 2016

Mergedinto: 638522
Status: Duplicate (was: Unconfirmed)
Duping tentatively.

Sign in to add a comment