[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.19-706-ge5415e9
pfeldman at chromium.org
pfeldman at chromium.org
Thu Feb 4 21:29:41 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit d8569c45a825dad27614806d2175b0d4de13ef9f
Author: pfeldman at chromium.org <pfeldman at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Jan 27 18:36:54 2010 +0000
2010-01-27 Pavel Feldman <pfeldman at 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
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 08db1ff..53dfd50 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,87 @@
+2010-01-27 Pavel Feldman <pfeldman at 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 at access-company.com>
Reviewed by Xan Lopez.
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index dfc34e7..57e186f 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -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',
diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj
index 626f14e..bfd59da 100644
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -42920,10 +42920,6 @@
>
</File>
<File
- RelativePath="..\inspector\front-end\SourceFrame2.js"
- >
- </File>
- <File
RelativePath="..\inspector\front-end\SourceHTMLTokenizer.js"
>
</File>
diff --git a/WebCore/bindings/js/JSInspectorFrontendHostCustom.cpp b/WebCore/bindings/js/JSInspectorFrontendHostCustom.cpp
index ff23e84..7b06bac 100644
--- a/WebCore/bindings/js/JSInspectorFrontendHostCustom.cpp
+++ b/WebCore/bindings/js/JSInspectorFrontendHostCustom.cpp
@@ -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)
diff --git a/WebCore/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp b/WebCore/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp
index ae5b828..df63bf1 100644
--- a/WebCore/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp
@@ -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();
diff --git a/WebCore/inspector/InspectorFrontendHost.cpp b/WebCore/inspector/InspectorFrontendHost.cpp
index 6cfaf5d..2e235ab 100644
--- a/WebCore/inspector/InspectorFrontendHost.cpp
+++ b/WebCore/inspector/InspectorFrontendHost.cpp
@@ -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)
diff --git a/WebCore/inspector/InspectorFrontendHost.h b/WebCore/inspector/InspectorFrontendHost.h
index a95eccf..390b018 100644
--- a/WebCore/inspector/InspectorFrontendHost.h
+++ b/WebCore/inspector/InspectorFrontendHost.h
@@ -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);
diff --git a/WebCore/inspector/InspectorFrontendHost.idl b/WebCore/inspector/InspectorFrontendHost.idl
index 7e7a62d..9de49c1 100644
--- a/WebCore/inspector/InspectorFrontendHost.idl
+++ b/WebCore/inspector/InspectorFrontendHost.idl
@@ -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);
};
}
diff --git a/WebCore/inspector/front-end/InspectorBackendStub.js b/WebCore/inspector/front-end/InspectorBackendStub.js
index 01afdfa..0b455cb 100644
--- a/WebCore/inspector/front-end/InspectorBackendStub.js
+++ b/WebCore/inspector/front-end/InspectorBackendStub.js
@@ -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)
{
},
diff --git a/WebCore/inspector/front-end/InspectorFrontendHostStub.js b/WebCore/inspector/front-end/InspectorFrontendHostStub.js
index 5328029..dc7da61 100644
--- a/WebCore/inspector/front-end/InspectorFrontendHostStub.js
+++ b/WebCore/inspector/front-end/InspectorFrontendHostStub.js
@@ -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()
+ {
}
}
diff --git a/WebCore/inspector/front-end/ResourceView.js b/WebCore/inspector/front-end/ResourceView.js
index baf5d79..334847e 100644
--- a/WebCore/inspector/front-end/ResourceView.js
+++ b/WebCore/inspector/front-end/ResourceView.js
@@ -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()
diff --git a/WebCore/inspector/front-end/ResourcesPanel.js b/WebCore/inspector/front-end/ResourcesPanel.js
index 558a014..e0c5521 100644
--- a/WebCore/inspector/front-end/ResourcesPanel.js
+++ b/WebCore/inspector/front-end/ResourcesPanel.js
@@ -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);
diff --git a/WebCore/inspector/front-end/ScriptView.js b/WebCore/inspector/front-end/ScriptView.js
index 38157ac..57f77a2 100644
--- a/WebCore/inspector/front-end/ScriptView.js
+++ b/WebCore/inspector/front-end/ScriptView.js
@@ -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;
diff --git a/WebCore/inspector/front-end/ScriptsPanel.js b/WebCore/inspector/front-end/ScriptsPanel.js
index 75f5c9c..da24ed2 100644
--- a/WebCore/inspector/front-end/ScriptsPanel.js
+++ b/WebCore/inspector/front-end/ScriptsPanel.js
@@ -799,6 +799,7 @@ WebInspector.ScriptsPanel.prototype = {
this.sidebarResizeWidgetElement.style.right = newWidth + "px";
this.sidebarResizeElement.style.right = (newWidth - 3) + "px";
+ this.resize();
event.preventDefault();
},
diff --git a/WebCore/inspector/front-end/SourceFrame.js b/WebCore/inspector/front-end/SourceFrame.js
index deb1494..9b4e952 100644
--- a/WebCore/inspector/front-end/SourceFrame.js
+++ b/WebCore/inspector/front-end/SourceFrame.js
@@ -1,45 +1,54 @@
/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- * Copyright (C) 2009 Joseph Pecoraro
+ * Copyright (C) 2009 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
+ * modification, are permitted provided that the following conditions are
+ * met:
*
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-WebInspector.SourceFrame = function(element, addBreakpointDelegate)
+WebInspector.SourceFrame = function(addBreakpointDelegate)
{
- this.messages = [];
+ this._editor = new WebInspector.TextEditor(WebInspector.platform);
+ this._textModel = this._editor.textModel;
+ this._editor.lineNumberDecorator = new WebInspector.BreakpointLineNumberDecorator(this);
+ this._editor.lineDecorator = new WebInspector.ExecutionLineDecorator(this);
+ this._editor.readOnly = true;
+ this._messages = [];
+ this._rowMessages = {};
+ this._messageBubbles = {};
this.breakpoints = [];
this._shortcuts = {};
+ this.element = this._editor.element;
+ this.element.addEventListener("keydown", this._keyDown.bind(this), true);
+ this._loaded = false;
this.addBreakpointDelegate = addBreakpointDelegate;
-
- this.element = element || document.createElement("iframe");
- this.element.addStyleClass("source-view-frame");
- this.element.setAttribute("viewsource", "true");
-
- this.element.addEventListener("load", this._loaded.bind(this), false);
}
WebInspector.SourceFrame.prototype = {
+
get executionLine()
{
return this._executionLine;
@@ -49,59 +58,24 @@ WebInspector.SourceFrame.prototype = {
{
if (this._executionLine === x)
return;
-
- var previousLine = this._executionLine;
this._executionLine = x;
-
- this._updateExecutionLine(previousLine);
- },
-
- sourceRow: function(lineNumber)
- {
- if (!lineNumber || !this.element.contentDocument)
- return;
-
- var table = this.element.contentDocument.getElementsByTagName("table")[0];
- if (!table)
- return;
-
- var rows = table.rows;
-
- // Line numbers are a 1-based index, but the rows collection is 0-based.
- --lineNumber;
-
- return rows[lineNumber];
- },
-
- lineNumberForSourceRow: function(sourceRow)
- {
- // Line numbers are a 1-based index, but the rows collection is 0-based.
- var lineNumber = 0;
- while (sourceRow) {
- ++lineNumber;
- sourceRow = sourceRow.previousSibling;
- }
-
- return lineNumber;
+ this._editor.repaintAll();
},
revealLine: function(lineNumber)
{
- if (!this._isContentLoaded()) {
+ if (!this._loaded)
this._lineNumberToReveal = lineNumber;
- return;
- }
-
- var row = this.sourceRow(lineNumber);
- if (row)
- row.scrollIntoViewIfNeeded(true);
+ else
+ this._editor.reveal(lineNumber - 1, 0);
},
addBreakpoint: function(breakpoint)
{
this.breakpoints.push(breakpoint);
- breakpoint.addEventListener("enabled", this._breakpointEnableChanged, this);
- breakpoint.addEventListener("disabled", this._breakpointEnableChanged, this);
+ breakpoint.addEventListener("enabled", this._breakpointChanged, this);
+ breakpoint.addEventListener("disabled", this._breakpointChanged, this);
+ breakpoint.addEventListener("condition-changed", this._breakpointChanged, this);
this._addBreakpointToSource(breakpoint);
},
@@ -110,6 +84,7 @@ WebInspector.SourceFrame.prototype = {
this.breakpoints.remove(breakpoint);
breakpoint.removeEventListener("enabled", null, this);
breakpoint.removeEventListener("disabled", null, this);
+ breakpoint.removeEventListener("condition-changed", null, this);
this._removeBreakpointFromSource(breakpoint);
},
@@ -118,230 +93,259 @@ WebInspector.SourceFrame.prototype = {
// Don't add the message if there is no message or valid line or if the msg isn't an error or warning.
if (!msg.message || msg.line <= 0 || !msg.isErrorOrWarning())
return;
- this.messages.push(msg);
+ this._messages.push(msg);
this._addMessageToSource(msg);
},
clearMessages: function()
{
- this.messages = [];
+ for (var line in this._messageBubbles) {
+ var bubble = this._messageBubbles[line];
+ bubble.parentNode.removeChild(bubble);
+ }
- if (!this.element.contentDocument)
- return;
+ this._messages = [];
+ this._rowMessages = {};
+ this._messageBubbles = {};
+ this._editor.packAndRepaintAll();
+ },
- var bubbles = this.element.contentDocument.querySelectorAll(".webkit-html-message-bubble");
- if (!bubbles)
- return;
+ sizeToFitContentHeight: function()
+ {
+ this._editor.packAndRepaintAll();
+ },
- for (var i = 0; i < bubbles.length; ++i) {
- var bubble = bubbles[i];
- bubble.parentNode.removeChild(bubble);
+ setContent: function(mimeType, content)
+ {
+ this._loaded = true;
+ this._editor.mimeType = mimeType;
+ this._editor.text = content;
+
+ this._addExistingMessagesToSource();
+ this._addExistingBreakpointsToSource();
+ if (this._executionLine)
+ this.revealLine(this._executionLine);
+
+ if (this._lineNumberToReveal) {
+ this.revealLine(this._lineNumberToReveal);
+ delete this._lineNumberToReveal;
}
+ this._editor.setCoalescingUpdate(true);
+ this._editor.updateCanvasSize();
+ this._editor.packAndRepaintAll();
+ this._editor.setCoalescingUpdate(false);
},
- sizeToFitContentHeight: function()
+ findSearchMatches: function(query)
{
- if (this.element.contentDocument) {
- this.element.style.setProperty("height", this.element.contentDocument.body.offsetHeight + "px");
- this.element.contentDocument.body.addStyleClass("webkit-height-sized-to-fit");
+ var ranges = [];
+
+ // First do case-insensitive search.
+ var regex = "";
+ for (var i = 0; i < query.length; ++i) {
+ var char = query.charAt(i);
+ if (char === "]")
+ char = "\\]";
+ regex += "[" + char + "]";
+ }
+ var regexObject = new RegExp(regex, "i");
+ this._collectRegexMatches(regexObject, ranges);
+
+ // Then try regex search if user knows the / / hint.
+ try {
+ if (/^\/.*\/$/.test(query))
+ this._collectRegexMatches(new RegExp(query.substring(1, query.length - 1)), ranges);
+ } catch (e) {
+ // Silent catch.
}
+ return ranges;
+ },
+
+ _collectRegexMatches: function(regexObject, ranges)
+ {
+ for (var i = 0; i < this._textModel.linesCount; ++i) {
+ var line = this._textModel.line(i);
+ var offset = 0;
+ do {
+ var match = regexObject.exec(line);
+ if (match) {
+ ranges.push(new WebInspector.TextRange(i, offset + match.index, i, offset + match.index + match[0].length));
+ offset += match.index + 1;
+ line = line.substring(match.index + 1);
+ }
+ } while (match)
+ }
+ return ranges;
},
- _highlightLineEnds: function(event)
+ setSelection: function(range)
{
- event.target.parentNode.removeStyleClass("webkit-highlighted-line");
+ this._editor.setSelection(range.startLine, range.startColumn, range.endLine, range.endColumn);
},
- highlightLine: function(lineNumber)
+ clearSelection: function()
{
- if (!this._isContentLoaded()) {
- this._lineNumberToHighlight = lineNumber;
+ var range = this._editor.selection;
+ this._editor.setSelection(range.endLine, range.endColumn, range.endLine, range.endColumn);
+ },
+
+ _incrementMessageRepeatCount: function(msg, repeatDelta)
+ {
+ if (!msg._resourceMessageLineElement)
return;
+
+ if (!msg._resourceMessageRepeatCountElement) {
+ var repeatedElement = document.createElement("span");
+ msg._resourceMessageLineElement.appendChild(repeatedElement);
+ msg._resourceMessageRepeatCountElement = repeatedElement;
}
- var sourceRow = this.sourceRow(lineNumber);
- if (!sourceRow)
- return;
- var line = sourceRow.getElementsByClassName('webkit-line-content')[0];
- // Trick to reset the animation if the user clicks on the same link
- // Using a timeout to avoid coalesced style updates
- line.style.setProperty("-webkit-animation-name", "none");
- setTimeout(function () {
- line.style.removeProperty("-webkit-animation-name");
- sourceRow.addStyleClass("webkit-highlighted-line");
- }, 0);
+ msg.repeatCount += repeatDelta;
+ msg._resourceMessageRepeatCountElement.textContent = WebInspector.UIString(" (repeated %d times)", msg.repeatCount);
},
- _loaded: function()
+ _addExistingMessagesToSource: function()
{
- WebInspector.addMainEventListeners(this.element.contentDocument);
- this.element.contentDocument.addEventListener("contextmenu", this._documentContextMenu.bind(this), true);
- this.element.contentDocument.addEventListener("mousedown", this._documentMouseDown.bind(this), true);
- this.element.contentDocument.addEventListener("keydown", this._documentKeyDown.bind(this), true);
- this.element.contentDocument.addEventListener("webkitAnimationEnd", this._highlightLineEnds.bind(this), false);
+ var length = this._messages.length;
+ for (var i = 0; i < length; ++i)
+ this._addMessageToSource(this._messages[i]);
+ },
- // Register 'eval' shortcut.
- var platformSpecificModifier = WebInspector.isMac() ? WebInspector.KeyboardShortcut.Modifiers.Meta : WebInspector.KeyboardShortcut.Modifiers.Ctrl;
- var shortcut = WebInspector.KeyboardShortcut.makeKey(69 /* 'E' */, platformSpecificModifier | WebInspector.KeyboardShortcut.Modifiers.Shift);
- this._shortcuts[shortcut] = this._evalSelectionInCallFrame.bind(this);
+ _addMessageToSource: function(msg)
+ {
+ if (msg.line >= this._textModel.linesCount)
+ return;
- var headElement = this.element.contentDocument.head;
- if (!headElement) {
- headElement = this.element.contentDocument.createElement("head");
- this.element.contentDocument.documentElement.insertBefore(headElement, this.element.contentDocument.documentElement.firstChild);
+ var messageBubbleElement = this._messageBubbles[msg.line];
+ if (!messageBubbleElement || messageBubbleElement.nodeType !== Node.ELEMENT_NODE || !messageBubbleElement.hasStyleClass("webkit-html-message-bubble")) {
+ messageBubbleElement = document.createElement("div");
+ messageBubbleElement.className = "webkit-html-message-bubble";
+ this._messageBubbles[msg.line] = messageBubbleElement;
+ this._editor.setDivDecoration(msg.line - 1, messageBubbleElement);
}
-
- var linkElement = this.element.contentDocument.createElement("link");
- linkElement.type = "text/css";
- linkElement.rel = "stylesheet";
- linkElement.href = "inspectorSyntaxHighlight.css";
- headElement.appendChild(linkElement);
-
- var styleElement = this.element.contentDocument.createElement("style");
- headElement.appendChild(styleElement);
-
- // Add these style rules here since they are specific to the Inspector. They also behave oddly and not
- // all properties apply if added to view-source.css (because it is a user agent sheet.)
- var styleText = ".webkit-line-number { background-repeat: no-repeat; background-position: right 1px; }\n";
- styleText += ".webkit-execution-line .webkit-line-number { color: transparent; background-image: -webkit-canvas(program-counter); }\n";
-
- styleText += ".webkit-breakpoint .webkit-line-number { color: white; background-image: -webkit-canvas(breakpoint); }\n";
- styleText += ".webkit-breakpoint-disabled .webkit-line-number { color: white; background-image: -webkit-canvas(breakpoint-disabled); }\n";
- styleText += ".webkit-breakpoint.webkit-execution-line .webkit-line-number { color: transparent; background-image: -webkit-canvas(breakpoint-program-counter); }\n";
- styleText += ".webkit-breakpoint-disabled.webkit-execution-line .webkit-line-number { color: transparent; background-image: -webkit-canvas(breakpoint-disabled-program-counter); }\n";
-
- styleText += ".webkit-breakpoint.webkit-breakpoint-conditional .webkit-line-number { color: white; background-image: -webkit-canvas(breakpoint-conditional); }\n";
- styleText += ".webkit-breakpoint-disabled.webkit-breakpoint-conditional .webkit-line-number { color: white; background-image: -webkit-canvas(breakpoint-disabled-conditional); }\n";
- styleText += ".webkit-breakpoint.webkit-breakpoint-conditional.webkit-execution-line .webkit-line-number { color: transparent; background-image: -webkit-canvas(breakpoint-conditional-program-counter); }\n";
- styleText += ".webkit-breakpoint-disabled.webkit-breakpoint-conditional.webkit-execution-line .webkit-line-number { color: transparent; background-image: -webkit-canvas(breakpoint-disabled-conditional-program-counter); }\n";
-
- styleText += ".webkit-execution-line .webkit-line-content { background-color: rgb(171, 191, 254); outline: 1px solid rgb(64, 115, 244); }\n";
- styleText += ".webkit-height-sized-to-fit { overflow-y: hidden }\n";
- styleText += ".webkit-line-content { background-color: white; }\n";
- styleText += "@-webkit-keyframes fadeout {from {background-color: rgb(255, 255, 120);} to { background-color: white;}}\n";
- styleText += ".webkit-highlighted-line .webkit-line-content { background-color: rgb(255, 255, 120); -webkit-animation: 'fadeout' 2s 500ms}\n";
-
- // TODO: Move these styles into inspector.css once https://bugs.webkit.org/show_bug.cgi?id=28913 is fixed and popup moved into the top frame.
- styleText += ".popup-content { position: absolute; z-index: 10000; padding: 4px; background-color: rgb(203, 226, 255); -webkit-border-radius: 7px; border: 2px solid rgb(169, 172, 203); }";
- styleText += ".popup-glasspane { position: absolute; top: 0; left: 0; height: 100%; width: 100%; opacity: 0; z-index: 9900; }";
- styleText += ".popup-message { background-color: transparent; font-family: Lucida Grande, sans-serif; font-weight: normal; font-size: 11px; text-align: left; text-shadow: none; color: rgb(85, 85, 85); cursor: default; margin: 0 0 2px 0; }";
- styleText += ".popup-content.breakpoint-condition { width: 90%; }";
- styleText += ".popup-content input#bp-condition { font-family: monospace; margin: 0; border: 1px inset rgb(190, 190, 190) !important; width: 100%; box-shadow: none !important; outline: none !important; -webkit-user-modify: read-write; }";
- // This class is already in inspector.css
- styleText += ".hidden { display: none !important; }";
-
- styleElement.textContent = styleText;
-
- this._needsProgramCounterImage = true;
- this._needsBreakpointImages = true;
-
- this.element.contentWindow.Element.prototype.addStyleClass = Element.prototype.addStyleClass;
- this.element.contentWindow.Element.prototype.removeStyleClass = Element.prototype.removeStyleClass;
- this.element.contentWindow.Element.prototype.removeChildren = Element.prototype.removeChildren;
- this.element.contentWindow.Element.prototype.positionAt = Element.prototype.positionAt;
- this.element.contentWindow.Element.prototype.removeMatchingStyleClasses = Element.prototype.removeMatchingStyleClasses;
- this.element.contentWindow.Element.prototype.hasStyleClass = Element.prototype.hasStyleClass;
- this.element.contentWindow.Element.prototype.pageOffsetRelativeToWindow = Element.prototype.pageOffsetRelativeToWindow;
- this.element.contentWindow.Element.prototype.__defineGetter__("totalOffsetLeft", Element.prototype.__lookupGetter__("totalOffsetLeft"));
- this.element.contentWindow.Element.prototype.__defineGetter__("totalOffsetTop", Element.prototype.__lookupGetter__("totalOffsetTop"));
- this.element.contentWindow.Node.prototype.enclosingNodeOrSelfWithNodeName = Node.prototype.enclosingNodeOrSelfWithNodeName;
- this.element.contentWindow.Node.prototype.enclosingNodeOrSelfWithNodeNameInArray = Node.prototype.enclosingNodeOrSelfWithNodeNameInArray;
- this._addExistingMessagesToSource();
- this._addExistingBreakpointsToSource();
- this._updateExecutionLine();
- if (this._executionLine)
- this.revealLine(this._executionLine);
+ var rowMessages = this._rowMessages[msg.line];
+ if (!rowMessages) {
+ rowMessages = [];
+ this._rowMessages[msg.line] = rowMessages;
+ }
- if (this._lineNumberToReveal) {
- this.revealLine(this._lineNumberToReveal);
- delete this._lineNumberToReveal;
+ for (var i = 0; i < rowMessages.length; ++i) {
+ if (rowMessages[i].isEqual(msg, true)) {
+ this._incrementMessageRepeatCount(rowMessages[i], msg.repeatDelta);
+ this._editor.packAndRepaintAll();
+ return;
+ }
}
- if (this._lineNumberToHighlight) {
- this.highlightLine(this._lineNumberToHighlight);
- delete this._lineNumberToHighlight;
+ rowMessages.push(msg);
+
+ var imageURL;
+ switch (msg.level) {
+ case WebInspector.ConsoleMessage.MessageLevel.Error:
+ messageBubbleElement.addStyleClass("webkit-html-error-message");
+ imageURL = "Images/errorIcon.png";
+ break;
+ case WebInspector.ConsoleMessage.MessageLevel.Warning:
+ messageBubbleElement.addStyleClass("webkit-html-warning-message");
+ imageURL = "Images/warningIcon.png";
+ break;
}
- this.dispatchEventToListeners("content loaded");
+ var messageLineElement = document.createElement("div");
+ messageLineElement.className = "webkit-html-message-line";
+ messageBubbleElement.appendChild(messageLineElement);
+
+ // Create the image element in the Inspector's document so we can use relative image URLs.
+ var image = document.createElement("img");
+ image.src = imageURL;
+ image.className = "webkit-html-message-icon";
+ messageLineElement.appendChild(image);
+ messageLineElement.appendChild(document.createTextNode(msg.message));
+
+ msg._resourceMessageLineElement = messageLineElement;
+
+ this._editor.packAndRepaintAll();
},
- _isContentLoaded: function() {
- var doc = this.element.contentDocument;
- return doc && doc.getElementsByTagName("table")[0];
+ _addExistingBreakpointsToSource: function()
+ {
+ var length = this.breakpoints.length;
+ for (var i = 0; i < length; ++i)
+ this._addBreakpointToSource(this.breakpoints[i]);
},
- _documentContextMenu: function(event)
+ _addBreakpointToSource: function(breakpoint)
+ {
+ this._textModel.setAttribute(breakpoint.line - 1, "breakpoint", breakpoint);
+ this._editor.paintLineNumbers();
+ },
+
+ _removeBreakpointFromSource: function(breakpoint)
+ {
+ this._textModel.removeAttribute(breakpoint.line - 1, "breakpoint");
+ this._editor.paintLineNumbers();
+ },
+
+ _contextMenu: function(lineNumber, event)
{
- if (!event.target.hasStyleClass("webkit-line-number"))
- return;
if (!this.addBreakpointDelegate)
return;
- var sourceRow = event.target.enclosingNodeOrSelfWithNodeName("tr");
var contextMenu = new WebInspector.ContextMenu();
-
- if (!sourceRow._breakpointObject && this.addBreakpointDelegate) {
- var lineNumber = this.lineNumberForSourceRow(sourceRow);
+
+ var breakpoint = this._textModel.getAttribute(lineNumber, "breakpoint");
+ if (!breakpoint) {
// This row doesn't have a breakpoint: We want to show Add Breakpoint and Add and Edit Breakpoint.
- contextMenu.appendItem(WebInspector.UIString("Add Breakpoint"), this.addBreakpointDelegate.bind(this, lineNumber));
+ contextMenu.appendItem(WebInspector.UIString("Add Breakpoint"), this.addBreakpointDelegate.bind(this, lineNumber + 1));
function addConditionalBreakpoint()
{
- this.addBreakpointDelegate(lineNumber);
- var breakpoint = sourceRow._breakpointObject;
+ this.addBreakpointDelegate(lineNumber + 1);
+ var breakpoint = this._textModel.getAttribute(lineNumber, "breakpoint");
if (breakpoint)
- this._editBreakpointCondition(event.target, sourceRow, breakpoint);
+ this._editBreakpointCondition(breakpoint);
}
contextMenu.appendItem(WebInspector.UIString("Add Conditional Breakpoint..."), addConditionalBreakpoint.bind(this));
- } else if (sourceRow._breakpointObject) {
+ } else {
// This row has a breakpoint, we want to show edit and remove breakpoint, and either disable or enable.
- contextMenu.appendItem(WebInspector.UIString("Remove Breakpoint"), WebInspector.panels.scripts.removeBreakpoint.bind(WebInspector.panels.scripts, sourceRow._breakpointObject));
- contextMenu.appendItem(WebInspector.UIString("Edit Breakpoint..."), this._editBreakpointCondition.bind(this, event.target, sourceRow, sourceRow._breakpointObject));
- if (sourceRow._breakpointObject.enabled)
- contextMenu.appendItem(WebInspector.UIString("Disable Breakpoint"), function() { sourceRow._breakpointObject.enabled = false; });
+ contextMenu.appendItem(WebInspector.UIString("Remove Breakpoint"), WebInspector.panels.scripts.removeBreakpoint.bind(WebInspector.panels.scripts, breakpoint));
+ contextMenu.appendItem(WebInspector.UIString("Edit Breakpoint..."), this._editBreakpointCondition.bind(this, breakpoint));
+ if (breakpoint.enabled)
+ contextMenu.appendItem(WebInspector.UIString("Disable Breakpoint"), function() { breakpoint.enabled = false; });
else
- contextMenu.appendItem(WebInspector.UIString("Enable Breakpoint"), function() { sourceRow._breakpointObject.enabled = true; });
+ contextMenu.appendItem(WebInspector.UIString("Enable Breakpoint"), function() { breakpoint.enabled = true; });
}
-
contextMenu.show(event);
},
- _documentMouseDown: function(event)
+ _toggleBreakpoint: function(lineNumber, event)
{
- if (!event.target.hasStyleClass("webkit-line-number"))
- return;
if (event.button != 0 || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey)
return;
- var sourceRow = event.target.enclosingNodeOrSelfWithNodeName("tr");
- if (sourceRow._breakpointObject)
- WebInspector.panels.scripts.removeBreakpoint(sourceRow._breakpointObject);
+ var breakpoint = this._textModel.getAttribute(lineNumber, "breakpoint");
+ if (breakpoint)
+ WebInspector.panels.scripts.removeBreakpoint(breakpoint);
else if (this.addBreakpointDelegate)
- this.addBreakpointDelegate(this.lineNumberForSourceRow(sourceRow));
-
+ this.addBreakpointDelegate(lineNumber + 1);
event.preventDefault();
},
- _editBreakpointCondition: function(eventTarget, sourceRow, breakpoint)
+ _editBreakpointCondition: function(breakpoint)
{
- // TODO: Migrate the popup to the top-level document and remove the blur listener from conditionElement once https://bugs.webkit.org/show_bug.cgi?id=28913 is fixed.
- var popupDocument = this.element.contentDocument;
- this._showBreakpointConditionPopup(eventTarget, breakpoint.line, popupDocument);
+ this._showBreakpointConditionPopup(breakpoint.line);
function committed(element, newText)
{
breakpoint.condition = newText;
- if (breakpoint.condition)
- sourceRow.addStyleClass("webkit-breakpoint-conditional");
- else
- sourceRow.removeStyleClass("webkit-breakpoint-conditional");
+ this._editor.paintLineNumbers();
dismissed.call(this);
}
function dismissed()
{
- this._popup.hide();
+ this._editor.setDivDecoration(breakpoint.line - 1, null);
delete this._conditionEditorElement;
}
@@ -353,42 +357,33 @@ WebInspector.SourceFrame.prototype = {
this._conditionEditorElement.select();
},
- _showBreakpointConditionPopup: function(clickedElement, lineNumber, popupDocument)
+ _showBreakpointConditionPopup: function(lineNumber)
{
- var popupContentElement = this._createPopupElement(lineNumber, popupDocument);
- var lineElement = clickedElement.enclosingNodeOrSelfWithNodeName("td").nextSibling;
- if (this._popup) {
- this._popup.hide();
- this._popup.element = popupContentElement;
- } else {
- this._popup = new WebInspector.Popup(popupContentElement);
- this._popup.autoHide = true;
- }
- this._popup.anchor = lineElement;
- this._popup.show();
+ var conditionElement = this._createConditionElement(lineNumber);
+ this._editor.setDivDecoration(lineNumber - 1, conditionElement);
},
- _createPopupElement: function(lineNumber, popupDocument)
+ _createConditionElement: function(lineNumber)
{
- var popupContentElement = popupDocument.createElement("div");
- popupContentElement.className = "popup-content breakpoint-condition";
+ var conditionElement = document.createElement("div");
+ conditionElement.className = "source-breakpoint-condition";
var labelElement = document.createElement("label");
- labelElement.className = "popup-message";
- labelElement.htmlFor = "bp-condition";
+ labelElement.className = "source-breakpoint-message";
+ labelElement.htmlFor = "source-breakpoint-condition";
labelElement.appendChild(document.createTextNode(WebInspector.UIString("The breakpoint on line %d will stop only if this expression is true:", lineNumber)));
- popupContentElement.appendChild(labelElement);
+ conditionElement.appendChild(labelElement);
var editorElement = document.createElement("input");
- editorElement.id = "bp-condition";
+ editorElement.id = "source-breakpoint-condition";
editorElement.type = "text"
- popupContentElement.appendChild(editorElement);
+ conditionElement.appendChild(editorElement);
this._conditionEditorElement = editorElement;
- return popupContentElement;
+ return conditionElement;
},
- _documentKeyDown: function(event)
+ _keyDown: function(event)
{
var shortcut = WebInspector.KeyboardShortcut.makeKeyFromEvent(event);
var handler = this._shortcuts[shortcut];
@@ -409,7 +404,7 @@ WebInspector.SourceFrame.prototype = {
if (!selection.rangeCount)
return;
- var expression = selection.getRangeAt(0).toString().trim();
+ var expression = selection.getRangeAt(0).toString().trimWhitespace();
WebInspector.panels.scripts.evaluateInSelectedCallFrame(expression, false, "console", function(result, exception) {
WebInspector.showConsole();
var commandMessage = new WebInspector.ConsoleCommand(expression);
@@ -418,305 +413,145 @@ WebInspector.SourceFrame.prototype = {
});
},
- _breakpointEnableChanged: function(event)
+ _breakpointChanged: function(event)
{
- var breakpoint = event.target;
- var sourceRow = this.sourceRow(breakpoint.line);
- if (!sourceRow)
- return;
-
- sourceRow.addStyleClass("webkit-breakpoint");
-
- if (breakpoint.enabled)
- sourceRow.removeStyleClass("webkit-breakpoint-disabled");
- else
- sourceRow.addStyleClass("webkit-breakpoint-disabled");
+ this._editor.paintLineNumbers();
},
- _updateExecutionLine: function(previousLine)
+ resize: function()
{
- if (previousLine) {
- var sourceRow = this.sourceRow(previousLine);
- if (sourceRow)
- sourceRow.removeStyleClass("webkit-execution-line");
- }
-
- if (!this._executionLine)
- return;
-
- this._drawProgramCounterImageIfNeeded();
-
- var sourceRow = this.sourceRow(this._executionLine);
- if (sourceRow)
- sourceRow.addStyleClass("webkit-execution-line");
- },
-
- _addExistingBreakpointsToSource: function()
- {
- var length = this.breakpoints.length;
- for (var i = 0; i < length; ++i)
- this._addBreakpointToSource(this.breakpoints[i]);
- },
-
- _addBreakpointToSource: function(breakpoint)
- {
- var sourceRow = this.sourceRow(breakpoint.line);
- if (!sourceRow)
- return;
-
- breakpoint.sourceText = sourceRow.getElementsByClassName('webkit-line-content')[0].textContent;
-
- this._drawBreakpointImagesIfNeeded();
-
- sourceRow._breakpointObject = breakpoint;
-
- sourceRow.addStyleClass("webkit-breakpoint");
- if (!breakpoint.enabled)
- sourceRow.addStyleClass("webkit-breakpoint-disabled");
- if (breakpoint.condition)
- sourceRow.addStyleClass("webkit-breakpoint-conditional");
- },
-
- _removeBreakpointFromSource: function(breakpoint)
- {
- var sourceRow = this.sourceRow(breakpoint.line);
- if (!sourceRow)
- return;
+ this._editor.updateCanvasSize();
+ }
+}
- delete sourceRow._breakpointObject;
+WebInspector.SourceFrame.prototype.__proto__ = WebInspector.Object.prototype;
- sourceRow.removeStyleClass("webkit-breakpoint");
- sourceRow.removeStyleClass("webkit-breakpoint-disabled");
- sourceRow.removeStyleClass("webkit-breakpoint-conditional");
- },
+WebInspector.BreakpointLineNumberDecorator = function(sourceFrame)
+{
+ this._sourceFrame = sourceFrame;
+ this._textModel = sourceFrame._editor.textModel;
+}
- _incrementMessageRepeatCount: function(msg, repeatDelta)
+WebInspector.BreakpointLineNumberDecorator.prototype = {
+ decorate: function(lineNumber, ctx, x, y, width, height, lineHeight)
{
- if (!msg._resourceMessageLineElement)
- return;
+ var breakpoint = this._textModel.getAttribute(lineNumber, "breakpoint");
+ var isExecutionLine = lineNumber + 1 === this._sourceFrame._executionLine;
+ if (breakpoint || isExecutionLine) {
+ ctx.save();
+ ctx.translate(x + 4, y + 2);
+ var breakpointWidth = width - 6;
+ var breakpointHeight = lineHeight - 4;
+
+ if (breakpoint)
+ this._paintBreakpoint(ctx, breakpointWidth, breakpointHeight, breakpoint);
+
+ if (isExecutionLine)
+ this._paintProgramCounter(ctx, breakpointWidth, breakpointHeight, false);
- if (!msg._resourceMessageRepeatCountElement) {
- var repeatedElement = document.createElement("span");
- msg._resourceMessageLineElement.appendChild(repeatedElement);
- msg._resourceMessageRepeatCountElement = repeatedElement;
+ ctx.restore();
}
- msg.repeatCount += repeatDelta;
- msg._resourceMessageRepeatCountElement.textContent = WebInspector.UIString(" (repeated %d times)", msg.repeatCount);
- },
+ if (isExecutionLine) {
+ // Override default behavior.
+ return true;
+ }
- _addExistingMessagesToSource: function()
- {
- var length = this.messages.length;
- for (var i = 0; i < length; ++i)
- this._addMessageToSource(this.messages[i]);
+ ctx.fillStyle = breakpoint ? "rgb(255,255,255)" : "rgb(155,155,155)";
+ return false;
},
- _addMessageToSource: function(msg)
+ _paintBreakpoint: function(ctx, width, height, breakpoint)
{
- var row = this.sourceRow(msg.line);
- if (!row)
- return;
-
- var cell = row.cells[1];
- if (!cell)
- return;
-
- var messageBubbleElement = cell.lastChild;
- if (!messageBubbleElement || messageBubbleElement.nodeType !== Node.ELEMENT_NODE || !messageBubbleElement.hasStyleClass("webkit-html-message-bubble")) {
- messageBubbleElement = this.element.contentDocument.createElement("div");
- messageBubbleElement.className = "webkit-html-message-bubble";
- cell.appendChild(messageBubbleElement);
- }
-
- if (!row.messages)
- row.messages = [];
-
- for (var i = 0; i < row.messages.length; ++i) {
- if (row.messages[i].isEqual(msg, true)) {
- this._incrementMessageRepeatCount(row.messages[i], msg.repeatDelta);
- return;
- }
- }
+ ctx.beginPath();
+ ctx.moveTo(0, 2);
+ ctx.lineTo(2, 0);
+ ctx.lineTo(width - 5, 0);
+ ctx.lineTo(width, height / 2);
+ ctx.lineTo(width - 5, height);
+ ctx.lineTo(2, height);
+ ctx.lineTo(0, height - 2);
+ ctx.closePath();
+ ctx.fillStyle = breakpoint.condition ? "rgb(217, 142, 1)" : "rgb(1, 142, 217)";
+ ctx.strokeStyle = breakpoint.condition ? "rgb(205, 103, 0)" : "rgb(0, 103, 205)";
+ ctx.lineWidth = 3;
+ ctx.fill();
- row.messages.push(msg);
+ ctx.save();
+ ctx.clip();
+ ctx.stroke();
+ ctx.restore();
- var imageURL;
- switch (msg.level) {
- case WebInspector.ConsoleMessage.MessageLevel.Error:
- messageBubbleElement.addStyleClass("webkit-html-error-message");
- imageURL = "Images/errorIcon.png";
- break;
- case WebInspector.ConsoleMessage.MessageLevel.Warning:
- messageBubbleElement.addStyleClass("webkit-html-warning-message");
- imageURL = "Images/warningIcon.png";
- break;
+ if (!breakpoint.enabled) {
+ ctx.save();
+ ctx.globalCompositeOperation = "destination-out";
+ ctx.fillStyle = "rgba(0, 0, 0, 0.5)";
+ ctx.fillRect(0, 0, width, height);
+ ctx.restore();
}
-
- var messageLineElement = this.element.contentDocument.createElement("div");
- messageLineElement.className = "webkit-html-message-line";
- messageBubbleElement.appendChild(messageLineElement);
-
- // Create the image element in the Inspector's document so we can use relative image URLs.
- var image = document.createElement("img");
- image.src = imageURL;
- image.className = "webkit-html-message-icon";
-
- // Adopt the image element since it wasn't created in element's contentDocument.
- image = this.element.contentDocument.adoptNode(image);
- messageLineElement.appendChild(image);
- messageLineElement.appendChild(this.element.contentDocument.createTextNode(msg.message));
-
- msg._resourceMessageLineElement = messageLineElement;
},
- _drawProgramCounterInContext: function(ctx, glow)
+ _paintProgramCounter: function(ctx, width, height)
{
- if (glow)
- ctx.save();
+ ctx.save();
ctx.beginPath();
- ctx.moveTo(17, 2);
- ctx.lineTo(19, 2);
- ctx.lineTo(19, 0);
- ctx.lineTo(21, 0);
- ctx.lineTo(26, 5.5);
- ctx.lineTo(21, 11);
- ctx.lineTo(19, 11);
- ctx.lineTo(19, 9);
- ctx.lineTo(17, 9);
+ ctx.moveTo(width - 9, 2);
+ ctx.lineTo(width - 7, 2);
+ ctx.lineTo(width - 7, 0);
+ ctx.lineTo(width - 5, 0);
+ ctx.lineTo(width, height / 2);
+ ctx.lineTo(width - 5, height);
+ ctx.lineTo(width - 7, height);
+ ctx.lineTo(width - 7, height - 2);
+ ctx.lineTo(width - 9, height - 2);
ctx.closePath();
ctx.fillStyle = "rgb(142, 5, 4)";
- if (glow) {
- ctx.shadowBlur = 4;
- ctx.shadowColor = "rgb(255, 255, 255)";
- ctx.shadowOffsetX = -1;
- ctx.shadowOffsetY = 0;
- }
+ ctx.shadowBlur = 4;
+ ctx.shadowColor = "rgb(255, 255, 255)";
+ ctx.shadowOffsetX = -1;
+ ctx.shadowOffsetY = 0;
ctx.fill();
ctx.fill(); // Fill twice to get a good shadow and darker anti-aliased pixels.
- if (glow)
- ctx.restore();
+ ctx.restore();
},
- _drawProgramCounterImageIfNeeded: function()
+ mouseDown: function(lineNumber, e)
{
- if (!this._needsProgramCounterImage || !this.element.contentDocument)
- return;
-
- var ctx = this.element.contentDocument.getCSSCanvasContext("2d", "program-counter", 26, 11);
- ctx.clearRect(0, 0, 26, 11);
- this._drawProgramCounterInContext(ctx, true);
-
- delete this._needsProgramCounterImage;
+ this._sourceFrame._toggleBreakpoint(lineNumber, e);
+ return true;
},
- _drawBreakpointImagesIfNeeded: function(conditional)
+ contextMenu: function(lineNumber, e)
{
- if (!this._needsBreakpointImages || !this.element.contentDocument)
- return;
-
- function drawBreakpoint(ctx, disabled, conditional)
- {
- ctx.beginPath();
- ctx.moveTo(0, 2);
- ctx.lineTo(2, 0);
- ctx.lineTo(21, 0);
- ctx.lineTo(26, 5.5);
- ctx.lineTo(21, 11);
- ctx.lineTo(2, 11);
- ctx.lineTo(0, 9);
- ctx.closePath();
- ctx.fillStyle = conditional ? "rgb(217, 142, 1)" : "rgb(1, 142, 217)";
- ctx.strokeStyle = conditional ? "rgb(205, 103, 0)" : "rgb(0, 103, 205)";
- ctx.lineWidth = 3;
- ctx.fill();
- ctx.save();
- ctx.clip();
- ctx.stroke();
- ctx.restore();
-
- if (!disabled)
- return;
-
- ctx.save();
- ctx.globalCompositeOperation = "destination-out";
- ctx.fillStyle = "rgba(0, 0, 0, 0.5)";
- ctx.fillRect(0, 0, 26, 11);
- ctx.restore();
- }
-
-
- // Unconditional breakpoints.
-
- var ctx = this.element.contentDocument.getCSSCanvasContext("2d", "breakpoint", 26, 11);
- ctx.clearRect(0, 0, 26, 11);
- drawBreakpoint(ctx);
-
- var ctx = this.element.contentDocument.getCSSCanvasContext("2d", "breakpoint-program-counter", 26, 11);
- ctx.clearRect(0, 0, 26, 11);
- drawBreakpoint(ctx);
- ctx.clearRect(20, 0, 6, 11);
- this._drawProgramCounterInContext(ctx, true);
-
- var ctx = this.element.contentDocument.getCSSCanvasContext("2d", "breakpoint-disabled", 26, 11);
- ctx.clearRect(0, 0, 26, 11);
- drawBreakpoint(ctx, true);
-
- var ctx = this.element.contentDocument.getCSSCanvasContext("2d", "breakpoint-disabled-program-counter", 26, 11);
- ctx.clearRect(0, 0, 26, 11);
- drawBreakpoint(ctx, true);
- ctx.clearRect(20, 0, 6, 11);
- this._drawProgramCounterInContext(ctx, true);
-
-
- // Conditional breakpoints.
-
- var ctx = this.element.contentDocument.getCSSCanvasContext("2d", "breakpoint-conditional", 26, 11);
- ctx.clearRect(0, 0, 26, 11);
- drawBreakpoint(ctx, false, true);
-
- var ctx = this.element.contentDocument.getCSSCanvasContext("2d", "breakpoint-conditional-program-counter", 26, 11);
- ctx.clearRect(0, 0, 26, 11);
- drawBreakpoint(ctx, false, true);
- ctx.clearRect(20, 0, 6, 11);
- this._drawProgramCounterInContext(ctx, true);
-
- var ctx = this.element.contentDocument.getCSSCanvasContext("2d", "breakpoint-disabled-conditional", 26, 11);
- ctx.clearRect(0, 0, 26, 11);
- drawBreakpoint(ctx, true, true);
-
- var ctx = this.element.contentDocument.getCSSCanvasContext("2d", "breakpoint-disabled-conditional-program-counter", 26, 11);
- ctx.clearRect(0, 0, 26, 11);
- drawBreakpoint(ctx, true, true);
- ctx.clearRect(20, 0, 6, 11);
- this._drawProgramCounterInContext(ctx, true);
-
- delete this._needsBreakpointImages;
- },
-
- syntaxHighlightJavascript: function()
- {
- var table = this.element.contentDocument.getElementsByTagName("table")[0];
- if (!table)
- return;
+ this._sourceFrame._contextMenu(lineNumber, e);
+ return true;
+ }
+}
- var jsSyntaxHighlighter = new WebInspector.JavaScriptSourceSyntaxHighlighter(table, this);
- jsSyntaxHighlighter.process();
- },
+WebInspector.ExecutionLineDecorator = function(sourceFrame)
+{
+ this._sourceFrame = sourceFrame;
+}
- syntaxHighlightCSS: function()
+WebInspector.ExecutionLineDecorator.prototype = {
+ decorate: function(lineNumber, ctx, x, y, width, height, lineHeight)
{
- var table = this.element.contentDocument.getElementsByTagName("table")[0];
- if (!table)
+ if (this._sourceFrame._executionLine !== lineNumber + 1)
return;
+ ctx.save();
+ ctx.fillStyle = "rgb(171, 191, 254)";
+ ctx.fillRect(x, y, width, height);
+
+ ctx.beginPath();
+ ctx.rect(x - 1, y, width + 2, height);
+ ctx.clip();
+ ctx.strokeStyle = "rgb(64, 115, 244)";
+ ctx.stroke();
- var cssSyntaxHighlighter = new WebInspector.CSSSourceSyntaxHighlighter(table, this);
- cssSyntaxHighlighter.process();
+ ctx.restore();
}
}
-
-WebInspector.SourceFrame.prototype.__proto__ = WebInspector.Object.prototype;
diff --git a/WebCore/inspector/front-end/SourceFrame2.js b/WebCore/inspector/front-end/SourceFrame2.js
deleted file mode 100644
index 49bf98e..0000000
--- a/WebCore/inspector/front-end/SourceFrame2.js
+++ /dev/null
@@ -1,522 +0,0 @@
-/*
- * Copyright (C) 2009 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-WebInspector.SourceFrame2 = function(addBreakpointDelegate)
-{
- this._editor = new WebInspector.TextEditor(WebInspector.platform);
- this._textModel = this._editor.textModel;
- this._editor.lineNumberDecorator = new WebInspector.BreakpointLineNumberDecorator(this);
- this._editor.lineDecorator = new WebInspector.ExecutionLineDecorator(this);
- this._editor.readOnly = true;
- this._messages = [];
- this._rowMessages = {};
- this._messageBubbles = {};
- this.breakpoints = [];
- this._shortcuts = {};
- this.element = this._editor.element;
- this.element.addEventListener("keydown", this._keyDown.bind(this), true);
- this._loaded = false;
-
- this.addBreakpointDelegate = addBreakpointDelegate;
-}
-
-WebInspector.SourceFrame2.prototype = {
-
- get executionLine()
- {
- return this._executionLine;
- },
-
- set executionLine(x)
- {
- if (this._executionLine === x)
- return;
- this._executionLine = x;
- this._editor.repaintAll();
- },
-
- revealLine: function(lineNumber)
- {
- if (!this._loaded)
- this._lineNumberToReveal = lineNumber;
- else
- this._editor.reveal(lineNumber - 1, 0);
- },
-
- addBreakpoint: function(breakpoint)
- {
- this.breakpoints.push(breakpoint);
- breakpoint.addEventListener("enabled", this._breakpointChanged, this);
- breakpoint.addEventListener("disabled", this._breakpointChanged, this);
- breakpoint.addEventListener("condition-changed", this._breakpointChanged, this);
- this._addBreakpointToSource(breakpoint);
- },
-
- removeBreakpoint: function(breakpoint)
- {
- this.breakpoints.remove(breakpoint);
- breakpoint.removeEventListener("enabled", null, this);
- breakpoint.removeEventListener("disabled", null, this);
- breakpoint.removeEventListener("condition-changed", null, this);
- this._removeBreakpointFromSource(breakpoint);
- },
-
- addMessage: function(msg)
- {
- // Don't add the message if there is no message or valid line or if the msg isn't an error or warning.
- if (!msg.message || msg.line <= 0 || !msg.isErrorOrWarning())
- return;
- this._messages.push(msg);
- this._addMessageToSource(msg);
- },
-
- clearMessages: function()
- {
- for (var line in this._messageBubbles) {
- var bubble = this._messageBubbles[line];
- bubble.parentNode.removeChild(bubble);
- }
-
- this._messages = [];
- this._rowMessages = {};
- this._messageBubbles = {};
- this._editor.packAndRepaintAll();
- },
-
- sizeToFitContentHeight: function()
- {
- this._editor.packAndRepaintAll();
- },
-
- setContent: function(mimeType, content)
- {
- this._loaded = true;
- this._editor.mimeType = mimeType;
- this._editor.text = content;
-
- this._addExistingMessagesToSource();
- this._addExistingBreakpointsToSource();
- if (this._executionLine)
- this.revealLine(this._executionLine);
-
- if (this._lineNumberToReveal) {
- this.revealLine(this._lineNumberToReveal);
- delete this._lineNumberToReveal;
- }
- this._editor.setCoalescingUpdate(true);
- this._editor.updateCanvasSize();
- this._editor.packAndRepaintAll();
- this._editor.setCoalescingUpdate(false);
- },
-
- findSearchMatches: function(query)
- {
- var ranges = [];
- for (var i = 0; i < this._textModel.linesCount; ++i) {
- var line = this._textModel.line(i);
- var column = line.indexOf(query);
- if (column === -1)
- continue;
- ranges.push(new WebInspector.TextRange(i, column, i, column + query.length));
- }
- return ranges;
- },
-
- setSelection: function(range)
- {
- this._editor.setSelection(range.startLine, range.startColumn, range.endLine, range.endColumn);
- },
-
- _incrementMessageRepeatCount: function(msg, repeatDelta)
- {
- if (!msg._resourceMessageLineElement)
- return;
-
- if (!msg._resourceMessageRepeatCountElement) {
- var repeatedElement = document.createElement("span");
- msg._resourceMessageLineElement.appendChild(repeatedElement);
- msg._resourceMessageRepeatCountElement = repeatedElement;
- }
-
- msg.repeatCount += repeatDelta;
- msg._resourceMessageRepeatCountElement.textContent = WebInspector.UIString(" (repeated %d times)", msg.repeatCount);
- },
-
- _addExistingMessagesToSource: function()
- {
- var length = this._messages.length;
- for (var i = 0; i < length; ++i)
- this._addMessageToSource(this._messages[i]);
- },
-
- _addMessageToSource: function(msg)
- {
- if (msg.line >= this._textModel.linesCount)
- return;
-
- var messageBubbleElement = this._messageBubbles[msg.line];
- if (!messageBubbleElement || messageBubbleElement.nodeType !== Node.ELEMENT_NODE || !messageBubbleElement.hasStyleClass("webkit-html-message-bubble")) {
- messageBubbleElement = document.createElement("div");
- messageBubbleElement.className = "webkit-html-message-bubble";
- this._messageBubbles[msg.line] = messageBubbleElement;
- this._editor.setDivDecoration(msg.line - 1, messageBubbleElement);
- }
-
- var rowMessages = this._rowMessages[msg.line];
- if (!rowMessages) {
- rowMessages = [];
- this._rowMessages[msg.line] = rowMessages;
- }
-
- for (var i = 0; i < rowMessages.length; ++i) {
- if (rowMessages[i].isEqual(msg, true)) {
- this._incrementMessageRepeatCount(rowMessages[i], msg.repeatDelta);
- this._editor.packAndRepaintAll();
- return;
- }
- }
-
- rowMessages.push(msg);
-
- var imageURL;
- switch (msg.level) {
- case WebInspector.ConsoleMessage.MessageLevel.Error:
- messageBubbleElement.addStyleClass("webkit-html-error-message");
- imageURL = "Images/errorIcon.png";
- break;
- case WebInspector.ConsoleMessage.MessageLevel.Warning:
- messageBubbleElement.addStyleClass("webkit-html-warning-message");
- imageURL = "Images/warningIcon.png";
- break;
- }
-
- var messageLineElement = document.createElement("div");
- messageLineElement.className = "webkit-html-message-line";
- messageBubbleElement.appendChild(messageLineElement);
-
- // Create the image element in the Inspector's document so we can use relative image URLs.
- var image = document.createElement("img");
- image.src = imageURL;
- image.className = "webkit-html-message-icon";
- messageLineElement.appendChild(image);
- messageLineElement.appendChild(document.createTextNode(msg.message));
-
- msg._resourceMessageLineElement = messageLineElement;
-
- this._editor.packAndRepaintAll();
- },
-
- _addExistingBreakpointsToSource: function()
- {
- var length = this.breakpoints.length;
- for (var i = 0; i < length; ++i)
- this._addBreakpointToSource(this.breakpoints[i]);
- },
-
- _addBreakpointToSource: function(breakpoint)
- {
- this._textModel.setAttribute(breakpoint.line - 1, "breakpoint", breakpoint);
- this._editor.paintLineNumbers();
- },
-
- _removeBreakpointFromSource: function(breakpoint)
- {
- this._textModel.removeAttribute(breakpoint.line - 1, "breakpoint");
- this._editor.paintLineNumbers();
- },
-
- _contextMenu: function(lineNumber, event)
- {
- if (!this.addBreakpointDelegate)
- return;
-
- var contextMenu = new WebInspector.ContextMenu();
-
- var breakpoint = this._textModel.getAttribute(lineNumber, "breakpoint");
- if (!breakpoint) {
- // This row doesn't have a breakpoint: We want to show Add Breakpoint and Add and Edit Breakpoint.
- contextMenu.appendItem(WebInspector.UIString("Add Breakpoint"), this.addBreakpointDelegate.bind(this, lineNumber + 1));
-
- function addConditionalBreakpoint()
- {
- this.addBreakpointDelegate(lineNumber + 1);
- var breakpoint = this._textModel.getAttribute(lineNumber, "breakpoint");
- if (breakpoint)
- this._editBreakpointCondition(breakpoint);
- }
-
- contextMenu.appendItem(WebInspector.UIString("Add Conditional Breakpoint..."), addConditionalBreakpoint.bind(this));
- } else {
- // This row has a breakpoint, we want to show edit and remove breakpoint, and either disable or enable.
- contextMenu.appendItem(WebInspector.UIString("Remove Breakpoint"), WebInspector.panels.scripts.removeBreakpoint.bind(WebInspector.panels.scripts, breakpoint));
- contextMenu.appendItem(WebInspector.UIString("Edit Breakpoint..."), this._editBreakpointCondition.bind(this, breakpoint));
- if (breakpoint.enabled)
- contextMenu.appendItem(WebInspector.UIString("Disable Breakpoint"), function() { breakpoint.enabled = false; });
- else
- contextMenu.appendItem(WebInspector.UIString("Enable Breakpoint"), function() { breakpoint.enabled = true; });
- }
- contextMenu.show(event);
- },
-
- _toggleBreakpoint: function(lineNumber, event)
- {
- if (event.button != 0 || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey)
- return;
- var breakpoint = this._textModel.getAttribute(lineNumber, "breakpoint");
- if (breakpoint)
- WebInspector.panels.scripts.removeBreakpoint(breakpoint);
- else if (this.addBreakpointDelegate)
- this.addBreakpointDelegate(lineNumber + 1);
- event.preventDefault();
- },
-
- _editBreakpointCondition: function(breakpoint)
- {
- this._showBreakpointConditionPopup(breakpoint.line);
-
- function committed(element, newText)
- {
- breakpoint.condition = newText;
- this._editor.paintLineNumbers();
- dismissed.call(this);
- }
-
- function dismissed()
- {
- this._editor.setDivDecoration(breakpoint.line - 1, null);
- delete this._conditionEditorElement;
- }
-
- var dismissedHandler = dismissed.bind(this);
- this._conditionEditorElement.addEventListener("blur", dismissedHandler, false);
-
- WebInspector.startEditing(this._conditionEditorElement, committed.bind(this), dismissedHandler);
- this._conditionEditorElement.value = breakpoint.condition;
- this._conditionEditorElement.select();
- },
-
- _showBreakpointConditionPopup: function(lineNumber)
- {
- var conditionElement = this._createConditionElement(lineNumber);
- this._editor.setDivDecoration(lineNumber - 1, conditionElement);
- },
-
- _createConditionElement: function(lineNumber)
- {
- var conditionElement = document.createElement("div");
- conditionElement.className = "source-breakpoint-condition";
-
- var labelElement = document.createElement("label");
- labelElement.className = "source-breakpoint-message";
- labelElement.htmlFor = "source-breakpoint-condition";
- labelElement.appendChild(document.createTextNode(WebInspector.UIString("The breakpoint on line %d will stop only if this expression is true:", lineNumber)));
- conditionElement.appendChild(labelElement);
-
- var editorElement = document.createElement("input");
- editorElement.id = "source-breakpoint-condition";
- editorElement.type = "text"
- conditionElement.appendChild(editorElement);
- this._conditionEditorElement = editorElement;
-
- return conditionElement;
- },
-
- _keyDown: function(event)
- {
- var shortcut = WebInspector.KeyboardShortcut.makeKeyFromEvent(event);
- var handler = this._shortcuts[shortcut];
- if (handler) {
- handler(event);
- event.preventDefault();
- } else {
- WebInspector.documentKeyDown(event);
- }
- },
-
- _evalSelectionInCallFrame: function(event)
- {
- if (!WebInspector.panels.scripts || !WebInspector.panels.scripts.paused)
- return;
-
- var selection = this.element.contentWindow.getSelection();
- if (!selection.rangeCount)
- return;
-
- var expression = selection.getRangeAt(0).toString().trimWhitespace();
- WebInspector.panels.scripts.evaluateInSelectedCallFrame(expression, false, "console", function(result, exception) {
- WebInspector.showConsole();
- var commandMessage = new WebInspector.ConsoleCommand(expression);
- WebInspector.console.addMessage(commandMessage);
- WebInspector.console.addMessage(new WebInspector.ConsoleCommandResult(result, exception, commandMessage));
- });
- },
-
- _breakpointChanged: function(event)
- {
- this._editor.paintLineNumbers();
- },
-
- resize: function()
- {
- this._editor.updateCanvasSize();
- }
-}
-
-WebInspector.SourceFrame2.prototype.__proto__ = WebInspector.Object.prototype;
-
-WebInspector.BreakpointLineNumberDecorator = function(sourceFrame)
-{
- this._sourceFrame = sourceFrame;
- this._textModel = sourceFrame._editor.textModel;
-}
-
-WebInspector.BreakpointLineNumberDecorator.prototype = {
- decorate: function(lineNumber, ctx, x, y, width, height, lineHeight)
- {
- var breakpoint = this._textModel.getAttribute(lineNumber, "breakpoint");
- var isExecutionLine = lineNumber + 1 === this._sourceFrame._executionLine;
- if (breakpoint || isExecutionLine) {
- ctx.save();
- ctx.translate(x + 4, y + 2);
- var breakpointWidth = width - 6;
- var breakpointHeight = lineHeight - 4;
-
- if (breakpoint)
- this._paintBreakpoint(ctx, breakpointWidth, breakpointHeight, breakpoint);
-
- if (isExecutionLine)
- this._paintProgramCounter(ctx, breakpointWidth, breakpointHeight, false);
-
- ctx.restore();
- }
-
- if (isExecutionLine) {
- // Override default behavior.
- return true;
- }
-
- ctx.fillStyle = breakpoint ? "rgb(255,255,255)" : "rgb(155,155,155)";
- return false;
- },
-
- _paintBreakpoint: function(ctx, width, height, breakpoint)
- {
- ctx.beginPath();
- ctx.moveTo(0, 2);
- ctx.lineTo(2, 0);
- ctx.lineTo(width - 5, 0);
- ctx.lineTo(width, height / 2);
- ctx.lineTo(width - 5, height);
- ctx.lineTo(2, height);
- ctx.lineTo(0, height - 2);
- ctx.closePath();
- ctx.fillStyle = breakpoint.condition ? "rgb(217, 142, 1)" : "rgb(1, 142, 217)";
- ctx.strokeStyle = breakpoint.condition ? "rgb(205, 103, 0)" : "rgb(0, 103, 205)";
- ctx.lineWidth = 3;
- ctx.fill();
-
- ctx.save();
- ctx.clip();
- ctx.stroke();
- ctx.restore();
-
- if (!breakpoint.enabled) {
- ctx.save();
- ctx.globalCompositeOperation = "destination-out";
- ctx.fillStyle = "rgba(0, 0, 0, 0.5)";
- ctx.fillRect(0, 0, width, height);
- ctx.restore();
- }
- },
-
- _paintProgramCounter: function(ctx, width, height)
- {
- ctx.save();
-
- ctx.beginPath();
- ctx.moveTo(width - 9, 2);
- ctx.lineTo(width - 7, 2);
- ctx.lineTo(width - 7, 0);
- ctx.lineTo(width - 5, 0);
- ctx.lineTo(width, height / 2);
- ctx.lineTo(width - 5, height);
- ctx.lineTo(width - 7, height);
- ctx.lineTo(width - 7, height - 2);
- ctx.lineTo(width - 9, height - 2);
- ctx.closePath();
- ctx.fillStyle = "rgb(142, 5, 4)";
-
- ctx.shadowBlur = 4;
- ctx.shadowColor = "rgb(255, 255, 255)";
- ctx.shadowOffsetX = -1;
- ctx.shadowOffsetY = 0;
-
- ctx.fill();
- ctx.fill(); // Fill twice to get a good shadow and darker anti-aliased pixels.
-
- ctx.restore();
- },
-
- mouseDown: function(lineNumber, e)
- {
- this._sourceFrame._toggleBreakpoint(lineNumber, e);
- return true;
- },
-
- contextMenu: function(lineNumber, e)
- {
- this._sourceFrame._contextMenu(lineNumber, e);
- return true;
- }
-}
-
-WebInspector.ExecutionLineDecorator = function(sourceFrame)
-{
- this._sourceFrame = sourceFrame;
-}
-
-WebInspector.ExecutionLineDecorator.prototype = {
- decorate: function(lineNumber, ctx, x, y, width, height, lineHeight)
- {
- if (this._sourceFrame._executionLine !== lineNumber + 1)
- return;
- ctx.save();
- ctx.fillStyle = "rgb(171, 191, 254)";
- ctx.fillRect(x, y, width, height);
-
- ctx.beginPath();
- ctx.rect(x - 1, y, width + 2, height);
- ctx.clip();
- ctx.strokeStyle = "rgb(64, 115, 244)";
- ctx.stroke();
-
- ctx.restore();
- }
-}
diff --git a/WebCore/inspector/front-end/SourceView.js b/WebCore/inspector/front-end/SourceView.js
index cdfdbdc..3dd6e0b 100644
--- a/WebCore/inspector/front-end/SourceView.js
+++ b/WebCore/inspector/front-end/SourceView.js
@@ -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;
}
- },
-
- _syntaxHighlightingComplete: function(event)
- {
- this._sourceFrameSetupFinished();
- this.sourceFrame.removeEventListener("syntax highlighting complete", null, this);
}
}
diff --git a/WebCore/inspector/front-end/TextEditor.js b/WebCore/inspector/front-end/TextEditor.js
index 46f0d55..dd430c4 100644
--- a/WebCore/inspector/front-end/TextEditor.js
+++ b/WebCore/inspector/front-end/TextEditor.js
@@ -49,10 +49,6 @@ WebInspector.TextEditor = function(platform)
this._sheet.className = "text-editor-sheet";
this._container.appendChild(this._sheet);
- this._clipboard = document.createElement("textarea");
- this._clipboard.className = "text-editor-clip";
- this._container.appendChild(this._clipboard);
-
var cursorElement = document.createElement("div");
cursorElement.className = "text-editor-cursor";
this._container.appendChild(cursorElement);
@@ -140,6 +136,11 @@ WebInspector.TextEditor.prototype = {
this._lineDecorator = lineDecorator;
},
+ get selection()
+ {
+ return this._selection.range();
+ },
+
setSelection: function(startLine, startColumn, endLine, endColumn)
{
var start = this._fit(startLine, startColumn);
@@ -514,7 +515,7 @@ WebInspector.TextEditor.prototype = {
{
// Hide div-based cursor first.
this._cursor._cursorElement.style.display = "none";
- setTimeout(this._repaintOnScroll.bind(this), 0);
+ setTimeout(this._repaintOnScroll.bind(this), 10);
},
_repaintOnScroll: function()
@@ -533,6 +534,9 @@ WebInspector.TextEditor.prototype = {
_mouseDown: function(e)
{
+ if (e.button === 2 || (this._isMac && e.ctrlKey))
+ return;
+
var location = this._caretForMouseEvent(e);
if (e.offsetX < this._lineNumberWidth && this._lineNumberDecorator) {
@@ -574,6 +578,14 @@ WebInspector.TextEditor.prototype = {
var line = location.line;
if (this._lineNumberDecorator.contextMenu(location.line, e))
return;
+ } else {
+ var range = this._selection.range();
+ if (!range.isEmpty()) {
+ var text = this._textModel.copyRange(range);
+ var contextMenu = new WebInspector.ContextMenu();
+ contextMenu.appendItem(WebInspector.UIString("Copy"), this._copy.bind(this));
+ contextMenu.show(event);
+ }
}
},
@@ -581,7 +593,7 @@ WebInspector.TextEditor.prototype = {
{
var lineNumber = Math.max(0, this._offsetToLine(e.offsetY) - 1);
var line = this._textModel.line(lineNumber);
- var offset = e.offsetX + this._scrollLeft - this._lineNumberWidth - this._digitWidth;
+ var offset = e.offsetX + this._scrollLeft - this._lineNumberWidth;
return { line: lineNumber, column: this._columnForOffset(lineNumber, offset) };
},
@@ -589,12 +601,23 @@ WebInspector.TextEditor.prototype = {
{
var length = 0;
var line = this._textModel.line(lineNumber);
- for (var column = 0; column < line.length; ++column) {
- if (length > offset)
- break;
- length += this._ctx.measureText(line.charAt(column)).width;
+
+ // First pretend it is monospace to get a quick guess.
+ var charWidth = this._ctx.measureText("a").width;
+ var index = Math.floor(offset / charWidth);
+ var indexOffset = this._ctx.measureText(line.substring(0, index)).width;
+ if (offset >= indexOffset && index < line.length && offset < indexOffset + this._ctx.measureText(line.charAt(index)).width)
+ return index;
+
+ // Fallback to non-monospace.
+ var delta = indexOffset < offset ? 1 : -1;
+ while (index >=0 && index < line.length) {
+ index += delta;
+ indexOffset += delta * this._ctx.measureText(line.charAt(index)).width;
+ if (offset >= indexOffset && offset < indexOffset + charWidth)
+ return index;
}
- return column;
+ return line.length;
},
_columnToOffset: function(lineNumber, column)
@@ -847,8 +870,14 @@ WebInspector.TextEditor.prototype = {
var range = this._selection.range();
var text = this._textModel.copyRange(range);
- this._clipboard.value = text;
- this._clipboard.select();
+ function delayCopy()
+ {
+ InspectorFrontendHost.copyText(text);
+ }
+
+ setTimeout(delayCopy);
+ if (e)
+ e.preventDefault();
},
_beforeCut: function(e)
@@ -859,6 +888,11 @@ WebInspector.TextEditor.prototype = {
_cut: function(e)
{
+ if (this._readOnly) {
+ e.preventDefault();
+ return;
+ }
+
this._textModel.markUndoableState();
this._copy(e);
this._replaceSelectionWith("");
diff --git a/WebCore/inspector/front-end/WebKit.qrc b/WebCore/inspector/front-end/WebKit.qrc
index d6d9a5d..363bb99 100644
--- a/WebCore/inspector/front-end/WebKit.qrc
+++ b/WebCore/inspector/front-end/WebKit.qrc
@@ -64,7 +64,6 @@
<file>SidebarTreeElement.js</file>
<file>SourceCSSTokenizer.js</file>
<file>SourceFrame.js</file>
- <file>SourceFrame2.js</file>
<file>SourceHTMLTokenizer.js</file>
<file>SourceJavaScriptTokenizer.js</file>
<file>SourceSyntaxHighlighter.js</file>
diff --git a/WebCore/inspector/front-end/inspector.html b/WebCore/inspector/front-end/inspector.html
index ce13c0a..a866003 100644
--- a/WebCore/inspector/front-end/inspector.html
+++ b/WebCore/inspector/front-end/inspector.html
@@ -93,7 +93,6 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<script type="text/javascript" src="AuditLauncherView.js"></script>
<script type="text/javascript" src="ResourceView.js"></script>
<script type="text/javascript" src="SourceFrame.js"></script>
- <script type="text/javascript" src="SourceFrame2.js"></script>
<script type="text/javascript" src="SourceSyntaxHighlighter.js"></script>
<script type="text/javascript" src="CSSSourceSyntaxHighlighter.js"></script>
<script type="text/javascript" src="JavaScriptSourceSyntaxHighlighter.js"></script>
diff --git a/WebCore/inspector/front-end/textEditor.css b/WebCore/inspector/front-end/textEditor.css
index daa12c0..5ebfe5f 100644
--- a/WebCore/inspector/front-end/textEditor.css
+++ b/WebCore/inspector/front-end/textEditor.css
@@ -31,14 +31,6 @@
overflow: auto;
}
-.text-editor-clip {
- opacity: 0;
- position: absolute;
- top:0;
- left:0;
- pointer-events: none;
-}
-
.text-editor-cursor {
-webkit-user-select: none;
-webkit-user-modify: none;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list