/Frameworks/AppKit/rhino.platform/CALayer.j

http://github.com/polymar/polish · Unknown · 704 lines · 704 code · 0 blank · 0 comment · 0 complexity · 23fac05add84ee82f2cd00e341b47689 MD5 · raw file

  1. I;21;Foundation/CPObject.jI;23;AppKit/CABackingStore.jI;18;AppKit/CGContext.jI;19;AppKit/CGGeometry.ji;12;CGGeometry.jc;24770;
  2. CGAffineTransformMake=function(a,b,c,d,tx,ty){
  3. return {a:a,b:b,c:c,d:d,tx:tx,ty:ty};
  4. };
  5. CGAffineTransformMakeIdentity=function(){
  6. return {a:1,b:0,c:0,d:1,tx:0,ty:0};
  7. };
  8. CGAffineTransformMakeCopy=function(_7){
  9. return {a:_7.a,b:_7.b,c:_7.c,d:_7.d,tx:_7.tx,ty:_7.ty};
  10. };
  11. CGAffineTransformMakeScale=function(sx,sy){
  12. return {a:sx,b:0,c:0,d:sy,tx:0,ty:0};
  13. };
  14. CGAffineTransformMakeTranslation=function(tx,ty){
  15. return {a:1,b:0,c:0,d:1,tx:tx,ty:ty};
  16. };
  17. CGAffineTransformTranslate=function(_c,tx,ty){
  18. return {a:_c.a,b:_c.b,c:_c.c,d:_c.d,tx:_c.tx+_c.a*tx+_c.c*ty,ty:_c.ty+_c.b*tx+_c.d*ty};
  19. };
  20. CGAffineTransformScale=function(_f,sx,sy){
  21. return {a:_f.a*sx,b:_f.b*sx,c:_f.c*sy,d:_f.d*sy,tx:_f.tx,ty:_f.ty};
  22. };
  23. CGAffineTransformConcat=function(lhs,rhs){
  24. return {a:lhs.a*rhs.a+lhs.b*rhs.c,b:lhs.a*rhs.b+lhs.b*rhs.d,c:lhs.c*rhs.a+lhs.d*rhs.c,d:lhs.c*rhs.b+lhs.d*rhs.d,tx:lhs.tx*rhs.a+lhs.ty*rhs.c+rhs.tx,ty:lhs.tx*rhs.b+lhs.ty*rhs.d+rhs.ty};
  25. };
  26. CGPointApplyAffineTransform=function(_14,_15){
  27. return {x:_14.x*_15.a+_14.y*_15.c+_15.tx,y:_14.x*_15.b+_14.y*_15.d+_15.ty};
  28. };
  29. CGSizeApplyAffineTransform=function(_16,_17){
  30. return {width:_16.width*_17.a+_16.height*_17.c,height:_16.width*_17.b+_16.height*_17.d};
  31. };
  32. CGAffineTransformIsIdentity=function(_18){
  33. return (_18.a==1&&_18.b==0&&_18.c==0&&_18.d==1&&_18.tx==0&&_18.ty==0);
  34. };
  35. CGAffineTransformEqualToTransform=function(lhs,rhs){
  36. return (lhs.a==rhs.a&&lhs.b==rhs.b&&lhs.c==rhs.c&&lhs.d==rhs.d&&lhs.tx==rhs.tx&&lhs.ty==rhs.ty);
  37. };
  38. CGStringCreateWithCGAffineTransform=function(_1b){
  39. return (" [[ "+_1b.a+", "+_1b.b+", 0 ], [ "+_1b.c+", "+_1b.d+", 0 ], [ "+_1b.tx+", "+_1b.ty+", 1]]");
  40. };
  41. CGAffineTransformCreateCopy=function(_1c){
  42. return {a:_1c.a,b:_1c.b,c:_1c.c,d:_1c.d,tx:_1c.tx,ty:_1c.ty};
  43. };
  44. CGAffineTransformMakeRotation=function(_1d){
  45. var sin=SIN(_1d),cos=COS(_1d);
  46. return {a:cos,b:sin,c:-sin,d:cos,tx:0,ty:0};
  47. };
  48. CGAffineTransformRotate=function(_20,_21){
  49. var sin=SIN(_21),cos=COS(_21);
  50. return {a:_20.a*cos+_20.c*sin,b:_20.b*cos+_20.d*sin,c:_20.c*cos-_20.a*sin,d:_20.d*cos-_20.b*sin,tx:_20.tx,ty:_20.ty};
  51. };
  52. CGAffineTransformInvert=function(_24){
  53. var _25=1/(_24.a*_24.d-_24.b*_24.c);
  54. return {a:_25*_24.d,b:-_25*_24.b,c:-_25*_24.c,d:_25*_24.a,tx:_25*(_24.c*_24.ty-_24.d*_24.tx),ty:_25*(_24.b*_24.tx-_24.a*_24.ty)};
  55. };
  56. CGRectApplyAffineTransform=function(_26,_27){
  57. var top=(_26.origin.y),_29=(_26.origin.x),_2a=(_26.origin.x+_26.size.width),_2b=(_26.origin.y+_26.size.height),_2c=CGPointApplyAffineTransform({x:_29,y:top},_27),_2d=CGPointApplyAffineTransform({x:_2a,y:top},_27),_2e=CGPointApplyAffineTransform({x:_29,y:_2b},_27),_2f=CGPointApplyAffineTransform({x:_2a,y:_2b},_27),_30=MIN(_2c.x,_2d.x,_2e.x,_2f.x),_31=MAX(_2c.x,_2d.x,_2e.x,_2f.x),_32=MIN(_2c.y,_2d.y,_2e.y,_2f.y),_33=MAX(_2c.y,_2d.y,_2e.y,_2f.y);
  58. return {origin:{x:_30,y:_32},size:{width:(_31-_30),height:(_33-_32)}};
  59. };
  60. CPStringFromCGAffineTransform=function(_34){
  61. return "{"+_34.a+", "+_34.b+", "+_34.c+", "+_34.d+", "+_34.tx+", "+_34.ty+"}";
  62. };
  63. var _35=1,_36=2,_37=4,_38=8,_39=16;
  64. var _3a=NO;
  65. var _3b=1,_3c=2,_3d=4,_3e=8,_3f=16,_40=_3d|_3b|_3c;
  66. var _41=nil;
  67. var _42=objj_allocateClassPair(CPObject,"CALayer"),_43=_42.isa;
  68. class_addIvars(_42,[new objj_ivar("_frame"),new objj_ivar("_bounds"),new objj_ivar("_position"),new objj_ivar("_zPosition"),new objj_ivar("_anchorPoint"),new objj_ivar("_affineTransform"),new objj_ivar("_sublayerTransform"),new objj_ivar("_sublayerTransformForSublayers"),new objj_ivar("_backingStoreFrame"),new objj_ivar("_standardBackingStoreFrame"),new objj_ivar("_hasSublayerTransform"),new objj_ivar("_hasCustomBackingStoreFrame"),new objj_ivar("_opacity"),new objj_ivar("_isHidden"),new objj_ivar("_backgroundColor"),new objj_ivar("_superlayer"),new objj_ivar("_sublayers"),new objj_ivar("_runLoopUpdateMask"),new objj_ivar("_needsDisplayOnBoundsChange"),new objj_ivar("_delegate"),new objj_ivar("_delegateRespondsToDisplayLayerSelector"),new objj_ivar("_delegateRespondsToDrawLayerInContextSelector"),new objj_ivar("_DOMElement"),new objj_ivar("_DOMContentsElement"),new objj_ivar("_contents"),new objj_ivar("_context"),new objj_ivar("_owningView"),new objj_ivar("_transformToLayer"),new objj_ivar("_transformFromLayer")]);
  69. objj_registerClassPair(_42);
  70. objj_addClassForBundle(_42,objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  71. class_addMethods(_42,[new objj_method(sel_getUid("init"),function(_44,_45){
  72. with(_44){
  73. _44=objj_msgSendSuper({receiver:_44,super_class:objj_getClass("CPObject")},"init");
  74. if(_44){
  75. _frame=CGRectMakeZero();
  76. _backingStoreFrame=CGRectMakeZero();
  77. _standardBackingStoreFrame=CGRectMakeZero();
  78. _bounds=CGRectMakeZero();
  79. _position=CGPointMakeZero();
  80. _zPosition=0;
  81. _anchorPoint=CGPointMake(0.5,0.5);
  82. _affineTransform=CGAffineTransformMakeIdentity();
  83. _sublayerTransform=CGAffineTransformMakeIdentity();
  84. _transformToLayer=CGAffineTransformMakeIdentity();
  85. _transformFromLayer=CGAffineTransformMakeIdentity();
  86. _opacity=1;
  87. _isHidden=NO;
  88. _masksToBounds=NO;
  89. _sublayers=[];
  90. _DOMElement=document.createElement("div");
  91. _DOMElement.style.overflow="visible";
  92. _DOMElement.style.position="absolute";
  93. _DOMElement.style.visibility="visible";
  94. _DOMElement.style.top="0px";
  95. _DOMElement.style.left="0px";
  96. _DOMElement.style.zIndex=0;
  97. _DOMElement.style.width="0px";
  98. _DOMElement.style.height="0px";
  99. }
  100. return _44;
  101. }
  102. }),new objj_method(sel_getUid("setBounds:"),function(_46,_47,_48){
  103. with(_46){
  104. if(CGRectEqualToRect(_bounds,_48)){
  105. return;
  106. }
  107. var _49=_bounds.origin;
  108. _bounds={origin:{x:_48.origin.x,y:_48.origin.y},size:{width:_48.size.width,height:_48.size.height}};
  109. if(_hasSublayerTransform){
  110. _CALayerUpdateSublayerTransformForSublayers(_46);
  111. }
  112. _CALayerRecalculateGeometry(_46,_35);
  113. }
  114. }),new objj_method(sel_getUid("bounds"),function(_4a,_4b){
  115. with(_4a){
  116. return _bounds;
  117. }
  118. }),new objj_method(sel_getUid("setPosition:"),function(_4c,_4d,_4e){
  119. with(_4c){
  120. if(CGPointEqualToPoint(_position,_4e)){
  121. return;
  122. }
  123. _position={x:_4e.x,y:_4e.y};
  124. _CALayerRecalculateGeometry(_4c,_36);
  125. }
  126. }),new objj_method(sel_getUid("position"),function(_4f,_50){
  127. with(_4f){
  128. return _position;
  129. }
  130. }),new objj_method(sel_getUid("setZPosition:"),function(_51,_52,_53){
  131. with(_51){
  132. if(_zPosition==_53){
  133. return;
  134. }
  135. _zPosition=_53;
  136. objj_msgSend(_51,"registerRunLoopUpdateWithMask:",_3d);
  137. }
  138. }),new objj_method(sel_getUid("setAnchorPoint:"),function(_54,_55,_56){
  139. with(_54){
  140. _56={x:_56.x,y:_56.y};
  141. _56.x=MIN(1,MAX(0,_56.x));
  142. _56.y=MIN(1,MAX(0,_56.y));
  143. if(CGPointEqualToPoint(_anchorPoint,_56)){
  144. return;
  145. }
  146. _anchorPoint=_56;
  147. if(_hasSublayerTransform){
  148. _CALayerUpdateSublayerTransformForSublayers(_54);
  149. }
  150. if(_owningView){
  151. _position=CGPointMake((_bounds.size.width)*_anchorPoint.x,(_bounds.size.height)*_anchorPoint.y);
  152. }
  153. _CALayerRecalculateGeometry(_54,_37);
  154. }
  155. }),new objj_method(sel_getUid("anchorPoint"),function(_57,_58){
  156. with(_57){
  157. return _anchorPoint;
  158. }
  159. }),new objj_method(sel_getUid("setAffineTransform:"),function(_59,_5a,_5b){
  160. with(_59){
  161. if(CGAffineTransformEqualToTransform(_affineTransform,_5b)){
  162. return;
  163. }
  164. _affineTransform={a:_5b.a,b:_5b.b,c:_5b.c,d:_5b.d,tx:_5b.tx,ty:_5b.ty};
  165. _CALayerRecalculateGeometry(_59,_38);
  166. }
  167. }),new objj_method(sel_getUid("affineTransform"),function(_5c,_5d){
  168. with(_5c){
  169. return _affineTransform;
  170. }
  171. }),new objj_method(sel_getUid("setSublayerTransform:"),function(_5e,_5f,_60){
  172. with(_5e){
  173. if(CGAffineTransformEqualToTransform(_sublayerTransform,_60)){
  174. return;
  175. }
  176. var _61=_hasSublayerTransform;
  177. _sublayerTransform={a:_60.a,b:_60.b,c:_60.c,d:_60.d,tx:_60.tx,ty:_60.ty};
  178. _hasSublayerTransform=!(_sublayerTransform.a==1&&_sublayerTransform.b==0&&_sublayerTransform.c==0&&_sublayerTransform.d==1&&_sublayerTransform.tx==0&&_sublayerTransform.ty==0);
  179. if(_hasSublayerTransform){
  180. _CALayerUpdateSublayerTransformForSublayers(_5e);
  181. var _62=_sublayers.length;
  182. while(_62--){
  183. _CALayerRecalculateGeometry(_sublayers[_62],_39);
  184. }
  185. }
  186. }
  187. }),new objj_method(sel_getUid("sublayerTransform"),function(_63,_64){
  188. with(_63){
  189. return _sublayerTransform;
  190. }
  191. }),new objj_method(sel_getUid("transformToLayer"),function(_65,_66){
  192. with(_65){
  193. return _transformToLayer;
  194. }
  195. }),new objj_method(sel_getUid("setFrame:"),function(_67,_68,_69){
  196. with(_67){
  197. alert("FIXME IMPLEMENT");
  198. }
  199. }),new objj_method(sel_getUid("frame"),function(_6a,_6b){
  200. with(_6a){
  201. if(!_frame){
  202. _frame=objj_msgSend(_6a,"convertRect:toLayer:",_bounds,_superlayer);
  203. }
  204. return _frame;
  205. }
  206. }),new objj_method(sel_getUid("backingStoreFrame"),function(_6c,_6d){
  207. with(_6c){
  208. return _backingStoreFrame;
  209. }
  210. }),new objj_method(sel_getUid("setBackingStoreFrame:"),function(_6e,_6f,_70){
  211. with(_6e){
  212. _hasCustomBackingStoreFrame=(_70!=nil);
  213. if(_70==nil){
  214. _70=CGRectMakeCopy(_standardBackingStoreFrame);
  215. }else{
  216. if(_superlayer){
  217. _70=objj_msgSend(_superlayer,"convertRect:toLayer:",_70,nil);
  218. var _71=objj_msgSend(_superlayer,"bounds"),_72=objj_msgSend(_superlayer,"convertRect:toLayer:",_71,nil);
  219. _70.origin.x-=(_72.origin.x);
  220. _70.origin.y-=(_72.origin.y);
  221. }else{
  222. _70=CGRectMakeCopy(_70);
  223. }
  224. }
  225. if(!CGPointEqualToPoint(_backingStoreFrame.origin,_70.origin)){
  226. objj_msgSend(_6e,"registerRunLoopUpdateWithMask:",_3b);
  227. }
  228. if(!CGSizeEqualToSize(_backingStoreFrame.size,_70.size)){
  229. objj_msgSend(_6e,"registerRunLoopUpdateWithMask:",_3c);
  230. }
  231. _backingStoreFrame=_70;
  232. }
  233. }),new objj_method(sel_getUid("contents"),function(_73,_74){
  234. with(_73){
  235. return _contents;
  236. }
  237. }),new objj_method(sel_getUid("setContents:"),function(_75,_76,_77){
  238. with(_75){
  239. if(_contents==_77){
  240. return;
  241. }
  242. _contents=_77;
  243. objj_msgSend(_75,"composite");
  244. }
  245. }),new objj_method(sel_getUid("composite"),function(_78,_79){
  246. with(_78){
  247. if(_3a&&!_contents||!_context){
  248. return;
  249. }
  250. CGContextClearRect(_context,{origin:{x:0,y:0},size:{width:(_backingStoreFrame.size.width),height:(_backingStoreFrame.size.height)}});
  251. var _7a=_transformFromLayer;
  252. if(_superlayer){
  253. var _7b=_CALayerGetTransform(_superlayer,nil),_7c=CGPointApplyAffineTransform(_superlayer._bounds.origin,_7b);
  254. _7a=CGAffineTransformConcat(_7a,_7b);
  255. _7a.tx-=_7c.x;
  256. _7a.ty-=_7c.y;
  257. }
  258. _7a.tx-=(_backingStoreFrame.origin.x);
  259. _7a.ty-=(_backingStoreFrame.origin.y);
  260. CGContextSaveGState(_context);
  261. CGContextConcatCTM(_context,_7a);
  262. if(_3a){
  263. _context.drawImage(_contents.buffer,(_bounds.origin.x),(_bounds.origin.y));
  264. }else{
  265. objj_msgSend(_78,"drawInContext:",_context);
  266. }
  267. CGContextRestoreGState(_context);
  268. }
  269. }),new objj_method(sel_getUid("display"),function(_7d,_7e){
  270. with(_7d){
  271. if(!_context){
  272. _context=CGBitmapGraphicsContextCreate();
  273. _DOMContentsElement=_context.DOMElement;
  274. _DOMContentsElement.style.zIndex=-100;
  275. _DOMContentsElement.style.overflow="hidden";
  276. _DOMContentsElement.style.position="absolute";
  277. _DOMContentsElement.style.visibility="visible";
  278. _DOMContentsElement.width=ROUND((_backingStoreFrame.size.width));
  279. _DOMContentsElement.height=ROUND((_backingStoreFrame.size.height));
  280. _DOMContentsElement.style.top="0px";
  281. _DOMContentsElement.style.left="0px";
  282. _DOMContentsElement.style.width=ROUND((_backingStoreFrame.size.width))+"px";
  283. _DOMContentsElement.style.height=ROUND((_backingStoreFrame.size.height))+"px";
  284. _DOMElement.appendChild(_DOMContentsElement);
  285. }
  286. if(_3a){
  287. if(_delegateRespondsToDisplayLayerSelector){
  288. return objj_msgSend(_delegate,"displayInLayer:",_7d);
  289. }
  290. if((_backingStoreFrame.size.width)==0||(_backingStoreFrame.size.height)==0){
  291. return;
  292. }
  293. if(!_contents){
  294. _contents=CABackingStoreCreate();
  295. }
  296. CABackingStoreSetSize(_contents,_bounds.size);
  297. objj_msgSend(_7d,"drawInContext:",CABackingStoreGetContext(_contents));
  298. }
  299. objj_msgSend(_7d,"composite");
  300. }
  301. }),new objj_method(sel_getUid("drawInContext:"),function(_7f,_80,_81){
  302. with(_7f){
  303. if(_backgroundColor){
  304. CGContextSetFillColor(_81,_backgroundColor);
  305. CGContextFillRect(_81,_bounds);
  306. }
  307. if(_delegateRespondsToDrawLayerInContextSelector){
  308. objj_msgSend(_delegate,"drawLayer:inContext:",_7f,_81);
  309. }
  310. }
  311. }),new objj_method(sel_getUid("opacity"),function(_82,_83){
  312. with(_82){
  313. return _opacity;
  314. }
  315. }),new objj_method(sel_getUid("setOpacity:"),function(_84,_85,_86){
  316. with(_84){
  317. if(_opacity==_86){
  318. return;
  319. }
  320. _opacity=_86;
  321. _DOMElement.style.opacity=_86;
  322. _DOMElement.style.filter="alpha(opacity="+_86*100+")";
  323. }
  324. }),new objj_method(sel_getUid("setHidden:"),function(_87,_88,_89){
  325. with(_87){
  326. _isHidden=_89;
  327. _DOMElement.style.display=_89?"none":"block";
  328. }
  329. }),new objj_method(sel_getUid("hidden"),function(_8a,_8b){
  330. with(_8a){
  331. return _isHidden;
  332. }
  333. }),new objj_method(sel_getUid("isHidden"),function(_8c,_8d){
  334. with(_8c){
  335. return _isHidden;
  336. }
  337. }),new objj_method(sel_getUid("setMasksToBounds:"),function(_8e,_8f,_90){
  338. with(_8e){
  339. if(_masksToBounds==_90){
  340. return;
  341. }
  342. _masksToBounds=_90;
  343. _DOMElement.style.overflow=_masksToBounds?"hidden":"visible";
  344. }
  345. }),new objj_method(sel_getUid("setBackgroundColor:"),function(_91,_92,_93){
  346. with(_91){
  347. _backgroundColor=_93;
  348. objj_msgSend(_91,"setNeedsDisplay");
  349. }
  350. }),new objj_method(sel_getUid("backgroundColor"),function(_94,_95){
  351. with(_94){
  352. return _backgroundColor;
  353. }
  354. }),new objj_method(sel_getUid("sublayers"),function(_96,_97){
  355. with(_96){
  356. return _sublayers;
  357. }
  358. }),new objj_method(sel_getUid("superlayer"),function(_98,_99){
  359. with(_98){
  360. return _superlayer;
  361. }
  362. }),new objj_method(sel_getUid("addSublayer:"),function(_9a,_9b,_9c){
  363. with(_9a){
  364. objj_msgSend(_9a,"insertSublayer:atIndex:",_9c,_sublayers.length);
  365. return;
  366. if(_DOMContentsElement&&_9c._zPosition>_DOMContentsElement.style.zIndex){
  367. _DOMContentsElement.style.zIndex-=100;
  368. }
  369. objj_msgSend(_sublayers,"addObject:",_9c);
  370. _DOMElement.appendChild(_9c._DOMElement);
  371. }
  372. }),new objj_method(sel_getUid("removeFromSuperlayer"),function(_9d,_9e){
  373. with(_9d){
  374. if(_owningView){
  375. objj_msgSend(_owningView,"setLayer:",nil);
  376. }
  377. if(!_superlayer){
  378. return;
  379. }
  380. _superlayer._DOMElement.removeChild(_DOMElement);
  381. objj_msgSend(_superlayer._sublayers,"removeObject:",_9d);
  382. _superlayer=nil;
  383. }
  384. }),new objj_method(sel_getUid("insertSublayer:atIndex:"),function(_9f,_a0,_a1,_a2){
  385. with(_9f){
  386. if(!_a1){
  387. return;
  388. }
  389. var _a3=objj_msgSend(_a1,"superlayer");
  390. if(_a3==_9f){
  391. var _a4=objj_msgSend(_sublayers,"indexOfObjectIdenticalTo:",_a1);
  392. if(_a4==_a2){
  393. return;
  394. }
  395. objj_msgSend(_sublayers,"removeObjectAtIndex:",_a4);
  396. if(_a4<_a2){
  397. --_a2;
  398. }
  399. }else{
  400. if(_a3!=nil){
  401. objj_msgSend(_a1,"removeFromSuperlayer");
  402. }
  403. }
  404. if(_DOMContentsElement&&_a1._zPosition>_DOMContentsElement.style.zIndex){
  405. _DOMContentsElement.style.zIndex-=100;
  406. }
  407. objj_msgSend(_sublayers,"insertObject:atIndex:",_a1,_a2);
  408. if(_a2>=_sublayers.length-1){
  409. _DOMElement.appendChild(_a1._DOMElement);
  410. }else{
  411. _DOMElement.insertBefore(_a1._DOMElement,_sublayers[_a2+1]._DOMElement);
  412. }
  413. _a1._superlayer=_9f;
  414. if(_9f!=_a3){
  415. _CALayerRecalculateGeometry(_a1,268435455);
  416. }
  417. }
  418. }),new objj_method(sel_getUid("insertSublayer:below:"),function(_a5,_a6,_a7,_a8){
  419. with(_a5){
  420. var _a9=_a8?objj_msgSend(_sublayers,"indexOfObjectIdenticalTo:",_a8):0;
  421. objj_msgSend(_a5,"insertSublayer:atIndex:",_a7,_a9==CPNotFound?_sublayers.length:_a9);
  422. }
  423. }),new objj_method(sel_getUid("insertSublayer:above:"),function(_aa,_ab,_ac,_ad){
  424. with(_aa){
  425. var _ae=_ad?objj_msgSend(_sublayers,"indexOfObjectIdenticalTo:",_ad):_sublayers.length;
  426. if(_ae==CPNotFound){
  427. objj_msgSend(CPException,"raise:reason:","CALayerNotFoundException","aSublayer is not a sublayer of this layer");
  428. }
  429. objj_msgSend(_sublayers,"insertObject:atIndex:",_ac,_ae==CPNotFound?_sublayers.length:_ae+1);
  430. }
  431. }),new objj_method(sel_getUid("replaceSublayer:with:"),function(_af,_b0,_b1,_b2){
  432. with(_af){
  433. if(_b1==_b2){
  434. return;
  435. }
  436. if(_b1._superlayer!=_af){
  437. alert("EXCEPTION");
  438. return;
  439. }
  440. if(_DOMContentsElement&&_b2._zPosition>_DOMContentsElement.style.zIndex){
  441. _DOMContentsElement.style.zIndex-=100;
  442. }
  443. objj_msgSend(_sublayers,"replaceObjectAtIndex:withObject:",objj_msgSend(_sublayers,"indexOfObjectIdenticalTo:",_b1),_b2);
  444. _DOMElement.replaceChild(_b1._DOMElement,_b2._DOMElement);
  445. }
  446. }),new objj_method(sel_getUid("registerRunLoopUpdateWithMask:"),function(_b3,_b4,_b5){
  447. with(_b3){
  448. if(_41==nil){
  449. _41={};
  450. objj_msgSend(objj_msgSend(CPRunLoop,"currentRunLoop"),"performSelector:target:argument:order:modes:",sel_getUid("runLoopUpdateLayers"),CALayer,nil,0,[CPDefaultRunLoopMode]);
  451. }
  452. _runLoopUpdateMask|=_b5;
  453. _41[objj_msgSend(_b3,"hash")]=_b3;
  454. }
  455. }),new objj_method(sel_getUid("setNeedsComposite"),function(_b6,_b7){
  456. with(_b6){
  457. objj_msgSend(_b6,"registerRunLoopUpdateWithMask:",_3f);
  458. }
  459. }),new objj_method(sel_getUid("setNeedsDisplay"),function(_b8,_b9){
  460. with(_b8){
  461. objj_msgSend(_b8,"registerRunLoopUpdateWithMask:",_3e);
  462. }
  463. }),new objj_method(sel_getUid("setNeedsDisplayOnBoundsChange:"),function(_ba,_bb,_bc){
  464. with(_ba){
  465. _needsDisplayOnBoundsChange=_bc;
  466. }
  467. }),new objj_method(sel_getUid("needsDisplayOnBoundsChange"),function(_bd,_be){
  468. with(_bd){
  469. return _needsDisplayOnBoundsChange;
  470. }
  471. }),new objj_method(sel_getUid("setNeedsDisplayInRect:"),function(_bf,_c0,_c1){
  472. with(_bf){
  473. _dirtyRect=_c1;
  474. objj_msgSend(_bf,"display");
  475. }
  476. }),new objj_method(sel_getUid("convertPoint:fromLayer:"),function(_c2,_c3,_c4,_c5){
  477. with(_c2){
  478. return CGPointApplyAffineTransform(_c4,_CALayerGetTransform(_c5,_c2));
  479. }
  480. }),new objj_method(sel_getUid("convertPoint:toLayer:"),function(_c6,_c7,_c8,_c9){
  481. with(_c6){
  482. return CGPointApplyAffineTransform(_c8,_CALayerGetTransform(_c6,_c9));
  483. }
  484. }),new objj_method(sel_getUid("convertRect:fromLayer:"),function(_ca,_cb,_cc,_cd){
  485. with(_ca){
  486. return CGRectApplyAffineTransform(_cc,_CALayerGetTransform(_cd,_ca));
  487. }
  488. }),new objj_method(sel_getUid("convertRect:toLayer:"),function(_ce,_cf,_d0,_d1){
  489. with(_ce){
  490. return CGRectApplyAffineTransform(_d0,_CALayerGetTransform(_ce,_d1));
  491. }
  492. }),new objj_method(sel_getUid("containsPoint:"),function(_d2,_d3,_d4){
  493. with(_d2){
  494. return (_d4.x>=(_bounds.origin.x)&&_d4.y>=(_bounds.origin.y)&&_d4.x<(_bounds.origin.x+_bounds.size.width)&&_d4.y<(_bounds.origin.y+_bounds.size.height));
  495. }
  496. }),new objj_method(sel_getUid("hitTest:"),function(_d5,_d6,_d7){
  497. with(_d5){
  498. if(_isHidden){
  499. return nil;
  500. }
  501. var _d8=CGPointApplyAffineTransform(_d7,_transformToLayer);
  502. if(!(_d8.x>=(_bounds.origin.x)&&_d8.y>=(_bounds.origin.y)&&_d8.x<(_bounds.origin.x+_bounds.size.width)&&_d8.y<(_bounds.origin.y+_bounds.size.height))){
  503. return nil;
  504. }
  505. var _d9=nil,_da=_sublayers.length;
  506. while(_da--){
  507. if(_d9=objj_msgSend(_sublayers[_da],"hitTest:",_d8)){
  508. return _d9;
  509. }
  510. }
  511. return _d5;
  512. }
  513. }),new objj_method(sel_getUid("setDelegate:"),function(_db,_dc,_dd){
  514. with(_db){
  515. if(_delegate==_dd){
  516. return;
  517. }
  518. _delegate=_dd;
  519. _delegateRespondsToDisplayLayerSelector=objj_msgSend(_delegate,"respondsToSelector:",sel_getUid("displayLayer:"));
  520. _delegateRespondsToDrawLayerInContextSelector=objj_msgSend(_delegate,"respondsToSelector:",sel_getUid("drawLayer:inContext:"));
  521. if(_delegateRespondsToDisplayLayerSelector||_delegateRespondsToDrawLayerInContextSelector){
  522. objj_msgSend(_db,"setNeedsDisplay");
  523. }
  524. }
  525. }),new objj_method(sel_getUid("delegate"),function(_de,_df){
  526. with(_de){
  527. return _delegate;
  528. }
  529. }),new objj_method(sel_getUid("_setOwningView:"),function(_e0,_e1,_e2){
  530. with(_e0){
  531. _owningView=_e2;
  532. if(_owningView){
  533. _owningView=_e2;
  534. _bounds.size=CGSizeMakeCopy(objj_msgSend(_owningView,"bounds").size);
  535. _position=CGPointMake((_bounds.size.width)*_anchorPoint.x,(_bounds.size.height)*_anchorPoint.y);
  536. }
  537. _CALayerRecalculateGeometry(_e0,_36|_35);
  538. }
  539. }),new objj_method(sel_getUid("_owningViewBoundsChanged"),function(_e3,_e4){
  540. with(_e3){
  541. _bounds.size=CGSizeMakeCopy(objj_msgSend(_owningView,"bounds").size);
  542. _position=CGPointMake((_bounds.size.width)*_anchorPoint.x,(_bounds.size.height)*_anchorPoint.y);
  543. _CALayerRecalculateGeometry(_e3,_36|_35);
  544. }
  545. }),new objj_method(sel_getUid("_update"),function(_e5,_e6){
  546. with(_e5){
  547. window.loop=true;
  548. var _e7=_runLoopUpdateMask;
  549. if(_e7&_40){
  550. _CALayerUpdateDOM(_e5,_e7);
  551. }
  552. if(_e7&_3e){
  553. objj_msgSend(_e5,"display");
  554. }else{
  555. if(_e7&_3c||_e7&_3f){
  556. objj_msgSend(_e5,"composite");
  557. }
  558. }
  559. _runLoopUpdateMask=0;
  560. window.loop=false;
  561. }
  562. })]);
  563. class_addMethods(_43,[new objj_method(sel_getUid("layer"),function(_e8,_e9){
  564. with(_e8){
  565. return objj_msgSend(objj_msgSend(objj_msgSend(_e8,"class"),"alloc"),"init");
  566. }
  567. }),new objj_method(sel_getUid("runLoopUpdateLayers"),function(_ea,_eb){
  568. with(_ea){
  569. if(window.oops){
  570. alert(window.latest);
  571. objj_debug_print_backtrace();
  572. }
  573. window.loop=true;
  574. for(hash in _41){
  575. var _ec=_41[hash],_ed=_ec._runLoopUpdateMask;
  576. if(_ed&_40){
  577. _CALayerUpdateDOM(_ec,_ed);
  578. }
  579. if(_ed&_3e){
  580. objj_msgSend(_ec,"display");
  581. }else{
  582. if(_ed&_3c||_ed&_3f){
  583. objj_msgSend(_ec,"composite");
  584. }
  585. }
  586. _ec._runLoopUpdateMask=0;
  587. }
  588. window.loop=false;
  589. _41=nil;
  590. }
  591. })]);
  592. _CALayerUpdateSublayerTransformForSublayers=function(_ee){
  593. var _ef=_ee._bounds,_f0=_ee._anchorPoint,_f1=(_ef.size.width)*_f0.x,_f2=(_ef.size.height)*_f0.y;
  594. _ee._sublayerTransformForSublayers=CGAffineTransformConcat(CGAffineTransformMakeTranslation(-_f1,-_f2),CGAffineTransformConcat(_ee._sublayerTransform,CGAffineTransformMakeTranslation(_f1,_f2)));
  595. };
  596. _CALayerUpdateDOM=function(_f3,_f4){
  597. var _f5=_f3._DOMElement.style;
  598. if(_f4&_3d){
  599. _f5.zIndex=_f3._zPosition;
  600. }
  601. var _f6=_f3._backingStoreFrame;
  602. if(_f4&_3b){
  603. _f5.top=ROUND((_f6.origin.y))+"px";
  604. _f5.left=ROUND((_f6.origin.x))+"px";
  605. }
  606. if(_f4&_3c){
  607. var _f7=MAX(0,ROUND((_f6.size.width))),_f8=MAX(0,ROUND((_f6.size.height))),_f9=_f3._DOMContentsElement;
  608. _f5.width=_f7+"px";
  609. _f5.height=_f8+"px";
  610. if(_f9){
  611. _f9.width=_f7;
  612. _f9.height=_f8;
  613. _f9.style.width=_f7+"px";
  614. _f9.style.height=_f8+"px";
  615. }
  616. }
  617. };
  618. _CALayerRecalculateGeometry=function(_fa,_fb){
  619. var _fc=_fa._bounds,_fd=_fa._superlayer,_fe=(_fc.size.width),_ff=(_fc.size.height),_100=_fa._position,_101=_fa._anchorPoint,_102=_fa._affineTransform,_103={width:_fa._backingStoreFrame.width,height:_fa._backingStoreFrame.height},_104=_fa._hasCustomBackingStoreFrame;
  620. _fa._transformFromLayer=CGAffineTransformConcat(CGAffineTransformMakeTranslation(-_fe*_101.x-(_fa._bounds.origin.x),-_ff*_101.y-(_fa._bounds.origin.y)),CGAffineTransformConcat(_102,CGAffineTransformMakeTranslation(_100.x,_100.y)));
  621. if(_fd&&_fd._hasSublayerTransform){
  622. var tx=_fa._transformFromLayer.tx*_fd._sublayerTransformForSublayers.a+_fa._transformFromLayer.ty*_fd._sublayerTransformForSublayers.c+_fd._sublayerTransformForSublayers.tx;
  623. _fa._transformFromLayer.ty=_fa._transformFromLayer.tx*_fd._sublayerTransformForSublayers.b+_fa._transformFromLayer.ty*_fd._sublayerTransformForSublayers.d+_fd._sublayerTransformForSublayers.ty;
  624. _fa._transformFromLayer.tx=tx;
  625. var a=_fa._transformFromLayer.a*_fd._sublayerTransformForSublayers.a+_fa._transformFromLayer.b*_fd._sublayerTransformForSublayers.c,b=_fa._transformFromLayer.a*_fd._sublayerTransformForSublayers.b+_fa._transformFromLayer.b*_fd._sublayerTransformForSublayers.d,c=_fa._transformFromLayer.c*_fd._sublayerTransformForSublayers.a+_fa._transformFromLayer.d*_fd._sublayerTransformForSublayers.c;
  626. _fa._transformFromLayer.d=_fa._transformFromLayer.c*_fd._sublayerTransformForSublayers.b+_fa._transformFromLayer.d*_fd._sublayerTransformForSublayers.d;
  627. _fa._transformFromLayer.a=a;
  628. _fa._transformFromLayer.b=b;
  629. _fa._transformFromLayer.c=c;
  630. }
  631. _fa._transformToLayer=CGAffineTransformInvert(_fa._transformFromLayer);
  632. _fa._frame=nil;
  633. _fa._standardBackingStoreFrame=objj_msgSend(_fa,"convertRect:toLayer:",_fc,nil);
  634. if(_fd){
  635. var _fc=objj_msgSend(_fd,"bounds"),_109=objj_msgSend(_fd,"convertRect:toLayer:",_fc,nil);
  636. _fa._standardBackingStoreFrame.origin.x-=(_109.origin.x);
  637. _fa._standardBackingStoreFrame.origin.y-=(_109.origin.y);
  638. }
  639. var _10a=_fa._standardBackingStoreFrame.origin,size=_fa._standardBackingStoreFrame.size;
  640. _10a.x=FLOOR(_10a.x);
  641. _10a.y=FLOOR(_10a.y);
  642. size.width=CEIL(size.width)+1;
  643. size.height=CEIL(size.height)+1;
  644. if(!_104){
  645. var _10c=CGRectMakeCopy(_fa._standardBackingStoreFrame);
  646. if(ROUND((_10c.origin.x))!=ROUND((_fa._backingStoreFrame.origin.x))||ROUND((_10c.origin.y))!=ROUND((_fa._backingStoreFrame.origin.y))){
  647. objj_msgSend(_fa,"registerRunLoopUpdateWithMask:",_3b);
  648. }
  649. if(((_10c.size.width)!=ROUND((_fa._backingStoreFrame.size.width))||(_10c.size.height)!=ROUND((_fa._backingStoreFrame.size.height)))){
  650. objj_msgSend(_fa,"registerRunLoopUpdateWithMask:",_3c);
  651. }
  652. _fa._backingStoreFrame=_10c;
  653. }
  654. if(_fb&_35&&_fa._needsDisplayOnBoundsChange){
  655. objj_msgSend(_fa,"setNeedsDisplay");
  656. }else{
  657. if(_104||(_fb&~(_36|_37))){
  658. objj_msgSend(_fa,"setNeedsComposite");
  659. }
  660. }
  661. var _10d=_fa._sublayers,_10e=0,_10f=_10d.length;
  662. for(;_10e<_10f;++_10e){
  663. _CALayerRecalculateGeometry(_10d[_10e],_fb);
  664. }
  665. };
  666. _CALayerGetTransform=function(_110,_111){
  667. var _112=CGAffineTransformMakeIdentity();
  668. if(_110){
  669. var _113=_110;
  670. while(_113&&_113!=_111){
  671. var _114=_113._transformFromLayer;
  672. var tx=_112.tx*_114.a+_112.ty*_114.c+_114.tx;
  673. _112.ty=_112.tx*_114.b+_112.ty*_114.d+_114.ty;
  674. _112.tx=tx;
  675. var a=_112.a*_114.a+_112.b*_114.c,b=_112.a*_114.b+_112.b*_114.d,c=_112.c*_114.a+_112.d*_114.c;
  676. _112.d=_112.c*_114.b+_112.d*_114.d;
  677. _112.a=a;
  678. _112.b=b;
  679. _112.c=c;
  680. _113=_113._superlayer;
  681. }
  682. if(_113==_111){
  683. return _112;
  684. }
  685. }
  686. var _119=[],_113=_111;
  687. while(_113){
  688. _119.push(_113);
  689. _113=_113._superlayer;
  690. }
  691. var _11a=_119.length;
  692. while(_11a--){
  693. var _11b=_119[_11a]._transformToLayer;
  694. var tx=_112.tx*_11b.a+_112.ty*_11b.c+_11b.tx;
  695. _112.ty=_112.tx*_11b.b+_112.ty*_11b.d+_11b.ty;
  696. _112.tx=tx;
  697. var a=_112.a*_11b.a+_112.b*_11b.c,b=_112.a*_11b.b+_112.b*_11b.d,c=_112.c*_11b.a+_112.d*_11b.c;
  698. _112.d=_112.c*_11b.b+_112.d*_11b.d;
  699. _112.a=a;
  700. _112.b=b;
  701. _112.c=c;
  702. }
  703. return _112;
  704. };