Skip to content

Commit

Permalink
Merge branch 'rlim/attr-value-hints' of github.com:adobe/brackets int…
Browse files Browse the repository at this point in the history
…o rlim/attr-value-hints
  • Loading branch information
njx committed Aug 17, 2012
2 parents a2bd984 + 16a7fdb commit 4aeb9be
Show file tree
Hide file tree
Showing 28 changed files with 4,025 additions and 2,357 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ The Brackets native shell currently runs on Mac and Windows. Since it's based on
CEF/Chromium, it could be ported to Linux relatively easily, but that work hasn't
been done yet. Stay tuned.

You can download "stable" builds of Brackets from the
[downloads page](http://github.com/adobe/brackets/downloads).
You can download "stable" builds of Brackets from the Download Packages section of the
[downloads page](http://github.com/adobe/brackets/downloads).
If you want to pull the repos directly via git, see
[How to Use Brackets](http://github.com/adobe/brackets/wiki/How-to-Use-Brackets)
for instructions on how to get everything. Either way, you can launch Brackets
Expand Down
27 changes: 19 additions & 8 deletions src/LiveDevelopment/Agents/CSSAgent.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, forin: true, maxerr: 50, regexp: true */
/*global define, $ */
/*global define, $, PathUtils */

/**
* CSSAgent keeps track of loaded style sheets and allows reloading them
Expand All @@ -33,20 +33,31 @@
define(function CSSAgent(require, exports, module) {
"use strict";

require("thirdparty/path-utils/path-utils.min");

var Inspector = require("LiveDevelopment/Inspector/Inspector");

var _load; // {$.Deferred} load promise
var _urlToStyle; // {url -> loaded} style definition

/**
* Create a canonicalized version of the given URL, stripping off query strings and hashes.
* @param {string} url the URL to canonicalize
* @return the canonicalized URL
*/
function _canonicalize(url) {
return PathUtils.parseUrl(url).hrefNoSearch;
}

// WebInspector Event: Page.loadEventFired
function _onLoadEventFired(res) {
function _onLoadEventFired(event, res) {
// res = {timestamp}
_urlToStyle = {};
Inspector.CSS.getAllStyleSheets(function onGetAllStyleSheets(res) {
var i, header;
for (i in res.headers) {
header = res.headers[i];
_urlToStyle[header.sourceURL] = header;
_urlToStyle[_canonicalize(header.sourceURL)] = header;
}
_load.resolve();
});
Expand All @@ -56,9 +67,9 @@ define(function CSSAgent(require, exports, module) {
* @param {string} url
*/
function styleForURL(url) {
return _urlToStyle[url];
return _urlToStyle[_canonicalize(url)];
}

/** Get a list of all loaded stylesheet files by URL */
function getStylesheetURLs() {
var urls = [], url;
Expand All @@ -78,7 +89,7 @@ define(function CSSAgent(require, exports, module) {
console.assert(style, "Style Sheet for document not loaded: " + doc.url);
Inspector.CSS.setStyleSheetText(style.styleSheetId, doc.getText());
}

/** Empties a CSS style sheet given a document that has been deleted
* @param {Document} document
*/
Expand All @@ -91,13 +102,13 @@ define(function CSSAgent(require, exports, module) {
/** Initialize the agent */
function load() {
_load = new $.Deferred();
Inspector.on("Page.loadEventFired", _onLoadEventFired);
$(Inspector.Page).on("loadEventFired.CSSAgent", _onLoadEventFired);
return _load.promise();
}

/** Clean up */
function unload() {
Inspector.off("Page.loadEventFired", _onLoadEventFired);
$(Inspector.Page).off(".CSSAgent");
}

// Export public functions
Expand Down
19 changes: 9 additions & 10 deletions src/LiveDevelopment/Agents/ConsoleAgent.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, forin: true, maxerr: 50, regexp: true */
/*global define */
/*global define, $ */

/**
* ConsoleAgent forwards all console message from the remote console to the
Expand Down Expand Up @@ -53,38 +53,37 @@ define(function ConsoleAgent(require, exports, module) {
}

// WebInspector Event: Console.messageAdded
function _onMessageAdded(res) {
function _onMessageAdded(event, res) {
// res = {message}
_lastMessage = res.message;
_log(_lastMessage);
}

// WebInspector Event: Console.messageRepeatCountUpdated
function _onMessageRepeatCountUpdated(res) {
function _onMessageRepeatCountUpdated(event, res) {
// res = {count}
if (_lastMessage) {
_log(_lastMessage);
}
}

// WebInspector Event: Console.messagesCleared
function _onMessagesCleared(res) {
function _onMessagesCleared(event, res) {
// res = {}
}

/** Initialize the agent */
function load() {
Inspector.Console.enable();
Inspector.on("Console.messageAdded", _onMessageAdded);
Inspector.on("Console.messageRepeatCountUpdated", _onMessageRepeatCountUpdated);
Inspector.on("Console.messagesCleared", _onMessagesCleared);
$(Inspector.Console)
.on("messageAdded.ConsoleAgent", _onMessageAdded)
.on("messageRepeatCountUpdated.ConsoleAgent", _onMessageRepeatCountUpdated)
.on("messagesCleared.ConsoleAgent", _onMessagesCleared);
}

/** Clean up */
function unload() {
Inspector.off("Console.messageAdded", _onMessageAdded);
Inspector.off("Console.messageRepeatCountUpdated", _onMessageRepeatCountUpdated);
Inspector.off("Console.messagesCleared", _onMessagesCleared);
$(Inspector.Console).off(".ConsoleAgent");
}

// Export public functions
Expand Down
45 changes: 22 additions & 23 deletions src/LiveDevelopment/Agents/DOMAgent.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@
* the source document (replace [from,to] with text) call
* `applyChange(from, to, text)`.
*
* The DOMAgent triggers `DOMAgent.getDocument` on Inspector once it has loaded
* The DOMAgent triggers `getDocument` once it has loaded
* the document.
*/
define(function DOMAgent(require, exports, module) {
"use strict";

var $exports = $(exports);

var Inspector = require("LiveDevelopment/Inspector/Inspector");
var RemoteAgent = require("LiveDevelopment/Agents/RemoteAgent");
var DOMNode = require("LiveDevelopment/Agents/DOMNode");
Expand Down Expand Up @@ -186,10 +188,10 @@ define(function DOMAgent(require, exports, module) {
}

// WebInspector Event: Page.loadEventFired
function _onLoadEventFired(res) {
function _onLoadEventFired(event, res) {
// res = {timestamp}
Inspector.DOM.getDocument(function onGetDocument(res) {
Inspector.trigger("DOMAgent.getDocument", res);
$exports.triggerHandler("getDocument", res);
// res = {root}
_idToNode = {};
_pendingRequests = 0;
Expand All @@ -198,18 +200,18 @@ define(function DOMAgent(require, exports, module) {
}

// WebInspector Event: Page.frameNavigated
function _onFrameNavigated(res) {
function _onFrameNavigated(event, res) {
// res = {frame}
exports.url = _cleanURL(res.frame.url);
}

// WebInspector Event: DOM.documentUpdated
function _onDocumentUpdated(res) {
function _onDocumentUpdated(event, res) {
// res = {}
}

// WebInspector Event: DOM.setChildNodes
function _onSetChildNodes(res) {
function _onSetChildNodes(event, res) {
// res = {parentId, nodes}
var node = nodeWithId(res.parentId);
node.setChildrenPayload(res.nodes);
Expand All @@ -219,15 +221,15 @@ define(function DOMAgent(require, exports, module) {
}

// WebInspector Event: DOM.childNodeCountUpdated
function _onChildNodeCountUpdated(res) {
function _onChildNodeCountUpdated(event, res) {
// res = {nodeId, childNodeCount}
if (res.nodeId > 0) {
Inspector.DOM.requestChildNodes(res.nodeId);
}
}

// WebInspector Event: DOM.childNodeInserted
function _onChildNodeInserted(res) {
function _onChildNodeInserted(event, res) {
// res = {parentNodeId, previousNodeId, node}
if (res.node.nodeId > 0) {
var parent = nodeWithId(res.parentNodeId);
Expand All @@ -238,7 +240,7 @@ define(function DOMAgent(require, exports, module) {
}

// WebInspector Event: DOM.childNodeRemoved
function _onChildNodeRemoved(res) {
function _onChildNodeRemoved(event, res) {
// res = {parentNodeId, nodeId}
if (res.nodeId > 0) {
var node = nodeWithId(res.nodeId);
Expand Down Expand Up @@ -286,27 +288,24 @@ define(function DOMAgent(require, exports, module) {
/** Initialize the agent */
function load() {
_load = new $.Deferred();
Inspector.on("Page.frameNavigated", _onFrameNavigated);
Inspector.on("Page.loadEventFired", _onLoadEventFired);
Inspector.on("DOM.documentUpdated", _onDocumentUpdated);
Inspector.on("DOM.setChildNodes", _onSetChildNodes);
Inspector.on("DOM.childNodeCountUpdated", _onChildNodeCountUpdated);
Inspector.on("DOM.childNodeInserted", _onChildNodeInserted);
Inspector.on("DOM.childNodeRemoved", _onChildNodeRemoved);
$(Inspector.Page)
.on("frameNavigated.DOMAgent", _onFrameNavigated)
.on("loadEventFired.DOMAgent", _onLoadEventFired);
$(Inspector.DOM)
.on("documentUpdated.DOMAgent", _onDocumentUpdated)
.on("setChildNodes.DOMAgent", _onSetChildNodes)
.on("childNodeCountUpdated.DOMAgent", _onChildNodeCountUpdated)
.on("childNodeInserted.DOMAgent", _onChildNodeInserted)
.on("childNodeRemoved.DOMAgent", _onChildNodeRemoved);
Inspector.Page.enable();
Inspector.Page.reload();
return _load.promise();
}

/** Clean up */
function unload() {
Inspector.off("Page.frameNavigated", _onFrameNavigated);
Inspector.off("Page.loadEventFired", _onLoadEventFired);
Inspector.off("DOM.documentUpdated", _onDocumentUpdated);
Inspector.off("DOM.setChildNodes", _onSetChildNodes);
Inspector.off("DOM.childNodeCountUpdated", _onChildNodeCountUpdated);
Inspector.off("DOM.childNodeInserted", _onChildNodeInserted);
Inspector.off("DOM.childNodeRemoved", _onChildNodeRemoved);
$(Inspector.Page).off(".DOMAgent");
$(Inspector.DOM).off(".DOMAgent");
}

// Export private functions
Expand Down
8 changes: 4 additions & 4 deletions src/LiveDevelopment/Agents/EditAgent.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ define(function EditAgent(require, exports, module) {
}

// Remote Event: Go to the given source node
function _onRemoteEdit(res) {
function _onRemoteEdit(event, res) {
// res = {nodeId, name, value}
var node = DOMAgent.nodeWithId(res.nodeId);
node = node.children[0];
Expand All @@ -90,20 +90,20 @@ define(function EditAgent(require, exports, module) {
var from = codeMirror.posFromIndex(node.location + change.from);
var to = codeMirror.posFromIndex(node.location + change.to);
editor.document.replaceRange(change.text, from, to);

var newPos = codeMirror.posFromIndex(node.location + change.from + change.text.length);
editor.setCursorPos(newPos.line, newPos.ch);
}
}

/** Initialize the agent */
function load() {
Inspector.on("RemoteAgent.edit", _onRemoteEdit);
$(RemoteAgent).on("edit.EditAgent", _onRemoteEdit);
}

/** Initialize the agent */
function unload() {
Inspector.off("RemoteAgent.edit", _onRemoteEdit);
$(RemoteAgent).off(".EditAgent");
}

// Export public functions
Expand Down
12 changes: 6 additions & 6 deletions src/LiveDevelopment/Agents/GotoAgent.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ define(function GotoAgent(require, exports, module) {
}

/** Gather options where to go to from the given source node */
function _onRemoteShowGoto(res) {
function _onRemoteShowGoto(event, res) {
// res = {nodeId, name, value}
var node = DOMAgent.nodeWithId(res.nodeId);

Expand Down Expand Up @@ -177,7 +177,7 @@ define(function GotoAgent(require, exports, module) {
}

/** Go to the given source node */
function _onRemoteGoto(res) {
function _onRemoteGoto(event, res) {
// res = {nodeId, name, value}
var location, url = res.value;
var matches = /^(.*):([^:]+)$/.exec(url);
Expand All @@ -195,14 +195,14 @@ define(function GotoAgent(require, exports, module) {

/** Initialize the agent */
function load() {
Inspector.on("RemoteAgent.showgoto", _onRemoteShowGoto);
Inspector.on("RemoteAgent.goto", _onRemoteGoto);
$(RemoteAgent)
.on("showgoto.GotoAgent", _onRemoteShowGoto)
.on("goto.GotoAgent", _onRemoteGoto);
}

/** Initialize the agent */
function unload() {
Inspector.off("RemoteAgent.showgoto", _onRemoteShowGoto);
Inspector.off("RemoteAgent.goto", _onRemoteGoto);
$(RemoteAgent).off(".GotoAgent");
}

// Export public functions
Expand Down
12 changes: 7 additions & 5 deletions src/LiveDevelopment/Agents/HighlightAgent.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@


/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, forin: true, maxerr: 50, regexp: true */
/*global define */
/*global define, $ */

/**
* HighlightAgent dispatches events for highlight requests from in-browser
* highlight requests, and allows highlighting nodes and rules in the browser.
*
* Trigger "highlight" when a node should be highlighted
*/
define(function HighlightAgent(require, exports, module) {
"use strict";
Expand All @@ -39,12 +41,12 @@ define(function HighlightAgent(require, exports, module) {
var _highlight; // active highlight

// Remote Event: Highlight
function _onRemoteHighlight(res) {
function _onRemoteHighlight(event, res) {
var node;
if (res.value === "1") {
node = DOMAgent.nodeWithId(res.nodeId);
}
Inspector.trigger("HighlightAgent.highlight", node);
$(exports).triggerHandler("highlight", node);
}

/** Hide in-browser highlighting */
Expand Down Expand Up @@ -103,12 +105,12 @@ define(function HighlightAgent(require, exports, module) {
/** Initialize the agent */
function load() {
_highlight = {};
Inspector.on("RemoteAgent.highlight", _onRemoteHighlight);
$(RemoteAgent).on("highlight.HighlightAgent", _onRemoteHighlight);
}

/** Clean up */
function unload() {
Inspector.off("RemoteAgent.highlight", _onRemoteHighlight);
$(RemoteAgent).off(".HighlightAgent");
}

// Export public functions
Expand Down
Loading

0 comments on commit 4aeb9be

Please sign in to comment.