Browse Source

project reorg and cleanup

master
Odilitime 2 years ago
parent
commit
bfcdda5c04
60 changed files with 309 additions and 166114 deletions
  1. 5
    5
      Makefile
  2. 0
    165800
      anime.h
  3. 40
    40
      src/app/App.cpp
  4. 3
    3
      src/app/App.h
  5. 7
    7
      src/app/browser/Browser.cpp
  6. 3
    3
      src/app/browser/Browser.h
  7. 1
    1
      src/environment/Environment.cpp
  8. 36
    36
      src/interfaces/components/DocumentComponent.cpp
  9. 3
    3
      src/interfaces/components/DocumentComponent.h
  10. 48
    50
      src/interfaces/components/InputComponent.cpp
  11. 2
    2
      src/interfaces/components/InputComponent.h
  12. 15
    15
      src/interfaces/components/MultiComponent.cpp
  13. 5
    5
      src/interfaces/components/TabbedComponent.h
  14. 1
    1
      src/interfaces/elements/AElement.cpp
  15. 7
    7
      src/interfaces/elements/BUTTONElement.cpp
  16. 7
    7
      src/interfaces/elements/INPUTElement.cpp
  17. 3
    3
      src/interfaces/elements/SCRIPTElement.cpp
  18. 2
    2
      src/interfaces/elements/TEXTAREAElement.cpp
  19. 0
    0
      src/interfaces/graphical/renderers/TextWindow.cpp
  20. 0
    0
      src/interfaces/graphical/renderers/TextWindow.h
  21. 1
    1
      src/interfaces/graphical/renderers/glfw/ShaderLoader.cpp
  22. 11
    13
      src/interfaces/graphical/renderers/glfw/Window.cpp
  23. 9
    9
      src/interfaces/graphical/renderers/glfw/Window.h
  24. 42
    42
      src/interfaces/graphical/renderers/glfw/opengl.cpp
  25. 25
    26
      src/main.cpp
  26. 1
    1
      src/networking/HTTPRequest.h
  27. 1
    1
      src/networking/HTTPSRequest.h
  28. 1
    1
      src/parsers/images/netpbm/pnm.h
  29. 2
    2
      src/parsers/images/tga/tga.h
  30. 9
    9
      src/parsers/scripting/javascript/JSParser.cpp
  31. 0
    0
      src/platform/Murmur3.cpp
  32. 0
    0
      src/platform/Murmur3.h
  33. 0
    0
      src/platform/netrunner.h
  34. 0
    0
      src/platform/slre.c
  35. 0
    0
      src/platform/slre.h
  36. 0
    0
      src/platform/target.h
  37. 0
    0
      src/platform/tlsf-winnt.h
  38. 0
    0
      src/platform/tlsf.c
  39. 0
    0
      src/platform/tlsf.h
  40. 0
    0
      src/tools/BrowsingHistory.cpp
  41. 0
    0
      src/tools/BrowsingHistory.h
  42. 2
    2
      src/tools/CFGFileParser.cpp
  43. 2
    2
      src/tools/CFGFileParser.h
  44. 0
    0
      src/tools/CommandLineParams.cpp
  45. 0
    0
      src/tools/CommandLineParams.h
  46. 0
    0
      src/tools/FormData.cpp
  47. 1
    1
      src/tools/FormData.h
  48. 0
    0
      src/tools/LRUCache.h
  49. 0
    0
      src/tools/Log.cpp
  50. 0
    0
      src/tools/Log.h
  51. 1
    1
      src/tools/Scheduler.cpp
  52. 0
    0
      src/tools/Scheduler.h
  53. 0
    0
      src/tools/StringUtils.cpp
  54. 0
    0
      src/tools/StringUtils.h
  55. 0
    0
      src/tools/TextBlock.cpp
  56. 0
    0
      src/tools/TextBlock.h
  57. 0
    0
      src/tools/URL.cpp
  58. 0
    0
      src/tools/URL.h
  59. 12
    12
      src/tools/WebResource.cpp
  60. 1
    1
      src/tools/WebResource.h

+ 5
- 5
Makefile View File

@@ -48,7 +48,7 @@ RES = res/

all: $(SOURCES) netrunner

netrunner: $(OBJECTS) $(OBJDIR)/tlsf.o $(OBJDIR)/slre.o
netrunner: $(OBJECTS) $(OBJDIR)/platform/tlsf.o $(OBJDIR)/platform/slre.o
$(LINK) $(LDFLAGS) -o $@ $^ $(LIBS)

$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
@@ -57,10 +57,10 @@ $(OBJDIR)/%.o: $(SRCDIR)/%.cpp
$(CXX) -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td $(CXXFLAGS) $(INCPATH) $(WARNINGS) -c -o $@ $<
@mv -f $(DEPDIR)/$*.Td $(DEPDIR)/$*.d && touch $@

$(OBJDIR)/tlsf.o: $(SRCDIR)/tlsf.c
$(OBJDIR)/platform/tlsf.o: $(SRCDIR)/platform/tlsf.c
$(CC) $(INCPATH) $(CWARN) -DTLSF_USE_LOCKS=0 -DUSE_MMAP=1 -DUSE_SBRK=1 -c -o $@ $<

$(OBJDIR)/slre.o: $(SRCDIR)/slre.c
$(OBJDIR)/platform/slre.o: $(SRCDIR)/platform/slre.c
$(CC) $(INCPATH) $(CWARN) -c -o $@ $<

$(DEPDIR)/%d: ;
@@ -69,10 +69,10 @@ $(DEPDIR)/%d: ;
test-url.o: tests/testPrograms/URLtest.cpp
$(CXX) -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td $(CXXFLAGS) $(INCPATH) $(WARINGS) -c -o $@ $<

ntr-run-tests: test-url.o $(OBJDIR)/URL.o $(OBJDIR)/StringUtils.o
ntr-run-tests: test-url.o $(OBJDIR)/tools/URL.o $(OBJDIR)/tools/StringUtils.o
$(LINK) $(LDFLAGS) -o $@ test-url.o $(OBJDIR)/URL.o $(OBJDIR)/StringUtils.o $(LIBS)

ntr-test-cfg: test-cfg.o $(OBJDIR)/CFGFileParser.o $(OBJDIR)/slre.o $(OBJDIR)/tlsf.o $(OBJDIR)/Murmur3.o
ntr-test-cfg: test-cfg.o $(OBJDIR)/tools/CFGFileParser.o $(OBJDIR)/platform/slre.o $(OBJDIR)/platform/tlsf.o $(OBJDIR)/platform/Murmur3.o
$(LINK) $(LDFLAGS) -o $@ $^ $(LIBS)

test-cfg.o: tests/TestCFG.cpp

+ 0
- 165800
anime.h
File diff suppressed because it is too large
View File


src/app.cpp → src/app/App.cpp View File

@@ -1,15 +1,15 @@
#include "app.h"
#include "scheduler.h"
#include "interfaces/components/TabbedComponent.h"
#include "parsers/markup/ntrml/NTRMLParser.h"
#include "parsers/markup/html/HTMLParser.h"
#include "App.h"
#include "../tools/Scheduler.h"
#include "../interfaces/components/TabbedComponent.h"
#include "../parsers/markup/ntrml/NTRMLParser.h"
#include "../parsers/markup/html/HTMLParser.h"

#include "interfaces/components/DocumentComponent.h"
#include "../interfaces/components/DocumentComponent.h"
//#include "interfaces/components/ComponentBuilder.h"
#include "interfaces/components/InputComponent.h"
#include "interfaces/components/ImageComponent.h"
#include "interfaces/components/TabbedComponent.h"
#include "interfaces/components/ButtonComponent.h"
#include "../interfaces/components/InputComponent.h"
#include "../interfaces/components/ImageComponent.h"
#include "../interfaces/components/TabbedComponent.h"
#include "../interfaces/components/ButtonComponent.h"

