Chromium Code Reviews| Index: chrome/browser/resources/ntp4/md_incognito_tab.js |
| diff --git a/chrome/browser/resources/ntp4/md_incognito_tab.js b/chrome/browser/resources/ntp4/md_incognito_tab.js |
| index 3918f70126322fd2dc661c8f65c12be8a393ae16..a385f87d025b98662d2a71817aa5793e610c6a42 100644 |
| --- a/chrome/browser/resources/ntp4/md_incognito_tab.js |
| +++ b/chrome/browser/resources/ntp4/md_incognito_tab.js |
| @@ -24,8 +24,18 @@ window.addEventListener('load', function() { |
| var bulletpoints = document.querySelectorAll('.bulletpoints'); |
| var content = document.querySelector('.content'); |
| - var maxWidth = (bulletpoints[0].offsetWidth + bulletpoints[1].offsetWidth + |
| - 40 /* margin */ + 2 /* offsetWidths may be rounded down */); |
| + // Unless this is the first load of the Incognito NTP in this session and |
| + // with this font size, we already have the maximum content width determined. |
| + var fontSize = |
| + window.getComputedStyle(document.body).getPropertyValue("font-size"); |
|
Dan Beam
2017/05/19 01:09:32
don't really get why you prefer getPropertyValue('
msramek
2017/05/19 09:50:59
Fixed. Sorry, I missed that in your original comme
|
| + var maxWidth = localStorage[fontSize] || |
| + (bulletpoints[0].offsetWidth + bulletpoints[1].offsetWidth + |
| + 40 /* margin */ + 2 /* offsetWidths may be rounded down */); |
| + |
| + // Save the data for quicker access when the NTP is reloaded. Note that since |
| + // we're in the Incognito mode, the local storage is ephemeral and the data |
| + // will be discarded when the session ends. |
| + localStorage[fontSize] = maxWidth; |
|
msramek
2017/05/18 15:16:29
I fixed the ordering here. We want to save the res
|
| // Limit the maximum width to 600px. That might force the two lists |
| // of bulletpoints under each other, in which case we must swap the left |