Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions docs/design/lazy-loading.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,13 @@ the first chunk of a sheet with shapes is always near: the writer states

**What stays.** The limits (`spreadsheet_limit`, `spreadsheet_cell_limit`)
stay as they are in this step. A sheet of 500 K cells
(`efficiency-big-1.ods`) took 7.0 s to its first frame, and takes 4.0 s
with chunks. About 2 s of the rest is `viewport.js`: to find whether the
browser adjusts the text size, it sets the zoom of the body twice. Each
set makes the browser compute the style and the layout of the whole
document again. Whether the limits can go up is a measurement after that
is fixed.
(`efficiency-big-1.ods`) took 7.0 s to its first frame, and takes 2.2 s
with chunks. The same page without its scripts takes 2.0 s. Before, the
page with chunks took 4.0 s, and 1.8 s of that was `viewport.js`. To find
whether the browser adjusts the text size, it set the zoom of the body
twice, and each set made the browser compute the style and the layout of
the whole document again. It now probes in an `iframe` of its own. Whether
the limits can go up is the next measurement.

## Order of work

Expand Down
32 changes: 22 additions & 10 deletions src/odr/internal/html/frontend/viewport.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,30 +57,42 @@
// A run against a stated length, so no rect convention enters. True in webkit
// and in the engines that ignore the property; false where it scales the text
// a second time.
//
// In a document of its own: a zoom on the body and an adjustment on the root
// are inherited, so in the page they would restyle and lay out all of it,
// twice.
function textAdjustHolds() {
var ruler = document.createElement("div");
var frame = document.createElement("iframe");
frame.style.cssText =
"position:absolute;top:0;left:0;width:400px;height:0;border:0;" +
"visibility:hidden";
body.appendChild(frame);
var probe = frame.contentDocument;
if (probe === null || probe.body === null) {
body.removeChild(frame);
return false;
}
probe.body.style.margin = "0";
var ruler = probe.createElement("div");
ruler.style.cssText =
"position:absolute;top:0;left:0;width:400px;height:0;overflow:hidden";
var run = document.createElement("span");
var run = probe.createElement("span");
run.style.cssText = "font:100px/1 monospace;white-space:pre";
run.textContent = "MMMMMMMMMM";
ruler.appendChild(run);
body.appendChild(ruler);
probe.body.appendChild(ruler);

function ratio() {
var length = ruler.getBoundingClientRect().width;
return length ? run.getBoundingClientRect().width / length : 0;
}

var zoom = body.style.zoom;
body.style.zoom = "1";
var unzoomed = ratio();
body.style.zoom = "0.5";
textAdjust("50%");
probe.body.style.zoom = "0.5";
probe.documentElement.style.setProperty("-webkit-text-size-adjust", "50%");
probe.documentElement.style.setProperty("text-size-adjust", "50%");
var zoomed = ratio();
textAdjust("");
body.style.zoom = zoom;
body.removeChild(ruler);
body.removeChild(frame);

return unzoomed > 0 && Math.abs(zoomed - unzoomed) < unzoomed / 50;
}
Expand Down
4 changes: 2 additions & 2 deletions test/data.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ odr_test_data(
odr_test_data(
PATH "reference-output/odr-public"
URL "https://github.com/opendocument-app/OpenDocument.test.output.git"
REVISION "1ff01470c6b43a1962d6f934a9d6a46600e3b72e")
REVISION "1ae5868d991da48d23b44be6d4e99264258dfd95")

odr_test_data(
PATH "reference-output/odr-private"
URL "https://github.com/opendocument-app/OpenDocument.test-private.output.git"
REVISION "07c9ef2bb3b2397249ef0ff0dec15baa9fc5d887")
REVISION "32f5ee77f480a8e21a4dfce80fc9a267a1034493")
Loading