#include <fstream>
#include <glob.h>
@@ -62,18 +62,18 @@ void doOnClick(std::string type, Component *component, Window *win) {
return;
}
//std::cout << "Browser:zdoOnClick.navAddressBar->onClick - got " << value << std::endl;
TabbedComponent *p_tabComponent = dynamic_cast<TabbedComponent*>(win->tabComponent.get());
if (p_tabComponent) {
if (!p_tabComponent->tabs.size()) {
p_tabComponent->addTab("Loading...");
p_tabComponent->selectTab(p_tabComponent->tabs.back());
win->renderDirty = true;
win->render(); // display loading tab before IO
}
}
std::shared_ptr<DocumentComponent> docComponent = win->getActiveDocumentComponent();
if (docComponent) {
//std::cout << "Browser:zdoOnClick.navAddressBar->onClick - Found an active document component" << std::endl;
@@ -137,7 +137,7 @@ void App::rebuildTheme() {
this->layers.clear(); // nuke any layers we have
this->createComponentTree(this->uiRootNode, rootComponent, win);
//Component::printComponentTree(rootComponent, 0);
// these probably should be fatal
if (!win->addressComponent) {
std::cout << "ERROR: no addressComponent" << std::endl;
@@ -145,7 +145,7 @@ void App::rebuildTheme() {
if (!win->tabComponent) {
std::cout << "ERROR: no tabComponent" << std::endl;
}
// we want each window to has it's own component tree, so each address bar can have different values
size_t layerCount = 0;
for(auto layer: this->layers) {
@@ -162,11 +162,11 @@ void App::rebuildTheme() {
layer.reset(); // deallocate our local layers
}
rootComponent.reset();
//newWindow->rootComponent = rootComponent;
//newWindow->ui->rootComponent = rootComponent;
win->renderDirty = true;
}
}

@@ -177,14 +177,14 @@ void App::transferTheme(std::string filename) {

for(auto win: this->windows) {
glfwMakeContextCurrent(win->window);
TabbedComponent *oldTabbedComponent = nullptr;
if (win->tabComponent) {
oldTabbedComponent = dynamic_cast<TabbedComponent *>(win->tabComponent.get());
}
win->tabComponent = nullptr; // release to release
win->addressComponent = nullptr; // I think this is ok to release now
// convert uiRootNode into a component list
std::shared_ptr<Component> rootComponent = std::make_shared<Component>();
rootComponent->name = "rootComponent of browser";
@@ -192,7 +192,7 @@ void App::transferTheme(std::string filename) {
// we build one global tree that each layer has a child node in
this->createComponentTree(this->uiRootNode, rootComponent, win);
//Component::printComponentTree(rootComponent, 0);
// these probably should be fatal
if (!win->addressComponent) {
std::cout << "ERROR: no addressComponent" << std::endl;
@@ -200,7 +200,7 @@ void App::transferTheme(std::string filename) {
if (!win->tabComponent) {
std::cout << "ERROR: no tabComponent" << std::endl;
}
// ok now we need to transfer the tabs over
if (oldTabbedComponent) {
// should have been set in createComponentTree
@@ -214,7 +214,7 @@ void App::transferTheme(std::string filename) {
if (oldDocComponent) {
//std::cout << "Reading DOM" << std::endl;
//printNode(oldDocComponent->domRootNode, 0);
std::shared_ptr<Tab> nTab = newTabbedComponent->addTab(tab->titleBox->text);
newTabbedComponent->selectTab(nTab);
// maybe faster if we can skip the component tree rebuild
@@ -275,13 +275,13 @@ void App::transferTheme(std::string filename) {
} else {
std::cout << "old theme didnt have tab component" << std::endl;
}
// now we're officially done with old layer, nuked them
for(auto layer: win->ui->layers) {
layer.reset();
}
win->ui->layers.clear();
// we want each window to has it's own component tree, so each address bar can have different values
size_t layerCount = 0;
for(auto layer: this->layers) {
@@ -298,7 +298,7 @@ void App::transferTheme(std::string filename) {
layer.reset(); // deallocate our local layers
}
rootComponent.reset();
//newWindow->rootComponent = rootComponent;
//newWindow->ui->rootComponent = rootComponent;
win->renderDirty = true;
@@ -383,7 +383,7 @@ void App::createComponentTree(const std::shared_ptr<Node> node, std::shared_ptr<
ss << std::hex << tagNode->properties["bgcolor"];
ss >> win->clearColor;
//std::cout << "set clear color " << std::hex << win->clearColor << std::dec << std::endl;
float r = (static_cast<float>((win->clearColor >> 24) & 0xFF)) / 255;
float g = (static_cast<float>((win->clearColor >> 16) & 0xFF)) / 255;
float b = (static_cast<float>((win->clearColor >> 8) & 0xFF)) / 255;
@@ -443,7 +443,7 @@ void App::createComponentTree(const std::shared_ptr<Node> node, std::shared_ptr<
ss >> color;
//std::cout << "read color " << tagNode->properties["color"] << " as " << std::hex << color << std::dec << std::endl;
}
// winHeight minus because box coordinates? yes
//std::cout << "placing box at " << cX << "," << cY << " " << cW << "x" << cH << " color: " << std::hex << color << std::dec << std::endl;
//std::shared_ptr<BoxComponent> box = std::make_unique<BoxComponent>(cX, winHeight - cH - cY, cW, cH, color, winWidth, winHeight);
@@ -515,18 +515,18 @@ void App::createComponentTree(const std::shared_ptr<Node> node, std::shared_ptr<

navAddressBar->onEnter=[win](std::string value) {
std::cout << "navAddressBar::onEnter got " << value << std::endl;
TabbedComponent *p_tabComponent = dynamic_cast<TabbedComponent*>(win->tabComponent.get());
if (p_tabComponent) {
if (!p_tabComponent->tabs.size()) {
p_tabComponent->addTab("Loading...");
p_tabComponent->selectTab(p_tabComponent->tabs.back());
win->renderDirty = true;
win->render(); // display loading tab before IO
}
}
std::shared_ptr<DocumentComponent> docComponent = win->getActiveDocumentComponent();
if (docComponent) {
std::cout << "Found an active document component" << std::endl;
@@ -536,7 +536,7 @@ void App::createComponentTree(const std::shared_ptr<Node> node, std::shared_ptr<
std::cout << "No active document component" << std::endl;
}
};
navAddressBar->win = win;
win->addressComponent = navAddressBar;
component = navAddressBar;
@@ -585,12 +585,12 @@ void App::addJSDebuggerWindow() {
newWindow->init(); // load our UI into it
std::shared_ptr<Component> p_rootComponent = std::make_shared<Component>();
p_rootComponent->name = "rootComponent of jsconsole";
std::shared_ptr<TextComponent> outputComp = std::make_shared<TextComponent>("NeTRunner JavaScript console", 0, 0, 12, false, 0x000000FF, newWindow->windowWidth, newWindow->windowHeight);
outputComp->win = newWindow;
newWindow->ui->layers.push_back(outputComp);
outputComp.reset();
/*
std::shared_ptr<InputComponent> inputComp = std::make_shared<InputComponent>(0, 0, 1024, 12, newWindow->windowWidth, newWindow->windowHeight);
inputComp->win = newWindow;
@@ -609,15 +609,15 @@ void App::addWindow() {
newWindow->windowWidth = 1024;
newWindow->windowHeight = 640;
newWindow->init(); // load our UI into it
// convert uiRootNode into a component list
std::shared_ptr<Component> p_rootComponent = std::make_shared<Component>();
p_rootComponent->name = "rootComponent of browser";
// we build one global tree that each layer has a child node in
this->createComponentTree(this->uiRootNode, p_rootComponent, newWindow);
//Component::printComponentTree(p_rootComponent, 0);
// these probably should be fatal
if (!newWindow->addressComponent) {
std::cout << "ERROR: no addressComponent" << std::endl;
@@ -625,7 +625,7 @@ void App::addWindow() {
if (!newWindow->tabComponent) {
std::cout << "ERROR: no tabComponent" << std::endl;
}
// we want each window to has it's own component tree, so each address bar can have different values
size_t layerCount = 0;
for(auto layer: this->layers) {
@@ -643,14 +643,14 @@ void App::addWindow() {
}
this->layers.clear(); // nuke any layers we have
p_rootComponent.reset();
//newWindow->rootComponent = rootComponent;
//newWindow->ui->rootComponent = rootComponent;
newWindow->renderDirty = true;
this->windows.push_back(newWindow);
newWindow.reset();
if (!activeWindow) {
//std::cout << "Browser::addWindow - setting active window" << std::endl;
activeWindow = this->windows.back().get();

src/app.h → src/app/App.h View File

@@ -1,9 +1,9 @@
#ifndef APP_H
#define APP_H

#include "interfaces/graphical/renderers/glfw/Window.h"
#include "interfaces/components/Component.h"
#include "parsers/markup/Node.h"
#include "../interfaces/graphical/renderers/glfw/Window.h"
#include "../interfaces/components/Component.h"
#include "../parsers/markup/Node.h"
//#include <GL/glew.h>
//#include <GLFW/glfw3.h>
//#include <memory>

src/browser.cpp → src/app/browser/Browser.cpp View File

@@ -1,11 +1,11 @@
#include "browser.h"
#include "interfaces/components/TabbedComponent.h"
#include "parsers/markup/html/HTMLParser.h"
#include "Browser.h"
#include "../../interfaces/components/TabbedComponent.h"
#include "../../parsers/markup/html/HTMLParser.h"

#include "interfaces/components/InputComponent.h"
#include "interfaces/components/ImageComponent.h"
#include "interfaces/components/TabbedComponent.h"
#include "interfaces/components/ButtonComponent.h"
#include "../../interfaces/components/InputComponent.h"
#include "../../interfaces/components/ImageComponent.h"
#include "../../interfaces/components/TabbedComponent.h"
#include "../../interfaces/components/ButtonComponent.h"

Browser::Browser() {
/*

src/browser.h → src/app/browser/Browser.h View File

@@ -1,10 +1,10 @@
#ifndef BROWSER_H
#define BROWSER_H

#include "app.h"
#include "../App.h"
//#include "interfaces/graphical/renderers/glfw/Window.h"
//#include "interfaces/components/Component.h"
#include "interfaces/components/DocumentComponent.h"
#include "../../interfaces/components/DocumentComponent.h"
//#include "interfaces/components/ComponentBuilder.h"
//#include "parsers/markup/Node.h"
//#include <GL/glew.h>
@@ -23,7 +23,7 @@ public:
Browser();
void addWindow();
std::shared_ptr<DocumentComponent> getActiveDocumentComponent();
std::shared_ptr<Component> tabComponent = nullptr;
std::shared_ptr<Component> addressComponent = nullptr;


+ 1
- 1
src/environment/Environment.cpp View File

@@ -3,7 +3,7 @@
#include <vector>

#include "Path.h"
#include "../Log.h"
#include "../tools/Log.h"

std::string Environment::resourceDir = "";


+ 36
- 36
src/interfaces/components/DocumentComponent.cpp View File

@@ -1,15 +1,15 @@
#include "DocumentComponent.h"
#include <cmath>
#include <iostream>
#include "../../Log.h"
#include "InputComponent.h"
#include "ButtonComponent.h"
#include "TabbedComponent.h"
#include <ctime>

#include "../graphical/renderers/glfw/Shader.h"
#include "../../WebResource.h"
#include "../../browser.h"
#include "../../tools/Log.h"
#include "../../tools/WebResource.h"
#include "../../app/browser/Browser.h"
#include "../../parsers/markup/html/HTMLParser.h"

void deleteComponent(std::shared_ptr<Component> &component);
@@ -59,20 +59,20 @@ DocumentComponent::DocumentComponent(const float rawX, const float rawY, const f
windowWidth = passedWindowWidth;
windowHeight = passedWindowHeight;
//std::cout << "DocumentComponent::DocumentComponent - window size: " << windowWidth << "x" << windowHeight << std::endl;
std::shared_ptr<Component> rootComponent = std::make_shared<Component>();
this->layers.push_back(rootComponent);
x = rawX;
y = rawY;
width = rawWidth;
height = rawHeight;
if (height < 0) {
std::cout << "DocumentComponent::DocumentComponent - height was less than zero" << std::endl;
height = 0;
}
//std::cout << "DocumentComponent::DocumentComponent - our size" << static_cast<int>(width) << "x" << static_cast<int>(height) << std::endl;
onMousemove=[this](int passedX, int passedY) {
// set hover component
@@ -320,19 +320,19 @@ DocumentComponent::DocumentComponent(const float rawX, const float rawY, const f
if (key == GLFW_KEY_PAGE_UP && (action == GLFW_PRESS || action == GLFW_REPEAT)) {
std::cout << "PgUp is/was pressed. Scrolling down." << std::endl;
this->scrollY(-yOffsetScroll*0.1);
}
if (key == GLFW_KEY_PAGE_DOWN && (action == GLFW_PRESS || action == GLFW_REPEAT)) {
std::cout << "PgDn is/was pressed. Scrolling up." << std::endl;
this->scrollY(yOffsetScroll*0.1);
}
// FIXME Scrolling with this can scroll past boundary whereas the same doesn't happen with
// scrolling wheel
if (key == GLFW_KEY_J && (action == GLFW_PRESS || action == GLFW_REPEAT)) {
std::cout << "J is/was pressed. Scrolling down." << std::endl;
this->scrollY(-yOffsetScroll*0.1);
}
// FIXME Scrolling with this can scroll past boundary whereas the same doesn't happen with
// scrolling wheel
@@ -404,17 +404,17 @@ void DocumentComponent::setDOM(const std::shared_ptr<Node> rootNode) {
// reset JS engine
//mainScript.clear();
mainScript = std::make_shared<JavaScript>();
// reset scroll position
//transformMatrix[13] = 2;
//transformMatrixDirty = true;
this->scrollY(0);
// new root component
rootComponent = std::make_shared<Component>();
rootComponent->name = "rootComponent of " + name;
rootComponent->y = y;
domRootNode = rootNode;
//std::cout << "DocumentComponent::setDOM - printing nodes" << endl; printNode(domRootNode, 0);
domDirty = true;
@@ -429,17 +429,17 @@ void DocumentComponent::render() {
const std::clock_t end = clock();
// root component here doesn't have any children...
std::cout << "built & laid out document components in: " << std::fixed << ((static_cast<double>(end - begin)) / CLOCKS_PER_SEC) << std::scientific << " seconds" << std::endl;
//Component::printComponentTree(rootComponent, 0);
domDirty = false;
/*
std::cout << "DocumentComponent::render - JS var state" << std::endl;
for(auto it : this->mainScript->rootScope.variables) {
std::cout << "[" << it.first << "=" << it.second << "]" << std::endl;
}
*/
//std::cout << "root Height: " << static_cast<int>(rootComponent->height) << " window Height: " << windowHeight << " y " << static_cast<int>(this->y) << std::endl;
//scrollHeight = std::max(0, static_cast<int>(rootComponent->height - (windowHeight + (this->y * 2))));

@@ -449,22 +449,22 @@ void DocumentComponent::render() {
transformMatrix[13]=std::max((rootComponent->height)/(windowHeight)*2.0f, 2.0f);
transformMatrixDirty = true;
}
// after we load in the document, allow scroll to work
this->updateMouse();
}
// we have to do this each time because window resets it
//if (transformMatrixDirty) {
//const std::clock_t begin = clock();
Shader *fontShader = this->win->shaderLoader.getShader(VertexShader("FontShader.vert"),
FragmentShader("FontShader.frag"));
GLint transformLocation = fontShader->uniform("transform");
glUniformMatrix4fv(transformLocation, 1, GL_FALSE, transformMatrix);
//const std::clock_t end = clock();
//std::cout << "Updated font matrix in: " << std::fixed << ((static_cast<double>(end - begin)) / CLOCKS_PER_SEC) << std::scientific << " seconds" << std::endl;
Shader *textureShader = this->win->shaderLoader.getShader(VertexShader("TextureShader.vert"),
FragmentShader("TextureShader.frag"));

@@ -474,7 +474,7 @@ void DocumentComponent::render() {
textureShader->bind();
GLint transformLocation2 = textureShader->uniform("transform");
glUniformMatrix4fv(transformLocation2, 1, GL_FALSE, textureTransformMatrix);
//std::cout << "DocumentComponent::render - start Box components" << std::endl;
//renderBoxComponents(rootComponent);
this->renderComponentType("input", rootComponent);
@@ -560,18 +560,18 @@ std::shared_ptr<Component> DocumentComponent::searchComponentTree(const std::sha
// preparation for multiple HTML documents
void DocumentComponent::navTo(const std::string url) {
logDebug() << "DocumentComponent::navTo(" << url << ")" << std::endl;
this->currentURL = currentURL.merge(URL(url));
logDebug() << "DocumentComponent::navTo - go to: " << currentURL << std::endl;
//setWindowContent(currentURL);
logDebug() << "main::setWindowContent - " << url << std::endl;
// integrity check
TabbedComponent *tabComponent = dynamic_cast<TabbedComponent*>(this->win->tabComponent.get());
if (!tabComponent->tabs.size()) {
std::cout << "DocumentComponent::navTo - There's a document when there's not tabs" << std::endl;
}
// download URL
WebResource res = getWebResource(this->currentURL);
this->handleResource(res, currentURL.toString());
@@ -587,23 +587,23 @@ void DocumentComponent::handleResource(WebResource &res, std::string url) {
// bind tag to root
tagNode->parent = rootNode;
rootNode->children.push_back(tagNode);
std::shared_ptr<TextNode> textNode = std::make_shared<TextNode>();
textNode->text = "Invalid Resource Type, HTTP Result Status: " + res.raw;
// bind text to tag
textNode->parent = tagNode;
tagNode->children.push_back(textNode);
// send NodeTree to window
//this->win->setDOM(rootNode);
this->setDOM(rootNode);
}
//std::cout << "body: " << res.raw << std::endl;
//std::cout << "type: " << res.resourceType << std::endl;
// parse HTML
if (res.resourceType == ResourceType::HTML) {
HTMLParser parser;
@@ -611,11 +611,11 @@ void DocumentComponent::handleResource(WebResource &res, std::string url) {
std::shared_ptr<Node> rootNode = parser.parse(res.raw);
const std::clock_t end = clock();
logDebug() << "DocumentComponent::handleResource - Parsed document in: " << std::fixed << ((static_cast<double>(end - begin)) / CLOCKS_PER_SEC) << std::scientific << " seconds" << std::endl;
// send NodeTree to window
//this->win->setDOM(rootNode);
//printNode(rootNode, 0);
// we need a way to communicate with our tabComponent
// maybe an event is best
if (this->onBeforeLoad) {
@@ -630,15 +630,15 @@ void DocumentComponent::handleResource(WebResource &res, std::string url) {
// bind tag to root
tagNode->parent = rootNode;
rootNode->children.push_back(tagNode);
std::shared_ptr<TextNode> textNode = std::make_shared<TextNode>();
textNode->text = res.raw;
// bind text to tag
textNode->parent = tagNode;
tagNode->children.push_back(textNode);
// send NodeTree to window
//this->win->setDOM(rootNode);
this->setDOM(rootNode);

+ 3
- 3
src/interfaces/components/DocumentComponent.h View File

@@ -7,9 +7,9 @@
#include "ComponentBuilder.h"
#include "../../parsers/markup/Node.h"
#include "../../parsers/scripting/javascript/JSParser.h"
#include "../../URL.h"
#include "../../networking/HTTPResponse.h"
#include "../../WebResource.h"
#include "../../tools/URL.h"
#include "../../tools/WebResource.h"

std::pair<size_t, size_t> getLine(std::string text, int findLine);
size_t getNumberOfLines(std::string text);
@@ -32,7 +32,7 @@ public:
//
//int scrollY = 0;
//int scrollHeight = 0;
// FIXME: I don't think we need two matrixes (they scroll in the same direction)
float textureTransformMatrix[16] = {
1, 0, 0, 0,

+ 48
- 50
src/interfaces/components/InputComponent.cpp View File

@@ -2,8 +2,6 @@
#include "DocumentComponent.h"
#include <iostream>
#include "../graphical/font/TextRasterizerCache.h"
#include "../../scheduler.h"

#include "../graphical/renderers/glfw/Shader.h"

extern TextRasterizerCache *rasterizerCache;
@@ -14,10 +12,10 @@ InputComponent::InputComponent(const float rawX, const float rawY, const float r

//std::cout << "InputComponent::InputComponent - create, boundToPage" << boundToPage << std::endl;
//std::cout << "InputComponent::InputComponent - window: " << windowWidth << "x" << windowHeight << " passed " << passedWindowWidth << "x" << passedWindowHeight << std::endl;
//boundToPage = true;
useBoxShader = true;
// set up state
windowWidth = passedWindowWidth;
windowHeight = passedWindowHeight;
@@ -29,7 +27,7 @@ InputComponent::InputComponent(const float rawX, const float rawY, const float r
x = rawX;
y = rawY;
lastRenderedWindowHeight = windowHeight;
// const float rawX, const float rawY, const float rawWidth, const float rawHeight, const unsigned int hexColor, const int passedWindowWidth, const int passedWindowHeight
// we only want it one line high (esp for text area)
this->cursorBox = new BoxComponent(x, y, 2, 13, 0x000000FF, windowWidth, windowHeight);
@@ -42,7 +40,7 @@ InputComponent::InputComponent(const float rawX, const float rawY, const float r
}
this->cursorBox->resize(this->windowWidth, this->windowHeight);
this->updateText();
onFocus=[this]() {
this->focused = true;
//std::cout << "focus input" << std::endl;
@@ -67,7 +65,7 @@ InputComponent::InputComponent(const float rawX, const float rawY, const float r
};

//std::cout << "InputComponent::InputComponent - placing box at " << (int)x << "," << (int)y << " size: " << (int)width << "x" << (int)height << std::endl;
// copy initial state
initialX = x;
initialY = y;
@@ -75,26 +73,26 @@ InputComponent::InputComponent(const float rawX, const float rawY, const float r
initialHeight = height;
initialWindowWidth = windowWidth;
initialWindowHeight = windowHeight;
data[0][0][0] = 0xf0; // set R color
data[0][0][1] = 0xf0; // set G color
data[0][0][2] = 0xf0; // set B color
data[0][0][3] = 0xff; // set alpha
float vx = rawX;
float vy = rawY;
//std::cout << "placing box at " << (int)vx << "x" << (int)vy << " size: " << (int)rawWidth << "x" << (int)rawHeight << std::endl;
float vWidth = rawWidth;
float vHeight = rawHeight;
pointToViewport(vx, vy);
// converts 512 to 1 and 1 to 2
//std::cout << "vWidth before: " << (int)vWidth << std::endl;
distanceToViewport(vWidth, vHeight);
//std::cout << "vWidth after: " << (int)vWidth << std::endl;
//std::cout << "InputComponent::InputComponent - placing box at GL " << vx << "," << vy << " to " << vx+vWidth << "," << vy+vHeight << " size: " << vWidth << "x" << vHeight << std::endl;
vertices[(0 * 5) + 0] = vx;
vertices[(0 * 5) + 1] = vy + vHeight;
vertices[(1 * 5) + 0] = vx + vWidth;
@@ -103,31 +101,31 @@ InputComponent::InputComponent(const float rawX, const float rawY, const float r
vertices[(2 * 5) + 1] = vy;
vertices[(3 * 5) + 0] = vx;
vertices[(3 * 5) + 1] = vy;
glGenVertexArrays(1, &vertexArrayObject);
glGenBuffers(1, &vertexBufferObject);
glGenBuffers(1, &elementBufferObject);
glBindVertexArray(vertexArrayObject);
glBindBuffer(GL_ARRAY_BUFFER, vertexBufferObject);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementBufferObject);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), nullptr);
glEnableVertexAttribArray(0);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(float), reinterpret_cast<void*>(3 * sizeof(float)));
glEnableVertexAttribArray(1);
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
glGenerateMipmap(GL_TEXTURE_2D);
glBindVertexArray(0); // protect what we created against any further modification
}

@@ -152,7 +150,7 @@ void InputComponent::render() {
}
verticesDirty = false;
}
glBindVertexArray(vertexArrayObject);
glErr=glGetError();
if(glErr != GL_NO_ERROR) {
@@ -196,7 +194,7 @@ void InputComponent::render() {
}
if (focused) {
//std::cout << "Rendering cursor" << std::endl;
// render it if we need to
if (showCursor) {
cursorBox->render();
@@ -207,14 +205,14 @@ void InputComponent::render() {
void InputComponent::resize(const int passedWindowWidth, const int passedWindowHeight) {
//std::cout << "InputComponent::resize" << std::endl;
//std::cout << "InputComponent::resize - rasterizing at " << (int)x << "x" << (int)y << " size: " << (int)width << "x" << (int)height << std::endl;
// maybe already done at component::resize
// set up state
windowWidth = passedWindowWidth;
windowHeight = passedWindowHeight;
//std::cout << "InputComponent::resize - boxShader: " << useBoxShader << " boundToPage: " << boundToPage << std::endl;
/*
if (!boundToPage) {
// ok because box shader is anchored to the bottom of the screen
@@ -225,20 +223,20 @@ void InputComponent::resize(const int passedWindowWidth, const int passedWindowH
lastRenderedWindowHeight = windowHeight;
}
*/
// turning this off breaks coordinates
//boundToPage = true;
/*
useBoxShader = true;
for (int i = 0; i < 3; i++) {
data[0][0][i] = 0xf0; // set RGB color
}
data[0][0][3] = 0xff; // set alpha
*/
//std::cout << "InputComponent::resize - placing box at " << (int)x << "," << (int)y << " size: " << (int)width << "x" << (int)height << std::endl;
float vx = x;
float vy = y;
if (this->boundToPage) {
@@ -246,37 +244,37 @@ void InputComponent::resize(const int passedWindowWidth, const int passedWindowH
//std::cout << "InputComponent::resize - Adjust y to " << vy << " from " << y << " h: " << (int)height << std::endl;
}
pointToViewport(vx, vy);
float vWidth = width;
float vHeight = height;
distanceToViewport(vWidth, vHeight);
float vx1 = vx + vWidth;
float vy1 = vy + vHeight;
//std::cout << "InputComponent::resize - placing box at GL " << vx << "," << vy << " to " << vx1 << "," << vy1 << " size: " << vWidth << "x" << vHeight << std::endl;
vertices[(0 * 5) + 0] = vx;
vertices[(0 * 5) + 1] = vy1;

vertices[(1 * 5) + 0] = vx1;
vertices[(1 * 5) + 1] = vy1;
vertices[(2 * 5) + 0] = vx1;
vertices[(2 * 5) + 1] = vy;
vertices[(3 * 5) + 0] = vx;
vertices[(3 * 5) + 1] = vy;
glBindVertexArray(vertexArrayObject);
glBindBuffer(GL_ARRAY_BUFFER, vertexBufferObject);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
glBindVertexArray(0); // protect what we created against any further modification
//updateText();
if (userInputText) {
// do we need updateText here?
userInputText->resize(passedWindowWidth, passedWindowHeight);
}
}

@@ -418,7 +416,7 @@ void InputComponent::updateCursor(int mX, int mY) {
//if (pos < this->text.getValue().size()) {
//std::cout << "InputComponent::updateCursor - Cursor at " << this->cursorCharX << "," << this->cursorCharY << " " << this->value.at(pos) << std::endl;
//}
const std::shared_ptr<TextRasterizer> textRasterizer = rasterizerCache->loadFont(12, false); // fontSize, bold
rasterizationRequest request;
//request.text = text.getValue().substr(0, pos);
@@ -437,7 +435,7 @@ void InputComponent::updateCursor(int mX, int mY) {
//std::cout << "InputComponent::updateCursor - response at [" << textInfo->endingX << "," << textInfo->endingY << "]" << std::endl;
int textEndingX = textInfo->endingX;
int textEndingY = textInfo->endingY;
// adjust text crop
//std::cout << "c.endingY: " << textInfo->endingY << " c.y:" << endingY << "" << std::endl;
this->textCropX = std::max(textInfo->endingX, static_cast<int>(this->width));
@@ -445,7 +443,7 @@ void InputComponent::updateCursor(int mX, int mY) {
this->textScrollY = 0; // reset scroll
//this->cursorStartAtX = textInfo->endingX;
//this->cursorStartAtY = textInfo->endingY;
// adjust our scroll
//std::cout << "cursor height" << (int)textInfo->height << " > " << (int)this->height << " (" << this->textScrollY << ")" << std::endl;
if (textInfo->height > this->height) {
@@ -463,7 +461,7 @@ void InputComponent::updateCursor(int mX, int mY) {
}
//std::cout << "placing cursor at " << (int)cursorBox->x << "," << (int)cursorBox->y << std::endl;
cursorBox->resize(this->windowWidth, this->windowHeight);
// ok placement of the cursor may trigger the text to scroll and need to be re-rasterized
if (moved) {
/*
@@ -482,7 +480,7 @@ void InputComponent::updateCursor(int mX, int mY) {
this->cursorLastX = this->cursorCharX;
this->cursorLastY = this->cursorCharY;
}
// if we move the cursor, redraw immediately
this->showCursor = true;
if (this->win) {
@@ -492,7 +490,7 @@ void InputComponent::updateCursor(int mX, int mY) {

void InputComponent::updateText() {
//std::cout << "InputComponent::updateText - input value is now: " << this->text.getValue() << std::endl;
if (this->node) {
std::map<std::string, std::string>::iterator it = this->node->properties.find("value");
if (it == this->node->properties.end()) {
@@ -501,7 +499,7 @@ void InputComponent::updateText() {
it->second = this->text.getValue();
}
}
//std::cout << "placed userInputText at " << static_cast<int>(x) << "," << static_cast<int>(y - windowHeight) << std::endl;
// 125 pixels width
// but first we need to know how wide the text is
@@ -528,7 +526,7 @@ void InputComponent::updateText() {
//int estHeight = textInfo->height;
//this->cursorStartAtX = textInfo->endingX;
//this->cursorStartAtY = textInfo->endingY;
// if textHeight is bigger than window, adjust cursor too
/*
if (estHeight > this->height) {
@@ -537,7 +535,7 @@ void InputComponent::updateText() {
}
*/
//this->updateCursor(0, 0);
// why does changing the width mess shit up?
//std::cout << "InputComponent::updateText - our width: " << static_cast<int>(width) << " windowWidth: " << windowWidth << std::endl;
if (this->win) {
@@ -559,7 +557,7 @@ void InputComponent::updateText() {
userInputText->y = this->y - this->windowHeight + 16;
}
userInputText->boundToPage = this->boundToPage;
userInputText->rasterStartX = this->textScrollX;
userInputText->rasterStartY = this->textScrollY;
userInputText->rasterCropX = this->textCropX;
@@ -594,8 +592,8 @@ void InputComponent::updateText() {
//std::cout << "InputComponent::updateText - textHeight: " << estHeight << " inputHeight: " << static_cast<int>(height) << " eY: " << textInfo->endingY << " y0max:" << textInfo->y0max << " rasterStartY: " << userInputText->rasterStartY << " lines: " << textInfo->lines << std::endl;
// don't wrap if multiLine, otherwise wrap
userInputText->noWrap = !this->multiLine;
userInputText->resize(this->windowWidth, this->windowHeight, this->width); // need to make sure there's a texture
this->win->renderDirty = true;
} // else it was called from cstr, and window isn't set up yet but no worrites, render will be dirty
}
}

+ 2
- 2
src/interfaces/components/InputComponent.h View File

@@ -5,8 +5,8 @@
#include <string>
#include "BoxComponent.h"
#include "TextComponent.h"
#include "../../scheduler.h"
#include "../../TextBlock.h"
#include "../../tools/TextBlock.h"
#include "../../tools/Scheduler.h"

class Window;


+ 15
- 15
src/interfaces/components/MultiComponent.cpp View File

@@ -8,27 +8,27 @@
#include "ImageComponent.h"

#include "../graphical/renderers/glfw/Shader.h"
#include "../../browser.h"
#include "../../app/browser/Browser.h"
#include <ctime>

extern std::unique_ptr<Browser> browser;

MultiComponent::MultiComponent(const float rawX, const float rawY, const float rawWidth, const float rawHeight, const int passedWindowWidth, const int passedWindowHeight) {
// take our space (for parent picking)
x = rawX;
y = rawY;
width = rawWidth;
height = rawHeight;
// not really needed but nothing else sets this
this->windowWidth = passedWindowWidth;
this->windowHeight = passedWindowHeight;
this->onResize=[this](int w, int h) {
this->resize(w, h);
};
// we need a mouseout to mouseout our hovercomponent
this->onMouseout=[this]() {
if (this->hoverComponent && this->hoverComponent->onMouseout) {
@@ -37,7 +37,7 @@ MultiComponent::MultiComponent(const float rawX, const float rawY, const float r
// select nothing
this->hoverComponent = nullptr;
};
this->onMousemove=[this](int passedX, int passedY) {
//std::cout << "MultiComponent::MultiComponent:onMousemove - at " << passedX << "," << passedY << std::endl;
if (this->cursorX == passedX && this->cursorY == passedY) {
@@ -86,7 +86,7 @@ MultiComponent::MultiComponent(const float rawX, const float rawY, const float r
this->hoverComponent->onFocus();
}
}
this->focusedComponent = this->hoverComponent;
if (this->focusedComponent && this->focusedComponent->onMouseup) {
//std::cout << "click event" << std::endl;
@@ -111,7 +111,7 @@ MultiComponent::MultiComponent(const float rawX, const float rawY, const float r
};
this->onWheel=[this](int passedX, int passedY) {
//std::cout << "MultiComponent::MultiComponent:onWheel " << passedX << "," << passedY << std::endl;
// if we're hovering over somethign
if (this->hoverComponent) {
// and it receives these messages
@@ -146,7 +146,7 @@ MultiComponent::MultiComponent(const float rawX, const float rawY, const float r
return;
}
*/
// allow address bar to hijack from relayKeyboardComponent
InputComponent *inputComponent = dynamic_cast<InputComponent*>(this->focusedComponent.get());
if (inputComponent) {
@@ -184,7 +184,7 @@ MultiComponent::MultiComponent(const float rawX, const float rawY, const float r
if (key == GLFW_KEY_BACKSLASH) key='|';
if (key == GLFW_KEY_RIGHT_BRACKET) key='}';
if (key == GLFW_KEY_GRAVE_ACCENT) key='~';
} else {
// no shift or caplocks
// basically: when SHIFT isn't pressed but key is in A-Z range, add ascii offset to make it lower case
@@ -230,7 +230,7 @@ MultiComponent::MultiComponent(const float rawX, const float rawY, const float r
}
if (key == GLFW_KEY_T && action == GLFW_RELEASE) {
browser->NextTheme();
}
}
if (relayKeyboardComponent->onKeyUp) {
relayKeyboardComponent->onKeyUp(key, scancode, action, mods);
return;
@@ -281,7 +281,7 @@ void MultiComponent::updateMouse() {
}
} else {
glfwSetCursor(this->win->window, this->win->cursorArrow);
}
}
}

void MultiComponent::resize(const int passedWindowWidth, const int passedWindowHeight) {
@@ -312,7 +312,7 @@ void MultiComponent::resize(const int passedWindowWidth, const int passedWindowH
}
const std::clock_t end = clock();
std::cout << "MultiComponent::resize - resized layers in: " << std::fixed << ((static_cast<double>(end - begin)) / CLOCKS_PER_SEC) << std::scientific << " seconds" << std::endl;
//renderDirty = true;
// should we mark win->renderDirty = true?
if (this->win) {
@@ -359,10 +359,10 @@ void MultiComponent::render() {

this->renderComponentType("tab", layer);
textureShader->bind();
//std::cout << "MultiComponent::render - end Box components" << std::endl;
//textureShader->release(); // select no shader
// if we move text earlier, we can't put tab labels on top of the tab
// but we have layers now
fontShader->bind();

+ 5
- 5
src/interfaces/components/TabbedComponent.h View File

@@ -3,7 +3,7 @@

#include "MultiComponent.h"
#include "TextComponent.h"
#include "../../BrowsingHistory.h"
#include "../../tools/BrowsingHistory.h"

struct Tab {
//std::string title;
@@ -52,20 +52,20 @@ public:
std::shared_ptr<Tab> mpSelectedTab = nullptr; // we just want a pointer to where we want to go
// this sucks tbh, just phase it out
std::vector<std::shared_ptr<Tab>>::iterator selectedTab;
// was DocumentComponent but generalized to be more general (and compatible with Tab)
std::shared_ptr<Component> documentComponent = nullptr;
unsigned int tabAddColor = 0xF0F0F0FF;
unsigned int tabAddHoverColor = 0x008800FF;

unsigned int tabInactiveColor = 0x808080FF;
unsigned int tabHoverColor = 0x8888BBFF;
unsigned int tabActiveColor = 0xE0E0E0FF;
unsigned int tabTextColor = 0x000000FF;
unsigned int tabTextHoverColor = 0x008888FF;
unsigned int tabCloseColor = 0x222222FF;
unsigned int tabCloseHoverColor = 0x880000FF;
};

+ 1
- 1
src/interfaces/elements/AElement.cpp View File

@@ -1,7 +1,7 @@
#include "AElement.h"
#include "../../parsers/markup/TagNode.h"
#include <iostream>
#include "../../browser.h"
#include "../../app/browser/Browser.h"

extern const std::unique_ptr<Browser> browser;


+ 7
- 7
src/interfaces/elements/BUTTONElement.cpp View File

@@ -3,9 +3,9 @@
#include "../components/InputComponent.h"
#include "../components/ButtonComponent.h"
#include "../components/DocumentComponent.h"
#include "../../WebResource.h"
#include "../../Log.h"
#include "../../FormData.h"
#include "../../tools/WebResource.h"
#include "../../tools/Log.h"
#include "../../tools/FormData.h"

BUTTONElement::BUTTONElement() {
isInline = true;
@@ -54,7 +54,7 @@ std::unique_ptr<Component> BUTTONElement::renderer(const ElementRenderRequest &r
method=formNodeMethodIter->second;
}
std::cout << "Form method is " << method << std::endl;
if (method=="POST" || method=="post") {
// need documentComponent
URL uAction = request.docComponent->currentURL.merge(URL(formNodeActionIter->second));
@@ -64,7 +64,7 @@ std::unique_ptr<Component> BUTTONElement::renderer(const ElementRenderRequest &r
request.docComponent->handleResource(res, uAction.toString());
} else {
// need documentComponent
std::string queryString = "";
if (formData) {
// iterator over formData
@@ -74,14 +74,14 @@ std::unique_ptr<Component> BUTTONElement::renderer(const ElementRenderRequest &r
// strip last & off
queryString = queryString.substr(0, queryString.size() - 1);
std::cout << "queryString is " << queryString << std::endl;
// The moral of the story is, if you have binary (non-alphanumeric) data (or a significantly sized payload) to transmit, use multipart/form-data
auto search = queryString.find(" ");
if (search != std::string::npos) {
queryString.replace(search, 1, "+");
}
}
URL uAction = request.docComponent->currentURL.merge(URL(formNodeActionIter->second+"?"+queryString));
std::cout << "Action URL is " << uAction.toString() << std::endl;
// download URL

+ 7
- 7
src/interfaces/elements/INPUTElement.cpp View File

@@ -2,9 +2,9 @@
#include "../components/InputComponent.h"
#include "../components/ButtonComponent.h"
#include "../components/DocumentComponent.h"
#include "../../Log.h"
#include "../../parsers/markup/html/HTMLParser.h"
#include "../../FormData.h"
#include "../../tools/Log.h"
#include "../../tools/FormData.h"
#include <ctime>

INPUTElement::INPUTElement() {
@@ -55,28 +55,28 @@ std::unique_ptr<Component> INPUTElement::renderer(const ElementRenderRequest &re
std::cout << "INPUTElement::renderer:butComponent->onClick - Can't find documentComponent for submit" << std::endl;
return;
}
TagNode *formTagNode = dynamic_cast<TagNode*>(formNode.get());
auto formNodeActionIter = formTagNode->properties.find("action");
if (formNodeActionIter == formTagNode->properties.end()) {
std::cout << "Form has no action" << std::endl;
return;
}
auto formNodeMethodIter = formTagNode->properties.find("method");
std::string method="GET";
if (formNodeMethodIter != formTagNode->properties.end()) {
method=formNodeMethodIter->second;
}
std::cout << "Form method is " << method << std::endl;
auto formData = buildFormData(formNode, nullptr);
// add our name/value (because we skip all submit buttons, there can only be one)
auto submitButtonNameValue = tagNode->getTagNodeNameValue();
if (submitButtonNameValue) {
formData->insert(*submitButtonNameValue);
}
if (method=="POST" || method=="post") {
// need documentComponent
URL uAction = request.docComponent->currentURL.merge(URL(formNodeActionIter->second));
@@ -103,7 +103,7 @@ std::unique_ptr<Component> INPUTElement::renderer(const ElementRenderRequest &re
queryString.replace(search, 1, "+");
}
}
URL uAction = request.docComponent->currentURL.merge(URL(formNodeActionIter->second+"?"+queryString));
std::cout << "Action URL is " << uAction.toString() << std::endl;
// download URL

+ 3
- 3
src/interfaces/elements/SCRIPTElement.cpp View File

@@ -1,7 +1,7 @@
#include "SCRIPTElement.h"
#include "../components/DocumentComponent.h"
#include "../../WebResource.h"
#include "../../Log.h"
#include "../../tools/WebResource.h"
#include "../../tools/Log.h"
#include "../../parsers/scripting/javascript/JSParser.h"
#include <ctime>

@@ -55,7 +55,7 @@ std::unique_ptr<Component> SCRIPTElement::renderer(const ElementRenderRequest &r
// we need to execute the new instructions with the combined scope
// copy scope back into our script
newScript->rootScope = request.docComponent->mainScript->rootScope;
}
return nullptr;
}

+ 2
- 2
src/interfaces/elements/TEXTAREAElement.cpp View File

@@ -2,9 +2,9 @@
#include "../components/InputComponent.h"
#include "../components/ButtonComponent.h"
#include "../components/DocumentComponent.h"
#include "../../Log.h"
#include "../../parsers/markup/html/HTMLParser.h"
#include "../../FormData.h"
#include "../../tools/Log.h"
#include "../../tools/FormData.h"
#include <ctime>

TEXTAREAElement::TEXTAREAElement() {

src/graphics/opengl/TextWindow.cpp → src/interfaces/graphical/renderers/TextWindow.cpp View File


src/graphics/opengl/TextWindow.h → src/interfaces/graphical/renderers/TextWindow.h View File


+ 1
- 1
src/interfaces/graphical/renderers/glfw/ShaderLoader.cpp View File

@@ -5,7 +5,7 @@
#include <iostream>

#include "Shader.h"
#include "../../../../Log.h"
#include "../../../../tools/Log.h"
#include "../../../../environment/Environment.h"
#include "../../../../environment/Path.h"


+ 11
- 13
src/interfaces/graphical/renderers/glfw/Window.cpp View File

@@ -1,13 +1,11 @@
#include "../../../../URL.h"
#include "Window.h"
#include "../../../../parsers/markup/TagNode.h"
#include "../../../../parsers/markup/TextNode.h"

#include "../../../../networking/HTTPRequest.h"
#include "../../../../parsers/markup/html/HTMLParser.h"
#include "../../../../StringUtils.h"
#include "../../../../URL.h"
#include "../../../../Log.h"
#include "../../../../tools/StringUtils.h"
#include "../../../../tools/Log.h"
#include "../../../components/BoxComponent.h"
#include "../../../components/ImageComponent.h"
#include "../../../components/DocumentComponent.h"
@@ -16,7 +14,7 @@
#include "../../../components/TabbedComponent.h"
#include "../../../components/InputComponent.h"
#include "Shader.h"
#include "../../../../browser.h"
#include "../../../../app/browser/Browser.h"

#include <cmath>
#include <ctime>
@@ -29,7 +27,7 @@ Window::~Window() {
}

bool Window::init() {
Rect windowPosSize;
windowPosSize.x = 0;
windowPosSize.y = 0;
@@ -50,16 +48,16 @@ bool Window::init() {
//std::cout << "OpenGL is set up" << std::endl;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &this->maxTextureSize);
std::cout << "Max texture size: " << this->maxTextureSize << std::endl;
// set up our UI with a new window
this->ui = std::make_unique<MultiComponent>(0, 0, this->windowWidth, this->windowHeight, this->windowWidth, this->windowHeight);
this->ui->windowed = true;
this->ui->win = shared_from_this();
this->cursorHand = pRenderer->cursorHand;
this->cursorArrow = pRenderer->cursorArrow;
this->cursorIbeam = pRenderer->cursorIbeam;
// relay events to our ui
// window
//this->openglWindow->onResize = this->ui->onResize;
@@ -94,7 +92,7 @@ bool Window::initGLFW() {
glfwSetErrorCallback([](int error, const char* description) {
std::cout << "glfw error [" << error << "]:" << description << std::endl;
});
GLFWwindow *context = nullptr;
if (browser->windows.size()) {
context = browser->windows.front().get()->window;
@@ -167,7 +165,7 @@ bool Window::initGLFW() {
glfwSetCharCallback(window, [](GLFWwindow* win, unsigned int codepoint) {
Window *thiz = reinterpret_cast<Window*>(glfwGetWindowUserPointer(win));
//std::cout << "Window::glfwSetCharCallback - codepoint: " << codepoint << std::endl;
// should be used for inputComponent
});

@@ -260,11 +258,11 @@ void Window::render() {
this->resize();
}
if (renderDirty) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
ui->render();
glfwSwapBuffers(window);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
ui->render();
glfwSwapBuffers(window);

+ 9
- 9
src/interfaces/graphical/renderers/glfw/Window.h View File

@@ -12,7 +12,7 @@
#include <vector>
#include <algorithm>
#include "../../../../networking/HTTPResponse.h"
#include "../../../../URL.h"
#include "../../../../tools/URL.h"
#include "opengl.h"

class DocumentComponent;
@@ -37,16 +37,16 @@ public:
void checkForResize();
void resize();
void scrollDocument(int y);
//void resizeComponentTree(const std::shared_ptr<Component> &component, const int windowWidth, const int windowHeight);
//std::shared_ptr<Component> searchComponentTree(const std::shared_ptr<Component> &component, const int x, const int y);
//void navTo(std::string url);

// properties
int maxTextureSize = 0;
unsigned int oglActiveShader = 0; // cache to minimize opengl state changes
// just a default matrix to reset UI since it won't scroll
float textureTransformMatrix[16] = {
1, 0, 0, 0,
@@ -70,10 +70,10 @@ public:
//std::shared_ptr<Node> domRootNode = nullptr;
//bool domDirty = false;
bool renderDirty = true;
//ComponentBuilder componentBuilder;
//std::shared_ptr<Component> rootComponent = std::make_shared<Component>();
// could break these out in some sort of cursor class
// to minimize dependencies
//std::shared_ptr<Component> focusedComponent = nullptr;
@@ -84,13 +84,13 @@ public:
GLFWcursor* cursorHand;
GLFWcursor* cursorArrow;
GLFWcursor* cursorIbeam;
// why is this a pointer? I think we thought it'd make moving the UI between windows easier
// open to opinions on changing this to a not-pointer
std::unique_ptr<MultiComponent> ui = nullptr;
ShaderLoader shaderLoader;
// is there only one selection per window? (probably not)
int highlightStartX = 0;
int highlightStartY = 0;

+ 42
- 42
src/interfaces/graphical/renderers/glfw/opengl.cpp View File

@@ -1,5 +1,5 @@
#include "opengl.h"
#include "../../../../browser.h"
#include "../../../../app/browser/Browser.h"

#include <iostream>
#include <cmath>
@@ -22,9 +22,9 @@ bool initGL() {
const GLubyte *version = glGetString(GL_VERSION);
std::cout << "Renderer: " << brenderer << std::endl;
std::cout << "Version: " << version << std::endl;
checkGLState("opengl::initGL - start");
glEnable(GL_BLEND); checkGLState("opengl::initGL - glEnable blend");
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); checkGLState("opengl::initGL - glBlendFunc");

@@ -33,14 +33,14 @@ bool initGL() {
float g = (static_cast<float>((clearColor >> 16) & 0xFF)) / 255;
float b = (static_cast<float>((clearColor >> 8) & 0xFF)) / 255;
float a = (static_cast<float>((clearColor >> 0) & 0xFF)) / 255;
//glClearColor(0.8f, 0.8f, 0.8f, 0.8f);
glClearColor(r, g, b, a); checkGLState("opengl::initGL - glClearColor");
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); checkGLState("opengl::initGL - glTexParameteri min");
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); checkGLState("opengl::initGL - glTexParameteri mag");
//std::cout << "OpenGL is set up" << std::endl;
return true;
}

@@ -67,7 +67,7 @@ bool OpenGL::initialize() {
glfwSetErrorCallback([](int error, const char* description) {
std::cout << "glfw error [" << error << "]:" << description << std::endl;
});
// I don't think you can init GLEW without a window
return true;
}
@@ -85,12 +85,12 @@ OpenGLWindowHandle * OpenGL::createWindow(std::string title, Rect *position, uns
twin->height = position->h;
GLFWwindow *window = glfwCreateWindow(windowWidth, windowHeight, title.c_str(), nullptr, nullptr);
twin->window = window;
// replace first parameter of all these callbacks with our window object instead of a GLFWwindow
glfwSetWindowUserPointer(window, this);
// probably should set up all the hooks here
glfwMakeContextCurrent(window);
// init GLEW
if (!initGLEW()) {
// FIXME: un do glfw create window
@@ -109,16 +109,16 @@ OpenGLWindowHandle * OpenGL::createWindow(std::string title, Rect *position, uns
twin->fontShader = twin->shaderLoader.getShader(VertexShader("FontShader.vert"),
FragmentShader("FontShader.frag"));

// configure opengl coordinates
//std::cout << "position: " << position->w << "x" << position->h << std::endl;
glViewport(0, 0, static_cast<GLsizei>(position->w), static_cast<GLsizei>(position->h)); checkGLState("OpenGL::createWindow - glViewport");
// replace first parameter of all these callbacks with our window object instead of a GLFWwindow
glfwSetWindowUserPointer(twin->window, twin);

// set up event callbacks
// window events
glfwSetFramebufferSizeCallback(window, [](GLFWwindow *glfwwin, int width, int height) {
glViewport(0, 0, width, height);
@@ -129,7 +129,7 @@ OpenGLWindowHandle * OpenGL::createWindow(std::string title, Rect *position, uns
thiz->onResize(width, height);
}
});
// mouse events
glfwSetCursorPosCallback(window, [](GLFWwindow *glfwwin, double xPos, double yPos) {
OpenGLWindowHandle *thiz = reinterpret_cast<OpenGLWindowHandle*>(glfwGetWindowUserPointer(glfwwin));
@@ -176,20 +176,20 @@ OpenGLWindowHandle * OpenGL::createWindow(std::string title, Rect *position, uns
}
}
});
// keyboard events
// works with utf-32 and os keyboard layout but we'll lkeep the low level for now
glfwSetCharCallback(window, [](GLFWwindow* glfwwin, unsigned int codepoint) {
OpenGLWindowHandle *thiz = reinterpret_cast<OpenGLWindowHandle*>(glfwGetWindowUserPointer(glfwwin));
//std::cout << "OpenGL::glfwSetCharCallback - codepoint: " << codepoint << std::endl;
// should be used for inputComponent
if (thiz->onKeyPress) {
thiz->onKeyPress(codepoint);
}
});
glfwSetKeyCallback(window, [](GLFWwindow *glfwwin, int key, int scancode, int action, int mods) {
OpenGLWindowHandle *thiz = reinterpret_cast<OpenGLWindowHandle*>(glfwGetWindowUserPointer(glfwwin));
if (action == GLFW_RELEASE) {
@@ -212,7 +212,7 @@ OpenGLWindowHandle * OpenGL::createWindow(std::string title, Rect *position, uns
}
}
});
/*
// Change to the projection matrix, reset the matrix and set up orthagonal projection (i.e. 2D)
glMatrixMode(GL_PROJECTION);
@@ -231,14 +231,14 @@ OpenGLWindowHandle * OpenGL::createWindow(std::string title, Rect *position, uns
std::cout << "OpenGL::createWindow - glOrtho - not ok: " << gluErrorString(glErr) << std::endl;
}
*/
// set up box shader
GLuint elementBufferObject = 0;

glGenVertexArrays(1, &twin->vertexArrayObjectBox); checkGLState("OpenGL::createWindow - genVAOBox");
glBindVertexArray(twin->vertexArrayObjectBox); checkGLState("OpenGL::createWindow - bindVAOBox");
glGenBuffers(1, &elementBufferObject); checkGLState("OpenGL::createWindow - genEBO");
// we may need the VBO here...
glGenBuffers(1, &twin->vertexBufferObjectBox); checkGLState("OpenGL::createWindow - genVBOBox");
float vertices[20] = {
@@ -254,17 +254,17 @@ OpenGLWindowHandle * OpenGL::createWindow(std::string title, Rect *position, uns
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); checkGLState("OpenGL::createWindow - bufVBO");
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementBufferObject); checkGLState("OpenGL::createWindow - bindEBO");
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(this->indices), this->indices, GL_STATIC_DRAW); checkGLState("OpenGL::createWindow - buffEBO");
// attribute 0 = 3 floats
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), nullptr); checkGLState("OpenGL::createWindow - glVertexAttribPointer0");
glEnableVertexAttribArray(0); checkGLState("OpenGL::createWindow - glEnableVertexAttribArray0");
// attribute 1 = 2 floats, at 3
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(float), reinterpret_cast<void*>(3 * sizeof(float))); checkGLState("OpenGL::createWindow - glVertexAttribPointer1");
glEnableVertexAttribArray(1); checkGLState("OpenGL::createWindow - glEnableVertexAttribArray1");
//glBindVertexArray(0);
// set up text shader
glGenVertexArrays(1, &twin->vertexArrayObjectText); checkGLState("OpenGL::createWindow - genVAOText");
glBindVertexArray(twin->vertexArrayObjectText); checkGLState("OpenGL::createWindow - bindVBOText");
@@ -274,22 +274,22 @@ OpenGLWindowHandle * OpenGL::createWindow(std::string title, Rect *position, uns
glBindBuffer(GL_ARRAY_BUFFER, twin->vertexBufferObjectText); checkGLState("OpenGL::createWindow - bindVBOText");
std::unique_ptr<float[]> vertices2 = std::make_unique<float[]>(36); // upload garbage for now
glBufferData(GL_ARRAY_BUFFER, ((3 + 4 + 2) * 4) * sizeof(float), vertices2.get(), GL_STATIC_DRAW); checkGLState("OpenGL::createWindow - buffVBOText");
// eBO
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementBufferObject); checkGLState("OpenGL::createWindow - bindVBOText");
//glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, (3 + 4 + 2) * sizeof(float), nullptr); checkGLState("OpenGL::createWindow - glVertexAttribPointerText0");
glEnableVertexAttribArray(0); checkGLState("OpenGL::createWindow - glEnableVertexAttribArrayText0");
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, (3 + 4 + 2) * sizeof(float), reinterpret_cast<void*>(3 * sizeof(float))); checkGLState("opengl::createWindow - glVertexAttribPointerText1");
glEnableVertexAttribArray(1); checkGLState("OpenGL::createWindow - glEnableVertexAttribArrayText1");
glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, (3 + 4 + 2) * sizeof(float), reinterpret_cast<void*>(7 * sizeof(float))); checkGLState("opengl::createWindow - glVertexAttribPointerText2");
glEnableVertexAttribArray(2); checkGLState("OpenGL::createWindow - glEnableVertexAttribArrayText2");

glBindVertexArray(0);
return twin;
}

@@ -304,7 +304,7 @@ void OpenGLWindowHandle::swapBuffers() {
OpenGLTexture* OpenGLWindowHandle::createSprite(unsigned char* texture, GLsizei w, GLsizei h) {
OpenGLTexture *handle = new OpenGLTexture;
glGenTextures(1, &handle->number);
// make sure texture size is a power of two
size_t potw = pow(2, ceil(log(w) / log(2)));
size_t poth = pow(2, ceil(log(h) / log(2)));
@@ -330,7 +330,7 @@ OpenGLTexture* OpenGLWindowHandle::createSprite(unsigned char* texture, GLsizei
}
}
}
// upload to video card
// select
glBindTexture(GL_TEXTURE_2D, handle->number); checkGLState("OpenGLWindowHandle::createSprite - bind");
@@ -340,26 +340,26 @@ OpenGLTexture* OpenGLWindowHandle::createSprite(unsigned char* texture, GLsizei
glGenerateMipmap(GL_TEXTURE_2D); checkGLState("OpenGLWindowHandle::createSprite - process");
// unselect
glBindTexture(GL_TEXTURE_2D, 0); checkGLState("OpenGLWindowHandle::createSprite - unselect");
return handle;
}

OpenGLTexture* OpenGLWindowHandle::createTextSprite(unsigned char *texture, GLsizei w, GLsizei h, textureMap &textureMap) {
OpenGLTexture *handle = new OpenGLTexture;
glGenTextures(1, &handle->number); checkGLState("OpenGLWindowHandle::createTextureFromColor - glGenTextures");
// upload
glBindTexture(GL_TEXTURE_2D, handle->number); checkGLState("OpenGLWindowHandle::createTextureFromColor - bindTexture");
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RED, GL_UNSIGNED_BYTE, texture); checkGLState("OpenGLWindowHandle::createTextureFromColor - glTexImage2D");
glGenerateMipmap(GL_TEXTURE_2D); checkGLState("OpenGLWindowHandle::createTextureFromColor - glGenerateMipmap");
glBindTexture(GL_TEXTURE_2D, 0); checkGLState("OpenGLWindowHandle::createTextureFromColor - unBindTex");
// I flipped this maybe due to coords...
handle->s0 = textureMap.map[0];
handle->t0 = textureMap.map[1];
handle->s1 = textureMap.map[2];
handle->t1 = textureMap.map[3];
return handle;
}

@@ -380,7 +380,7 @@ OpenGLTexture* OpenGLWindowHandle::createSpriteFromColor(const unsigned int hexC
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture); checkGLState("OpenGLWindowHandle::createTextureFromColor - glTexImage2D");
glGenerateMipmap(GL_TEXTURE_2D); checkGLState("OpenGLWindowHandle::createTextureFromColor - glGenerateMipmap");
glBindTexture(GL_TEXTURE_2D, 0); checkGLState("OpenGLWindowHandle::createTextureFromColor - unselect");
return handle;
}

@@ -444,11 +444,11 @@ void OpenGLWindowHandle::drawSpriteBox(OpenGLTexture *texture, Rect *position) {
float vHeight = position->h;
//std::cout << "placing box at " << (int)vx << "x" << (int)vy << " size: " << (int)vWidth << "x" << (int)vHeight << std::endl;
pointToViewport(vx, vy, this->width, this->height);
//std::cout << "vWidth before: " << (int)vWidth << std::endl;
distanceToViewport(vWidth, vHeight, this->width, this->height);
//std::cout << "vWidth after: " << (int)vWidth << std::endl;
//std::cout << "placing box at GL " << (int)vx << "x" << (int)vy << " size: " << (int)(vWidth*10000) << "x" << (int)(vHeight*10000) << std::endl;
float vertices[20] = {
0.0f, 0.0f, 0.0f, 0.0f, 1.0f,
@@ -476,7 +476,7 @@ void OpenGLWindowHandle::drawSpriteBox(OpenGLTexture *texture, Rect *position) {
textureShader->bind();
GLint transformLocation = textureShader->uniform("transform");
glUniformMatrix4fv(transformLocation, 1, GL_FALSE, textureTransformMatrix); checkGLState("OpenGLWindowHandle::drawSpriteBox - glUniformMatrix4fv");
glBindVertexArray(vertexArrayObjectBox); checkGLState("OpenGLWindowHandle::drawSpriteBox - glBindVertexArray");
glBindTexture(GL_TEXTURE_2D, texture->number); checkGLState("OpenGLWindowHandle::drawSpriteBox - glBindTexture");
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, nullptr); checkGLState("OpenGLWindowHandle::drawSpriteBox - glDrawElements");
@@ -508,19 +508,19 @@ void OpenGLWindowHandle::drawSpriteText(OpenGLTexture *texture, unsigned int hex
setVerticesColor(vertices, 0, hexColor);
vertices[posMac(0) + 7] = texture->s0;
vertices[posMac(0) + 8] = texture->t0;
vertices[posMac(1) + 0] = vx0;
vertices[posMac(1) + 1] = vy1;
setVerticesColor(vertices, 1, hexColor);
vertices[posMac(1) + 7] = texture->s0;
vertices[posMac(1) + 8] = texture->t1;
vertices[posMac(2) + 0] = vx1;
vertices[posMac(2) + 1] = vy1;
setVerticesColor(vertices, 2, hexColor);
vertices[posMac(2) + 7] = texture->s1;
vertices[posMac(2) + 8] = texture->t1;
vertices[posMac(3) + 0] = vx1;
vertices[posMac(3) + 1] = vy0;
setVerticesColor(vertices, 3, hexColor);

+ 25
- 26
src/main.cpp View File

@@ -1,22 +1,21 @@
#include "CommandLineParams.h"
#include "interfaces/components/TabbedComponent.h"
#include "interfaces/components/InputComponent.h"
#include "environment/Environment.h"
#include "Log.h"
#include "URL.h"
#include "WebResource.h"
#include "tlsf.h"
#include "CFGFileParser.h"
#include "browser.h"

#include "interfaces/graphical/renderers/glfw/opengl.h"
#include "parsers/images/netpbm/pnm.h"

#include <ctime>
#include <iostream>
#include <sys/stat.h>
#include <string.h>

#include "app/browser/Browser.h"
#include "environment/Environment.h"
#include "interfaces/components/TabbedComponent.h"
#include "interfaces/components/InputComponent.h"
#include "interfaces/graphical/renderers/glfw/opengl.h"
#include "parsers/images/netpbm/pnm.h"
#include "platform/tlsf.h"
#include "tools/CFGFileParser.h"
#include "tools/CommandLineParams.h"
#include "tools/Log.h"
#include "tools/URL.h"
#include "tools/WebResource.h"

#ifdef _WIN32
extern "C"{
void init_heap();
@@ -82,7 +81,7 @@ int main(int argc, char *argv[]) {
std::cout << "/g/ntr - NetRunner build " << __DATE__ << ": internal-dev non-Makefile build" << std::endl;
#endif

Environment::init();
CFGFileParser *parser = new CFGFileParser("res/netrunner.cfg");
BrowserConfiguration *config = new BrowserConfiguration();
@@ -100,13 +99,13 @@ int main(int argc, char *argv[]) {
}
std::cout << std::endl;
#endif
renderer = std::make_unique<OpenGL>();

//Environment::init();
renderer->initialize();
/*
Rect pos;
pos.x=0;
@@ -118,7 +117,7 @@ int main(int argc, char *argv[]) {
std::cout << "Couldn't create window" << std::endl;
return 0;
}
OpenGLTexture *blue = win->createSpriteFromColor(0x0000FFFF);
if (!blue) {
std::cout << "Couldn't create blue" << std::endl;
@@ -126,7 +125,7 @@ int main(int argc, char *argv[]) {
}
Rect dPos = { 0, 0, 512, 320 };
*/
/*
const std::shared_ptr<TextRasterizer> textRasterizer = rasterizerCache->loadFont(12, false);
rasterizationRequest request;
@@ -137,17 +136,17 @@ int main(int argc, char *argv[]) {
request.noWrap = true;
//std::cout << "rasterizing [" << text << "] @" << rawX << " availableWidth: " << availableWidth << " sourceStartX: " << rasterStartX << " noWrap: " << noWrap << std::endl;
std::shared_ptr<rasterizationResponse> response = textRasterizer->rasterize(request);
textureMap textureMap;
textureMap.map[0] = response->s0;
textureMap.map[1] = response->t0;
textureMap.map[2] = response->s1;
textureMap.map[3] = response->t1;
OpenGLTexture *text = win->createTextSprite(response->textureData.get(), response->textureWidth, response->textureHeight, textureMap);
Rect dPos3 = { 512, 320, 512, 320};
*/
/*
RGBAPNMObject *anime = readPPM("kon32_661.pam");
if (!anime) {
@@ -157,7 +156,7 @@ int main(int argc, char *argv[]) {
opengl_texture_handle *red = win->createSprite(anime->m_Ptr, anime->width, anime->height);
Rect dPos2 = { 512, 320, 512, 320};
*/
/*
win->clear();
win->drawSpriteBox(blue, &dPos);
@@ -168,7 +167,7 @@ int main(int argc, char *argv[]) {
while(1) {
glfwWaitEvents(); // block until something changes
}
return 0;
*/

@@ -224,7 +223,7 @@ int main(int argc, char *argv[]) {
// be nice if we could put http:// in the address bar
}
}
browser->loop();
return 0;
}

+ 1
- 1
src/networking/HTTPRequest.h View File

@@ -3,7 +3,7 @@

#include "HTTPCommon.h"
#include "HTTPResponse.h"
#include "../URL.h"
#include "../tools/URL.h"
#include <functional>
#include <string>


+ 1
- 1
src/networking/HTTPSRequest.h View File

@@ -3,7 +3,7 @@
#include "HTTPCommon.h"
#include "HTTPResponse.h"
#include "../URL.h"
#include "../tools/URL.h"
#include <functional>
#include <string>
#ifdef NULL

+ 1
- 1
src/parsers/images/netpbm/pnm.h View File

@@ -2,7 +2,7 @@
#define PNMPARSER_H

#include <string>
#include "../../../tlsf.h"
#include "../../../platform/tlsf.h"

// this structure expects RGBA
struct RGBAPNMObject {

+ 2
- 2
src/parsers/images/tga/tga.h View File

@@ -2,7 +2,7 @@
#define TGAPARSER_H

#include <string>
#include "../../../tlsf.h"
#include "../../../platform/tlsf.h"

struct TGAObject {
unsigned char imageTypeCode;
@@ -17,7 +17,7 @@ struct BitMapObject {
std::string filename;
size_t width, height;
unsigned char *imageData;
// fast allocation!
static void* operator new(size_t n){
void *mem = tlsf_malloc(n);

+ 9
- 9
src/parsers/scripting/javascript/JSParser.cpp View File

@@ -1,5 +1,5 @@
#include "JSParser.h"
#include "../../../StringUtils.h"
#include "../../../tools/StringUtils.h"

std::vector<std::string> JSParser::getTokens(const std::string &source) const {
std::vector<std::string> tokens;
@@ -105,7 +105,7 @@ std::vector<std::string> JSParser::getTokens(const std::string &source) const {
}
} else if (state == 7) {
}
//
if (source[cursor] == '{') {
scopeLevel++;
@@ -119,7 +119,7 @@ std::vector<std::string> JSParser::getTokens(const std::string &source) const {
endIt = true;
}
}
// state 0 or 7, ignore states 1-6
if ((state == 0 || state == 7) && !scopeLevel) {
if (source[cursor] == '\n' || source[cursor] == ';' || endIt || (source[cursor] == ',' && state != 7)) {
@@ -136,7 +136,7 @@ std::vector<std::string> JSParser::getTokens(const std::string &source) const {
tokens.push_back(token);
}
last = cursor;
if (state == 7) { // allow var constructs to end normally and take us out of var construct
state = 0; // reset state
}
@@ -209,7 +209,7 @@ void doExpression(js_scope &rootScope, std::string token) {
last = cursor + 1;
expression_parts.push_back("{");
}
// single =
if (token[cursor] == '=' && token.length() > cursor + 1 && token[cursor + 1] != '=') {
//state = 1;
@@ -291,7 +291,7 @@ void doExpression(js_scope &rootScope, std::string token) {
trinaryLevel++;
state = 9;
}
} else if (state == 1) {
if (token[cursor] == '{') {
parenLevel++;
@@ -893,7 +893,7 @@ bool doAssignment(js_scope &rootScope, std::string token) {
last = cursor + 1;
expression_parts.push_back("{");
}
// single =
if (token[cursor] == '=' && token.length() > cursor + 1 && token[cursor + 1] != '=') {
//state = 1;
@@ -1064,7 +1064,7 @@ bool doAssignment(js_scope &rootScope, std::string token) {
if (last != token.length()) {
expression_parts.push_back(token.substr(last, token.length()));
}
std::cout << "expression string[" << token << "]" << std::endl;
std::cout << "expression debug" << std::endl;
std::string lastToken = "";
@@ -1174,7 +1174,7 @@ bool doAssignment(js_scope &rootScope, std::string token) {
std::shared_ptr<JavaScript> JSParser::parse(const std::string &source) const {
std::shared_ptr<JavaScript> script = std::make_shared<JavaScript>();
script->tokens = this->getTokens(source);
// we need to at least build the root scope
//std::cout << "\nstart script" << std::endl;