You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by zs...@apache.org on 2017/04/10 02:46:16 UTC
[1/4] incubator-weex git commit: add a member in WXComponent to flag
the component have no view
Repository: incubator-weex
Updated Branches:
refs/heads/0.12-dev 43eb4dfcd -> 35a3f8c21
add a member in WXComponent to flag the component have no view
commonly component always has a host view, but some times maybe not,
such as a svg label, the sub component like defs will not have a
hostview, infact, the ellipse has no view too, it just tell us need to
draw a ellipse to it's parent compoent's hostview.
example:
<svg width="100%" height="100%" version="1.1"
xmlns="http://www.w3.org/2000/svg">
<defs>
<linearGradient id="orange_red" x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" style="stop-color:rgb(255,255,0);
stop-opacity:1"/>
<stop offset="100%" style="stop-color:rgb(255,0,0);
stop-opacity:1"/>
</linearGradient>
</defs>
<ellipse cx="200" cy="190" rx="85" ry="55"
style="fill:url(#orange_red)"/>
</svg>
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/babfa411
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/babfa411
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/babfa411
Branch: refs/heads/0.12-dev
Commit: babfa411709212973e1bb4f2807f692ff0e174b9
Parents: 41c8ef6
Author: littleseven <70...@qq.com>
Authored: Thu Apr 6 16:44:39 2017 +0800
Committer: littleseven <70...@qq.com>
Committed: Thu Apr 6 16:44:39 2017 +0800
----------------------------------------------------------------------
.../taobao/weex/ui/component/WXComponent.java | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/babfa411/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java
index 44e6c23..7e7259f 100755
--- a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java
@@ -230,6 +230,10 @@ public abstract class WXComponent<T extends View> implements IWXObject, IWXActi
private PesudoStatus mPesudoStatus = new PesudoStatus();
private boolean mIsDestroyed = false;
private boolean mIsDisabled = false;
+ private int mType = TYPE_COMMON;
+
+ public static final int TYPE_COMMON = 0;
+ public static final int TYPE_VIRTUAL = 1;
//Holding the animation bean when component is uninitialized
public void postAnimation(WXAnimationModule.AnimationHolder holder) {
@@ -318,9 +322,14 @@ public abstract class WXComponent<T extends View> implements IWXObject, IWXActi
}
public WXComponent(WXSDKInstance instance, WXDomObject dom, WXVContainer parent) {
+ this(instance, dom, parent, TYPE_COMMON);
+ }
+
+ public WXComponent(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, int type) {
mInstance = instance;
mContext = mInstance.getContext();
mParent = parent;
+ mType = type;
mDomObj = dom.clone();
mCurrentRef = mDomObj.getRef();
mGestureType = new HashSet<>();
@@ -635,7 +644,7 @@ public abstract class WXComponent<T extends View> implements IWXObject, IWXActi
@Deprecated
public void updateProperties(Map<String, Object> props) {
- if (props == null || mHost == null) {
+ if (props == null || (mHost == null && !isVirtualComponent())) {
return;
}
@@ -966,7 +975,7 @@ public abstract class WXComponent<T extends View> implements IWXObject, IWXActi
protected void createViewImpl() {
if (mContext != null) {
mHost = initComponentHostView(mContext);
- if (mHost == null) {
+ if (mHost == null && !isVirtualComponent()) {
//compatible
initView();
}
@@ -1431,11 +1440,15 @@ public abstract class WXComponent<T extends View> implements IWXObject, IWXActi
* @return false component add subview
*/
public boolean isVirtualComponent(){
- return false;
+ return mType == TYPE_VIRTUAL;
}
public void removeVirtualComponent() {
}
+ public void setType(int type) {
+ mType = type;
+ }
+
public boolean hasScrollParent(WXComponent component) {
if (component.getParent() == null) {
return true;
[3/4] incubator-weex git commit: Merge pull request #1 from
yangshengtao/0.12-dev
Posted by zs...@apache.org.
Merge pull request #1 from yangshengtao/0.12-dev
add the component type, when the node is virtual node
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/e4823690
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/e4823690
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/e4823690
Branch: refs/heads/0.12-dev
Commit: e48236900f82c6952501ce3f3a28b23099dfb328
Parents: babfa41 ebb1b0e
Author: \u535c\u9053 <70...@qq.com>
Authored: Thu Apr 6 17:30:20 2017 +0800
Committer: GitHub <no...@github.com>
Committed: Thu Apr 6 17:30:20 2017 +0800
----------------------------------------------------------------------
ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m | 1 +
ios/sdk/WeexSDK/Sources/Model/WXComponent.h | 6 ++++++
ios/sdk/WeexSDK/Sources/Model/WXComponent.m | 5 +++++
ios/sdk/WeexSDK/Sources/Utility/WXDefine.h | 11 +++++++++++
ios/sdk/WeexSDK/Sources/Utility/WXType.h | 5 +++++
.../WeexSDK/Sources/View/WXComponent+ViewManagement.m | 3 +++
6 files changed, 31 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/e4823690/ios/sdk/WeexSDK/Sources/Model/WXComponent.m
----------------------------------------------------------------------
diff --cc ios/sdk/WeexSDK/Sources/Model/WXComponent.m
index cecc708,cfd1dbc..adc252f
--- a/ios/sdk/WeexSDK/Sources/Model/WXComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Model/WXComponent.m
@@@ -450,36 -455,9 +454,37 @@@
}
+- (void)setGradientLayer
+{
+ if (CGRectEqualToRect(self.view.frame, CGRectZero)) {
+ return;
+ }
+ NSDictionary * linearGradient = [WXUtility linearGradientWithBackgroundImage:_backgroundImage];
+ if (!linearGradient) {
+ return ;
+ }
+
+ __weak typeof(self) weakSelf = self;
+ dispatch_async(dispatch_get_main_queue(), ^{
+ __strong typeof(self) strongSelf = weakSelf;
+ /*
+ must insert the gradientLayer at index 0, and then set masksToBounds to match the view bounds
+ or the subview will be invisible
+ */
+
+ if(strongSelf) {
+ UIColor * startColor = (UIColor*)linearGradient[@"startColor"];
+ UIColor * endColor = (UIColor*)linearGradient[@"endColor"];
+ CAGradientLayer * gradientLayer = [WXUtility gradientLayerFromColors:@[startColor, endColor] locations:nil frame:strongSelf.view.bounds gradientType:[linearGradient[@"gradientType"] integerValue]];
+ [strongSelf.view.layer insertSublayer:gradientLayer atIndex:0];
+ strongSelf.view.layer.masksToBounds = YES;
+ }
+ });
+}
+
- (void)_configWXComponentA11yWithAttributes:(NSDictionary *)attributes
{
+ WX_CHECK_COMPONENT_TYPE(self.componentType)
if (attributes[@"role"]){
_role = [WXConvert WXUIAccessibilityTraits:attributes[@"role"]];
self.view.accessibilityTraits = _role;
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/e4823690/ios/sdk/WeexSDK/Sources/View/WXComponent+ViewManagement.m
----------------------------------------------------------------------
[4/4] incubator-weex git commit: Merge branch '0.12-dev' of
https://git-wip-us.apache.org/repos/asf/incubator-weex into 0.12-dev
Posted by zs...@apache.org.
Merge branch '0.12-dev' of https://git-wip-us.apache.org/repos/asf/incubator-weex into 0.12-dev
* '0.12-dev' of https://git-wip-us.apache.org/repos/asf/incubator-weex:
* [test] update slider testcase
+ [ios] add feature timer
* [jsfm] v0.20.3
* [android] fix NPE in move fixed view
* [doc] add scrollToElement animation support
eslint warning
* [jsfm] fix function markupState
call C++ timer instead of WxTimerModule with in week jsfm
* [example] fix banner
* [jsfm] v0.20.2
* [android] disable click event when gesture already consume touch event
* [android] fix the invaild interval time and add testcase
* [android] disable auto scroll on not infinite
* [android] slider improvement
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/35a3f8c2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/35a3f8c2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/35a3f8c2
Branch: refs/heads/0.12-dev
Commit: 35a3f8c2197a4d796bab323d5e0c37712f038909
Parents: e482369 43eb4df
Author: zshshr <zh...@gmail.com>
Authored: Mon Apr 10 10:46:12 2017 +0800
Committer: zshshr <zh...@gmail.com>
Committed: Mon Apr 10 10:46:12 2017 +0800
----------------------------------------------------------------------
.../java/com/taobao/weex/WXSDKInstance.java | 10 ++-
.../taobao/weex/ui/component/WXComponent.java | 4 +
.../com/taobao/weex/ui/component/WXSlider.java | 81 ++++++++++++++++++--
.../taobao/weex/ui/view/WXCircleViewPager.java | 21 +++--
.../taobao/weex/ui/view/gesture/WXGesture.java | 14 ++++
build/webpack.examples.config.js | 4 +-
doc/source/cn/references/modules/dom.md | 3 +-
doc/source/references/modules/dom.md | 3 +-
examples/module/componentRect.we | 4 +-
html5/frameworks/legacy/app/ctrl/init.js | 42 ++++++++--
html5/frameworks/legacy/static/life.js | 8 +-
.../WeexSDK/Sources/Bridge/WXBridgeContext.m | 4 +
ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m | 77 +++++++++++++++++++
.../WeexSDK/Sources/Protocol/WXBridgeProtocol.h | 5 ++
package.json | 6 +-
test/pages/slider-infinite.vue | 49 ++++++++++++
test/scripts/components/slider-infinite.test.js | 38 +++++++++
17 files changed, 342 insertions(+), 31 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/35a3f8c2/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java
----------------------------------------------------------------------
[2/4] incubator-weex git commit: add the component type,
when the node is virtual node, prohibit to create view and update view
Posted by zs...@apache.org.
add the component type, when the node is virtual node, prohibit to create view and update view
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/ebb1b0e9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/ebb1b0e9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/ebb1b0e9
Branch: refs/heads/0.12-dev
Commit: ebb1b0e91f268f99edd30383f3290b823584e330
Parents: 80df1aa
Author: yangshengtao <ya...@163.com>
Authored: Thu Apr 6 17:02:47 2017 +0800
Committer: yangshengtao <ya...@163.com>
Committed: Thu Apr 6 17:02:47 2017 +0800
----------------------------------------------------------------------
ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m | 1 +
ios/sdk/WeexSDK/Sources/Model/WXComponent.h | 6 ++++++
ios/sdk/WeexSDK/Sources/Model/WXComponent.m | 5 +++++
ios/sdk/WeexSDK/Sources/Utility/WXDefine.h | 11 +++++++++++
ios/sdk/WeexSDK/Sources/Utility/WXType.h | 5 +++++
.../WeexSDK/Sources/View/WXComponent+ViewManagement.m | 3 +++
6 files changed, 31 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ebb1b0e9/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m b/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
index 2231d46..d768dda 100644
--- a/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
+++ b/ios/sdk/WeexSDK/Sources/Display/WXComponent+Display.m
@@ -477,6 +477,7 @@ do {\
WX_CHECK_BORDER_PROP_PIXEL(Radius, TopLeft, TopRight, BottomLeft, BottomRight)
if (updating) {
+ WX_CHECK_COMPONENT_TYPE(self.componentType)
BOOL nowNeedsDrawBorder = [self _needsDrawBorder];
if (nowNeedsDrawBorder && !previousNeedsDrawBorder) {
_layer.cornerRadius = 0;
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ebb1b0e9/ios/sdk/WeexSDK/Sources/Model/WXComponent.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Model/WXComponent.h b/ios/sdk/WeexSDK/Sources/Model/WXComponent.h
index a2f75d7..0c5d0f1 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXComponent.h
+++ b/ios/sdk/WeexSDK/Sources/Model/WXComponent.h
@@ -8,6 +8,7 @@
#import <Foundation/Foundation.h>
#import "WXLayoutDefine.h"
+#import "WXType.h"
@class WXSDKInstance;
@@ -61,6 +62,11 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly, copy) NSString *type;
/**
+ * @abstract The component's type.
+ */
+@property (nonatomic, assign) WXComponentType componentType;
+
+/**
* @abstract The component's styles.
*/
@property (nonatomic, readonly, strong) NSDictionary *styles;
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ebb1b0e9/ios/sdk/WeexSDK/Sources/Model/WXComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Model/WXComponent.m b/ios/sdk/WeexSDK/Sources/Model/WXComponent.m
index ba5752a..cfd1dbc 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Model/WXComponent.m
@@ -69,6 +69,7 @@
_ref = ref;
_type = type;
_weexInstance = weexInstance;
+ _componentType = WXComponentTypeCommon;
_styles = [self parseStyles:styles];
_attributes = attributes ? [NSMutableDictionary dictionaryWithDictionary:attributes] : [NSMutableDictionary dictionary];
_events = events ? [NSMutableArray arrayWithArray:events] : [NSMutableArray array];
@@ -175,6 +176,9 @@
- (UIView *)view
{
+ if (_componentType != WXComponentTypeCommon) {
+ return nil;
+ }
if ([self isViewLoaded]) {
return _view;
} else {
@@ -453,6 +457,7 @@
- (void)_configWXComponentA11yWithAttributes:(NSDictionary *)attributes
{
+ WX_CHECK_COMPONENT_TYPE(self.componentType)
if (attributes[@"role"]){
_role = [WXConvert WXUIAccessibilityTraits:attributes[@"role"]];
self.view.accessibilityTraits = _role;
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ebb1b0e9/ios/sdk/WeexSDK/Sources/Utility/WXDefine.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Utility/WXDefine.h b/ios/sdk/WeexSDK/Sources/Utility/WXDefine.h
index 5256555..20d290e 100644
--- a/ios/sdk/WeexSDK/Sources/Utility/WXDefine.h
+++ b/ios/sdk/WeexSDK/Sources/Utility/WXDefine.h
@@ -145,6 +145,17 @@ parts = [parts subarrayWithRange:(NSRange){0, parts.count - 1}];\
*/
#define WX_SYS_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
+/**
+ * @abstract Estimate component's type. If the type isn't equal to WXComponentTypeCommon, then return.
+ */
+#define WX_CHECK_COMPONENT_TYPE(type)\
+do {\
+if (type != WXComponentTypeCommon) {\
+return;\
+}\
+} while (0);
+
+
#if __has_attribute(objc_requires_super)
#define WX_REQUIRES_SUPER __attribute__((objc_requires_super))
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ebb1b0e9/ios/sdk/WeexSDK/Sources/Utility/WXType.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Utility/WXType.h b/ios/sdk/WeexSDK/Sources/Utility/WXType.h
index e00878d..7f3f0c6 100644
--- a/ios/sdk/WeexSDK/Sources/Utility/WXType.h
+++ b/ios/sdk/WeexSDK/Sources/Utility/WXType.h
@@ -9,6 +9,11 @@
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
+typedef NS_ENUM(NSUInteger, WXComponentType) {
+ WXComponentTypeCommon = 0,
+ WXComponentTypeVirtual
+};
+
typedef NS_ENUM(NSUInteger, WXScrollDirection) {
WXScrollDirectionVertical,
WXScrollDirectionHorizontal,
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ebb1b0e9/ios/sdk/WeexSDK/Sources/View/WXComponent+ViewManagement.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/View/WXComponent+ViewManagement.m b/ios/sdk/WeexSDK/Sources/View/WXComponent+ViewManagement.m
index ffc4922..28a2dbb 100644
--- a/ios/sdk/WeexSDK/Sources/View/WXComponent+ViewManagement.m
+++ b/ios/sdk/WeexSDK/Sources/View/WXComponent+ViewManagement.m
@@ -35,6 +35,7 @@
{
WXAssertMainThread();
+ WX_CHECK_COMPONENT_TYPE(self.componentType)
if (subcomponent->_positionType == WXPositionTypeFixed) {
[self.weexInstance.rootView addSubview:subcomponent.view];
return;
@@ -66,6 +67,7 @@
- (void)moveToSuperview:(WXComponent *)newSupercomponent atIndex:(NSUInteger)index
{
+ WX_CHECK_COMPONENT_TYPE(self.componentType)
[self removeFromSuperview];
[newSupercomponent insertSubview:self atIndex:index];
}
@@ -111,6 +113,7 @@
- (void)_updateViewStyles:(NSDictionary *)styles
{
+ WX_CHECK_COMPONENT_TYPE(self.componentType)
if (styles[@"boxShadow"]) {
_lastBoxShadow = _boxShadow;
_boxShadow = styles[@"boxShadow"]?[WXConvert WXBoxShadow:styles[@"boxShadow"] scaleFactor:self.weexInstance.pixelScaleFactor]:nil;