Bug 116319 - webkit-backface-visibility on a parent element stops background-position from updating
Summary: webkit-backface-visibility on a parent element stops background-position from...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 525.x (Safari 3.2)
Hardware: Mac (Intel) OS X 10.8
: P2 Normal
Assignee: Simon Fraser (smfr)
URL: http://jsfiddle.net/nathanstitt/JcX4g/7/
Keywords: InRadar
Depends on: 116397
Blocks:
  Show dependency treegraph
 
Reported: 2013-05-17 08:24 PDT by Nathan Stitt
Modified: 2013-06-16 09:58 PDT (History)
8 users (show)

See Also:


Attachments
Testcase (592 bytes, text/html)
2013-05-18 12:20 PDT, Simon Fraser (smfr)
no flags Details
Patch (26.93 KB, patch)
2013-05-18 14:22 PDT, Simon Fraser (smfr)
no flags Details | Formatted Diff | Diff
Patch (11.41 KB, patch)
2013-06-15 23:12 PDT, Simon Fraser (smfr)
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nathan Stitt 2013-05-17 08:24:22 PDT
If a parent element in the DOM has -webkit-backface-visibility: none applied,  it's children no longer re-render when their background-position is updated.

http://jsfiddle.net/nathanstitt/JcX4g/3/ will illustrate the issue.   Observe how the magnifier image shows the high-resolution image when it's moved.  Uncommenting line 3 ( webkit-backface-visibility) and re-rerunning the jsfiddle and the image never redraws, even though the attributes in the DOM are updated.

I encountered this when using the flexslider library (http://flexslider.woothemes.com/), which applies the backface-visibility.

Hope this helps, contact me if you need any further details.
Comment 1 Nathan Stitt 2013-05-17 08:31:20 PDT
Forgot to mention, removing the div & re-adding it does force an update to the background-position and it will re-render properly.  http://jsfiddle.net/JcX4g/5/ line 28 shows the work-around.
Comment 2 Nathan Stitt 2013-05-17 09:20:30 PDT
I've also prepared a plain javascript version of the test case:  http://jsfiddle.net/nathanstitt/JcX4g/7/
Comment 3 Simon Fraser (smfr) 2013-05-18 12:17:29 PDT
The bug occurs when there's both a position change and a background-position change.
Comment 4 Radar WebKit Bug Importer 2013-05-18 12:20:36 PDT
<rdar://problem/13932329>
Comment 5 Simon Fraser (smfr) 2013-05-18 12:20:43 PDT
Created attachment 202210 [details]
Testcase
Comment 6 Simon Fraser (smfr) 2013-05-18 12:27:09 PDT
Not a recent regression.
Comment 7 Simon Fraser (smfr) 2013-05-18 12:43:07 PDT
Probably regressed with http://trac.webkit.org/changeset/102952
Comment 8 Simon Fraser (smfr) 2013-05-18 12:46:13 PDT
The optimization added in r102952 is basically incorrect. RenderStyle::diff() returns StyleDifferenceLayoutPositionedMovementOnly, but that doesn't mean that some other property changes don't require repainting.
Comment 9 Simon Fraser (smfr) 2013-05-18 14:22:43 PDT
Created attachment 202216 [details]
Patch
Comment 10 Simon Fraser (smfr) 2013-05-18 14:23:15 PDT
Comment on attachment 202216 [details]
Patch

Wrong bug.
Comment 11 Simon Fraser (smfr) 2013-06-15 23:12:57 PDT
Created attachment 204781 [details]
Patch
Comment 12 Darin Adler 2013-06-16 08:50:08 PDT
Comment on attachment 204781 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=204781&action=review

> Source/WebCore/rendering/RenderObject.h:1255
> +            if (oldStyle && m_style->diffRequiresRepaint(oldStyle))

Is there some other level of the code already doing a diff? Is it bad for performance to do this here too?

> Source/WebCore/rendering/style/RenderStyle.cpp:797
> +    unsigned contextSensitiveProperties = 0;

This should be named changedContextSensitiveProperties. Leaving out the word “changed” makes it hard to understand that this is an out argument and whether 0 is the correct value to initialize to.
Comment 13 Simon Fraser (smfr) 2013-06-16 09:01:13 PDT
(In reply to comment #12)
> (From update of attachment 204781 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=204781&action=review
> 
> > Source/WebCore/rendering/RenderObject.h:1255
> > +            if (oldStyle && m_style->diffRequiresRepaint(oldStyle))
> 
> Is there some other level of the code already doing a diff? Is it bad for performance to do this here too?

There is, but the earlier diff bailed early, never testing the repaint properties. So this isn't another full diff.

> > Source/WebCore/rendering/style/RenderStyle.cpp:797
> > +    unsigned contextSensitiveProperties = 0;
> 
> This should be named changedContextSensitiveProperties. Leaving out the word “changed” makes it hard to understand that this is an out argument and whether 0 is the correct value to initialize to.

Agreedn.
Comment 14 Simon Fraser (smfr) 2013-06-16 09:58:04 PDT
http://trac.webkit.org/changeset/151622