mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2025-05-13 21:46:53 +02:00
Improved zoom handling
- Added TChromium.IncZoomPct procedure to increase the zoom percent value - Added TChromium.DecZoomPct procedure to decrease the zoom percent value - Added TChromium.ResetZoomLevel procedure to reset the zoom level value - Added TChromium.ResetZoomPct procedure to reset the zoom percent value - Added TChromium.ReadZoom procedure to trigger the TChromium.OnZoomPctAvailable event with the current zoom percent value. - Added TChromium.OnZoomPctAvailable event. - Added the new TChromium.OnZoomPctAvailable event to the MiniBrowser demo.
This commit is contained in:
parent
52cf914bbb
commit
c99d14c8f0
@ -270,7 +270,7 @@ object MiniBrowserFrm: TMiniBrowserFrm
|
||||
OnNavigationVisitorResultAvailable = Chromium1NavigationVisitorResultAvailable
|
||||
OnDownloadImageFinished = Chromium1DownloadImageFinished
|
||||
OnCookiesFlushed = Chromium1CookiesFlushed
|
||||
OnExecuteTaskOnCefThread = Chromium1ExecuteTaskOnCefThread
|
||||
OnZoomPctAvailable = Chromium1ZoomPctAvailable
|
||||
OnRenderCompMsg = Chromium1RenderCompMsg
|
||||
OnLoadEnd = Chromium1LoadEnd
|
||||
OnLoadError = Chromium1LoadError
|
||||
|
@ -84,7 +84,6 @@ const
|
||||
MINIBROWSER_CONTEXTMENU_GETNAVIGATION = MENU_ID_USER_FIRST + 12;
|
||||
MINIBROWSER_CONTEXTMENU_MUTEAUDIO = MENU_ID_USER_FIRST + 13;
|
||||
MINIBROWSER_CONTEXTMENU_UNMUTEAUDIO = MENU_ID_USER_FIRST + 14;
|
||||
MINIBROWSER_CONTEXTMENU_SHOWZOOMPCT = MENU_ID_USER_FIRST + 15;
|
||||
|
||||
type
|
||||
TMiniBrowserFrm = class(TForm)
|
||||
@ -234,9 +233,9 @@ type
|
||||
pluginUrl: ustring; isMainFrame: Boolean;
|
||||
const topOriginUrl: ustring; const pluginInfo: ICefWebPluginInfo;
|
||||
var pluginPolicy: TCefPluginPolicy; var aResult: Boolean);
|
||||
procedure Chromium1ExecuteTaskOnCefThread(Sender: TObject;
|
||||
aTaskID: Cardinal);
|
||||
procedure Acceptlanguage1Click(Sender: TObject);
|
||||
procedure Chromium1ZoomPctAvailable(Sender: TObject;
|
||||
const aZoomPct: Double);
|
||||
|
||||
protected
|
||||
FResponse : TStringList;
|
||||
@ -389,7 +388,6 @@ begin
|
||||
model.AddItem(MINIBROWSER_CONTEXTMENU_JSWRITEDOC, 'Modify HTML document');
|
||||
model.AddItem(MINIBROWSER_CONTEXTMENU_JSPRINTDOC, 'Print using Javascript');
|
||||
model.AddItem(MINIBROWSER_CONTEXTMENU_SHOWRESPONSE, 'Show server headers');
|
||||
model.AddItem(MINIBROWSER_CONTEXTMENU_SHOWZOOMPCT, 'Show ZoomPct');
|
||||
|
||||
if DevTools.Visible then
|
||||
model.AddItem(MINIBROWSER_CONTEXTMENU_HIDEDEVTOOLS, 'Hide DevTools')
|
||||
@ -569,9 +567,6 @@ begin
|
||||
|
||||
MINIBROWSER_CONTEXTMENU_MUTEAUDIO :
|
||||
Chromium1.AudioMuted := True;
|
||||
|
||||
MINIBROWSER_CONTEXTMENU_SHOWZOOMPCT :
|
||||
Chromium1.ExecuteTaskOnCefThread(TID_UI, 1);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -626,12 +621,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMiniBrowserFrm.Chromium1ExecuteTaskOnCefThread(Sender: TObject;
|
||||
aTaskID: Cardinal);
|
||||
begin
|
||||
ShowStatusText('ZoomPct : ' + floattostr(Chromium1.ZoomPct));
|
||||
end;
|
||||
|
||||
procedure TMiniBrowserFrm.Chromium1FullScreenModeChange(Sender: TObject;
|
||||
const browser: ICefBrowser; fullscreen: Boolean);
|
||||
begin
|
||||
@ -996,6 +985,12 @@ begin
|
||||
caption := 'MiniBrowser';
|
||||
end;
|
||||
|
||||
procedure TMiniBrowserFrm.Chromium1ZoomPctAvailable(Sender: TObject;
|
||||
const aZoomPct: Double);
|
||||
begin
|
||||
ShowStatusText('Zoom : ' + floattostr(aZoomPct) + '%');
|
||||
end;
|
||||
|
||||
procedure TMiniBrowserFrm.Flushcookies1Click(Sender: TObject);
|
||||
begin
|
||||
if not(Chromium1.FlushCookieStore(False)) then
|
||||
|
@ -4,7 +4,7 @@
|
||||
<PathDelim Value="\"/>
|
||||
<Version Value="11"/>
|
||||
<BuildModes Active="Default"/>
|
||||
<Units Count="4">
|
||||
<Units Count="6">
|
||||
<Unit0>
|
||||
<Filename Value="CookieVisitor.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
@ -52,128 +52,135 @@
|
||||
<CursorPos Y="413"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit3>
|
||||
<Unit4>
|
||||
<Filename Value="..\..\..\source\uCEFChromiumCore.pas"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="40"/>
|
||||
<CursorPos X="3" Y="61"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit4>
|
||||
<Unit5>
|
||||
<Filename Value="C:\lazarus\lcl\lcltype.pp"/>
|
||||
<UnitName Value="LCLType"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="54"/>
|
||||
<CursorPos X="3" Y="68"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit5>
|
||||
</Units>
|
||||
<JumpHistory Count="30" HistoryIndex="29">
|
||||
<JumpHistory Count="28" HistoryIndex="27">
|
||||
<Position1>
|
||||
<Filename Value="uCookieVisitor.pas"/>
|
||||
<Caret Line="356" Column="81" TopLine="334"/>
|
||||
<Caret Line="252" Column="3" TopLine="239"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="uCookieVisitor.pas"/>
|
||||
<Caret Line="223" TopLine="206"/>
|
||||
<Caret Line="79" Column="67" TopLine="75"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="uCookieVisitor.pas"/>
|
||||
<Caret Line="251" Column="70" TopLine="234"/>
|
||||
<Caret Line="352" Column="38" TopLine="336"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="uCookieVisitor.pas"/>
|
||||
<Caret Line="252" Column="3" TopLine="239"/>
|
||||
<Caret Line="41" Column="100" TopLine="29"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="uCookieVisitor.pas"/>
|
||||
<Caret Line="79" Column="67" TopLine="75"/>
|
||||
<Caret Line="99" Column="40" TopLine="71"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="uCookieVisitor.pas"/>
|
||||
<Caret Line="352" Column="38" TopLine="336"/>
|
||||
<Caret Line="119" Column="15" TopLine="103"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="uCookieVisitor.pas"/>
|
||||
<Caret Line="41" Column="100" TopLine="29"/>
|
||||
<Caret Line="191" Column="3" TopLine="182"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="uCookieVisitor.pas"/>
|
||||
<Caret Line="99" Column="40" TopLine="71"/>
|
||||
<Caret Line="339" Column="60" TopLine="324"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="uCookieVisitor.pas"/>
|
||||
<Caret Line="119" Column="15" TopLine="103"/>
|
||||
<Caret Line="191" Column="62" TopLine="176"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="uCookieVisitor.pas"/>
|
||||
<Caret Line="191" Column="3" TopLine="182"/>
|
||||
<Caret Line="120" Column="67" TopLine="106"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="uCookieVisitor.pas"/>
|
||||
<Caret Line="339" Column="60" TopLine="324"/>
|
||||
<Caret Line="339" Column="31" TopLine="324"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="uCookieVisitor.pas"/>
|
||||
<Caret Line="191" Column="62" TopLine="176"/>
|
||||
<Caret Line="117" Column="84" TopLine="94"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="uCookieVisitor.pas"/>
|
||||
<Caret Line="120" Column="67" TopLine="106"/>
|
||||
<Caret Line="115" Column="96" TopLine="95"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="uCookieVisitor.pas"/>
|
||||
<Caret Line="339" Column="31" TopLine="324"/>
|
||||
<Caret Line="119" Column="87" TopLine="95"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="uCookieVisitor.pas"/>
|
||||
<Caret Line="117" Column="84" TopLine="94"/>
|
||||
<Caret Line="245" Column="11" TopLine="222"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="uCookieVisitor.pas"/>
|
||||
<Caret Line="115" Column="96" TopLine="95"/>
|
||||
<Caret Line="340" TopLine="325"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
<Filename Value="uCookieVisitor.pas"/>
|
||||
<Caret Line="119" Column="87" TopLine="95"/>
|
||||
<Caret Line="339" Column="74" TopLine="325"/>
|
||||
</Position17>
|
||||
<Position18>
|
||||
<Filename Value="uCookieVisitor.pas"/>
|
||||
<Caret Line="245" Column="11" TopLine="222"/>
|
||||
<Caret Line="216" Column="51" TopLine="202"/>
|
||||
</Position18>
|
||||
<Position19>
|
||||
<Filename Value="uCookieVisitor.pas"/>
|
||||
<Caret Line="340" TopLine="325"/>
|
||||
<Caret Line="340" Column="68" TopLine="326"/>
|
||||
</Position19>
|
||||
<Position20>
|
||||
<Filename Value="uCookieVisitor.pas"/>
|
||||
<Caret Line="339" Column="74" TopLine="325"/>
|
||||
<Caret Line="121" Column="15" TopLine="109"/>
|
||||
</Position20>
|
||||
<Position21>
|
||||
<Filename Value="uCookieVisitor.pas"/>
|
||||
<Caret Line="216" Column="51" TopLine="202"/>
|
||||
<Caret Line="198" Column="5" TopLine="190"/>
|
||||
</Position21>
|
||||
<Position22>
|
||||
<Filename Value="uCookieVisitor.pas"/>
|
||||
<Caret Line="340" Column="68" TopLine="326"/>
|
||||
<Caret Line="221" Column="66" TopLine="208"/>
|
||||
</Position22>
|
||||
<Position23>
|
||||
<Filename Value="uCookieVisitor.pas"/>
|
||||
<Caret Line="121" Column="15" TopLine="109"/>
|
||||
<Caret Line="198" Column="28" TopLine="178"/>
|
||||
</Position23>
|
||||
<Position24>
|
||||
<Filename Value="uCookieVisitor.pas"/>
|
||||
<Caret Line="198" Column="5" TopLine="190"/>
|
||||
<Caret Line="83" Column="72" TopLine="75"/>
|
||||
</Position24>
|
||||
<Position25>
|
||||
<Filename Value="uCookieVisitor.pas"/>
|
||||
<Caret Line="221" Column="66" TopLine="208"/>
|
||||
<Caret Line="236" Column="13" TopLine="232"/>
|
||||
</Position25>
|
||||
<Position26>
|
||||
<Filename Value="uCookieVisitor.pas"/>
|
||||
<Caret Line="198" Column="28" TopLine="178"/>
|
||||
<Caret Line="66" Column="3" TopLine="37"/>
|
||||
</Position26>
|
||||
<Position27>
|
||||
<Filename Value="uCookieVisitor.pas"/>
|
||||
<Caret Line="83" Column="72" TopLine="75"/>
|
||||
<Caret Line="252" Column="9" TopLine="233"/>
|
||||
</Position27>
|
||||
<Position28>
|
||||
<Filename Value="uCookieVisitor.pas"/>
|
||||
<Caret Line="236" Column="13" TopLine="232"/>
|
||||
<Caret Line="250" Column="17" TopLine="229"/>
|
||||
</Position28>
|
||||
<Position29>
|
||||
<Filename Value="uCookieVisitor.pas"/>
|
||||
<Caret Line="66" Column="3" TopLine="37"/>
|
||||
</Position29>
|
||||
<Position30>
|
||||
<Filename Value="uCookieVisitor.pas"/>
|
||||
<Caret Line="252" Column="9" TopLine="233"/>
|
||||
</Position30>
|
||||
</JumpHistory>
|
||||
<RunParams>
|
||||
<FormatVersion Value="2"/>
|
||||
|
@ -22,13 +22,13 @@
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<TopLine Value="369"/>
|
||||
<CursorPos X="98" Y="377"/>
|
||||
<TopLine Value="391"/>
|
||||
<CursorPos X="27" Y="394"/>
|
||||
<UsageCount Value="21"/>
|
||||
<Bookmarks Count="3">
|
||||
<Item0 Y="819" ID="1"/>
|
||||
<Item0 Y="821" ID="1"/>
|
||||
<Item1 X="49" Y="61" ID="2"/>
|
||||
<Item2 X="65" Y="1044" ID="3"/>
|
||||
<Item2 X="65" Y="1046" ID="3"/>
|
||||
</Bookmarks>
|
||||
<Loaded Value="True"/>
|
||||
<LoadedDesigner Value="True"/>
|
||||
@ -98,123 +98,123 @@
|
||||
<JumpHistory Count="30" HistoryIndex="29">
|
||||
<Position1>
|
||||
<Filename Value="uMiniBrowser.pas"/>
|
||||
<Caret Line="388" Column="5" TopLine="364"/>
|
||||
<Caret Line="1228" Column="70" TopLine="1212"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="uMiniBrowser.pas"/>
|
||||
<Caret Line="988" Column="26" TopLine="969"/>
|
||||
<Caret Line="401" TopLine="396"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="uMiniBrowser.pas"/>
|
||||
<Caret Line="258" Column="93" TopLine="245"/>
|
||||
<Caret Line="989" Column="44" TopLine="989"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="uMiniBrowser.pas"/>
|
||||
<Caret Line="288" Column="76" TopLine="276"/>
|
||||
<Caret Line="406" Column="110" TopLine="387"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="uMiniBrowser.pas"/>
|
||||
<Caret Line="1221" Column="70" TopLine="1205"/>
|
||||
<Caret Line="298" Column="62" TopLine="276"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="uMiniBrowser.pas"/>
|
||||
<Caret Line="1228" Column="70" TopLine="1212"/>
|
||||
<Caret Line="794" Column="3" TopLine="780"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="uMiniBrowser.pas"/>
|
||||
<Caret Line="401" TopLine="396"/>
|
||||
<Caret Line="61" Column="49" TopLine="45"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="uMiniBrowser.pas"/>
|
||||
<Caret Line="989" Column="44" TopLine="989"/>
|
||||
<Caret Line="794" Column="3" TopLine="779"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="uMiniBrowser.pas"/>
|
||||
<Caret Line="406" Column="110" TopLine="387"/>
|
||||
<Caret Line="62" Column="46" TopLine="46"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="uMiniBrowser.pas"/>
|
||||
<Caret Line="298" Column="62" TopLine="276"/>
|
||||
<Caret Line="795" Column="3" TopLine="780"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="uMiniBrowser.pas"/>
|
||||
<Caret Line="794" Column="3" TopLine="780"/>
|
||||
<Caret Line="266" Column="20" TopLine="255"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="uMiniBrowser.pas"/>
|
||||
<Caret Line="61" Column="49" TopLine="45"/>
|
||||
<Caret Line="1032" Column="5" TopLine="1018"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="uMiniBrowser.pas"/>
|
||||
<Caret Line="794" Column="3" TopLine="779"/>
|
||||
<Caret Line="798" TopLine="783"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="uMiniBrowser.pas"/>
|
||||
<Caret Line="62" Column="46" TopLine="46"/>
|
||||
<Caret Line="1027" Column="28" TopLine="1012"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="uMiniBrowser.pas"/>
|
||||
<Caret Line="795" Column="3" TopLine="780"/>
|
||||
<Caret Line="806" TopLine="783"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="uMiniBrowser.pas"/>
|
||||
<Caret Line="266" Column="20" TopLine="255"/>
|
||||
<Caret Line="1035" Column="36" TopLine="1015"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
<Filename Value="uMiniBrowser.pas"/>
|
||||
<Caret Line="1032" Column="5" TopLine="1018"/>
|
||||
<Caret Line="62" TopLine="46"/>
|
||||
</Position17>
|
||||
<Position18>
|
||||
<Filename Value="uMiniBrowser.pas"/>
|
||||
<Caret Line="798" TopLine="783"/>
|
||||
<Caret Line="798" Column="52" TopLine="783"/>
|
||||
</Position18>
|
||||
<Position19>
|
||||
<Filename Value="uMiniBrowser.pas"/>
|
||||
<Caret Line="1027" Column="28" TopLine="1012"/>
|
||||
<Caret Line="836" Column="84" TopLine="818"/>
|
||||
</Position19>
|
||||
<Position20>
|
||||
<Filename Value="uMiniBrowser.pas"/>
|
||||
<Caret Line="806" TopLine="783"/>
|
||||
<Caret Line="1079" Column="54" TopLine="1055"/>
|
||||
</Position20>
|
||||
<Position21>
|
||||
<Filename Value="uMiniBrowser.pas"/>
|
||||
<Caret Line="1035" Column="36" TopLine="1015"/>
|
||||
<Caret Line="1157" Column="11" TopLine="1133"/>
|
||||
</Position21>
|
||||
<Position22>
|
||||
<Filename Value="uMiniBrowser.pas"/>
|
||||
<Caret Line="62" TopLine="46"/>
|
||||
<Caret Line="1172" Column="75" TopLine="1153"/>
|
||||
</Position22>
|
||||
<Position23>
|
||||
<Filename Value="uMiniBrowser.pas"/>
|
||||
<Caret Line="798" Column="52" TopLine="783"/>
|
||||
<Caret Line="1077" Column="74" TopLine="1065"/>
|
||||
</Position23>
|
||||
<Position24>
|
||||
<Filename Value="uMiniBrowser.pas"/>
|
||||
<Caret Line="836" Column="84" TopLine="818"/>
|
||||
<Caret Line="749" Column="43" TopLine="735"/>
|
||||
</Position24>
|
||||
<Position25>
|
||||
<Filename Value="uMiniBrowser.pas"/>
|
||||
<Caret Line="1079" Column="54" TopLine="1055"/>
|
||||
<Caret Line="756" Column="43" TopLine="742"/>
|
||||
</Position25>
|
||||
<Position26>
|
||||
<Filename Value="uMiniBrowser.pas"/>
|
||||
<Caret Line="1157" Column="11" TopLine="1133"/>
|
||||
<Caret Line="379" Column="98" TopLine="350"/>
|
||||
</Position26>
|
||||
<Position27>
|
||||
<Filename Value="uMiniBrowser.pas"/>
|
||||
<Caret Line="1172" Column="75" TopLine="1153"/>
|
||||
<Caret Line="1130" Column="58" TopLine="1115"/>
|
||||
</Position27>
|
||||
<Position28>
|
||||
<Filename Value="uMiniBrowser.pas"/>
|
||||
<Caret Line="1077" Column="74" TopLine="1065"/>
|
||||
<Caret Line="818" TopLine="813"/>
|
||||
</Position28>
|
||||
<Position29>
|
||||
<Filename Value="uMiniBrowser.pas"/>
|
||||
<Caret Line="749" Column="43" TopLine="735"/>
|
||||
<Caret Line="395" Column="27" TopLine="393"/>
|
||||
</Position29>
|
||||
<Position30>
|
||||
<Filename Value="uMiniBrowser.pas"/>
|
||||
<Caret Line="756" Column="43" TopLine="742"/>
|
||||
<Caret Line="237" TopLine="223"/>
|
||||
</Position30>
|
||||
</JumpHistory>
|
||||
<RunParams>
|
||||
|
@ -245,6 +245,7 @@ object MiniBrowserFrm: TMiniBrowserFrm
|
||||
OnNavigationVisitorResultAvailable = Chromium1NavigationVisitorResultAvailable
|
||||
OnDownloadImageFinished = Chromium1DownloadImageFinished
|
||||
OnCookiesFlushed = Chromium1CookiesFlushed
|
||||
OnZoomPctAvailable = Chromium1ZoomPctAvailable
|
||||
OnRenderCompMsg = Chromium1RenderCompMsg
|
||||
OnLoadEnd = Chromium1LoadEnd
|
||||
OnLoadError = Chromium1LoadError
|
||||
|
@ -135,6 +135,8 @@ type
|
||||
procedure Chromium1CookiesFlushed(Sender: TObject);
|
||||
procedure Chromium1DownloadImageFinished(Sender: TObject;
|
||||
const imageUrl: ustring; httpStatusCode: Integer; const image: ICefImage);
|
||||
procedure Chromium1ZoomPctAvailable(Sender: TObject; const aZoomPct: double
|
||||
);
|
||||
procedure FormShow(Sender: TObject);
|
||||
procedure BackBtnClick(Sender: TObject);
|
||||
procedure ForwardBtnClick(Sender: TObject);
|
||||
@ -389,7 +391,7 @@ end;
|
||||
|
||||
procedure TMiniBrowserFrm.Resetzoom1Click(Sender: TObject);
|
||||
begin
|
||||
Chromium1.ResetZoomStep;
|
||||
Chromium1.ResetZoomLevel;
|
||||
end;
|
||||
|
||||
procedure TMiniBrowserFrm.Resolvehost1Click(Sender: TObject);
|
||||
@ -1116,6 +1118,12 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMiniBrowserFrm.Chromium1ZoomPctAvailable(Sender: TObject;
|
||||
const aZoomPct: double);
|
||||
begin
|
||||
ShowStatusText('Zoom : ' + floattostr(aZoomPct) + '%');
|
||||
end;
|
||||
|
||||
procedure TMiniBrowserFrm.Timer1Timer(Sender: TObject);
|
||||
begin
|
||||
Timer1.Enabled := False;
|
||||
|
@ -404,7 +404,7 @@ type
|
||||
property SitePerProcess : boolean read FSitePerProcess write FSitePerProcess; // --site-per-process
|
||||
property DisableWebSecurity : boolean read FDisableWebSecurity write FDisableWebSecurity; // --disable-web-security
|
||||
property DisablePDFExtension : boolean read FDisablePDFExtension write FDisablePDFExtension; // --disable-pdf-extension
|
||||
property DisableSiteIsolationTrials : boolean read FDisableSiteIsolationTrials write FDisableSiteIsolationTrials; //--disable-site-isolation-trials
|
||||
property DisableSiteIsolationTrials : boolean read FDisableSiteIsolationTrials write FDisableSiteIsolationTrials; // --disable-site-isolation-trials
|
||||
property DisableExtensions : boolean read FDisableExtensions write FDisableExtensions; // --disable-extensions
|
||||
property AutoplayPolicy : TCefAutoplayPolicy read FAutoplayPolicy write FAutoplayPolicy; // --autoplay-policy
|
||||
property DisableBackgroundNetworking : boolean read FDisableBackgroundNetworking write FDisableBackgroundNetworking; // --disable-background-networking
|
||||
|
@ -50,7 +50,7 @@ interface
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
{$IFDEF MSWINDOWS}WinApi.Windows, WinApi.Messages, WinApi.ActiveX, WinApi.CommCtrl,{$ENDIF} System.Classes,
|
||||
{$IFDEF MSWINDOWS}WinApi.Windows, WinApi.Messages, WinApi.ActiveX, WinApi.CommCtrl,{$ENDIF} System.Classes, System.SyncObjs,
|
||||
{$ELSE}
|
||||
{$IFDEF MSWINDOWS}Windows, ActiveX, CommCtrl,{$ENDIF} Classes,
|
||||
{$IFDEF FPC}
|
||||
@ -58,6 +58,7 @@ uses
|
||||
{$ELSE}
|
||||
Messages,
|
||||
{$ENDIF}
|
||||
SyncObjs,
|
||||
{$ENDIF}
|
||||
uCEFTypes, uCEFInterfaces, uCEFLibFunctions, uCEFMiscFunctions, uCEFClient,
|
||||
uCEFConstants, uCEFTask, uCEFDomVisitor, uCEFChromiumEvents,
|
||||
@ -103,6 +104,7 @@ type
|
||||
FSpellChecking : boolean;
|
||||
FSpellCheckerDicts : ustring;
|
||||
FZoomStep : byte;
|
||||
FZoomStepCS : TCriticalSection;
|
||||
FPrefsFileName : string;
|
||||
FIsOSR : boolean;
|
||||
FInitialized : boolean;
|
||||
@ -262,6 +264,7 @@ type
|
||||
FOnCookiesVisited : TOnCookiesVisited;
|
||||
FOnCookieVisitorDestroyed : TOnCookieVisitorDestroyed;
|
||||
FOnCookieSet : TOnCookieSet;
|
||||
FOnZoomPctAvailable : TOnZoomPctAvailable;
|
||||
{$IFDEF MSWINDOWS}
|
||||
FOnBrowserCompMsg : TOnCompMsgEvent;
|
||||
FOnWidgetCompMsg : TOnCompMsgEvent;
|
||||
@ -280,6 +283,7 @@ type
|
||||
function GetDocumentURL : ustring;
|
||||
function GetZoomLevel : double;
|
||||
function GetZoomPct : double;
|
||||
function GetZoomStep : byte;
|
||||
function GetIsPopUp : boolean;
|
||||
function GetWindowHandle : TCefWindowHandle;
|
||||
function GetWindowlessFrameRate : integer;
|
||||
@ -359,17 +363,24 @@ type
|
||||
procedure HandleList(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string);
|
||||
procedure HandleInvalid(const aValue : ICefValue; var aResultSL : TStringList; const aRoot, aKey : string);
|
||||
|
||||
function ExecuteUpdateZoomStepTask(aInc : boolean) : boolean;
|
||||
function ExecuteUpdateZoomPctTask(aInc : boolean) : boolean;
|
||||
function ExecuteReadZoomTask : boolean;
|
||||
function ExecuteSetZoomPctTask(const aValue : double) : boolean;
|
||||
function ExecuteSetZoomLevelTask(const aValue : double) : boolean;
|
||||
function ExecuteSetZoomStepTask(aValue : byte) : boolean;
|
||||
|
||||
procedure UpdateHostZoomLevel(const aValue : double);
|
||||
procedure UpdateHostZoomPct(const aValue : double);
|
||||
|
||||
procedure DelayedDragging;
|
||||
procedure InitializeWindowInfo(aParentHandle : TCefWindowHandle; aParentRect : TRect; const aWindowName : ustring); virtual;
|
||||
procedure DefaultInitializeDevToolsWindowInfo(aDevToolsWnd: TCefWindowHandle; const aClientRect: TRect; const aWindowName: ustring);
|
||||
|
||||
{$IFDEF MSWINDOWS}
|
||||
procedure PrefsAvailableMsg(var aMessage : TMessage);
|
||||
function SendCompMessage(aMsg : cardinal; wParam : cardinal = 0; lParam : integer = 0) : boolean;
|
||||
procedure ToMouseEvent(grfKeyState : Longint; pt : TPoint; var aMouseEvent : TCefMouseEvent);
|
||||
{$ENDIF}
|
||||
procedure ApplyZoomStep;
|
||||
procedure DelayedDragging;
|
||||
|
||||
procedure InitializeWindowInfo(aParentHandle : TCefWindowHandle; aParentRect : TRect; const aWindowName : ustring); virtual;
|
||||
procedure DefaultInitializeDevToolsWindowInfo(aDevToolsWnd: TCefWindowHandle; const aClientRect: TRect; const aWindowName: ustring);
|
||||
{$IFDEF MSWINDOWS}
|
||||
procedure WndProc(var aMessage: TMessage);
|
||||
procedure CreateStub(const aMethod : TWndMethod; var aStub : Pointer);
|
||||
procedure FreeAndNilStub(var aStub : pointer);
|
||||
@ -516,6 +527,12 @@ type
|
||||
procedure doOnCookiesVisited(const name_, value, domain, path: ustring; secure, httponly, hasExpires: Boolean; const creation, lastAccess, expires: TDateTime; count, total, aID : Integer; var aDeleteCookie, aResult : Boolean); virtual;
|
||||
procedure doOnCookieVisitorDestroyed(aID : integer); virtual;
|
||||
procedure doOnCookieSet(aSuccess : boolean; aID : integer); virtual;
|
||||
procedure doUpdateZoomStep(aInc : boolean); virtual;
|
||||
procedure doUpdateZoomPct(aInc : boolean); virtual;
|
||||
procedure doReadZoom; virtual;
|
||||
procedure doSetZoomLevel(const aValue : double); virtual;
|
||||
procedure doSetZoomPct(const aValue : double); virtual;
|
||||
procedure doSetZoomStep(aValue : byte); virtual;
|
||||
function MustCreateLoadHandler : boolean; virtual;
|
||||
function MustCreateFocusHandler : boolean; virtual;
|
||||
function MustCreateContextMenuHandler : boolean; virtual;
|
||||
@ -616,7 +633,12 @@ type
|
||||
|
||||
procedure IncZoomStep;
|
||||
procedure DecZoomStep;
|
||||
procedure IncZoomPct;
|
||||
procedure DecZoomPct;
|
||||
procedure ResetZoomStep;
|
||||
procedure ResetZoomLevel;
|
||||
procedure ResetZoomPct;
|
||||
procedure ReadZoom;
|
||||
|
||||
procedure WasResized;
|
||||
procedure WasHidden(hidden: Boolean);
|
||||
@ -689,7 +711,7 @@ type
|
||||
property DocumentURL : ustring read GetDocumentURL;
|
||||
property ZoomLevel : double read GetZoomLevel write SetZoomLevel;
|
||||
property ZoomPct : double read GetZoomPct write SetZoomPct;
|
||||
property ZoomStep : byte read FZoomStep write SetZoomStep;
|
||||
property ZoomStep : byte read GetZoomStep write SetZoomStep;
|
||||
property WindowlessFrameRate : integer read GetWindowlessFrameRate write SetWindowlessFrameRate;
|
||||
property CustomHeaderName : ustring read FCustomHeaderName write SetCustomHeaderName;
|
||||
property CustomHeaderValue : ustring read FCustomHeaderValue write SetCustomHeaderValue;
|
||||
@ -740,6 +762,7 @@ type
|
||||
property OnCookiesVisited : TOnCookiesVisited read FOnCookiesVisited write FOnCookiesVisited;
|
||||
property OnCookieVisitorDestroyed : TOnCookieVisitorDestroyed read FOnCookieVisitorDestroyed write FOnCookieVisitorDestroyed;
|
||||
property OnCookieSet : TOnCookieSet read FOnCookieSet write FOnCookieSet;
|
||||
property OnZoomPctAvailable : TOnZoomPctAvailable read FOnZoomPctAvailable write FOnZoomPctAvailable;
|
||||
{$IFDEF MSWINDOWS}
|
||||
property OnBrowserCompMsg : TOnCompMsgEvent read FOnBrowserCompMsg write FOnBrowserCompMsg;
|
||||
property OnWidgetCompMsg : TOnCompMsgEvent read FOnWidgetCompMsg write FOnWidgetCompMsg;
|
||||
@ -930,6 +953,7 @@ begin
|
||||
FSpellChecking := True;
|
||||
FSpellCheckerDicts := '';
|
||||
FZoomStep := ZOOM_STEP_DEF;
|
||||
FZoomStepCS := nil;
|
||||
FSafeSearch := False;
|
||||
FYouTubeRestrict := YOUTUBE_RESTRICT_OFF;
|
||||
FPrintingEnabled := True;
|
||||
@ -998,6 +1022,7 @@ begin
|
||||
if (FFontOptions <> nil) then FreeAndNil(FFontOptions);
|
||||
if (FOptions <> nil) then FreeAndNil(FOptions);
|
||||
if (FPDFPrintOptions <> nil) then FreeAndNil(FPDFPrintOptions);
|
||||
if (FZoomStepCS <> nil) then FreeAndNil(FZoomStepCS);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TChromiumCore.Destroy', e) then raise;
|
||||
@ -1224,6 +1249,7 @@ begin
|
||||
FOptions := TChromiumOptions.Create;
|
||||
FFontOptions := TChromiumFontOptions.Create;
|
||||
FPDFPrintOptions := TPDFPrintOptions.Create;
|
||||
FZoomStepCS := TCriticalSection.Create;
|
||||
end;
|
||||
except
|
||||
on e : exception do
|
||||
@ -1388,6 +1414,7 @@ begin
|
||||
FOnCookiesVisited := nil;
|
||||
FOnCookieVisitorDestroyed := nil;
|
||||
FOnCookieSet := nil;
|
||||
FOnZoomPctAvailable := nil;
|
||||
|
||||
{$IFDEF MSWINDOWS}
|
||||
FOnBrowserCompMsg := nil;
|
||||
@ -2198,75 +2225,213 @@ begin
|
||||
if Initialized then Result := FBrowser.Host.ZoomLevel;
|
||||
end;
|
||||
|
||||
procedure TChromiumCore.SetZoomLevel(const aValue : double);
|
||||
begin
|
||||
if Initialized then FBrowser.Host.ZoomLevel := aValue;
|
||||
end;
|
||||
|
||||
function TChromiumCore.GetZoomPct : double;
|
||||
begin
|
||||
Result := power(1.2, ZoomLevel) * 100;
|
||||
end;
|
||||
|
||||
procedure TChromiumCore.SetZoomPct(const aValue : double);
|
||||
function TChromiumCore.GetZoomStep : byte;
|
||||
begin
|
||||
if Initialized and (aValue > 0) then ZoomLevel := LogN(1.2, aValue / 100);
|
||||
Result := ZOOM_STEP_DEF;
|
||||
|
||||
if (FZoomStepCS <> nil) then
|
||||
try
|
||||
FZoomStepCS.Acquire;
|
||||
Result := FZoomStep;
|
||||
finally
|
||||
FZoomStepCS.Release;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TChromiumCore.ApplyZoomStep;
|
||||
procedure TChromiumCore.SetZoomLevel(const aValue : double);
|
||||
begin
|
||||
case FZoomStep of
|
||||
ZOOM_STEP_25 : ZoomPct := 25;
|
||||
ZOOM_STEP_33 : ZoomPct := 33;
|
||||
ZOOM_STEP_50 : ZoomPct := 50;
|
||||
ZOOM_STEP_67 : ZoomPct := 67;
|
||||
ZOOM_STEP_75 : ZoomPct := 75;
|
||||
ZOOM_STEP_90 : ZoomPct := 90;
|
||||
ZOOM_STEP_100 : ZoomPct := 100;
|
||||
ZOOM_STEP_110 : ZoomPct := 110;
|
||||
ZOOM_STEP_125 : ZoomPct := 125;
|
||||
ZOOM_STEP_150 : ZoomPct := 150;
|
||||
ZOOM_STEP_175 : ZoomPct := 175;
|
||||
ZOOM_STEP_200 : ZoomPct := 200;
|
||||
ZOOM_STEP_250 : ZoomPct := 250;
|
||||
ZOOM_STEP_300 : ZoomPct := 300;
|
||||
ZOOM_STEP_400 : ZoomPct := 400;
|
||||
ZOOM_STEP_500 : ZoomPct := 500;
|
||||
end;
|
||||
if CefCurrentlyOn(TID_UI) then
|
||||
doSetZoomLevel(aValue)
|
||||
else
|
||||
ExecuteSetZoomLevelTask(aValue);
|
||||
end;
|
||||
|
||||
procedure TChromiumCore.SetZoomPct(const aValue : double);
|
||||
begin
|
||||
if CefCurrentlyOn(TID_UI) then
|
||||
doSetZoomPct(aValue)
|
||||
else
|
||||
ExecuteSetZoomPctTask(aValue);
|
||||
end;
|
||||
|
||||
procedure TChromiumCore.SetZoomStep(aValue : byte);
|
||||
begin
|
||||
if Initialized and (aValue in [ZOOM_STEP_MIN..ZOOM_STEP_MAX]) then
|
||||
begin
|
||||
FZoomStep := aValue;
|
||||
ApplyZoomStep;
|
||||
end;
|
||||
if CefCurrentlyOn(TID_UI) then
|
||||
doSetZoomStep(aValue)
|
||||
else
|
||||
ExecuteSetZoomStepTask(aValue);
|
||||
end;
|
||||
|
||||
// Increments the Zoom Step value and triggers the TChromium.OnZoomPctAvailable event with the new value
|
||||
procedure TChromiumCore.IncZoomStep;
|
||||
begin
|
||||
if Initialized and (FZoomStep < ZOOM_STEP_MAX) then
|
||||
begin
|
||||
inc(FZoomStep);
|
||||
ApplyZoomStep;
|
||||
end;
|
||||
if CefCurrentlyOn(TID_UI) then
|
||||
doUpdateZoomStep(True)
|
||||
else
|
||||
ExecuteUpdateZoomStepTask(True);
|
||||
end;
|
||||
|
||||
// Decrements the Zoom Step value and triggers the TChromium.OnZoomPctAvailable event with the new value
|
||||
procedure TChromiumCore.DecZoomStep;
|
||||
begin
|
||||
if Initialized and (FZoomStep > ZOOM_STEP_MIN) then
|
||||
begin
|
||||
dec(FZoomStep);
|
||||
ApplyZoomStep;
|
||||
end;
|
||||
if CefCurrentlyOn(TID_UI) then
|
||||
doUpdateZoomStep(False)
|
||||
else
|
||||
ExecuteUpdateZoomStepTask(False);
|
||||
end;
|
||||
|
||||
// Increments the Zoom Percent value and triggers the TChromium.OnZoomPctAvailable event with the new value
|
||||
procedure TChromiumCore.IncZoomPct;
|
||||
begin
|
||||
if CefCurrentlyOn(TID_UI) then
|
||||
doUpdateZoomPct(True)
|
||||
else
|
||||
ExecuteUpdateZoomPctTask(True);
|
||||
end;
|
||||
|
||||
// Decrements the Zoom Percent value and triggers the TChromium.OnZoomPctAvailable event with the new value
|
||||
procedure TChromiumCore.DecZoomPct;
|
||||
begin
|
||||
if CefCurrentlyOn(TID_UI) then
|
||||
doUpdateZoomPct(False)
|
||||
else
|
||||
ExecuteUpdateZoomPctTask(False);
|
||||
end;
|
||||
|
||||
// Sets the Zoom Step to the default value and triggers the TChromium.OnZoomPctAvailable event
|
||||
procedure TChromiumCore.ResetZoomStep;
|
||||
begin
|
||||
ZoomStep := ZOOM_STEP_DEF;
|
||||
end;
|
||||
|
||||
// Sets the Zoom Level to the default value and triggers the TChromium.OnZoomPctAvailable event
|
||||
procedure TChromiumCore.ResetZoomLevel;
|
||||
begin
|
||||
ZoomLevel := 0;
|
||||
end;
|
||||
|
||||
// Sets the Zoom Percent to the default value and triggers the TChromium.OnZoomPctAvailable event
|
||||
procedure TChromiumCore.ResetZoomPct;
|
||||
begin
|
||||
ZoomPct := ZoomStepValues[ZOOM_STEP_DEF];
|
||||
end;
|
||||
|
||||
// Triggers the TChromium.OnZoomPctAvailable event with the current Zoom Percent value
|
||||
procedure TChromiumCore.ReadZoom;
|
||||
begin
|
||||
if CefCurrentlyOn(TID_UI) then
|
||||
doReadZoom
|
||||
else
|
||||
ExecuteReadZoomTask;
|
||||
end;
|
||||
|
||||
function TChromiumCore.ExecuteUpdateZoomStepTask(aInc : boolean) : boolean;
|
||||
var
|
||||
TempTask : ICefTask;
|
||||
begin
|
||||
Result := False;
|
||||
|
||||
try
|
||||
if Initialized then
|
||||
begin
|
||||
TempTask := TCefUpdateZoomStepTask.Create(self, aInc);
|
||||
Result := CefPostTask(TID_UI, TempTask);
|
||||
end;
|
||||
finally
|
||||
TempTask := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TChromiumCore.ExecuteUpdateZoomPctTask(aInc : boolean) : boolean;
|
||||
var
|
||||
TempTask : ICefTask;
|
||||
begin
|
||||
Result := False;
|
||||
|
||||
try
|
||||
if Initialized then
|
||||
begin
|
||||
TempTask := TCefUpdateZoomPctTask.Create(self, aInc);
|
||||
Result := CefPostTask(TID_UI, TempTask);
|
||||
end;
|
||||
finally
|
||||
TempTask := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TChromiumCore.ExecuteReadZoomTask : boolean;
|
||||
var
|
||||
TempTask : ICefTask;
|
||||
begin
|
||||
Result := False;
|
||||
|
||||
try
|
||||
if Initialized then
|
||||
begin
|
||||
TempTask := TCefReadZoomTask.Create(self);
|
||||
Result := CefPostTask(TID_UI, TempTask);
|
||||
end;
|
||||
finally
|
||||
TempTask := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TChromiumCore.ExecuteSetZoomPctTask(const aValue : double) : boolean;
|
||||
var
|
||||
TempTask : ICefTask;
|
||||
begin
|
||||
Result := False;
|
||||
|
||||
try
|
||||
if Initialized then
|
||||
begin
|
||||
TempTask := TCefSetZoomPctTask.Create(self, aValue);
|
||||
Result := CefPostTask(TID_UI, TempTask);
|
||||
end;
|
||||
finally
|
||||
TempTask := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TChromiumCore.ExecuteSetZoomLevelTask(const aValue : double) : boolean;
|
||||
var
|
||||
TempTask : ICefTask;
|
||||
begin
|
||||
Result := False;
|
||||
|
||||
try
|
||||
if Initialized then
|
||||
begin
|
||||
TempTask := TCefSetZoomLevelTask.Create(self, aValue);
|
||||
Result := CefPostTask(TID_UI, TempTask);
|
||||
end;
|
||||
finally
|
||||
TempTask := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TChromiumCore.ExecuteSetZoomStepTask(aValue : byte) : boolean;
|
||||
var
|
||||
TempTask : ICefTask;
|
||||
begin
|
||||
Result := False;
|
||||
|
||||
try
|
||||
if Initialized then
|
||||
begin
|
||||
TempTask := TCefSetZoomStepTask.Create(self, aValue);
|
||||
Result := CefPostTask(TID_UI, TempTask);
|
||||
end;
|
||||
finally
|
||||
TempTask := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TChromiumCore.SetDoNotTrack(aValue : boolean);
|
||||
begin
|
||||
if (FDoNotTrack <> aValue) then
|
||||
@ -2389,6 +2554,16 @@ begin
|
||||
CreateReqContextHandler;
|
||||
end;
|
||||
|
||||
procedure TChromiumCore.UpdateHostZoomLevel(const aValue : double);
|
||||
begin
|
||||
if Initialized then FBrowser.Host.ZoomLevel := aValue;
|
||||
end;
|
||||
|
||||
procedure TChromiumCore.UpdateHostZoomPct(const aValue : double);
|
||||
begin
|
||||
if (aValue > 0) then UpdateHostZoomLevel(LogN(1.2, aValue / 100));
|
||||
end;
|
||||
|
||||
procedure TChromiumCore.SetWebRTCIPHandlingPolicy(aValue : TCefWebRTCHandlingPolicy);
|
||||
begin
|
||||
if (FWebRTCIPHandlingPolicy <> aValue) then
|
||||
@ -3606,6 +3781,185 @@ begin
|
||||
if assigned(FOnCookieSet) then FOnCookieSet(self, aSuccess, aID);
|
||||
end;
|
||||
|
||||
procedure TChromiumCore.doUpdateZoomStep(aInc : boolean);
|
||||
var
|
||||
TempPct, TempPrev, TempNext : double;
|
||||
i : integer;
|
||||
begin
|
||||
if not(Initialized) or (FZoomStepCS = nil) then exit;
|
||||
|
||||
try
|
||||
FZoomStepCS.Acquire;
|
||||
|
||||
if (FZoomStep in [ZOOM_STEP_MIN..ZOOM_STEP_MAX]) then
|
||||
begin
|
||||
if aInc then
|
||||
begin
|
||||
if (FZoomStep < ZOOM_STEP_MAX) then
|
||||
begin
|
||||
inc(FZoomStep);
|
||||
UpdateHostZoomPct(ZoomStepValues[FZoomStep]);
|
||||
end;
|
||||
end
|
||||
else
|
||||
if (FZoomStep > ZOOM_STEP_MIN) then
|
||||
begin
|
||||
dec(FZoomStep);
|
||||
UpdateHostZoomPct(ZoomStepValues[FZoomStep]);
|
||||
end;
|
||||
end
|
||||
else
|
||||
begin
|
||||
TempPct := ZoomPct;
|
||||
TempPrev := 0;
|
||||
i := ZOOM_STEP_MIN;
|
||||
|
||||
repeat
|
||||
if (i <= ZOOM_STEP_MAX) then
|
||||
TempNext := ZoomStepValues[i]
|
||||
else
|
||||
TempNext := ZoomStepValues[ZOOM_STEP_MAX] * 2;
|
||||
|
||||
if (TempPct > TempPrev) and (TempPct < TempNext) then
|
||||
begin
|
||||
if aInc then
|
||||
begin
|
||||
if (i <= ZOOM_STEP_MAX) then
|
||||
begin
|
||||
FZoomStep := i;
|
||||
UpdateHostZoomPct(ZoomStepValues[FZoomStep]);
|
||||
end;
|
||||
end
|
||||
else
|
||||
if (i > ZOOM_STEP_MIN) then
|
||||
begin
|
||||
FZoomStep := pred(i);
|
||||
UpdateHostZoomPct(ZoomStepValues[FZoomStep]);
|
||||
end;
|
||||
|
||||
i := ZOOM_STEP_MAX + 2;
|
||||
end
|
||||
else
|
||||
begin
|
||||
TempPrev := TempNext;
|
||||
inc(i);
|
||||
end;
|
||||
|
||||
until (i > succ(ZOOM_STEP_MAX));
|
||||
end;
|
||||
finally
|
||||
FZoomStepCS.Release;
|
||||
|
||||
if assigned(FOnZoomPctAvailable) then FOnZoomPctAvailable(self, ZoomPct);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TChromiumCore.doUpdateZoomPct(aInc : boolean);
|
||||
var
|
||||
TempNewZoom : double;
|
||||
i : integer;
|
||||
begin
|
||||
if not(Initialized) or (FZoomStepCS = nil) then exit;
|
||||
|
||||
TempNewZoom := ZoomPct;
|
||||
|
||||
try
|
||||
FZoomStepCS.Acquire;
|
||||
|
||||
if aInc then
|
||||
TempNewZoom := min(TempNewZoom + ZOOM_PCT_DELTA, ZoomStepValues[ZOOM_STEP_MAX])
|
||||
else
|
||||
TempNewZoom := max(TempNewZoom - ZOOM_PCT_DELTA, ZoomStepValues[ZOOM_STEP_MIN]);
|
||||
|
||||
for i := ZOOM_STEP_MIN to ZOOM_STEP_MAX do
|
||||
if (TempNewZoom = ZoomStepValues[i]) then break;
|
||||
|
||||
FZoomStep := i;
|
||||
UpdateHostZoomPct(TempNewZoom);
|
||||
finally
|
||||
FZoomStepCS.Release;
|
||||
|
||||
if assigned(FOnZoomPctAvailable) then FOnZoomPctAvailable(self, TempNewZoom);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TChromiumCore.doReadZoom;
|
||||
begin
|
||||
if Initialized and assigned(FOnZoomPctAvailable) then
|
||||
FOnZoomPctAvailable(self, ZoomPct);
|
||||
end;
|
||||
|
||||
procedure TChromiumCore.doSetZoomLevel(const aValue : double);
|
||||
var
|
||||
TempZoom : double;
|
||||
i : integer;
|
||||
begin
|
||||
if not(Initialized) or (FZoomStepCS = nil) then exit;
|
||||
|
||||
try
|
||||
FZoomStepCS.Acquire;
|
||||
|
||||
UpdateHostZoomLevel(aValue);
|
||||
TempZoom := ZoomPct;
|
||||
|
||||
for i := ZOOM_STEP_MIN to ZOOM_STEP_MAX do
|
||||
if (TempZoom = ZoomStepValues[i]) then break;
|
||||
|
||||
FZoomStep := i;
|
||||
finally
|
||||
FZoomStepCS.Release;
|
||||
|
||||
if assigned(FOnZoomPctAvailable) then FOnZoomPctAvailable(self, ZoomPct);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TChromiumCore.doSetZoomPct(const aValue : double);
|
||||
var
|
||||
TempZoom : double;
|
||||
i : integer;
|
||||
begin
|
||||
if not(Initialized) or (FZoomStepCS = nil) then exit;
|
||||
|
||||
try
|
||||
FZoomStepCS.Acquire;
|
||||
|
||||
if (aValue >= ZoomStepValues[ZOOM_STEP_MIN]) and
|
||||
(aValue <= ZoomStepValues[ZOOM_STEP_MAX]) then
|
||||
begin
|
||||
UpdateHostZoomPct(aValue);
|
||||
TempZoom := ZoomPct;
|
||||
|
||||
for i := ZOOM_STEP_MIN to ZOOM_STEP_MAX do
|
||||
if (TempZoom = ZoomStepValues[i]) then break;
|
||||
|
||||
FZoomStep := i;
|
||||
end;
|
||||
finally
|
||||
FZoomStepCS.Release;
|
||||
|
||||
if assigned(FOnZoomPctAvailable) then FOnZoomPctAvailable(self, ZoomPct);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TChromiumCore.doSetZoomStep(aValue : byte);
|
||||
begin
|
||||
if not(Initialized) or (FZoomStepCS = nil) then exit;
|
||||
|
||||
try
|
||||
FZoomStepCS.Acquire;
|
||||
|
||||
if (aValue in [ZOOM_STEP_MIN..ZOOM_STEP_MAX]) then
|
||||
begin
|
||||
FZoomStep := aValue;
|
||||
UpdateHostZoomPct(ZoomStepValues[aValue]);
|
||||
end;
|
||||
finally
|
||||
FZoomStepCS.Release;
|
||||
|
||||
if assigned(FOnZoomPctAvailable) then FOnZoomPctAvailable(self, ZoomPct);
|
||||
end;
|
||||
end;
|
||||
|
||||
function TChromiumCore.MustCreateLoadHandler : boolean;
|
||||
begin
|
||||
Result := assigned(FOnLoadStart) or
|
||||
|
@ -178,6 +178,7 @@ type
|
||||
TOnCookiesVisited = procedure(Sender: TObject; const name_, value, domain, path: ustring; secure, httponly, hasExpires: Boolean; const creation, lastAccess, expires: TDateTime; count, total, aID : Integer; var aDeleteCookie, aResult : Boolean) of object;
|
||||
TOnCookieVisitorDestroyed = procedure(Sender: TObject; aID : integer) of object;
|
||||
TOnCookieSet = procedure(Sender: TObject; aSuccess : boolean; aID : integer) of object;
|
||||
TOnZoomPctAvailable = procedure(Sender: TObject; const aZoomPct : double) of object;
|
||||
{$IFDEF MSWINDOWS}
|
||||
TOnCompMsgEvent = procedure(var aMessage: TMessage; var aHandled: Boolean) of object;
|
||||
{$ENDIF}
|
||||
|
@ -567,10 +567,15 @@ const
|
||||
ZOOM_STEP_300 = 13;
|
||||
ZOOM_STEP_400 = 14;
|
||||
ZOOM_STEP_500 = 15;
|
||||
ZOOM_STEP_UNK = 16;
|
||||
ZOOM_STEP_MIN = ZOOM_STEP_25;
|
||||
ZOOM_STEP_MAX = ZOOM_STEP_500;
|
||||
ZOOM_STEP_DEF = ZOOM_STEP_100;
|
||||
|
||||
ZOOM_PCT_DELTA = 5;
|
||||
|
||||
ZoomStepValues : array[ZOOM_STEP_MIN..ZOOM_STEP_MAX] of integer = (25, 33, 50, 67, 75, 90, 100, 110, 125, 150, 175, 200, 250, 300, 400, 500);
|
||||
|
||||
{$IFDEF MSWINDOWS}
|
||||
CEF_PREFERENCES_SAVED = WM_APP + $A00;
|
||||
CEF_DOONCLOSE = WM_APP + $A01;
|
||||
|
@ -397,6 +397,12 @@ type
|
||||
procedure doOnCookiesVisited(const name_, value, domain, path: ustring; secure, httponly, hasExpires: Boolean; const creation, lastAccess, expires: TDateTime; count, total, aID : Integer; var aDeleteCookie, aResult : Boolean);
|
||||
procedure doOnCookieVisitorDestroyed(aID : integer);
|
||||
procedure doOnCookieSet(aSuccess : boolean; aID : integer);
|
||||
procedure doUpdateZoomStep(aInc : boolean);
|
||||
procedure doUpdateZoomPct(aInc : boolean);
|
||||
procedure doSetZoomLevel(const aValue : double);
|
||||
procedure doSetZoomPct(const aValue : double);
|
||||
procedure doSetZoomStep(aValue : byte);
|
||||
procedure doReadZoom;
|
||||
function MustCreateLoadHandler : boolean;
|
||||
function MustCreateFocusHandler : boolean;
|
||||
function MustCreateContextMenuHandler : boolean;
|
||||
|
@ -125,6 +125,77 @@ type
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
|
||||
TCefUpdateZoomStepTask = class(TCefTaskOwn)
|
||||
protected
|
||||
FEvents : Pointer;
|
||||
FInc : boolean;
|
||||
|
||||
procedure Execute; override;
|
||||
|
||||
public
|
||||
constructor Create(const aEvents : IChromiumEvents; aInc : boolean); reintroduce;
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
|
||||
TCefUpdateZoomPctTask = class(TCefTaskOwn)
|
||||
protected
|
||||
FEvents : Pointer;
|
||||
FInc : boolean;
|
||||
|
||||
procedure Execute; override;
|
||||
|
||||
public
|
||||
constructor Create(const aEvents : IChromiumEvents; aInc : boolean); reintroduce;
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
|
||||
TCefReadZoomTask = class(TCefTaskOwn)
|
||||
protected
|
||||
FEvents : Pointer;
|
||||
|
||||
procedure Execute; override;
|
||||
|
||||
public
|
||||
constructor Create(const aEvents : IChromiumEvents); reintroduce;
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
|
||||
TCefSetZoomLevelTask = class(TCefTaskOwn)
|
||||
protected
|
||||
FEvents : Pointer;
|
||||
FValue : double;
|
||||
|
||||
procedure Execute; override;
|
||||
|
||||
public
|
||||
constructor Create(const aEvents : IChromiumEvents; const aValue : double); reintroduce;
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
|
||||
TCefSetZoomPctTask = class(TCefTaskOwn)
|
||||
protected
|
||||
FEvents : Pointer;
|
||||
FValue : double;
|
||||
|
||||
procedure Execute; override;
|
||||
|
||||
public
|
||||
constructor Create(const aEvents : IChromiumEvents; const aValue : double); reintroduce;
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
|
||||
TCefSetZoomStepTask = class(TCefTaskOwn)
|
||||
protected
|
||||
FEvents : Pointer;
|
||||
FValue : byte;
|
||||
|
||||
procedure Execute; override;
|
||||
|
||||
public
|
||||
constructor Create(const aEvents : IChromiumEvents; aValue : byte); reintroduce;
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
@ -327,4 +398,201 @@ begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
// TCefUpdateZoomStepTask
|
||||
|
||||
procedure TCefUpdateZoomStepTask.Execute;
|
||||
begin
|
||||
try
|
||||
try
|
||||
if (FEvents <> nil) then IChromiumEvents(FEvents).doUpdateZoomStep(FInc);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCefUpdateZoomStepTask.Execute', e) then raise;
|
||||
end;
|
||||
finally
|
||||
FEvents := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
constructor TCefUpdateZoomStepTask.Create(const aEvents : IChromiumEvents; aInc : boolean);
|
||||
begin
|
||||
inherited Create;
|
||||
|
||||
FEvents := Pointer(aEvents);
|
||||
FInc := aInc;
|
||||
end;
|
||||
|
||||
destructor TCefUpdateZoomStepTask.Destroy;
|
||||
begin
|
||||
FEvents := nil;
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
// TCefUpdateZoomPctTask
|
||||
|
||||
procedure TCefUpdateZoomPctTask.Execute;
|
||||
begin
|
||||
try
|
||||
try
|
||||
if (FEvents <> nil) then IChromiumEvents(FEvents).doUpdateZoomPct(FInc);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCefUpdateZoomPctTask.Execute', e) then raise;
|
||||
end;
|
||||
finally
|
||||
FEvents := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
constructor TCefUpdateZoomPctTask.Create(const aEvents : IChromiumEvents; aInc : boolean);
|
||||
begin
|
||||
inherited Create;
|
||||
|
||||
FEvents := Pointer(aEvents);
|
||||
FInc := aInc;
|
||||
end;
|
||||
|
||||
destructor TCefUpdateZoomPctTask.Destroy;
|
||||
begin
|
||||
FEvents := nil;
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
// TCefReadZoomTask
|
||||
|
||||
procedure TCefReadZoomTask.Execute;
|
||||
begin
|
||||
try
|
||||
try
|
||||
if (FEvents <> nil) then IChromiumEvents(FEvents).doReadZoom;
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCefReadZoomTask.Execute', e) then raise;
|
||||
end;
|
||||
finally
|
||||
FEvents := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
constructor TCefReadZoomTask.Create(const aEvents : IChromiumEvents);
|
||||
begin
|
||||
inherited Create;
|
||||
|
||||
FEvents := Pointer(aEvents);
|
||||
end;
|
||||
|
||||
destructor TCefReadZoomTask.Destroy;
|
||||
begin
|
||||
FEvents := nil;
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
// TCefSetZoomLevelTask
|
||||
|
||||
procedure TCefSetZoomLevelTask.Execute;
|
||||
begin
|
||||
try
|
||||
try
|
||||
if (FEvents <> nil) then IChromiumEvents(FEvents).doSetZoomLevel(FValue);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCefSetZoomLevelTask.Execute', e) then raise;
|
||||
end;
|
||||
finally
|
||||
FEvents := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
constructor TCefSetZoomLevelTask.Create(const aEvents : IChromiumEvents; const aValue : double);
|
||||
begin
|
||||
inherited Create;
|
||||
|
||||
FEvents := Pointer(aEvents);
|
||||
FValue := aValue;
|
||||
end;
|
||||
|
||||
destructor TCefSetZoomLevelTask.Destroy;
|
||||
begin
|
||||
FEvents := nil;
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
// TCefSetZoomPctTask
|
||||
|
||||
procedure TCefSetZoomPctTask.Execute;
|
||||
begin
|
||||
try
|
||||
try
|
||||
if (FEvents <> nil) then IChromiumEvents(FEvents).doSetZoomPct(FValue);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCefSetZoomPctTask.Execute', e) then raise;
|
||||
end;
|
||||
finally
|
||||
FEvents := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
constructor TCefSetZoomPctTask.Create(const aEvents : IChromiumEvents; const aValue : double);
|
||||
begin
|
||||
inherited Create;
|
||||
|
||||
FEvents := Pointer(aEvents);
|
||||
FValue := aValue;
|
||||
end;
|
||||
|
||||
destructor TCefSetZoomPctTask.Destroy;
|
||||
begin
|
||||
FEvents := nil;
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
// TCefSetZoomStepTask
|
||||
|
||||
procedure TCefSetZoomStepTask.Execute;
|
||||
begin
|
||||
try
|
||||
try
|
||||
if (FEvents <> nil) then IChromiumEvents(FEvents).doSetZoomStep(FValue);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCefSetZoomStepTask.Execute', e) then raise;
|
||||
end;
|
||||
finally
|
||||
FEvents := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
constructor TCefSetZoomStepTask.Create(const aEvents : IChromiumEvents; aValue : byte);
|
||||
begin
|
||||
inherited Create;
|
||||
|
||||
FEvents := Pointer(aEvents);
|
||||
FValue := aValue;
|
||||
end;
|
||||
|
||||
destructor TCefSetZoomStepTask.Destroy;
|
||||
begin
|
||||
FEvents := nil;
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -2,7 +2,7 @@
|
||||
"UpdateLazPackages" : [
|
||||
{
|
||||
"ForceNotify" : true,
|
||||
"InternalVersion" : 73,
|
||||
"InternalVersion" : 74,
|
||||
"Name" : "cef4delphi_lazarus.lpk",
|
||||
"Version" : "78.3.9.0"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user