Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Implimented Inline style editing, and setting the envirement varaible
Browse files Browse the repository at this point in the history
 AdapterLogging 1 will cause debugging infomation to be dumped in the adapter
  • Loading branch information
alexcope committed Jul 23, 2015
1 parent dce12fb commit d0ffff9
Show file tree
Hide file tree
Showing 4 changed files with 174 additions and 102 deletions.
22 changes: 17 additions & 5 deletions IEDiagnosticsAdapter/WebSocketHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,17 @@ m_port(9222)
m_server.listen("0.0.0.0", port.str());
m_server.start_accept();

cout << "Proxy server listening on port " << port.str() << "..." << endl;
CString AdaptorLogging_EnvironmentVariable;
DWORD ret = AdaptorLogging_EnvironmentVariable.GetEnvironmentVariable(L"AdapterLogging");
if (ret > 0 && AdaptorLogging_EnvironmentVariable == L"1") {
std::cout << "Logging enabled" << endl;
m_AdaptorLogging_EnvironmentVariable = "1";
}
else {
m_AdaptorLogging_EnvironmentVariable = "";
}

std::cout << "Proxy server listening on port " << port.str() << "..." << endl;
}

// WebSocket Callbacks
Expand Down Expand Up @@ -207,8 +217,9 @@ void WebSocketHandler::OnMessage(websocketpp::connection_hdl hdl, server::messag
{
if (m_clientConnections.find(hdl) != m_clientConnections.end())
{
// uncomment this to dump logging info to the adaptor
//std::cout << msg->get_payload().c_str() << "\n";
if(m_AdaptorLogging_EnvironmentVariable == "1") {
std::cout << msg->get_payload().c_str() << "\n";
}

// Message from WebKit client to IE
CString message(msg->get_payload().c_str());
Expand Down Expand Up @@ -347,8 +358,9 @@ void WebSocketHandler::RunServer() {

void WebSocketHandler::OnMessageFromIE(string message, HWND proxyHwnd)
{
// uncomment this to dump logging info to the adaptor
//std::cout << message << "\n";
if (m_AdaptorLogging_EnvironmentVariable == "1") {
std::cout << message << "\n";
}

// post this message to our IO queue so the server thread will pick it up and handle it synchronously
this->m_server.get_io_service().post(boost::bind(&WebSocketHandler::OnMessageFromIEHandler, this, message, proxyHwnd));
Expand Down
1 change: 1 addition & 0 deletions IEDiagnosticsAdapter/WebSocketHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,5 @@ class WebSocketHandler
map<HWND, IEInstance> m_instances;
map<websocketpp::connection_hdl, HWND, owner_less<websocketpp::connection_hdl>> m_clientConnections;
map<HWND, websocketpp::connection_hdl> m_proxyConnections;
string m_AdaptorLogging_EnvironmentVariable;
};
35 changes: 26 additions & 9 deletions IEWebKitImpl/CSSParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ module Proxy {
constructor(text: string) {
this._rootNodes = [];
this._text = text;
}

/** Returns an array containing ICssRuleset and ICssMediaQuery objects */
public parseCss(): any[] {
// Statement control
this._inComment = false;
this._currentQuotationMark = "";
Expand All @@ -56,7 +53,32 @@ module Proxy {
this._currentRuleset = null;
this._currentDeclaration = null;
this._currentMediaQuery = null;
}

/** Returns an array containing ICssRuleset and ICssMediaQuery objects */
public parseCss(): any[] {
this.parseText();

// Put any text that wasn't valid CSS into it's own node at the end of the file
this.handleIncompleteBlocks();
return this._rootNodes;
}

/** Returns an array containing a single rule, ICssRuleset and ICssMediaQuery objects */
public parseInlineCss(): ICssRuleset {
// inline CSS is just a list of properties. Set up the parser state to read them correctly.
this._currentRuleset = { originalOffset: this._lastCheckpoint, selector: "DoesNotMatter", declarations: [] };
this._state = CssToken.Property;

this.parseText();

Assert.isTrue(this._currentRuleset && this._rootNodes.length === 0, "Text was not valid inline CSS");
this._currentRuleset.endOffset = this._text.length;

return this._currentRuleset;
}

private parseText(): void {
for (this._index = 0; this._index < this._text.length; this._index++) {
if (this.handleQuoteCharacter()) {
} else if (this.handleCommentCharacter()) {
Expand All @@ -70,11 +92,6 @@ module Proxy {
} else if (this.handleSelectorCloseBracket()) {
}
}

// Put any text that wasn't valid CSS into it's own node at the end of the file
this.handleIncompleteBlocks();

return this._rootNodes;
}

private handleMediaQueryStart(): boolean {
Expand Down Expand Up @@ -218,7 +235,7 @@ module Proxy {
}

if (this._lastCheckpoint < this._text.length - 1) {
var textNode: ICssRuleset = { selector: this._text.substr(this._lastCheckpoint), originalOffset: this._lastCheckpoint, declarations: null, endOffset: this._index + 1};
var textNode: ICssRuleset = { selector: this._text.substr(this._lastCheckpoint), originalOffset: this._lastCheckpoint, declarations: null, endOffset: this._index + 1 };
this._rootNodes.push(textNode);
}
}
Expand Down
Loading

0 comments on commit d0ffff9

Please sign in to comment.