home *** CD-ROM | disk | FTP | other *** search
/ Computer Active 2010 July / CA07.iso / Multimedija / QuickTimeInstaller.exe / AppleApplicationSupport.msi / WebKit.resources_inspector_ScriptView.js < prev    next >
Encoding:
Text File  |  2010-03-15  |  4.2 KB  |  104 lines

  1. /*
  2.  * Copyright (C) 2008 Apple Inc. All Rights Reserved.
  3.  *
  4.  * Redistribution and use in source and binary forms, with or without
  5.  * modification, are permitted provided that the following conditions
  6.  * are met:
  7.  * 1. Redistributions of source code must retain the above copyright
  8.  *    notice, this list of conditions and the following disclaimer.
  9.  * 2. Redistributions in binary form must reproduce the above copyright
  10.  *    notice, this list of conditions and the following disclaimer in the
  11.  *    documentation and/or other materials provided with the distribution.
  12.  *
  13.  * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
  14.  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  15.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  16.  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
  17.  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  18.  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  19.  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  20.  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  21.  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  23.  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24.  */
  25.  
  26. WebInspector.ScriptView = function(script)
  27. {
  28.     WebInspector.View.call(this);
  29.  
  30.     this.element.addStyleClass("script-view");
  31.  
  32.     this.script = script;
  33.  
  34.     this._frameNeedsSetup = true;
  35.     this._sourceFrameSetup = false;
  36.  
  37.     this.sourceFrame = new WebInspector.SourceFrame(null, this._addBreakpoint.bind(this));
  38.  
  39.     this.element.appendChild(this.sourceFrame.element);
  40. }
  41.  
  42. WebInspector.ScriptView.prototype = {
  43.     show: function(parentElement)
  44.     {
  45.         WebInspector.View.prototype.show.call(this, parentElement);
  46.         this.setupSourceFrameIfNeeded();
  47.     },
  48.  
  49.     hide: function()
  50.     {
  51.         WebInspector.View.prototype.hide.call(this);
  52.         this._currentSearchResultIndex = -1;
  53.     },
  54.  
  55.     setupSourceFrameIfNeeded: function()
  56.     {
  57.         if (!this._frameNeedsSetup)
  58.             return;
  59.  
  60.         this.attach();
  61.  
  62.         if (!InspectorController.addSourceToFrame("text/javascript", this.script.source, this.sourceFrame.element))
  63.             return;
  64.  
  65.         delete this._frameNeedsSetup;
  66.  
  67.         this.sourceFrame.addEventListener("syntax highlighting complete", this._syntaxHighlightingComplete, this);
  68.         this.sourceFrame.syntaxHighlightJavascript();
  69.     },
  70.  
  71.     attach: function()
  72.     {
  73.         if (!this.element.parentNode)
  74.             document.getElementById("script-resource-views").appendChild(this.element);
  75.     },
  76.  
  77.     _addBreakpoint: function(line)
  78.     {
  79.         var breakpoint = new WebInspector.Breakpoint(this.script.sourceURL, line, this.script.sourceID);
  80.         WebInspector.panels.scripts.addBreakpoint(breakpoint);
  81.     },
  82.  
  83.     // The follow methods are pulled from SourceView, since they are
  84.     // generic and work with ScriptView just fine.
  85.  
  86.     revealLine: WebInspector.SourceView.prototype.revealLine,
  87.     highlightLine: WebInspector.SourceView.prototype.highlightLine,
  88.     addMessage: WebInspector.SourceView.prototype.addMessage,
  89.     clearMessages: WebInspector.SourceView.prototype.clearMessages,
  90.     searchCanceled: WebInspector.SourceView.prototype.searchCanceled,
  91.     performSearch: WebInspector.SourceView.prototype.performSearch,
  92.     jumpToFirstSearchResult: WebInspector.SourceView.prototype.jumpToFirstSearchResult,
  93.     jumpToLastSearchResult: WebInspector.SourceView.prototype.jumpToLastSearchResult,
  94.     jumpToNextSearchResult: WebInspector.SourceView.prototype.jumpToNextSearchResult,
  95.     jumpToPreviousSearchResult: WebInspector.SourceView.prototype.jumpToPreviousSearchResult,
  96.     showingFirstSearchResult: WebInspector.SourceView.prototype.showingFirstSearchResult,
  97.     showingLastSearchResult: WebInspector.SourceView.prototype.showingLastSearchResult,
  98.     _jumpToSearchResult: WebInspector.SourceView.prototype._jumpToSearchResult,
  99.     _sourceFrameSetupFinished: WebInspector.SourceView.prototype._sourceFrameSetupFinished,
  100.     _syntaxHighlightingComplete: WebInspector.SourceView.prototype._syntaxHighlightingComplete
  101. }
  102.  
  103. WebInspector.ScriptView.prototype.__proto__ = WebInspector.View.prototype;
  104.