• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4
5#import "ui/base/cocoa/nsgraphics_context_additions.h"
6
7@implementation NSGraphicsContext (CrAdditions)
8
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];
19    phase.x -= offset.x;
20    phase.y -= offset.y;
21  }
22  [self setPatternPhase:phase];
23}
24
25@end
26