Skip to content

Commit

Permalink
Fix setPatternPhase to work with squashed layers.
Browse files Browse the repository at this point in the history
The computation for setPatternPhase does not work if the NSView renders
into the CALayer of an ancestor of the NSView. Change the computation
to look up through the NSView hierarchy for a view that has a layer, and
compute the new phase using the coordinate system of that layer.

This is updating a fix that was originally made in r206004 to support
the squashed layers enabled in r247098.

BUG=245900

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247326 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
ccameron@chromium.org committed Jan 27, 2014
1 parent d9b583e commit 36c9c53
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions ui/base/cocoa/nsgraphics_context_additions.mm
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ @implementation NSGraphicsContext (CrAdditions)

- (void)cr_setPatternPhase:(NSPoint)phase
forView:(NSView*)view {
if ([view layer]) {
NSView* ancestorWithLayer = view;
while (ancestorWithLayer && ![ancestorWithLayer layer])
ancestorWithLayer = [ancestorWithLayer superview];
if (ancestorWithLayer) {
NSPoint bottomLeft = NSZeroPoint;
if ([view isFlipped])
bottomLeft.y = NSMaxY([view bounds]);
NSPoint offset = [view convertPoint:bottomLeft toView:nil];
if ([ancestorWithLayer isFlipped])
bottomLeft.y = NSMaxY([ancestorWithLayer bounds]);
NSPoint offset = [ancestorWithLayer convertPoint:bottomLeft toView:nil];
phase.x -= offset.x;
phase.y -= offset.y;
}
Expand Down

0 comments on commit 36c9c53

Please sign in to comment.