Fixing merge conflicts.

Merge branch 'master' into merge_branch

Conflicts:
	AppKit/CPView.j
This commit is contained in:
Francisco Ryan Tolmasky I committed 2008-09-10 20:48:10 -07:00
commit e1fefd1018
4 files changed
+271 -148

No files matched your search

+124 -73
View File
@@ -55,14 +55,14 @@ var _DOMOriginUpdateMask = 1 << 0,
var _CPViewNotificationCenter = nil;
#if PLATFORM(DOM)
var DOMCanvasElementZIndex = -1,
DOMBackgroundElementZIndex = -2,
DOMElementPrototype = nil,
var DOMElementPrototype = nil,
BackgroundTrivialColor = 0,
BackgroundVerticalThreePartImage = 1,
BackgroundHorizontalThreePartImage = 2,
BackgroundNinePartImage = 3;
BackgroundNinePartImage = 3,
CustomDrawRectViews = {};
#endif
/*
@@ -106,14 +106,16 @@ var DOMCanvasElementZIndex = -1,
#if PLATFORM(DOM)
DOMElement _DOMElement;
DOMElement _DOMContentsElement;
CPArray _DOMImageParts;
CPArray _DOMImageSizes;
unsigned _backgroundType;
DOMElement _DOMGraphicsElement;
#endif
CGRect _dirtyRect;
float _opacity;
CPColor _backgroundColor;
@@ -135,6 +137,9 @@ var DOMCanvasElementZIndex = -1,
*/
+ (void)initialize
{
if ([self instanceMethodForSelector:@selector(drawRect:)] != [CPView instanceMethodForSelector:@selector(drawRect:)])
CustomDrawRectViews[[self hash]] = YES;
if (self != [CPView class])
return;
@@ -398,7 +403,7 @@ var DOMCanvasElementZIndex = -1,
*/
- (void)viewDidMoveToSuperview
{
if (_graphicsContext)
// if (_graphicsContext)
[self setNeedsDisplay:YES];
}
@@ -555,10 +560,18 @@ var DOMCanvasElementZIndex = -1,
if (_autoresizesSubviews)
[self resizeSubviewsWithOldSize:oldSize];
[self setNeedsDisplay:YES];
#if PLATFORM(DOM)
CPDOMDisplayServerSetStyleSize(_DOMElement, size.width, size.height);
if (_DOMContentsElement)
{
CPDOMDisplayServerSetSize(_DOMContentsElement, size.width, size.height);
CPDOMDisplayServerSetStyleSize(_DOMContentsElement, size.width, size.height);
}
if (_backgroundType == BackgroundTrivialColor)
return;
@@ -1291,35 +1304,120 @@ setBoundsOrigin:
}
// Focus
// Displaying
/*
Marks the entire view as dirty, and needing a redraw.
*/
- (void)setNeedsDisplay:(BOOL)aFlag
{
if (aFlag)
[self setNeedsDisplayInRect:[self bounds]];
#if PLATFORM(DOM)
else
CPDOMDisplayServerRemoveView(self);
#endif
}
/*
Marks the area denoted by <code>aRect</code> as dirty, and initiates a redraw on it.
@param aRect the area that needs to be redrawn
*/
- (void)setNeedsDisplayInRect:(CPRect)aRect
{
if (!CustomDrawRectViews[[[self class] hash]])
return;
if (_CGRectIsEmpty(aRect))
return;
if (_dirtyRect && !_CGRectIsEmpty(_dirtyRect))
_dirtyRect = CGRectUnion(aRect, _dirtyRect);
else
_dirtyRect = _CGRectMakeCopy(aRect);
#if PLATFORM(DOM)
CPDOMDisplayServerAddView(self);
#endif
}
- (BOOL)needsDisplay
{
return _dirtyRect && !_CGRectIsEmpty(_dirtyRect);
}
/*
Displays the receiver and any of its subviews that need to be displayed.
*/
- (void)displayIfNeeded
{
if ([self needsDisplay])
[self displayRect:_dirtyRect];
}
/*
Draws the entire area of the receiver as defined by its <code>bounds</code>.
*/
- (void)display
{
[self displayRect:[self visibleRect]];
}
- (void)displayIfNeededInRect:(CGRect)aRect
{
if ([self needsDisplay])
[self displayRect:aRect];
}
/*
Draws the receiver into the area defined by <code>aRect</code>.
@param aRect the area to be drawn
*/
- (void)displayRect:(CPRect)aRect
{
[self displayRectIgnoringOpacity:aRect inContext:nil];
_dirtyRect = NULL;
}
- (void)displayRectIgnoringOpacity:(CGRect)aRect inContext:(CPGraphicsContext)aGraphicsContext
{
[self lockFocus];
CGContextClearRect([[CPGraphicsContext currentContext] graphicsPort], aRect);
[self drawRect:aRect];
[self unlockFocus];
}
/*
Locks focus on the receiver, so drawing commands apply to it.
*/
- (void)lockFocus
{
// If we don't yet have a graphics context, then we must first create a
// canvas element, then use its 2d context.
if (!_graphicsContext)
{
var context = CGBitmapGraphicsContextCreate();
var graphicsPort = CGBitmapGraphicsContextCreate();
#if PLATFORM(DOM)
_DOMGraphicsElement = context.DOMElement;
_DOMContentsElement = graphicsPort.DOMElement;
_DOMGraphicsElement.style.position = "absolute";
_DOMGraphicsElement.style.top = "0px";
_DOMGraphicsElement.style.left = "0px";
_DOMGraphicsElement.style.zIndex = DOMCanvasElementZIndex;
_DOMGraphicsElement.width = CPRectGetWidth(_frame);
_DOMGraphicsElement.height = CPRectGetHeight(_frame);
_DOMContentsElement.style.zIndex = -100;
_DOMGraphicsElement.style.width = CPRectGetWidth(_frame) + "px";
_DOMGraphicsElement.style.height = CPRectGetHeight(_frame) + "px";
_DOMContentsElement.style.overflow = "hidden";
_DOMContentsElement.style.position = "absolute";
_DOMContentsElement.style.visibility = "visible";
_DOMContentsElement.width = ROUND(_CGRectGetWidth(_frame));
_DOMContentsElement.height = ROUND(_CGRectGetHeight(_frame));
_DOMContentsElement.style.top = "0px";
_DOMContentsElement.style.left = "0px";
_DOMContentsElement.style.width = ROUND(_CGRectGetWidth(_frame)) + "px";
_DOMContentsElement.style.height = ROUND(_CGRectGetHeight(_frame)) + "px";
_DOMElement.appendChild(_DOMGraphicsElement);
#endif
_graphicsContext = [CPGraphicsContext graphicsContextWithGraphicsPort:context flipped:YES];
CPDOMDisplayServerAppendChild(_DOMElement, _DOMContentsElement);
_graphicsContext = [CPGraphicsContext graphicsContextWithGraphicsPort:graphicsPort flipped:YES];
}
[CPGraphicsContext setCurrentContext:_graphicsContext];
@@ -1332,58 +1430,11 @@ setBoundsOrigin:
*/
- (void)unlockFocus
{
var graphicsPort = [_graphicsContext graphicsPort];
CGContextRestoreGState(graphicsPort);
CGContextRestoreGState([_graphicsContext graphicsPort]);
[CPGraphicsContext setCurrentContext:nil];
}
// Displaying
/*
Marks the entire view as dirty, and needing a redraw.
*/
- (void)setNeedsDisplay:(BOOL)aFlag
{
if (aFlag)
[self display];
}
/*
Marks the area denoted by <code>aRect</code> as dirty, and initiates a redraw on it.
@param aRect the area that needs to be redrawn
*/
- (void)setNeedsDisplayInRect:(CGRect)aRect
{
[self displayRect:aRect];
}
/*
Displays the receiver and any of its subviews that need to be displayed.
*/
- (void)displayIfNeeded
{
}
/*
Draws the entire area of the receiver as defined by its <code>bounds</code>.
*/
- (void)display
{
[self displayRect:_bounds];
}
/*
Draws the receiver into the area defined by <code>aRect</code>.
@param aRect the area to be drawn
*/
- (void)displayRect:(CGRect)aRect
{
[self lockFocus];
[self drawRect:aRect];
[self unlockFocus];
}
/*
Returns whether the receiver is completely opaque. By default, returns <code>NO</code>.
*/
+40 -3
View File
@@ -26,9 +26,10 @@
#define SetStyleLeftBottom 2
#define SetStyleRightBottom 3
#define SetStyleSize 4
#define AppendChild 5
#define InsertBefore 6
#define RemoveChild 7
#define SetSize 5
#define AppendChild 6
#define InsertBefore 7
#define RemoveChild 8
#define CPDOMDisplayServerSetStyleOrigin(anInstruction, aDOMElement, aTransform, x, y)\
if (!aDOMElement.CPDOMDisplayContext)\
@@ -67,6 +68,20 @@
CPDOMDisplayServerInstructions[__index + 2] = aWidth;\
CPDOMDisplayServerInstructions[__index + 3] = aHeight;
#define CPDOMDisplayServerSetSize(aDOMElement, aWidth, aHeight)\
if (!aDOMElement.CPDOMDisplayContext)\
aDOMElement.CPDOMDisplayContext = [];\
var __index = aDOMElement.CPDOMDisplayContext[SetSize];\
if (!(__index >= 0))\
{\
__index = aDOMElement.CPDOMDisplayContext[SetSize] = CPDOMDisplayServerInstructionCount;\
CPDOMDisplayServerInstructionCount += 4;\
}\
CPDOMDisplayServerInstructions[__index] = SetSize;\
CPDOMDisplayServerInstructions[__index + 1] = aDOMElement;\
CPDOMDisplayServerInstructions[__index + 2] = aWidth;\
CPDOMDisplayServerInstructions[__index + 3] = aHeight;
#define CPDOMDisplayServerAppendChild(aParentElement, aChildElement)\
if (aChildElement.CPDOMDisplayContext) aChildElement.CPDOMDisplayContext[SetStyleOrigin] = -1;\
CPDOMDisplayServerInstructions[CPDOMDisplayServerInstructionCount++] = AppendChild;\
@@ -86,3 +101,25 @@
CPDOMDisplayServerInstructions[CPDOMDisplayServerInstructionCount++] = aChildElement;
//#dfeine CPDOMDisplayServerCustomAction()
#define CPDOMDisplayServerAddView(aView)\
{\
var ___hash = [aView hash];\
if (typeof (CPDOMDisplayServerViewsContext[___hash]) == "undefined")\
{\
CPDOMDisplayServerViews[CPDOMDisplayServerViewsCount++] = aView;\
CPDOMDisplayServerViewsContext[___hash] = aView;\
}\
}\
#define CPDOMDisplayServerRemoveView(aView)\
{\
var index = CPDOMDisplayServerViewsContext[[aView hash]];\
if (typeof index != "undefined") \
{\
CPDOMDisplayServerViewsContext[[aView hash]];\
CPDOMDisplayServerViews[index] = NULL;\
}\
}\
+106 -71
View File
@@ -28,8 +28,12 @@ import <Foundation/CPRunLoop.j>
var CPDOMDisplayRunLoop = nil;
CPDOMDisplayServerInstructions = [];
CPDOMDisplayServerInstructionCount = 0;
CPDOMDisplayServerInstructions = [];
CPDOMDisplayServerInstructionCount = 0;
CPDOMDisplayServerViews = [];
CPDOMDisplayServerViewsCount = 0;
CPDOMDisplayServerViewsContext = {};
@implementation CPDOMDisplayServer : CPObject
{
@@ -44,83 +48,114 @@ CPDOMDisplayServerInstructionCount = 0;
+ (void)run
{
var index = 0;
while (index < CPDOMDisplayServerInstructionCount)
while (CPDOMDisplayServerInstructionCount || CPDOMDisplayServerViewsCount)
{
var instruction = CPDOMDisplayServerInstructions[index++];
try{
switch (instruction)
var index = 0;
while (index < CPDOMDisplayServerInstructionCount)
{
case SetStyleLeftTop:
case SetStyleRightTop:
case SetStyleLeftBottom:
case SetStyleRightBottom: var element = CPDOMDisplayServerInstructions[index],
style = element.style,
x = (instruction == SetStyleLeftTop || instruction == SetStyleLeftBottom) ? "left" : "right",
y = (instruction == SetStyleLeftTop || instruction == SetStyleRightTop) ? "top" : "bottom";
CPDOMDisplayServerInstructions[index++] = nil;
var instruction = CPDOMDisplayServerInstructions[index++];
try{
switch (instruction)
{
case SetStyleLeftTop:
case SetStyleRightTop:
case SetStyleLeftBottom:
case SetStyleRightBottom: var element = CPDOMDisplayServerInstructions[index],
style = element.style,
x = (instruction == SetStyleLeftTop || instruction == SetStyleLeftBottom) ? "left" : "right",
y = (instruction == SetStyleLeftTop || instruction == SetStyleRightTop) ? "top" : "bottom";
var transform = CPDOMDisplayServerInstructions[index++];
if (transform)
{
var point = _CGPointMake(CPDOMDisplayServerInstructions[index++], CPDOMDisplayServerInstructions[index++]),
transformed = _CGPointApplyAffineTransform(point, transform);
style[x] = ROUND(transformed.x) + "px";
style[y] = ROUND(transformed.y) + "px";
CPDOMDisplayServerInstructions[index++] = nil;
var transform = CPDOMDisplayServerInstructions[index++];
if (transform)
{
var point = _CGPointMake(CPDOMDisplayServerInstructions[index++], CPDOMDisplayServerInstructions[index++]),
transformed = _CGPointApplyAffineTransform(point, transform);
style[x] = ROUND(transformed.x) + "px";
style[y] = ROUND(transformed.y) + "px";
}
else
{
style[x] = ROUND(CPDOMDisplayServerInstructions[index++]) + "px";
style[y] = ROUND(CPDOMDisplayServerInstructions[index++]) + "px";
}
element.CPDOMDisplayContext[SetStyleOrigin] = -1;
break;
case SetStyleSize: var element = CPDOMDisplayServerInstructions[index],
style = element.style;
CPDOMDisplayServerInstructions[index++] = nil;
element.CPDOMDisplayContext[SetStyleSize] = -1;
style.width = MAX(0.0, ROUND(CPDOMDisplayServerInstructions[index++])) + "px";
style.height = MAX(0.0, ROUND(CPDOMDisplayServerInstructions[index++])) + "px";
break;
}
else
{
style[x] = ROUND(CPDOMDisplayServerInstructions[index++]) + "px";
style[y] = ROUND(CPDOMDisplayServerInstructions[index++]) + "px";
}
case SetSize: var element = CPDOMDisplayServerInstructions[index];
CPDOMDisplayServerInstructions[index++] = nil;
element.CPDOMDisplayContext[SetSize] = -1;
element.width = MAX(0.0, ROUND(CPDOMDisplayServerInstructions[index++]));
element.height = MAX(0.0, ROUND(CPDOMDisplayServerInstructions[index++]));
element.CPDOMDisplayContext[SetStyleOrigin] = -1;
break;
break;
case AppendChild: CPDOMDisplayServerInstructions[index].appendChild(CPDOMDisplayServerInstructions[index + 1]);
case SetStyleSize: var element = CPDOMDisplayServerInstructions[index],
style = element.style;
CPDOMDisplayServerInstructions[index++] = nil;
element.CPDOMDisplayContext[SetStyleSize] = -1;
style.width = MAX(0.0, ROUND(CPDOMDisplayServerInstructions[index++])) + "px";
style.height = MAX(0.0, ROUND(CPDOMDisplayServerInstructions[index++])) + "px";
break;
CPDOMDisplayServerInstructions[index++] = nil;
CPDOMDisplayServerInstructions[index++] = nil;
break;
case InsertBefore: CPDOMDisplayServerInstructions[index].insertBefore(CPDOMDisplayServerInstructions[index + 1], CPDOMDisplayServerInstructions[index + 2]);
CPDOMDisplayServerInstructions[index++] = nil;
CPDOMDisplayServerInstructions[index++] = nil;
CPDOMDisplayServerInstructions[index++] = nil;
break;
case AppendChild: CPDOMDisplayServerInstructions[index].appendChild(CPDOMDisplayServerInstructions[index + 1]);
CPDOMDisplayServerInstructions[index++] = nil;
CPDOMDisplayServerInstructions[index++] = nil;
break;
case InsertBefore: CPDOMDisplayServerInstructions[index].insertBefore(CPDOMDisplayServerInstructions[index + 1], CPDOMDisplayServerInstructions[index + 2]);
CPDOMDisplayServerInstructions[index++] = nil;
CPDOMDisplayServerInstructions[index++] = nil;
CPDOMDisplayServerInstructions[index++] = nil;
break;
case RemoveChild: CPDOMDisplayServerInstructions[index].removeChild(CPDOMDisplayServerInstructions[index + 1]);
CPDOMDisplayServerInstructions[index++] = nil;
CPDOMDisplayServerInstructions[index++] = nil;
break;
}}catch(e) { alert("here?" + instruction) }
case RemoveChild: CPDOMDisplayServerInstructions[index].removeChild(CPDOMDisplayServerInstructions[index + 1]);
CPDOMDisplayServerInstructions[index++] = nil;
CPDOMDisplayServerInstructions[index++] = nil;
break;
}}catch(e) { alert("here?" + instruction) }
}
CPDOMDisplayServerInstructionCount = 0;
var views = CPDOMDisplayServerViews,
index = 0,
count = CPDOMDisplayServerViewsCount;
// We don't reset CPDOMDisplayServerViewsContext because it can serve for displays that are coming...
CPDOMDisplayServerViews = [];
CPDOMDisplayServerViewsCount = 0;
for (; index < count; ++index)
{
var view = views[index];
delete CPDOMDisplayServerViewsContext[[view hash]];
[view displayIfNeeded];
}
}
CPDOMDisplayServerInstructionCount = 0;
[CPDOMDisplayRunLoop performSelector:@selector(run) target:CPDOMDisplayServer argument:nil order:0 modes:[CPDefaultRunLoopMode]];
}
+1 -1
View File
@@ -192,7 +192,7 @@
*/
+ (IMP)instanceMethodForSelector:(SEL)aSelector
{
return class_getInstanceMethod(isa, aSelector);
return class_getInstanceMethod(self, aSelector);
}
/*