You've already forked lazarus-ccr
Some fixes about native window handle which does not match THANDLE in all platforms, specially Linux64.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1433 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -114,7 +114,14 @@ type
|
|||||||
*)
|
*)
|
||||||
gfx_format = PRInt32;
|
gfx_format = PRInt32;
|
||||||
nscoord = 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
|
gfxIFormats = interface
|
||||||
['{96d086e6-1dd1-11b2-b6b2-b77b59390247}']
|
['{96d086e6-1dd1-11b2-b6b2-b77b59390247}']
|
||||||
end;
|
end;
|
||||||
|
@ -55,7 +55,7 @@ interface
|
|||||||
uses
|
uses
|
||||||
LclIntf, LMessages, LclType, LResources, Graphics,
|
LclIntf, LMessages, LclType, LResources, Graphics,
|
||||||
SysUtils, Classes, Controls, nsXPCOM,
|
SysUtils, Classes, Controls, nsXPCOM,
|
||||||
nsGeckoStrings, CallbackInterfaces, nsTypes, nsXPCOMGlue, BrowserSupports,
|
nsGeckoStrings, nsTypes, CallbackInterfaces, nsXPCOMGlue, BrowserSupports,
|
||||||
nsXPCOM_std19
|
nsXPCOM_std19
|
||||||
{$IFDEF LCLCarbon}, CarbonPrivate {$ENDIF}
|
{$IFDEF LCLCarbon}, CarbonPrivate {$ENDIF}
|
||||||
{$IFDEF LCLCocoa}, CocoaPrivate, CocoaAll, CocoaUtils {$ENDIF}
|
{$IFDEF LCLCocoa}, CocoaPrivate, CocoaAll, CocoaUtils {$ENDIF}
|
||||||
@ -218,7 +218,7 @@ type
|
|||||||
function GetWebBrowserFind: nsIWebBrowserFind;
|
function GetWebBrowserFind: nsIWebBrowserFind;
|
||||||
function GetWebBrowserPrint: nsIWebBrowserPrint;
|
function GetWebBrowserPrint: nsIWebBrowserPrint;
|
||||||
function GetWebNavigation: nsIWebNavigation;
|
function GetWebNavigation: nsIWebNavigation;
|
||||||
function GetNativeWindow : THANDLE;
|
function GetNativeWindow : nativeWindow;
|
||||||
//function GetMarkupDocumentViewer: nsIMarkupDocumentViewer;
|
//function GetMarkupDocumentViewer: nsIMarkupDocumentViewer;
|
||||||
//function GetDocShell: nsIDocShell;
|
//function GetDocShell: nsIDocShell;
|
||||||
//function GetDocumentCharsetInfo: nsIDocumentCharsetInfo;
|
//function GetDocumentCharsetInfo: nsIDocumentCharsetInfo;
|
||||||
@ -1989,7 +1989,7 @@ begin
|
|||||||
Result := FWebBrowser as nsIWebNavigation;
|
Result := FWebBrowser as nsIWebNavigation;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomGeckoBrowser.GetNativeWindow: THANDLE;
|
function TCustomGeckoBrowser.GetNativeWindow: nativeWindow;
|
||||||
{$IFDEF LCLCocoa}
|
{$IFDEF LCLCocoa}
|
||||||
var
|
var
|
||||||
ARect : NSRect;
|
ARect : NSRect;
|
||||||
@ -2000,7 +2000,7 @@ begin
|
|||||||
Result := Handle;
|
Result := Handle;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$IFDEF LCLCarbon}
|
{$IFDEF LCLCarbon}
|
||||||
Result := THANDLE(TCarbonWindow(Handle).Window);
|
Result := nativeWindow(TCarbonWindow(Handle).Window);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$IFDEF LCLCocoa}
|
{$IFDEF LCLCocoa}
|
||||||
ARect := NSView(TCocoaWindow(Handle).contentView).visibleRect;
|
ARect := NSView(TCocoaWindow(Handle).contentView).visibleRect;
|
||||||
@ -2010,13 +2010,14 @@ begin
|
|||||||
ARect.origin.y := 15;
|
ARect.origin.y := 15;
|
||||||
AView := NSView.alloc.initWithFrame(ARect);
|
AView := NSView.alloc.initWithFrame(ARect);
|
||||||
NSView(TCocoaWindow(Handle).contentView).addSubView(AView);
|
NSView(TCocoaWindow(Handle).contentView).addSubView(AView);
|
||||||
|
//Maybe Result := nativeWindow(AView) ? for 64 bits ?
|
||||||
Result := THANDLE(AView);
|
Result := THANDLE(AView);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$IFDEF LCLGtk}
|
{$IFDEF LCLGtk}
|
||||||
Result := Handle;
|
Result := Handle;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$IFDEF LCLGtk2}
|
{$IFDEF LCLGtk2}
|
||||||
Result := PtrInt(PGtkWindow(Handle)^.default_widget);
|
Result := nativeWindow(PGtkWindow(Handle)^.default_widget);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -61,6 +61,15 @@ uses
|
|||||||
{$IFDEF LCLCocoa}, CocoaAll, CocoaUtils, CocoaPrivate {$ENDIF};
|
{$IFDEF LCLCocoa}, CocoaAll, CocoaUtils, CocoaPrivate {$ENDIF};
|
||||||
|
|
||||||
type
|
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,
|
TGeckoChromeForm = class(TForm,
|
||||||
IGeckoCreateWindowTarget,
|
IGeckoCreateWindowTarget,
|
||||||
nsIWebBrowserChrome,
|
nsIWebBrowserChrome,
|
||||||
@ -111,7 +120,7 @@ type
|
|||||||
// for nsISupportsWeakReference
|
// for nsISupportsWeakReference
|
||||||
function GetWeakReference(): nsIWeakReference; safecall;
|
function GetWeakReference(): nsIWeakReference; safecall;
|
||||||
|
|
||||||
function GetNativeWindow : THANDLE; //FPC port: added this.
|
function GetNativeWindow : nativeWindow; //FPC port: added this.
|
||||||
procedure InitWebBrowser;
|
procedure InitWebBrowser;
|
||||||
procedure UpdateChrome;
|
procedure UpdateChrome;
|
||||||
procedure ContentFinishedLoading;
|
procedure ContentFinishedLoading;
|
||||||
@ -159,7 +168,7 @@ begin
|
|||||||
Action := caFree;
|
Action := caFree;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TGeckoChromeForm.GetNativeWindow : THANDLE;
|
function TGeckoChromeForm.GetNativeWindow : nativeWindow;
|
||||||
{$IFDEF LCLCocoa}
|
{$IFDEF LCLCocoa}
|
||||||
var
|
var
|
||||||
ARect : NSRect;
|
ARect : NSRect;
|
||||||
@ -195,7 +204,7 @@ begin
|
|||||||
{$IFDEF LCLGtk}Result := Handle;{$ENDIF} //Is Handle same as GTK Window?
|
{$IFDEF LCLGtk}Result := Handle;{$ENDIF} //Is Handle same as GTK Window?
|
||||||
|
|
||||||
{$IFDEF LCLGtk2}
|
{$IFDEF LCLGtk2}
|
||||||
Result := PtrInt(PGtkWindow(GeckoChromeForm.Handle)^.bin.child);
|
Result := nativeWindow(PGtkWindow(GeckoChromeForm.Handle)^.bin.child);
|
||||||
{$ENDIF} //Is Handle same as GTK Window?
|
{$ENDIF} //Is Handle same as GTK Window?
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -388,7 +397,7 @@ end;
|
|||||||
procedure TGeckoChromeForm.SetVisibility(Value: LongBool);
|
procedure TGeckoChromeForm.SetVisibility(Value: LongBool);
|
||||||
begin
|
begin
|
||||||
UseParameter(Value);
|
UseParameter(Value);
|
||||||
//Visible := Value;
|
Visible := Value;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TGeckoChromeForm.GetTitle: PWideChar;
|
function TGeckoChromeForm.GetTitle: PWideChar;
|
||||||
@ -469,7 +478,12 @@ begin
|
|||||||
begin
|
begin
|
||||||
// FPC port: Result is PRUInt32, but QueryInterface returns Longint,
|
// FPC port: Result is PRUInt32, but QueryInterface returns Longint,
|
||||||
// so cast to nsresult to prevent range check error.
|
// so cast to nsresult to prevent range check error.
|
||||||
|
try
|
||||||
Result := nsresult(QueryInterface(uuid, Intf));
|
Result := nsresult(QueryInterface(uuid, Intf));
|
||||||
|
except
|
||||||
|
Result:=0;
|
||||||
|
Integer(Intf):=0;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -496,7 +510,6 @@ procedure TGeckoChromeForm.FormResize(Sender: TObject);
|
|||||||
var
|
var
|
||||||
baseWin: nsIBaseWindow;
|
baseWin: nsIBaseWindow;
|
||||||
begin
|
begin
|
||||||
//
|
|
||||||
baseWin:=FWebBrowser as nsIBaseWindow;
|
baseWin:=FWebBrowser as nsIBaseWindow;
|
||||||
baseWin.SetPositionAndSize(0, 0, ClientWidth, ClientHeight, True);
|
baseWin.SetPositionAndSize(0, 0, ClientWidth, ClientHeight, True);
|
||||||
baseWin.SetVisibility(True);
|
baseWin.SetVisibility(True);
|
||||||
@ -505,13 +518,22 @@ end;
|
|||||||
procedure TGeckoChromeForm.ContentFinishedLoading;
|
procedure TGeckoChromeForm.ContentFinishedLoading;
|
||||||
var
|
var
|
||||||
contentWin: nsIDOMWindow;
|
contentWin: nsIDOMWindow;
|
||||||
|
baseWin: nsIBaseWindow;
|
||||||
begin
|
begin
|
||||||
try
|
|
||||||
contentWin := FWebBrowser.ContentDOMWindow;
|
contentWin := FWebBrowser.ContentDOMWindow;
|
||||||
|
try
|
||||||
|
//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;
|
contentWin.SizeToContent;
|
||||||
Visible := True;
|
|
||||||
except
|
except
|
||||||
|
//Workaround
|
||||||
|
baseWin:=FWebBrowser as nsIBaseWindow;
|
||||||
|
//Forces reflow...
|
||||||
|
baseWin.SetPositionAndSize(0,0,ClientWidth, ClientHeight+1, false);
|
||||||
|
baseWin.SetPositionAndSize(0,0,ClientWidth, ClientHeight, true);
|
||||||
end;
|
end;
|
||||||
|
Visible:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$IFDEF LCL}
|
{$IFDEF LCL}
|
||||||
|
Reference in New Issue
Block a user