From 08ad551a015b8ade9ebc3db754bb1db277549ef2 Mon Sep 17 00:00:00 2001 From: Rob Wu Date: Sat, 11 Jun 2016 15:54:16 +0200 Subject: [PATCH] Force inline block display style for . Test: 1. Build the Chrome extension and load it. 2. Visit https://robwu.nl/pdfjs/object-embed.html 3. Verify that all displayed blocks have the same width and height as the reference ("Expected dimension"). --- extensions/chromium/contentscript.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/extensions/chromium/contentscript.js b/extensions/chromium/contentscript.js index c2e899114..18675091c 100644 --- a/extensions/chromium/contentscript.js +++ b/extensions/chromium/contentscript.js @@ -160,6 +160,22 @@ function updateObjectElement(elem) { elem.type = 'application/not-a-pee-dee-eff-type'; // Force the to reload and render its fallback content. elem.data += ''; + + // Usually the browser renders plugin content in this tag, which is completely + // oblivious of styles such as padding, but we insert and render child nodes, + // so force padding to be zero to avoid undesired dimension changes. + elem.style.padding = '0'; + + // and elements have a "display:inline" style by default. + // Despite this property, when a plugin is loaded in the tag, the tag is + // treated like "display:inline-block". However, when the browser does not + // render plugin content, the tag does not behave like that, and as + // a result the width and height is ignored. + // Force "display:inline-block" to make sure that the width/height as set by + // web pages is respected. + // ( behaves as expected with the default display value, but setting it + // to display:inline-block doesn't hurt). + elem.style.display = 'inline-block'; } // Create an