Skip to content
Permalink
Browse files
2010-04-14 Simon Fraser <simon.fraser@apple.com>
        Reviewed by Dan Bernstein.

        Repaint of fixed, transformed element is broken
        https://bugs.webkit.org/show_bug.cgi?id=37637

        RenderBox::computeRectForRepaint() failed to set the 'fixed' flag correctly
        for elements that had both fixed position and a transform. If the element has
        a transform, 'fixed' should only remain true if the element itself is fixed
        position.

        Also cache style()->position() in a local variable for performance.

        Test: fast/repaint/fixed-tranformed.html

        * rendering/RenderBox.cpp:
        (WebCore::RenderBox::computeRectForRepaint):

Canonical link: https://commits.webkit.org/48920@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@57633 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
smfr committed Apr 15, 2010
1 parent c13a932 commit e76092d0e630864302af91395c6d15df1ba766ab
Showing 7 changed files with 99 additions and 7 deletions.
@@ -1,3 +1,18 @@
2010-04-14 Simon Fraser <simon.fraser@apple.com>

Reviewed by Dan Bernstein.

Repaint of fixed, transformed element is broken
https://bugs.webkit.org/show_bug.cgi?id=37637

Testcase for repainting a fixed-position elemnt with a transform in a
scrolled page.

* fast/repaint/fixed-tranformed.html: Added.
* platform/mac/fast/repaint/fixed-tranformed-expected.checksum: Added.
* platform/mac/fast/repaint/fixed-tranformed-expected.png: Added.
* platform/mac/fast/repaint/fixed-tranformed-expected.txt: Added.

2010-04-14 Luiz Agostini <luiz.agostini@openbossa.org>

Reviewed by Kenneth Rohde Christiansen.
@@ -0,0 +1,49 @@
<!DOCTYPE html>

<html>
<head>
<style type="text/css" media="screen">
body {
height: 1000px;
margin: 0;
}
#test {
width: 100px;
height: 100px;
background-color: red;
position: fixed;
top: 10px;
left: 10px;
-webkit-transform: translate(50px, 50px);
}

.box:hover {
background-color: green;
}
</style>
<script src="resources/repaint.js" type="text/javascript"></script>
<script type="text/javascript">
function repaintTest()
{
document.getElementById('test').style.background='green';
}

function setupTest()
{
window.scrollBy(0, 50);
runRepaintTest();
}
window.addEventListener('load', setupTest, false);
</script>
</head>
<body>

<!--
https://bugs.webkit.org/show_bug.cgi?id=36686
Test repainting of a fixed-position element with a transform.
The box should be entirely green.
-->
<div id="test"></div>

</body>
</html>
@@ -0,0 +1 @@
85213e8cc061917fc232939f5eaac773
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,8 @@
layer at (0,0) size 785x1000
RenderView at (0,0) size 785x600
layer at (0,0) size 785x1000
RenderBlock {HTML} at (0,0) size 785x1000
RenderBody {BODY} at (0,0) size 785x1000
layer at (10,60) size 100x100
RenderBlock (positioned) {DIV} at (10,10) size 100x100 [bgcolor=#008000]
scrolled to 0,50
@@ -1,3 +1,22 @@
2010-04-14 Simon Fraser <simon.fraser@apple.com>

Reviewed by Dan Bernstein.

Repaint of fixed, transformed element is broken
https://bugs.webkit.org/show_bug.cgi?id=37637

RenderBox::computeRectForRepaint() failed to set the 'fixed' flag correctly
for elements that had both fixed position and a transform. If the element has
a transform, 'fixed' should only remain true if the element itself is fixed
position.

Also cache style()->position() in a local variable for performance.

Test: fast/repaint/fixed-tranformed.html

* rendering/RenderBox.cpp:
(WebCore::RenderBox::computeRectForRepaint):

2010-04-14 Luiz Agostini <luiz.agostini@openbossa.org>

Reviewed by Kenneth Rohde Christiansen.
@@ -1184,10 +1184,9 @@ void RenderBox::computeRectForRepaint(RenderBoxModelObject* repaintContainer, In
IntPoint topLeft = rect.location();
topLeft.move(x(), y());

if (style()->position() == FixedPosition)
fixed = true;
EPosition position = style()->position();

if (o->isBlockFlow() && style()->position() != AbsolutePosition && style()->position() != FixedPosition) {
if (o->isBlockFlow() && position != AbsolutePosition && position != FixedPosition) {
RenderBlock* cb = toRenderBlock(o);
if (cb->hasColumns()) {
IntRect repaintRect(topLeft, rect.size());
@@ -1200,16 +1199,17 @@ void RenderBox::computeRectForRepaint(RenderBoxModelObject* repaintContainer, In
// We are now in our parent container's coordinate space. Apply our transform to obtain a bounding box
// in the parent's coordinate space that encloses us.
if (layer() && layer()->transform()) {
fixed = false;
fixed = position == FixedPosition;
rect = layer()->transform()->mapRect(rect);
// FIXME: this clobbers topLeft adjustment done for multicol above
topLeft = rect.location();
topLeft.move(x(), y());
}
} else if (position == FixedPosition)
fixed = true;

if (style()->position() == AbsolutePosition && o->isRelPositioned() && o->isRenderInline())
if (position == AbsolutePosition && o->isRelPositioned() && o->isRenderInline())
topLeft += toRenderInline(o)->relativePositionedInlineOffset(this);
else if (style()->position() == RelativePosition && layer()) {
else if (position == RelativePosition && layer()) {
// Apply the relative position offset when invalidating a rectangle. The layer
// is translated, but the render box isn't, so we need to do this to get the
// right dirty rect. Since this is called from RenderObject::setStyle, the relative position

0 comments on commit e76092d

Please sign in to comment.