Permalink
Browse files

Merge in webkit-server changes.

  • Loading branch information...
1 parent 0792b82 commit 7c75de85149c95e9265b02e5cfbe86456dda879f @tristandunn committed Apr 23, 2012
Showing with 403 additions and 231 deletions.
  1. +2 −2 vendor/webkit-server/src/Body.h
  2. +2 −5 vendor/webkit-server/src/ClearCookies.cpp
  3. +2 −2 vendor/webkit-server/src/ClearCookies.h
  4. +7 −3 vendor/webkit-server/src/Command.cpp
  5. +4 −2 vendor/webkit-server/src/Command.h
  6. +6 −2 vendor/webkit-server/src/CommandFactory.cpp
  7. +1 −1 vendor/webkit-server/src/CommandFactory.h
  8. +13 −5 vendor/webkit-server/src/CommandParser.cpp
  9. +6 −2 vendor/webkit-server/src/CommandParser.h
  10. +18 −47 vendor/webkit-server/src/Connection.cpp
  11. +5 −7 vendor/webkit-server/src/Connection.h
  12. +2 −3 vendor/webkit-server/src/ConsoleMessages.cpp
  13. +2 −2 vendor/webkit-server/src/ConsoleMessages.h
  14. +3 −6 vendor/webkit-server/src/CurrentUrl.cpp
  15. +2 −2 vendor/webkit-server/src/CurrentUrl.h
  16. +3 −3 vendor/webkit-server/src/Evaluate.cpp
  17. +2 −2 vendor/webkit-server/src/Evaluate.h
  18. +4 −4 vendor/webkit-server/src/Execute.cpp
  19. +2 −2 vendor/webkit-server/src/Execute.h
  20. +5 −4 vendor/webkit-server/src/Find.cpp
  21. +2 −2 vendor/webkit-server/src/Find.h
  22. +7 −7 vendor/webkit-server/src/FrameFocus.cpp
  23. +2 −2 vendor/webkit-server/src/FrameFocus.h
  24. +2 −4 vendor/webkit-server/src/GetCookies.cpp
  25. +2 −2 vendor/webkit-server/src/GetCookies.h
  26. +4 −4 vendor/webkit-server/src/Header.cpp
  27. +2 −2 vendor/webkit-server/src/Header.h
  28. +2 −3 vendor/webkit-server/src/Headers.cpp
  29. +2 −2 vendor/webkit-server/src/Headers.h
  30. +4 −0 vendor/webkit-server/src/NetworkAccessManager.cpp
  31. +2 −1 vendor/webkit-server/src/NetworkAccessManager.h
  32. +3 −3 vendor/webkit-server/src/Node.cpp
  33. +2 −2 vendor/webkit-server/src/Node.h
  34. +10 −0 vendor/webkit-server/src/NullCommand.cpp
  35. +11 −0 vendor/webkit-server/src/NullCommand.h
  36. +46 −0 vendor/webkit-server/src/PageLoadingCommand.cpp
  37. +40 −0 vendor/webkit-server/src/PageLoadingCommand.h
  38. +5 −6 vendor/webkit-server/src/Render.cpp
  39. +2 −2 vendor/webkit-server/src/Render.h
  40. +3 −6 vendor/webkit-server/src/RequestedUrl.cpp
  41. +2 −2 vendor/webkit-server/src/RequestedUrl.h
  42. +8 −7 vendor/webkit-server/src/Reset.cpp
  43. +2 −2 vendor/webkit-server/src/Reset.h
  44. +16 −0 vendor/webkit-server/src/ResizeWindow.cpp
  45. +12 −0 vendor/webkit-server/src/ResizeWindow.h
  46. +6 −1 vendor/webkit-server/src/Response.cpp
  47. +4 −2 vendor/webkit-server/src/Response.h
  48. +1 −1 vendor/webkit-server/src/Server.cpp
  49. +3 −5 vendor/webkit-server/src/SetCookie.cpp
  50. +2 −2 vendor/webkit-server/src/SetCookie.h
  51. +7 −9 vendor/webkit-server/src/SetProxy.cpp
  52. +2 −2 vendor/webkit-server/src/SetProxy.h
  53. +2 −4 vendor/webkit-server/src/Source.cpp
  54. +2 −2 vendor/webkit-server/src/Source.h
  55. +2 −3 vendor/webkit-server/src/Status.cpp
  56. +2 −2 vendor/webkit-server/src/Status.h
  57. +3 −6 vendor/webkit-server/src/Url.cpp
  58. +2 −2 vendor/webkit-server/src/Url.h
  59. +4 −13 vendor/webkit-server/src/Visit.cpp
  60. +2 −5 vendor/webkit-server/src/Visit.h
  61. +4 −0 vendor/webkit-server/src/WebPage.cpp
  62. +1 −0 vendor/webkit-server/src/WebPage.h
  63. +2 −3 vendor/webkit-server/src/body.cpp
  64. +2 −1 vendor/webkit-server/src/find_command.h
  65. +60 −3 vendor/webkit-server/src/webkit_server.js
  66. +6 −0 vendor/webkit-server/src/webkit_server.pro
