@@ -12138,7 +12138,9 @@ console.log("J2S._getRawDataFromServer " + J2S._serverUrl + " for " + query);
1213812138 return true;
1213912139 }
1214012140 var target = ev.target["data-keycomponent"];
12141- var who = ev.target;
12141+ if (!target) {
12142+ return;
12143+ }
1214212144 var id;
1214312145 switch (ev.type) {
1214412146 case "keypress":
@@ -12159,6 +12161,7 @@ console.log("J2S._getRawDataFromServer " + J2S._serverUrl + " for " + query);
1215912161 J2S.setMouse = function(who, isSwingJS) {
1216012162 // swingjs.api.J2SInterface
1216112163
12164+
1216212165 var checkStopPropagation = function(ev, ui, handled, target) {
1216312166 if (ui && ui.checkStopPropagation$O$Z) {
1216412167 handled = ui.checkStopPropagation$O$Z(ev, handled);
@@ -12291,6 +12294,7 @@ console.log("J2S._getRawDataFromServer " + J2S._serverUrl + " for " + query);
1229112294// Integer.MAX_VALUE);
1229212295 who.applet._processEvent(501, xym, ev, who._frameViewer); // MouseEvent.MOUSE_PRESSED
1229312296 }
12297+
1229412298 return !!(ui || target);
1229512299// return !!target || ui && ui.j2sDoPropagate;
1229612300 });
@@ -12430,6 +12434,35 @@ console.log("J2S._getRawDataFromServer " + J2S._serverUrl + " for " + query);
1243012434
1243112435 }
1243212436
12437+ J2S.unsetMouse = function(who) {
12438+ if (!who)
12439+ return;
12440+ // swingjs.api.J2SInterface
12441+ who.applet = null;
12442+ J2S
12443+ .$bind(
12444+ who,
12445+ 'click mousedown touchstart mousemove touchmove mouseup touchend DOMMouseScroll mousewheel contextmenu mouseleave mouseenter mousemoveoutjsmol',
12446+ null);
12447+ J2S.setMouseOwner(null);
12448+ }
12449+
12450+ J2S.setMouseOwner = function(who, doSet, target) {
12451+ // called for mousedown, mouseup, mouse, jsUnsetMouse,
12452+ // and outsideEvent.teardown, outsideEvent.mouseUp
12453+ if (!who && J2S._mouseOwner)
12454+ J2S._mouseOwner.isDragging = false;
12455+
12456+ who && who.focus();
12457+
12458+ if (!who || doSet)
12459+ J2S._mouseOwner = who;
12460+ else if (J2S._mouseOwner == who)
12461+ J2S._mouseOwner = who = null;
12462+ if (target || !who)
12463+ J2S._mouseTarget = target || null;
12464+ }
12465+
1243312466 J2S._drag = function(who, ev, id) {
1243412467
1243512468 if (id != 503) {
@@ -12459,32 +12492,6 @@ console.log("J2S._getRawDataFromServer " + J2S._serverUrl + " for " + query);
1245912492 return !!(ui || target);
1246012493 }
1246112494
12462- J2S.unsetMouse = function(who) {
12463- if (!who)
12464- return;
12465- // swingjs.api.J2SInterface
12466- who.applet = null;
12467- J2S
12468- .$bind(
12469- who,
12470- 'click mousedown touchstart mousemove touchmove mouseup touchend DOMMouseScroll mousewheel contextmenu mouseleave mouseenter mousemoveoutjsmol',
12471- null);
12472- J2S.setMouseOwner(null);
12473- }
12474-
12475- J2S.setMouseOwner = function(who, doSet, target) {
12476- // called for mousedown, mouseup, mouse, jsUnsetMouse,
12477- // and outsideEvent.teardown, outsideEvent.mouseUp
12478- if (!who && J2S._mouseOwner)
12479- J2S._mouseOwner.isDragging = false;
12480- if (!who || doSet)
12481- J2S._mouseOwner = who;
12482- else if (J2S._mouseOwner == who)
12483- J2S._mouseOwner = who = null;
12484- if (target || !who)
12485- J2S._mouseTarget = target || null;
12486- }
12487-
1248812495 var getMouseModifiers = function(ev, id) {
1248912496 // id needed to properly not assign the InputEvent.ButtonX_DOWN_MASK for an UP operation
1249012497 // and also recognize a drag (503 + buttons pressed
@@ -12521,7 +12528,10 @@ console.log("J2S._getRawDataFromServer " + J2S._serverUrl + " for " + query);
1252112528 if (ev.target == who) {
1252212529 var ui = ev.target["data-ui"];
1252312530 if (ui) {
12524- who = ui.jc.getTopLevelAncestor$().ui.domNode;
12531+ var top = ui.jc.getTopLevelAncestor$();
12532+ if (top)
12533+ who = top.ui.domNode;
12534+ // else we have a popup menu
1252512535 }
1252612536 }
1252712537 var offsets = J2S.$offset(who.id);
@@ -13597,6 +13607,7 @@ console.log("J2S._getRawDataFromServer " + J2S._serverUrl + " for " + query);
1359713607
1359813608// TODO: still a lot of references to window[...]
1359913609
13610+ // BH 1/8/2019 3.2.4.07 fixes String.prototype.to[Upper|Lower]Case$java_util_Locale - using toLocal[Upper|Lower]Case()
1360013611// BH 1/3/2019 3.2.4.07 adds ByteBuffer/CharBuffer support, proper CharSet encoding, including GBK (Standard Chinese)
1360113612
1360213613// see earlier notes at net.sf.j2s.java.core.srcjs/js/devnotes.txt
@@ -14422,82 +14433,51 @@ Clazz.setConsoleDiv = function(d) {
1442214433// which could be a bottle-neck for function calling.
1442314434// This is critical for performance optimization.
1442414435
14425- var _profile = null;
14426- var _profileNoOpt = false; // setting this true will remove Bob's signature optimization
14427-
1442814436var __signatures = "";
1442914437var profilet0;
1443014438var _profileNew = null;
1443114439var _jsid0 = 0;
1443214440
1443314441Clazz.startProfiling = function(doProfile) {
14442+ _profileNew = {};
1443414443 if (typeof doProfile == "number") {
14435- _profileNew = (arguments[1] ? {} : null);
1443614444 _jsid0 = _jsid;
1443714445 setTimeout(function() { var s = "total wall time: " + doProfile + " sec\n" + Clazz.getProfile(); console.log(s); System.out.println(s)}, doProfile * 1000);
14446+ } else if (!doProfile) {
14447+ _jsid = 0;
14448+ _profileNew = null;
1443814449 }
14439- _profile = ((doProfile || arguments.length == 0) && self.JSON && window.performance ? {} : null);
14440- return (_profile ? "use Clazz.getProfile() to show results" : "profiling stopped and cleared")
14450+ return (_profileNew ? "use Clazz.getProfile() to show results" : "profiling stopped and cleared")
1444114451}
1444214452
1444314453var tabN = function(n) { n = ("" + n).split(".")[0]; return "..........".substring(n.length) + n + "\t" };
1444414454
1444514455Clazz.getProfile = function() {
1444614456 var s = "run Clazz.startProfiling() first";
14447- if (_profile) {
14448- var l = [];
14449- var totalcount = 0;
14450- var totalprep = 0;
14451- var totaltime = 0;
14452- for (var name in _profile) {
14453- var n = _profile[name][0];
14454- var t1 = _profile[name][1];
14455- var t2 = _profile[name][2];
14456- l.push(tabN(n) + tabN(t1) + tabN(t2) + name);
14457- totalcount += n
14458- totalprep += t1
14459- totaltime += t2
14460- }
14461- s = "\ncount \tprep(ms)\texec(ms)\n"
14462- + "--------\t--------\t--------\n"
14463- + tabN(totalcount)+ tabN(totalprep)+tabN(totaltime) + "\n"
14464- + "--------\t--------\t--------\n"
14465- + l.sort().reverse().join("\n")
14466- ;
14467- _profile = null;
1446814457
1446914458 if (_profileNew) {
1447014459 s += "\n\n Total new objects: " + (_jsid - _jsid0) + "\n";
1447114460 s += "\ncount \texec(ms)\n";
1447214461 s += "--------\t--------\t------------------------------\n";
1447314462 totalcount = 0;
1447414463 totaltime = 0;
14464+ var rows = [];
1447514465 for (var key in _profileNew) {
1447614466 var count = _profileNew[key][0];
1447714467 var tnano = _profileNew[key][1];
14478- totalcount += count
14479- totaltime += tnano
14480- s += tabN(count) + tabN(tnano) + "\t" +key + "\n";
14468+ totalcount += count;
14469+ totaltime += tnano;
14470+ rows.push( tabN(count) + tabN(tnano) + "\t" +key + "\n") ;
1448114471 }
14482- s+= tabN(totalcount)+tabN(totaltime) + "\n"
14472+ rows.sort();
14473+ rows.reverse();
14474+ s += rows.join("");
14475+ s+= tabN(totalcount)+tabN(totaltime) + "\n";
1448314476 }
14484- }
1448514477 _profileNew = null;
1448614478 return s; //+ __signatures;
1448714479}
1448814480
14489-
14490- var addProfile = function(c, f, p, t1, t2) {
14491- var s = c.__CLASS_NAME__ + " " + f + " ";// + JSON.stringify(p);
14492- if (__signatures.indexOf(s) < 0)
14493- __signatures += s + "\n";
14494- var p = _profile[s];
14495- p || (p = _profile[s] = [0,0,0]);
14496- p[0]++;
14497- p[1] += t1;
14498- p[2] += t2;
14499- }
14500-
1450114481var addProfileNew = function(c, t) {
1450214482 var s = c.__CLASS_NAME__;
1450314483 var p = _profileNew[s];
@@ -15209,7 +15189,7 @@ Clazz._getStackTrace = function(n) {
1520915189 s += estack.join("\n");
1521015190 if (Clazz._stack.length) {
1521115191 s += "\nsee Clazz._stack";
15212- console.log("Clazz._stack = " + Clazz._stack );
15192+ console.log("Clazz.stack = \n " + estack.join("\n") );
1521315193 console.log("Use Clazz._showStack() or Clazz._showStack(n) to show parameters");
1521415194 }
1521515195 return s;
@@ -18173,10 +18153,11 @@ sp.charCodeAt$I = sp.charCodeAt;
1817318153sp.charAt$I = sp.charAt;
1817418154sp.substring$I = sp.substring$I$I = sp.subSequence$I$I = sp.substring;
1817518155sp.replace$C$C = sp.replace$CharSequence$CharSequence = sp.replace$;
18176- sp.toUpperCase$ = sp.toUpperCase$java_util_locale = sp.toUpperCase ;
18177- sp.toLowerCase$ = sp.toLowerCase$java_util_locale = sp.toLowerCase ;
18156+ sp.toUpperCase$ = sp.toUpperCase;
18157+ sp.toLowerCase$ = sp.toLowerCase;
1817818158sp.trim$ = sp.trim;
18179-
18159+ sp.toLowerCase$java_util_Locale = sp.toLocaleLowerCase ? function(loc) {loc = loc.toString(); var s = this.valueOf(); return (loc ? s.toLocaleLowerCase(loc.replace(/_/g,'-')) : s.toLocaleLowerCase()) } : sp.toLowerCase;
18160+ sp.toUpperCase$java_util_Locale = sp.toLocaleUpperCase ? function(loc) {loc = loc.toString(); var s = this.valueOf(); return (loc ? s.toLocaleUpperCase(loc.replace(/_/g,'-')) : s.toLocaleUpperCase()) } : sp.toUpperCase;
1818018161sp.length$ = function() {return this.length};
1818118162
1818218163//sp.chars$ = CharSequence.prototype.chars$;
0 commit comments