1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #import "ui/base/cocoa/nsgraphics_context_additions.h"
7 @implementation NSGraphicsContext (CrAdditions)
9 - (void)cr_setPatternPhase:(NSPoint)phase
10 forView:(NSView*)view {
11 NSView* ancestorWithLayer = view;
12 while (ancestorWithLayer && ![ancestorWithLayer layer])
13 ancestorWithLayer = [ancestorWithLayer superview];
14 if (ancestorWithLayer) {
15 NSPoint bottomLeft = NSZeroPoint;
16 if ([ancestorWithLayer isFlipped])
17 bottomLeft.y = NSMaxY([ancestorWithLayer bounds]);
18 NSPoint offset = [ancestorWithLayer convertPoint:bottomLeft toView:nil];
22 [self setPatternPhase:phase];