@@ -6,7 +6,7 @@ class Body : public Command {
Q_OBJECT
public:
- Body(WebPage *page, QObject *parent = 0);
- virtual void start(QStringList &arguments);
+ Body(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ virtual void start();
};
@@ -3,13 +3,10 @@
#include "NetworkCookieJar.h"
#include <QNetworkCookie>
-ClearCookies::ClearCookies(WebPage *page, QObject *parent)
- : Command(page, parent)
-{ }
+ClearCookies::ClearCookies(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {}
-void ClearCookies::start(QStringList &arguments)
+void ClearCookies::start()
{
- Q_UNUSED(arguments);
NetworkCookieJar *jar = qobject_cast<NetworkCookieJar*>(page()
->networkAccessManager()
->cookieJar());
@@ -6,6 +6,6 @@ class ClearCookies : public Command {
Q_OBJECT;
public:
- ClearCookies(WebPage *page, QObject *parent = 0);
- virtual void start(QStringList &arguments);
+ ClearCookies(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ virtual void start();
};
@@ -1,15 +1,19 @@
#include "Command.h"
#include "WebPage.h"
-Command::Command(WebPage *page, QObject *parent) : QObject(parent) {
+Command::Command(WebPage *page, QStringList &arguments, QObject *parent) : QObject(parent) {
m_page = page;
+ m_arguments = arguments;
}
-void Command::start(QStringList &arguments) {
- Q_UNUSED(arguments);
+void Command::start() {
}
WebPage *Command::page() {
return m_page;
}
+QStringList &Command::arguments() {
+ return m_arguments;
+}
+
@@ -11,17 +11,19 @@ class Command : public QObject {
Q_OBJECT
public:
- Command(WebPage *page, QObject *parent = 0);
- virtual void start(QStringList &arguments);
+ Command(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ virtual void start();
signals:
void finished(Response *response);
protected:
WebPage *page();
+ QStringList &arguments();
private:
WebPage *m_page;
+ QStringList m_arguments;
};
@@ -1,4 +1,5 @@
#include "CommandFactory.h"
+#include "NullCommand.h"
#include "Visit.h"
#include "Find.h"
#include "Command.h"
@@ -21,12 +22,15 @@
#include "ConsoleMessages.h"
#include "RequestedUrl.h"
#include "CurrentUrl.h"
+#include "ResizeWindow.h"
CommandFactory::CommandFactory(WebPage *page, QObject *parent) : QObject(parent) {
m_page = page;
}
-Command *CommandFactory::createCommand(const char *name) {
+Command *CommandFactory::createCommand(const char *name, QStringList &arguments) {
#include "find_command.h"
- return NULL;
+ arguments.clear();
+ arguments.append(QString(name));
+ return new NullCommand(m_page, arguments);
}
@@ -8,7 +8,7 @@ class CommandFactory : public QObject {
public:
CommandFactory(WebPage *page, QObject *parent = 0);
- Command *createCommand(const char *name);
+ Command *createCommand(const char *name, QStringList &arguments);
private:
WebPage *m_page;
@@ -1,11 +1,14 @@
#include "CommandParser.h"
+#include "CommandFactory.h"
+#include "Command.h"
#include <QIODevice>
-CommandParser::CommandParser(QIODevice *device, QObject *parent) :
+CommandParser::CommandParser(QIODevice *device, CommandFactory *commandFactory, QObject *parent) :
QObject(parent) {
m_device = device;
m_expectingDataSize = -1;
+ m_commandFactory = commandFactory;
connect(m_device, SIGNAL(readyRead()), this, SLOT(checkNext()));
}
@@ -60,9 +63,14 @@ void CommandParser::processArgument(const char *data) {
}
if (m_arguments.length() == m_argumentsExpected) {
- emit commandReady(m_commandName, m_arguments);
- m_commandName = QString();
- m_arguments.clear();
- m_argumentsExpected = -1;
+ Command *command = m_commandFactory->createCommand(m_commandName.toAscii().constData(), m_arguments);
+ emit commandReady(command);
+ reset();
}
}
+
+void CommandParser::reset() {
+ m_commandName = QString();
+ m_arguments.clear();
+ m_argumentsExpected = -1;
+}
@@ -2,28 +2,32 @@
#include <QStringList>
class QIODevice;
+class CommandFactory;
+class Command;
class CommandParser : public QObject {
Q_OBJECT
public:
- CommandParser(QIODevice *device, QObject *parent = 0);
+ CommandParser(QIODevice *device, CommandFactory *commandFactory, QObject *parent = 0);
public slots:
void checkNext();
signals:
- void commandReady(QString commandName, QStringList arguments);
+ void commandReady(Command *command);
private:
void readLine();
void readDataBlock();
void processNext(const char *line);
void processArgument(const char *data);
+ void reset();
QIODevice *m_device;
QString m_commandName;
QStringList m_arguments;
int m_argumentsExpected;
int m_expectingDataSize;
+ CommandFactory *m_commandFactory;
};
@@ -1,34 +1,27 @@
#include "Connection.h"
#include "WebPage.h"
-#include "UnsupportedContentHandler.h"
#include "CommandParser.h"
#include "CommandFactory.h"
+#include "PageLoadingCommand.h"
#include "Command.h"
#include <QTcpSocket>
-#include <iostream>
Connection::Connection(QTcpSocket *socket, WebPage *page, QObject *parent) :
QObject(parent) {
m_socket = socket;
m_page = page;
- m_commandParser = new CommandParser(socket, this);
m_commandFactory = new CommandFactory(page, this);
- m_command = NULL;
+ m_commandParser = new CommandParser(socket, m_commandFactory, this);
m_pageSuccess = true;
m_commandWaiting = false;
- m_pageLoadingFromCommand = false;
- m_pendingResponse = NULL;
connect(m_socket, SIGNAL(readyRead()), m_commandParser, SLOT(checkNext()));
- connect(m_commandParser, SIGNAL(commandReady(QString, QStringList)), this, SLOT(commandReady(QString, QStringList)));
+ connect(m_commandParser, SIGNAL(commandReady(Command *)), this, SLOT(commandReady(Command *)));
connect(m_page, SIGNAL(pageFinished(bool)), this, SLOT(pendingLoadFinished(bool)));
}
-
-void Connection::commandReady(QString commandName, QStringList arguments) {
- m_commandName = commandName;
- m_arguments = arguments;
-
+void Connection::commandReady(Command *command) {
+ m_queuedCommand = command;
if (m_page->isLoading())
m_commandWaiting = true;
else
@@ -38,51 +31,29 @@ void Connection::commandReady(QString commandName, QStringList arguments) {
void Connection::startCommand() {
m_commandWaiting = false;
if (m_pageSuccess) {
- m_command = m_commandFactory->createCommand(m_commandName.toAscii().constData());
- if (m_command) {
- connect(m_page, SIGNAL(loadStarted()), this, SLOT(pageLoadingFromCommand()));
- connect(m_command,
- SIGNAL(finished(Response *)),
- this,
- SLOT(finishCommand(Response *)));
- m_command->start(m_arguments);
- } else {
- QString failure = QString("[WebKitServer] Unknown command: ") + m_commandName + "\n";
- writeResponse(new Response(false, failure));
- }
- m_commandName = QString();
+ m_runningCommand = new PageLoadingCommand(m_queuedCommand, m_page, this);
+ connect(m_runningCommand, SIGNAL(finished(Response *)), this, SLOT(finishCommand(Response *)));
+ m_runningCommand->start();
} else {
- m_pageSuccess = true;
- QString message = m_page->failureString();
- writeResponse(new Response(false, message));
+ writePageLoadFailure();
}
}
-void Connection::pageLoadingFromCommand() {
- m_pageLoadingFromCommand = true;
-}
-
void Connection::pendingLoadFinished(bool success) {
m_pageSuccess = success;
if (m_commandWaiting)
startCommand();
- if (m_pageLoadingFromCommand) {
- m_pageLoadingFromCommand = false;
- if (m_pendingResponse) {
- writeResponse(m_pendingResponse);
- m_pendingResponse = NULL;
- }
- }
+}
+
+void Connection::writePageLoadFailure() {
+ m_pageSuccess = true;
+ QString message = m_page->failureString();
+ writeResponse(new Response(false, message));
}
void Connection::finishCommand(Response *response) {
- disconnect(m_page, SIGNAL(loadStarted()), this, SLOT(pageLoadingFromCommand()));
- m_command->deleteLater();
- m_command = NULL;
- if (m_pageLoadingFromCommand)
- m_pendingResponse = response;
- else
- writeResponse(response);
+ m_runningCommand->deleteLater();
+ writeResponse(response);
}
void Connection::writeResponse(Response *response) {
@@ -91,7 +62,7 @@ void Connection::writeResponse(Response *response) {
else
m_socket->write("failure\n");
- QByteArray messageUtf8 = response->message().toUtf8();
+ QByteArray messageUtf8 = response->message();
QString messageLength = QString::number(messageUtf8.size()) + "\n";
m_socket->write(messageLength.toAscii());
m_socket->write(messageUtf8);
@@ -7,6 +7,7 @@ class Command;
class Response;
class CommandParser;
class CommandFactory;
+class PageLoadingCommand;
class Connection : public QObject {
Q_OBJECT
@@ -15,25 +16,22 @@ class Connection : public QObject {
Connection(QTcpSocket *socket, WebPage *page, QObject *parent = 0);
public slots:
- void commandReady(QString commandName, QStringList arguments);
+ void commandReady(Command *command);
void finishCommand(Response *response);
void pendingLoadFinished(bool success);
- void pageLoadingFromCommand();
private:
void startCommand();
void writeResponse(Response *response);
+ void writePageLoadFailure();
QTcpSocket *m_socket;
- QString m_commandName;
- Command *m_command;
- QStringList m_arguments;
+ Command *m_queuedCommand;
WebPage *m_page;
CommandParser *m_commandParser;
CommandFactory *m_commandFactory;
+ PageLoadingCommand *m_runningCommand;
bool m_pageSuccess;
bool m_commandWaiting;
- bool m_pageLoadingFromCommand;
- Response *m_pendingResponse;
};
@@ -1,11 +1,10 @@
#include "ConsoleMessages.h"
#include "WebPage.h"
-ConsoleMessages::ConsoleMessages(WebPage *page, QObject *parent) : Command(page, parent) {
+ConsoleMessages::ConsoleMessages(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
}
-void ConsoleMessages::start(QStringList &arguments) {
- Q_UNUSED(arguments);
+void ConsoleMessages::start() {
emit finished(new Response(true, page()->consoleMessages()));
}
@@ -6,7 +6,7 @@ class ConsoleMessages : public Command {
Q_OBJECT
public:
- ConsoleMessages(WebPage *page, QObject *parent = 0);
- virtual void start(QStringList &arguments);
+ ConsoleMessages(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ virtual void start();
};
@@ -1,7 +1,7 @@
#include "CurrentUrl.h"
#include "WebPage.h"
-CurrentUrl::CurrentUrl(WebPage *page, QObject *parent) : Command(page, parent) {
+CurrentUrl::CurrentUrl(WebPage *page, QStringList &arguments, QObject *parent) : Command(page, arguments, parent) {
}
/*
@@ -51,14 +51,11 @@ CurrentUrl::CurrentUrl(WebPage *page, QObject *parent) : Command(page, parent) {
* redirect w/o pushState, in which case QWebFrame->url() will have the correct
* current_url value. In all other cases QWebFrame->requestedUrl() is correct.
*/
-void CurrentUrl::start(QStringList &arguments) {
- Q_UNUSED(arguments);
-
+void CurrentUrl::start() {
QUrl humanUrl = wasRedirectedAndNotModifiedByJavascript() ?
page()->currentFrame()->url() : page()->currentFrame()->requestedUrl();
QByteArray encodedBytes = humanUrl.toEncoded();
- QString urlString = QString(encodedBytes);
- emit finished(new Response(true, urlString));
+ emit finished(new Response(true, encodedBytes));
}
bool CurrentUrl::wasRegularLoad() {
@@ -6,8 +6,8 @@ class CurrentUrl : public Command {
Q_OBJECT
public:
- CurrentUrl(WebPage *page, QObject *parent = 0);
- virtual void start(QStringList &arguments);
+ CurrentUrl(WebPage *page, QStringList &arguments, QObject *parent = 0);
+ virtual void start();
private:
bool wasRegularLoad();
Oops, something went wrong.

0 comments on commit 7c75de8

Please sign in to comment.