Changeset 8

Show
Ignore:
Timestamp:
02/29/08 19:32:35 (2 years ago)
Author:
rob.linden
Message:

Latest internal snapshot
Last Changed Rev: 80909
Last Changed Date: 2008-02-27 15:08:55 -0800 (Wed, 27 Feb 2008)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/llmozlib2/README-linux-linden.txt

    r1 r8  
    6767Probably only of interest if you're a Second Life developer! 
    6868 
    69 1. copy llmozlib.h to ${SLSRC}/libraries/include/ 
    70 2. copy libllmozlib.a to ${SLSRC}/libraries/i686-linux/lib_release_client/ 
     691. copy llmozlib2.h to ${SLSRC}/libraries/include/ 
     702. copy libllmozlib2.a to ${SLSRC}/libraries/i686-linux/lib_release_client/ 
    71713. copy libraries/i686-linux/lib_release/libprofdirserviceprovider_s.a to ${SLSRC}/libraries/i686-linux/lib_release_client/ 
    72724. copy libraries/i686-linux/runtime_release to ${SLSRC}/indra/newview/app_settings/mozilla-runtime-linux-i686 
  • trunk/llmozlib2/README-linux.txt

    r1 r8  
    34341. ./build-linux-llmozlib.sh 
    3535 
    36 This simple builder-script will build the libllmozlib.a library. 
     36This simple builder-script will build the libllmozlib2.a library. 
    3737 
    38383. BUILDING THE TEST APPLICATIONS 
     
    4646downloaded from http://glui.sourceforge.net/ 
    4747 
    48 0. Edit tests/ubrowser.llmozlib/ubrowser-linux-build.sh 
     480. Edit tests/ubrowser/ubrowser-linux-build.sh 
    4949   * Change CXX if appropriate. 
    50 1. cd tests/ubrowser.llmozlib
     501. cd tests/ubrowser
    51512. ./browser-linux-build.sh 
    5252 
     
    5454 
    55553. cd ../../libraries/i686-linux/runtime_release 
    56 4. LD_LIBRARY_PATH=`pwd` ../../../tests/ubrowser.llmozlib/ubrowser 
     564. LD_LIBRARY_PATH=`pwd` ../../../tests/ubrowser/ubrowser 
    5757 
  • trunk/llmozlib2/README-mac.txt

    r1 r8  
    33If you just need to rebuild the llmozlib library, you can skip ahead to building the xcode project. 
    44 
    5 If you want to start from scratch, you should first build the mozilla project.  The script ../mozilla-mac-universal-build/checkout_patch_build.sh will check out the mozilla sources from the mozilla cvs server, apply our local patches, and build the whole thing. 
     5Building mozilla from scratch 
     6----------------------------- 
    67 
    7 Once you have the mozilla library built, run the copy_products_mac.sh script in this directory to pull the necessary bits across.  This will repopulate the architecture-specific portions of the libraries directory here, so you may want to do a preemptive 'svn remove' and commit first.  It will also create mozilla-universal-darwin.tgz which contains the necessary runtime bits that need to go into the application bundle. 
     8If you want to start from scratch, or are updating to a new mozilla release tag, you should first build the mozilla project.  The script ../mozilla-mac-universal-build/checkout_patch_build.sh will check out the mozilla sources from the mozilla cvs server, apply our local patches, and build the whole thing.  Embedded in this script is the CVS tag to check out, which should correspond to one of the official mozilla releases.  If you update to a later version, please commit the change to checkout_patch_build.sh so that others will be able to tell which version is current. 
     9 
     10Once you have the mozilla library built, run the copy_products_mac.sh script in this directory to pull the necessary bits across.  This will repopulate the architecture-specific portions of the libraries directory here, so you may want to do a preemptive 'svn remove' and commit first.  It will also create mozilla-universal-darwin-original.tgz which contains the necessary runtime bits that need to go into the application bundle. 
     11 
     12At this point, you can 'svn add' any new files in ./libraries, commit them and mozilla-universal-darwin-original.tgz, and someone else will be able to check out this directory and rebuild llmozlib without having to do a full mozilla build.  This is the reason for splitting the build process at this point.   
     13 
     14Rebuilding llmozlib (Xcode) 
     15--------------------------- 
     16 
     17*** WARNING *** 
     18 
     19Build will fail the first time!  This is expected!  There's some voodoo going on with include directory names.  Open the project in Xcode (or use the command line equivalent listed at the end of this section).  Build it.  Now close the Xcode project and reopen it and build it again (or just run the command line equivalent again). 
    820 
    921Once you've got the mozilla libraries in place, open llmozlib.xcodeproj and build the "Release" build style.  If the build fails with a bunch of missing include files, close the project and reopen it, then try again.  (A script phase in the project creates a symlink, but xcode only reevaluates the wildcard header path search when the project is opened.  You should only have to do this once per checkout.) 
    1022 
    11 After that completes, run repackage_runtime.sh to do the final packaging step and copy the necessary pieces into your sandbox.  The script takes a single argument, which is the location of the sandbox directory.  (Note that this should be the directory containing the 'libraries' and 'indra' directories.)  The script should be run from the llmozlib directory, and the sandbox path can either be relative or absolute (i.e. './repackage_runtime.sh ../../BRANCH' will work fine). 
     23If the llmozlib build still fails due to missing header files after doing the steps above, you'll want to figure out where in the mozilla build they live and modify copy_products_mac.sh to copy them, run it (so they get pulled into ./libraries), 'svn add' the new files, and commit. 
     24 
     25If there's any chance the public interface (i.e. member functions) of the LLMozLib class has changed, you need to regenerate the exports file and (re)build the "Release" target.  See the NOTE about llmozlib2.exp below. 
     26 
     27If you did a full mozilla build and you're certain you have all the header files you need copied into ./libraries, it's now safe to delete the files that the mozilla build generated: 
     28 
     29        build_mozilla/cvsco.log 
     30        build_mozilla/mozilla 
     31        build_mozilla/objdir-mozilla-universal 
     32 
     33After the xcode build completes, run repackage_runtime.sh to do the final packaging step (including creating mozilla-universal-darwin.tgz from mozilla-universal-darwin-original.tgz and the llmozlib build products) and copy the necessary pieces into your sandbox.  The script takes a single argument, which is the location of the sandbox directory.  (Note that this should be the directory containing the 'libraries' and 'indra' directories.)  The script should be run from the llmozlib directory, and the sandbox path can either be relative or absolute (i.e. './repackage_runtime.sh ../../BRANCH' will work fine). 
     34 
     35NOTE:  Command line build command: 
     36 
     37xcodebuild -project llmozlib2.xcodeproj -target llmozlib2 -configuration Release build 
     38 
     39(You can use "clean" instead of "build") 
    1240 
    1341----------- 
    14 NOTE: about llmozlib.exp 
     42NOTE: about llmozlib2.exp 
    1543 
    1644In order to hide internal symbols in the mozilla library, we have to use an explicit export list when building llmozlib. 
     
    1846The list of symbols to export is in llmozlib.exp.  The symbols are in "name mangled" form, making them a bit of a pain to read. 
    1947 
    20 If changes are made to any of the class definitions in llmozlib.h, this list may need to be regenerated.  To regenerate the list of symbols: 
     48If changes are made to any of the class definitions in llmozlib.h, this list may need to be regenerated.  The script update-mac-symbols.sh in this directory now takes care of doing this step.  The following directions are what I used to do manually, preserved for posterity (or in case the script breaks in the future).  If you run the script and it works, you don't need to read any further. 
     49 
     50 
     51To regenerate the list of symbols: 
    2152 
    2253- Open up the xcode project 
    23 - Change the "Exported Symbols File" setting in the llmozlib target from llmozlib.exp to nothing 
    24 - Build the "Release" target 
     54- Build the "All Symbols" configuration 
    2555- Execute the following commands: 
    2656 
    27 otool -vT build/Release/libllmozlib.dylib >symbols.txt 
     57otool -vT 'build/All Symbols/libllmozlib2.dylib' >symbols.txt 
    2858sed -n -e '/.*\.eh/d' -e 's/^single module    \(.*\)/\1/p' <symbols.txt >symbols2.txt 
    2959 
     
    3363 
    3464Once you've got the new list, paste it into llmozlib.exp and change the "Exported Symbols File" setting back to "llmozlib.exp". 
     65 
     66NOTE:  Command line build command: 
     67 
     68xcodebuild -project llmozlib2.xcodeproj -target llmozlib2 -configuration Release build 
     69 
     70(You can use "clean" instead of "build") 
    3571 
    3672----------- 
  • trunk/llmozlib2/build-linux-llmozlib.sh

    r1 r8  
    1 #!/bin/sh 
     1#!/bin/bash 
    22# This script builds llmozlib itself.  This should happen after 
    33# mozilla has been built and copy_products_linux.sh has been run. 
     
    55CXX='g++-3.4' 
    66MOZARCH='i686-linux' 
    7 SRCS='llembeddedbrowser.cpp llembeddedbrowserwindow.cpp llmozlib.cpp' 
     7SRCS='llembeddedbrowser.cpp llembeddedbrowserwindow.cpp llmozlib2.cpp' 
    88 
    99#------------------------ 
    1010 
    11 LIBNAME=libllmozlib 
     11LIBNAME=libllmozlib2 
    1212OBJS=`echo ${SRCS} | sed s/\\.cpp/.o/g` 
    13 INCS_LINE="`pkg-config gtk+-2.0 --cflags` `find libraries/${MOZARCH}/include -type d | sed s/^/-I/`" 
     13INCS_LINE="`find libraries/${MOZARCH}/include -type d | sed s/^/-I/`" 
    1414DEFS='-DMOZILLA_INTERNAL_API -DLL_LINUX=1' 
    1515OPTS='-ggdb' 
  • trunk/llmozlib2/build_mozilla/.mozconfig.debug

    r1 r8  
    2727ac_add_options --enable-image-decoders=png,gif,jpeg 
    2828ac_add_options --enable-svg 
    29 ac_add_options --enable-svg-renderer=gdiplus 
    3029ac_add_options --disable-javaxpcom 
    3130ac_add_options --disable-activex 
  • trunk/llmozlib2/build_mozilla/.mozconfig.optimized

    r1 r8  
    2727ac_add_options --enable-image-decoders=png,gif,jpeg 
    2828ac_add_options --enable-svg 
    29 ac_add_options --enable-svg-renderer=gdiplus 
    3029ac_add_options --disable-javaxpcom 
    3130ac_add_options --disable-activex 
  • trunk/llmozlib2/build_mozilla/linux-checkout_patch_build.sh

    r1 r8  
    1010echo 'use the password "anonymous" if prompted' 
    1111cvs login 
    12 cvs checkout -r FIREFOX_1_5_0_12_RELEASE mozilla/client.mk 
     12cvs checkout -r FIREFOX_2_0_0_11_RELEASE mozilla/client.mk 
    1313(cd mozilla && make -f client.mk checkout MOZ_CO_PROJECT=xulrunner) 
    1414 
     
    1818# apply a patch to the mozilla source so that it doesn't try to use the OS  
    1919# versions of scrollbars, combo boxes, etc. 
    20 cat linux-libxul-bits/linden_updates.patch | (cd mozilla && patch -p0) 
     20cat linden.patch | (cd mozilla && patch -p0) 
    2121 
    2222# XXX FIXME: ideally we need to bring custom GTK in-tree and do some magic on its .pc files - yuck.  Only Linden Lab's conservative-deps binary builds really care though. 
    23 #export PKG_CONFIG_PATH=/home/moss/linden/GTKBUILD24/lib/pkgconfig 
     23export PKG_CONFIG_PATH=/tmp/GTKBUILD24/lib/pkgconfig 
    2424(cd mozilla && make -f client.mk build) 
    2525 
  • trunk/llmozlib2/build_mozilla/linux-libxul-bits/mozconfig

    r1 r8  
    6161CURRENTDIR=`pwd` 
    6262 
     63# parallel build (adjust to taste) 
     64mk_add_options MOZ_MAKE_FLAGS=-j4 
     65 
    6366mk_add_options MOZ_CO_PROJECT=xulrunner 
    6467ac_add_options --enable-application=xulrunner 
     
    99102#ac_add_options --with-gtk-prefix=/tmp/GTKBUILD 
    100103#ac_add_options --with-glib-prefix=/tmp/GTKBUILD 
    101 #ac_add_options --disable-pango 
     104ac_add_options --disable-pango 
     105#ac_add_options --enable-pango 
     106#ac_add_options --enable-freetype2 
    102107ac_add_options --disable-gnomevfs 
    103108ac_add_options --disable-gnomeui 
  • trunk/llmozlib2/build_mozilla/mac-checkout_patch_build.sh

    r1 r8  
    1111cvs login 
    1212#cvs checkout -r MOZILLA_1_8_BRANCH mozilla/client.mk 
    13 cvs checkout -r FIREFOX_1_5_0_12_RELEASE mozilla/client.mk 
     13cvs checkout -r FIREFOX_2_0_0_11_RELEASE mozilla/client.mk 
    1414(cd mozilla && make -f client.mk checkout MOZ_CO_PROJECT=xulrunner) 
    1515 
     
    2020# shell scripts that I don't want to set up.  Since we don't need to build the  
    2121# package, just comment this out. 
    22 cp mac-universal-libxul-bits/installer-mac-Makefile.in mozilla/xulrunner/installer/mac/Makefile.in 
     22# NOTE: this is now part of the linden.patch file instead. 
     23#cp mac-universal-libxul-bits/installer-mac-Makefile.in mozilla/xulrunner/installer/mac/Makefile.in 
    2324 
    2425# replace the 'flight.mk' with one that does the right thing for the xulrunner build 
     
    2930# apply a patch to the mozilla source so that it doesn't try to use the OS  
    3031# versions of scrollbars, combo boxes, etc. 
    31 cat mac-universal-libxul-bits/linden-mozilla-mods.patch | (cd mozilla && patch -p0) 
     32cat linden.patch | (cd mozilla && patch -p0) 
    3233 
    3334(cd mozilla && make -f client.mk build) 
  • trunk/llmozlib2/build_mozilla/mac-universal-libxul-bits/mozconfig

    r1 r8  
    107107fi 
    108108 
     109 
    109110# parallel build (adjust to taste) 
    110111mk_add_options MOZ_MAKE_FLAGS=-j4 
     
    142143ac_add_options --disable-activex 
    143144ac_add_options --disable-activex-scripting 
    144 ac_add_options --enable-canvas 
     145# MBW -- got a mysterious compile error somewhere in the canvas stuff.  Turning it off for now. 
     146#ac_add_options --enable-canvas 
     147ac_add_options --disable-canvas 
    145148 
    146149ac_add_options --enable-cpp-rtti 
  • trunk/llmozlib2/copy_products_linux.sh

    r1 r8  
    1 #!/bin/sh 
     1#!/bin/bash 
    22 
    33# This script copies the relevant headers from the mozilla tree to the llmozlib  
     
    1212export LIBRARIES_DEST="." 
    1313 
    14 export ARCH=i686-linux 
     14export ARCH=`uname -m`-linux 
    1515 
    1616# make sure the destination directories exist.  If they don't, the user running the script probably hasn't set them up properly. 
     
    2727SRC="$MOZ_OBJDIR" 
    2828DST="$LIBRARIES_DEST/libraries/$ARCH" 
    29 for dir in /include/webbrwsr/ /include/docshell/ /include/dom/ /include/xpcom/ /include/widget/ /include/gfx/ /include/string/ /include/uriloader/ /include/view/ /include/layout/ /include/content/ /include/locale/ /include/profdirserviceprovider/ /include/xulapp/ /include/pref/ /include/necko/ /include/nkcache/ /sdk/include/ ; do 
     29for dir in /include/webbrwsr/ /include/docshell/ /include/dom/ /include/xpcom/ /include/widget/ /include/gfx/ /include/string/ /include/uriloader/ /include/view/ /include/layout/ /include/content/ /include/locale/ /include/profdirserviceprovider/ /include/xulapp/ /include/pref/ /include/necko/ /include/nkcache/ /include/js/ /include/appshell/ /sdk/include/ ; do 
    3030        mkdir -p $DST/include/mozilla/${dir} 
    3131        cp -LR $SRC/dist/${dir}/* $DST/include/mozilla/${dir} 
  • trunk/llmozlib2/copy_products_mac.sh

    r1 r8  
    9797+ /include/necko/ 
    9898+ /include/nkcache/ 
     99+ /include/js/ 
    99100+ /sdk/ 
    100101+ /sdk/include/ 
    101102+ /sdk/include/*/ 
    102103+ *.h 
     104+ *.tbl 
    103105- * 
    104106EOF 
  • trunk/llmozlib2/copy_products_windows.bat

    r1 r8  
    11@rem ===== source/destination dirs that may change depending where you build mozilla ===== 
    2 @set SRC_DIR_OPT="c:\mozilla.1.8.0.9\objdir-opt-xulrunner-small" 
    3 @set SRC_DIR_DEBUG="c:\mozilla.1.8.0.9\objdir-debug-xulrunner-small" 
     2@set SRC_DIR_OPT="c:\mozilla\objdir-opt-xulrunner-small" 
     3@set SRC_DIR_DEBUG="c:\mozilla\objdir-debug-xulrunner-small" 
    44@set DEST_DIR="libraries\i686-win32" 
    55 
    66@rem =============== instructions =============== 
    77@echo This batch file copies the files required to build the  
    8 @echo Linden Lab Mozilla Library (LLMozLib). 
     8@echo Linden Lab Mozilla Library2 (LLMozLib2). 
    99@echo. 
    1010@echo It will copy the required files from a Mozilla build in the specified  
    11 @echo directories to the right location for LLMozLib
     11@echo directories to the right location for LLMozLib2
    1212@echo. 
    1313@echo The release build will be copied from: 
     
    2828xcopy %SRC_DIR_OPT%\dist\include\dom\*.*                                                %DEST_DIR%\include\mozilla\include\dom\ /s 
    2929xcopy %SRC_DIR_OPT%\dist\include\gfx\*.*                                                %DEST_DIR%\include\mozilla\include\gfx\ /s 
     30xcopy %SRC_DIR_OPT%\dist\include\js\*.*                                                 %DEST_DIR%\include\mozilla\include\js\ /s 
    3031xcopy %SRC_DIR_OPT%\dist\include\layout\*.*                                             %DEST_DIR%\include\mozilla\include\layout\ /s 
    3132xcopy %SRC_DIR_OPT%\dist\include\locale\*.*                                             %DEST_DIR%\include\mozilla\include\locale\ /s 
  • trunk/llmozlib2/llembeddedbrowser.cpp

    r3 r8  
    1 /** 
    2  * @file llembeddedbrowser.cpp 
    3  * @brief LLEmbeddedBrowser implementation. 
    4  * 
    5  * $LicenseInfo:firstyear=2006&license=viewergpl$ 
    6  * 
    7  * Copyright (c) 2006-2007, Linden Research, Inc. 
    8  * 
    9  * Second Life Viewer Source Code 
    10  * The source code in this file ("Source Code") is provided by Linden Lab 
    11  * to you under the terms of the GNU General Public License, version 2.0 
    12  * ("GPL"), unless you have obtained a separate licensing agreement 
    13  * ("Other License"), formally executed by you and Linden Lab.  Terms of 
    14  * the GPL can be found in doc/GPL-license.txt in this distribution, or 
    15  * online at http://secondlife.com/developers/opensource/gplv2 
    16  * 
    17  * There are special exceptions to the terms and conditions of the GPL as 
    18  * it is applied to this Source Code. View the full text of the exception 
    19  * in the file doc/FLOSS-exception.txt in this software distribution, or 
    20  * online at http://secondlife.com/developers/opensource/flossexception 
    21  * 
    22  * By copying, modifying or distributing this software, you acknowledge 
    23  * that you have read and understood your obligations described above, 
    24  * and agree to abide by those obligations. 
    25  * 
    26  * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO 
    27  * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, 
    28  * COMPLETENESS OR PERFORMANCE. 
    29  * $/LicenseInfo$ 
    30  */ 
     1/* ***** BEGIN LICENSE BLOCK ***** 
     2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 
     3 * 
     4 * The contents of this file are subject to the Mozilla Public License Version 
     5 * 1.1 (the "License"); you may not use this file except in compliance with 
     6 * the License. You may obtain a copy of the License at 
     7 * http://www.mozilla.org/MPL/ 
     8 * 
     9 * Software distributed under the License is distributed on an "AS IS" basis, 
     10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
     11 * for the specific language governing rights and limitations under the 
     12 * License. 
     13 * 
     14 * The Original Code is Linden Lab Inc. (http://lindenlab.com) code. 
     15 * 
     16 * The Initial Developer of the Original Code is: 
     17 *   Callum Prentice (callum@ubrowser.com) 
     18 * 
     19 * Portions created by the Initial Developer are Copyright (C) 2006 
     20 * the Initial Developer. All Rights Reserved. 
     21 * 
     22 * Contributor(s): 
     23 *  Callum Prentice (callum@ubrowser.com) 
     24 * 
     25 * Alternatively, the contents of this file may be used under the terms of 
     26 * either the GNU General Public License Version 2 or later (the "GPL"), or 
     27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 
     28 * in which case the provisions of the GPL or the LGPL are applicable instead 
     29 * of those above. If you wish to allow use of your version of this file only 
     30 * under the terms of either the GPL or the LGPL, and not to allow others to 
     31 * use your version of this file under the terms of the MPL, indicate your 
     32 * decision by deleting the provisions above and replace them with the notice 
     33 * and other provisions required by the GPL or the LGPL. If you do not delete 
     34 * the provisions above, a recipient may use your version of this file under 
     35 * the terms of any one of the MPL, the GPL or the LGPL. 
     36 * 
     37 * ***** END LICENSE BLOCK ***** */ 
    3138 
    3239// Windows specific switches 
     
    3643                #define DEBUG 1 
    3744        #endif 
    38 #endif 
     45#endif // WIN32 
    3946 
    4047#include "llembeddedbrowser.h" 
     
    4249 
    4350#ifdef WIN32 
    44         #pragma warning( disable : 4265 ) // "class has virtual functions, but destructor is not virtual" 
    45         #pragma warning( disable : 4291 ) // (no matching operator delete found; memory will not be freed if initialization throws an exception) 
     51        #pragma warning( disable : 4265 )      // "class has virtual functions, but destructor is not virtual" 
     52        #pragma warning( disable : 4291 )      // (no matching operator delete found; memory will not be freed if initialization throws an exception) 
    4653#endif  // WIN32 
    4754 
    4855#include "nsBuildID.h" 
    49 #include "nsNetCID.h" 
    50 #include "nsCWebBrowser.h" 
    51 #include "nsGUIEvent.h" 
    5256#include "nsICacheService.h" 
    5357#include "nsICookieManager.h" 
    54 #include "nsICaret.h" 
    55 #include "nsIComponentRegistrar.h" 
    56 #include "nsIContent.h" 
    57 #include "nsIDOMDocument.h" 
    58 #include "nsIDOMElement.h" 
    59 #include "nsIDOMWindow.h" 
    60 #include "nsIDocShell.h" 
    61 #include "nsIDocShellTreeItem.h" 
    62 #include "nsIDocument.h" 
    63 #include "nsIFactory.h" 
    64 #include "nsIFrame.h" 
    65 #include "nsIInterfaceRequestorUtils.h" 
    6658#include "nsIPref.h" 
    67 #include "nsIPromptService.h" 
    68 #include "nsIScrollableView.h" 
    69 #include "nsISelection.h" 
    70 #include "nsISelectionController.h" 
    71 #include "nsIWebBrowserChrome.h" 
    72 #include "nsIWebBrowserChromeFocus.h" 
    73 #include "nsIWebBrowserFocus.h" 
    74 #include "nsPresContext.h" 
     59#include "nsNetCID.h" 
    7560#include "nsProfileDirServiceProvider.h" 
    76 #include "nsXPCOMGlue.h" 
    7761#include "nsXULAppAPI.h" 
    78 #include "nsWidgetsCID.h" // for NS_APPSHELL_CID 
    7962#include "nsIAppShell.h" 
    80 static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID); 
     63 
     64#if defined(LL_LINUX) || defined(LL_DARWIN) 
     65#include "nsWidgetsCID.h" 
     66static nsIAppShell *sAppShell = nsnull; 
     67#endif // defined(LL_LINUX) || defined(LL_DARWIN) 
    8168 
    8269// singleton pattern - initialization 
     
    8673// 
    8774LLEmbeddedBrowser::LLEmbeddedBrowser() : 
    88         mErrorNum( 0 ) 
     75        mErrorNum( 0 ), 
     76        mNativeWindowHandle( 0 ) 
    8977{ 
    9078} 
     
    131119//////////////////////////////////////////////////////////////////////////////// 
    132120// 
    133 static nsIAppShell *sAppShell = nsnull; 
    134  
    135 bool LLEmbeddedBrowser::init( std::string applicationDir, std::string componentDir, std::string profileDir ) 
    136 
     121std::string LLEmbeddedBrowser::getGREVersion() 
     122
     123        // take the string directly from Mozilla 
     124        return std::string( GRE_BUILD_ID ); 
     125
     126 
     127//////////////////////////////////////////////////////////////////////////////// 
     128// 
     129bool LLEmbeddedBrowser::init( std::string applicationDir, 
     130                                                                std::string componentDir, 
     131                                                                        std::string profileDir, 
     132                                                                                void* nativeWindowHandleIn ) 
     133
     134        mNativeWindowHandle = nativeWindowHandleIn; 
     135 
    137136        nsCOMPtr< nsILocalFile > applicationDirNative; 
    138137        nsresult result = NS_NewNativeLocalFile( nsCString( applicationDir.c_str() ), PR_FALSE, getter_AddRefs( applicationDirNative ) ); 
     
    193192        if ( pref ) 
    194193        { 
    195                 //pref->SetBoolPref( "viewmanager.do_doublebuffering", PR_FALSE ); 
    196194                pref->SetBoolPref( "security.warn_entering_secure", PR_FALSE ); 
    197195                pref->SetBoolPref( "security.warn_entering_weak", PR_FALSE ); 
     
    208206        enableProxy( false, "", 0 ); 
    209207 
    210 #ifdef LL_LINUX 
     208#if defined(LL_LINUX) || defined(LL_DARWIN) 
    211209        // Essential on Linux/GTK to add the gecko pump to the GTK event 
    212210        // loop.  Might be harmless/good on other platforms too. 
     211        nsresult rv; 
    213212        nsCOMPtr<nsIAppShell> appShell; 
    214         appShell = do_CreateInstance(kAppShellCID); 
     213        NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID); 
     214        appShell = do_CreateInstance(kAppShellCID, &rv); 
    215215        if (!appShell) 
    216216        { 
     
    233233bool LLEmbeddedBrowser::reset() 
    234234{ 
    235         if (sAppShell) { 
    236                 // Shutdown the appshell service. 
    237                 sAppShell->Spindown(); 
    238                 NS_RELEASE(sAppShell); 
    239                 sAppShell = NULL; 
    240         } 
    241  
    242235        XRE_TermEmbedding(); 
    243  
    244         return true; 
    245 } 
    246  
    247 //////////////////////////////////////////////////////////////////////////////// 
    248 // 
    249 std::string LLEmbeddedBrowser::getGREVersion() 
    250 { 
    251         // take the string directly from Mozilla 
    252         return std::string( GRE_BUILD_ID ); 
    253 } 
    254  
    255 //////////////////////////////////////////////////////////////////////////////// 
    256 // 
    257 void LLEmbeddedBrowser::setBrowserAgentId( std::string idIn ) 
    258 { 
    259         nsCOMPtr<nsIPref> pref = do_CreateInstance( NS_PREF_CONTRACTID ); 
    260         if ( pref ) 
    261         { 
    262                 pref->SetCharPref( "general.useragent.extra.* ", idIn.c_str() ); 
    263         }; 
    264 } 
    265  
    266 //////////////////////////////////////////////////////////////////////////////// 
    267 // 
    268 LLEmbeddedBrowserWindow* createWindow(  void* nativeWindowHandleIn, int widthIn, int heightIn, PRUint32 aChromeFlags, nsIWebBrowserChrome* aParent, nsIWebBrowserChrome** aNewWindow ) 
    269 { 
    270         LLEmbeddedBrowserWindow* chrome = new LLEmbeddedBrowserWindow(); 
    271         if ( ! chrome ) 
    272         { 
    273                 return 0; 
    274         }; 
    275  
    276         CallQueryInterface( NS_STATIC_CAST( nsIWebBrowserChrome*, chrome ), aNewWindow ); 
    277  
    278         NS_ADDREF( *aNewWindow ); 
    279  
    280         chrome->SetChromeFlags( aChromeFlags ); 
    281  
    282         nsCOMPtr< nsIWebBrowser > newBrowser; 
    283  
    284         chrome->createBrowser( nativeWindowHandleIn, widthIn, heightIn, getter_AddRefs( newBrowser ) ); 
    285         if ( ! newBrowser ) 
    286         { 
    287                 return 0; 
    288         }; 
    289  
    290         return chrome; 
    291 } 
    292  
    293 //////////////////////////////////////////////////////////////////////////////// 
    294 // 
    295 LLEmbeddedBrowserWindow* LLEmbeddedBrowser::createBrowserWindow( void* nativeWindowHandleIn, int browserWidthIn, int browserHeightIn ) 
    296 { 
    297     nsCOMPtr< nsIWebBrowserChrome > chrome; 
    298     LLEmbeddedBrowserWindow* newWin = createWindow( nativeWindowHandleIn, browserWidthIn, browserHeightIn, nsIWebBrowserChrome::CHROME_ALL, nsnull, getter_AddRefs( chrome ) ); 
    299     if ( newWin && chrome ) 
    300     { 
    301         nsCOMPtr< nsIWebBrowser > newBrowser; 
    302         chrome->GetWebBrowser( getter_AddRefs( newBrowser ) ); 
    303         nsCOMPtr< nsIWebNavigation > webNav( do_QueryInterface ( newBrowser ) ); 
    304         webNav->LoadURI( NS_ConvertUTF8toUTF16( "about:blank" ).get(), nsIWebNavigation::LOAD_FLAGS_NONE, nsnull, nsnull, nsnull ); 
    305  
    306  
    307                 clearLastError(); 
    308  
    309                 return newWin; 
    310     }; 
    311  
    312         setLastError( 0x2001 ); 
    313  
    314         return 0; 
    315 }; 
    316  
    317 //////////////////////////////////////////////////////////////////////////////// 
    318 // 
    319 bool LLEmbeddedBrowser::destroyBrowserWindow( LLEmbeddedBrowserWindow* browserWindowIn ) 
    320 { 
    321         nsCOMPtr< nsIWebBrowser > webBrowser; 
    322         nsCOMPtr< nsIWebNavigation > webNavigation; 
    323  
    324         browserWindowIn->GetWebBrowser( getter_AddRefs( webBrowser ) ); 
    325         webNavigation = do_QueryInterface( webBrowser ); 
    326         if ( webNavigation ) 
    327         { 
    328                 webNavigation->Stop( nsIWebNavigation::STOP_ALL ); 
    329         }; 
    330  
    331         nsCOMPtr< nsIWebBrowser > browser = nsnull; 
    332         browserWindowIn->GetWebBrowser( getter_AddRefs( browser ) ); 
    333         nsCOMPtr< nsIBaseWindow > browserAsWin = do_QueryInterface( browser ); 
    334         if ( browserAsWin ) 
    335         { 
    336                 browserAsWin->Destroy(); 
    337         }; 
    338  
    339         browserWindowIn->SetWebBrowser( nsnull ); 
    340  
    341         NS_RELEASE( browserWindowIn ); 
    342  
    343         delete browserWindowIn; 
    344  
    345         clearLastError(); 
    346236 
    347237        return true; 
     
    361251} 
    362252 
    363 /////////////////////////////////////////////////////////////////////////////// 
     253//////////////////////////////////////////////////////////////////////////////// 
    364254// 
    365255bool LLEmbeddedBrowser::enableProxy( bool proxyEnabledIn, std::string proxyHostNameIn, int proxyPortIn ) 
     
    440330                        pref->SetBoolPref( "plugin.scan.plid.all", PR_FALSE ); 
    441331                        pref->SetBoolPref( "xpinstall-enabled", PR_FALSE ); 
     332                        pref->SetBoolPref( "plugin.scan.4xPluginFolder", PR_FALSE ); 
     333                        pref->SetCharPref( "plugin.scan.Quicktime", "20.0" ); 
     334                        pref->SetCharPref( "plugin.scan.Acrobat", "99.0" ); 
     335                        pref->SetCharPref( "plugin.scan.SunJRE", "99.0" ); 
     336                        pref->SetCharPref( "plugin.scan.WindowsMediaPlayer", "99.0" ); 
    442337                }; 
    443338 
     
    446341 
    447342        return false; 
     343} 
     344 
     345//////////////////////////////////////////////////////////////////////////////// 
     346// 
     347void LLEmbeddedBrowser::setBrowserAgentId( std::string idIn ) 
     348{ 
     349        nsCOMPtr<nsIPref> pref = do_CreateInstance( NS_PREF_CONTRACTID ); 
     350        if ( pref ) 
     351        { 
     352                pref->SetCharPref( "general.useragent.extra.* ", idIn.c_str() ); 
     353        }; 
     354} 
     355 
     356//////////////////////////////////////////////////////////////////////////////// 
     357// 
     358LLEmbeddedBrowserWindow* LLEmbeddedBrowser::createBrowserWindow( int browserWidthIn, int browserHeightIn ) 
     359{ 
     360    nsCOMPtr< nsIWebBrowserChrome > chrome; 
     361 
     362        LLEmbeddedBrowserWindow* newWin = new LLEmbeddedBrowserWindow(); 
     363        if ( ! newWin ) 
     364        { 
     365                return 0; 
     366        }; 
     367 
     368        nsIWebBrowserChrome** aNewWindow = getter_AddRefs( chrome ); 
     369 
     370        CallQueryInterface( NS_STATIC_CAST( nsIWebBrowserChrome*, newWin ), aNewWindow ); 
     371 
     372        NS_ADDREF( *aNewWindow ); 
     373 
     374        newWin->SetChromeFlags( nsIWebBrowserChrome::CHROME_ALL ); 
     375 
     376        nsCOMPtr< nsIWebBrowser > newBrowser; 
     377 
     378        newWin->createBrowser( mNativeWindowHandle, browserWidthIn, browserHeightIn, getter_AddRefs( newBrowser ) ); 
     379        if ( ! newBrowser ) 
     380        { 
     381                return 0; 
     382        }; 
     383 
     384    if ( newWin && chrome ) 
     385    { 
     386                newWin->setParent( this ); 
     387        nsCOMPtr< nsIWebBrowser > newBrowser; 
     388        chrome->GetWebBrowser( getter_AddRefs( newBrowser ) ); 
     389        nsCOMPtr< nsIWebNavigation > webNav( do_QueryInterface ( newBrowser ) ); 
     390                webNav->LoadURI( NS_ConvertUTF8toUTF16( "about:blank" ).get(), nsIWebNavigation::LOAD_FLAGS_NONE, nsnull, nsnull, nsnull ); 
     391 
     392                clearLastError(); 
     393 
     394                return newWin; 
     395    }; 
     396 
     397        setLastError( 0x2001 ); 
     398        return 0; 
     399}; 
     400 
     401//////////////////////////////////////////////////////////////////////////////// 
     402// 
     403bool LLEmbeddedBrowser::destroyBrowserWindow( LLEmbeddedBrowserWindow* browserWindowIn ) 
     404{ 
     405        nsCOMPtr< nsIWebBrowser > webBrowser; 
     406        nsCOMPtr< nsIWebNavigation > webNavigation; 
     407 
     408        browserWindowIn->GetWebBrowser( getter_AddRefs( webBrowser ) ); 
     409        webNavigation = do_QueryInterface( webBrowser ); 
     410        if ( webNavigation ) 
     411        { 
     412                webNavigation->Stop( nsIWebNavigation::STOP_ALL ); 
     413        }; 
     414 
     415        nsCOMPtr< nsIWebBrowser > browser = nsnull; 
     416        browserWindowIn->GetWebBrowser( getter_AddRefs( browser ) ); 
     417        nsCOMPtr< nsIBaseWindow > browserAsWin = do_QueryInterface( browser ); 
     418        if ( browserAsWin ) 
     419        { 
     420                browserAsWin->Destroy(); 
     421        }; 
     422 
     423        browserWindowIn->SetWebBrowser( nsnull ); 
     424 
     425        NS_RELEASE( browserWindowIn ); 
     426 
     427        delete browserWindowIn; 
     428 
     429        clearLastError(); 
     430 
     431        return true; 
    448432} 
    449433 
    450434// Windows specific switches 
    451435#ifdef WIN32 
    452  
    453         #pragma warning( 3 : 4265 ) // "class has virtual functions, but destructor is not virtual" 
    454436        #pragma warning( 3 : 4291 ) // (no matching operator delete found; memory will not be freed if initialization throws an exception) 
     437        #pragma warning( 3 : 4265 )     // "class has virtual functions, but destructor is not virtual" 
    455438 
    456439        // #define required by this file for LibXUL/Mozilla code to avoid crashes in their debug code 
  • trunk/llmozlib2/llembeddedbrowser.h

    r3 r8  
    1 /** 
    2  * @file llembeddedbrowser.h 
    3  * @brief LLEmbeddedBrowser declaration. 
     1/* ***** BEGIN LICENSE BLOCK ***** 
     2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 
    43 * 
    5  * $LicenseInfo:firstyear=2006&license=viewergpl$ 
     4 * The contents of this file are subject to the Mozilla Public License Version 
     5 * 1.1 (the "License"); you may not use this file except in compliance with 
     6 * the License. You may obtain a copy of the License at 
     7 * http://www.mozilla.org/MPL/ 
    68 * 
    7  * Copyright (c) 2006-2007, Linden Research, Inc. 
     9 * Software distributed under the License is distributed on an "AS IS" basis, 
     10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
     11 * for the specific language governing rights and limitations under the 
     12 * License. 
    813 * 
    9  * Second Life Viewer Source Code 
    10  * The source code in this file ("Source Code") is provided by Linden Lab 
    11  * to you under the terms of the GNU General Public License, version 2.0 
    12  * ("GPL"), unless you have obtained a separate licensing agreement 
    13  * ("Other License"), formally executed by you and Linden Lab.  Terms of 
    14  * the GPL can be found in doc/GPL-license.txt in this distribution, or 
    15  * online at http://secondlife.com/developers/opensource/gplv2 
     14 * The Original Code is Linden Lab Inc. (http://lindenlab.com) code. 
    1615 * 
    17  * There are special exceptions to the terms and conditions of the GPL as 
    18  * it is applied to this Source Code. View the full text of the exception 
    19  * in the file doc/FLOSS-exception.txt in this software distribution, or 
    20  * online at http://secondlife.com/developers/opensource/flossexception 
     16 * The Initial Developer of the Original Code is: 
     17 *   Callum Prentice (callum@ubrowser.com) 
    2118 * 
    22  * By copying, modifying or distributing this software, you acknowledge 
    23  * that you have read and understood your obligations described above, 
    24  * and agree to abide by those obligations. 
     19 * Portions created by the Initial Developer are Copyright (C) 2006 
     20 * the Initial Developer. All Rights Reserved. 
    2521 * 
    26  * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO 
    27  * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, 
    28  * COMPLETENESS OR PERFORMANCE. 
    29  * $/LicenseInfo$ 
    30  */ 
     22 * Contributor(s): 
     23 *  Callum Prentice (callum@ubrowser.com) 
     24 * 
     25 * Alternatively, the contents of this file may be used under the terms of 
     26 * either the GNU General Public License Version 2 or later (the "GPL"), or 
     27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 
     28 * in which case the provisions of the GPL or the LGPL are applicable instead 
     29 * of those above. If you wish to allow use of your version of this file only 
     30 * under the terms of either the GPL or the LGPL, and not to allow others to 
     31 * use your version of this file under the terms of the MPL, indicate your 
     32 * decision by deleting the provisions above and replace them with the notice 
     33 * and other provisions required by the GPL or the LGPL. If you do not delete 
     34 * the provisions above, a recipient may use your version of this file under 
     35 * the terms of any one of the MPL, the GPL or the LGPL. 
     36 * 
     37 * ***** END LICENSE BLOCK ***** */ 
    3138 
    3239#ifndef LLEMBEDDEDBROWSER_H 
     
    4754                static LLEmbeddedBrowser* getInstance(); 
    4855 
    49                 bool init( std::string applicationDir, std::string componentDir, std::string profileDir ); 
     56                bool init( std::string applicationDir, std::string componentDir, std::string profileDir, void* nativeWindowHandleIn ); 
    5057                bool reset(); 
    5158                bool clearCache(); 
     
    5663                std::string getGREVersion(); 
    5764                void setBrowserAgentId( std::string idIn ); 
    58                 LLEmbeddedBrowserWindow* createBrowserWindow( void* nativeWindowHandleIn, int browserWidthIn, int browserHeightIn ); 
     65                LLEmbeddedBrowserWindow* createBrowserWindow( int browserWidthIn, int browserHeightIn ); 
    5966                bool destroyBrowserWindow( LLEmbeddedBrowserWindow* browserWindowIn ); 
    60                 bool setCaretColor( int browserWindowIdIn, const int redIn, const int greenIn, const int blueIn ); 
    6167                void setLastError( int errorNumIn ); 
    6268                void clearLastError(); 
     
    6571        private: 
    6672                static LLEmbeddedBrowser* sInstance; 
     73                void* mNativeWindowHandle; 
    6774                int mErrorNum; 
    6875}; 
    6976 
    7077#endif  // LLEMBEDDEDBROWSER_H 
     78 
  • trunk/llmozlib2/llembeddedbrowserwindow.cpp

    r3 r8  
    1 /** 
    2  * @file llembeddedbrowserwindow.cpp 
    3  * @brief LLEmbeddedBrowserWindow implementation. 
     1/* ***** BEGIN LICENSE BLOCK ***** 
     2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 
    43 * 
    5  * $LicenseInfo:firstyear=2006&license=viewergpl$ 
     4 * The contents of this file are subject to the Mozilla Public License Version 
     5 * 1.1 (the "License"); you may not use this file except in compliance with 
     6 * the License. You may obtain a copy of the License at 
     7 * http://www.mozilla.org/MPL/ 
    68 * 
    7  * Copyright (c) 2006-2007, Linden Research, Inc. 
     9 * Software distributed under the License is distributed on an "AS IS" basis, 
     10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
     11 * for the specific language governing rights and limitations under the 
     12 * License. 
    813 * 
    9  * Second Life Viewer Source Code 
    10  * The source code in this file ("Source Code") is provided by Linden Lab 
    11  * to you under the terms of the GNU General Public License, version 2.0 
    12  * ("GPL"), unless you have obtained a separate licensing agreement 
    13  * ("Other License"), formally executed by you and Linden Lab.  Terms of 
    14  * the GPL can be found in doc/GPL-license.txt in this distribution, or 
    15  * online at http://secondlife.com/developers/opensource/gplv2 
     14 * The Original Code is Linden Lab Inc. (http://lindenlab.com) code. 
    1615 * 
    17  * There are special exceptions to the terms and conditions of the GPL as 
    18  * it is applied to this Source Code. View the full text of the exception 
    19  * in the file doc/FLOSS-exception.txt in this software distribution, or 
    20  * online at http://secondlife.com/developers/opensource/flossexception 
     16 * The Initial Developer of the Original Code is: 
     17 *   Callum Prentice (callum@ubrowser.com) 
    2118 * 
    22  * By copying, modifying or distributing this software, you acknowledge 
    23  * that you have read and understood your obligations described above, 
    24  * and agree to abide by those obligations. 
     19 * Portions created by the Initial Developer are Copyright (C) 2006 
     20 * the Initial Developer. All Rights Reserved. 
    2521 * 
    26  * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO 
    27  * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, 
    28  * COMPLETENESS OR PERFORMANCE. 
    29  * $/LicenseInfo$ 
    30  */ 
    31  
    32 // required by LibXUL/Mozilla code to avoid crashes in their debug code, but only on Windows. 
     22 * Contributor(s): 
     23 *  Callum Prentice (callum@ubrowser.com) 
     24 * 
     25 * Alternatively, the contents of this file may be used under the terms of 
     26 * either the GNU General Public License Version 2 or later (the "GPL"), or 
     27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 
     28 * in which case the provisions of the GPL or the LGPL are applicable instead 
     29 * of those above. If you wish to allow use of your version of this file only 
     30 * under the terms of either the GPL or the LGPL, and not to allow others to 
     31 * use your version of this file under the terms of the MPL, indicate your 
     32 * decision by deleting the provisions above and replace them with the notice 
     33 * and other provisions required by the GPL or the LGPL. If you do not delete 
     34 * the provisions above, a recipient may use your version of this file under 
     35 * the terms of any one of the MPL, the GPL or the LGPL. 
     36 * 
     37 * ***** END LICENSE BLOCK ***** */ 
     38 
     39// seems to be required by LibXUL/Mozilla code to avoid crashes in their debug code, but only on Windows. 
    3340// undef'd at end of this 
    3441#ifdef _DEBUG 
     
    3845#endif 
    3946 
     47// needed for the code in LLEmbeddedBrowserWindow::NotifyInvalidated() which will 
     48// one day be moved to platform agnostic code when I find out how... 
     49#ifdef WIN32 
     50#include "windows.h" 
     51#endif 
     52 
     53#include "llembeddedbrowser.h" 
    4054#include "llembeddedbrowserwindow.h" 
    4155 
     
    7387#include "nsXULAppAPI.h" 
    7488 
     89#include "llembeddedbrowserwindow.h" 
     90 
     91#include <iostream> 
     92 
    7593#ifdef WIN32 
    7694#pragma warning( 3 : 4265 ) // "class has virtual functions, but destructor is not virtual" 
     
    8098// 
    8199LLEmbeddedBrowserWindow::LLEmbeddedBrowserWindow() : 
     100        mParent( 0 ), 
    82101        mWebBrowser( nsnull ), 
    83102        mBaseWindow( nsnull ), 
     
    87106        mBrowserHeight( 0 ), 
    88107        mBrowserDepth( 4 ), 
    89         mPageBuffer( NULL ), 
    90         mPageBufferSize ( 0 ), 
     108        mPageBuffer( 0 ), 
     109        mEnabled( true ), 
    91110        mCurrentUri( "" ), 
    92111        mStatusText( "" ), 
    93112        mClickHref( "" ), 
    94         mBackgroundRed( 0xff ), 
    95         mBackgroundGreen( 0xff ), 
    96         mBackgroundBlue( 0xff ), 
     113        mClickTarget( "" ), 
     114        mNoFollowScheme( "secondlife://" ), 
     115        mBkgRed( 0xff ), 
     116        mBkgGreen( 0xff ), 
     117        mBkgBlue( 0xff ), 
    97118        mCaretRed( 0x0 ), 
    98119        mCaretGreen( 0x0 ), 
    99120        mCaretBlue( 0x0 ), 
    100         m404RedirectUrl( "" ) 
     121        m404RedirectUrl( "" ), 
     122        mFlipBitmap( false ) 
    101123{ 
    102124} 
     
    121143        { 
    122144                delete[] mPageBuffer; 
    123                 mPageBuffer = NULL; 
    124                 mPageBufferSize = 0; 
     145                mPageBuffer = 0; 
    125146        }; 
    126147} 
     
    133154        *aBrowser = nsnull; 
    134155 
    135         mWebBrowser = do_CreateInstance( NS_WEBBROWSER_CONTRACTID ); 
     156        nsresult rv; 
     157        mWebBrowser = do_CreateInstance( NS_WEBBROWSER_CONTRACTID, &rv ); 
    136158        if ( ! mWebBrowser ) 
     159        { 
    137160                return NS_ERROR_FAILURE; 
    138  
    139     (void)mWebBrowser->SetContainerWindow(NS_STATIC_CAST(nsIWebBrowserChrome*, this)); 
    140  
    141     nsCOMPtr<nsIDocShellTreeItem> dsti = do_QueryInterface(mWebBrowser); 
    142     dsti->SetItemType(nsIDocShellTreeItem::typeContentWrapper); 
    143  
    144     mBaseWindow = do_QueryInterface(mWebBrowser); 
     161        } 
     162 
     163    (void)mWebBrowser->SetContainerWindow( NS_STATIC_CAST( nsIWebBrowserChrome*, this ) ); 
     164 
     165    nsCOMPtr<nsIDocShellTreeItem> dsti = do_QueryInterface( mWebBrowser ); 
     166    dsti->SetItemType( nsIDocShellTreeItem::typeContentWrapper ); 
     167 
     168    mBaseWindow = do_QueryInterface( mWebBrowser ); 
    145169 
    146170    mBaseWindow->InitWindow( nativeWindowHandleIn, nsnull,  0, 0, mBrowserWidth, mBrowserHeight ); 
    147171    mBaseWindow->Create(); 
    148172 
    149     nsCOMPtr<nsIWebProgressListener> listener(NS_STATIC_CAST(nsIWebProgressListener*, this)); 
    150     nsCOMPtr<nsIWeakReference> thisListener(do_GetWeakReference(listener)); 
    151     (void)mWebBrowser->AddWebBrowserListener(thisListener, 
    152         NS_GET_IID(nsIWebProgressListener)); 
     173    nsCOMPtr< nsIWebProgressListener > listener( NS_STATIC_CAST( nsIWebProgressListener*, this ) ); 
     174    nsCOMPtr< nsIWeakReference > thisListener( do_GetWeakReference( listener ) ); 
     175    mWebBrowser->AddWebBrowserListener( thisListener, NS_GET_IID( nsIWebProgressListener ) ); 
     176 
     177#if LL_DARWIN 
     178        // Without this, the mac doesn't get upates for animating gifs, mouseovers, etc. 
     179        mBaseWindow->SetVisibility( PR_TRUE ); 
     180#else 
     181        mBaseWindow->SetVisibility( PR_FALSE ); 
     182#endif 
    153183 
    154184        nsresult result; 
    155         // set the listener to we can catch nsURIContentListener events 
    156         if ( mWebBrowser ) 
    157         { 
    158                 result = mWebBrowser->SetParentURIContentListener( NS_STATIC_CAST( nsIURIContentListener*, this ) ); 
    159                 if ( NS_FAILED( result ) ) 
    160                 { 
    161                 }; 
    162         }; 
    163  
    164185        mWebNav = do_QueryInterface( mWebBrowser, &result ); 
    165186        if ( NS_FAILED( result ) || ! mWebNav ) 
    166187        { 
    167         }; 
    168  
    169         mBaseWindow->SetVisibility( PR_FALSE ); 
     188                return NS_ERROR_FAILURE; 
     189        }; 
    170190 
    171191        setSize( widthIn, heightIn ); 
    172192 
    173     if (mWebBrowser
     193    if ( mWebBrowser
    174194    { 
    175195                *aBrowser = mWebBrowser; 
    176                 NS_ADDREF(*aBrowser); 
     196                NS_ADDREF( *aBrowser ); 
     197 
    177198                return NS_OK; 
    178199    }; 
     
    195216        NS_INTERFACE_MAP_ENTRY( nsIURIContentListener ) 
    196217        NS_INTERFACE_MAP_ENTRY( nsISupportsWeakReference ) 
     218        NS_INTERFACE_MAP_ENTRY( nsIToolkitObserver ) 
    197219NS_INTERFACE_MAP_END 
    198220 
     
    220242        mStatusText = std::string( NS_ConvertUTF16toUTF8( aStatus ).get() ); 
    221243 
    222         LLEmbeddedBrowserWindowEvent event( getWindowId(), mStatusText ); 
     244        LLEmbeddedBrowserWindowEvent event( getWindowId(), getCurrentUri(), mStatusText ); 
    223245        mEventEmitter.update( &LLEmbeddedBrowserWindowObserver::onStatusTextChange, event ); 
    224246 
     
    317339                mPercentComplete = 100; 
    318340 
    319         LLEmbeddedBrowserWindowEvent event( getWindowId(), mPercentComplete ); 
     341        LLEmbeddedBrowserWindowEvent event( getWindowId(), getCurrentUri(), mPercentComplete ); 
    320342        mEventEmitter.update( &LLEmbeddedBrowserWindowObserver::onUpdateProgress, event ); 
    321343 
     
    330352        if ( ( progressStateFlags & STATE_START ) && ( progressStateFlags & STATE_IS_DOCUMENT ) && ( status == NS_OK ) ) 
    331353        { 
     354                // TODO: move this to a better place. 
     355                enableToolkitObserver( false ); 
     356                enableToolkitObserver( true ); 
     357 
    332358                // page load is starting so remove listener that catches "click" events 
    333359                nsCOMPtr< nsIDOMWindow > window; 
     
    340366                }; 
    341367 
     368                // set the listener to we can catch nsURIContentListener events 
     369                if ( mWebBrowser ) 
     370                { 
     371                        mWebBrowser->SetParentURIContentListener( NS_STATIC_CAST( nsIURIContentListener*, this ) ); 
     372                }; 
     373 
    342374                // emit event that navigation is beginning 
    343375                mStatusText = std::string( "Browser loaded" ); 
    344                 LLEmbeddedBrowserWindowEvent event( getWindowId() ); 
     376                LLEmbeddedBrowserWindowEvent event( getWindowId(), getCurrentUri(), mStatusText ); 
    345377                mEventEmitter.update( &LLEmbeddedBrowserWindowObserver::onNavigateBegin, event ); 
     378 
     379                // about to move to a different page so have to stop grabbing a page 
     380                // but done one final grab in case the app doesn't ever call grabWindow again 
     381                grabWindow( 0, 0, mBrowserWidth, mBrowserHeight ); 
    346382        }; 
    347383 
     
    358394                }; 
    359395 
     396                // pick up raw HTML response status code 
     397                PRUint32 responseStatus = 0; 
     398                if ( request ) 
     399                { 
     400                        nsCOMPtr< nsIHttpChannel > httpChannel = do_QueryInterface( request ); 
     401                        if ( httpChannel ) 
     402                        { 
     403                                httpChannel->GetResponseStatus( &responseStatus ); 
     404                        }; 
     405                }; 
     406 
    360407                // emit event that navigation is finished 
    361408                mStatusText = std::string( "Done" ); 
    362                 LLEmbeddedBrowserWindowEvent event( getWindowId() ); 
     409                LLEmbeddedBrowserWindowEvent event( getWindowId(), getCurrentUri(), mStatusText, (int)responseStatus ); 
    363410                mEventEmitter.update( &LLEmbeddedBrowserWindowObserver::onNavigateComplete, event ); 
     411 
     412                // also set the flag here since back/forward navigation doesn't call progress change 
     413                grabWindow( 0, 0, mBrowserWidth, mBrowserHeight ); 
    364414        }; 
    365415 
     
    379429        }; 
    380430 
    381         LLEmbeddedBrowserWindowEvent event( getWindowId(), mStatusText ); 
     431        LLEmbeddedBrowserWindowEvent event( getWindowId(), getCurrentUri(), mStatusText ); 
    382432        mEventEmitter.update( &LLEmbeddedBrowserWindowObserver::onStatusTextChange, event ); 
    383433 
     
    389439// TODO: ought to check that this change is on the top frame and 
    390440// indicate this to the consumer of this class 
    391 NS_IMETHODIMP LLEmbeddedBrowserWindow::OnLocationChange( nsIWebProgress* progress, 
    392                                                                                                                        nsIRequest* request, 
    393                                                                                                                                nsIURI* location ) 
     441NS_IMETHODIMP LLEmbeddedBrowserWindow::OnLocationChange( nsIWebProgress* webProgress, 
     442                                                                                                                nsIRequest* request, 
     443                                                                                                                        nsIURI* location ) 
    394444{ 
    395445        if ( request ) 
     
    422472        mCurrentUri = newURI.get(); 
    423473 
    424         LLEmbeddedBrowserWindowEvent event( getWindowId(), mCurrentUri ); 
     474        LLEmbeddedBrowserWindowEvent event( getWindowId(), getCurrentUri() ); 
    425475        mEventEmitter.update( &LLEmbeddedBrowserWindowObserver::onLocationChange, event ); 
    426476 
    427477        return NS_OK; 
     478} 
     479 
     480//////////////////////////////////////////////////////////////////////////////// 
     481// change the background color that gets used between pages (usually white) 
     482void LLEmbeddedBrowserWindow::setBackgroundColor( const PRUint8 redIn, const PRUint8 greenIn, const PRUint8 blueIn ) 
     483{ 
     484        mBkgRed = redIn; 
     485        mBkgGreen = greenIn; 
     486        mBkgBlue = blueIn; 
     487} 
     488 
     489//////////////////////////////////////////////////////////////////////////////// 
     490// change the caret color (we have different backgrounds to edit fields - black caret on black background == bad) 
     491void LLEmbeddedBrowserWindow::setCaretColor( const PRUint8 redIn, const PRUint8 greenIn, const PRUint8 blueIn ) 
     492{ 
     493        mCaretRed = redIn; 
     494        mCaretGreen = greenIn; 
     495        mCaretBlue = blueIn; 
     496} 
     497 
     498//////////////////////////////////////////////////////////////////////////////// 
     499// 
     500void LLEmbeddedBrowserWindow::setEnabled( PRBool enabledIn ) 
     501{ 
     502        mEnabled = enabledIn; 
    428503} 
    429504 
     
    468543{ 
    469544        return mClickHref; 
     545} 
     546 
     547//////////////////////////////////////////////////////////////////////////////// 
     548// utility method that is used by observers to retrieve data after an event 
     549const std::string& LLEmbeddedBrowserWindow::getClickLinkTarget() 
     550{ 
     551        return mClickTarget; 
    470552} 
    471553 
     
    479561        mStatusText = std::string( NS_ConvertUTF16toUTF8( aMessage ).get() ); 
    480562 
    481         LLEmbeddedBrowserWindowEvent event( getWindowId(), mStatusText ); 
     563        LLEmbeddedBrowserWindowEvent event( getWindowId(), getCurrentUri(), mStatusText ); 
    482564        mEventEmitter.update( &LLEmbeddedBrowserWindowObserver::onStatusTextChange, event ); 
    483565 
     
    495577 
    496578//////////////////////////////////////////////////////////////////////////////// 
    497 // 
    498 unsigned char* LLEmbeddedBrowserWindow::grabWindow() 
    499 
     579// render a page into memory and grab the window 
     580// TODO: 0,0, browser width, browser height is always passed in right now 
     581//       need to make this work with arbitrary rects (i.e. the dirty rect) 
     582unsigned char* LLEmbeddedBrowserWindow::grabWindow( int xIn, int yIn, int widthIn, int heightIn ) 
     583
     584        // sanity check 
     585        if ( ! mWebBrowser ) 
     586                return 0; 
     587 
     588        // only grab the window if it's enabled 
     589        if ( ! mEnabled ) 
     590                return false; 
     591 
     592        // get the docshell 
    500593        nsCOMPtr< nsIDocShell > docShell = do_GetInterface( mWebBrowser ); 
    501594        if ( ! docShell ) 
    502595                return PR_FALSE; 
    503596 
     597        // get pres context 
    504598        nsCOMPtr< nsPresContext > presContext; 
    505599        nsresult result = docShell->GetPresContext( getter_AddRefs( presContext ) ); 
     
    507601                return PR_FALSE; 
    508602 
     603        // get view manager 
    509604        nsIViewManager* viewManager = presContext->GetViewManager(); 
    510605        if ( ! viewManager ) 
    511606                return PR_FALSE; 
    512607 
     608        // get the view 
    513609        nsIScrollableView* scrollableView = NULL; 
    514610        viewManager->GetRootScrollableView( &scrollableView ); 
    515  
    516611        nsIView* view = NULL; 
    517612        if ( scrollableView ) 
     
    520615                viewManager->GetRootView( view ); 
    521616 
     617        // get the rectangle we want to render in twips (this looks odd but takees care of scrolling too) 
    522618        nsRect rect = view->GetBounds() - view->GetPosition() - view->GetPosition(); 
    523619        if ( rect.IsEmpty() ) 
     
    525621 
    526622        float p2t = presContext->PixelsToTwips(); 
    527         rect.width = NSIntPixelsToTwips( mBrowserWidth, p2t ); 
    528         rect.height = NSIntPixelsToTwips( mBrowserHeight, p2t ); 
    529  
     623        rect.width = NSIntPixelsToTwips( widthIn, p2t ); 
     624        rect.height = NSIntPixelsToTwips( heightIn, p2t ); 
     625 
     626        // render the page 
    530627        nsCOMPtr< nsIRenderingContext > context; 
    531         result = viewManager->RenderOffscreen( view, rect, PR_FALSE, PR_FALSE, NS_RGB( mBackgroundRed, mBackgroundGreen, mBackgroundBlue ), getter_AddRefs( context ) ); 
     628        result = viewManager->RenderOffscreen( view, rect, PR_FALSE, PR_FALSE, NS_RGB( mBkgRed, mBkgGreen, mBkgBlue ), getter_AddRefs( context ) ); 
    532629        if ( NS_FAILED( result ) ) 
    533630                return 0; 
    534631 
     632        // retrieve the surface we rendered to 
    535633        nsIDrawingSurface* surface = nsnull; 
    536634        context->GetDrawingSurface( &surface ); 
     
    538636                return 0; 
    539637 
    540         float t2p = presContext->TwipsToPixels(); 
    541         PRInt32 width = NSTwipsToIntPixels( rect.width, t2p ); 
    542         PRInt32 height = NSTwipsToIntPixels( rect.height, t2p ); 
    543  
     638        // lock the surface and retrieve a pointer to the rendered data and current row span 
    544639        PRUint8* data; 
    545640        PRInt32 rowLen; 
    546  
    547641        // sometime rowspan ! width in pixels * bytes per pixel so save row span value and use in application 
    548         result = surface->Lock( 0, 0, width, height, reinterpret_cast< void** >( &data ), &mBrowserRowSpan, &rowLen, NS_LOCK_SURFACE_READ_ONLY ); 
     642        result = surface->Lock( xIn, yIn, widthIn, heightIn, reinterpret_cast< void** >( &data ), &mBrowserRowSpan, &rowLen, NS_LOCK_SURFACE_READ_ONLY ); 
    549643        if ( NS_FAILED ( result ) ) 
    550644                return 0; 
    551645 
    552         PRUint32 bytesPerPix = rowLen / width; 
    553         nsPixelFormat format; 
    554         surface->GetPixelFormat( &format ); 
    555         mBrowserDepth = bytesPerPix; 
    556         size_t bufferSize = mBrowserRowSpan * mBrowserHeight; 
    557  
    558         if( (mPageBuffer) && ( mPageBufferSize < bufferSize ) ) 
    559         { 
    560                 // the page buffer exists, but it's too small.  Delete it so it'll be recreated. 
    561                 delete[] mPageBuffer; 
    562                 mPageBuffer = NULL; 
    563                 mPageBufferSize = 0; 
     646        // save row span - it *can* change during the life of the app 
     647        mBrowserDepth = rowLen / mBrowserWidth; 
     648 
     649        // create memory buffer here so it can be deleted and recreated elsewhere 
     650        if ( ! mPageBuffer ) 
     651                mPageBuffer = new unsigned char[ mBrowserRowSpan * mBrowserHeight ]; 
     652 
     653        // save the pixels and optionally invert them  
     654        // (it's useful the SL client to get bitmaps that are inverted compared 
     655        // to the way that Mozilla renders them - allow to optionally flip 
     656        if ( mFlipBitmap ) 
     657        { 
     658                for( int y = mBrowserHeight - 1; y > -1; --y ) 
     659                { 
     660                        memcpy( mPageBuffer + y * mBrowserRowSpan,  
     661                                                data + ( mBrowserHeight - y - 1 ) * mBrowserRowSpan,  
     662                                                        mBrowserRowSpan ); 
     663                }; 
    564664        } 
    565  
    566         // create it here so it can be deleted and recreated elsewhere 
    567         if ( ! mPageBuffer ) 
    568         { 
    569                 mPageBufferSize = bufferSize; 
    570                 mPageBuffer = new unsigned char[ mPageBufferSize ]; 
    571         } 
    572  
    573         memcpy( mPageBuffer, data, bufferSize ); 
    574  
     665        else 
     666        { 
     667                memcpy( mPageBuffer, data, mBrowserRowSpan * mBrowserHeight ); 
     668        }; 
     669 
     670        // release and destroy the surface we rendered to 
    575671        surface->Unlock(); 
    576672        context->DestroyDrawingSurface( surface ); 
     
    579675 
    580676        return mPageBuffer; 
     677} 
     678 
     679//////////////////////////////////////////////////////////////////////////////// 
     680// all this just to render a caret! 
     681PRBool LLEmbeddedBrowserWindow::renderCaret() 
     682{ 
     683        nsCOMPtr< nsIWebBrowserFocus > focus = do_QueryInterface( mWebBrowser ); 
     684 
     685        nsCOMPtr< nsIDOMElement > focusedElement; 
     686        focus->GetFocusedElement( getter_AddRefs( focusedElement ) ); 
     687        if ( ! focusedElement ) 
     688                return NS_ERROR_FAILURE; 
     689 
     690        nsCOMPtr<nsIContent> focusedContent = do_QueryInterface( focusedElement ); 
     691 
     692        nsCOMPtr< nsIDOMWindow > domWindow; 
     693        mWebBrowser->GetContentDOMWindow( getter_AddRefs( domWindow ) ); 
     694        if ( ! domWindow ) 
     695                return NS_ERROR_FAILURE; 
     696 
     697        nsCOMPtr< nsIDOMDocument > domDocument; 
     698        domWindow->GetDocument( getter_AddRefs( domDocument ) ); 
     699        if ( ! domDocument ) 
     700                return NS_ERROR_FAILURE; 
     701 
     702        nsCOMPtr< nsIDocument> document = do_QueryInterface( domDocument ); 
     703        if ( ! document ) 
     704                return NS_ERROR_FAILURE; 
     705 
     706        nsIPresShell* presShell = document->GetShellAt( 0 ); 
     707        if ( ! presShell ) 
     708                return NS_ERROR_FAILURE; 
     709 
     710        nsCOMPtr< nsICaret > caret; 
     711        presShell->GetCaret( getter_AddRefs( caret ) ); 
     712 
     713        nsIFrame* frame = nsnull; 
     714        presShell->GetPrimaryFrameFor( focusedContent, &frame ); 
     715        if ( ! frame ) 
     716                return NS_ERROR_FAILURE; 
     717 
     718        nsCOMPtr<nsISelectionController> selCtrl; 
     719        frame->GetSelectionController( presShell->GetPresContext(), getter_AddRefs( selCtrl ) ); 
     720 
     721        nsCOMPtr<nsISelection> selection; 
     722        selCtrl->GetSelection( nsISelectionController::SELECTION_NORMAL, getter_AddRefs( selection ) ); 
     723 
     724        PRBool collapsed; 
     725        nsRect coords; 
     726        nsIView* caretView; 
     727        caret->GetCaretCoordinates( nsICaret::eTopLevelWindowCoordinates, selection, &coords, &collapsed, &caretView ); 
     728 
     729        float twips2Pixls = presShell->GetPresContext()->TwipsToPixels(); 
     730 
     731        PRInt32 caretX = NSTwipsToIntPixels( coords.x, twips2Pixls ); 
     732        PRInt32 caretY = NSTwipsToIntPixels( coords.y, twips2Pixls ); 
     733        PRInt32 caretHeight = NSTwipsToIntPixels( coords.height, twips2Pixls ); 
     734 
     735        if ( caretX > -1 && caretX < mBrowserWidth && caretY > -1 && caretY < mBrowserHeight ) 
     736        { 
     737                if ( mPageBuffer ) 
     738                { 
     739                        for( int y = 1; y < caretHeight - 1; ++y ) 
     740                        { 
     741                                PRInt32 base_pos = caretY + y; 
     742                                if ( mFlipBitmap ) 
     743                                        base_pos = mBrowserHeight - ( caretY + y ); 
     744 
     745                                // sometimes the caret seems valid when it really isn't - cap it to size of screen 
     746                                if ( caretY + y + caretHeight < mBrowserHeight ) 
     747                                { 
     748                                        mPageBuffer[ base_pos * getBrowserRowSpan() + ( caretX + 1 ) * mBrowserDepth + 0 ] = mCaretBlue; 
     749                                        mPageBuffer[ base_pos * getBrowserRowSpan() + ( caretX + 1 ) * mBrowserDepth + 1 ] = mCaretGreen; 
     750                                        mPageBuffer[ base_pos * getBrowserRowSpan() + ( caretX + 1 ) * mBrowserDepth + 2 ] = mCaretRed; 
     751                                }; 
     752                        }; 
     753                }; 
     754        }; 
     755 
     756        return NS_OK; 
    581757} 
    582758 
     
    637813{ 
    638814        if ( ! mWebNav ) 
    639                 return PR_FALSE; 
     815        { 
     816                return PR_FALSE; 
     817        }; 
    640818 
    641819        PRBool canGoBack = PR_FALSE; 
     
    693871 
    694872//////////////////////////////////////////////////////////////////////////////// 
    695 // 
     873// set the size of the browser window 
    696874PRBool LLEmbeddedBrowserWindow::setSize( PRInt16 widthIn, PRInt16 heightIn ) 
    697875{ 
    698         if ( widthIn > 2048 ) 
    699                 widthIn = 2048; 
    700  
    701         if ( heightIn > 2048 ) 
    702                 heightIn = 2048; 
    703  
    704876        if ( mBaseWindow ) 
    705877        { 
     
    708880                { 
    709881                        delete[] mPageBuffer; 
    710                         mPageBuffer = NULL; 
    711                         mPageBufferSize = 0; 
     882                        mPageBuffer = 0; 
    712883                }; 
    713884 
    714                 // record new size 
     885                // record new size (important: may change after grabWindow() is called); 
    715886                mBrowserWidth = widthIn; 
    716887                mBrowserHeight = heightIn; 
     888                mBrowserRowSpan = mBrowserWidth * mBrowserDepth; 
    717889 
    718890                // On the Mac, these calls do strange things to the main viewer window, and they don't seem necessary in any case. 
    719 #if WIN32 
     891               #ifdef WIN32 
    720892                // this is the actual OS (on Win32) Window so it needs to be hidden 
    721893                mBaseWindow->SetVisibility( PR_FALSE ); 
    722894 
    723                 // move off screen (and in a place that makes the combobox hack work 
     895                // move WAY off screen (and in a place that makes the combobox hack work) 
    724896                mBaseWindow->SetPosition( 8000, -6000 ); 
    725 #endif 
     897               #endif 
    726898 
    727899                // tell Mozilla about the new size 
     
    735907 
    736908//////////////////////////////////////////////////////////////////////////////// 
    737 // higher level mouse event 
    738 void LLEmbeddedBrowserWindow::mouseDown( PRInt16 xPosIn, PRInt16 yPosIn ) 
    739 
    740         const PRUint32 clickCount = 1; 
    741         sendMozillaMouseEvent( NS_MOUSE_LEFT_BUTTON_DOWN, xPosIn, yPosIn, clickCount ); 
    742 
    743  
    744 //////////////////////////////////////////////////////////////////////////////// 
    745 // higher level mouse event 
    746 void LLEmbeddedBrowserWindow::mouseUp( PRInt16 xPosIn, PRInt16 yPosIn ) 
    747 
    748         const PRUint32 clickCount = 1; 
    749         sendMozillaMouseEvent( NS_MOUSE_LEFT_BUTTON_UP, xPosIn, yPosIn, clickCount ); 
    750 
    751  
    752 //////////////////////////////////////////////////////////////////////////////// 
    753 // higher level mouse event 
    754 void LLEmbeddedBrowserWindow::mouseMove( PRInt16 xPosIn, PRInt16 yPosIn ) 
    755 
    756         const PRUint32 clickCount = 1;  // ignored? 
    757         sendMozillaMouseEvent( NS_MOUSE_MOVE, xPosIn, yPosIn, clickCount ); 
     909// 
     910PRBool LLEmbeddedBrowserWindow::flipWindow( PRBool flip ) 
     911
     912        mFlipBitmap = flip; 
     913 
     914        return true; 
    758915} 
    759916 
     
    769926 
    770927//////////////////////////////////////////////////////////////////////////////// 
     928// higher level mouse event 
     929void LLEmbeddedBrowserWindow::mouseDown( PRInt16 xPosIn, PRInt16 yPosIn ) 
     930{ 
     931        const PRUint32 clickCount = 1; 
     932        sendMozillaMouseEvent( NS_MOUSE_LEFT_BUTTON_DOWN, xPosIn, yPosIn, clickCount ); 
     933} 
     934 
     935//////////////////////////////////////////////////////////////////////////////// 
     936// higher level mouse event 
     937void LLEmbeddedBrowserWindow::mouseUp( PRInt16 xPosIn, PRInt16 yPosIn ) 
     938{ 
     939        const PRUint32 clickCount = 1; 
     940        sendMozillaMouseEvent( NS_MOUSE_LEFT_BUTTON_UP, xPosIn, yPosIn, clickCount ); 
     941} 
     942 
     943//////////////////////////////////////////////////////////////////////////////// 
     944// higher level mouse event 
     945void LLEmbeddedBrowserWindow::mouseMove( PRInt16 xPosIn, PRInt16 yPosIn ) 
     946{ 
     947        const PRUint32 clickCount = 1;  // ignored? 
     948        sendMozillaMouseEvent( NS_MOUSE_MOVE, xPosIn, yPosIn, clickCount ); 
     949} 
     950 
     951//////////////////////////////////////////////////////////////////////////////// 
    771952// utility methods to set an error message so something else can look at it 
    772953void LLEmbeddedBrowserWindow::scrollByLines( PRInt16 linesIn ) 
     
    786967//////////////////////////////////////////////////////////////////////////////// 
    787968// synthesizes a mouse event and sends into the embedded instance 
    788 // 
    789969// eventIn - NS_MOUSE_LEFT_BUTTON_DOWN, NS_MOUSE_LEFT_BUTTON_UP, etc. 
    790 // xPosIn, yPosIn - coordinates (in browser window space?
     970// xPosIn, yPosIn - coordinates (in browser window space
    791971// clickCountIn - use 1 for single click, 2 for double-click, etc. 
    792972PRBool LLEmbeddedBrowserWindow::sendMozillaMouseEvent( PRInt16 eventIn, PRInt16 xPosIn, PRInt16 yPosIn, PRUint32 clickCountIn ) 
    793973{ 
     974        if ( ! mEnabled ) 
     975                return PR_FALSE; 
     976 
     977        if ( ! mWebBrowser ) 
     978                return PR_FALSE; 
     979 
    794980        nsCOMPtr< nsIDocShell > docShell = do_GetInterface( mWebBrowser ); 
    795981        if ( ! docShell ) 
     
    8551041PRBool LLEmbeddedBrowserWindow::sendMozillaKeyboardEvent( PRUint32 uni_char, PRUint32 ns_vk_code ) 
    8561042{ 
    857         nsresult result = NS_OK; 
     1043        if ( ! mEnabled ) 
     1044                return PR_FALSE; 
     1045 
     1046        if ( ! mWebBrowser ) 
     1047                return PR_FALSE; 
    8581048 
    8591049        nsCOMPtr< nsIDocShell > docShell = do_GetInterface( mWebBrowser ); 
     
    8961086 
    8971087        nsEventStatus status; 
    898         result = viewManager->DispatchEvent( &keyEvent, &status ); 
     1088        nsresult result = viewManager->DispatchEvent( &keyEvent, &status ); 
    8991089        if ( NS_FAILED( result ) ) 
    9001090                return PR_FALSE; 
    9011091 
    9021092        return PR_TRUE; 
    903 } 
    904  
    905 //////////////////////////////////////////////////////////////////////////////// 
    906 // all this just to render a caret! 
    907 PRBool LLEmbeddedBrowserWindow::renderCaret() 
    908 { 
    909         nsCOMPtr< nsIWebBrowserFocus > focus = do_QueryInterface( mWebBrowser ); 
    910  
    911         nsCOMPtr< nsIDOMElement > focusedElement; 
    912         focus->GetFocusedElement( getter_AddRefs( focusedElement ) ); 
    913         if ( ! focusedElement ) 
    914                 return NS_ERROR_FAILURE; 
    915  
    916         nsCOMPtr<nsIContent> focusedContent = do_QueryInterface( focusedElement ); 
    917  
    918         nsCOMPtr< nsIDOMWindow > domWindow; 
    919         mWebBrowser->GetContentDOMWindow( getter_AddRefs( domWindow ) ); 
    920         if ( ! domWindow ) 
    921                 return NS_ERROR_FAILURE; 
    922  
    923         nsCOMPtr< nsIDOMDocument > domDocument; 
    924         domWindow->GetDocument( getter_AddRefs( domDocument ) ); 
    925         if ( ! domDocument ) 
    926                 return NS_ERROR_FAILURE; 
    927  
    928         nsCOMPtr< nsIDocument> document = do_QueryInterface( domDocument ); 
    929         if ( ! document ) 
    930                 return NS_ERROR_FAILURE; 
    931  
    932         nsIPresShell* presShell = document->GetShellAt( 0 ); 
    933         if ( ! presShell ) 
    934                 return NS_ERROR_FAILURE; 
    935  
    936         nsCOMPtr< nsICaret > caret; 
    937         presShell->GetCaret( getter_AddRefs( caret ) ); 
    938  
    939         nsIFrame* frame = nsnull; 
    940         presShell->GetPrimaryFrameFor( focusedContent, &frame ); 
    941         if ( ! frame ) 
    942                 return NS_ERROR_FAILURE; 
    943  
    944         nsCOMPtr<nsISelectionController> selCtrl; 
    945         frame->GetSelectionController( presShell->GetPresContext(), getter_AddRefs( selCtrl ) ); 
    946  
    947         nsCOMPtr<nsISelection> selection; 
    948         selCtrl->GetSelection( nsISelectionController::SELECTION_NORMAL, getter_AddRefs( selection ) ); 
    949  
    950         PRBool collapsed; 
    951         nsRect coords; 
    952         nsIView* caretView; 
    953         caret->GetCaretCoordinates( nsICaret::eTopLevelWindowCoordinates, selection, &coords, &collapsed, &caretView ); 
    954  
    955         float twips2Pixls = presShell->GetPresContext()->TwipsToPixels(); 
    956  
    957         PRInt32 caretX = NSTwipsToIntPixels( coords.x, twips2Pixls ); 
    958         PRInt32 caretY = NSTwipsToIntPixels( coords.y, twips2Pixls ); 
    959         PRInt32 caretHeight = NSTwipsToIntPixels( coords.height, twips2Pixls ); 
    960  
    961         if ( caretX > -1 && caretX < mBrowserWidth && caretY > -1 && caretY < mBrowserHeight ) 
    962         { 
    963                 if ( mPageBuffer ) 
    964                 { 
    965                         for( int y = 1; y < caretHeight - 1; ++y ) 
    966                         { 
    967                                 // sometimes the caret seems valid when it really isn't - cap it to size of screen 
    968                                 if ( caretY + y + caretHeight < mBrowserHeight ) 
    969                                 { 
    970                                         mPageBuffer[ ( caretY + y ) * getBrowserRowSpan() + ( caretX + 1 ) * mBrowserDepth + 0 ] = mCaretBlue; 
    971                                         mPageBuffer[ ( caretY + y ) * getBrowserRowSpan() + ( caretX + 1 ) * mBrowserDepth + 1 ] = mCaretGreen; 
    972                                         mPageBuffer[ ( caretY + y ) * getBrowserRowSpan() + ( caretX + 1 ) * mBrowserDepth + 2 ] = mCaretRed; 
    973                                 }; 
    974                         }; 
    975                 }; 
    976         }; 
    977  
    978         return NS_OK; 
    979 } 
    980  
    981 //////////////////////////////////////////////////////////////////////////////// 
    982 // 
    983 void LLEmbeddedBrowserWindow::setBackgroundColor( PRUint8 redIn, PRUint8 greenIn, PRUint8 blueIn ) 
    984 { 
    985         mBackgroundRed = redIn; 
    986         mBackgroundGreen = greenIn; 
    987         mBackgroundBlue = blueIn; 
    988 } 
    989  
    990 //////////////////////////////////////////////////////////////////////////////// 
    991 // change the caret color (we have different backgrounds to edit fields - black caret on black background == bad) 
    992 void LLEmbeddedBrowserWindow::setCaretColor( const PRUint8 redIn, const PRUint8 greenIn, const PRUint8 blueIn ) 
    993 { 
    994         mCaretRed = redIn; 
    995         mCaretGreen = greenIn; 
    996         mCaretBlue = blueIn; 
    9971093} 
    9981094 
     
    10071103        if ( linkElement ) 
    10081104        { 
     1105                // look for an href link 
    10091106                nsString name; 
    10101107                linkElement->GetAttribute( NS_ConvertUTF8toUTF16( "href" ), name ); 
    10111108                mClickHref = std::string( NS_ConvertUTF16toUTF8( name ).get() ); 
    10121109 
    1013                 LLEmbeddedBrowserWindowEvent event( getWindowId(), mClickHref ); 
    1014                 mEventEmitter.update( &LLEmbeddedBrowserWindowObserver::onClickLinkHref, event ); 
     1110                // look for a target element 
     1111                linkElement->GetAttribute( NS_ConvertUTF8toUTF16( "target" ), name ); 
     1112                mClickTarget = std::string( NS_ConvertUTF16toUTF8( name ).get() ); 
     1113 
     1114                // if the href link contains something 
     1115                if ( mClickHref.length() ) 
     1116                { 
     1117                        LLEmbeddedBrowserWindowEvent event( getWindowId(), getCurrentUri(), mClickHref, mClickTarget ); 
     1118                        mEventEmitter.update( &LLEmbeddedBrowserWindowObserver::onClickLinkHref, event ); 
     1119                }; 
    10151120        }; 
    10161121 
     
    10261131        std::string rawUri = newURI.get(); 
    10271132 
    1028         if ( rawUri.substr( 0, std::string( "secondlife://" ).length() ) == "secondlife://" ) 
    1029         { 
    1030                 LLEmbeddedBrowserWindowEvent event( getWindowId(), rawUri ); 
    1031                 mEventEmitter.update( &LLEmbeddedBrowserWindowObserver::onClickLinkSecondLife, event ); 
     1133        // are we navigating to a 'nofollow' link 
     1134        if ( mNoFollowScheme.length() && rawUri.substr( 0, mNoFollowScheme.length() ) == mNoFollowScheme ) 
     1135        { 
     1136                LLEmbeddedBrowserWindowEvent event( getWindowId(), rawUri, rawUri ); 
     1137                mEventEmitter.update( &LLEmbeddedBrowserWindowObserver::onClickLinkNoFollow, event ); 
    10321138 
    10331139                // tell browser we're handling things and don't follow link 
     
    10411147 
    10421148        return NS_OK; 
     1149} 
     1150 
     1151//////////////////////////////////////////////////////////////////////////////// 
     1152// 
     1153void LLEmbeddedBrowserWindow::setNoFollowScheme( std::string schemeIn ) 
     1154{ 
     1155        mNoFollowScheme = schemeIn; 
     1156} 
     1157 
     1158//////////////////////////////////////////////////////////////////////////////// 
     1159// 
     1160std::string LLEmbeddedBrowserWindow::getNoFollowScheme() 
     1161{ 
     1162        return mNoFollowScheme; 
    10431163} 
    10441164 
     
    11071227void LLEmbeddedBrowserWindow::focusBrowser( PRBool focusBrowserIn ) 
    11081228{ 
    1109         if ( focusBrowserIn ) 
    1110         { 
    1111                 nsCOMPtr< nsIWebBrowserFocus > focus( do_GetInterface( mWebBrowser ) ); 
    1112                 focus->Activate(); 
     1229        if ( mWebBrowser ) 
     1230        { 
     1231                if ( focusBrowserIn ) 
     1232                { 
     1233                        nsCOMPtr< nsIWebBrowserFocus > focus( do_GetInterface( mWebBrowser ) ); 
     1234                        focus->Activate(); 
     1235                } 
     1236                else 
     1237                { 
     1238                        nsCOMPtr< nsIWebBrowserFocus > focus( do_GetInterface( mWebBrowser ) ); 
     1239                        focus->Deactivate(); 
     1240                }; 
     1241        }; 
     1242
     1243 
     1244//////////////////////////////////////////////////////////////////////////////// 
     1245// 
     1246void LLEmbeddedBrowserWindow::setWindowId( int windowIdIn ) 
     1247
     1248        mWindowId = windowIdIn; 
     1249
     1250 
     1251//////////////////////////////////////////////////////////////////////////////// 
     1252// 
     1253int LLEmbeddedBrowserWindow::getWindowId() 
     1254
     1255        //printf("## Getting id for %p and it is %d\n", this, mWindowId ); 
     1256 
     1257        return mWindowId; 
     1258
     1259 
     1260//////////////////////////////////////////////////////////////////////////////// 
     1261// add / remove the toolkit (and therefore 'page changed') observer 
     1262PRBool LLEmbeddedBrowserWindow::enableToolkitObserver( PRBool enableIn ) 
     1263
     1264        //TODO: AddObserver fails if I grab the toolkit this way. 
     1265        //static NS_DEFINE_CID(kNS_TOOLKIT_CID, NS_TOOLKIT_CID); 
     1266        //nsresult result1; 
     1267        //nsCOMPtr< nsIToolkit > toolkit = do_GetService( kNS_TOOLKIT_CID, &result1 ); 
     1268        //if ( ( result1 == NS_OK ) && toolkit ) 
     1269        //{ 
     1270        //      if ( toolkit->AddObserver( this ) ) 
     1271        //      { 
     1272        //              return true; 
     1273        //      }; 
     1274        //}; 
     1275        //return false; 
     1276 
     1277        // TODO: this is horrible but seems to work - need a better way to get the toolkit 
     1278        nsCOMPtr< nsIDocShell > docShell = do_GetInterface( mWebBrowser ); 
     1279        if ( ! docShell ) 
     1280                return false; 
     1281 
     1282        nsCOMPtr< nsPresContext > presContext; 
     1283        nsresult result = docShell->GetPresContext( getter_AddRefs( presContext ) ); 
     1284        if ( NS_FAILED( result ) || ( ! presContext ) ) 
     1285                return false; 
     1286 
     1287        nsIViewManager* viewManager = presContext->GetViewManager(); 
     1288        if ( ! viewManager ) 
     1289                return false; 
     1290 
     1291        nsIView* rootView; 
     1292        result = viewManager->GetRootView( rootView ); 
     1293        if ( NS_FAILED( result ) || ( ! rootView ) ) 
     1294                return false; 
     1295 
     1296        nsCOMPtr< nsIWidget > widget = rootView->GetWidget(); 
     1297        if ( ! widget ) 
     1298                return false; 
     1299 
     1300        nsCOMPtr< nsIToolkit > mToolkit = widget->GetToolkit(); 
     1301        if ( ! mToolkit ) 
     1302                return false; 
     1303 
     1304        if ( enableIn ) 
     1305                mToolkit->AddObserver( this ); 
     1306        else 
     1307                mToolkit->RemoveObserver( this ); 
     1308 
     1309        return true; 
     1310
     1311 
     1312//////////////////////////////////////////////////////////////////////////////// 
     1313// something on the page changed - e.g. a new page loaded, scrolling, user 
     1314// input or as the result of some kind of animation. 
     1315// NOTE: we don't call grabWindow here as this can stall graphics apps - 
     1316//       we merely pass back an event to the app and let it decide when/if 
     1317//       to call grabWindow() 
     1318NS_METHOD LLEmbeddedBrowserWindow::NotifyInvalidated( nsIWidget *aWidget, PRInt32 x, PRInt32 y, PRInt32 width, PRInt32 height ) 
     1319
     1320//      printf("LLEmbeddedBrowserWindow::NotifyInvalidated(%p, %d, %d, %d, %d)\n", (void*)aWidget, (int)x, (int)y, (int)width, (int)height); 
     1321 
     1322        // try to match widget-window against ourselves to see if we need to update the texture 
     1323        // only works using native widgets (on Windows) at the moment - needs to be moved to platform agnostic code ASAP 
     1324        #ifdef WIN32 
     1325 
     1326        // this is horrible beyond words but it seems to work... 
     1327        // nsToolkit tells us that a widget changed and we need to see if it's this instance 
     1328        // so we can emit an event that causes the parent app to update the browser texture 
     1329        nsIWidget* mainWidget; 
     1330        mBaseWindow->GetMainWidget( &mainWidget ); 
     1331 
     1332        HWND nativeWidget = (HWND)aWidget->GetNativeData( NS_NATIVE_WIDGET ); 
     1333        HWND nativeWidgetChild; 
     1334        while ( ::GetParent( nativeWidget ) ) 
     1335        { 
     1336                nativeWidgetChild = nativeWidget; 
     1337                nativeWidget = ::GetParent( nativeWidget ); 
     1338        }; 
     1339 
     1340        if ( ( (HWND)mainWidget->GetNativeData( NS_NATIVE_WIDGET ) ) == nativeWidgetChild ) 
     1341        { 
     1342                LLEmbeddedBrowserWindowEvent event( getWindowId(), getCurrentUri(), x, y, width, height ); 
     1343                mEventEmitter.update( &LLEmbeddedBrowserWindowObserver::onPageChanged, event ); 
     1344        }; 
     1345 
     1346        // other platforms will always update - desperately inefficient but you'll see something. 
     1347        #else 
     1348                LLEmbeddedBrowserWindowEvent event( getWindowId(), getCurrentUri(), x, y, width, height ); 
     1349                mEventEmitter.update( &LLEmbeddedBrowserWindowObserver::onPageChanged, event ); 
     1350        #endif 
     1351 
     1352        return NS_OK; 
     1353
     1354 
     1355//////////////////////////////////////////////////////////////////////////////// 
     1356// 
     1357std::string LLEmbeddedBrowserWindow::evaluateJavascript( std::string scriptIn ) 
     1358
     1359        nsCOMPtr< nsIScriptGlobalObjectOwner > theGlobalObjectOwner( do_GetInterface( mWebBrowser ) ); 
     1360 
     1361        if ( theGlobalObjectOwner ) 
     1362        { 
     1363                nsIScriptGlobalObject* theGlobalObject; 
     1364                theGlobalObject = theGlobalObjectOwner->GetScriptGlobalObject(); 
     1365 
     1366                nsIScriptContext* theScriptContext = theGlobalObject->GetContext(); 
     1367 
     1368                PRBool IsUndefined; 
     1369                nsString output; 
     1370                nsresult result = theScriptContext->EvaluateString(NS_ConvertUTF8toUTF16(scriptIn.c_str()), 
     1371                   nsnull, nsnull, "", 1, nsnull, &output, &IsUndefined); 
     1372 
     1373                if( NS_FAILED( result ) ) 
     1374                        return ""; 
     1375 
     1376                return std::string( NS_ConvertUTF16toUTF8( output ).get() ); 
    11131377        } 
    1114         else 
    1115         { 
    1116                 nsCOMPtr< nsIWebBrowserFocus > focus( do_GetInterface( mWebBrowser ) ); 
    1117                 focus->Deactivate(); 
    1118         }; 
    1119 
    1120  
    1121 //////////////////////////////////////////////////////////////////////////////// 
    1122 // 
    1123 void LLEmbeddedBrowserWindow::setWindowId( int windowIdIn ) 
    1124 
    1125         mWindowId = windowIdIn; 
    1126 
    1127  
    1128 //////////////////////////////////////////////////////////////////////////////// 
    1129 // 
    1130 int LLEmbeddedBrowserWindow::getWindowId() 
    1131 
    1132         return mWindowId; 
     1378 
     1379        return ""; 
    11331380} 
    11341381 
  • trunk/llmozlib2/llembeddedbrowserwindow.h

    r3 r8  
    1 /** 
    2  * @file llembeddedbrowserwindow.h 
    3  * @brief LLEmbeddedBrowserWindow and associated helpers declaration. 
    4  * 
    5  * $LicenseInfo:firstyear=2006&license=viewergpl$ 
    6  * 
    7  * Copyright (c) 2006-2007, Linden Research, Inc. 
    8  * 
    9  * Second Life Viewer Source Code 
    10  * The source code in this file ("Source Code") is provided by Linden Lab 
    11  * to you under the terms of the GNU General Public License, version 2.0 
    12  * ("GPL"), unless you have obtained a separate licensing agreement 
    13  * ("Other License"), formally executed by you and Linden Lab.  Terms of 
    14  * the GPL can be found in doc/GPL-license.txt in this distribution, or 
    15  * online at http://secondlife.com/developers/opensource/gplv2 
    16  * 
    17  * There are special exceptions to the terms and conditions of the GPL as 
    18  * it is applied to this Source Code. View the full text of the exception 
    19  * in the file doc/FLOSS-exception.txt in this software distribution, or 
    20  * online at http://secondlife.com/developers/opensource/flossexception 
    21  * 
    22  * By copying, modifying or distributing this software, you acknowledge 
    23  * that you have read and understood your obligations described above, 
    24  * and agree to abide by those obligations. 
    25  * 
    26  * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO 
    27  * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, 
    28  * COMPLETENESS OR PERFORMANCE. 
    29  * $/LicenseInfo$ 
    30  */ 
     1/* ***** BEGIN LICENSE BLOCK ***** 
     2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 
     3 * 
     4 * The contents of this file are subject to the Mozilla Public License Version 
     5 * 1.1 (the "License"); you may not use this file except in compliance with 
     6 * the License. You may obtain a copy of the License at 
     7 * http://www.mozilla.org/MPL/ 
     8 * 
     9 * Software distributed under the License is distributed on an "AS IS" basis, 
     10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
     11 * for the specific language governing rights and limitations under the 
     12 * License. 
     13 * 
     14 * The Original Code is Linden Lab Inc. (http://lindenlab.com) code. 
     15 * 
     16 * The Initial Developer of the Original Code is: 
     17 *   Callum Prentice (callum@ubrowser.com) 
     18 * 
     19 * Portions created by the Initial Developer are Copyright (C) 2006 
     20 * the Initial Developer. All Rights Reserved. 
     21 * 
     22 * Contributor(s): 
     23 *  Callum Prentice (callum@ubrowser.com) 
     24 * 
     25 * Alternatively, the contents of this file may be used under the terms of 
     26 * either the GNU General Public License Version 2 or later (the "GPL"), or 
     27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 
     28 * in which case the provisions of the GPL or the LGPL are applicable instead 
     29 * of those above. If you wish to allow use of your version of this file only 
     30 * under the terms of either the GPL or the LGPL, and not to allow others to 
     31 * use your version of this file under the terms of the MPL, indicate your 
     32 * decision by deleting the provisions above and replace them with the notice 
     33 * and other provisions required by the GPL or the LGPL. If you do not delete 
     34 * the provisions above, a recipient may use your version of this file under 
     35 * the terms of any one of the MPL, the GPL or the LGPL. 
     36 * 
     37 * ***** END LICENSE BLOCK ***** */ 
    3138 
    3239#ifndef LLEMBEDDEDBROWSERWINDOW_H 
     
    4855#include "nsWeakReference.h" 
    4956#include "nsIWebBrowser.h" 
     57#include "nsIToolkit.h" 
     58#include "nsIScriptGlobalObject.h" 
     59#include "nsIScriptGlobalObjectOwner.h" 
     60#include "nsIScriptContext.h" 
     61 
     62#ifdef WIN32 
     63#pragma warning( 3 : 4265 ) // "class has virtual functions, but destructor is not virtual" 
     64#endif 
    5065 
    5166#include <string> 
     
    5368#include <algorithm> 
    5469 
    55 #include "llmozlib.h" 
     70#include "llmozlib2.h" 
    5671 
    5772/////////////////////////////////////////////////////////////////////////////// 
    58 // manages the process of sotring and emitting events that the consumer 
     73// manages the process of storing and emitting events that the consumer 
    5974// of the embedding class can observe 
    6075template< class T > 
     
    124139        public nsIURIContentListener, 
    125140        public nsSupportsWeakReference, 
    126         public nsIDOMEventListener 
     141        public nsIDOMEventListener, 
     142        public nsIToolkitObserver 
    127143{ 
    128144        public: 
     
    136152                NS_DECL_NSIURICONTENTLISTENER 
    137153                NS_DECL_NSIDOMEVENTLISTENER 
    138  
     154                NS_DECL_NSITOOLKITOBSERVER 
     155 
     156                // housekeeping 
    139157                nsresult createBrowser( void* nativeWindowHandleIn, PRInt32 widthIn, PRInt32 heightIn, nsIWebBrowser** aBrowser ); 
     158                void setParent( LLEmbeddedBrowser* parentIn ) { mParent = parentIn; }; 
    140159                PRBool setSize( PRInt16 widthIn, PRInt16 heightIn ); 
    141160                void focusBrowser( PRBool focusBrowserIn ); 
     
    144163                int getWindowId(); 
    145164 
     165                // random accessors 
    146166                const PRInt16 getPercentComplete(); 
    147167                const std::string& getStatusMsg(); 
    148168                const std::string& getCurrentUri(); 
    149169                const std::string& getClickLinkHref(); 
    150  
    151                 unsigned char* grabWindow(); 
     170                const std::string& getClickLinkTarget(); 
     171 
     172                // memory buffer management 
     173                unsigned char* grabWindow( int xIn, int yIn, int widthIn, int heightIn ); 
     174                PRBool flipWindow( PRBool flip ); 
    152175                unsigned char* getPageBuffer(); 
    153176                PRInt16 getBrowserWidth(); 
     
    156179                PRInt32 getBrowserRowSpan(); 
    157180 
    158                 void setBackgroundColor( PRUint8 redIn, PRUint8 greenIn, PRUint8 blueIn ); 
     181                // set background color that you see in between pages - default is white but sometimes useful to change 
     182                void setBackgroundColor( const PRUint8 redIn, const PRUint8 greenIn, const PRUint8 blueIn ); 
     183 
     184                // change the caret color (we have different backgrounds to edit fields - black caret on black background == bad) 
    159185                void setCaretColor( const PRUint8 redIn, const PRUint8 greenIn, const PRUint8 blueIn ); 
    160186 
     187                // can turn off updates to a page - e.g. when it's hidden by your windowing system 
     188                void setEnabled( PRBool enabledIn ); 
     189 
     190                // navigation 
    161191                void navigateStop(); 
    162192                PRBool navigateTo( const std::string uriIn ); 
     
    166196                void navigateForward(); 
    167197 
     198                // javascript access/control 
     199                std::string evaluateJavascript( std::string scriptIn ); 
     200 
     201                // redirection when you hit a missing page 
    168202                bool set404RedirectUrl( std::string redirect_url ); 
    169203                bool clr404RedirectUrl(); 
    170204 
     205                // mouse & keyboard events 
    171206                void mouseDown( PRInt16 xPosIn, PRInt16 yPosIn ); 
    172207                void mouseUp( PRInt16 xPosIn, PRInt16 yPosIn ); 
     
    176211                void unicodeInput( PRUint32 uni_char ); 
    177212 
     213                // allow consumers of this class and to observe browser events 
    178214                bool addObserver( LLEmbeddedBrowserWindowObserver* observerIn ); 
    179215                bool remObserver( LLEmbeddedBrowserWindowObserver* observerIn ); 
     216 
     217                // accessor/mutator for scheme that browser doesn't follow - e.g. secondlife.com:// 
     218                void setNoFollowScheme( std::string schemeIn ); 
     219                std::string getNoFollowScheme(); 
    180220 
    181221        private: 
     
    183223                PRBool sendMozillaKeyboardEvent( PRUint32 keyIn, PRUint32 ns_vk_code ); 
    184224                PRBool renderCaret(); 
     225                PRBool enableToolkitObserver( PRBool enableIn ); 
     226 
    185227                LLEmbeddedBrowserWindowEmitter< LLEmbeddedBrowserWindowObserver > mEventEmitter; 
     228 
     229                LLEmbeddedBrowser* mParent; 
    186230                PRInt16 mPercentComplete; 
    187231                std::string mStatusText; 
    188232                std::string mCurrentUri; 
    189233                std::string mClickHref; 
    190                 std::string m404RedirectUrl
    191  
     234                std::string mClickTarget
     235                std::string mNoFollowScheme; 
    192236                nsCOMPtr< nsIWebBrowser > mWebBrowser; 
    193237                nsCOMPtr< nsIBaseWindow > mBaseWindow; 
    194238                nsCOMPtr< nsIWebNavigation > mWebNav; 
    195  
    196239                int mWindowId; 
    197  
    198                 PRUint8 mBackgroundRed; 
    199                 PRUint8 mBackgroundGreen; 
    200                 PRUint8 mBackgroundBlue; 
    201                 PRUint8 mCaretRed; 
    202                 PRUint8 mCaretGreen; 
    203                 PRUint8 mCaretBlue; 
    204  
    205240                unsigned char* mPageBuffer; 
    206                 size_t mPageBufferSize; 
     241                std::string m404RedirectUrl; 
     242                PRBool mEnabled; 
     243                PRBool mFlipBitmap; 
    207244                PRInt32 mBrowserRowSpan; 
    208245                PRInt16 mBrowserWidth; 
    209246                PRInt16 mBrowserHeight; 
    210247                PRInt16 mBrowserDepth; 
     248                PRUint8 mBkgRed; 
     249                PRUint8 mBkgGreen; 
     250                PRUint8 mBkgBlue; 
     251                PRUint8 mCaretRed; 
     252                PRUint8 mCaretGreen; 
     253                PRUint8 mCaretBlue; 
    211254}; 
    212255 
    213 #ifdef WIN32 
    214 #pragma warning( 3 : 4265 ) // "class has virtual functions, but destructor is not virtual" 
    215 #endif 
    216  
    217256#endif // LLEMBEDEDDBROWSERWINDOW_H 
  • trunk/llmozlib2/repackage_runtime_mac.sh

    r1 r8  
    11#!/bin/bash 
    22 
    3 # This script adds or updates libllmozlib.dylib in mozilla-universal-darwin.tgz. 
     3# This script adds or updates libllmozlib2.dylib in mozilla-universal-darwin.tgz. 
    44sandbox_location="$1" 
    55 
     6xcodebuild -project llmozlib2.xcodeproj -target llmozlib2 -configuration 'Release' build 
    67 
    7 if [ -f build/Release/libllmozlib.dylib ]; then 
    8         echo "libllmozlib.dylib found" 
     8if [ -f build/Release/libllmozlib2.dylib ]; then 
     9        echo "libllmozlib2.dylib found" 
    910else 
    10         echo "libllmozlib.dylib not found, please build the Release target in llmozlib.xcodeproj" 
     11        echo "libllmozlib2.dylib not found, please build the Release target in llmozlib.xcodeproj" 
    1112        exit 1 
    1213fi 
     
    3031(cd mozilla-universal-darwin && tar -zxf ../mozilla-universal-darwin-original.tgz) 
    3132 
    32 echo "Adding libllmozlib.dylib..." 
     33echo "Adding libllmozlib2.dylib..." 
    3334 
    34 # copy in the latest built version of llmozlib 
    35 cp ./build/Release/libllmozlib.dylib mozilla-universal-darwin 
     35# copy in the latest built version of llmozlib2 
     36cp ./build/Release/libllmozlib2.dylib mozilla-universal-darwin 
    3637 
    3738echo "Removing unneeded pieces..." 
     
    4849echo "Creating mozilla-universal-darwin.tgz..." 
    4950 
    50 # tar up the runtime and llmozlib  
     51# tar up the runtime and llmozlib2  
    5152rm -f ./mozilla-universal-darwin.tgz 
    5253tar -zcf ./mozilla-universal-darwin.tgz \ 
     
    6263 
    6364echo "Copying stub library to $sandbox_location/libraries/universal-darwin/..." 
    64 cp build/Release_stub/libllmozlib.dylib $sandbox_location/libraries/universal-darwin/lib_debug/libllmozlib.dylib 
    65 cp build/Release_stub/libllmozlib.dylib $sandbox_location/libraries/universal-darwin/lib_release/libllmozlib.dylib 
     65cp build/Release_stub/libllmozlib2.dylib $sandbox_location/libraries/universal-darwin/lib_debug/libllmozlib2.dylib 
     66cp build/Release_stub/libllmozlib2.dylib $sandbox_location/libraries/universal-darwin/lib_release/libllmozlib2.dylib 
    6667 
    6768echo "done!" 
  • trunk/llmozlib2/tests/dependencies/include/GL/glut.h

    r1 r8  
    1111 
    1212/* GLUT 3.7 now tries to avoid including <windows.h> 
    13    to avoid name space pollution, but Win32's <GL/gl.h>  
     13   to avoid name space pollution, but Win32's <GL/gl.h> 
    1414   needs APIENTRY and WINGDIAPI defined properly. */ 
    1515# if 0 
     
    162162/** 
    163163 GLUT API revision history: 
    164   
     164 
    165165 GLUT_API_VERSION is updated to reflect incompatible GLUT 
    166166 API changes (interface changes, semantic changes, deletions, 
    167167 or additions). 
    168   
     168 
    169169 GLUT_API_VERSION=1  First public release of GLUT.  11/29/94 
    170170 
     
    187187/** 
    188188 GLUT implementation revision history: 
    189   
     189 
    190190 GLUT_XLIB_IMPLEMENTATION is updated to reflect both GLUT 
    191191 API revisions and implementation revisions (ie, bug fixes). 
     
    195195 
    196196 GLUT_XLIB_IMPLEMENTATION=2  mjk's second public release of 
    197  GLUT Xlib-based implementation providing GLUT version 2  
     197 GLUT Xlib-based implementation providing GLUT version 2 
    198198 interfaces. 
    199199