mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-10-06 09:02:50 +00:00
Fixed: This PR adapts views and custom views decoding to fix "not ready view" bugs (#2917)
This commit is contained in:
1 parent
1282f1ac0e
commit
48e786e8b5
2 files changed
+27
-12
No files matched your search
+11
-11
@@ -3781,16 +3781,21 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask",
|
||||
// Also decode these "early".
|
||||
_frame = [aCoder decodeRectForKey:CPViewFrameKey];
|
||||
_bounds = [aCoder decodeRectForKey:CPViewBoundsKey];
|
||||
_scaleSize = [aCoder containsValueForKey:CPViewScaleKey] ? [aCoder decodeSizeForKey:CPViewScaleKey] : CGSizeMake(1.0, 1.0);
|
||||
_hierarchyScaleSize = [aCoder containsValueForKey:CPViewSizeScaleKey] ? [aCoder decodeSizeForKey:CPViewSizeScaleKey] : CGSizeMake(1.0, 1.0);
|
||||
_isScaled = [aCoder containsValueForKey:CPViewIsScaledKey] ? [aCoder decodeBoolForKey:CPViewIsScaledKey] : NO;
|
||||
_subviews = @[];
|
||||
|
||||
// Trying to fix "not ready" views
|
||||
_trackingAreas = [aCoder decodeObjectForKey:CPViewTrackingAreasKey] || @[];
|
||||
|
||||
[self _decodeThemeObjectsWithCoder:aCoder];
|
||||
[self setAppearance:[aCoder decodeObjectForKey:CPViewAppearanceKey]];
|
||||
|
||||
self = [super initWithCoder:aCoder];
|
||||
|
||||
if (self)
|
||||
{
|
||||
_trackingAreas = [aCoder decodeObjectForKey:CPViewTrackingAreasKey];
|
||||
|
||||
if (!_trackingAreas)
|
||||
_trackingAreas = [];
|
||||
|
||||
// We have to manually check because it may be 0, so we can't use ||
|
||||
_tag = [aCoder containsValueForKey:CPViewTagKey] ? [aCoder decodeIntForKey:CPViewTagKey] : -1;
|
||||
_identifier = [aCoder decodeObjectForKey:CPReuseIdentifierKey];
|
||||
@@ -3799,7 +3804,6 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask",
|
||||
_superview = [aCoder decodeObjectForKey:CPViewSuperviewKey];
|
||||
// We have to manually add the subviews so that they will receive
|
||||
// viewWillMoveToSuperview: and viewDidMoveToSuperview:
|
||||
_subviews = [];
|
||||
|
||||
var subviews = [aCoder decodeObjectForKey:CPViewSubviewsKey] || [];
|
||||
|
||||
@@ -3828,10 +3832,6 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask",
|
||||
if (_toolTip)
|
||||
[self _installToolTipEventHandlers];
|
||||
|
||||
_scaleSize = [aCoder containsValueForKey:CPViewScaleKey] ? [aCoder decodeSizeForKey:CPViewScaleKey] : CGSizeMake(1.0, 1.0);
|
||||
_hierarchyScaleSize = [aCoder containsValueForKey:CPViewSizeScaleKey] ? [aCoder decodeSizeForKey:CPViewSizeScaleKey] : CGSizeMake(1.0, 1.0);
|
||||
_isScaled = [aCoder containsValueForKey:CPViewIsScaledKey] ? [aCoder decodeBoolForKey:CPViewIsScaledKey] : NO;
|
||||
|
||||
// DOM SETUP
|
||||
#if PLATFORM(DOM)
|
||||
_cssStylePreviousState = @[];
|
||||
@@ -3862,12 +3862,12 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask",
|
||||
|
||||
[self setBackgroundColor:[aCoder decodeObjectForKey:CPViewBackgroundColorKey]];
|
||||
[self _setupViewFlags];
|
||||
[self _decodeThemeObjectsWithCoder:aCoder];
|
||||
|
||||
[self setAppearance:[aCoder decodeObjectForKey:CPViewAppearanceKey]];
|
||||
// Set the current appearance to something that can't be the correct one so it will recalculate it at the first layout.
|
||||
_currentAppearance = _frame;
|
||||
|
||||
[self updateTrackingAreas];
|
||||
[self setNeedsDisplay:YES];
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
@@ -118,9 +118,24 @@ var _CPCibCustomViewClassNameKey = @"_CPCibCustomViewClassNameKey";
|
||||
[view setAlphaValue:[self alphaValue]];
|
||||
[view setIdentifier:[self identifier]];
|
||||
|
||||
// Trying to fix not ready view bug (or running condition)
|
||||
view._appearance = self._appearance;
|
||||
view._theme = self._theme;
|
||||
|
||||
if (view._themeState == CPThemeStateNormal)
|
||||
view._themeState = self._themeState;
|
||||
|
||||
view._themeAttributes = self._themeAttributes;
|
||||
view._themeClass = [theClass themeClass];
|
||||
|
||||
[view _loadThemeAttributes];
|
||||
|
||||
[_superview replaceSubview:self with:view];
|
||||
|
||||
[view setBackgroundColor:[self backgroundColor]];
|
||||
var backgroundColor = [self backgroundColor];
|
||||
|
||||
if (backgroundColor)
|
||||
[view setBackgroundColor:backgroundColor];
|
||||
}
|
||||
|
||||
return view;
|
||||
|
||||
Reference in new issue
Block a user