summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLynx Linden <lynx@lindenlab.com>2010-01-26 13:09:26 +0000
committerLynx Linden <lynx@lindenlab.com>2010-01-26 13:09:26 +0000
commit0a38adfd8af7d95627cd43e44901b9ae4e4e2d29 (patch)
tree8d84c992a705d3e6f52579d760036c8791f16359
parentfbf605ea321ee29afad63a4afe47f65584d67eea (diff)
EXT-4678: Don't hyperlink sim URLs in About window.
Added support for specifying a black list of URLs on a per-widget basis. URLs on this black list will not be hyperlinked in the text widget. The About dialog adds the sim hostname to this black list.
-rw-r--r--indra/llui/lltextbase.cpp46
-rw-r--r--indra/llui/lltextbase.h8
-rw-r--r--indra/newview/llfloaterabout.cpp6
3 files changed, 51 insertions, 9 deletions
diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index 47db990a37..ab0d9b2221 100644
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -1511,6 +1511,25 @@ void LLTextBase::setText(const LLStringExplicit &utf8str, const LLStyle::Params&
onValueChange(0, getLength());
}
+void LLTextBase::addBlackListUrl(const std::string &url)
+{
+ mBlackListUrls.push_back(url);
+}
+
+bool LLTextBase::isBlackListUrl(const std::string &url) const
+{
+ std::vector<std::string>::const_iterator it;
+ for (it = mBlackListUrls.begin(); it != mBlackListUrls.end(); ++it)
+ {
+ const std::string &blacklist_url = *it;
+ if (url.find(blacklist_url) != std::string::npos)
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
//virtual
std::string LLTextBase::getText() const
{
@@ -1585,20 +1604,29 @@ void LLTextBase::appendText(const std::string &new_text, bool prepend_newline, c
prepend_newline = false;
}
}
- // output the styled Url
- appendAndHighlightText(match.getLabel(), prepend_newline, part, link_params);
- prepend_newline = false;
- // set the tooltip for the Url label
- if (! match.getTooltip().empty())
+ // output the styled Url (unless we've been asked to suppress it)
+ if (isBlackListUrl(match.getUrl()))
+ {
+ std::string orig_url = text.substr(start, end-start);
+ appendAndHighlightText(orig_url, prepend_newline, part, style_params);
+ }
+ else
{
- segment_set_t::iterator it = getSegIterContaining(getLength()-1);
- if (it != mSegments.end())
+ appendAndHighlightText(match.getLabel(), prepend_newline, part, link_params);
+
+ // set the tooltip for the Url label
+ if (! match.getTooltip().empty())
{
- LLTextSegmentPtr segment = *it;
- segment->setToolTip(match.getTooltip());
+ segment_set_t::iterator it = getSegIterContaining(getLength()-1);
+ if (it != mSegments.end())
+ {
+ LLTextSegmentPtr segment = *it;
+ segment->setToolTip(match.getTooltip());
+ }
}
}
+ prepend_newline = false;
// move on to the rest of the text after the Url
if (end < (S32)text.length())
diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h
index 038b9eaa62..e1c6cc36ab 100644
--- a/indra/llui/lltextbase.h
+++ b/indra/llui/lltextbase.h
@@ -41,6 +41,7 @@
#include "llpanel.h"
#include <string>
+#include <vector>
#include <set>
#include <boost/signals2.hpp>
@@ -186,6 +187,9 @@ public:
const LLFontGL* getDefaultFont() const { return mDefaultFont; }
LLStyle::Params getDefaultStyle();
+ // tell the text object to suppress auto highlighting of a specific URL
+ void addBlackListUrl(const std::string &url);
+
public:
// Fired when a URL link is clicked
commit_signal_t mURLClickSignal;
@@ -308,6 +312,7 @@ protected:
void updateRects();
void needsScroll() { mScrollNeeded = TRUE; }
void replaceUrlLabel(const std::string &url, const std::string &label);
+ bool isBlackListUrl(const std::string &url) const;
protected:
// text segmentation and flow
@@ -359,6 +364,9 @@ protected:
LLView* mDocumentView;
class LLScrollContainer* mScroller;
+ // list of URLs to suppress from automatic hyperlinking
+ std::vector<std::string> mBlackListUrls;
+
// transient state
bool mReflowNeeded; // need to reflow text because of change to text contents or display region
bool mScrollNeeded; // need to change scroll region because of change to cursor position
diff --git a/indra/newview/llfloaterabout.cpp b/indra/newview/llfloaterabout.cpp
index ef69f39ad2..04f4ddf996 100644
--- a/indra/newview/llfloaterabout.cpp
+++ b/indra/newview/llfloaterabout.cpp
@@ -187,6 +187,12 @@ BOOL LLFloaterAbout::postBuild()
support << '\n' << getString("AboutTraffic", args);
}
+ // don't make the sim hostname be a hyperlink
+ if (info.has("HOSTNAME"))
+ {
+ support_widget->addBlackListUrl(info["HOSTNAME"].asString());
+ }
+
support_widget->appendText(support.str(),
FALSE,
LLStyle::Params()