mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 21:17:03 +00:00
new: render to dom only the visible stuff
This commit is contained in:
@@ -1170,6 +1170,7 @@ var _objectsInRange = function(aList, aRange)
|
||||
var color = [attributes objectForKey:CPForegroundColorAttributeName],
|
||||
elem = [self createDOMElementWithText:string andFont:font andColor:color],
|
||||
run = {_range:CPMakeRangeCopy(effectiveRange), elem:elem, string:string};
|
||||
run = {_range:CPMakeRangeCopy(effectiveRange), color:color, font:font, elem:nil, string:string};
|
||||
|
||||
_runs.push(run);
|
||||
}
|
||||
@@ -1257,7 +1258,12 @@ var _objectsInRange = function(aList, aRange)
|
||||
{
|
||||
var run = runs[i];
|
||||
|
||||
if (run.DOMactive && !run.DOMpatched || !run.elem)
|
||||
if (!run.elem && CPRectIntersectsRect([_textContainer._textView exposedRect], _fragmentRect))
|
||||
{
|
||||
run.elem=[self createDOMElementWithText:run.string andFont:run.font andColor:run.color];
|
||||
}
|
||||
|
||||
if (run.DOMactive && !run.DOMpatched)
|
||||
continue;
|
||||
|
||||
if (!_glyphsFrames)
|
||||
@@ -1267,19 +1273,19 @@ var _objectsInRange = function(aList, aRange)
|
||||
orig.x = _glyphsFrames[loc].origin.x + aPoint.x;
|
||||
orig.y = _glyphsFrames[loc].origin.y + aPoint.y + _glyphsOffsets[loc];
|
||||
|
||||
run.elem.style.left = (orig.x) + "px";
|
||||
run.elem.style.top = (orig.y) + "px";
|
||||
if(run.elem)
|
||||
{
|
||||
run.elem.style.left = (orig.x) + "px";
|
||||
run.elem.style.top = (orig.y) + "px";
|
||||
|
||||
if (!run.DOMactive)
|
||||
_textContainer._textView._DOMElement.appendChild(run.elem);
|
||||
if (!run.DOMactive)
|
||||
_textContainer._textView._DOMElement.appendChild(run.elem);
|
||||
|
||||
run.DOMactive = YES;
|
||||
}
|
||||
|
||||
run.DOMactive = YES;
|
||||
run.DOMpatched = NO;
|
||||
|
||||
if (run.underline)
|
||||
{
|
||||
// <!> FIXME
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1324,7 +1330,7 @@ var _objectsInRange = function(aList, aRange)
|
||||
{
|
||||
_runs[i]._range.location += rangeOffset;
|
||||
|
||||
if (verticalOffset)
|
||||
if (verticalOffset && _runs[i].elem)
|
||||
{
|
||||
_runs[i].elem.top = (_runs[i].elem.top + verticalOffset) + 'px';
|
||||
_runs[i].DOMpatched = YES;
|
||||
|
||||
@@ -138,6 +138,9 @@ var kDelegateRespondsTo_textShouldBeginEditing
|
||||
int _stickyXLocation;
|
||||
|
||||
CPArray _selectionSpans;
|
||||
CPView _observedClipView;
|
||||
CGRect _exposedRect;
|
||||
|
||||
CPTimer _scrollingTimer;
|
||||
}
|
||||
|
||||
@@ -248,6 +251,86 @@ var kDelegateRespondsTo_textShouldBeginEditing
|
||||
|
||||
[super _addObservers];
|
||||
[self _setObserveWindowKeyNotifications:YES];
|
||||
[self _startObservingClipView];
|
||||
}
|
||||
- (void)_startObservingClipView
|
||||
{
|
||||
if (!_observedClipView)
|
||||
return;
|
||||
|
||||
var defaultCenter = [CPNotificationCenter defaultCenter];
|
||||
|
||||
[_observedClipView setPostsFrameChangedNotifications:YES];
|
||||
[_observedClipView setPostsBoundsChangedNotifications:YES];
|
||||
|
||||
[defaultCenter addObserver:self
|
||||
selector:@selector(superviewFrameChanged:)
|
||||
name:CPViewFrameDidChangeNotification
|
||||
object:_observedClipView];
|
||||
|
||||
[defaultCenter addObserver:self
|
||||
selector:@selector(superviewBoundsChanged:)
|
||||
name:CPViewBoundsDidChangeNotification
|
||||
object:_observedClipView];
|
||||
}
|
||||
- (CGRect)exposedRect
|
||||
{
|
||||
if (!_exposedRect)
|
||||
{
|
||||
var superview = [self superview];
|
||||
|
||||
if ([superview isKindOfClass:[CPClipView class]])
|
||||
_exposedRect = [superview bounds];
|
||||
else
|
||||
_exposedRect = [self bounds];
|
||||
}
|
||||
|
||||
return _exposedRect;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
*/
|
||||
- (void)superviewBoundsChanged:(CPNotification)aNotification
|
||||
{
|
||||
_exposedRect = nil;
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
*/
|
||||
- (void)superviewFrameChanged:(CPNotification)aNotification
|
||||
{
|
||||
_exposedRect = nil;
|
||||
}
|
||||
|
||||
- (void)viewWillMoveToSuperview:(CPView)aView
|
||||
{
|
||||
if ([aView isKindOfClass:[CPClipView class]])
|
||||
_observedClipView = aView;
|
||||
else
|
||||
[self _stopObservingClipView];
|
||||
|
||||
[super viewWillMoveToSuperview:aView];
|
||||
}
|
||||
|
||||
- (void)_stopObservingClipView
|
||||
{
|
||||
if (!_observedClipView)
|
||||
return;
|
||||
|
||||
var defaultCenter = [CPNotificationCenter defaultCenter];
|
||||
|
||||
[defaultCenter removeObserver:self
|
||||
name:CPViewFrameDidChangeNotification
|
||||
object:_observedClipView];
|
||||
|
||||
[defaultCenter removeObserver:self
|
||||
name:CPViewBoundsDidChangeNotification
|
||||
object:_observedClipView];
|
||||
|
||||
_observedClipView = nil;
|
||||
}
|
||||
|
||||
- (void)_windowDidResignKey:(CPNotification)aNotification
|
||||
|
||||
Reference in New Issue
Block a user