summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorccameron@chromium.org <ccameron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-27 22:29:54 +0000
committerccameron@chromium.org <ccameron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-27 22:29:54 +0000
commit36c9c5311efa71566b58503538f3851033708772 (patch)
tree0ae7616ce1573d860f5cf1313f3bc3a3cd32c412 /ui
parentd9b583ea3e2242c236adde1995b97435fcec4ab2 (diff)
downloadchromium_src-36c9c5311efa71566b58503538f3851033708772.zip
chromium_src-36c9c5311efa71566b58503538f3851033708772.tar.gz
chromium_src-36c9c5311efa71566b58503538f3851033708772.tar.bz2
Fix setPatternPhase to work with squashed layers.
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
Diffstat (limited to 'ui')
-rw-r--r--ui/base/cocoa/nsgraphics_context_additions.mm11
1 files changed, 7 insertions, 4 deletions
diff --git a/ui/base/cocoa/nsgraphics_context_additions.mm b/ui/base/cocoa/nsgraphics_context_additions.mm
index 3f70145..9e85fad 100644
--- a/ui/base/cocoa/nsgraphics_context_additions.mm
+++ b/ui/base/cocoa/nsgraphics_context_additions.mm
@@ -8,11 +8,14 @@
- (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;
}