Fixed black screen issue in OSR mode thanks to "Student"

- Fixed issues adding or replacing command line switches with hyphenated and non-hyphenated keys in TCEFApplicationCore.
- Remove the values from the "enable-features" and "enable-blink-features" when that value is in the "disable-features" or "disable-blink-features" in the command line switches.
This commit is contained in:
Salvador Diaz Fau 2021-01-21 19:32:43 +01:00
parent 151b6fe3da
commit 47fb09e887
3 changed files with 121 additions and 19 deletions

View File

@ -343,6 +343,7 @@ type
procedure AddCustomCommandLineSwitches(var aKeys, aValues : TStringList); virtual;
procedure AppendSwitch(var aKeys, aValues : TStringList; const aNewKey : ustring; const aNewValue : ustring = '');
procedure ReplaceSwitch(var aKeys, aValues : TStringList; const aNewKey : ustring; const aNewValue : ustring = '');
procedure CleanupFeatures(var aKeys, aValues : TStringList; const aEnableKey, aDisableKey : string);
public
constructor Create;
@ -1744,22 +1745,34 @@ end;
procedure TCefApplicationCore.AppendSwitch(var aKeys, aValues : TStringList; const aNewKey, aNewValue : ustring);
var
TempKey : ustring;
TempKey, TempHyphenatedKey : ustring;
i : integer;
begin
if (copy(aNewKey, 1, 2) = '--') then
TempKey := copy(aNewKey, 3, length(aNewKey))
begin
TempHyphenatedKey := aNewKey;
TempKey := copy(aNewKey, 3, length(aNewKey));
end
else
begin
TempHyphenatedKey := '--' + aNewKey;
TempKey := aNewKey;
end;
i := aKeys.IndexOf(TempKey);
if (i < 0) then
begin
i := aKeys.IndexOf(TempHyphenatedKey);
if (i < 0) then
begin
aKeys.Add(aNewKey);
aValues.Add(aNewValue);
end
else
exit;
end;
end;
if (length(aNewValue) > 0) then
begin
if (length(aValues[i]) > 0) then
@ -1769,18 +1782,93 @@ begin
end;
end;
procedure TCefApplicationCore.CleanupFeatures(var aKeys, aValues : TStringList; const aEnableKey, aDisableKey : string);
var
i, j, k, n : integer;
TempEnabledValues, TempDisabledValues : TStringList;
TempEnableKey, TempHyphenatedEnableKey, TempDisableKey, TempHyphenatedDisableKey : ustring;
begin
if (copy(aEnableKey, 1, 2) = '--') then
begin
TempHyphenatedEnableKey := aEnableKey;
TempEnableKey := copy(aEnableKey, 3, length(aEnableKey));
end
else
begin
TempHyphenatedEnableKey := '--' + aEnableKey;
TempEnableKey := aEnableKey;
end;
if (copy(aDisableKey, 1, 2) = '--') then
begin
TempHyphenatedDisableKey := aDisableKey;
TempDisableKey := copy(aDisableKey, 3, length(aDisableKey));
end
else
begin
TempHyphenatedDisableKey := '--' + aDisableKey;
TempDisableKey := aDisableKey;
end;
i := aKeys.IndexOf(TempEnableKey);
if (i < 0) then i := aKeys.IndexOf(TempHyphenatedEnableKey);
j := aKeys.IndexOf(TempDisableKey);
if (j < 0) then j := aKeys.IndexOf(TempHyphenatedDisableKey);
if (i < 0) or (j < 0) then exit;
TempEnabledValues := TStringList.Create;
TempDisabledValues := TStringList.Create;
TempEnabledValues.CommaText := aValues[i];
TempDisabledValues.CommaText := aValues[j];
k := 0;
while (k < TempDisabledValues.Count) do
begin
if (length(TempDisabledValues[k]) > 0) then
begin
n := TempEnabledValues.IndexOf(TempDisabledValues[k]);
if (n >= 0) then TempEnabledValues.Delete(n);
end;
inc(k);
end;
if (TempEnabledValues.Count > 0) then
aValues[i] := TempEnabledValues.CommaText
else
begin
aKeys.Delete(i);
aValues.Delete(i);
end;
FreeAndNil(TempEnabledValues);
FreeAndNil(TempDisabledValues);
end;
procedure TCefApplicationCore.ReplaceSwitch(var aKeys, aValues : TStringList; const aNewKey, aNewValue : ustring);
var
TempKey : ustring;
TempKey, TempHyphenatedKey : ustring;
i : integer;
begin
if (copy(aNewKey, 1, 2) = '--') then
TempKey := copy(aNewKey, 3, length(aNewKey))
begin
TempHyphenatedKey := aNewKey;
TempKey := copy(aNewKey, 3, length(aNewKey));
end
else
begin
TempHyphenatedKey := '--' + aNewKey;
TempKey := aNewKey;
end;
i := aKeys.IndexOf(TempKey);
if (i < 0) then
begin
i := aKeys.IndexOf(TempHyphenatedKey);
if (i < 0) then
begin
aKeys.Add(aNewKey);
@ -1788,6 +1876,9 @@ begin
end
else
aValues[i] := aNewValue;
end
else
aValues[i] := aNewValue;
end;
procedure TCefApplicationCore.AddCustomCommandLineSwitches(var aKeys, aValues : TStringList);
@ -1975,6 +2066,8 @@ begin
if (length(FDisableFeatures) > 0) then
AppendSwitch(aKeys, aValues, '--disable-features', FDisableFeatures);
CleanupFeatures(aKeys, aValues, '--enable-features', '--disable-features');
// The list of Blink features you can enable is here :
// https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/runtime_enabled_features.json5
if (length(FEnableBlinkFeatures) > 0) then
@ -1985,6 +2078,8 @@ begin
if (length(FDisableBlinkFeatures) > 0) then
AppendSwitch(aKeys, aValues, '--disable-blink-features', FDisableBlinkFeatures);
CleanupFeatures(aKeys, aValues, '--enable-blink-features', '--disable-blink-features');
// The list of Blink settings you can modify is here :
// https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/core/frame/settings.json5
if (length(FBlinkSettings) > 0) then

View File

@ -996,7 +996,14 @@ end;
procedure TBufferPanel.BufferDraw(const aBitmap : TBitmap; const aSrcRect, aDstRect : TRect);
begin
if (FBuffer <> nil) then FBuffer.Canvas.CopyRect(aDstRect, aBitmap.Canvas, aSrcRect);
if (FBuffer <> nil) and (aBitmap <> nil) then
begin
FBuffer.Canvas.Lock;
aBitmap.Canvas.Lock;
FBuffer.Canvas.CopyRect(aDstRect, aBitmap.Canvas, aSrcRect);
aBitmap.Canvas.UnLock;
FBuffer.Canvas.UnLock;
end;
end;
function TBufferPanel.UpdateBufferDimensions(aWidth, aHeight : integer) : boolean;

View File

@ -2,7 +2,7 @@
"UpdateLazPackages" : [
{
"ForceNotify" : true,
"InternalVersion" : 237,
"InternalVersion" : 238,
"Name" : "cef4delphi_lazarus.lpk",
"Version" : "88.1.4.0"
}