| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2009 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 <Cocoa/Cocoa.h> |
| 6 |
| 7 // BrowserFrameView is a class whose methods we swizzle into NSGrayFrame |
| 8 // (an AppKit framework class) so that we can support custom frame drawing, and |
| 9 // have the ability to move our window widgets (close, zoom, miniaturize) where |
| 10 // we want them. |
| 11 // This class is never to be instantiated on its own. |
| 12 // We explored a variety of ways to support custom frame drawing and custom |
| 13 // window widgets. |
| 14 // Our requirements were: |
| 15 // a) that we could fall back on standard system drawing at any time for the |
| 16 // "default theme" |
| 17 // b) We needed to be able to draw both a background pattern, and an overlay |
| 18 // graphic, and we need to be able to set the pattern phase of our background |
| 19 // window. |
| 20 // c) We had to be able to support "transparent" themes, so that you could see |
| 21 // through to the underlying windows in places without the system theme |
| 22 // getting in the way. |
| 23 // d) We had to support having the custom window controls moved down by a couple |
| 24 // of pixels and rollovers, accessibility, etc. all had to work. |
| 25 // |
| 26 // Since we want "A" we couldn't just do a transparent borderless window. At |
| 27 // least I couldn't find the right combination of HITheme calls to make it draw |
| 28 // nicely, and I don't trust that the HITheme calls are going to exist in future |
| 29 // system versions. |
| 30 // "C" precluded us from inserting a view between the system frame and the |
| 31 // the content frame in Z order. To get the transparency we actually need to |
| 32 // replace the drawing of the system frame. |
| 33 // "D" required us to override _mouseInGroup to get our custom widget rollovers |
| 34 // drawing correctly. The widgets call _mouseInGroup on their superview to |
| 35 // decide whether they should draw in highlight mode or not. |
| 36 // "B" precluded us from just setting a background color on the window. |
| 37 // |
| 38 // Originally we tried overriding the private API +frameViewForStyleMask: to |
| 39 // add our own subclass of NSGrayView to our window. Turns out that if you |
| 40 // subclass NSGrayView it does not draw correctly when you call NSGrayView's |
| 41 // drawRect. It appears that NSGrayView's drawRect: method (and that of its |
| 42 // superclasses) do lots of "isMemberOfClass/isKindOfClass" calls, and if your |
| 43 // class is NOT an instance of NSGrayView (as opposed to a subclass of |
| 44 // NSGrayView) then the system drawing will not work correctly. |
| 45 // |
| 46 // Given all of the above, we found swizzling drawRect, and adding an |
| 47 // implementation of _mouseInGroup and updateTrackingAreas, in _load to be the |
| 48 // easiest and safest method of achieving our goals. We do the best we can to |
| 49 // check that everything is safe, and attempt to fallback gracefully if it is |
| 50 // not. |
| 51 @interface BrowserFrameView : NSView |
| 52 @end |
| OLD | NEW |