home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / macfe / central / CBrowserContext.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  13.9 KB  |  486 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. // CBrowserContext.h
  20.  
  21. #pragma once
  22.  
  23.  
  24. #include <LBroadcaster.h>
  25. #include <LSharable.h>
  26.  
  27. #include "CNSContext.h"
  28.  
  29. #include "structs.h"
  30. #include "ctxtfunc.h"
  31. #include "cstring.h"
  32.  
  33. class CHTMLView;
  34. class CSharableCompositor;
  35.  
  36. const MessageT msg_SecurityState = 'SECS';    // ESecurityState
  37.  
  38. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  39. //
  40. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  41.  
  42. class CBrowserContext : public CNSContext
  43. {
  44.     friend class CNSContextCallbacks;
  45.     friend class CPlainTextConversionContext;
  46.     
  47.     public:
  48.         // history navigation
  49.         // these are special indices for LoadHistoryEntry
  50.         enum {
  51.             index_Reload        =    -2,
  52.             index_GoBack        =    -1,
  53.             index_GoForward        =     0
  54.         };
  55.             
  56.                                 CBrowserContext();
  57.                                 CBrowserContext(MWContextType inType);
  58.                                 CBrowserContext(const CBrowserContext& inOriginal);
  59.                                 
  60.         virtual                 ~CBrowserContext();
  61.  
  62.         virtual void                NoMoreUsers(void);
  63.  
  64.         operator MWContext*();
  65.         operator MWContext&();
  66.  
  67.         virtual    void                SetCurrentView(CHTMLView* inView);
  68.  
  69.         virtual    CBrowserContext*    GetTopContext();
  70.         
  71.         virtual    Boolean                HasColorSpace(void) const;
  72.         virtual    Boolean                HasGridParent(void) const;
  73.         virtual    Boolean                HasFullPagePlugin(void) const;
  74.         
  75.         virtual    void                SetLoadImagesOverride(Boolean inOverride);
  76.         virtual Boolean                IsLoadImagesOverride(void) const;
  77.  
  78.         virtual void                SetDelayImages(Boolean inDelay);
  79.         virtual    Boolean                IsImageLoadingDelayed(void) const;
  80.  
  81.         virtual Boolean                IsRestrictedTarget(void) const;
  82.         virtual void                SetRestrictedTarget(Boolean inIsRestricted);
  83.         
  84.         virtual Boolean                IsRootDocInfoContext();
  85.         virtual Boolean                IsViewSourceContext();
  86.         
  87.         virtual Boolean                IsSpecialBrowserContext();
  88.         
  89.         virtual Boolean                SupportsPageServices();
  90.         
  91. // FIX ME!!! ACCESSOR for unique ID
  92.  
  93.             // LAYERS / COMPOSITOR
  94.  
  95.         virtual Boolean                HasCompositor(void) const;
  96.     
  97.         virtual CL_Compositor*        GetCompositor(void) const;
  98.     
  99.         virtual    void                SetCompositor(
  100.                                             CSharableCompositor*    inCompositor);
  101.  
  102.         virtual    PRBool                HandleLayerEvent(    
  103.                                             CL_Layer*                inLayer, 
  104.                                             CL_Event*                inEvent);
  105.                                             
  106.         virtual PRBool                HandleEmbedEvent(    
  107.                                             LO_EmbedStruct*            inEmbed, 
  108.                                             CL_Event*                inEvent);
  109.                                                         
  110.             // HISTORY
  111.         virtual    void                RememberHistoryPosition(
  112.                                             Int32                    inX,
  113.                                             Int32                    inY);
  114.     
  115.         virtual void                 InitHistoryFromContext( CBrowserContext *parentContext);
  116.  
  117.  
  118.             // Image Observer
  119.             
  120.         virtual Boolean                IsContextLooping();
  121.         Boolean                        IsMochaLoadingImages() { return mMochaImagesLoading; }
  122.  
  123.         void                        SetImagesLoading(Boolean inValue);
  124.         void                        SetImagesLooping(Boolean inValue);
  125.         void                        SetImagesDelayed(Boolean inValue);
  126.         void                        SetMochaImagesLoading(Boolean inValue);
  127.         void                        SetMochaImagesLooping(Boolean inValue);
  128.         void                        SetMochaImagesDelayed(Boolean inValue);
  129.  
  130.     protected:
  131.         // we don't need to expose these
  132.         virtual History_entry*        GetNextHistoryEntry(void);
  133.         virtual History_entry*        GetPreviousHistoryEntry(void);
  134.         virtual Boolean                IsContextLoopingRecurse();
  135.     
  136.     public:
  137.         virtual Boolean                CanGoForward(void);
  138.         virtual Boolean                CanGoBack(void);
  139.  
  140.         virtual Boolean                HasGridChildren(void);
  141.         virtual Boolean                IsGridChild(void);
  142.         virtual Boolean                IsGridCell();
  143.  
  144.         virtual void                GoForwardOneHost();
  145.         virtual void                GoBackOneHost();
  146.  
  147.         virtual void                GoForward(void);
  148.         virtual void                GoBack(void);
  149.         virtual void                LoadHistoryEntry(    // one-based
  150.                                             Int32                     inIndex,
  151.                                             Boolean                    inSuperReload = false);
  152.         virtual Boolean                GoForwardInGrid(void);
  153.         virtual Boolean                GoBackInGrid(void);        
  154.         
  155. /*
  156.             // URL MANIPULATION
  157.         virtual    cstring                GetCurrentURL(void);
  158.         
  159.         virtual    void                SwitchLoadURL(
  160.                                             URL_Struct*                inURL,
  161.                                             FO_Present_Types        inOutputFormat);
  162.                                             
  163.         virtual    void                ImmediateLoadURL(
  164.                                             URL_Struct*                inURL,
  165.                                             FO_Present_Types        inOutputFormat);
  166. */
  167.             // REPAGINTAION
  168.  
  169.         virtual    void                 Repaginate(NET_ReloadMethod repage = NET_RESIZE_RELOAD);
  170.         virtual    Boolean                IsRepaginating(void) const;
  171.         virtual    Boolean                IsRepagintaitonPending(void) const;
  172.  
  173.             // FRAME MANAGEMENT
  174.  
  175.         virtual    MWContext*             CreateGridContext(
  176.                                             void*                     inHistList,
  177.                                             void*                     inHistEntry,
  178.                                             Int32                    inX,
  179.                                             Int32                     inY,
  180.                                             Int32                    inWidth,
  181.                                             Int32                    inHeight,
  182.                                             char*                     inURLString,
  183.                                             char*                     inWindowTarget,
  184.                                             Int8                    inScrollMode,
  185.                                             NET_ReloadMethod         inForceReload,
  186.                                             Bool                     inNoEdge);
  187.                                             
  188.         virtual void*                DisposeGridContext(
  189.                                             XP_Bool                    inSaveHistory);
  190.                                             
  191.         virtual    void                DisposeGridChild(
  192.                                             CBrowserContext*                inChildContext);
  193.                                             
  194.         virtual    void                RestructureGridContext(
  195.                                             Int32                    inX,
  196.                                             Int32                     inY,
  197.                                             Int32                    inWidth,
  198.                                             Int32                    inHeight);
  199.  
  200.         virtual    void                GetFullGridSize(
  201.                                             Int32&                    outWidth,
  202.                                             Int32&                    outHeight);
  203.  
  204.         virtual    void                ReloadGridFromHistory(
  205.                                             void*                     inHistEntry,
  206.                                             NET_ReloadMethod         inReload);
  207.  
  208.  
  209.         virtual    Int32                CountGridChildren(void) const;
  210.  
  211.         // save dialog for editor--Paul will fix some time
  212.         virtual CSaveProgress*        GetSaveDialog() { return fSaveDialog; };
  213.         virtual void                SetSaveDialog( CSaveProgress* theDialog ) { fSaveDialog = theDialog; };
  214.  
  215.         // override for JavaScript foolishness
  216.         virtual    void                 Alert(
  217.                                             const char*                inAlertText);
  218.  
  219.         virtual    XP_Bool                Confirm(
  220.                                             const char*             inMessage);
  221.     protected:
  222.         CSaveProgress*                fSaveDialog;
  223.  
  224.         void                        ConstructJSDialogTitle(LStr255& outTitle);
  225.  
  226.  
  227.             // CALLBACK IMPLEMENTATION
  228.  
  229. // FIX ME!!! this needs to become an apple event
  230. //        virtual    MWContext*             CreateNewDocWindow(
  231. //                                            URL_Struct*                inURL);
  232.  
  233.         virtual    void                 LayoutNewDocument(
  234.                                             URL_Struct*                inURL,
  235.                                             Int32*                    inWidth,
  236.                                             Int32*                    inHeight,
  237.                                             Int32*                    inMarginWidth,
  238.                                             Int32*                    inMarginHeight);
  239.  
  240.         virtual    void                 SetDocTitle(
  241.                                             char*                     inTitle);
  242.                                             
  243.         virtual    void                 FinishedLayout(void);
  244.                                             
  245.         virtual    int                 GetTextInfo(
  246.                                             LO_TextStruct*            inText,
  247.                                             LO_TextInfo*            inTextInfo);
  248.                                             
  249.         virtual    int                 MeasureText(
  250.                                             LO_TextStruct*            inText,
  251.                                             short*                    outCharLocs);
  252.                                             
  253.         virtual    void                 GetEmbedSize(
  254.                                             LO_EmbedStruct*            inEmbedStruct,
  255.                                             NET_ReloadMethod        inReloadMethod);
  256.                                             
  257.         virtual    void                 GetJavaAppSize(
  258.                                             LO_JavaAppStruct*        inJavaAppStruct,
  259.                                             NET_ReloadMethod        inReloadMethod);
  260.                                             
  261.         virtual    void                 GetFormElementInfo(
  262.                                             LO_FormElementStruct*     inElement);
  263.  
  264.         virtual    void                 GetFormElementValue(
  265.                                             LO_FormElementStruct*     inElement,
  266.                                             XP_Bool                 inHide);
  267.  
  268.         virtual    void                 ResetFormElement(
  269.                                             LO_FormElementStruct*     inElement);
  270.  
  271.         virtual    void                 SetFormElementToggle(
  272.                                             LO_FormElementStruct*     inElement,
  273.                                             XP_Bool                 inToggle);
  274.  
  275.         virtual    void                 FreeEmbedElement(
  276.                                             LO_EmbedStruct*            inEmbedStruct);
  277.  
  278.         virtual    void                 CreateEmbedWindow(
  279.                                             NPEmbeddedApp*            inEmbeddedApp);
  280.  
  281.         virtual    void                 SaveEmbedWindow(
  282.                                             NPEmbeddedApp*            inEmbeddedApp);
  283.  
  284.         virtual    void                 RestoreEmbedWindow(
  285.                                             NPEmbeddedApp*            inEmbeddedApp);
  286.  
  287.         virtual    void                 DestroyEmbedWindow(
  288.                                             NPEmbeddedApp*            inEmbeddedApp);
  289.  
  290.         virtual    void                 FreeJavaAppElement(
  291.                                             LJAppletData*            inAppletData);
  292.  
  293.         virtual    void                 HideJavaAppElement(
  294.                                             LJAppletData*                inAppletData);
  295.  
  296.         virtual    void                 FreeEdgeElement(
  297.                                             LO_EdgeStruct*            inEdgeStruct);
  298.  
  299.         virtual    void                 FormTextIsSubmit(
  300.                                             LO_FormElementStruct*     inElement);
  301.  
  302.         virtual    void                 DisplaySubtext(
  303.                                             int                     inLocation,
  304.                                             LO_TextStruct*            inText,
  305.                                             Int32                     inStartPos,
  306.                                             Int32                    inEndPos,
  307.                                             XP_Bool                 inNeedBG);
  308.  
  309.         virtual    void                 DisplayText(
  310.                                             int                     inLocation,
  311.                                             LO_TextStruct*            inText,
  312.                                             XP_Bool                 inNeedBG);
  313.  
  314.         virtual    void                 DisplayEmbed(
  315.                                             int                     inLocation,
  316.                                             LO_EmbedStruct*            inEmbedStruct);
  317.  
  318.         virtual    void                 DisplayJavaApp(
  319.                                             int                     inLocation,
  320.                                             LO_JavaAppStruct*        inJavaAppStruct);
  321.  
  322.         virtual    void                 DisplayEdge (
  323.                                             int                     inLocation,
  324.                                             LO_EdgeStruct*            inEdgeStruct);
  325.  
  326.         virtual    void                 DisplayTable(
  327.                                             int                     inLocation,
  328.                                             LO_TableStruct*            inTableStruct);
  329.  
  330.         virtual    void                 DisplayCell(
  331.                                             int                     inLocation,
  332.                                             LO_CellStruct*            inCellStruct);
  333.  
  334.         virtual    void                 InvalidateEntireTableOrCell(
  335.                                             LO_Element*                inElement);
  336.  
  337.         virtual    void                 DisplayAddRowOrColBorder(
  338.                                             XP_Rect*                inRect,
  339.                                             XP_Bool                    inDoErase);
  340.  
  341.         virtual    void                 DisplaySubDoc(
  342.                                             int                     inLocation,
  343.                                             LO_SubDocStruct*        inSubdocStruct);
  344.  
  345.         virtual    void                 DisplayLineFeed(
  346.                                             int                     inLocation,
  347.                                             LO_LinefeedStruct*        inLinefeedStruct,
  348.                                             XP_Bool                 inNeedBG);
  349.  
  350.         virtual    void                 DisplayHR(
  351.                                             int                     inLocation,
  352.                                             LO_HorizRuleStruct*        inRuleStruct);
  353.  
  354.         virtual    void                 DisplayBullet(
  355.                                             int                     inLocation,
  356.                                             LO_BullettStruct*        inBullettStruct);
  357.  
  358.         virtual    void                 DisplayFormElement(
  359.                                             int                     inLocation,
  360.                                             LO_FormElementStruct*     inFormElement);
  361.  
  362.         virtual    void                 DisplayBorder(
  363.                                             int                     inLocation,
  364.                                             int                        inX,
  365.                                             int                        inY,
  366.                                             int                        inWidth,
  367.                                             int                        inHeight,
  368.                                             int                        inBW,
  369.                                             LO_Color*                 inColor,
  370.                                             LO_LineStyle            inStyle);
  371.  
  372.         virtual void                UpdateEnableStates();
  373.         
  374.         virtual void                DisplayFeedback(
  375.                                             int                     inLocation,
  376.                                             LO_Element_struct        *inElement);
  377.  
  378.         virtual    void                 ClearView(
  379.                                             int                     inWhich);
  380.  
  381.         virtual    void                 SetDocDimension(
  382.                                             int                     inLocation,
  383.                                             Int32                     inWidth,
  384.                                             Int32                     inLength);
  385.  
  386.         virtual    void                 SetDocPosition(
  387.                                             int                     inLocation,
  388.                                             Int32                     inX,
  389.                                             Int32                     inY);
  390.  
  391.         virtual    void                 GetDocPosition(
  392.                                             int                     inLocation,
  393.                                             Int32*                    outX,
  394.                                             Int32*                    outY);
  395.  
  396.         virtual    void                 SetBackgroundColor(
  397.                                             Uint8                     inRed,
  398.                                             Uint8                    inGreen,
  399.                                             Uint8                     inBlue);
  400.  
  401.         virtual    void                 AllConnectionsComplete(void);
  402.  
  403.         virtual    void                 EraseBackground(
  404.                                             int                        inLocation,
  405.                                             Int32                    inX,
  406.                                             Int32                    inY,
  407.                                             Uint32                    inWidth,
  408.                                             Uint32                    inHieght,
  409.                                             LO_Color*                inColor);
  410.  
  411.         virtual    void                 SetDrawable(
  412.                                             CL_Drawable*            inDrawable);
  413.  
  414.         virtual    void                 GetTextFrame(
  415.                                             LO_TextStruct*            inTextStruct,
  416.                                             Int32                    inStartPos,
  417.                                             Int32                    inEndPos,
  418.                                             XP_Rect*                outFrame);
  419.  
  420.         virtual    void                 GetDefaultBackgroundColor(
  421.                                             LO_Color*                outColor) const;
  422.  
  423.         virtual    void                 DrawJavaApp(
  424.                                             int                     inLocation,
  425.                                             LO_JavaAppStruct*        inJavaAppStruct);
  426.                                             
  427.         virtual    void                 HandleClippingView(
  428.                                             struct LJAppletData     *appletD, 
  429.                                             int                     x, 
  430.                                             int                     y, 
  431.                                             int                     width, 
  432.                                             int                     height);
  433.  
  434.         virtual    char*                 Prompt(
  435.                                             const char*             inMessage,
  436.                                             const char*                inDefaultText);
  437.  
  438. #if 0
  439.         Int32            GetTransactionID() { return fProgressID; }
  440.         Int32            GetContextUniqueID() { return fWindowID; }
  441.         // Window ID. Used to identify the context
  442.         static    Int32    sWindowID;        // Unique ID, incremented for each context
  443.         Int32            fWindowID;        // ID of this window
  444.  
  445.  
  446.     private:
  447. #endif
  448.  
  449.         Boolean                    mIsRepaginating;
  450.         Boolean                    mIsRepaginationPending;
  451.  
  452.         Boolean                    mLoadImagesOverride;        
  453.         Boolean                    mDelayImages;
  454.         CSharableCompositor*    mCompositor;
  455.  
  456.         IL_GroupContext*        mImageGroupContext;
  457.         
  458.         Boolean                    mImagesLoading;
  459.         Boolean                    mImagesLooping;
  460.         Boolean                    mImagesDelayed;
  461.         Boolean                    mMochaImagesLoading;
  462.         Boolean                    mMochaImagesLooping;
  463.         Boolean                    mMochaImagesDelayed;
  464.         
  465.         Boolean                    mInNoMoreUsers;
  466.  
  467. }; // class CBrowserContext
  468.  
  469. inline CBrowserContext::operator MWContext*()
  470.     {    return &mContext;        };
  471. inline CBrowserContext::operator MWContext&()
  472.     {    return mContext;        };
  473.     
  474. inline CBrowserContext* ExtractBrowserContext(MWContext* inContext)
  475.     {    return dynamic_cast<CBrowserContext*>(inContext->fe.newContext);        }
  476.  
  477. class CSharableCompositor : public LSharable
  478. {
  479. public:
  480.     CSharableCompositor(CL_Compositor* c = nil) : mCompositor(c) {}
  481.     void SetCompositor(CL_Compositor* c) { mCompositor = c; }
  482.     virtual ~CSharableCompositor();
  483.     operator CL_Compositor*() { return mCompositor; }
  484.     CL_Compositor* mCompositor;
  485. }; // class CSharableCompositor
  486.