|
From: CVS C. to T. <the...@li...> - 2011-07-30 18:48:42
|
Revision: 663
http://themis.svn.sourceforge.net/themis/?rev=663&view=rev
Author: mark_hellegers
Date: 2011-07-30 18:48:36 +0000 (Sat, 30 Jul 2011)
Log Message:
-----------
Added support for loading other resources. Currently disabled as it seems to cause trouble in the http protocol on my machine.
Remove comment from mView->RetrieveResources() in CSSRendererView.cpp to enable it.
Modified Paths:
--------------
trunk/themis/framework/win.cpp
trunk/themis/modules/CSSRenderer/CSSRenderer.cpp
trunk/themis/modules/CSSRenderer/CSSRendererView.cpp
trunk/themis/modules/CSSRenderer/CSSRendererView.hpp
trunk/themis/modules/CSSRenderer/CSSScrolledRendererView.cpp
trunk/themis/modules/CSSRenderer/CSSScrolledRendererView.hpp
trunk/themis/modules/CSSRenderer/CSSView.cpp
trunk/themis/modules/CSSRenderer/CSSView.hpp
Modified: trunk/themis/framework/win.cpp
===================================================================
--- trunk/themis/framework/win.cpp 2011-07-16 23:25:27 UTC (rev 662)
+++ trunk/themis/framework/win.cpp 2011-07-30 18:48:36 UTC (rev 663)
@@ -350,44 +350,67 @@
// stop, if there is no url, or about:blank
if ((url.Length() == 0) || (strcmp(url.String(), kAboutBlankPage) == 0))
break;
+
+ int32 siteId = 0;
+ msg->FindInt32("site_id", &siteId);
+ int32 urlId = 0;
+ msg->FindInt32("url_id", &urlId);
- uint32 selection = tabview->Selection();
- /* Get an unique ID from the app for the site entry*/
- int32 siteId = ((App *)be_app)->GetNewID();
- SiteEntry * siteEntry = new SiteEntry(siteId, url.String());
- /* Get an unique ID from the app for the url entry */
- int32 urlId = ((App *)be_app)->GetNewID();
- UrlEntry * urlEntry = new UrlEntry(urlId, url.String());
- siteEntry->addEntry(urlEntry);
- ((App *)be_app)->GetSiteHandler()->AddEntry(siteEntry);
+ bool visible;
+ if (msg->HasBool("visible")) {
+ msg->FindBool("visible", &visible);
+ }
+ else {
+ visible = true;
+ }
- ThemisTab * tab = NULL;
- if (msg->HasInt32("tab_to_open_in")) {
- int32 index = msg->FindInt32("tab_to_open_in");
- tab = (ThemisTab *) tabview->TabAt(index);
+ uint32 selection = 0;
+ if (visible) {
+ selection = tabview->Selection();
+ /* Get an unique ID from the app for the site entry*/
+ siteId = ((App *)be_app)->GetNewID();
+ SiteEntry * siteEntry = new SiteEntry(siteId, url.String());
+ /* Get an unique ID from the app for the url entry */
+ urlId = ((App *)be_app)->GetNewID();
+ UrlEntry * urlEntry = new UrlEntry(urlId, url.String());
+ siteEntry->addEntry(urlEntry);
+ ((App *)be_app)->GetSiteHandler()->AddEntry(siteEntry);
+
+ ThemisTab * tab = NULL;
+ if (msg->HasInt32("tab_to_open_in")) {
+ int32 index = msg->FindInt32("tab_to_open_in");
+ tab = (ThemisTab *) tabview->TabAt(index);
+ }
+ else {
+ tab = (ThemisTab *) tabview->TabAt(selection);
+ }
+ tab->SetSiteID(siteId);
+ // add history entry for tab
+ if(msg->HasBool("no_history_add") == false)
+ tab->GetHistory()->AddEntry(url.String());
+ BRect rect = tabview->Bounds();
+ siteEntry->SetSize(rect.Width() - 2, rect.Height() - 2);
+
+ /* add url to global history
+ * ( You ask, why I am also adding the url on RELOAD, and not only on URL_OPEN?
+ * Simple. Imagine a browser being open for longer then GlobalHistoryDepthInDays.
+ * The url would be deleted after this period of days. If the user would then reload
+ * the page, it would not be saved in the history. If he closes the browser, his url
+ * would be lost. Ok, this is somewhat unlikely, but could happen. )
+ */
+ ((App *)be_app)->GetGlobalHistory()->AddEntry(url.String());
}
else {
- tab = (ThemisTab *) tabview->TabAt(selection);
+ urlId = ((App *)be_app)->GetNewID();
+ UrlEntry * urlEntry = new UrlEntry(urlId, url.String());
+ SiteEntry * siteEntry = ((App *)be_app)->GetSiteHandler()->GetEntry(siteId);
+ siteEntry->addEntry(urlEntry);
}
- tab->SetSiteID(siteId);
- // add history entry for tab
- if(msg->HasBool("no_history_add") == false)
- tab->GetHistory()->AddEntry(url.String());
- BRect rect = tabview->Bounds();
- siteEntry->SetSize(rect.Width() - 2, rect.Height() - 2);
- /* add url to global history
- * ( You ask, why I am also adding the url on RELOAD, and not only on URL_OPEN?
- * Simple. Imagine a browser being open for longer then GlobalHistoryDepthInDays.
- * The url would be deleted after this period of days. If the user would then reload
- * the page, it would not be saved in the history. If he closes the browser, his url
- * would be lost. Ok, this is somewhat unlikely, but could happen. )
- */
- ((App *)be_app)->GetGlobalHistory()->AddEntry(url.String());
-
// I don't want to destroy anything working right now. So let's just
// get something new in.
+ printf("Url to load: %s\n", url.String());
BMessage * load = new BMessage(SH_RETRIEVE_START);
load->AddInt32("command", COMMAND_RETRIEVE);
load->AddInt32("site_id", siteId);
@@ -404,11 +427,12 @@
* Otherwise we wouldn't see any URL in UrlView during load.
* Sad, but true.
*/
-
- if (msg->FindBool("hidden") == true)
- tabview->DrawTabs();
- else
- tabview->Select(selection);
+ if (visible) {
+ if (msg->FindBool("hidden") == true)
+ tabview->DrawTabs();
+ else
+ tabview->Select(selection);
+ }
break;
}
Modified: trunk/themis/modules/CSSRenderer/CSSRenderer.cpp
===================================================================
--- trunk/themis/modules/CSSRenderer/CSSRenderer.cpp 2011-07-16 23:25:27 UTC (rev 662)
+++ trunk/themis/modules/CSSRenderer/CSSRenderer.cpp 2011-07-30 18:48:36 UTC (rev 663)
@@ -189,19 +189,21 @@
int width = 0;
int height = 0;
site->GetSize(width, height);
+ int32 urlId = 0;
+ aMessage->FindInt32("url_id", &urlId);
CSSScrolledRendererView * view =
new CSSScrolledRendererView(document,
stylesheet,
width,
- height);
+ height,
+ siteId,
+ urlId);
/* Get an unique ID from the app for the DOM entry */
int32 viewId = ((App *)be_app)->GetNewID();
BaseEntry * entry = new BaseEntry(viewId);
entry->set("render_view", (void *) view);
((App *)be_app)->GetSiteHandler()->AddEntry(entry, siteId, domEntry->getId());
- int32 urlId = 0;
- aMessage->FindInt32("url_id", &urlId);
//Do the Broadcasting to give the view to the UI
BMessage *message = new BMessage(SH_RENDER_FINISHED);
message->AddInt32("command", COMMAND_INFO);
Modified: trunk/themis/modules/CSSRenderer/CSSRendererView.cpp
===================================================================
--- trunk/themis/modules/CSSRenderer/CSSRendererView.cpp 2011-07-16 23:25:27 UTC (rev 662)
+++ trunk/themis/modules/CSSRenderer/CSSRendererView.cpp 2011-07-30 18:48:36 UTC (rev 663)
@@ -50,7 +50,9 @@
CSSRendererView :: CSSRendererView(BRect aFrame,
TDocumentPtr aDocument,
- CSSStyleSheetPtr aStyleSheet)
+ CSSStyleSheetPtr aStyleSheet,
+ int32 aSiteId,
+ int32 aUrlId)
: BView(aFrame,
"CSSRendererView",
B_FOLLOW_ALL_SIDES,
@@ -74,6 +76,8 @@
root,
mStyleSheets,
rect,
+ aSiteId,
+ aUrlId,
defaultColor);
printf("Doing layout\n");
mView->Layout(rect, BPoint(rect.left, rect.top));
@@ -125,6 +129,7 @@
}
Window()->SetTitle(title.c_str());
SetViewColor(B_TRANSPARENT_COLOR);
+// mView->RetrieveResources();
}
Modified: trunk/themis/modules/CSSRenderer/CSSRendererView.hpp
===================================================================
--- trunk/themis/modules/CSSRenderer/CSSRendererView.hpp 2011-07-16 23:25:27 UTC (rev 662)
+++ trunk/themis/modules/CSSRenderer/CSSRendererView.hpp 2011-07-30 18:48:36 UTC (rev 663)
@@ -65,7 +65,9 @@
public:
CSSRendererView(BRect aFrame,
TDocumentPtr aDocument,
- CSSStyleSheetPtr aStyleSheet);
+ CSSStyleSheetPtr aStyleSheet,
+ int32 aSiteId,
+ int32 aUrlId);
~CSSRendererView();
virtual void MouseDown(BPoint aPoint);
virtual void Draw(BRect aRect);
Modified: trunk/themis/modules/CSSRenderer/CSSScrolledRendererView.cpp
===================================================================
--- trunk/themis/modules/CSSRenderer/CSSScrolledRendererView.cpp 2011-07-16 23:25:27 UTC (rev 662)
+++ trunk/themis/modules/CSSRenderer/CSSScrolledRendererView.cpp 2011-07-30 18:48:36 UTC (rev 663)
@@ -60,7 +60,9 @@
CSSScrolledRendererView :: CSSScrolledRendererView(TDocumentPtr aDocument,
CSSStyleSheetPtr aStyleSheet,
float aWidth,
- float aHeight)
+ float aHeight,
+ int32 aSiteId,
+ int32 aUrlId)
: BView(BRect(0, 0, aWidth, aHeight),
"CSSScrolledRendererView",
B_FOLLOW_ALL_SIDES,
@@ -73,7 +75,7 @@
BRect rect = Bounds();
rect.bottom -= B_H_SCROLL_BAR_HEIGHT;
rect.right -= B_V_SCROLL_BAR_WIDTH;
- mView = new CSSRendererView(rect, mDocument, mStyleSheet);
+ mView = new CSSRendererView(rect, mDocument, mStyleSheet, aSiteId, aUrlId);
mScrollView = new BScrollView("CSS Scroll view",
mView,
B_FOLLOW_ALL_SIDES,
Modified: trunk/themis/modules/CSSRenderer/CSSScrolledRendererView.hpp
===================================================================
--- trunk/themis/modules/CSSRenderer/CSSScrolledRendererView.hpp 2011-07-16 23:25:27 UTC (rev 662)
+++ trunk/themis/modules/CSSRenderer/CSSScrolledRendererView.hpp 2011-07-30 18:48:36 UTC (rev 663)
@@ -67,7 +67,9 @@
CSSScrolledRendererView(TDocumentPtr aDocument,
CSSStyleSheetPtr aStyleSheet,
float aWidth,
- float aHeight);
+ float aHeight,
+ int32 aSiteId,
+ int32 aUrlId);
~CSSScrolledRendererView();
void FrameResized(float aWidth, float aHeight);
void MessageReceived(BMessage * aMessage);
Modified: trunk/themis/modules/CSSRenderer/CSSView.cpp
===================================================================
--- trunk/themis/modules/CSSRenderer/CSSView.cpp 2011-07-16 23:25:27 UTC (rev 662)
+++ trunk/themis/modules/CSSRenderer/CSSView.cpp 2011-07-30 18:48:36 UTC (rev 663)
@@ -70,6 +70,8 @@
TNodePtr aNode,
CSSStyleContainer * aStyleSheets,
BRect aRect,
+ int32 aSiteId,
+ int32 aUrlId,
rgb_color aColor,
BFont * aFont)
: BHandler("CSSView") {
@@ -78,6 +80,8 @@
mNode = aNode;
mStyleSheets = aStyleSheets;
mRect = aRect;
+ mSiteId = aSiteId;
+ mUrlId = aUrlId;
mDisplay = true;
mBlock = true;
mTable = false;
@@ -117,7 +121,7 @@
}
else if (mNode->getNodeType() == ELEMENT_NODE) {
TElementPtr element = shared_static_cast<TElement>(mNode);
- if (mNode->getNodeName() == "A") {
+ if (mName == "A") {
// Only A can have a href for a hyperlink, so it is hardcoded here.
if (element->hasAttribute("HREF")) {
mHref = element->getAttribute("HREF");
@@ -133,6 +137,8 @@
child,
mStyleSheets,
mRect,
+ mSiteId,
+ mUrlId,
mColor,
mFont);
mChildren.push_back(childView);
@@ -152,6 +158,15 @@
SplitText();
}
+ else if (mNode->getNodeType() == ELEMENT_NODE) {
+ TElementPtr element = shared_static_cast<TElement>(mNode);
+ if (mName == "IMG") {
+ // Images have the image source in the src attribute.
+ if (element->hasAttribute("SRC")) {
+ mHref = element->getAttribute("SRC");
+ }
+ }
+ }
}
@@ -170,7 +185,7 @@
}
-void CSSView :: RetrieveLink() {
+void CSSView :: RetrieveLink(bool aVisible) {
if (mHref.size() > 0) {
// Send a message to the window.
@@ -201,7 +216,10 @@
}
urlString += mHref;
BMessage message(URL_OPEN);
+ message.AddInt32("site_id", mSiteId);
+ message.AddInt32("url_id", mUrlId);
message.AddString("url_to_open", urlString.c_str());
+ message.AddBool("visible", aVisible);
BMessenger messenger(NULL, mBaseView->Window());
messenger.SendMessage(&message);
}
@@ -733,3 +751,20 @@
}
}
+
+void CSSView :: RetrieveResources() {
+
+// printf("Retrieving resources in %s with href %s\n", mName.c_str(), mHref.c_str());
+ if (mHref != "" && !mClickable) {
+ // Some resource that must be loaded.
+ printf("Retrieving %s\n", mHref.c_str());
+ RetrieveLink(false);
+ }
+
+ unsigned int length = mChildren.size();
+ for (unsigned int i = 0; i < length; i++) {
+ CSSView * childView = mChildren[i];
+ childView->RetrieveResources();
+ }
+
+}
Modified: trunk/themis/modules/CSSRenderer/CSSView.hpp
===================================================================
--- trunk/themis/modules/CSSRenderer/CSSView.hpp 2011-07-16 23:25:27 UTC (rev 662)
+++ trunk/themis/modules/CSSRenderer/CSSView.hpp 2011-07-30 18:48:36 UTC (rev 663)
@@ -47,6 +47,7 @@
#include <Handler.h>
#include <Rect.h>
#include <Point.h>
+#include <be/interface/GraphicsDefs.h>
// DOM headers
#include "DOMSupport.h"
@@ -98,8 +99,10 @@
string mBorderStyle;
float mBorderWidth;
BRect mListStyleRect;
+ int32 mSiteId;
+ int32 mUrlId;
- void RetrieveLink();
+ void RetrieveLink(bool aVisible = true);
protected:
void ApplyStyle(const TElementPtr aElement);
@@ -109,6 +112,8 @@
TNodePtr aNode,
CSSStyleContainer * aStyleSheets,
BRect aRect,
+ int32 aSiteId,
+ int32 aUrlId,
rgb_color aColor,
BFont * aFont = NULL);
~CSSView();
@@ -120,10 +125,10 @@
bool IsClickable();
BRect Bounds();
BPoint GetEndPoint();
- void Layout(BRect aRect,
- BPoint aStartingPoint);
+ virtual void Layout(BRect aRect,
+ BPoint aStartingPoint);
void SplitText();
- CSSStyleDeclarationPtr GetComputedStyle(const TElementPtr aElement);
+ void RetrieveResources();
};
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|