Skip to content

Commit 47cb200

Browse files
authored
Merge pull request #3470 from pandamicro/develop
Refactor Editbox to have better user experience and some issue fix
2 parents 2292d7d + 3131889 commit 47cb200

File tree

4 files changed

+184
-198
lines changed

4 files changed

+184
-198
lines changed

CCBoot.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1758,8 +1758,8 @@ var _initSys = function () {
17581758
sys.browserVersion = "";
17591759
/* Determine the browser version number */
17601760
(function(){
1761-
var versionReg1 = /(micromessenger|mqqbrowser|qq|maxthon|baidu|sogou)(mobile)?(browser)?\/?([\d.]+)/i;
1762-
var versionReg2 = /(msie |rv:|firefox|chrome|ucbrowser|oupeng|opera|opr|safari|miui)(mobile)?(browser)?\/?([\d.]+)/i;
1761+
var versionReg1 = /(mqqbrowser|micromessenger|sogou|qzone|liebao|maxthon|baidu)(mobile)?(browser)?\/?([\d.]+)/i;
1762+
var versionReg2 = /(msie |rv:|firefox|chrome|ucbrowser|qq|oupeng|opera|opr|safari|miui)(mobile)?(browser)?\/?([\d.]+)/i;
17631763
var tmp = ua.match(versionReg1);
17641764
if(!tmp) tmp = ua.match(versionReg2);
17651765
sys.browserVersion = tmp ? tmp[4] : "";

cocos2d/core/platform/CCEGLView.js

+16-34
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ cc.DENSITYDPI_LOW = "low-dpi";
3737

3838
var __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
6666
switch (__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';

cocos2d/core/renderer/RendererCanvas.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@ cc.rendererCanvas = {
163163

164164
ctx.setTransform(1, 0, 0, 1, 0, 0);
165165
ctx.clearRect(0, 0, viewport.width, viewport.height);
166-
if (this._clearColor.r !== 0 ||
167-
this._clearColor.g !== 0 ||
168-
this._clearColor.b !== 0) {
166+
if (this._clearColor.r !== 255 ||
167+
this._clearColor.g !== 255 ||
168+
this._clearColor.b !== 255) {
169169
wrapper.setFillStyle(this._clearFillStyle);
170170
wrapper.setGlobalAlpha(this._clearColor.a);
171171
ctx.fillRect(0, 0, viewport.width, viewport.height);

0 commit comments

Comments
 (0)