Issue metadata
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)
,
Aug 24 2016
,
Aug 24 2016
,
Aug 25 2016
Going to wait on the feedback asked for in the first comment
,
Aug 26 2016
|
|||||||||||||||||||||||||
►
Sign in to add a comment |
|||||||||||||||||||||||||
Comment 1 by msrchandra@chromium.org
, Aug 1 2016Labels: Needs-Feedback