diff --git a/components/geckoport/Components/BrowserSupports.pas b/components/geckoport/Components/BrowserSupports.pas index 31667a9f2..f4b39b0dd 100644 --- a/components/geckoport/Components/BrowserSupports.pas +++ b/components/geckoport/Components/BrowserSupports.pas @@ -114,7 +114,14 @@ type *) gfx_format = PRInt32; nscoord = PRInt32; - nativeWindow = THANDLE; + //In all currently supported platforms the native window handle is a pointer + //size handle. In Linux64 THANDLE can not be used because by default it is 32 + //bits due file descriptors which are 32 bits even in 64 bit platform. + //Win32 WindowHandle 32 bits THANDLE 32 bits + //Win64 WindowHandle 64 bits THANDLE 64 bits + //Linux32 WindowHandle 32 bits THANDLE 32 bits + //Linux64 WindowHandle 64 bits THANDLE 32 bits + nativeWindow = PtrUInt; gfxIFormats = interface ['{96d086e6-1dd1-11b2-b6b2-b77b59390247}'] end; diff --git a/components/geckoport/Components/GeckoBrowser.pas b/components/geckoport/Components/GeckoBrowser.pas index 5e7bcb9b3..08dfbfe0b 100755 --- a/components/geckoport/Components/GeckoBrowser.pas +++ b/components/geckoport/Components/GeckoBrowser.pas @@ -55,7 +55,7 @@ interface uses LclIntf, LMessages, LclType, LResources, Graphics, SysUtils, Classes, Controls, nsXPCOM, - nsGeckoStrings, CallbackInterfaces, nsTypes, nsXPCOMGlue, BrowserSupports, + nsGeckoStrings, nsTypes, CallbackInterfaces, nsXPCOMGlue, BrowserSupports, nsXPCOM_std19 {$IFDEF LCLCarbon}, CarbonPrivate {$ENDIF} {$IFDEF LCLCocoa}, CocoaPrivate, CocoaAll, CocoaUtils {$ENDIF} @@ -218,7 +218,7 @@ type function GetWebBrowserFind: nsIWebBrowserFind; function GetWebBrowserPrint: nsIWebBrowserPrint; function GetWebNavigation: nsIWebNavigation; - function GetNativeWindow : THANDLE; + function GetNativeWindow : nativeWindow; //function GetMarkupDocumentViewer: nsIMarkupDocumentViewer; //function GetDocShell: nsIDocShell; //function GetDocumentCharsetInfo: nsIDocumentCharsetInfo; @@ -1989,7 +1989,7 @@ begin Result := FWebBrowser as nsIWebNavigation; end; -function TCustomGeckoBrowser.GetNativeWindow: THANDLE; +function TCustomGeckoBrowser.GetNativeWindow: nativeWindow; {$IFDEF LCLCocoa} var ARect : NSRect; @@ -2000,7 +2000,7 @@ begin Result := Handle; {$ENDIF} {$IFDEF LCLCarbon} - Result := THANDLE(TCarbonWindow(Handle).Window); + Result := nativeWindow(TCarbonWindow(Handle).Window); {$ENDIF} {$IFDEF LCLCocoa} ARect := NSView(TCocoaWindow(Handle).contentView).visibleRect; @@ -2010,13 +2010,14 @@ begin ARect.origin.y := 15; AView := NSView.alloc.initWithFrame(ARect); NSView(TCocoaWindow(Handle).contentView).addSubView(AView); + //Maybe Result := nativeWindow(AView) ? for 64 bits ? Result := THANDLE(AView); {$ENDIF} {$IFDEF LCLGtk} Result := Handle; {$ENDIF} {$IFDEF LCLGtk2} - Result := PtrInt(PGtkWindow(Handle)^.default_widget); + Result := nativeWindow(PGtkWindow(Handle)^.default_widget); {$ENDIF} end; diff --git a/components/geckoport/Components/GeckoChromeWindow.pas b/components/geckoport/Components/GeckoChromeWindow.pas index a65f1b2e6..66ae9fa2c 100755 --- a/components/geckoport/Components/GeckoChromeWindow.pas +++ b/components/geckoport/Components/GeckoChromeWindow.pas @@ -61,6 +61,15 @@ uses {$IFDEF LCLCocoa}, CocoaAll, CocoaUtils, CocoaPrivate {$ENDIF}; type + //In all currently supported platforms the native window handle is a pointer + //size handle. In Linux64 THANDLE can not be used because by default it is 32 + //bits due file descriptors which are 32 bits even in 64 bit platform. + //Win32 WindowHandle 32 bits THANDLE 32 bits + //Win64 WindowHandle 64 bits THANDLE 64 bits + //Linux32 WindowHandle 32 bits THANDLE 32 bits + //Linux64 WindowHandle 64 bits THANDLE 32 bits + nativeWindow = PtrUInt; + TGeckoChromeForm = class(TForm, IGeckoCreateWindowTarget, nsIWebBrowserChrome, @@ -111,7 +120,7 @@ type // for nsISupportsWeakReference function GetWeakReference(): nsIWeakReference; safecall; - function GetNativeWindow : THANDLE; //FPC port: added this. + function GetNativeWindow : nativeWindow; //FPC port: added this. procedure InitWebBrowser; procedure UpdateChrome; procedure ContentFinishedLoading; @@ -159,7 +168,7 @@ begin Action := caFree; end; -function TGeckoChromeForm.GetNativeWindow : THANDLE; +function TGeckoChromeForm.GetNativeWindow : nativeWindow; {$IFDEF LCLCocoa} var ARect : NSRect; @@ -195,7 +204,7 @@ begin {$IFDEF LCLGtk}Result := Handle;{$ENDIF} //Is Handle same as GTK Window? {$IFDEF LCLGtk2} - Result := PtrInt(PGtkWindow(GeckoChromeForm.Handle)^.bin.child); + Result := nativeWindow(PGtkWindow(GeckoChromeForm.Handle)^.bin.child); {$ENDIF} //Is Handle same as GTK Window? end; @@ -388,7 +397,7 @@ end; procedure TGeckoChromeForm.SetVisibility(Value: LongBool); begin UseParameter(Value); - //Visible := Value; + Visible := Value; end; function TGeckoChromeForm.GetTitle: PWideChar; @@ -469,7 +478,12 @@ begin begin // FPC port: Result is PRUInt32, but QueryInterface returns Longint, // so cast to nsresult to prevent range check error. + try Result := nsresult(QueryInterface(uuid, Intf)); + except + Result:=0; + Integer(Intf):=0; + end; end; end; @@ -496,7 +510,6 @@ procedure TGeckoChromeForm.FormResize(Sender: TObject); var baseWin: nsIBaseWindow; begin - // baseWin:=FWebBrowser as nsIBaseWindow; baseWin.SetPositionAndSize(0, 0, ClientWidth, ClientHeight, True); baseWin.SetVisibility(True); @@ -505,13 +518,22 @@ end; procedure TGeckoChromeForm.ContentFinishedLoading; var contentWin: nsIDOMWindow; + baseWin: nsIBaseWindow; begin + contentWin := FWebBrowser.ContentDOMWindow; try - contentWin := FWebBrowser.ContentDOMWindow; + //Will try to resize the form to the size of the HTML page, but if the HTML + //does not have a width specified (UNRESTRICTED) it will raise an exception + //and badly resize the HTML content. contentWin.SizeToContent; - Visible := True; except + //Workaround + baseWin:=FWebBrowser as nsIBaseWindow; + //Forces reflow... + baseWin.SetPositionAndSize(0,0,ClientWidth, ClientHeight+1, false); + baseWin.SetPositionAndSize(0,0,ClientWidth, ClientHeight, true); end; + Visible:=true; end; {$IFDEF LCL}