Commit 24112032 authored by pfeldman@chromium.org's avatar pfeldman@chromium.org

2010-01-27 Pavel Feldman <pfeldman@chromium.org>

        Reviewed by Timothy Hatcher.

        Web Inspector: migrate from SourceFrame to SourceFrame2.

        https://bugs.webkit.org/show_bug.cgi?id=34171

        * WebCore.gypi:
        * WebCore.vcproj/WebCore.vcproj:
        * bindings/js/JSInspectorFrontendHostCustom.cpp:
        * bindings/v8/custom/V8InspectorFrontendHostCustom.cpp:
        * inspector/InspectorFrontendHost.cpp:
        * inspector/InspectorFrontendHost.h:
        * inspector/InspectorFrontendHost.idl:
        * inspector/front-end/InspectorBackendStub.js:
        * inspector/front-end/InspectorFrontendHostStub.js:
        * inspector/front-end/ResourceView.js:
        (WebInspector.ResourceView.prototype._innerSelectContentTab):
        * inspector/front-end/ResourcesPanel.js:
        (WebInspector.getResourceContent):
        * inspector/front-end/ScriptView.js:
        (WebInspector.ScriptView):
        (WebInspector.ScriptView.prototype.setupSourceFrameIfNeeded):
        * inspector/front-end/ScriptsPanel.js:
        (WebInspector.ScriptsPanel.prototype._sidebarResizeDrag):
        * inspector/front-end/SourceFrame.js:
        (WebInspector.SourceFrame):
        (WebInspector.SourceFrame.prototype.set executionLine):
        (WebInspector.SourceFrame.prototype.revealLine):
        (WebInspector.SourceFrame.prototype.addBreakpoint):
        (WebInspector.SourceFrame.prototype.removeBreakpoint):
        (WebInspector.SourceFrame.prototype.addMessage):
        (WebInspector.SourceFrame.prototype.clearMessages):
        (WebInspector.SourceFrame.prototype.sizeToFitContentHeight):
        (WebInspector.SourceFrame.prototype.setContent):
        (WebInspector.SourceFrame.prototype.findSearchMatches):
        (WebInspector.SourceFrame.prototype._collectRegexMatches):
        (WebInspector.SourceFrame.prototype.setSelection):
        (WebInspector.SourceFrame.prototype._incrementMessageRepeatCount):
        (WebInspector.SourceFrame.prototype._addExistingMessagesToSource):
        (WebInspector.SourceFrame.prototype._addMessageToSource):
        (WebInspector.SourceFrame.prototype._addExistingBreakpointsToSource):
        (WebInspector.SourceFrame.prototype._addBreakpointToSource):
        (WebInspector.SourceFrame.prototype._removeBreakpointFromSource):
        (WebInspector.SourceFrame.prototype._contextMenu.addConditionalBreakpoint):
        (WebInspector.SourceFrame.prototype._contextMenu):
        (WebInspector.SourceFrame.prototype._toggleBreakpoint):
        (WebInspector.SourceFrame.prototype._editBreakpointCondition.committed):
        (WebInspector.SourceFrame.prototype._editBreakpointCondition.dismissed):
        (WebInspector.SourceFrame.prototype._editBreakpointCondition):
        (WebInspector.SourceFrame.prototype._showBreakpointConditionPopup):
        (WebInspector.SourceFrame.prototype._createConditionElement):
        (WebInspector.SourceFrame.prototype._keyDown):
        (WebInspector.SourceFrame.prototype._evalSelectionInCallFrame):
        (WebInspector.SourceFrame.prototype._breakpointChanged):
        (WebInspector.SourceFrame.prototype.resize):
        (WebInspector.BreakpointLineNumberDecorator):
        (WebInspector.BreakpointLineNumberDecorator.prototype.decorate):
        (WebInspector.BreakpointLineNumberDecorator.prototype._paintBreakpoint):
        (WebInspector.BreakpointLineNumberDecorator.prototype._paintProgramCounter):
        (WebInspector.BreakpointLineNumberDecorator.prototype.mouseDown):
        (WebInspector.BreakpointLineNumberDecorator.prototype.contextMenu):
        (WebInspector.ExecutionLineDecorator):
        (WebInspector.ExecutionLineDecorator.prototype.decorate):
        * inspector/front-end/SourceFrame2.js: Removed.
        * inspector/front-end/SourceView.js:
        (WebInspector.SourceView):
        (WebInspector.SourceView.prototype.show):
        (WebInspector.SourceView.prototype.resize):
        (WebInspector.SourceView.prototype.setupSourceFrameIfNeeded):
        (WebInspector.SourceView.prototype._contentLoaded):
        (WebInspector.SourceView.prototype.performSearch.findSearchMatches):
        (WebInspector.SourceView.prototype.performSearch):
        (WebInspector.SourceView.prototype._jumpToSearchResult):
        (WebInspector.SourceView.prototype._sourceFrameSetupFinished):
        * inspector/front-end/TextEditor.js:
        (WebInspector.TextEditor.prototype._mouseDown):
        (WebInspector.TextEditor.prototype._copy.delayCopy):
        (WebInspector.TextEditor.prototype._copy):
        (WebInspector.TextEditor.prototype._cut):
        * inspector/front-end/WebKit.qrc:
        * inspector/front-end/inspector.html:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53941 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 5bc29613
