Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C422918AB4 for ; Tue, 10 Nov 2015 01:01:53 +0000 (UTC) Received: (qmail 32301 invoked by uid 500); 10 Nov 2015 01:01:53 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 32261 invoked by uid 500); 10 Nov 2015 01:01:53 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 32248 invoked by uid 99); 10 Nov 2015 01:01:53 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Nov 2015 01:01:53 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 76AF4E07E9; Tue, 10 Nov 2015 01:01:53 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: purplecabbage@apache.org To: commits@cordova.apache.org Date: Tue, 10 Nov 2015 01:01:53 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/2] ios commit: Removed wk-webview exec and some linting Repository: cordova-ios Updated Branches: refs/heads/master 4a0bb3a8c -> 361816225 Removed wk-webview exec and some linting Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/21a71fe8 Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/21a71fe8 Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/21a71fe8 Branch: refs/heads/master Commit: 21a71fe89ffe575d1b70ce51aa9957777ac23f17 Parents: 4a0bb3a Author: Jesse MacFadyen Authored: Fri Nov 6 17:53:29 2015 -0800 Committer: Jesse MacFadyen Committed: Fri Nov 6 17:53:29 2015 -0800 ---------------------------------------------------------------------- cordova-js-src/exec.js | 72 ++++++++++----------------------------------- 1 file changed, 16 insertions(+), 56 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/21a71fe8/cordova-js-src/exec.js ---------------------------------------------------------------------- diff --git a/cordova-js-src/exec.js b/cordova-js-src/exec.js index d5354b1..11c6f55 100644 --- a/cordova-js-src/exec.js +++ b/cordova-js-src/exec.js @@ -19,25 +19,16 @@ * */ +/*global require, module, atob, document */ + /** * Creates a gap bridge iframe used to notify the native code about queued * commands. */ var cordova = require('cordova'), - channel = require('cordova/channel'), utils = require('cordova/utils'), base64 = require('cordova/base64'), - jsToNativeModes = { - IFRAME_NAV: 0, // Default. Uses a new iframe for each poke. - WK_WEBVIEW_BINDING: 1 // Only way that works for WKWebView :) - }, - bridgeMode, execIframe, - execHashIframe, - hashToggle = 1, - execXhr, - requestCount = 0, - vcHeaderValue = null, commandQueue = [], // Contains pending JS->Native messages. isInContextOfEvalJs = 0, failSafeTimerId = 0; @@ -92,17 +83,10 @@ function convertMessageToArgsNativeToJs(message) { } function iOSExec() { - if (bridgeMode === undefined) { - bridgeMode = jsToNativeModes.IFRAME_NAV; - } - - if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.cordova && window.webkit.messageHandlers.cordova.postMessage) { - bridgeMode = jsToNativeModes.WK_WEBVIEW_BINDING; - } - var successCallback, failCallback, service, action, actionArgs, splitCommand; + var successCallback, failCallback, service, action, actionArgs; var callbackId = null; - if (typeof arguments[0] !== "string") { + if (typeof arguments[0] !== 'string') { // FORMAT ONE successCallback = arguments[0]; failCallback = arguments[1]; @@ -136,21 +120,17 @@ function iOSExec() { var command = [callbackId, service, action, actionArgs]; - if (bridgeMode === jsToNativeModes.WK_WEBVIEW_BINDING) { - window.webkit.messageHandlers.cordova.postMessage(command); - } else { - // Stringify and queue the command. We stringify to command now to - // effectively clone the command arguments in case they are mutated before - // the command is executed. - commandQueue.push(JSON.stringify(command)); - - // If we're in the context of a stringByEvaluatingJavaScriptFromString call, - // then the queue will be flushed when it returns; no need for a poke. - // Also, if there is already a command in the queue, then we've already - // poked the native side, so there is no reason to do so again. - if (!isInContextOfEvalJs && commandQueue.length == 1) { - pokeNative(); - } + // Stringify and queue the command. We stringify to command now to + // effectively clone the command arguments in case they are mutated before + // the command is executed. + commandQueue.push(JSON.stringify(command)); + + // If we're in the context of a stringByEvaluatingJavaScriptFromString call, + // then the queue will be flushed when it returns; no need for a poke. + // Also, if there is already a command in the queue, then we've already + // poked the native side, so there is no reason to do so again. + if (!isInContextOfEvalJs && commandQueue.length == 1) { + pokeNative(); } } @@ -184,21 +164,6 @@ function pokeNative() { }, 50); // Making this > 0 improves performance (marginally) in the normal case (where it doesn't fire). } -iOSExec.jsToNativeModes = jsToNativeModes; - -iOSExec.setJsToNativeBridgeMode = function(mode) { - // Remove the iFrame since it may be no longer required, and its existence - // can trigger browser bugs. - // https://issues.apache.org/jira/browse/CB-593 - if (execIframe) { - if (execIframe.parentNode) { - execIframe.parentNode.removeChild(execIframe); - } - execIframe = null; - } - bridgeMode = mode; -}; - iOSExec.nativeFetchMessages = function() { // Stop listing for window detatch once native side confirms poke. if (failSafeTimerId) { @@ -221,12 +186,7 @@ iOSExec.nativeCallback = function(callbackId, status, message, keepCallback, deb function nc2() { cordova.callbackFromNative(callbackId, success, status, args, keepCallback); } - // CB-8468 - if (debug) { - setTimeout(nc2, 0); - } else { - nc2(); - } + setTimeout(nc2, 0); }); }; --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org For additional commands, e-mail: commits-help@cordova.apache.org