use of com.taobao.weex.dom.WXDomObject in project incubator-weex by apache.
the class Statements method copyComponentTree.
/**
* recursive copy component,
*/
private static final WXComponent copyComponentTree(WXComponent source, WXVContainer parent) {
WXDomObject node = (WXDomObject) source.getDomObject();
WXComponent component = WXComponentFactory.newInstance(source.getInstance(), node, parent);
if (source instanceof WXVContainer) {
WXVContainer container = (WXVContainer) source;
WXVContainer childParent = (WXVContainer) component;
WXDomObject childParentNode = (WXDomObject) childParent.getDomObject();
int count = container.getChildCount();
for (int i = 0; i < count; ++i) {
WXComponent child = container.getChild(i);
if (child != null) {
WXComponent targetChild = copyComponentTree(child, childParent);
childParent.addChild(targetChild);
childParentNode.add((WXDomObject) targetChild.getDomObject(), -1);
}
}
}
// copy info need be sync
if (source.isWaste()) {
component.setWaste(true);
}
return component;
}
use of com.taobao.weex.dom.WXDomObject in project incubator-weex by apache.
the class WXComponent method setWaste.
/**
* mark node waste,
* if node is waster should hidden, and dom tree should allow not show
*/
public void setWaste(boolean waste) {
if (this.waste != waste) {
this.waste = waste;
WXDomObject domObject = (WXDomObject) getDomObject();
if (waste) {
// update dom not show, and put style to hidden
domObject.setVisible(false);
domObject.getStyles().put(Constants.Name.VISIBILITY, Constants.Value.HIDDEN);
// if component not init, mark lazy init when use, reduce view count
if (getHostView() == null) {
if (!mLazy) {
lazy(true);
}
} else {
getHostView().setVisibility(View.GONE);
}
} else {
domObject.setVisible(true);
domObject.getStyles().put(Constants.Name.VISIBILITY, Constants.Value.VISIBLE);
if (getHostView() == null) {
if (mLazy) {
// when parent is lazy just mark node lazy false
if (mParent != null && mParent.isLazy()) {
lazy(false);
} else {
ComponentUtils.initLazyComponent(this, mParent);
}
}
} else {
getHostView().setVisibility(View.VISIBLE);
}
}
}
}
use of com.taobao.weex.dom.WXDomObject in project WeexErosFramework by bmfe.
the class BMRich method organizeChild.
private void organizeChild(WXDomObject object) {
if (object instanceof WXTextDomObject) {
WXTextDomObject textDomObject = (WXTextDomObject) object;
BMRichUtil util = new BMRichUtil();
Spanned test = util.createSpan(textDomObject.getAttrs(), textDomObject.getStyles());
SpannableString spannableString = ((SpannableString) test);
Object[] spans = spannableString.getSpans(0, spannableString.length(), Object.class);
for (Object span : spans) {
mSpans.add(new RichTextDomObject.BMRichSpan(span, mText.length(), spannableString.length() + mText.length()));
}
// 设置span的事件
WXEvent events = object.getEvents();
for (String event : events) {
appendChildEvent(event, spannableString, textDomObject);
}
mText.append(spannableString.toString());
spannableStringBuilder.append(spannableString);
}
update();
}
use of com.taobao.weex.dom.WXDomObject in project WeexErosFramework by bmfe.
the class BMPop method getAnimationHeight.
private void getAnimationHeight() {
WXDomObject wxDomObject = (WXDomObject) getDomObject();
if (wxDomObject == null)
return;
WXStyle wxStyle = wxDomObject.getStyles();
Object object = wxStyle.get("height");
if (object == null)
return;
mHeight = Integer.valueOf(object.toString());
}
use of com.taobao.weex.dom.WXDomObject in project weex-example by KalicyZhou.
the class WXListComponentTest method testParseTransforms.
@Test
public void testParseTransforms() throws Exception {
WXDiv div = WXDivTest.create();
ComponentTest.create(div);
WXDomObject dom = new WXListDomObject();
dom.getAttrs().put(WXListComponent.TRANSFORM, "scale(0.9,0.8);translate(10,20);opacity(0.5);rotate(100)");
component = create(div, dom);
ComponentTest.create(component);
}
Aggregations