Don't always full invalidation on 'position' style change

Move position changed case from
RenderStyle::diffNeedsFullLayoutAndPaintInvalidation()
to RenderStyle::diffNeedsFullLayout().

Our layout code can issue invalidations if actually needed.

BUG=408697
TEST=fast/repaint/position-change-keeping-geometry.html

Review URL: https://codereview.chromium.org/536183002

git-svn-id: svn://svn.chromium.org/blink/trunk@181423 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent e7e70113
{
"bounds": [800, 600],
"children": [
{
"bounds": [800, 600],
"contentsOpaque": true,
"drawsContent": true
}
]
}
<!DOCTYPE html>
<script src="resources/text-based-repaint.js"></script>
<script>
function changePositionKeepingGeometry(id, newPosition) {
var target = document.getElementById(id);
var originalTop = target.offsetTop;
var originalLeft = target.offsetLeft;
target.style.position = newPosition;
target.style.top = originalTop + 'px';
target.style.left = originalLeft + 'px';
}
function repaintTest()
{
changePositionKeepingGeometry('target1', 'absolute');
changePositionKeepingGeometry('target2', 'absolute');
changePositionKeepingGeometry('target3', 'fixed');
}
onload = runRepaintTest;
</script>
<style>
body {
margin: 0;
}
div {
width: 100px;
height: 100px;
top: 20px;
background-color: blue;
}
#target1 {
left: 20px;
position: relative;
}
#target2 {
left: 220px;
position: fixed;
z-index: 0;
}
#target3 {
left: 420px;
position: absolute;
z-index: 0;
}
</style>
There should be no invalildations on change of position without actual change of position and size.
<div id="target1"></div>
<div id="target2"></div>
<div id="target3"></div>
......@@ -538,7 +538,6 @@ bool RenderStyle::diffNeedsFullLayoutAndPaintInvalidation(const RenderStyle& oth
|| noninherited_flags.overflowY != other.noninherited_flags.overflowY
|| noninherited_flags.clear != other.noninherited_flags.clear
|| noninherited_flags.unicodeBidi != other.noninherited_flags.unicodeBidi
|| noninherited_flags.position != other.noninherited_flags.position
|| noninherited_flags.floating != other.noninherited_flags.floating
|| noninherited_flags.originalDisplay != other.noninherited_flags.originalDisplay)
return true;
......@@ -599,7 +598,8 @@ bool RenderStyle::diffNeedsFullLayout(const RenderStyle& other) const
return true;
}
if (noninherited_flags.verticalAlign != other.noninherited_flags.verticalAlign)
if (noninherited_flags.verticalAlign != other.noninherited_flags.verticalAlign
|| noninherited_flags.position != other.noninherited_flags.position)
return true;
if (surround.get() != other.surround.get()) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment