aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llwebbrowserctrl.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:54 -0500
committerJacek Antonelli2008-08-15 23:44:54 -0500
commitb2afb8800bb033a04bb3ecdf0363068d56648ef1 (patch)
tree3568129b5bbddb47cd39d622b4137a8fbff4abaf /linden/indra/newview/llwebbrowserctrl.cpp
parentSecond Life viewer sources 1.14.0.1 (diff)
downloadmeta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.zip
meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.gz
meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.bz2
meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.xz
Second Life viewer sources 1.15.0.2
Diffstat (limited to 'linden/indra/newview/llwebbrowserctrl.cpp')
-rw-r--r--linden/indra/newview/llwebbrowserctrl.cpp98
1 files changed, 60 insertions, 38 deletions
diff --git a/linden/indra/newview/llwebbrowserctrl.cpp b/linden/indra/newview/llwebbrowserctrl.cpp
index 7df2da4..bd671fa 100644
--- a/linden/indra/newview/llwebbrowserctrl.cpp
+++ b/linden/indra/newview/llwebbrowserctrl.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2006-2007, Linden Research, Inc. 5 * Copyright (c) 2006-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -50,8 +51,10 @@ LLWebBrowserCtrl::LLWebBrowserCtrl( const std::string& name, const LLRect& rect
50 mBorder(NULL), 51 mBorder(NULL),
51 mFrequentUpdates( true ), 52 mFrequentUpdates( true ),
52 mOpenLinksInExternalBrowser( false ), 53 mOpenLinksInExternalBrowser( false ),
54 mOpenSecondLifeLinksInMap( true ),
53 mHomePageUrl( "" ), 55 mHomePageUrl( "" ),
54 mIgnoreUIScale( true ) 56 mIgnoreUIScale( true ),
57 mAlwaysRefresh( false )
55{ 58{
56 S32 screen_width = mIgnoreUIScale ? llround((F32)mRect.getWidth() * LLUI::sGLScaleFactor.mV[VX]) : mRect.getWidth(); 59 S32 screen_width = mIgnoreUIScale ? llround((F32)mRect.getWidth() * LLUI::sGLScaleFactor.mV[VX]) : mRect.getWidth();
57 S32 screen_height = mIgnoreUIScale ? llround((F32)mRect.getHeight() * LLUI::sGLScaleFactor.mV[VY]) : mRect.getHeight(); 60 S32 screen_height = mIgnoreUIScale ? llround((F32)mRect.getHeight() * LLUI::sGLScaleFactor.mV[VY]) : mRect.getHeight();
@@ -63,12 +66,11 @@ LLWebBrowserCtrl::LLWebBrowserCtrl( const std::string& name, const LLRect& rect
63 // the locale to protect it, as exotic/non-C locales 66 // the locale to protect it, as exotic/non-C locales
64 // causes our code lots of general critical weirdness 67 // causes our code lots of general critical weirdness
65 // and crashness. (SL-35450) 68 // and crashness. (SL-35450)
66 char *saved_locale = setlocale(LC_ALL, NULL); 69 std::string saved_locale = setlocale(LC_ALL, NULL);
67#endif // LL_LINUX 70#endif // LL_LINUX
68 mEmbeddedBrowserWindowId = LLMozLib::getInstance()->createBrowserWindow( gViewerWindow->getPlatformWindow(), screen_width, screen_height ); 71 mEmbeddedBrowserWindowId = LLMozLib::getInstance()->createBrowserWindow( gViewerWindow->getPlatformWindow(), screen_width, screen_height );
69#if LL_LINUX 72#if LL_LINUX
70 if (saved_locale) 73 setlocale(LC_ALL, saved_locale.c_str() );
71 setlocale(LC_ALL, saved_locale);
72#endif // LL_LINUX 74#endif // LL_LINUX
73 } 75 }
74 76
@@ -133,6 +135,13 @@ void LLWebBrowserCtrl::setOpenInExternalBrowser( bool valIn )
133}; 135};
134 136
135//////////////////////////////////////////////////////////////////////////////// 137////////////////////////////////////////////////////////////////////////////////
138// open secondlife:// links in map automatically or not
139void LLWebBrowserCtrl::setOpenSecondLifeLinksInMap( bool valIn )
140{
141 mOpenSecondLifeLinksInMap = valIn;
142};
143
144////////////////////////////////////////////////////////////////////////////////
136// 145//
137BOOL LLWebBrowserCtrl::handleHover( S32 x, S32 y, MASK mask ) 146BOOL LLWebBrowserCtrl::handleHover( S32 x, S32 y, MASK mask )
138{ 147{
@@ -163,7 +172,7 @@ BOOL LLWebBrowserCtrl::handleMouseUp( S32 x, S32 y, MASK mask )
163 convertInputCoords(x, y); 172 convertInputCoords(x, y);
164 LLMozLib::getInstance()->mouseUp( mEmbeddedBrowserWindowId, x, y ); 173 LLMozLib::getInstance()->mouseUp( mEmbeddedBrowserWindowId, x, y );
165 174
166 gViewerWindow->setMouseCapture( 0, 0 ); 175 gViewerWindow->setMouseCapture( NULL );
167 176
168 return TRUE; 177 return TRUE;
169} 178}
@@ -175,7 +184,7 @@ BOOL LLWebBrowserCtrl::handleMouseDown( S32 x, S32 y, MASK mask )
175 convertInputCoords(x, y); 184 convertInputCoords(x, y);
176 LLMozLib::getInstance()->mouseDown( mEmbeddedBrowserWindowId, x, y ); 185 LLMozLib::getInstance()->mouseDown( mEmbeddedBrowserWindowId, x, y );
177 186
178 gViewerWindow->setMouseCapture( this, 0 ); 187 gViewerWindow->setMouseCapture( this );
179 188
180 setFocus( TRUE ); 189 setFocus( TRUE );
181 190
@@ -198,6 +207,8 @@ void LLWebBrowserCtrl::onFocusLost()
198 LLMozLib::getInstance()->focusBrowser( mEmbeddedBrowserWindowId, false ); 207 LLMozLib::getInstance()->focusBrowser( mEmbeddedBrowserWindowId, false );
199 208
200 gViewerWindow->focusClient(); 209 gViewerWindow->focusClient();
210
211 LLUICtrl::onFocusLost();
201} 212}
202 213
203//////////////////////////////////////////////////////////////////////////////// 214////////////////////////////////////////////////////////////////////////////////
@@ -516,38 +527,48 @@ void LLWebBrowserCtrl::onClickLinkSecondLife( const EventType& eventIn )
516 { 527 {
517 if ( LLString::compareInsensitive( eventIn.getStringValue().substr( 0, protocol.length() ).c_str(), protocol.c_str() ) == 0 ) 528 if ( LLString::compareInsensitive( eventIn.getStringValue().substr( 0, protocol.length() ).c_str(), protocol.c_str() ) == 0 )
518 { 529 {
519 // parse out sim name and coordinates 530 if ( mOpenSecondLifeLinksInMap )
520 LLURLSimString::setString( eventIn.getStringValue() );
521 LLURLSimString::parse();
522
523 // if there is a world map
524 if ( gFloaterWorldMap )
525 { 531 {
526 #if ! LL_RELEASE_FOR_DOWNLOAD 532 openMapAtlocation( eventIn.getStringValue() );
527 llinfos << "MOZ> opening map to " << LLURLSimString::sInstance.mSimName.c_str() << " at " << LLURLSimString::sInstance.mX << "," << LLURLSimString::sInstance.mY << "," << LLURLSimString::sInstance.mZ << llendl;
528 #endif
529
530 // mark where the destination is
531 gFloaterWorldMap->trackURL( LLURLSimString::sInstance.mSimName.c_str(),
532 LLURLSimString::sInstance.mX,
533 LLURLSimString::sInstance.mY,
534 LLURLSimString::sInstance.mZ );
535
536 // display map
537 LLFloaterWorldMap::show( NULL, TRUE );
538 }
539 else
540 // if there is no world map, assume we're on the login page.. (this might be bad but I don't see a way to tell if you're at login or not)
541 {
542 // refresh the login page and force the location combo box to be visible
543 LLPanelLogin::refreshLocation( true );
544 }; 533 };
534
535 // chain this event on to observers of an instance of LLWebBrowserCtrl
536 LLWebBrowserCtrlEvent event( eventIn.getStringValue() );
537 mEventEmitter.update( &LLWebBrowserCtrlObserver::onClickLinkSecondLife, event );
545 }; 538 };
546 }; 539 };
540}
547 541
548 // chain this event on to observers of an instance of LLWebBrowserCtrl 542////////////////////////////////////////////////////////////////////////////////
549 LLWebBrowserCtrlEvent event( eventIn.getStringValue() ); 543// virtual
550 mEventEmitter.update( &LLWebBrowserCtrlObserver::onClickLinkSecondLife, event ); 544void LLWebBrowserCtrl::openMapAtlocation( std::string second_life_url )
545{
546 // parse out sim name and coordinates
547 LLURLSimString::setString( second_life_url );
548 LLURLSimString::parse();
549
550 // if there is a world map
551 if ( gFloaterWorldMap )
552 {
553 #if ! LL_RELEASE_FOR_DOWNLOAD
554 llinfos << "MOZ> opening map to " << LLURLSimString::sInstance.mSimName.c_str() << " at " << LLURLSimString::sInstance.mX << "," << LLURLSimString::sInstance.mY << "," << LLURLSimString::sInstance.mZ << llendl;
555 #endif
556
557 // mark where the destination is
558 gFloaterWorldMap->trackURL( LLURLSimString::sInstance.mSimName.c_str(),
559 LLURLSimString::sInstance.mX,
560 LLURLSimString::sInstance.mY,
561 LLURLSimString::sInstance.mZ );
562
563 // display map
564 LLFloaterWorldMap::show( NULL, TRUE );
565 }
566 else
567 // if there is no world map, assume we're on the login page.. (this might be bad but I don't see a way to tell if you're at login or not)
568 {
569 // refresh the login page and force the location combo box to be visible
570 LLPanelLogin::refreshLocation( true );
571 };
551} 572}
552 573
553//////////////////////////////////////////////////////////////////////////////// 574////////////////////////////////////////////////////////////////////////////////
@@ -575,7 +596,7 @@ LLWebBrowserTexture::~LLWebBrowserTexture()
575BOOL LLWebBrowserTexture::render() 596BOOL LLWebBrowserTexture::render()
576{ 597{
577 // frequent updates turned on? 598 // frequent updates turned on?
578 if ( mWebBrowserCtrl->getFrequentUpdates() ) 599 if ( mWebBrowserCtrl->getFrequentUpdates() || mWebBrowserCtrl->getAlwaysRefresh() )
579 { 600 {
580 // only update mozilla/texture occasionally 601 // only update mozilla/texture occasionally
581 if ( mElapsedTime.getElapsedTimeF32() > ( 1.0f / 15.0f ) ) 602 if ( mElapsedTime.getElapsedTimeF32() > ( 1.0f / 15.0f ) )
@@ -591,12 +612,13 @@ BOOL LLWebBrowserTexture::render()
591 if ( actual_rowspan < 1 || browser_depth < 2 ) 612 if ( actual_rowspan < 1 || browser_depth < 2 )
592 return FALSE; 613 return FALSE;
593 614
615 // width can change after it's rendered - (Mozilla bug# 24721)
594 S32 pagebuffer_width = actual_rowspan / browser_depth; 616 S32 pagebuffer_width = actual_rowspan / browser_depth;
595 617
618 // Browser depth hasn't changed.
596 if(mLastBrowserDepth == browser_depth) 619 if(mLastBrowserDepth == browser_depth)
597 { 620 {
598 // Browser depth hasn't changed. Just grab the pixels. 621 // Just grab the pixels.
599
600 mTexture->setSubImage( pixels, 622 mTexture->setSubImage( pixels,
601 pagebuffer_width, mBrowserHeight, 623 pagebuffer_width, mBrowserHeight,
602 0, 0, pagebuffer_width, mBrowserHeight ); 624 0, 0, pagebuffer_width, mBrowserHeight );
@@ -605,7 +627,7 @@ BOOL LLWebBrowserTexture::render()
605 { 627 {
606 // Browser depth has changed -- need to recreate texture to match. 628 // Browser depth has changed -- need to recreate texture to match.
607 resize(mBrowserWidth, mBrowserHeight); 629 resize(mBrowserWidth, mBrowserHeight);
608 } 630 };
609 }; 631 };
610 }; 632 };
611 633