@@ -37,7 +37,7 @@ cc.DENSITYDPI_LOW = "low-dpi";
3737
3838var __BrowserGetter = {
3939 init : function ( ) {
40- this . html = document . getElementsByTagName ( "html" ) [ 0 ] ;
40+ this . html = document . documentElement ;
4141 } ,
4242 availWidth : function ( frame ) {
4343 if ( ! frame || frame === this . html )
@@ -66,25 +66,11 @@ if (cc.sys.os === cc.sys.OS_IOS) // All browsers are WebView
6666switch ( __BrowserGetter . adaptationType ) {
6767 case cc . sys . BROWSER_TYPE_SAFARI :
6868 __BrowserGetter . meta [ "minimal-ui" ] = "true" ;
69- __BrowserGetter . availWidth = function ( frame ) {
70- return frame . clientWidth ;
71- } ;
72- __BrowserGetter . availHeight = function ( frame ) {
73- return frame . clientHeight ;
74- } ;
7569 break ;
7670 case cc . sys . BROWSER_TYPE_CHROME :
7771 __BrowserGetter . __defineGetter__ ( "target-densitydpi" , function ( ) {
7872 return cc . view . _targetDensityDPI ;
7973 } ) ;
80- case cc . sys . BROWSER_TYPE_SOUGOU :
81- case cc . sys . BROWSER_TYPE_UC :
82- __BrowserGetter . availWidth = function ( frame ) {
83- return frame . clientWidth ;
84- } ;
85- __BrowserGetter . availHeight = function ( frame ) {
86- return frame . clientHeight ;
87- } ;
8874 break ;
8975 case cc . sys . BROWSER_TYPE_MIUI :
9076 __BrowserGetter . init = function ( view ) {
@@ -318,9 +304,11 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{
318304 orientation = orientation & cc . ORIENTATION_AUTO ;
319305 if ( orientation && this . _orientation !== orientation ) {
320306 this . _orientation = orientation ;
321- var designWidth = this . _originalDesignResolutionSize . width ;
322- var designHeight = this . _originalDesignResolutionSize . height ;
323- this . setDesignResolutionSize ( designWidth , designHeight , this . _resolutionPolicy ) ;
307+ if ( this . _resolutionPolicy ) {
308+ var designWidth = this . _originalDesignResolutionSize . width ;
309+ var designHeight = this . _originalDesignResolutionSize . height ;
310+ this . setDesignResolutionSize ( designWidth , designHeight , this . _resolutionPolicy ) ;
311+ }
324312 }
325313 } ,
326314
@@ -342,7 +330,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{
342330 var h = __BrowserGetter . availHeight ( this . _frame ) ;
343331 var isLandscape = w >= h ;
344332
345- if ( ! this . _orientationChanging || ! cc . sys . isMobile ||
333+ if ( ! cc . sys . isMobile ||
346334 ( isLandscape && this . _orientation & cc . ORIENTATION_LANDSCAPE ) ||
347335 ( ! isLandscape && this . _orientation & cc . ORIENTATION_PORTRAIT ) ) {
348336 locFrameSize . width = w ;
@@ -577,17 +565,10 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{
577565 this . _frameSize . height = height ;
578566 this . _frame . style . width = width + "px" ;
579567 this . _frame . style . height = height + "px" ;
580- //this.centerWindow();
581568 this . _resizeEvent ( ) ;
582569 cc . director . setProjection ( cc . director . getProjection ( ) ) ;
583570 } ,
584571
585- /**
586- * Empty function
587- */
588- centerWindow : function ( ) {
589- } ,
590-
591572 /**
592573 * Returns the visible area size of the view port.
593574 * @return {cc.Size }
@@ -697,6 +678,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{
697678
698679 // Permit to re-detect the orientation of device.
699680 this . _orientationChanging = true ;
681+ // If resizing, then frame size is already initialized, this logic should be improved
700682 if ( ! this . _resizing )
701683 this . _initFrameSize ( ) ;
702684
@@ -850,13 +832,13 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{
850832 var boxArr = gl . getParameter ( gl . SCISSOR_BOX ) ;
851833 _scissorRect = cc . rect ( boxArr [ 0 ] , boxArr [ 1 ] , boxArr [ 2 ] , boxArr [ 3 ] ) ;
852834 }
853- var scaleX = this . _scaleX ;
854- var scaleY = this . _scaleY ;
835+ var scaleXFactor = 1 / this . _scaleX ;
836+ var scaleYFactor = 1 / this . _scaleY ;
855837 return cc . rect (
856- ( _scissorRect . x - this . _viewPortRect . x ) / scaleX ,
857- ( _scissorRect . y - this . _viewPortRect . y ) / scaleY ,
858- _scissorRect . width / scaleX ,
859- _scissorRect . height / scaleY
838+ ( _scissorRect . x - this . _viewPortRect . x ) * scaleXFactor ,
839+ ( _scissorRect . y - this . _viewPortRect . y ) * scaleYFactor ,
840+ _scissorRect . width * scaleXFactor ,
841+ _scissorRect . height * scaleYFactor
860842 ) ;
861843 } ,
862844
@@ -1106,7 +1088,7 @@ cc.ContentStrategy = cc.Class.extend(/** @lends cc.ContentStrategy# */{
11061088 this . _setupContainer ( view , view . _frameSize . width , view . _frameSize . height ) ;
11071089 // Setup container's margin and padding
11081090 if ( view . _isRotated ) {
1109- containerStyle . marginLeft = frameH + 'px' ;
1091+ containerStyle . margin = '0 0 0 ' + frameH + 'px' ;
11101092 }
11111093 else {
11121094 containerStyle . margin = '0px' ;
@@ -1136,7 +1118,7 @@ cc.ContentStrategy = cc.Class.extend(/** @lends cc.ContentStrategy# */{
11361118 this . _setupContainer ( view , containerW , containerH ) ;
11371119 // Setup container's margin and padding
11381120 if ( view . _isRotated ) {
1139- containerStyle . marginLeft = frameH + 'px' ;
1121+ containerStyle . margin = '0 0 0 ' + frameH + 'px' ;
11401122 }
11411123 else {
11421124 containerStyle . margin = '0px' ;
0 commit comments