Skip to content

Commit cefee59

Browse files
authored
Improved open performance for some web based UI floaters by preloading the web content during login (#4574)
* First phase of some work to replace certain UI web based floaters with a much more simple floater (no more browserish web-content-floater) and then pre-load content as login is progressing. This means that after login, the floater can be opened much more rapidly than now. This first commit does this process for the Search floater * This commit brings in a new marketplace floater than hosts the marketplace web page (no more webcontent floater here either). It works as expected and opens quickly but the user is not logged in when the page is opened so that needs to be tackled before we can declare that this is a viable solution * This commit introduces a way to set the openID cookie that arrives via login.cgi into all the instances that are preloaded - the result is that when you open the preloaded floater after login, you are logged into your linden account * Fix a mac only warning as error - function overrides a member function but is not marked 'override' * Marchcat spotted left over cruft from earlier dev when we used a trimmed down URL for the pre-load search. Now we use the same search URL throughout and zero out the query parameters
1 parent 1022be6 commit cefee59

23 files changed

+289
-387
lines changed

indra/newview/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ set(viewer_SOURCE_FILES
393393
llmaniprotate.cpp
394394
llmanipscale.cpp
395395
llmaniptranslate.cpp
396+
llfloatermarketplace.cpp
396397
llmarketplacefunctions.cpp
397398
llmarketplacenotifications.cpp
398399
llmaterialeditor.cpp
@@ -930,6 +931,7 @@ set(viewer_HEADER_FILES
930931
llfloaterlinkreplace.h
931932
llfloaterloadprefpreset.h
932933
llfloatermap.h
934+
llfloatermarketplace.h
933935
llfloatermarketplacelistings.h
934936
llfloatermediasettings.h
935937
llfloatermemleak.h
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* @file llfloatermarketplace.cpp
3+
* @brief floater for the Marketplace web site
4+
*
5+
* $LicenseInfo:firstyear=2011&license=viewerlgpl$
6+
* Second Life Viewer Source Code
7+
* Copyright (C) 2011, Linden Research, Inc.
8+
*
9+
* This library is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation;
12+
* version 2.1 of the License only.
13+
*
14+
* This library is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with this library; if not, write to the Free Software
21+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22+
*
23+
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
24+
* $/LicenseInfo$
25+
*/
26+
27+
#include "llviewerprecompiledheaders.h"
28+
29+
#include "llfloatermarketplace.h"
30+
#include "lluictrlfactory.h"
31+
32+
LLFloaterMarketplace::LLFloaterMarketplace(const LLSD& key)
33+
: LLFloater(key)
34+
{
35+
}
36+
37+
LLFloaterMarketplace::~LLFloaterMarketplace()
38+
{
39+
}
40+
41+
bool LLFloaterMarketplace::postBuild()
42+
{
43+
enableResizeCtrls(true, true, false);
44+
return true;
45+
}
46+
47+

indra/newview/llfloatermarketplace.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* @file llfloatermarketplace.h
3+
* @brief floater for the Marketplace web site
4+
*
5+
* $LicenseInfo:firstyear=2011&license=viewerlgpl$
6+
* Second Life Viewer Source Code
7+
* Copyright (C) 2011, Linden Research, Inc.
8+
*
9+
* This library is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation;
12+
* version 2.1 of the License only.
13+
*
14+
* This library is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with this library; if not, write to the Free Software
21+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22+
*
23+
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
24+
* $/LicenseInfo$
25+
*/
26+
27+
#pragma once
28+
29+
#include "llfloater.h"
30+
31+
class LLFloaterMarketplace:
32+
public LLFloater
33+
{
34+
friend class LLFloaterReg;
35+
private:
36+
LLFloaterMarketplace(const LLSD& key);
37+
~LLFloaterMarketplace();
38+
bool postBuild() override;
39+
};
40+

indra/newview/llfloatersearch.cpp

Lines changed: 72 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
/**
22
* @file llfloatersearch.cpp
3-
* @author Martin Reddy
4-
* @brief Search floater - uses an embedded web browser control
3+
* @brief Floater for Search (update 2025, preload)
54
*
6-
* $LicenseInfo:firstyear=2009&license=viewerlgpl$
5+
* $LicenseInfo:firstyear=2011&license=viewerlgpl$
76
* Second Life Viewer Source Code
8-
* Copyright (C) 2010, Linden Research, Inc.
7+
* Copyright (C) 2011, Linden Research, Inc.
98
*
109
* This library is free software; you can redistribute it and/or
1110
* modify it under the terms of the GNU Lesser General Public
@@ -27,68 +26,34 @@
2726

2827
#include "llviewerprecompiledheaders.h"
2928

29+
#include "llfloatersearch.h"
30+
31+
#include "llagent.h"
3032
#include "llcommandhandler.h"
3133
#include "llfloaterreg.h"
32-
#include "llfloatersearch.h"
33-
#include "llhttpconstants.h"
3434
#include "llmediactrl.h"
35-
#include "llnotificationsutil.h"
36-
#include "lllogininstance.h"
37-
#include "lluri.h"
38-
#include "llagent.h"
39-
#include "llui.h"
35+
#include "lluictrlfactory.h"
4036
#include "llviewercontrol.h"
4137
#include "llweb.h"
4238

4339
// support secondlife:///app/search/{CATEGORY}/{QUERY} SLapps
44-
class LLSearchHandler : public LLCommandHandler
45-
{
46-
public:
47-
// requires trusted browser to trigger
48-
LLSearchHandler() : LLCommandHandler("search", UNTRUSTED_CLICK_ONLY) { }
49-
bool handle(const LLSD& tokens, const LLSD& query_map, const std::string& grid, LLMediaCtrl* web)
50-
{
51-
const size_t parts = tokens.size();
52-
53-
// get the (optional) category for the search
54-
std::string collection;
55-
if (parts > 0)
56-
{
57-
collection = tokens[0].asString();
40+
class LLSearchHandler : public LLCommandHandler {
41+
public:
42+
// requires trusted browser to trigger
43+
LLSearchHandler() : LLCommandHandler("search", UNTRUSTED_CLICK_ONLY) { }
44+
bool handle(const LLSD& tokens, const LLSD& query_map, const std::string& grid, LLMediaCtrl* web) {
45+
const size_t parts = tokens.size();
46+
47+
// open the search floater and perform the requested search
48+
LLFloaterReg::showInstance("search", tokens);
49+
return true;
5850
}
59-
60-
// get the (optional) search string
61-
std::string search_text;
62-
if (parts > 1)
63-
{
64-
search_text = tokens[1].asString();
65-
}
66-
67-
// create the LLSD arguments for the search floater
68-
LLFloaterSearch::Params p;
69-
p.search.collection = collection;
70-
p.search.query = LLURI::unescape(search_text);
71-
72-
// open the search floater and perform the requested search
73-
LLFloaterReg::showInstance("search", p);
74-
return true;
75-
}
7651
};
7752
LLSearchHandler gSearchHandler;
7853

79-
LLFloaterSearch::SearchQuery::SearchQuery()
80-
: category("category", ""),
81-
collection("collection", ""),
82-
query("query")
83-
{}
84-
85-
LLFloaterSearch::LLFloaterSearch(const Params& key) :
86-
LLFloaterWebContent(key),
87-
mSearchGodLevel(0)
54+
LLFloaterSearch::LLFloaterSearch(const LLSD& key)
55+
: LLFloater(key)
8856
{
89-
// declare a map that transforms a category name into
90-
// the URL suffix that is used to search that category
91-
9257
mSearchType.insert("standard");
9358
mSearchType.insert("land");
9459
mSearchType.insert("classified");
@@ -100,76 +65,61 @@ LLFloaterSearch::LLFloaterSearch(const Params& key) :
10065
mCollectionType.insert("people");
10166
}
10267

103-
bool LLFloaterSearch::postBuild()
68+
LLFloaterSearch::~LLFloaterSearch()
10469
{
105-
LLFloaterWebContent::postBuild();
106-
mWebBrowser->addObserver(this);
107-
108-
return true;
10970
}
11071

111-
void LLFloaterSearch::onOpen(const LLSD& key)
72+
void LLFloaterSearch::onOpen(const LLSD& tokens)
11273
{
113-
Params p(key);
114-
p.trusted_content = true;
115-
p.allow_address_entry = false;
116-
117-
LLFloaterWebContent::onOpen(p);
118-
mWebBrowser->setFocus(true);
119-
search(p.search);
74+
initiateSearch(tokens);
12075
}
12176

122-
void LLFloaterSearch::onClose(bool app_quitting)
77+
void LLFloaterSearch::initiateSearch(const LLSD& tokens)
12378
{
124-
LLFloaterWebContent::onClose(app_quitting);
125-
// tear down the web view so we don't show the previous search
126-
// result when the floater is opened next time
127-
destroy();
128-
}
79+
std::string url = gSavedSettings.getString("SearchURL");
12980

130-
void LLFloaterSearch::godLevelChanged(U8 godlevel)
131-
{
132-
// search results can change based upon god level - if the user
133-
// changes god level, then give them a warning (we don't refresh
134-
// the search as this might undo any page navigation or
135-
// AJAX-driven changes since the last search).
81+
LLSD subs;
13682

137-
//FIXME: set status bar text
83+
// Setting this substitution here results in a full set of collections being
84+
// substituted into the final URL using the logic from the original search.
85+
subs["TYPE"] = "standard";
13886

139-
//getChildView("refresh_search")->setVisible( (godlevel != mSearchGodLevel));
140-
}
87+
const size_t parts = tokens.size();
14188

142-
void LLFloaterSearch::search(const SearchQuery &p)
143-
{
144-
if (! mWebBrowser || !p.validateBlock())
89+
// get the (optional) category for the search
90+
std::string collection;
91+
if (parts > 0)
14592
{
146-
return;
93+
collection = tokens[0].asString();
14794
}
14895

149-
// reset the god level warning as we're sending the latest state
150-
getChildView("refresh_search")->setVisible(false);
151-
mSearchGodLevel = gAgent.getGodLevel();
96+
// get the (optional) search string
97+
std::string search_text;
98+
if (parts > 1)
99+
{
100+
search_text = tokens[1].asString();
101+
}
152102

153-
// work out the subdir to use based on the requested category
154-
LLSD subs;
155-
if (mSearchType.find(p.category) != mSearchType.end())
103+
// TODO: where does category get set? I cannot find a reference to
104+
// it in internal docs - might be conflated with values in mSearchType
105+
std::string category;
106+
if (mSearchType.find(category) != mSearchType.end())
156107
{
157-
subs["TYPE"] = p.category;
108+
subs["TYPE"] = category;
158109
}
159110
else
160111
{
161112
subs["TYPE"] = "standard";
162113
}
163114

164-
// add the search query string
165-
subs["QUERY"] = LLURI::escape(p.query);
115+
subs["QUERY"] = LLURI::escape(search_text);
166116

167117
subs["COLLECTION"] = "";
168118
if (subs["TYPE"] == "standard")
169119
{
170-
if (mCollectionType.find(p.collection) != mCollectionType.end())
120+
if (mCollectionType.find(collection) != mCollectionType.end())
171121
{
172-
subs["COLLECTION"] = "&collection_chosen=" + std::string(p.collection);
122+
subs["COLLECTION"] = "&collection_chosen=" + std::string(collection);
173123
}
174124
else
175125
{
@@ -182,30 +132,41 @@ void LLFloaterSearch::search(const SearchQuery &p)
182132
}
183133
}
184134

185-
// add the user's preferred maturity (can be changed via prefs)
186-
std::string maturity;
135+
// Default to PG
136+
std::string maturity = "g";
187137
if (gAgent.prefersAdult())
188138
{
189-
maturity = "gma"; // PG,Mature,Adult
139+
// PG,Mature,Adult
140+
maturity = "gma";
190141
}
191142
else if (gAgent.prefersMature())
192143
{
193-
maturity = "gm"; // PG,Mature
194-
}
195-
else
196-
{
197-
maturity = "g"; // PG
144+
// PG,Mature
145+
maturity = "gm";
198146
}
199147
subs["MATURITY"] = maturity;
200148

201-
// add the user's god status
149+
// God status
202150
subs["GODLIKE"] = gAgent.isGodlike() ? "1" : "0";
203151

204-
// get the search URL and expand all of the substitutions
205-
// (also adds things like [LANGUAGE], [VERSION], [OS], etc.)
206-
std::string url = gSavedSettings.getString("SearchURL");
152+
// This call expands a set of generic substitutions like language, viewer version
153+
// etc. and then also does the same with the list of subs passed in.
207154
url = LLWeb::expandURLSubstitutions(url, subs);
208155

209-
// and load the URL in the web view
210-
mWebBrowser->navigateTo(url, HTTP_CONTENT_TEXT_HTML);
156+
// Naviation to the calculated URL - we know it's HTML so we can
157+
// tell the media system not to bother with the MIME type check.
158+
LLMediaCtrl* search_browser = findChild<LLMediaCtrl>("search_contents");
159+
search_browser->navigateTo(url, HTTP_CONTENT_TEXT_HTML);
160+
}
161+
162+
bool LLFloaterSearch::postBuild()
163+
{
164+
enableResizeCtrls(true, true, false);
165+
166+
// This call is actioned by the preload code in llViewerWindow
167+
// that creates the search floater during the login process
168+
// using a generic search with no query
169+
initiateSearch(LLSD());
170+
171+
return true;
211172
}

0 commit comments

Comments
 (0)