Calculate ClientWebView to include HTML element margins.

* ui/client-web-view.js (PageState::getPreferredHeight): Compute and use
  top and bottom when determining the height value.

* ui/conversation-web-view.css: Remove onerous style defaults now we
  can deal with HTML elements with margins.
This commit is contained in:
Michael James Gratton 2017-01-27 02:09:23 +11:00
parent 9e171d0db1
commit 5ff2d9b908
2 changed files with 16 additions and 25 deletions

View file

@ -53,7 +53,17 @@ PageState.prototype = {
}, true);
},
getPreferredHeight: function() {
return window.document.documentElement.offsetHeight;
let html = window.document.documentElement;
let height = html.offsetHeight;
let computed = window.getComputedStyle(html);
let top = computed.getPropertyValue('margin-top');
let bot = computed.getPropertyValue('margin-bottom');
return (
height
+ parseInt(top.substring(0, top.length - 2))
+ parseInt(bot.substring(0, bot.length - 2))
);
},
loaded: function() {
this.isLoaded = true;

View file

@ -7,33 +7,15 @@
*/
* {
transition: height 0.25s;
}
html {
/* Trigger CSS 2.1 § 10.6.7 to get a shrink-wrapped height. */
position: absolute !important;
top: 0 !important;
left: 0 !important;
bottom: auto !important;
width: 100% !important;
height: auto !important;
/* Lock down the box enough so we don't get an incrementally
expanding web view */
box-sizing: border-box !important;
margin: 0 !important;
border: 0 !important;
padding: 0;
/* Never show scroll bars */
overflow: hidden;
transition: height 0.25s !important;
}
body {
margin: 0;
margin: 12px;
border: 0;
padding: 12px;
padding: 0;
/* XXX for plain text only? */
overflow-wrap: break-word !important;
}
@ -61,7 +43,6 @@ blockquote {
padding: 0 8px;
}
pre {
white-space: pre-wrap;
}