Browse Source

main javascript source, v to debug js variables

master
Odilitime 5 years ago
parent
commit
cc7084ec96
  1. 22
      src/interfaces/components/DocumentComponent.cpp
  2. 2
      src/interfaces/components/DocumentComponent.h

22
src/interfaces/components/DocumentComponent.cpp

@ -272,6 +272,14 @@ DocumentComponent::DocumentComponent(const float rawX, const float rawY, const f @@ -272,6 +272,14 @@ DocumentComponent::DocumentComponent(const float rawX, const float rawY, const f
}
printf("\n\n");
}
if (key == GLFW_KEY_V && action == GLFW_RELEASE) {
printf("Printing JS Variables\n\n");
//std::cout << "DocumentComponent::render - JS var state" << std::endl;
for(auto it : this->mainScript->rootScope.variables) {
std::cout << "[" << it.first << "=" << it.second << "]" << std::endl;
}
printf("\n\n");
}
if (key == GLFW_KEY_T && action == GLFW_RELEASE) {
browser->NextTheme();
}
@ -393,6 +401,10 @@ void DocumentComponent::setDOM(const std::shared_ptr<Node> rootNode) { @@ -393,6 +401,10 @@ void DocumentComponent::setDOM(const std::shared_ptr<Node> rootNode) {
if (domRootNode) {
deleteNode(domRootNode);
}
// reset JS engine
//mainScript.clear();
mainScript = std::make_shared<JavaScript>();
// reset scroll position
//transformMatrix[13] = 2;
//transformMatrixDirty = true;
@ -420,6 +432,14 @@ void DocumentComponent::render() { @@ -420,6 +432,14 @@ void DocumentComponent::render() {
//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))));
@ -606,7 +626,7 @@ void DocumentComponent::handleResource(WebResource &res, std::string url) { @@ -606,7 +626,7 @@ void DocumentComponent::handleResource(WebResource &res, std::string url) {
std::cout << "DocumentComponent::handleResource - Rendering text document" << std::endl;
std::shared_ptr<Node> rootNode = std::make_shared<Node>(NodeType::ROOT);
std::shared_ptr<TagNode> tagNode = std::make_shared<TagNode>();
tagNode->tag="p";
tagNode->tag = "p";
// bind tag to root
tagNode->parent = rootNode;
rootNode->children.push_back(tagNode);

2
src/interfaces/components/DocumentComponent.h

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
#include "MultiComponent.h"
#include "ComponentBuilder.h"
#include "../../parsers/markup/Node.h"
#include "../../parsers/scripting/javascript/JSParser.h"
#include "../../URL.h"
#include "../../networking/HTTPResponse.h"
#include "../../WebResource.h"
@ -47,6 +48,7 @@ public: @@ -47,6 +48,7 @@ public:
};
bool transformMatrixDirty = true;
std::function<void(std::string url)> onBeforeLoad = nullptr;
std::shared_ptr<JavaScript> mainScript = nullptr;
};

Loading…
Cancel
Save