Files
WebODF/webodf/misctests/zoomtest.html
T
Philip Peitsch c610f20c33 Take zoom levels into account when drawing the caret (issue #127)
In firefox, range rectangles are not affected by transforms applied to
the start and end containers, however, in chrome, the range *is*
transformed.

For Chrome, this means differences between range rectangles need to be
scaled according to the current zoom level in order to be correct. In
Firefox, this scaling is unnecessary if two ranges are compared.

Additionally, in firefox this means mixing range and element client rects
will result in undesirable behaviour due to the different transforms
applied to each.

See related firefox bugs:
* https://bugzilla.mozilla.org/show_bug.cgi?id=863618
* https://bugzilla.mozilla.org/show_bug.cgi?id=816238

http://dev.w3.org/csswg/cssom-view/#extensions-to-the-range-interface
Section 10, getClientRects, "The transforms that apply to the ancestors are applied."

Inverted bug detection logic
2013-10-26 11:31:00 +11:00

40 lines
1.4 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<div id="zoomed" style="position: absolute">
<div id="container" style="position: absolute; top: 10px; left: 20px; width: 200px; height: 20px; background-color: red">
</div>
</div>
<pre style="position: absolute; top: 50px">
<script>
var zoomed = document.getElementById("zoomed"),
container = document.getElementById("container"),
range = document.createRange();
range.selectNode(container);
function toString(rect) {
return "top: " + rect.top + ", left: " + rect.left + ", height: " + rect.height;
}
document.writeln("Before transform");
document.writeln("================");
document.writeln("container.getBoundingClientRect: " + toString(container.getBoundingClientRect()));
document.writeln("range.getBoundingClientRect: " + toString(range.getBoundingClientRect()));
zoomed.style["transform"] = "scale(1.5)";
zoomed.style["transform-origin"] = "left top 0px";
zoomed.style["-webkit-transform"] = "scale(1.5)";
zoomed.style["-webkit-transform-origin"] = "50% 0%";
document.writeln("");
document.writeln("After transform");
document.writeln("================");
document.writeln("container.getBoundingClientRect: " + toString(container.getBoundingClientRect()));
document.writeln("range.getBoundingClientRect: " + toString(range.getBoundingClientRect()));
</script>
</pre>
</body>
</html>