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

Commit d0ffff9

Browse files
committed
Implimented Inline style editing, and setting the envirement varaible
AdapterLogging 1 will cause debugging infomation to be dumped in the adapter
1 parent dce12fb commit d0ffff9

File tree

4 files changed

+174
-102
lines changed

4 files changed

+174
-102
lines changed

IEDiagnosticsAdapter/WebSocketHandler.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,17 @@ m_port(9222)
3333
m_server.listen("0.0.0.0", port.str());
3434
m_server.start_accept();
3535

36-
cout << "Proxy server listening on port " << port.str() << "..." << endl;
36+
CString AdaptorLogging_EnvironmentVariable;
37+
DWORD ret = AdaptorLogging_EnvironmentVariable.GetEnvironmentVariable(L"AdapterLogging");
38+
if (ret > 0 && AdaptorLogging_EnvironmentVariable == L"1") {
39+
std::cout << "Logging enabled" << endl;
40+
m_AdaptorLogging_EnvironmentVariable = "1";
41+
}
42+
else {
43+
m_AdaptorLogging_EnvironmentVariable = "";
44+
}
45+
46+
std::cout << "Proxy server listening on port " << port.str() << "..." << endl;
3747
}
3848

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

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

348359
void WebSocketHandler::OnMessageFromIE(string message, HWND proxyHwnd)
349360
{
350-
// uncomment this to dump logging info to the adaptor
351-
//std::cout << message << "\n";
361+
if (m_AdaptorLogging_EnvironmentVariable == "1") {
362+
std::cout << message << "\n";
363+
}
352364

353365
// post this message to our IO queue so the server thread will pick it up and handle it synchronously
354366
this->m_server.get_io_service().post(boost::bind(&WebSocketHandler::OnMessageFromIEHandler, this, message, proxyHwnd));

IEDiagnosticsAdapter/WebSocketHandler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,5 @@ class WebSocketHandler
8484
map<HWND, IEInstance> m_instances;
8585
map<websocketpp::connection_hdl, HWND, owner_less<websocketpp::connection_hdl>> m_clientConnections;
8686
map<HWND, websocketpp::connection_hdl> m_proxyConnections;
87+
string m_AdaptorLogging_EnvironmentVariable;
8788
};

IEWebKitImpl/CSSParser.ts

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@ module Proxy {
3939
constructor(text: string) {
4040
this._rootNodes = [];
4141
this._text = text;
42-
}
4342

44-
/** Returns an array containing ICssRuleset and ICssMediaQuery objects */
45-
public parseCss(): any[] {
4643
// Statement control
4744
this._inComment = false;
4845
this._currentQuotationMark = "";
@@ -56,7 +53,32 @@ module Proxy {
5653
this._currentRuleset = null;
5754
this._currentDeclaration = null;
5855
this._currentMediaQuery = null;
56+
}
57+
58+
/** Returns an array containing ICssRuleset and ICssMediaQuery objects */
59+
public parseCss(): any[] {
60+
this.parseText();
61+
62+
// Put any text that wasn't valid CSS into it's own node at the end of the file
63+
this.handleIncompleteBlocks();
64+
return this._rootNodes;
65+
}
66+
67+
/** Returns an array containing a single rule, ICssRuleset and ICssMediaQuery objects */
68+
public parseInlineCss(): ICssRuleset {
69+
// inline CSS is just a list of properties. Set up the parser state to read them correctly.
70+
this._currentRuleset = { originalOffset: this._lastCheckpoint, selector: "DoesNotMatter", declarations: [] };
71+
this._state = CssToken.Property;
72+
73+
this.parseText();
74+
75+
Assert.isTrue(this._currentRuleset && this._rootNodes.length === 0, "Text was not valid inline CSS");
76+
this._currentRuleset.endOffset = this._text.length;
77+
78+
return this._currentRuleset;
79+
}
5980

81+
private parseText(): void {
6082
for (this._index = 0; this._index < this._text.length; this._index++) {
6183
if (this.handleQuoteCharacter()) {
6284
} else if (this.handleCommentCharacter()) {
@@ -70,11 +92,6 @@ module Proxy {
7092
} else if (this.handleSelectorCloseBracket()) {
7193
}
7294
}
73-
74-
// Put any text that wasn't valid CSS into it's own node at the end of the file
75-
this.handleIncompleteBlocks();
76-
77-
return this._rootNodes;
7895
}
7996

8097
private handleMediaQueryStart(): boolean {
@@ -218,7 +235,7 @@ module Proxy {
218235
}
219236

220237
if (this._lastCheckpoint < this._text.length - 1) {
221-
var textNode: ICssRuleset = { selector: this._text.substr(this._lastCheckpoint), originalOffset: this._lastCheckpoint, declarations: null, endOffset: this._index + 1};
238+
var textNode: ICssRuleset = { selector: this._text.substr(this._lastCheckpoint), originalOffset: this._lastCheckpoint, declarations: null, endOffset: this._index + 1 };
222239
this._rootNodes.push(textNode);
223240
}
224241
}

0 commit comments

Comments
 (0)