Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / devtools / front_end / script_formatter_worker / ScriptFormatterWorker.js
index d278ecb..c1518c2 100644 (file)
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-importScripts("../common/utilities.js");
-importScripts("../cm/headlesscodemirror.js");
-importScripts("../cm/css.js");
-importScripts("../cm/javascript.js");
-importScripts("../cm/xml.js");
-importScripts("../cm/htmlmixed.js");
-WebInspector = {};
 FormatterWorker = {
     /**
      * @param {string} mimeType
@@ -150,7 +143,11 @@ FormatterWorker.javaScriptOutline = function(params)
      */
     function processToken(tokenValue, tokenType, column, newColumn)
     {
-        if (isJavaScriptIdentifier(tokenType)) {
+        if (tokenType === "property" && previousTokenType === "property" && (previousToken === "get" || previousToken === "set")) {
+            currentFunction = { line: i, column: column, name: previousToken + " " + tokenValue };
+            addedFunction = true;
+            previousIdentifier = null;
+        } else if (isJavaScriptIdentifier(tokenType)) {
             previousIdentifier = tokenValue;
             if (tokenValue && previousToken === "function") {
                 // A named function: "function f...".
@@ -279,7 +276,7 @@ FormatterWorker.parseCSS = function(params)
             }
             break;
         case FormatterWorker.CSSParserStates.PropertyName:
-            if (tokenValue === ":" && tokenType["operator"]) {
+            if (tokenValue === ":" && tokenType === UndefTokenType) {
                 property.name = property.name.trim();
                 state = FormatterWorker.CSSParserStates.PropertyValue;
             } else if (tokenType["property"]) {
@@ -389,28 +386,41 @@ FormatterWorker.HTMLFormatter.prototype = {
         var scriptOpened = false;
         var styleOpened = false;
         var tokenizer = FormatterWorker.createTokenizer("text/html");
+        var accumulatedTokenValue = "";
+        var accumulatedTokenStart = 0;
 
         /**
          * @this {FormatterWorker.HTMLFormatter}
          */
         function processToken(tokenValue, tokenType, tokenStart, tokenEnd) {
-            if (tokenType !== "tag")
+            if (!tokenType)
                 return;
-            if (tokenValue.toLowerCase() === "<script") {
+            var oldType = tokenType;
+            tokenType = tokenType.split(" ").keySet();
+            if (!tokenType["tag"])
+                return;
+            if (tokenType["bracket"] && (tokenValue === "<" || tokenValue === "</")) {
+                accumulatedTokenValue = tokenValue;
+                accumulatedTokenStart = tokenStart;
+                return;
+            }
+            accumulatedTokenValue = accumulatedTokenValue + tokenValue.toLowerCase();
+            if (accumulatedTokenValue === "<script") {
                 scriptOpened = true;
             } else if (scriptOpened && tokenValue === ">") {
                 scriptOpened = false;
                 this._scriptStarted(tokenEnd);
-            } else if (tokenValue.toLowerCase() === "</script") {
-                this._scriptEnded(tokenStart);
-            } else if (tokenValue.toLowerCase() === "<style") {
+            } else if (accumulatedTokenValue === "</script") {
+                this._scriptEnded(accumulatedTokenStart);
+            } else if (accumulatedTokenValue === "<style") {
                 styleOpened = true;
             } else if (styleOpened && tokenValue === ">") {
                 styleOpened = false;
                 this._styleStarted(tokenEnd);
-            } else if (tokenValue.toLowerCase() === "</style") {
-                this._styleEnded(tokenStart);
+            } else if (accumulatedTokenValue === "</style") {
+                this._styleEnded(accumulatedTokenStart);
             }
+            accumulatedTokenValue = "";
         }
         tokenizer(content, processToken.bind(this));
 
@@ -484,15 +494,11 @@ FormatterWorker.HTMLFormatter.prototype = {
  */
 function require()
 {
-    return parse;
+    return tokenizerHolder;
 }
 
 /**
  * @type {!{tokenizer}}
  */
 var exports = { tokenizer: null };
-importScripts("../UglifyJS/parse-js.js");
-var parse = exports;
-
-importScripts("JavaScriptFormatter.js");
-importScripts("CSSFormatter.js");
+var tokenizerHolder = exports;