PageRenderTime 19ms CodeModel.GetById 11ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/Frameworks/AppKit/rhino.platform/CPDOMWindowBridge.j

http://github.com/jfahrenkrug/MapKit-HelloWorld
Unknown | 590 lines | 590 code | 0 blank | 0 comment | 0 complexity | e244004459b31dbc69288591f1e68399 MD5 | raw file
  1I;21;Foundation/CPObject.jI;22;Foundation/CPRunLoop.ji;9;CPEvent.ji;17;CPCompatibility.ji;18;CPDOMWindowLayer.jc;19391;
  2CPSharedDOMWindowBridge=nil;
  3var _1=[];
  4var _2,_3,_4;
  5var _5=objj_allocateClassPair(CPObject,"CPDOMWindowBridge"),_6=_5.isa;
  6class_addIvars(_5,[new objj_ivar("_orderedWindows"),new objj_ivar("_mouseDownWindow"),new objj_ivar("_DOMWindow"),new objj_ivar("_DOMBodyElement"),new objj_ivar("_DOMFocusElement"),new objj_ivar("_windowLevels"),new objj_ivar("_windowLayers"),new objj_ivar("_frame"),new objj_ivar("_contentBounds"),new objj_ivar("_mouseIsDown"),new objj_ivar("_lastMouseUp"),new objj_ivar("_lastMouseDown"),new objj_ivar("_charCodes"),new objj_ivar("_keyCode"),new objj_ivar("_DOMEventMode"),new objj_ivar("_DOMPasteboardElement"),new objj_ivar("_pasteboardKeyDownEvent"),new objj_ivar("_overriddenEventType")]);
  7objj_registerClassPair(_5);
  8objj_addClassForBundle(_5,objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  9class_addMethods(_5,[new objj_method(sel_getUid("initWithFrame:"),function(_7,_8,_9){
 10with(_7){
 11alert("unimplemented");
 12}
 13}),new objj_method(sel_getUid("_initWithDOMWindow:"),function(_a,_b,_c){
 14with(_a){
 15_a=objj_msgSendSuper({receiver:_a,super_class:objj_getClass("CPObject")},"init");
 16if(_a){
 17_DOMWindow=_c;
 18_windowLevels=[];
 19_windowLayers=objj_msgSend(CPDictionary,"dictionary");
 20_DOMBodyElement=document.getElementsByTagName("body")[0];
 21_DOMBodyElement.innerHTML="";
 22_DOMBodyElement.style.overflow="hidden";
 23_DOMBodyElement.style.webkitTouchCallout="none";
 24objj_msgSend(CPString,"_resetSize");
 25if(document.documentElement){
 26document.documentElement.style.overflow="hidden";
 27}
 28_frame=_2(_DOMWindow);
 29_contentBounds=CGRectMake(0,0,CPRectGetWidth(_frame),CPRectGetHeight(_frame));
 30_DOMFocusElement=document.createElement("input");
 31_DOMFocusElement.style.position="absolute";
 32_DOMFocusElement.style.zIndex="-1000";
 33_DOMFocusElement.style.opacity="0";
 34_DOMFocusElement.style.filter="alpha(opacity=0)";
 35_DOMBodyElement.appendChild(_DOMFocusElement);
 36_DOMPasteboardElement=document.createElement("input");
 37_DOMPasteboardElement.style.position="absolute";
 38_DOMPasteboardElement.style.top="-10000px";
 39_DOMPasteboardElement.style.zIndex="99";
 40_DOMBodyElement.appendChild(_DOMPasteboardElement);
 41_DOMPasteboardElement.blur();
 42_charCodes={};
 43var _d=objj_msgSend(_a,"class"),_e=sel_getUid("_bridgeKeyEvent:"),_f=class_getMethodImplementation(_d,_e),_10=function(_11){
 44_f(_a,nil,_11);
 45},_12=sel_getUid("_bridgeMouseEvent:"),_13=class_getMethodImplementation(_d,_12),_14=function(_15){
 46_13(_a,nil,_15);
 47},_16=sel_getUid("_bridgeScrollEvent:"),_17=class_getMethodImplementation(_d,_16),_18=function(_19){
 48_17(_a,nil,_19);
 49},_1a=sel_getUid("_bridgeResizeEvent:"),_1b=class_getMethodImplementation(_d,_1a),_1c=function(_1d){
 50_1b(_a,nil,_1d);
 51},_1e=sel_getUid("_bridgeTouchEvent:"),_1f=class_getMethodImplementation(_d,_1e),_20=function(_21){
 52_1f(_a,nil,_21);
 53},_22=_DOMWindow.document;
 54if(document.addEventListener){
 55_DOMWindow.addEventListener("resize",_1c,NO);
 56_22.addEventListener(CPDOMEventMouseUp,_14,NO);
 57_22.addEventListener(CPDOMEventMouseDown,_14,NO);
 58_22.addEventListener(CPDOMEventMouseMoved,_14,NO);
 59_22.addEventListener(CPDOMEventKeyUp,_10,NO);
 60_22.addEventListener(CPDOMEventKeyDown,_10,NO);
 61_22.addEventListener(CPDOMEventKeyPress,_10,NO);
 62_22.addEventListener(CPDOMEventTouchStart,_20,NO);
 63_22.addEventListener(CPDOMEventTouchEnd,_20,NO);
 64_22.addEventListener(CPDOMEventTouchMove,_20,NO);
 65_22.addEventListener(CPDOMEventTouchCancel,_20,NO);
 66_DOMWindow.addEventListener("DOMMouseScroll",_18,NO);
 67_DOMWindow.addEventListener(CPDOMEventScrollWheel,_18,NO);
 68}else{
 69if(document.attachEvent){
 70_DOMWindow.attachEvent("onresize",_1c);
 71_22.attachEvent("on"+CPDOMEventMouseUp,_14);
 72_22.attachEvent("on"+CPDOMEventMouseDown,_14);
 73_22.attachEvent("on"+CPDOMEventMouseMoved,_14);
 74_22.attachEvent("on"+CPDOMEventDoubleClick,_14);
 75_22.attachEvent("on"+CPDOMEventKeyUp,_10);
 76_22.attachEvent("on"+CPDOMEventKeyDown,_10);
 77_22.attachEvent("on"+CPDOMEventKeyPress,_10);
 78_DOMWindow.onmousewheel=_18;
 79_22.onmousewheel=_18;
 80_22.body.ondrag=function(){
 81return NO;
 82};
 83_22.body.onselectstart=function(){
 84return window.event.srcElement==_DOMPasteboardElement;
 85};
 86}
 87}
 88_1["INPUT"]=YES;
 89_1["SELECT"]=YES;
 90_1["TEXTAREA"]=YES;
 91_1["OPTION"]=YES;
 92}
 93return _a;
 94}
 95}),new objj_method(sel_getUid("frame"),function(_23,_24){
 96with(_23){
 97return CGRectMakeCopy(_frame);
 98}
 99}),new objj_method(sel_getUid("visibleFrame"),function(_25,_26){
100with(_25){
101var _27=objj_msgSend(_25,"frame");
102_27.origin=CGPointMakeZero();
103if(objj_msgSend(CPMenu,"menuBarVisible")){
104var _28=objj_msgSend(objj_msgSend(CPApp,"mainMenu"),"menuBarHeight");
105_27.origin.y+=_28;
106_27.size.height-=_28;
107}
108return _27;
109}
110}),new objj_method(sel_getUid("contentBounds"),function(_29,_2a){
111with(_29){
112return CPRectCreateCopy(_contentBounds);
113}
114}),new objj_method(sel_getUid("orderedWindowsAtLevel:"),function(_2b,_2c,_2d){
115with(_2b){
116var _2e=objj_msgSend(_2b,"layerAtLevel:create:",_2d,NO);
117if(!_2e){
118return [];
119}
120return objj_msgSend(_2e,"orderedWindows");
121}
122}),new objj_method(sel_getUid("layerAtLevel:create:"),function(_2f,_30,_31,_32){
123with(_2f){
124var _33=objj_msgSend(_windowLayers,"objectForKey:",_31);
125if(!_33&&_32){
126_33=objj_msgSend(objj_msgSend(CPDOMWindowLayer,"alloc"),"initWithLevel:",_31);
127objj_msgSend(_windowLayers,"setObject:forKey:",_33,_31);
128var low=0,_35=_windowLevels.length-1,_36;
129while(low<=_35){
130_36=FLOOR((low+_35)/2);
131if(_windowLevels[_36]>_31){
132_35=_36-1;
133}else{
134low=_36+1;
135}
136}
137objj_msgSend(_windowLevels,"insertObject:atIndex:",_31,_windowLevels[_36]>_31?_36:_36+1);
138_33._DOMElement.style.zIndex=_31;
139_DOMBodyElement.appendChild(_33._DOMElement);
140}
141return _33;
142}
143}),new objj_method(sel_getUid("order:window:relativeTo:"),function(_37,_38,_39,_3a,_3b){
144with(_37){
145var _3c=objj_msgSend(_37,"layerAtLevel:create:",objj_msgSend(_3a,"level"),_39!=CPWindowOut);
146if(_39==CPWindowOut){
147return objj_msgSend(_3c,"removeWindow:",_3a);
148}
149objj_msgSend(_3c,"insertWindow:atIndex:",_3a,(_3b?(_39==CPWindowAbove?_3b._index+1:_3b._index):CPNotFound));
150}
151}),new objj_method(sel_getUid("_dragHitTest:pasteboard:"),function(_3d,_3e,_3f,_40){
152with(_3d){
153var _41=_windowLevels,_42=_windowLayers,_43=_41.length;
154while(_43--){
155if(_41[_43]>=CPDraggingWindowLevel){
156continue;
157}
158var _44=objj_msgSend(_42,"objectForKey:",_41[_43])._windows,_45=_44.length;
159while(_45--){
160var _46=_44[_45];
161if(objj_msgSend(_46,"containsPoint:",_3f)){
162return objj_msgSend(_46,"_dragHitTest:pasteboard:",_3f,_40);
163}
164}
165}
166return nil;
167}
168}),new objj_method(sel_getUid("_propagateCurrentDOMEvent:"),function(_47,_48,_49){
169with(_47){
170StopDOMEventPropagation=!_49;
171}
172}),new objj_method(sel_getUid("hitTest:"),function(_4a,_4b,_4c){
173with(_4a){
174var _4d=_windowLevels,_4e=_windowLayers,_4f=_4d.length,_50=nil;
175while(_4f--&&!_50){
176var _51=objj_msgSend(_4e,"objectForKey:",_4d[_4f])._windows,_52=_51.length;
177while(_52--&&!_50){
178var _53=_51[_52];
179if(!_53._ignoresMouseEvents&&objj_msgSend(_53,"containsPoint:",_4c)){
180_50=_53;
181}
182}
183}
184return _50;
185}
186})]);
187class_addMethods(_6,[new objj_method(sel_getUid("sharedDOMWindowBridge"),function(_54,_55){
188with(_54){
189if(!CPSharedDOMWindowBridge){
190CPSharedDOMWindowBridge=objj_msgSend(objj_msgSend(CPDOMWindowBridge,"alloc"),"_initWithDOMWindow:",window);
191}
192return CPSharedDOMWindowBridge;
193}
194})]);
195var _2=function(_56){
196var _57=nil;
197if(_56.outerWidth){
198_57=CGRectMake(0,0,_56.outerWidth,_56.outerHeight);
199}else{
200_57=CGRectMake(0,0,-1,-1);
201}
202if(window.screenTop){
203_57.origin=CGPointMake(_56.screenLeft,_56.screenTop,0);
204}else{
205if(window.screenX){
206_57.origin=CGPointMake(_56.screenX,_56.screenY,0);
207}
208}
209if(_56.innerWidth){
210_57.size=CGSizeMake(_56.innerWidth,_56.innerHeight);
211}else{
212if(document.documentElement&&document.documentElement.clientWidth){
213_57.size=CGSizeMake(_56.document.documentElement.clientWidth,_56.document.documentElement.clientHeight);
214}else{
215_57.size=CGSizeMake(_56.document.body.clientWidth,_56.document.body.clientHeight);
216}
217}
218return _57;
219};
220var _58={},_59={},_5a={"8":1,"9":1,"37":1,"38":1,"39":1,"40":1,"46":1,"33":1,"34":1};
221var _5b=17;
222var _5=objj_getClass("CPDOMWindowBridge");
223if(!_5){
224objj_exception_throw(new objj_exception(OBJJClassNotFoundException,"*** Could not find definition for class \"CPDOMWindowBridge\""));
225}
226var _6=_5.isa;
227class_addMethods(_5,[new objj_method(sel_getUid("preventCharacterKeysFromPropagating:"),function(_5c,_5d,_5e){
228with(_5c){
229for(var i=_5e.length;i>0;i--){
230_59[""+_5e[i-1].toLowerCase()]=YES;
231}
232}
233}),new objj_method(sel_getUid("preventCharacterKeyFromPropagating:"),function(_60,_61,_62){
234with(_60){
235_59[_62.toLowerCase()]=YES;
236}
237}),new objj_method(sel_getUid("clearCharacterKeysToPreventFromPropagating"),function(_63,_64){
238with(_63){
239_59={};
240}
241}),new objj_method(sel_getUid("preventKeyCodesFromPropagating:"),function(_65,_66,_67){
242with(_65){
243for(var i=_67.length;i>0;i--){
244_58[_67[i-1]]=YES;
245}
246}
247}),new objj_method(sel_getUid("preventKeyCodeFromPropagating:"),function(_69,_6a,_6b){
248with(_69){
249_58[_6b]=YES;
250}
251}),new objj_method(sel_getUid("clearKeyCodesToPreventFromPropagating"),function(_6c,_6d){
252with(_6c){
253_58={};
254}
255}),new objj_method(sel_getUid("_bridgeMouseEvent:"),function(_6e,_6f,_70){
256with(_6e){
257var _71=_overriddenEventType||_70.type;
258if(_71==CPDOMEventDoubleClick){
259_overriddenEventType=CPDOMEventMouseDown;
260objj_msgSend(_6e,"_bridgeMouseEvent:",_70);
261_overriddenEventType=CPDOMEventMouseUp;
262objj_msgSend(_6e,"_bridgeMouseEvent:",_70);
263_overriddenEventType=nil;
264return;
265}
266try{
267var _72,_73={x:_70.clientX,y:_70.clientY},_74=_70.timeStamp?_70.timeStamp:new Date(),_75=(_70.target||_70.srcElement),_76=0,_77=(_70.shiftKey?CPShiftKeyMask:0)|(_70.ctrlKey?CPControlKeyMask:0)|(_70.altKey?CPAlternateKeyMask:0)|(_70.metaKey?CPCommandKeyMask:0);
268StopDOMEventPropagation=YES;
269if(_mouseDownWindow){
270_76=objj_msgSend(_mouseDownWindow,"windowNumber");
271}else{
272var _78=objj_msgSend(_6e,"hitTest:",_73);
273if(_70.type==CPDOMEventMouseDown&&_78){
274_mouseDownWindow=_78;
275}
276_76=objj_msgSend(_78,"windowNumber");
277}
278if(_76){
279var _79=CPApp._windows[_76]._frame;
280_73.x-=(_79.origin.x);
281_73.y-=(_79.origin.y);
282}
283switch(_71){
284case CPDOMEventMouseUp:
285if(_mouseIsDown){
286_72=objj_msgSend(CPEvent,"mouseEventWithType:location:modifierFlags:timestamp:windowNumber:context:eventNumber:clickCount:pressure:",CPLeftMouseUp,_73,_77,_74,_76,nil,-1,_3(_lastMouseUp,_74,_73),0);
287_mouseIsDown=NO;
288_lastMouseUp=_72;
289_mouseDownWindow=nil;
290}
291if(_DOMEventMode){
292_DOMEventMode=NO;
293return;
294}
295break;
296case CPDOMEventMouseDown:
297if(_1[_75.tagName]&&_75!=_DOMFocusElement){
298_DOMEventMode=YES;
299_mouseIsDown=YES;
300objj_msgSend(CPApp,"sendEvent:",objj_msgSend(CPEvent,"mouseEventWithType:location:modifierFlags:timestamp:windowNumber:context:eventNumber:clickCount:pressure:",CPLeftMouseDown,_73,_77,_74,_76,nil,-1,_3(_lastMouseDown,_74,_73),0));
301objj_msgSend(CPApp,"sendEvent:",objj_msgSend(CPEvent,"mouseEventWithType:location:modifierFlags:timestamp:windowNumber:context:eventNumber:clickCount:pressure:",CPLeftMouseUp,_73,_77,_74,_76,nil,-1,_3(_lastMouseDown,_74,_73),0));
302return;
303}
304_72=objj_msgSend(CPEvent,"mouseEventWithType:location:modifierFlags:timestamp:windowNumber:context:eventNumber:clickCount:pressure:",CPLeftMouseDown,_73,_77,_74,_76,nil,-1,_3(_lastMouseDown,_74,_73),0);
305_mouseIsDown=YES;
306_lastMouseDown=_72;
307break;
308case CPDOMEventMouseMoved:
309if(_DOMEventMode){
310return;
311}
312_72=objj_msgSend(CPEvent,"mouseEventWithType:location:modifierFlags:timestamp:windowNumber:context:eventNumber:clickCount:pressure:",_mouseIsDown?CPLeftMouseDragged:CPMouseMoved,_73,_77,_74,_76,nil,-1,1,0);
313break;
314}
315if(_72){
316_72._DOMEvent=_70;
317objj_msgSend(CPApp,"sendEvent:",_72);
318}
319if(StopDOMEventPropagation){
320_4(_70);
321}
322objj_msgSend(objj_msgSend(CPRunLoop,"currentRunLoop"),"limitDateForMode:",CPDefaultRunLoopMode);
323}
324catch(anException){
325objj_exception_report(anException,{path:"CPDOMWindowBridge.j"});
326}
327}
328}),new objj_method(sel_getUid("_bridgeKeyEvent:"),function(_7a,_7b,_7c){
329with(_7a){
330try{
331var _7d,_7e=_7c.timeStamp?_7c.timeStamp:new Date(),_7f=(_7c.target||_7c.srcElement),_80=objj_msgSend(objj_msgSend(CPApp,"keyWindow"),"windowNumber"),_81=(_7c.shiftKey?CPShiftKeyMask:0)|(_7c.ctrlKey?CPControlKeyMask:0)|(_7c.altKey?CPAlternateKeyMask:0)|(_7c.metaKey?CPCommandKeyMask:0);
332if(_1[_7f.tagName]&&_7f!=_DOMFocusElement&&_7f!=_DOMPasteboardElement){
333return;
334}
335StopDOMEventPropagation=!(_81&(CPControlKeyMask|CPCommandKeyMask))||_59[String.fromCharCode(_7c.keyCode||_7c.charCode).toLowerCase()]||_58[_7c.keyCode];
336var _82=NO,_83=NO;
337switch(_7c.type){
338case CPDOMEventKeyDown:
339_keyCode=_7c.keyCode;
340var _84=String.fromCharCode(_keyCode).toLowerCase();
341if(_84=="v"&&(_81&CPPlatformActionKeyMask)){
342_DOMPasteboardElement.select();
343_DOMPasteboardElement.value="";
344_82=YES;
345}else{
346if((_84=="c"||_84=="x")&&(_81&CPPlatformActionKeyMask)){
347_83=YES;
348}else{
349if(!CPFeatureIsCompatible(CPJavascriptRemedialKeySupport)){
350return;
351}else{
352if(!_5a[_keyCode]&&(_keyCode==_5b||!(_81&CPControlKeyMask))){
353return;
354}
355}
356}
357}
358case CPDOMEventKeyPress:
359if((_7c.target||_7c.srcElement)==_DOMPasteboardElement){
360return;
361}
362var _85=_keyCode,_86=_7c.keyCode||_7c.charCode,_87=(_charCodes[_85]!=nil);
363_charCodes[_85]=_86;
364var _84=String.fromCharCode(_86),_88=_84.toLowerCase();
365_7d=objj_msgSend(CPEvent,"keyEventWithType:location:modifierFlags:timestamp:windowNumber:context:characters:charactersIgnoringModifiers:isARepeat:keyCode:",CPKeyDown,location,_81,_7e,_80,nil,_84,_88,_87,_85);
366if(_82){
367_pasteboardKeyDownEvent=_7d;
368window.setNativeTimeout(function(){
369objj_msgSend(_7a,"_checkPasteboardElement");
370},0);
371return;
372}
373break;
374case CPDOMEventKeyUp:
375var _85=_7c.keyCode,_86=_charCodes[_85];
376_charCodes[_85]=nil;
377var _84=String.fromCharCode(_86),_88=_84.toLowerCase();
378if(!(_81&CPShiftKeyMask)){
379_84=_88;
380}
381_7d=objj_msgSend(CPEvent,"keyEventWithType:location:modifierFlags:timestamp:windowNumber:context:characters:charactersIgnoringModifiers:isARepeat:keyCode:",CPKeyUp,location,_81,_7e,_80,nil,_84,_88,NO,_85);
382break;
383}
384if(_7d){
385_7d._DOMEvent=_7c;
386objj_msgSend(CPApp,"sendEvent:",_7d);
387if(_83){
388var _89=objj_msgSend(CPPasteboard,"generalPasteboard"),_8a=objj_msgSend(_89,"types");
389if(_8a.length){
390if(objj_msgSend(_8a,"indexOfObjectIdenticalTo:",CPStringPboardType)!=CPNotFound){
391_DOMPasteboardElement.value=objj_msgSend(_89,"stringForType:",CPStringPboardType);
392}else{
393_DOMPasteboardElement.value=objj_msgSend(_89,"_generateStateUID");
394}
395_DOMPasteboardElement.select();
396window.setNativeTimeout(function(){
397objj_msgSend(_7a,"_clearPasteboardElement");
398},0);
399}
400return;
401}
402}
403if(StopDOMEventPropagation){
404_4(_7c);
405}
406objj_msgSend(objj_msgSend(CPRunLoop,"currentRunLoop"),"limitDateForMode:",CPDefaultRunLoopMode);
407}
408catch(anException){
409objj_exception_report(anException,{path:"CPDOMWindowBridge.j"});
410}
411}
412}),new objj_method(sel_getUid("_bridgeScrollEvent:"),function(_8b,_8c,_8d){
413with(_8b){
414if(!_8d){
415_8d=window.event;
416}
417try{
418if(CPFeatureIsCompatible(CPJavaScriptMouseWheelValues_8_15)){
419var x=0,y=0,_90=_8d.target;
420while(_90.nodeType!==1){
421_90=_90.parentNode;
422}
423if(_90.offsetParent){
424do{
425x+=_90.offsetLeft;
426y+=_90.offsetTop;
427}while(_90=_90.offsetParent);
428}
429var _91={x:(x+((_8d.clientX-8)/15)),y:(y+((_8d.clientY-8)/15))};
430}else{
431var _91={x:_8d.clientX,y:_8d.clientY};
432}
433var _92=0,_93=0,_94=0,_95=_8d.timeStamp?_8d.timeStamp:new Date(),_96=(_8d.shiftKey?CPShiftKeyMask:0)|(_8d.ctrlKey?CPControlKeyMask:0)|(_8d.altKey?CPAlternateKeyMask:0)|(_8d.metaKey?CPCommandKeyMask:0);
434StopDOMEventPropagation=YES;
435_94=objj_msgSend(objj_msgSend(_8b,"hitTest:",_91),"windowNumber");
436if(!_94){
437return;
438}
439var _97=CPApp._windows[_94]._frame;
440_91.x-=CGRectGetMinX(_97);
441_91.y-=CGRectGetMinY(_97);
442if(typeof _8d.wheelDeltaX!="undefined"){
443_92=_8d.wheelDeltaX/120;
444_93=_8d.wheelDeltaY/120;
445}else{
446if(_8d.wheelDelta){
447_93=_8d.wheelDelta/120;
448}else{
449if(_8d.detail){
450_93=-_8d.detail/3;
451}else{
452return;
453}
454}
455}
456if(!CPFeatureIsCompatible(CPJavaScriptNegativeMouseWheelValues)){
457_92=-_92;
458_93=-_93;
459}
460var _98=objj_msgSend(CPEvent,"mouseEventWithType:location:modifierFlags:timestamp:windowNumber:context:eventNumber:clickCount:pressure:",CPScrollWheel,_91,_96,_95,_94,nil,-1,1,0);
461_98._DOMEvent=_8d;
462_98._deltaX=ROUND(_92*1.5);
463_98._deltaY=ROUND(_93*1.5);
464objj_msgSend(CPApp,"sendEvent:",_98);
465if(StopDOMEventPropagation){
466_4(_8d);
467}
468objj_msgSend(objj_msgSend(CPRunLoop,"currentRunLoop"),"limitDateForMode:",CPDefaultRunLoopMode);
469}
470catch(anException){
471objj_exception_report(anException,{path:"CPDOMWindowBridge.j"});
472}
473}
474}),new objj_method(sel_getUid("_bridgeResizeEvent:"),function(_99,_9a,_9b){
475with(_99){
476try{
477var _9c=_frame.size;
478_frame=_2(_DOMWindow);
479_contentBounds.size=CGSizeCreateCopy(_frame.size);
480var _9d=_windowLevels,_9e=_windowLayers,_9f=_9d.length;
481while(_9f--){
482var _a0=objj_msgSend(_9e,"objectForKey:",_9d[_9f])._windows,_a1=_a0.length;
483while(_a1--){
484objj_msgSend(_a0[_a1],"resizeWithOldBridgeSize:",_9c);
485}
486}
487objj_msgSend(objj_msgSend(CPRunLoop,"currentRunLoop"),"limitDateForMode:",CPDefaultRunLoopMode);
488}
489catch(anException){
490objj_exception_report(anException,{path:"CPDOMWindowBridge.j"});
491}
492}
493}),new objj_method(sel_getUid("_bridgeTouchEvent:"),function(_a2,_a3,_a4){
494with(_a2){
495try{
496if(_a4.touches&&(_a4.touches.length==1||(_a4.touches.length==0&&_a4.changedTouches.length==1))){
497var _a5={};
498switch(_a4.type){
499case CPDOMEventTouchStart:
500_a5.type=CPDOMEventMouseDown;
501break;
502case CPDOMEventTouchEnd:
503_a5.type=CPDOMEventMouseUp;
504break;
505case CPDOMEventTouchMove:
506_a5.type=CPDOMEventMouseMoved;
507break;
508case CPDOMEventTouchCancel:
509_a5.type=CPDOMEventMouseUp;
510break;
511}
512var _a6=_a4.touches.length?_a4.touches[0]:_a4.changedTouches[0];
513_a5.clientX=_a6.clientX;
514_a5.clientY=_a6.clientY;
515_a5.timestamp=_a4.timestamp;
516_a5.target=_a4.target;
517_a5.shiftKey=_a5.ctrlKey=_a5.altKey=_a5.metaKey=false;
518_a5.preventDefault=function(){
519if(_a4.preventDefault){
520_a4.preventDefault();
521}
522};
523_a5.stopPropagation=function(){
524if(_a4.stopPropagation){
525_a4.stopPropagation();
526}
527};
528objj_msgSend(_a2,"_bridgeMouseEvent:",_a5);
529return;
530}else{
531if(_a4.preventDefault){
532_a4.preventDefault();
533}
534if(_a4.stopPropagation){
535_a4.stopPropagation();
536}
537}
538}
539catch(e){
540objj_exception_report(e,{path:"CPDOMWindowBridge.j"});
541}
542}
543}),new objj_method(sel_getUid("_checkPasteboardElement"),function(_a7,_a8){
544with(_a7){
545try{
546var _a9=_DOMPasteboardElement.value;
547if(objj_msgSend(_a9,"length")){
548var _aa=objj_msgSend(CPPasteboard,"generalPasteboard");
549if(objj_msgSend(_aa,"_stateUID")!=_a9){
550objj_msgSend(_aa,"declareTypes:owner:",[CPStringPboardType],_a7);
551objj_msgSend(_aa,"setString:forType:",_a9,CPStringPboardType);
552}
553}
554objj_msgSend(_a7,"_clearPasteboardElement");
555objj_msgSend(CPApp,"sendEvent:",_pasteboardKeyDownEvent);
556_pasteboardKeyDownEvent=nil;
557objj_msgSend(objj_msgSend(CPRunLoop,"currentRunLoop"),"limitDateForMode:",CPDefaultRunLoopMode);
558}
559catch(anException){
560objj_exception_report(anException,{path:"CPDOMWindowBridge.j"});
561}
562}
563}),new objj_method(sel_getUid("_clearPasteboardElement"),function(_ab,_ac){
564with(_ab){
565_DOMPasteboardElement.value="";
566_DOMPasteboardElement.blur();
567}
568})]);
569var _ad=5,_ae=(typeof document!="undefined"&&document.addEventListener)?350:1000;
570var _3=function(_af,_b0,_b1){
571if(!_af){
572return 1;
573}
574var _b2=objj_msgSend(_af,"locationInWindow");
575return (_b0-objj_msgSend(_af,"timestamp")<_ae&&ABS(_b2.x-_b1.x)<_ad&&ABS(_b2.y-_b1.y)<_ad)?objj_msgSend(_af,"clickCount")+1:1;
576};
577var _4=function(_b3){
578_b3.cancelBubble=true;
579_b3.returnValue=false;
580if(_b3.preventDefault){
581_b3.preventDefault();
582}
583if(_b3.stopPropagation){
584_b3.stopPropagation();
585}
586if(_b3.type==CPDOMEventMouseDown){
587CPSharedDOMWindowBridge._DOMFocusElement.focus();
588CPSharedDOMWindowBridge._DOMFocusElement.blur();
589}
590};