Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
Fix div in list which cause weexcore render objects not ordered. (#1602)
Browse files Browse the repository at this point in the history
* [Core] Refactor. Remove useless "_isNeedJoinLayoutSystem".

* [Core] Refactor. div inside list, we add div to subcomponents of list, but do not display it.
  • Loading branch information
wqyfavor authored and cxfeng1 committed Sep 30, 2018
1 parent ae6fdb5 commit f009d29
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ - (instancetype)initWithRef:(NSString *)ref
}
_templateCaseType = attributes[@"case"] ? [WXConvert NSString:attributes[@"case"]] :const_cast<NSString *>(WXDefaultRecycleTemplateType);
_lazyCreateView = YES;
_isNeedJoinLayoutSystem = NO;
}

return self;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ - (void)updateBindingData:(NSDictionary *)data
if (!needDisplay) {
self.displayType = WXDisplayTypeNone;
return;
} else if (needDisplay && !_isNeedJoinLayoutSystem) {
} else if (needDisplay) {
self.displayType = WXDisplayTypeBlock;
}
}
Expand Down
1 change: 0 additions & 1 deletion ios/sdk/WeexSDK/Sources/Component/WXCellComponent.mm
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ - (instancetype)initWithRef:(NSString *)ref type:(NSString *)type styles:(NSDict
_deleteAnimation = [WXConvert UITableViewRowAnimation:attributes[@"deleteAnimation"]];
_keepScrollPosition = attributes[@"keepScrollPosition"] ? [WXConvert BOOL:attributes[@"keepScrollPosition"]] : NO;
_lazyCreateView = YES;
_isNeedJoinLayoutSystem = NO;
if (attributes[@"zIndex"]) {
_zIndex = [WXConvert NSString:attributes[@"zIndex"]];
}
Expand Down
3 changes: 1 addition & 2 deletions ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,9 @@ typedef id (^WXDataBindingBlock)(NSDictionary *data, BOOL *needUpdate);
WXBorderStyle _borderBottomStyle;
WXBorderStyle _borderLeftStyle;


BOOL _isViewTreeIgnored; // Component is added to super, but it is not added to views.
BOOL _isFixed;
BOOL _async;
BOOL _isNeedJoinLayoutSystem;
BOOL _lazyCreateView;

WXTransform *_transform;
Expand Down
1 change: 0 additions & 1 deletion ios/sdk/WeexSDK/Sources/Component/WXHeaderComponent.mm
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ - (instancetype)initWithRef:(NSString *)ref type:(NSString *)type styles:(NSDict

if (self) {
_async = YES;
_isNeedJoinLayoutSystem = NO;
_keepScrollPosition = attributes[@"keepScrollPosition"] ? [WXConvert BOOL:attributes[@"keepScrollPosition"]] : NO;
}

Expand Down
2 changes: 1 addition & 1 deletion ios/sdk/WeexSDK/Sources/Component/WXListComponent.mm
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ - (BOOL)_insertSubcomponent:(WXComponent *)subcomponent atIndex:(NSInteger)index
&& ![subcomponent isKindOfClass:[WXLoadingComponent class]]
&& subcomponent->_positionType != WXPositionTypeFixed) {
WXLogError(@"list only support cell/header/refresh/loading/fixed-component as child.");
return NO;
subcomponent->_isViewTreeIgnored = YES; // do not show this element.
}

BOOL inserted = [super _insertSubcomponent:subcomponent atIndex:index];
Expand Down
5 changes: 0 additions & 5 deletions ios/sdk/WeexSDK/Sources/Model/WXComponent.mm
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ - (instancetype)initWithRef:(NSString *)ref
_absolutePosition = CGPointMake(NAN, NAN);

_displayType = WXDisplayTypeBlock;
_isNeedJoinLayoutSystem = YES;
_isViewFrameSyncWithCalculated = YES;
_ariaHidden = nil;
_accessible = nil;
Expand Down Expand Up @@ -323,13 +322,11 @@ - (void)setDisplayType:(WXDisplayType)displayType
if (_displayType != displayType) {
_displayType = displayType;
if (displayType == WXDisplayTypeNone) {
_isNeedJoinLayoutSystem = NO;
[self _removeFromSupercomponent];
WXPerformBlockOnMainThread(^{
[self removeFromSuperview];
});
} else {
_isNeedJoinLayoutSystem = YES;
WXPerformBlockOnMainThread(^{
[self _buildViewHierarchyLazily];
// TODO: insert into the correct index
Expand Down Expand Up @@ -594,7 +591,6 @@ - (BOOL)_insertSubcomponent:(WXComponent *)subcomponent atIndex:(NSInteger)index

if (subcomponent->_positionType == WXPositionTypeFixed) {
[self.weexInstance.componentManager addFixedComponent:subcomponent];
subcomponent->_isNeedJoinLayoutSystem = NO;
}

if (_useCompositing || _isCompositingChild) {
Expand Down Expand Up @@ -628,7 +624,6 @@ - (void)_removeFromSupercomponent:(BOOL)remove

if (_positionType == WXPositionTypeFixed) {
[self.weexInstance.componentManager removeFixedComponent:self];
self->_isNeedJoinLayoutSystem = YES;
}
if (_positionType == WXPositionTypeSticky) {
[self.ancestorScroller removeStickyComponent:self];
Expand Down
13 changes: 11 additions & 2 deletions ios/sdk/WeexSDK/Sources/View/WXComponent+ViewManagement.mm
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,17 @@ - (void)insertSubview:(WXComponent *)subcomponent atIndex:(NSInteger)index
if (subcomponent.displayType == WXDisplayTypeNone) {
return;
}

if (_isViewTreeIgnored) {
// self not added to views, children also ignored.
subcomponent->_isViewTreeIgnored = YES;
return;
}

if (subcomponent->_isViewTreeIgnored) {
// children not added to views, such as div in list, we do not create view.
return;
}

WX_CHECK_COMPONENT_TYPE(self.componentType)
if (subcomponent->_positionType == WXPositionTypeFixed) {
Expand Down Expand Up @@ -230,10 +241,8 @@ - (void)_updateViewStyles:(NSDictionary *)styles
WXPerformBlockOnComponentThread(^{
if (positionType == WXPositionTypeFixed) {
[self.weexInstance.componentManager addFixedComponent:self];
_isNeedJoinLayoutSystem = NO;
} else if (_positionType == WXPositionTypeFixed) {
[self.weexInstance.componentManager removeFixedComponent:self];
_isNeedJoinLayoutSystem = YES;
}

_positionType = positionType;
Expand Down

0 comments on commit f009d29

Please sign in to comment.