示例#1
0
        internal HtmlDocument(HtmlShimManager shimManager, UnsafeNativeMethods.IHTMLDocument doc)
        {
            this.htmlDocument2 = (UnsafeNativeMethods.IHTMLDocument2)doc;
            Debug.Assert(this.NativeHtmlDocument2 != null, "The document should implement IHtmlDocument2");

            this.shimManager = shimManager;
        }
 public void NavigateComplete2(object pDisp, ref object url)
 {
     UnsafeNativeMethods.IWebBrowser2 webBrowser = (UnsafeNativeMethods.IWebBrowser2)pDisp;
     if (this._parent.AxIWebBrowser2 == webBrowser)
     {
         if (this._parent.DocumentStream != null)
         {
             Invariant.Assert(this._parent.NavigatingToAboutBlank && string.Compare((string)url, "about:blank", StringComparison.OrdinalIgnoreCase) == 0);
             try
             {
                 UnsafeNativeMethods.IHTMLDocument nativeHTMLDocument = this._parent.NativeHTMLDocument;
                 if (nativeHTMLDocument != null)
                 {
                     UnsafeNativeMethods.IPersistStreamInit          persistStreamInit = nativeHTMLDocument as UnsafeNativeMethods.IPersistStreamInit;
                     System.Runtime.InteropServices.ComTypes.IStream pstm = new ManagedIStream(this._parent.DocumentStream);
                     persistStreamInit.Load(pstm);
                 }
                 return;
             }
             finally
             {
                 this._parent.DocumentStream = null;
             }
         }
         string text = (string)url;
         if (this._parent.NavigatingToAboutBlank)
         {
             Invariant.Assert(string.Compare(text, "about:blank", StringComparison.OrdinalIgnoreCase) == 0);
             text = null;
         }
         Uri uri = string.IsNullOrEmpty(text) ? null : new Uri(text);
         NavigationEventArgs e = new NavigationEventArgs(uri, null, null, null, null, true);
         this._parent.OnNavigated(e);
     }
 }
示例#3
0
        /// <include file='doc\HtmlDocument.uex' path='docs/doc[@for="HtmlDocument.OpenNew"]/*' />
        public HtmlDocument OpenNew(bool replaceInHistory)
        {
            object name          = (object)(replaceInHistory ? "replace" : "");
            object nullObject    = null;
            object ohtmlDocument = this.NativeHtmlDocument2.Open("text/html", name, nullObject, nullObject);

            UnsafeNativeMethods.IHTMLDocument iHTMLDocument = ohtmlDocument as UnsafeNativeMethods.IHTMLDocument;
            return(iHTMLDocument != null ? new HtmlDocument(ShimManager, iHTMLDocument) : null);
        }
示例#4
0
        public void NavigateComplete2(object pDisp, ref object url)
        {
            Debug.Assert(url == null || url is string, "invalid url type");

            // Events only fired for top level navigation.
            UnsafeNativeMethods.IWebBrowser2 axIWebBrowser2 = (UnsafeNativeMethods.IWebBrowser2)pDisp;
            if (_parent.AxIWebBrowser2 == axIWebBrowser2)
            {
                // If we are loading from stream.
                if (_parent.DocumentStream != null)
                {
                    Invariant.Assert(_parent.NavigatingToAboutBlank &&
                                     (String.Compare((string)url, WebBrowser.AboutBlankUriString, StringComparison.OrdinalIgnoreCase) == 0));

                    try
                    {
                        UnsafeNativeMethods.IHTMLDocument nativeHTMLDocument = _parent.NativeHTMLDocument;
                        if (nativeHTMLDocument != null)
                        {
                            UnsafeNativeMethods.IPersistStreamInit psi = nativeHTMLDocument as UnsafeNativeMethods.IPersistStreamInit;
                            Debug.Assert(psi != null, "The Document does not implement IPersistStreamInit");

                            System.Runtime.InteropServices.ComTypes.IStream iStream =
                                new MS.Internal.IO.Packaging.ManagedIStream(_parent.DocumentStream);

                            psi.Load(iStream);
                        }
                    }
                    finally
                    {
                        _parent.DocumentStream = null;
                    }
                }
                else
                {
                    string urlString = (string)url;
                    // When source set to null or navigating to stream/string, we navigate to "about:blank"
                    // internally. Make sure we pass null in the event args.
                    if (_parent.NavigatingToAboutBlank)
                    {
                        Invariant.Assert(String.Compare(urlString, WebBrowser.AboutBlankUriString, StringComparison.OrdinalIgnoreCase) == 0);
                        urlString = null;
                    }
                    Uri source            = (String.IsNullOrEmpty(urlString) ? null : new Uri(urlString));
                    NavigationEventArgs e = new NavigationEventArgs(source, null, null, null, null, true);

                    _parent.OnNavigated(e);
                }
            }
        }