@@ -37,7 +37,7 @@ cc.DENSITYDPI_LOW = "low-dpi";
37
37
38
38
var __BrowserGetter = {
39
39
init : function ( ) {
40
- this . html = document . getElementsByTagName ( "html" ) [ 0 ] ;
40
+ this . html = document . documentElement ;
41
41
} ,
42
42
availWidth : function ( frame ) {
43
43
if ( ! frame || frame === this . html )
@@ -66,25 +66,11 @@ if (cc.sys.os === cc.sys.OS_IOS) // All browsers are WebView
66
66
switch ( __BrowserGetter . adaptationType ) {
67
67
case cc . sys . BROWSER_TYPE_SAFARI :
68
68
__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
- } ;
75
69
break ;
76
70
case cc . sys . BROWSER_TYPE_CHROME :
77
71
__BrowserGetter . __defineGetter__ ( "target-densitydpi" , function ( ) {
78
72
return cc . view . _targetDensityDPI ;
79
73
} ) ;
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
- } ;
88
74
break ;
89
75
case cc . sys . BROWSER_TYPE_MIUI :
90
76
__BrowserGetter . init = function ( view ) {
@@ -318,9 +304,11 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{
318
304
orientation = orientation & cc . ORIENTATION_AUTO ;
319
305
if ( orientation && this . _orientation !== orientation ) {
320
306
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
+ }
324
312
}
325
313
} ,
326
314
@@ -342,7 +330,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{
342
330
var h = __BrowserGetter . availHeight ( this . _frame ) ;
343
331
var isLandscape = w >= h ;
344
332
345
- if ( ! this . _orientationChanging || ! cc . sys . isMobile ||
333
+ if ( ! cc . sys . isMobile ||
346
334
( isLandscape && this . _orientation & cc . ORIENTATION_LANDSCAPE ) ||
347
335
( ! isLandscape && this . _orientation & cc . ORIENTATION_PORTRAIT ) ) {
348
336
locFrameSize . width = w ;
@@ -577,17 +565,10 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{
577
565
this . _frameSize . height = height ;
578
566
this . _frame . style . width = width + "px" ;
579
567
this . _frame . style . height = height + "px" ;
580
- //this.centerWindow();
581
568
this . _resizeEvent ( ) ;
582
569
cc . director . setProjection ( cc . director . getProjection ( ) ) ;
583
570
} ,
584
571
585
- /**
586
- * Empty function
587
- */
588
- centerWindow : function ( ) {
589
- } ,
590
-
591
572
/**
592
573
* Returns the visible area size of the view port.
593
574
* @return {cc.Size }
@@ -697,6 +678,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{
697
678
698
679
// Permit to re-detect the orientation of device.
699
680
this . _orientationChanging = true ;
681
+ // If resizing, then frame size is already initialized, this logic should be improved
700
682
if ( ! this . _resizing )
701
683
this . _initFrameSize ( ) ;
702
684
@@ -850,13 +832,13 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{
850
832
var boxArr = gl . getParameter ( gl . SCISSOR_BOX ) ;
851
833
_scissorRect = cc . rect ( boxArr [ 0 ] , boxArr [ 1 ] , boxArr [ 2 ] , boxArr [ 3 ] ) ;
852
834
}
853
- var scaleX = this . _scaleX ;
854
- var scaleY = this . _scaleY ;
835
+ var scaleXFactor = 1 / this . _scaleX ;
836
+ var scaleYFactor = 1 / this . _scaleY ;
855
837
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
860
842
) ;
861
843
} ,
862
844
@@ -1106,7 +1088,7 @@ cc.ContentStrategy = cc.Class.extend(/** @lends cc.ContentStrategy# */{
1106
1088
this . _setupContainer ( view , view . _frameSize . width , view . _frameSize . height ) ;
1107
1089
// Setup container's margin and padding
1108
1090
if ( view . _isRotated ) {
1109
- containerStyle . marginLeft = frameH + 'px' ;
1091
+ containerStyle . margin = '0 0 0 ' + frameH + 'px' ;
1110
1092
}
1111
1093
else {
1112
1094
containerStyle . margin = '0px' ;
@@ -1136,7 +1118,7 @@ cc.ContentStrategy = cc.Class.extend(/** @lends cc.ContentStrategy# */{
1136
1118
this . _setupContainer ( view , containerW , containerH ) ;
1137
1119
// Setup container's margin and padding
1138
1120
if ( view . _isRotated ) {
1139
- containerStyle . marginLeft = frameH + 'px' ;
1121
+ containerStyle . margin = '0 0 0 ' + frameH + 'px' ;
1140
1122
}
1141
1123
else {
1142
1124
containerStyle . margin = '0px' ;
0 commit comments