-
Notifications
You must be signed in to change notification settings - Fork 10k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement autoprefixer #9629
Implement autoprefixer #9629
Conversation
cursor: none; | ||
-moz-user-select: none; | ||
} | ||
|
||
#viewerContainer.pdfPresentationMode:-ms-fullscreen { | ||
top: 0px !important; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the line I was mentioning in the description. The thing is, now that we have separate rules:
- :-ms-fullscreen
- :fullscreen
they get expanded by autoprefixer to:
- :-ms-fullscreen
- :-webkit-full-screen
- :-moz-full-screen
- :-ms-fullscreen
- :fullscreen
As you can see, 1. was untouched, but 2 got expanded into all rules for all the browsers. So now, -ms-specific overwrites are before all the others, so if any other !important would occur in generic code, we can get these rules overwritten. This is not the case, thankfully, but it's something we should be aware of for the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you show the diff between the CSS files generated before, and after this PR?
gulpfile.js
Outdated
@@ -766,6 +772,7 @@ gulp.task('chromium-pre', ['buildnumber', 'locale'], function () { | |||
preprocessHTML('web/viewer.html', defines) | |||
.pipe(gulp.dest(CHROME_BUILD_CONTENT_DIR + 'web')), | |||
preprocessCSS('web/viewer.css', 'chrome', defines, true) | |||
.pipe(postcss([autoprefixer()])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This version only needs to be compatible with Chrome, so use:
autoprefixer({ browsers: ['chrome >= 49'], })
(Chrome 49, because it is the last supported Chrome version by WIndows XP).
gulpfile.js
Outdated
@@ -719,6 +724,7 @@ gulp.task('mozcentral-pre', ['buildnumber', 'locale'], function () { | |||
preprocessHTML('web/viewer.html', defines) | |||
.pipe(gulp.dest(MOZCENTRAL_CONTENT_DIR + 'web')), | |||
preprocessCSS('web/viewer.css', 'mozcentral', defines, true) | |||
.pipe(postcss([autoprefixer()])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only used in the latest version of Firefox, so use:
autoprefixer({ browsers: ['last 1 firefox versions'], })
Absolutely, here are the files:
|
Generated viewer.css for chromium and mozcentral looks good to me. The browser support table is at https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#faq-support . Can you add a browserlist so that the autoprefixer generates the expected prefixes? |
We went for config passed directly to This table is a little too general for me to build a config as it doesn't state which browser versions we definitely support. Here's my best guess. How does that sound?
|
Firefox ESR is missing from the list. Perhaps you can use |
So to sum up, we could go for: Option 1: Old iOS support (>99,5% market share), XP support
Option 2: iOS default (>95% market share), XP support
Option 3: No XP support, iOS default
|
The intention is to support Safari 8 and later, so How about this:
(based on the How did you determine the browser support? I'm checking browserl.ist and the results are different. E.g. option 1 has 76.64% coverage according to http://browserl.ist/?q=last%202%20versions,Firefox%2052,Chrome%2049,IE%2011,last%203%20iOS%20versions,Safari%208 (note: I fixed the syntax by changing "iOS last 3 versions" to "last 3 iOS versions"). |
Browser support was only applying to iOS versions, I thought I made it clear, sorry if it wasn't. This config looks great to me! |
Nice work! The integration indeed looks easier than I would have expected. I'll review this in the coming days (mainly checking the various diffs), but quickly looking at the diffs tells me that this is a good idea; it cleans up the CSS quite a bit and it's much less error-prone since I'm seeing some (un)prefixed rules that we currently just miss. Edit: I'll also dive into the |
I'm adding what @Rob--W suggested (no reason not to, it doesn't cost us anything to support some more prefixes), but in a form of |
Yes, that sound fine to me. |
/botio-linux preview |
From: Bot.io (Linux m4)ReceivedCommand cmd_preview from @timvandermeij received. Current queue size: 0 Live output at: http://54.67.70.0:8877/21e593bfeae8a81/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.67.70.0:8877/21e593bfeae8a81/output.txt Total script time: 2.32 mins Published |
/botio test |
From: Bot.io (Linux m4)ReceivedCommand cmd_test from @timvandermeij received. Current queue size: 0 Live output at: http://54.67.70.0:8877/24cf616f40ebf3a/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_test from @timvandermeij received. Current queue size: 0 Live output at: http://54.215.176.217:8877/79f71dc9faf0d9c/output.txt |
From: Bot.io (Linux m4)FailedFull output at http://54.67.70.0:8877/24cf616f40ebf3a/output.txt Total script time: 18.06 mins
Image differences available at: http://54.67.70.0:8877/24cf616f40ebf3a/reftest-analyzer.html#web=eq.log |
From: Bot.io (Windows)FailedFull output at http://54.215.176.217:8877/79f71dc9faf0d9c/output.txt Total script time: 24.53 mins
Image differences available at: http://54.215.176.217:8877/79f71dc9faf0d9c/reftest-analyzer.html#web=eq.log |
In `rasterizeAnnotationLayer` we load the source CSS files directly, so these are not processed by Autoprefixer. Since the prefixed rules have now been removed from the source CSS files, we must manually provide one prefixed rule that Chrome needs in the overrides CSS file for checkbox and radio button rendering to work in the reference tests.
/botio test |
From: Bot.io (Linux m4)ReceivedCommand cmd_test from @timvandermeij received. Current queue size: 0 Live output at: http://54.67.70.0:8877/e0fa6c49410b608/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_test from @timvandermeij received. Current queue size: 0 Live output at: http://54.215.176.217:8877/afa5de509a23cf2/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.67.70.0:8877/e0fa6c49410b608/output.txt Total script time: 17.99 mins
|
From: Bot.io (Windows)SuccessFull output at http://54.215.176.217:8877/afa5de509a23cf2/output.txt Total script time: 24.52 mins
|
Thank you for implementing this! It cleans up the CSS files quite a bit. |
Super glad I could help. ❤️ to Mozilla! |
Any chance we could address #9392 as well? |
Implement autoprefixer
Hey there!
I've implemented autoprefixer as a proof of concept. It was a breeze, actually!
Likely will help with: #6685
The only caveat worth mentioning is that if there were some browser-specific hacks like adding
!important
to:-ms-something
only. See comments in the actual code for details.Action:
I need to ask you for help regarding specific configuration on which browsers to target. For now, it's all on default settings and we don't configure anything.
I carefully compared the files using Mergely, and most of the differences make sense, but you will want to hardcode the configuration so that you'll be sure there are no changes without your knowledge.
This config would be in form of
.browserslistrc
file. Sample file could look like this:which means that we would like to support anything with more than 1%, market share, all last 2 versions of everything, no exceptions, and IE10.
Here's all the fun you can do: https://www.npmjs.com/package/browserslist
I checked Allow edits from maintainers and you can feel invited to use this option :)