2010-01-27 Pavel Feldman <pfeldman@chromium.org>
Reviewed by Timothy Hatcher.
Web Inspector: migrate from SourceFrame to SourceFrame2.
https://bugs.webkit.org/show_bug.cgi?id=34171
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* bindings/js/JSInspectorFrontendHostCustom.cpp:
* bindings/v8/custom/V8InspectorFrontendHostCustom.cpp:
* inspector/InspectorFrontendHost.cpp:
* inspector/InspectorFrontendHost.h:
* inspector/InspectorFrontendHost.idl:
* inspector/front-end/InspectorBackendStub.js:
* inspector/front-end/InspectorFrontendHostStub.js:
* inspector/front-end/ResourceView.js:
(WebInspector.ResourceView.prototype._innerSelectContentTab):
* inspector/front-end/ResourcesPanel.js:
(WebInspector.getResourceContent):
* inspector/front-end/ScriptView.js:
(WebInspector.ScriptView):
(WebInspector.ScriptView.prototype.setupSourceFrameIfNeeded):
* inspector/front-end/ScriptsPanel.js:
(WebInspector.ScriptsPanel.prototype._sidebarResizeDrag):
* inspector/front-end/SourceFrame.js:
(WebInspector.SourceFrame):
(WebInspector.SourceFrame.prototype.set executionLine):
(WebInspector.SourceFrame.prototype.revealLine):
(WebInspector.SourceFrame.prototype.addBreakpoint):
(WebInspector.SourceFrame.prototype.removeBreakpoint):
(WebInspector.SourceFrame.prototype.addMessage):
(WebInspector.SourceFrame.prototype.clearMessages):
(WebInspector.SourceFrame.prototype.sizeToFitContentHeight):
(WebInspector.SourceFrame.prototype.setContent):
(WebInspector.SourceFrame.prototype.findSearchMatches):
(WebInspector.SourceFrame.prototype._collectRegexMatches):
(WebInspector.SourceFrame.prototype.setSelection):
(WebInspector.SourceFrame.prototype._incrementMessageRepeatCount):
(WebInspector.SourceFrame.prototype._addExistingMessagesToSource):
(WebInspector.SourceFrame.prototype._addMessageToSource):
(WebInspector.SourceFrame.prototype._addExistingBreakpointsToSource):
(WebInspector.SourceFrame.prototype._addBreakpointToSource):
(WebInspector.SourceFrame.prototype._removeBreakpointFromSource):
(WebInspector.SourceFrame.prototype._contextMenu.addConditionalBreakpoint):
(WebInspector.SourceFrame.prototype._contextMenu):
(WebInspector.SourceFrame.prototype._toggleBreakpoint):
(WebInspector.SourceFrame.prototype._editBreakpointCondition.committed):
(WebInspector.SourceFrame.prototype._editBreakpointCondition.dismissed):
(WebInspector.SourceFrame.prototype._editBreakpointCondition):
(WebInspector.SourceFrame.prototype._showBreakpointConditionPopup):
(WebInspector.SourceFrame.prototype._createConditionElement):
(WebInspector.SourceFrame.prototype._keyDown):
(WebInspector.SourceFrame.prototype._evalSelectionInCallFrame):
(WebInspector.SourceFrame.prototype._breakpointChanged):
(WebInspector.SourceFrame.prototype.resize):
(WebInspector.BreakpointLineNumberDecorator):
(WebInspector.BreakpointLineNumberDecorator.prototype.decorate):
(WebInspector.BreakpointLineNumberDecorator.prototype._paintBreakpoint):
(WebInspector.BreakpointLineNumberDecorator.prototype._paintProgramCounter):
(WebInspector.BreakpointLineNumberDecorator.prototype.mouseDown):
(WebInspector.BreakpointLineNumberDecorator.prototype.contextMenu):
(WebInspector.ExecutionLineDecorator):
(WebInspector.ExecutionLineDecorator.prototype.decorate):
* inspector/front-end/SourceFrame2.js: Removed.
* inspector/front-end/SourceView.js:
(WebInspector.SourceView):
(WebInspector.SourceView.prototype.show):
(WebInspector.SourceView.prototype.resize):
(WebInspector.SourceView.prototype.setupSourceFrameIfNeeded):
(WebInspector.SourceView.prototype._contentLoaded):
(WebInspector.SourceView.prototype.performSearch.findSearchMatches):
(WebInspector.SourceView.prototype.performSearch):
(WebInspector.SourceView.prototype._jumpToSearchResult):
(WebInspector.SourceView.prototype._sourceFrameSetupFinished):
* inspector/front-end/TextEditor.js:
(WebInspector.TextEditor.prototype._mouseDown):
(WebInspector.TextEditor.prototype._copy.delayCopy):
(WebInspector.TextEditor.prototype._copy):
(WebInspector.TextEditor.prototype._cut):
* inspector/front-end/WebKit.qrc:
* inspector/front-end/inspector.html:
2010-01-27 Dominik Röttsches <dominik.roettsches@access-company.com>
Reviewed by Xan Lopez.
......@@ -3733,7 +3733,6 @@
'inspector/front-end/SidebarTreeElement.js',
'inspector/front-end/SourceCSSTokenizer.js',
'inspector/front-end/SourceFrame.js',
'inspector/front-end/SourceFrame2.js',
'inspector/front-end/SourceHTMLTokenizer.js',
'inspector/front-end/SourceJavaScriptTokenizer.js',
'inspector/front-end/SourceSyntaxHighlighter.js',
......
......@@ -42919,10 +42919,6 @@
RelativePath="..\inspector\front-end\SourceFrame.js"
>
</File>
<File
RelativePath="..\inspector\front-end\SourceFrame2.js"
>
</File>
<File
RelativePath="..\inspector\front-end\SourceHTMLTokenizer.js"
>
......
......@@ -36,18 +36,10 @@
#if ENABLE(INSPECTOR)
#include "ContextMenuItem.h"
#include "ExceptionCode.h"
#include "Frame.h"
#include "InspectorController.h"
#include "InspectorFrontendHost.h"
#include "JSEvent.h"
#include "JSNode.h"
#include "JSRange.h"
#include "MouseEvent.h"
#include "Node.h"
#include "Page.h"
#include "TextIterator.h"
#include "VisiblePosition.h"
#include <runtime/JSArray.h>
#include <runtime/JSLock.h>
#include <runtime/JSObject.h>
......@@ -57,42 +49,6 @@ using namespace JSC;
namespace WebCore {
JSValue JSInspectorFrontendHost::search(ExecState* exec, const ArgList& args)
{
if (args.size() < 2)
return jsUndefined();
Node* node = toNode(args.at(0));
if (!node)
return jsUndefined();
String target = args.at(1).toString(exec);
if (exec->hadException())
return jsUndefined();
MarkedArgumentBuffer result;
RefPtr<Range> searchRange(rangeOfContents(node));
ExceptionCode ec = 0;
do {
RefPtr<Range> resultRange(findPlainText(searchRange.get(), target, true, false));
if (resultRange->collapsed(ec))
break;
// A non-collapsed result range can in some funky whitespace cases still not
// advance the range's start position (4509328). Break to avoid infinite loop.
VisiblePosition newStart = endVisiblePosition(resultRange.get(), DOWNSTREAM);
if (newStart == startVisiblePosition(searchRange.get(), DOWNSTREAM))
break;
result.append(toJS(exec, resultRange.get()));
setStart(searchRange.get(), newStart);
} while (true);
return constructArray(exec, result);
}
JSValue JSInspectorFrontendHost::showContextMenu(ExecState* execState, const ArgList& args)
{
if (args.size() < 2)
......
......@@ -31,61 +31,15 @@
#include "config.h"
#include "V8InspectorFrontendHost.h"
#include "ExceptionCode.h"
#include "InspectorController.h"
#include "InspectorFrontendHost.h"
#include "Node.h"
#include "Range.h"
#include "Page.h"
#include "TextIterator.h"
#include "VisiblePosition.h"
#include "V8Binding.h"
#include "V8CustomBinding.h"
#include "V8Node.h"
#include "V8Proxy.h"
namespace WebCore {
v8::Handle<v8::Value> V8InspectorFrontendHost::searchCallback(const v8::Arguments& args)
{
INC_STATS("InspectorFrontendHost.search()");
if (args.Length() < 2)
return v8::Undefined();
Node* node = V8Node::toNative(v8::Handle<v8::Object>::Cast(args[0]));
if (!node)
return v8::Undefined();
String target = toWebCoreStringWithNullCheck(args[1]);
if (target.isEmpty())
return v8::Undefined();
v8::Local<v8::Array> result = v8::Array::New();
RefPtr<Range> searchRange(rangeOfContents(node));
ExceptionCode ec = 0;
int index = 0;
do {
RefPtr<Range> resultRange(findPlainText(searchRange.get(), target, true, false));
if (resultRange->collapsed(ec))
break;
// A non-collapsed result range can in some funky whitespace cases still not
// advance the range's start position (4509328). Break to avoid infinite loop.
VisiblePosition newStart = endVisiblePosition(resultRange.get(), DOWNSTREAM);
if (newStart == startVisiblePosition(searchRange.get(), DOWNSTREAM))
break;
result->Set(v8::Number::New(index++), V8DOMWrapper::convertToV8Object(V8ClassIndex::RANGE, resultRange.release()));
setStart(searchRange.get(), newStart);
} while (true);
return result;
}
v8::Handle<v8::Value> V8InspectorFrontendHost::showContextMenuCallback(const v8::Arguments& args)
{
return v8::Undefined();
......
......@@ -45,6 +45,7 @@
#include "InspectorFrontend.h"
#include "InspectorResource.h"
#include "Page.h"
#include "Pasteboard.h"
#include <wtf/RefPtr.h>
#include <wtf/StdLibExtras.h>
......@@ -133,7 +134,6 @@ const String& InspectorFrontendHost::platform() const
return platform;
}
const String& InspectorFrontendHost::port() const
{
#if PLATFORM(QT)
......@@ -149,54 +149,9 @@ const String& InspectorFrontendHost::port() const
return port;
}
// FIXME: Remove this once migrated to SourceFrame2.
void InspectorFrontendHost::addResourceSourceToFrame(long identifier, Node* frame)
{
if (!m_inspectorController)
return;
RefPtr<InspectorResource> resource = m_inspectorController->resources().get(identifier);
if (resource) {
String sourceString = resource->sourceString();
if (!sourceString.isEmpty())
addSourceToFrame(resource->mimeType(), sourceString, frame);
}
}
// FIXME: Remove this once migrated to SourceFrame2.
bool InspectorFrontendHost::addSourceToFrame(const String& mimeType, const String& source, Node* frameNode)
void InspectorFrontendHost::copyText(const String& text)
{
ASSERT_ARG(frameNode, frameNode);
if (!frameNode)
return false;
if (!frameNode->attached()) {
ASSERT_NOT_REACHED();
return false;
}
ASSERT(frameNode->isElementNode());
if (!frameNode->isElementNode())
return false;
Element* element = static_cast<Element*>(frameNode);
ASSERT(element->isFrameOwnerElement());
if (!element->isFrameOwnerElement())
return false;
HTMLFrameOwnerElement* frameOwner = static_cast<HTMLFrameOwnerElement*>(element);
ASSERT(frameOwner->contentFrame());
if (!frameOwner->contentFrame())
return false;
FrameLoader* loader = frameOwner->contentFrame()->loader();
loader->setResponseMIMEType(mimeType);
loader->begin();
loader->write(source);
loader->end();
return true;
Pasteboard::generalPasteboard()->writePlainText(text);
}
void InspectorFrontendHost::showContextMenu(Event* event, const Vector<ContextMenuItem*>& items)
......
......@@ -73,9 +73,7 @@ public:
const String& platform() const;
const String& port() const;
// FIXME: Remove these once migrated to SourceFrame2.
void addResourceSourceToFrame(long identifier, Node* frame);
bool addSourceToFrame(const String& mimeType, const String& source, Node* frame);
void copyText(const String& text);
// Called from [Custom] implementations.
void showContextMenu(Event*, const Vector<ContextMenuItem*>& items);
......
......@@ -46,11 +46,8 @@ module core {
DOMString platform();
DOMString port();
// FIXME: Remove these once migrated to SourceFrame2.
void addResourceSourceToFrame(in long identifier, in Node frame);
boolean addSourceToFrame(in DOMString mimeType, in DOMString sourceValue, in Node frame);
void copyText(in DOMString text);
[Custom] void search(in Node node, in DOMString query);
[Custom] void showContextMenu(in MouseEvent event, in DOMObject items);
};
}
......@@ -100,27 +100,11 @@ WebInspector.InspectorBackendStub.prototype = {
{
},
addResourceSourceToFrame: function(identifier, element)
{
},
addSourceToFrame: function(mimeType, source, element)
{
return false;
},
// FIXME: remove once migrated to SourceFrame2.
getResourceContent: function(callId, identifier)
{
WebInspector.didGetResourceContent(callId, "");
},
// FIXME: remove once migrated to SourceFrame2.
getResourceDocumentNode: function(identifier)
{
return undefined;
},
highlightDOMNode: function(node)
{
},
......
......@@ -71,17 +71,6 @@ WebInspector.InspectorFrontendHostStub.prototype = {
{
},
// FIXME: remove once migrated to SourceFrame2.
addResourceSourceToFrame: function(identifier, element)
{
},
// FIXME: remove once migrated to SourceFrame2.
addSourceToFrame: function(mimeType, source, element)
{
return false;
},
loaded: function()
{
},
......@@ -98,6 +87,10 @@ WebInspector.InspectorFrontendHostStub.prototype = {
windowUnloading: function()
{
},
copyText: function()
{
}
}
......
......@@ -131,26 +131,33 @@ WebInspector.ResourceView.prototype = {
}
},
show: function(parentElement)
{
WebInspector.View.prototype.show.call(this, parentElement);
this._selectTab();
},
set headersVisible(x)
{
if (x === this._headersVisible)
return;
this._headersVisible = x;
if (x) {
if (x)
this.element.addStyleClass("headers-visible");
this._selectTab();
} else {
else
this.element.removeStyleClass("headers-visible");
this._innerSelectContentTab();
}
this._selectTab();
},
_selectTab: function()
{
if (WebInspector.settings.resourceViewTab === "headers")
this._selectHeadersTab();
else
this._selectContentTab();
if (this._headersVisible) {
if (WebInspector.settings.resourceViewTab === "headers")
this._selectHeadersTab();
else
this._selectContentTab();
} else
this._innerSelectContentTab();
},
_selectHeadersTab: function()
......@@ -174,6 +181,8 @@ WebInspector.ResourceView.prototype = {
this.headersTabElement.removeStyleClass("selected");
this.contentElement.removeStyleClass("hidden");
this.headersElement.addStyleClass("hidden");
if ("resize" in this)
this.resize();
},
_refreshURL: function()
......
......@@ -710,6 +710,13 @@ WebInspector.ResourcesPanel.prototype = {
WebInspector.ResourcesPanel.prototype.__proto__ = WebInspector.AbstractTimelinePanel.prototype;
WebInspector.getResourceContent = function(identifier, callback)
{
InspectorBackend.getResourceContent(WebInspector.Callback.wrap(callback), identifier);
}
WebInspector.didGetResourceContent = WebInspector.Callback.processCallback;
WebInspector.ResourceTimeCalculator = function(startAtZero)
{
WebInspector.AbstractTimelineCalculator.call(this);
......
......@@ -33,8 +33,7 @@ WebInspector.ScriptView = function(script)
this._frameNeedsSetup = true;
this._sourceFrameSetup = false;
this.sourceFrame = new WebInspector.SourceFrame(null, this._addBreakpoint.bind(this));
this.sourceFrame = new WebInspector.SourceFrame(this._addBreakpoint.bind(this));
this.element.appendChild(this.sourceFrame.element);
}
......@@ -44,12 +43,7 @@ WebInspector.ScriptView.prototype = {
{
WebInspector.View.prototype.show.call(this, parentElement);
this.setupSourceFrameIfNeeded();
},
hide: function()
{
WebInspector.View.prototype.hide.call(this);
this._currentSearchResultIndex = -1;
this.resize();
},
setupSourceFrameIfNeeded: function()
......@@ -59,13 +53,9 @@ WebInspector.ScriptView.prototype = {
this.attach();
if (!InspectorFrontendHost.addSourceToFrame("text/javascript", this.script.source, this.sourceFrame.element))
return;
this.sourceFrame.setContent("text/javascript", this.script.source);
this._sourceFrameSetup = true;
delete this._frameNeedsSetup;
this.sourceFrame.addEventListener("syntax highlighting complete", this._syntaxHighlightingComplete, this);
this.sourceFrame.syntaxHighlightJavascript();
},
attach: function()
......@@ -83,6 +73,7 @@ WebInspector.ScriptView.prototype = {
// The follow methods are pulled from SourceView, since they are
// generic and work with ScriptView just fine.
hide: WebInspector.SourceView.prototype.hide,
revealLine: WebInspector.SourceView.prototype.revealLine,
highlightLine: WebInspector.SourceView.prototype.highlightLine,
addMessage: WebInspector.SourceView.prototype.addMessage,
......@@ -97,7 +88,7 @@ WebInspector.ScriptView.prototype = {
showingLastSearchResult: WebInspector.SourceView.prototype.showingLastSearchResult,
_jumpToSearchResult: WebInspector.SourceView.prototype._jumpToSearchResult,
_sourceFrameSetupFinished: WebInspector.SourceView.prototype._sourceFrameSetupFinished,
_syntaxHighlightingComplete: WebInspector.SourceView.prototype._syntaxHighlightingComplete
resize: WebInspector.SourceView.prototype.resize
}
WebInspector.ScriptView.prototype.__proto__ = WebInspector.View.prototype;
......@@ -799,6 +799,7 @@ WebInspector.ScriptsPanel.prototype = {
this.sidebarResizeWidgetElement.style.right = newWidth + "px";
this.sidebarResizeElement.style.right = (newWidth - 3) + "px";
this.resize();
event.preventDefault();
},
......
This diff is collapsed.
This diff is collapsed.
......@@ -30,7 +30,7 @@ WebInspector.SourceView = function(resource)
{
WebInspector.ResourceView.call(this, resource);
this.sourceFrame = new WebInspector.SourceFrame(null, this._addBreakpoint.bind(this));
this.sourceFrame = new WebInspector.SourceFrame(this._addBreakpoint.bind(this));
resource.addEventListener("finished", this._resourceLoadingFinished, this);
......@@ -50,6 +50,7 @@ WebInspector.SourceView.prototype = {
{
WebInspector.ResourceView.prototype.show.call(this, parentElement);
this.setupSourceFrameIfNeeded();
this.resize();
},
hide: function()
......@@ -58,6 +59,12 @@ WebInspector.SourceView.prototype = {
this._currentSearchResultIndex = -1;
},
resize: function()
{
if (this._sourceFrameSetup)
this.sourceFrame.resize();
},
detach: function()
{
WebInspector.ResourceView.prototype.detach.call(this);
......@@ -76,28 +83,13 @@ WebInspector.SourceView.prototype = {
this.attach();
delete this._frameNeedsSetup;
this.sourceFrame.addEventListener("content loaded", this._contentLoaded, this);
InspectorFrontendHost.addResourceSourceToFrame(this.resource.identifier, this.sourceFrame.element);
WebInspector.getResourceContent(this.resource.identifier, this._contentLoaded.bind(this));
},
_contentLoaded: function()
_contentLoaded: function(content)
{
delete this._frameNeedsSetup;
this.sourceFrame.removeEventListener("content loaded", this._contentLoaded, this);
if (this.resource.type === WebInspector.Resource.Type.Script
|| this.resource.mimeType === "application/json"
|| this.resource.mimeType === "application/javascript"
|| /\.js(on)?$/.test(this.resource.lastPathComponent) ) {
this.sourceFrame.addEventListener("syntax highlighting complete", this._syntaxHighlightingComplete, this);
this.sourceFrame.syntaxHighlightJavascript();
} else if (this.resource.type === WebInspector.Resource.Type.Stylesheet
|| this.resource.mimeType === "text/css"
|| /\.css$/.test(this.resource.lastPathComponent) ) {
this.sourceFrame.addEventListener("syntax highlighting complete", this._syntaxHighlightingComplete, this);
this.sourceFrame.syntaxHighlightCSS();
} else
this._sourceFrameSetupFinished();
this.sourceFrame.setContent(this.resource.mimeType, content);
this._sourceFrameSetupFinished();
},
_resourceLoadingFinished: function(event)
......@@ -135,6 +127,7 @@ WebInspector.SourceView.prototype = {
{
this._currentSearchResultIndex = -1;
this._searchResults = [];
this.sourceFrame.clearSelection();
delete this._delayedFindSearchMatches;
},
......@@ -143,44 +136,11 @@ WebInspector.SourceView.prototype = {
// Call searchCanceled since it will reset everything we need before doing a new search.
this.searchCanceled();
var lineQueryRegex = /(^|\s)(?:#|line:\s*)(\d+)(\s|$)/i;
var lineQueryMatch = query.match(lineQueryRegex);
if (lineQueryMatch) {
var lineToSearch = parseInt(lineQueryMatch[2]);
// If there was a space before and after the line query part, replace with a space.
// Otherwise replace with an empty string to eat the prefix or postfix space.
var lineQueryReplacement = (lineQueryMatch[1] && lineQueryMatch[3] ? " " : "");
var filterlessQuery = query.replace(lineQueryRegex, lineQueryReplacement);
}
this._searchFinishedCallback = finishedCallback;
function findSearchMatches(query, finishedCallback)
{
if (isNaN(lineToSearch)) {
// Search the whole document since there was no line to search.
this._searchResults = (InspectorFrontendHost.search(this.sourceFrame.element.contentDocument, query) || []);
} else {
var sourceRow = this.sourceFrame.sourceRow(lineToSearch);
if (sourceRow) {
if (filterlessQuery) {
// There is still a query string, so search for that string in the line.
this._searchResults = (InspectorFrontendHost.search(sourceRow, filterlessQuery) || []);
} else {
// Match the whole line, since there was no remaining query string to match.
var rowRange = this.sourceFrame.element.contentDocument.createRange();
rowRange.selectNodeContents(sourceRow);
this._searchResults = [rowRange];
}
}
// Attempt to search for the whole query, just incase it matches a color like "#333".
var wholeQueryMatches = InspectorFrontendHost.search(this.sourceFrame.element.contentDocument, query);
if (wholeQueryMatches)
this._searchResults = this._searchResults.concat(wholeQueryMatches);
}
this._searchResults = this.sourceFrame.findSearchMatches(query);
if (this._searchResults)
finishedCallback(this, this._searchResults.length);
}
......@@ -267,29 +227,17 @@ WebInspector.SourceView.prototype = {
if (!foundRange)
return;
var selection = this.sourceFrame.element.contentWindow.getSelection();
selection.removeAllRanges();
selection.addRange(foundRange);
if (foundRange.startContainer.scrollIntoViewIfNeeded)
foundRange.startContainer.scrollIntoViewIfNeeded(true);
else if (foundRange.startContainer.parentNode)
foundRange.startContainer.parentNode.scrollIntoViewIfNeeded(true);
this.sourceFrame.setSelection(foundRange);
},
_sourceFrameSetupFinished: function()
{
this._sourceFrameSetup = true;
this.resize();
if (this._delayedFindSearchMatches) {
this._delayedFindSearchMatches();
delete this._delayedFindSearchMatches;
}
},