Move common wxWebView code to base class

Removes duplicate code in the various webview backends
This commit is contained in:
Tobias Taschner
2021-02-04 14:49:26 +01:00
parent 0d82348328
commit b351e7762d
10 changed files with 200 additions and 485 deletions

View File

@@ -909,65 +909,11 @@ wxString wxWebViewWebKit::GetPageSource() const
}
wxWebViewZoom wxWebViewWebKit::GetZoom() const
{
float zoom = GetWebkitZoom();
// arbitrary way to map float zoom to our common zoom enum
if (zoom <= 0.65f)
{
return wxWEBVIEW_ZOOM_TINY;
}
if (zoom <= 0.90f)
{
return wxWEBVIEW_ZOOM_SMALL;
}
if (zoom <= 1.15f)
{
return wxWEBVIEW_ZOOM_MEDIUM;
}
if (zoom <= 1.45f)
{
return wxWEBVIEW_ZOOM_LARGE;
}
return wxWEBVIEW_ZOOM_LARGEST;
}
float wxWebViewWebKit::GetZoomFactor() const
{
return GetWebkitZoom();
}
void wxWebViewWebKit::SetZoom(wxWebViewZoom zoom)
{
// arbitrary way to map our common zoom enum to float zoom
switch (zoom)
{
case wxWEBVIEW_ZOOM_TINY:
SetWebkitZoom(0.6f);
break;
case wxWEBVIEW_ZOOM_SMALL:
SetWebkitZoom(0.8f);
break;
case wxWEBVIEW_ZOOM_MEDIUM:
SetWebkitZoom(1.0f);
break;
case wxWEBVIEW_ZOOM_LARGE:
SetWebkitZoom(1.3);
break;
case wxWEBVIEW_ZOOM_LARGEST:
SetWebkitZoom(1.6);
break;
default:
wxFAIL;
}
}
void wxWebViewWebKit::SetZoomFactor(float zoom)
{
SetWebkitZoom(zoom);