Permalink
Browse files

fine tune performance

  • Loading branch information...
1 parent f2d9295 commit e7ae0e8faa1bcff899dda8b9f19add81bff972aa @jumperchen jumperchen committed Sep 27, 2012
@@ -103,5 +103,5 @@ zhtml.Widget = zk.$extends(zk.Widget, {
this.domUnlisten_(this.$n(), 'onChange');
this.$supers(zhtml.Widget, 'unbind_', arguments);
},
- redraw: zk.Native.prototype.redraw
+ redraw: zk.Native.$redraw
});
@@ -2898,15 +2898,15 @@ unbind_: function (skipper, after) {
if (sz.height !== undefined) {
if (sz.height == 'auto')
n.style.height = '';
- else if (sz.height != '' || sz.height === 0) //bug #2943174, #2979776, ZK-1159
+ else if (sz.height != '' || (sz.height === 0 && !this.isFloating_())) //bug #2943174, #2979776, ZK-1159, ZK-1358
this.setFlexSizeH_(n, zkn, sz.height, isFlexMin);
else
n.style.height = this._height || '';
}
if (sz.width !== undefined) {
if (sz.width == 'auto')
n.style.width = '';
- else if (sz.width != '' || sz.width === 0) //bug #2943174, #2979776, ZK-1159
+ else if (sz.width != '' || (sz.width === 0 && !this.isFloating_())) //bug #2943174, #2979776, ZK-1159, ZK-1358
this.setFlexSizeW_(n, zkn, sz.width, isFlexMin);
else
n.style.width = this._width || '';
@@ -4815,13 +4815,14 @@ zk.Page = zk.$extends(zk.Widget, {
* of all child widgets.
* @param Array out an array of HTML fragments.
*/
- redraw: function (out) {
+ redraw: _zkf = function (out) {
out.push('<div', this.domAttrs_(), '>');
for (var w = this.firstChild; w; w = w.nextSibling)
w.redraw(out);
out.push('</div>');
}
},{
+ $redraw: _zkf,
/** An array of contained pages (i.e., a standalone ZK page but included by other technology).
* For example, a ZUL age that is included by a JSP page.
* A contained page usually covers a portion of the browser window.
@@ -4865,7 +4866,7 @@ zk.Native = zk.$extends(zk.Widget, {
return !subId && this.id ? jq('#' + this.id):
this.$supers('$n', arguments); // Bug ZK-606/607
},
- redraw: function (out) {
+ redraw: _zkf = function (out) {
var s = this.prolog, p;
if (s) {
//Bug ZK-606/607: hflex/vflex and many components need to know
@@ -4902,6 +4903,8 @@ zk.Native = zk.$extends(zk.Widget, {
s = this.epilog;
if (s) out.push(s);
}
+}, {
+ $redraw: _zkf
});
/** A macro widget.
@@ -30,8 +30,14 @@ it will be useful, but WITHOUT ANY WARRANTY.
_stamps = [],
_t0 = jq.now();
- function newClass() {
- return function () {
+ function newClass(copy) {
+ var init = function () {
+ if (!init.$copied) {
+ init.$copied = true;
+ var cf = init.$copyf;
+ delete init.$copyf;
+ cf();
+ }
this.$oid = ++_oid;
this.$init.apply(this, arguments);
@@ -42,6 +48,9 @@ it will be useful, but WITHOUT ANY WARRANTY.
ais[j].call(this);
}
};
+ init.$copyf = copy;
+ init.$copied = !init.$copyf;
+ return init;
}
function regClass(jclass, superclass) {
var oid = jclass.$oid = ++_oid;
@@ -81,7 +90,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
function defSet11(nm, before, after) {
return function (v, opts) {
var o = this[nm];
- this[nm] = v = before.apply(this, arguments);;
+ this[nm] = v = before.apply(this, arguments);
if (o !== v || (opts && opts.force))
after.apply(this, arguments);
return this;
@@ -668,17 +677,34 @@ foo.Widget = zk.$extends(zk.Widget, {
if (!superclass)
throw 'unknown superclass';
- var jclass = newClass(),
- thispt = jclass.prototype,
- superpt = superclass.prototype,
- define = members['$define'];
- delete members['$define'];
- zk.copy(thispt, superpt); //inherit non-static
- zk.define(jclass, define);
- zk.copy(thispt, members);
-
+ var superpt = superclass.prototype,
+ jclass = newClass(function () {
+ if (superclass.$copyf && !superclass.$copied) {
+ superclass.$copyf();
+ superclass.$copied = true;
+ }
+ var define = members['$define'],
+ superpt = superclass.prototype,
+ thispt = jclass.prototype;
+
+ delete members['$define'];
+ for (var p in superpt) //inherit non-static
+ if ('|_$super|_$subs|className|$class|_$extds|superclass|widgetName|'.indexOf('|'+p+'|') < 0)
+ thispt[p] = superpt[p];
+
+ zk.define(jclass, define);
+ zk.copy(thispt, members);
+ }),
+ thispt = jclass.prototype;
+
+ var zf;
+ if (!(zf = zk.feature) || !zf.ee) {
+ jclass.$copyf();
+ jclass.$copied = true;
+ }
+
for (var p in superclass) //inherit static
- if (p != 'prototype')
+ if ('|prototype|$copyf|$copied|'.indexOf('|'+p+'|') < 0)
jclass[p] = superclass[p];
zk.copy(jclass, staticMembers);
@@ -781,6 +807,15 @@ zk.override(zul.inp.Combobox.prototype, _xCombobox, {
* @see #override(Object, Map, Map)
*/
override: function (dst, backup, src) {
+ if (dst.$class && dst.$class.$copied === false) {
+ var f = dst.$class.$copyf;
+ dst.$class.$copyf = function () {
+ f();
+ zk.override(dst, backup, src);
+ };
+ return dst;
+ }
+
switch (typeof backup) {
case "function":
var old = dst;
@@ -791,7 +826,6 @@ zk.override(zul.inp.Combobox.prototype, _xCombobox, {
_overrideSub(dst, backup, dst['$'+backup] = dst[backup], dst[backup] = src, true);
return dst;
}
-
for (var nm in src)
_overrideSub(dst, nm, backup[nm] = dst[nm], dst[nm] = src[nm]);
return dst;
@@ -14,4 +14,4 @@ Copyright (C) 2008 Potix Corporation. All Rights Reserved.
{{IS_RIGHT
}}IS_RIGHT
*/
-zul.inp.ComboWidget.prototype.redraw_
+zul.inp.ComboWidget.$redraw
@@ -28,7 +28,9 @@ zul.grid.Column = zk.$extends(zul.mesh.SortWidget, {
/** Returns the grid that contains this column.
* @return zul.grid.Grid
*/
- getGrid: zul.mesh.HeaderWidget.prototype.getMeshWidget,
+ getGrid: function () {
+ return this.parent ? this.parent.parent : null;
+ },
$init: function () {
this.$supers('$init', arguments);
@@ -22,7 +22,9 @@ zul.grid.Columns = zk.$extends(zul.mesh.ColumnMenuWidget, {
/** Returns the grid that contains this columns.
* @return zul.grid.Grid
*/
- getGrid: zul.mesh.HeadWidget.prototype.getMeshWidget,
+ getGrid: function () {
+ return this.parent;
+ },
rerender: function () {
if (this.desktop) {
if (this.parent)
@@ -359,41 +359,6 @@ zul.inp.ComboWidget = zk.$extends(zul.inp.InputWidget, {
getPopupSize_: function (pp) {
return ['auto', 'auto'];
},
-
- /** Utility to implement {@link #redraw}.
- * @param Array out an array of HTML fragments.
- */
- redraw_: function (out) {
- var uuid = this.uuid,
- zcls = this.getZclass(),
- isButtonVisible = this._buttonVisible;
-
- out.push('<i', this.domAttrs_({text:true}), '><input id="',
- uuid, '-real" class="', zcls, '-inp');
-
- if(!isButtonVisible)
- out.push(' ', zcls, '-right-edge');
-
- out.push('" autocomplete="off"',
- this.textAttrs_(), '/><i id="', uuid, '-btn" class="',
- zcls, '-btn');
-
- if (this.inRoundedMold()) {
- if (!isButtonVisible)
- out.push(' ', zcls, '-btn-right-edge');
- if (this._readonly)
- out.push(' ', zcls, '-btn-readonly');
- if (zk.ie6_ && !isButtonVisible && this._readonly)
- out.push(' ', zcls, '-btn-right-edge-readonly');
- } else if (!isButtonVisible)
- out.push('" style="display:none');
-
- out.push('"><div class="', zcls, '-btn-icon"></div></i>');
-
- this.redrawpp_(out);
-
- out.push('</i>');
- },
/** Called by {@link #redraw_} to redraw popup.
* <p>Default: does nothing
* @param Array out an array of HTML fragments.
@@ -547,5 +512,41 @@ zul.inp.ComboWidget = zk.$extends(zul.inp.InputWidget, {
if (this._shadow) this._shadow.sync();
},
onChildRemoved_: _zkf,
- onChildVisible_: _zkf
+ onChildVisible_: _zkf,
+ /** Utility to implement {@link #redraw}.
+ * @param Array out an array of HTML fragments.
+ */
+ redraw_: _zkf = function (out) {
+ var uuid = this.uuid,
+ zcls = this.getZclass(),
+ isButtonVisible = this._buttonVisible;
+
+ out.push('<i', this.domAttrs_({text:true}), '><input id="',
+ uuid, '-real" class="', zcls, '-inp');
+
+ if(!isButtonVisible)
+ out.push(' ', zcls, '-right-edge');
+
+ out.push('" autocomplete="off"',
+ this.textAttrs_(), '/><i id="', uuid, '-btn" class="',
+ zcls, '-btn');
+
+ if (this.inRoundedMold()) {
+ if (!isButtonVisible)
+ out.push(' ', zcls, '-btn-right-edge');
+ if (this._readonly)
+ out.push(' ', zcls, '-btn-readonly');
+ if (zk.ie6_ && !isButtonVisible && this._readonly)
+ out.push(' ', zcls, '-btn-right-edge-readonly');
+ } else if (!isButtonVisible)
+ out.push('" style="display:none');
+
+ out.push('"><div class="', zcls, '-btn-icon"></div></i>');
+
+ this.redrawpp_(out);
+
+ out.push('</i>');
+ }
+}, {
+ $redraw: _zkf
});
@@ -12,4 +12,4 @@ Copyright (C) 2009 Potix Corporation. All Rights Reserved.
This program is distributed under LGPL Version 2.1 in the hope that
it will be useful, but WITHOUT ANY WARRANTY.
*/
-zul.inp.Bandbox.prototype.redraw_
+zul.inp.ComboWidget.$redraw
@@ -12,4 +12,4 @@ Copyright (C) 2009 Potix Corporation. All Rights Reserved.
This program is distributed under LGPL Version 2.1 in the hope that
it will be useful, but WITHOUT ANY WARRANTY.
*/
-zul.inp.Combobox.prototype.redraw_
+zul.inp.ComboWidget.$redraw
@@ -46,13 +46,17 @@ zul.layout.East = zk.$extends(_zkf = zul.layout.LayoutRegion, {
* {@link #getWidth()}.
* @return String
*/
- getSize: _zkf.prototype.getWidth,
+ getSize: function () {
+ return this.$supers('getWidth', arguments);
+ },
/**
* Sets the size of this region. This method is shortcut for
* {@link #setWidth(String)}.
* @param String size
*/
- setSize: _zkf.prototype.setWidth,
+ setSize: function () {
+ return this.$supers('setWidth', arguments);
+ },
_ambit2: function (ambit, mars, split) {
ambit.w += split.offsetWidth;
@@ -42,13 +42,17 @@ zul.layout.North = zk.$extends(_zkf = zul.layout.LayoutRegion, {
* {@link #getHeight()}.
* @return String
*/
- getSize: _zkf.prototype.getHeight,
+ getSize: function () {
+ return this.$supers('getHeight', arguments);
+ },
/**
* Sets the size of this region. This method is shortcut for
* {@link #setHeight(String)}.
* @param String size
*/
- setSize: _zkf.prototype.setHeight,
+ setSize: function () {
+ return this.$supers('setHeight', arguments);
+ },
_ambit2: function (ambit, mars, split) {
ambit.w = mars.left + mars.right;
@@ -42,13 +42,17 @@ zul.layout.South = zk.$extends(_zkf = zul.layout.LayoutRegion, {
* {@link #getHeight()}.
* @return String
*/
- getSize: _zkf.prototype.getHeight,
+ getSize: function () {
+ return this.$supers('getHeight', arguments);
+ },
/**
* Sets the size of this region. This method is shortcut for
* {@link #setHeight(String)}.
* @param String size
*/
- setSize: _zkf.prototype.setHeight,
+ setSize: function () {
+ return this.$supers('setHeight', arguments);
+ },
_ambit2: function (ambit, mars, split) {
ambit.w = mars.left + mars.right;
@@ -46,13 +46,17 @@ zul.layout.West = zk.$extends(_zkf = zul.layout.LayoutRegion, {
* {@link #getWidth()}.
* @return String
*/
- getSize: _zkf.prototype.getWidth,
+ getSize: function () {
+ return this.$supers('getWidth', arguments);
+ },
/**
* Sets the size of this region. This method is shortcut for
* {@link #setWidth(String)}.
* @param String size
*/
- setSize: _zkf.prototype.setWidth,
+ setSize: function () {
+ return this.$supers('setWidth', arguments);
+ },
_ambit2: function (ambit, mars, split) {
ambit.w += split.offsetWidth;
@@ -214,7 +214,12 @@ zul.menu.Menuitem = zk.$extends(zul.LabelImageWidget, {
/** Returns the {@link Menubar} that contains this menuitem, or null if not available.
* @return zul.menu.Menubar
*/
- getMenubar: zul.menu.Menu.prototype.getMenubar,
+ getMenubar: function () {
+ for (var p = this.parent; p; p = p.parent)
+ if (p.$instanceof(zul.menu.Menubar))
+ return p;
+ return null;
+ },
bind_: function () {
this.$supers(zul.menu.Menuitem, 'bind_', arguments);
Oops, something went wrong.

0 comments on commit e7ae0e8

Please sign in to comment.