diff options
author | Allan Sandfeld Jensen <allan.jensen@digia.com> | 2013-09-13 12:51:20 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-19 20:50:05 +0200 |
commit | d441d6f39bb846989d95bcf5caf387b42414718d (patch) | |
tree | e367e64a75991c554930278175d403c072de6bb8 /Tools/MiniBrowser | |
parent | 0060b2994c07842f4c59de64b5e3e430525c4b90 (diff) | |
download | qtwebkit-d441d6f39bb846989d95bcf5caf387b42414718d.tar.gz |
Import Qt5x2 branch of QtWebkit for Qt 5.2
Importing a new snapshot of webkit.
Change-Id: I2d01ad12cdc8af8cb015387641120a9d7ea5f10c
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
Diffstat (limited to 'Tools/MiniBrowser')
34 files changed, 1501 insertions, 1991 deletions
diff --git a/Tools/MiniBrowser/MiniBrowser.vcproj b/Tools/MiniBrowser/MiniBrowser.vcproj deleted file mode 100644 index 4981c6c4e..000000000 --- a/Tools/MiniBrowser/MiniBrowser.vcproj +++ /dev/null @@ -1,508 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="8.00"
- Name="MiniBrowser"
- ProjectGUID="{1480CF5F-4160-47B5-A0E6-96AEC8258FB5}"
- RootNamespace="MiniBrowser"
- Keyword="Win32Proj"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- ConfigurationType="2"
- InheritedPropertySheets=".\Configurations\MiniBrowserDebug.vsprops"
- UseOfATL="1"
- CharacterSet="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- ConfigurationType="2"
- InheritedPropertySheets=".\Configurations\MiniBrowserRelease.vsprops"
- UseOfATL="1"
- CharacterSet="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug_All|Win32"
- ConfigurationType="2"
- InheritedPropertySheets=".\Configurations\MiniBrowserDebugAll.vsprops"
- UseOfATL="1"
- CharacterSet="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug_Cairo_CFLite|Win32"
- ConfigurationType="2"
- InheritedPropertySheets=".\Configurations\MiniBrowserDebugCairoCFLite.vsprops"
- UseOfATL="1"
- CharacterSet="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release_Cairo_CFLite|Win32"
- ConfigurationType="2"
- InheritedPropertySheets=".\Configurations\MiniBrowserReleaseCairoCFLite.vsprops"
- UseOfATL="1"
- CharacterSet="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Production|Win32"
- ConfigurationType="2"
- InheritedPropertySheets=".\Configurations\MiniBrowserProduction.vsprops"
- UseOfATL="1"
- CharacterSet="1"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath=".\win\BrowserView.cpp"
- >
- </File>
- <File
- RelativePath=".\win\BrowserWindow.cpp"
- >
- </File>
- <File
- RelativePath=".\win\main.cpp"
- >
- </File>
- <File
- RelativePath=".\win\MiniBrowser.cpp"
- >
- </File>
- <File
- RelativePath=".\win\stdafx.cpp"
- >
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="1"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="1"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug_All|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="1"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug_Cairo_CFLite|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="1"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release_Cairo_CFLite|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="1"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Production|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- UsePrecompiledHeader="1"
- />
- </FileConfiguration>
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl;inc;xsd"
- UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
- >
- <File
- RelativePath=".\win\BrowserView.h"
- >
- </File>
- <File
- RelativePath=".\win\BrowserWindow.h"
- >
- </File>
- <File
- RelativePath=".\win\MiniBrowser.h"
- >
- </File>
- <File
- RelativePath=".\win\Resource.h"
- >
- </File>
- <File
- RelativePath=".\win\stdafx.h"
- >
- </File>
- </Filter>
- <Filter
- Name="Resource Files"
- Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
- UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
- >
- <File
- RelativePath=".\win\MiniBrowser.rc"
- >
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/Tools/MiniBrowser/MiniBrowser.xcodeproj/project.pbxproj b/Tools/MiniBrowser/MiniBrowser.xcodeproj/project.pbxproj index 68dadb51d..225644535 100644 --- a/Tools/MiniBrowser/MiniBrowser.xcodeproj/project.pbxproj +++ b/Tools/MiniBrowser/MiniBrowser.xcodeproj/project.pbxproj @@ -86,8 +86,8 @@ buildActionMask = 2147483647; files = ( 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */, - BC8FB5A8116AA1FE0080D413 /* WebKit2.framework in Frameworks */, 0F7EB6E3134113C300F4D865 /* WebKit.framework in Frameworks */, + BC8FB5A8116AA1FE0080D413 /* WebKit2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -95,8 +95,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 0F7EB879134113F200F4D865 /* WebKit.framework in Frameworks */, BC20545E11C96C92008F3375 /* Cocoa.framework in Frameworks */, + 0F7EB879134113F200F4D865 /* WebKit.framework in Frameworks */, BCBD384411B08AAD00E01E54 /* WebKit2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -107,18 +107,18 @@ 080E96DDFE201D6D7F000001 /* MiniBrowser */ = { isa = PBXGroup; children = ( - BC72B89A11E57E8A001EB4EA /* Info.plist */, - BC329486116A92E2008635D0 /* main.m */, 256AC3D80F4B6AC300CF3369 /* AppDelegate.h */, 256AC3D90F4B6AC300CF3369 /* AppDelegate.m */, 0FE6439F161FA8940059E3FF /* BrowserWindowController.h */, 0FE643A0161FA8940059E3FF /* BrowserWindowController.m */, + BC72B89A11E57E8A001EB4EA /* Info.plist */, + BC329486116A92E2008635D0 /* main.m */, + 51E244F811EFCE07008228D1 /* MBToolbarItem.h */, + 51E244F911EFCE07008228D1 /* MBToolbarItem.m */, 0FE643A2161FAC660059E3FF /* WK1BrowserWindowController.h */, 0FE643A3161FAC660059E3FF /* WK1BrowserWindowController.m */, BC329496116A941B008635D0 /* WK2BrowserWindowController.h */, BC329497116A941B008635D0 /* WK2BrowserWindowController.m */, - 51E244F811EFCE07008228D1 /* MBToolbarItem.h */, - 51E244F911EFCE07008228D1 /* MBToolbarItem.m */, ); name = MiniBrowser; sourceTree = "<group>"; @@ -274,8 +274,8 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - BC72B89511E57E07001EB4EA /* MainMenu.xib in Resources */, BC72B89611E57E0F001EB4EA /* BrowserWindow.xib in Resources */, + BC72B89511E57E07001EB4EA /* MainMenu.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -294,11 +294,11 @@ buildActionMask = 2147483647; files = ( 256AC3DA0F4B6AC300CF3369 /* AppDelegate.m in Sources */, + 0FE643A1161FA8940059E3FF /* BrowserWindowController.m in Sources */, BC329487116A92E2008635D0 /* main.m in Sources */, - BC329498116A941B008635D0 /* WK2BrowserWindowController.m in Sources */, 51E244FA11EFCE07008228D1 /* MBToolbarItem.m in Sources */, - 0FE643A1161FA8940059E3FF /* BrowserWindowController.m in Sources */, 0FE643A4161FAC660059E3FF /* WK1BrowserWindowController.m in Sources */, + BC329498116A941B008635D0 /* WK2BrowserWindowController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Tools/MiniBrowser/MiniBrowserLauncher.vcproj b/Tools/MiniBrowser/MiniBrowserLauncher.vcproj deleted file mode 100644 index 03e3481ec..000000000 --- a/Tools/MiniBrowser/MiniBrowserLauncher.vcproj +++ /dev/null @@ -1,396 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="8.00"
- Name="MiniBrowserLauncher"
- ProjectGUID="{7AF4EBFB-CCBC-448F-A36A-8210E08D6A7D}"
- RootNamespace="MiniBrowserLauncher"
- Keyword="Win32Proj"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- ConfigurationType="1"
- InheritedPropertySheets=".\Configurations\MiniBrowserLauncherDebug.vsprops"
- CharacterSet="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- ConfigurationType="1"
- InheritedPropertySheets=".\Configurations\MiniBrowserLauncherRelease.vsprops"
- CharacterSet="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug_Cairo_CFLite|Win32"
- ConfigurationType="1"
- InheritedPropertySheets=".\Configurations\MiniBrowserLauncherDebugCairoCFLite.vsprops"
- CharacterSet="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug_All|Win32"
- ConfigurationType="1"
- InheritedPropertySheets=".\Configurations\MiniBrowserLauncherDebugAll.vsprops"
- CharacterSet="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Production|Win32"
- ConfigurationType="1"
- InheritedPropertySheets=".\Configurations\MiniBrowserLauncherProduction.vsprops"
- CharacterSet="1"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release_Cairo_CFLite|Win32"
- ConfigurationType="1"
- InheritedPropertySheets=".\Configurations\MiniBrowserLauncherReleaseCairoCFLite.vsprops"
- CharacterSet="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <File
- RelativePath="..\win\DLLLauncher\DLLLauncherMain.cpp"
- >
- </File>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/Tools/MiniBrowser/MiniBrowserPostBuild.cmd b/Tools/MiniBrowser/MiniBrowserPostBuild.cmd deleted file mode 100644 index 9dea026b4..000000000 --- a/Tools/MiniBrowser/MiniBrowserPostBuild.cmd +++ /dev/null @@ -1,29 +0,0 @@ -mkdir 2>NUL "%CONFIGURATIONBUILDDIR%\bin" - -if exist "%WEBKITLIBRARIESDIR%\bin\CoreFoundation%LIBRARYCONFIGSUFFIX%.dll" xcopy /y /d "%WEBKITLIBRARIESDIR%\bin\CoreFoundation%LIBRARYCONFIGSUFFIX%.dll" "%CONFIGURATIONBUILDDIR%\bin" -if exist "%WEBKITLIBRARIESDIR%\bin\CoreFoundation%LIBRARYCONFIGSUFFIX%.pdb" xcopy /y /d "%WEBKITLIBRARIESDIR%\bin\CoreFoundation%LIBRARYCONFIGSUFFIX%.pdb" "%CONFIGURATIONBUILDDIR%\bin" -if exist "%WEBKITLIBRARIESDIR%\bin\CFNetwork%LIBRARYCONFIGSUFFIX%.dll" xcopy /y /d "%WEBKITLIBRARIESDIR%\bin\CFNetwork%LIBRARYCONFIGSUFFIX%.dll" "%CONFIGURATIONBUILDDIR%\bin" -if exist "%WEBKITLIBRARIESDIR%\bin\CFNetwork%LIBRARYCONFIGSUFFIX%.pdb" xcopy /y /d "%WEBKITLIBRARIESDIR%\bin\CFNetwork%LIBRARYCONFIGSUFFIX%.pdb" "%CONFIGURATIONBUILDDIR%\bin" -if exist "%WEBKITLIBRARIESDIR%\bin\CFNetwork.resources" xcopy /y /d /e /i "%WEBKITLIBRARIESDIR%\bin\CFNetwork.resources" "%CONFIGURATIONBUILDDIR%\bin\CFNetwork.resources" -if exist "%WEBKITLIBRARIESDIR%\bin\CoreFoundation.resources" xcopy /y /d /e /i "%WEBKITLIBRARIESDIR%\bin\CoreFoundation.resources" "%CONFIGURATIONBUILDDIR%\bin\CoreFoundation.resources" -if exist "%WEBKITLIBRARIESDIR%\bin\CoreGraphics%LIBRARYCONFIGSUFFIX%.dll" xcopy /y /d "%WEBKITLIBRARIESDIR%\bin\CoreGraphics%LIBRARYCONFIGSUFFIX%.dll" "%CONFIGURATIONBUILDDIR%\bin" -if exist "%WEBKITLIBRARIESDIR%\bin\CoreGraphics%LIBRARYCONFIGSUFFIX%.pdb" xcopy /y /d "%WEBKITLIBRARIESDIR%\bin\CoreGraphics%LIBRARYCONFIGSUFFIX%.pdb" "%CONFIGURATIONBUILDDIR%\bin" -if exist "%WEBKITLIBRARIESDIR%\bin\icuin40%LIBRARYCONFIGSUFFIX%.dll" xcopy /y /d "%WEBKITLIBRARIESDIR%\bin\icuin40%LIBRARYCONFIGSUFFIX%.dll" "%CONFIGURATIONBUILDDIR%\bin" -if exist "%WEBKITLIBRARIESDIR%\bin\icuin40%LIBRARYCONFIGSUFFIX%.pdb" xcopy /y /d "%WEBKITLIBRARIESDIR%\bin\icuin40%LIBRARYCONFIGSUFFIX%.pdb" "%CONFIGURATIONBUILDDIR%\bin" -if exist "%WEBKITLIBRARIESDIR%\bin\icuuc40%LIBRARYCONFIGSUFFIX%.dll" xcopy /y /d "%WEBKITLIBRARIESDIR%\bin\icuuc40%LIBRARYCONFIGSUFFIX%.dll" "%CONFIGURATIONBUILDDIR%\bin" -if exist "%WEBKITLIBRARIESDIR%\bin\icuuc40%LIBRARYCONFIGSUFFIX%.pdb" xcopy /y /d "%WEBKITLIBRARIESDIR%\bin\icuuc40%LIBRARYCONFIGSUFFIX%.pdb" "%CONFIGURATIONBUILDDIR%\bin" -if exist "%WEBKITLIBRARIESDIR%\bin\libxml2%LIBRARYCONFIGSUFFIX%.dll" xcopy /y /d "%WEBKITLIBRARIESDIR%\bin\libxml2%LIBRARYCONFIGSUFFIX%.dll" "%CONFIGURATIONBUILDDIR%\bin" -if exist "%WEBKITLIBRARIESDIR%\bin\libxslt%LIBRARYCONFIGSUFFIX%.dll" xcopy /y /d "%WEBKITLIBRARIESDIR%\bin\libxslt%LIBRARYCONFIGSUFFIX%.dll" "%CONFIGURATIONBUILDDIR%\bin" -if exist "%WEBKITLIBRARIESDIR%\bin\pthreadVC2%LIBRARYCONFIGSUFFIX%.dll" xcopy /y /d "%WEBKITLIBRARIESDIR%\bin\pthreadVC2%LIBRARYCONFIGSUFFIX%.dll" "%CONFIGURATIONBUILDDIR%\bin" -if exist "%WEBKITLIBRARIESDIR%\bin\pthreadVC2%LIBRARYCONFIGSUFFIX%.pdb" xcopy /y /d "%WEBKITLIBRARIESDIR%\bin\pthreadVC2%LIBRARYCONFIGSUFFIX%.pdb" "%CONFIGURATIONBUILDDIR%\bin" -if exist "%WEBKITLIBRARIESDIR%\bin\SQLite3%LIBRARYCONFIGSUFFIX%.dll" xcopy /y /d "%WEBKITLIBRARIESDIR%\bin\SQLite3%LIBRARYCONFIGSUFFIX%.dll" "%CONFIGURATIONBUILDDIR%\bin" -if exist "%WEBKITLIBRARIESDIR%\bin\SQLite3%LIBRARYCONFIGSUFFIX%.pdb" xcopy /y /d "%WEBKITLIBRARIESDIR%\bin\SQLite3%LIBRARYCONFIGSUFFIX%.pdb" "%CONFIGURATIONBUILDDIR%\bin" -if exist "%WEBKITLIBRARIESDIR%\bin\zlib1%LIBRARYCONFIGSUFFIX%.dll" xcopy /y /d "%WEBKITLIBRARIESDIR%\bin\zlib1%LIBRARYCONFIGSUFFIX%.dll" "%CONFIGURATIONBUILDDIR%\bin" -if exist "%WEBKITLIBRARIESDIR%\bin\zlib1%LIBRARYCONFIGSUFFIX%.pdb" xcopy /y /d "%WEBKITLIBRARIESDIR%\bin\zlib1%LIBRARYCONFIGSUFFIX%.pdb" "%CONFIGURATIONBUILDDIR%\bin" -if exist "%WEBKITLIBRARIESDIR%\bin\objc%LIBRARYCONFIGSUFFIX%.dll" xcopy /y /d "%WEBKITLIBRARIESDIR%\bin\objc%LIBRARYCONFIGSUFFIX%.dll" "%CONFIGURATIONBUILDDIR%\bin" -if exist "%WEBKITLIBRARIESDIR%\bin\objc%LIBRARYCONFIGSUFFIX%.pdb" xcopy /y /d "%WEBKITLIBRARIESDIR%\bin\objc%LIBRARYCONFIGSUFFIX%.pdb" "%CONFIGURATIONBUILDDIR%\bin" - -if exist "%WEBKITLIBRARIESDIR%\bin\QuartzCore%LIBRARYCONFIGSUFFIX%.dll" xcopy /y /d "%WEBKITLIBRARIESDIR%\bin\QuartzCore%LIBRARYCONFIGSUFFIX%.dll" "%CONFIGURATIONBUILDDIR%\bin" -if exist "%WEBKITLIBRARIESDIR%\bin\QuartzCore%LIBRARYCONFIGSUFFIX%.pdb" xcopy /y /d "%WEBKITLIBRARIESDIR%\bin\QuartzCore%LIBRARYCONFIGSUFFIX%.pdb" "%CONFIGURATIONBUILDDIR%\bin" - -if exist "%CONFIGURATIONBUILDDIR%\buildfailed" del "%CONFIGURATIONBUILDDIR%\buildfailed" diff --git a/Tools/MiniBrowser/MiniBrowserPreBuild.cmd b/Tools/MiniBrowser/MiniBrowserPreBuild.cmd deleted file mode 100644 index 833ae5bfc..000000000 --- a/Tools/MiniBrowser/MiniBrowserPreBuild.cmd +++ /dev/null @@ -1,5 +0,0 @@ -set PATH=%SystemDrive%\cygwin\bin;%PATH% - -if exist "%CONFIGURATIONBUILDDIR%\buildfailed" grep XX%PROJECTNAME%XX "%CONFIGURATIONBUILDDIR%\buildfailed" -if errorlevel 1 exit 1 -echo XX%PROJECTNAME%XX > "%CONFIGURATIONBUILDDIR%\buildfailed" diff --git a/Tools/MiniBrowser/efl/CMakeLists.txt b/Tools/MiniBrowser/efl/CMakeLists.txt index e39d9115c..13180762a 100644 --- a/Tools/MiniBrowser/efl/CMakeLists.txt +++ b/Tools/MiniBrowser/efl/CMakeLists.txt @@ -1,17 +1,24 @@ -SET(MiniBrowser_DIR "${TOOLS_DIR}/MiniBrowser/efl") +set(MiniBrowser_DIR "${TOOLS_DIR}/MiniBrowser/efl") -SET(MiniBrowser_SOURCES +# Elementary is needed to build MiniBrowser +find_package(Elementary 1.6) + +set(MiniBrowser_SOURCES ${TOOLS_DIR}/EWebLauncher/url_utils.c ${MiniBrowser_DIR}/main.c ) -SET(MiniBrowser_INCLUDE_DIRECTORIES +set(MiniBrowser_INCLUDE_DIRECTORIES ${CAIRO_INCLUDE_DIRS} ${ECORE_INCLUDE_DIRS} ${ECORE_EVAS_INCLUDE_DIRS} + ${ECORE_CON_INCLUDE_DIRS} ${ECORE_FILE_INCLUDE_DIRS} + ${ECORE_IMF_INCLUDE_DIRS} + ${ECORE_INPUT_INCLUDE_DIRS} ${EDJE_INCLUDE_DIRS} ${EET_INCLUDE_DIRS} + ${EO_INCLUDE_DIRS} ${DBUS_INCLUDE_DIRS} ${E_DBUS_INCLUDE_DIRS} ${EFREET_INCLUDE_DIRS} @@ -24,37 +31,33 @@ SET(MiniBrowser_INCLUDE_DIRECTORIES ${CMAKE_SOURCE_DIR}/Source ) -SET(MiniBrowser_LIBRARIES - ${JavaScriptCore_LIBRARY_NAME} - ${WebCore_LIBRARY_NAME} - ${WebKit2_LIBRARY_NAME} +set(MiniBrowser_LIBRARIES + JavaScriptCore + WebCore + WebKit2 ${CAIRO_LIBRARIES} ${ECORE_LIBRARIES} ${ECORE_EVAS_LIBRARIES} ${ECORE_FILE_LIBRARIES} ${EDJE_LIBRARIES} + ${EET_LIBRARIES} ${EINA_LIBRARIES} ${ELEMENTARY_LIBRARIES} + ${EO_LIBRARIES} ${EVAS_LIBRARIES} ${FONTCONFIG_LIBRARIES} + ${GLIB_LIBRARIES} + ${GLIB_GTHREAD_LIBRARIES} ${LIBSOUP_LIBRARIES} ${LIBXML2_LIBRARIES} - ${LIBXSLT_LIBRARIES} + ${LIBXSLT_LIBRARIES} -lm ${OPENGL_LIBRARIES} ${SQLITE_LIBRARIES} ) -IF (ENABLE_GLIB_SUPPORT) - LIST(APPEND MiniBrowser_LIBRARIES - ${GLIB_LIBRARIES} - ${GLIB_GTHREAD_LIBRARIES} - ) -ENDIF () - -ADD_DEFINITIONS(-DTHEME_DIR=\"${THEME_BINARY_DIR}\") - -INCLUDE_DIRECTORIES(${MiniBrowser_INCLUDE_DIRECTORIES}) - -ADD_EXECUTABLE(MiniBrowser ${MiniBrowser_SOURCES}) -TARGET_LINK_LIBRARIES(MiniBrowser ${MiniBrowser_LIBRARIES}) -SET_TARGET_PROPERTIES(MiniBrowser PROPERTIES FOLDER "Tools") +if (ELEMENTARY_FOUND) + include_directories(${MiniBrowser_INCLUDE_DIRECTORIES}) + add_executable(MiniBrowser ${MiniBrowser_SOURCES}) + target_link_libraries(MiniBrowser ${MiniBrowser_LIBRARIES}) + set_target_properties(MiniBrowser PROPERTIES FOLDER "Tools") +endif () diff --git a/Tools/MiniBrowser/efl/main.c b/Tools/MiniBrowser/efl/main.c index ac38b7ec5..03f9cf8d9 100644 --- a/Tools/MiniBrowser/efl/main.c +++ b/Tools/MiniBrowser/efl/main.c @@ -21,6 +21,8 @@ #include "url_utils.h" #include <Ecore.h> #include <Ecore_Evas.h> +#include <Ecore_Getopt.h> +#include <Eet.h> #include <Eina.h> #include <Elementary.h> #include <Evas.h> @@ -29,24 +31,53 @@ static const char DEFAULT_URL[] = "http://www.google.com/"; static const char APP_NAME[] = "EFL MiniBrowser"; static const int TOOL_BAR_ICON_SIZE = 24; static const int TOOL_BAR_BUTTON_SIZE = 32; +static const int SEARCH_FIELD_SIZE = 200; +static const int SEARCH_BUTTON_SIZE = 25; +static const int MAX_SEARCH_COUNT = 100; +static const int DEFAULT_SEARCH_FLAGS = EWK_FIND_OPTIONS_SHOW_HIGHLIGHT | EWK_FIND_OPTIONS_CASE_INSENSITIVE | EWK_FIND_OPTIONS_WRAP_AROUND; +static const double TOOLTIP_DELAY_SECONDS = 1.0; #define info(format, args...) \ do { \ if (verbose) \ - printf(format, ##args); \ + printf(format"\n", ##args); \ } while (0) static int verbose = 1; static Eina_List *windows = NULL; static char *evas_engine_name = NULL; +static char *user_agent_string = NULL; static Eina_Bool encoding_detector_enabled = EINA_FALSE; static Eina_Bool frame_flattening_enabled = EINA_FALSE; static Eina_Bool local_storage_enabled = EINA_TRUE; +static Eina_Bool fullscreen_enabled = EINA_FALSE; +static Eina_Bool spell_checking_enabled = EINA_FALSE; static int window_width = 800; static int window_height = 600; /* Default value of device_pixel_ratio is '0' so that we don't set custom device * scale factor unless it's required by the User. */ static double device_pixel_ratio = 0; +static Eina_Bool legacy_behavior_enabled = EINA_FALSE; + +#define DEFAULT_ZOOM_LEVEL 5 // Set default zoom level to 1.0 (index 5 on zoomLevels). +// The zoom values are chosen to be like in Mozilla Firefox 3. +const static float zoomLevels[] = {0.3, 0.5, 0.67, 0.8, 0.9, 1.0, 1.1, 1.2, 1.33, 1.5, 1.7, 2.0, 2.4, 3.0}; + +static Eina_Bool +zoom_level_set(Evas_Object *webview, int level) +{ + if (level < 0 || level >= sizeof(zoomLevels) / sizeof(float)) + return EINA_FALSE; + + Evas_Coord ox, oy, mx, my, cx, cy; + evas_pointer_canvas_xy_get(evas_object_evas_get(webview), &mx, &my); // Get current mouse position on window. + evas_object_geometry_get(webview, &ox, &oy, NULL, NULL); // Get webview's position on window. + cx = mx - ox; // current x position = mouse x position - webview x position + cy = my - oy; // current y position = mouse y position - webview y position + + Eina_Bool result = ewk_view_scale_set(webview, zoomLevels[level], cx, cy); + return result; +} static Ewk_View_Smart_Class *miniBrowserViewSmartClass() { @@ -54,12 +85,42 @@ static Ewk_View_Smart_Class *miniBrowserViewSmartClass() return &ewkViewClass; } +typedef struct _Tooltip_Information { + Ecore_Timer *show_timer; + Eina_Bool activated; + Eina_Bool text_set; + Eina_Bool shown; +} Tooltip_Information; + +typedef struct _Color_Selector { + Ewk_Color_Picker *ewk_picker; + Evas_Object *elm_selector; + Evas_Object *elm_selector_window; +} Color_Selector; + typedef struct _Browser_Window { Evas_Object *elm_window; Evas_Object *ewk_view; Evas_Object *url_bar; Evas_Object *back_button; Evas_Object *forward_button; + struct { + Evas_Object *elm_menu; + Ewk_Popup_Menu *ewk_menu; + } popup; + struct { + Evas_Object *search_bar; + Evas_Object *search_field; + Evas_Object *backward_button; + Evas_Object *forward_button; + } search; + int current_zoom_level; + Tooltip_Information tooltip; + Color_Selector color_selector; + struct { + Evas_Object *elm_menu; + Ewk_Context_Menu *ewk_menu; + } context_menu; } Browser_Window; typedef struct _File_Selector_Data { @@ -87,6 +148,10 @@ static const Ecore_Getopt options = { ('e', "engine", "ecore-evas engine to use."), ECORE_GETOPT_STORE_STR ('s', "window-size", "window size in following format (width)x(height)."), + ECORE_GETOPT_STORE_STR + ('u', "user-agent", "user agent to set."), + ECORE_GETOPT_STORE_DEF_BOOL + ('b', "legacy", "Legacy mode", EINA_FALSE), ECORE_GETOPT_STORE_DOUBLE ('r', "device-pixel-ratio", "Ratio between the CSS units and device pixels."), ECORE_GETOPT_CALLBACK_NOARGS @@ -98,6 +163,12 @@ static const Ecore_Getopt options = { ('f', "flattening", "frame flattening.", EINA_FALSE), ECORE_GETOPT_STORE_DEF_BOOL ('l', "local-storage", "HTML5 local storage support (enabled by default).", EINA_TRUE), + ECORE_GETOPT_STORE_DEF_BOOL + ('F', "full-screen", "start in full-screen.", EINA_FALSE), + ECORE_GETOPT_STORE_DEF_BOOL + ('t', "text-checking", "text spell checking enabled", EINA_TRUE), + ECORE_GETOPT_STORE_DEF_STR + ('p', "policy-cookies", "Cookies policy:\n always - always accept,\n never - never accept,\n no-third-party - don't accept third-party cookies.", "no-third-party"), ECORE_GETOPT_VERSION ('V', "version"), ECORE_GETOPT_COPYRIGHT @@ -108,7 +179,8 @@ static const Ecore_Getopt options = { } }; -static Browser_Window *window_create(const char *url, int width, int height); +static Eina_Stringshare *show_file_entry_dialog(Browser_Window *window, const char *label_tag, const char *default_text); +static Browser_Window *window_create(Evas_Object* opener, const char *url, int width, int height, Eina_Bool view_mode); static Browser_Window *window_find_with_elm_window(Evas_Object *elm_window) { @@ -142,11 +214,100 @@ static Browser_Window *window_find_with_ewk_view(Evas_Object *ewk_view) return NULL; } +static Eina_Bool +on_tooltip_show(void *user_data) +{ + Browser_Window *window = (Browser_Window *)user_data; + + window->tooltip.show_timer = NULL; + elm_object_tooltip_show(window->elm_window); + window->tooltip.shown = EINA_TRUE; + return ECORE_CALLBACK_CANCEL; +} + +static void +window_tooltip_hide(Browser_Window *window) +{ + if (window->tooltip.show_timer) { + ecore_timer_del(window->tooltip.show_timer); + window->tooltip.show_timer = NULL; + } + + if (window->tooltip.shown) { + elm_object_tooltip_hide(window->elm_window); + window->tooltip.shown = EINA_FALSE; + } +} + +static void +window_tooltip_update(Browser_Window *window) +{ + window_tooltip_hide(window); + + if (window->tooltip.activated && window->tooltip.text_set) + window->tooltip.show_timer = ecore_timer_add(TOOLTIP_DELAY_SECONDS, on_tooltip_show, window); +} + +static void +on_mouse_in(void *user_data, Evas *e, Evas_Object *ewk_view, void *event_info) +{ + Browser_Window *window = (Browser_Window *)user_data; + + window->tooltip.activated = EINA_TRUE; + window_tooltip_update(window); +} + +static void +on_mouse_move(void *user_data, Evas *e, Evas_Object *ewk_view, void *event_info) +{ + window_tooltip_update((Browser_Window *)user_data); +} + +static void +on_mouse_out(void *user_data, Evas *e, Evas_Object *ewk_view, void *event_info) +{ + Browser_Window *window = (Browser_Window *)user_data; + + window->tooltip.activated = EINA_FALSE; + window_tooltip_update(window); +} + +static void +on_window_resize(void *user_data, Evas *e, Evas_Object *elm_window, void *event_info) +{ + Browser_Window *window = (Browser_Window *)user_data; + + if (!window) { + info("ERROR: window is NULL."); + return; + } + + if (window->context_menu.ewk_menu) + ewk_context_menu_hide(window->context_menu.ewk_menu); + if (window->popup.ewk_menu) + ewk_popup_menu_close(window->popup.ewk_menu); + if (window->popup.elm_menu) + elm_menu_close(window->popup.elm_menu); +} + static void window_free(Browser_Window *window) { + evas_object_event_callback_del(window->ewk_view, EVAS_CALLBACK_MOUSE_IN, on_mouse_in); + evas_object_event_callback_del(window->ewk_view, EVAS_CALLBACK_MOUSE_OUT, on_mouse_out); + evas_object_event_callback_del(window->ewk_view, EVAS_CALLBACK_MOUSE_MOVE, on_mouse_move); + + evas_object_event_callback_del(window->elm_window, EVAS_CALLBACK_RESIZE, on_window_resize); + evas_object_del(window->ewk_view); /* The elm_win will take care of freeing its children */ evas_object_del(window->elm_window); + + if (window->tooltip.show_timer) + ecore_timer_del(window->tooltip.show_timer); + + if (window->color_selector.elm_selector_window) + evas_object_del(window->color_selector.elm_selector_window); + free(window); } @@ -160,6 +321,65 @@ static void window_close(Browser_Window *window) } static void +search_box_show(Browser_Window *window) +{ + evas_object_size_hint_min_set(window->search.search_bar, SEARCH_FIELD_SIZE + 2 * SEARCH_BUTTON_SIZE, SEARCH_BUTTON_SIZE); + + evas_object_show(window->search.search_bar); + evas_object_show(window->search.search_field); + evas_object_show(window->search.backward_button); + evas_object_show(window->search.forward_button); + + /* Grab focus from the view */ + evas_object_focus_set(window->ewk_view, EINA_FALSE); + elm_object_focus_set(window->search.search_field, EINA_TRUE); +} + +static void +search_box_hide(Browser_Window *window) +{ + ewk_view_text_find_highlight_clear(window->ewk_view); + + evas_object_size_hint_min_set(window->search.search_bar, SEARCH_FIELD_SIZE + 2 * SEARCH_BUTTON_SIZE, 0); + evas_object_hide(window->search.search_bar); + evas_object_hide(window->search.search_field); + evas_object_hide(window->search.backward_button); + evas_object_hide(window->search.forward_button); + + /* Give focus back to the view */ + elm_object_focus_set(window->search.search_field, EINA_FALSE); + evas_object_focus_set(window->ewk_view, EINA_TRUE); +} + +static void save_page_contents_callback(Ewk_Page_Contents_Type type, const char *data, void *user_data) +{ + Eet_File *ef; + Eina_Stringshare *fileName = (Eina_Stringshare *)user_data; + + if (!eina_str_has_extension(fileName, ".mht")) { + Eina_Strbuf *fileNameWithMht = eina_strbuf_new(); + eina_strbuf_append_printf(fileNameWithMht, "%s.mht", fileName); + ef = eet_open(eina_strbuf_string_get(fileNameWithMht), EET_FILE_MODE_WRITE); + info("Saving file to: %s", eina_strbuf_string_get(fileNameWithMht)); + eina_strbuf_free(fileNameWithMht); + } else { + ef = eet_open(fileName, EET_FILE_MODE_WRITE); + info("Saving file to: %s", fileName); + } + + if (!ef) { + info("ERROR: Could not create File"); + return; + } + + eet_write(ef, "MHTML data", data, strlen(data), 0 /* compress */); + eet_close(ef); + info("SUCCESS: saved."); + + eina_stringshare_del(fileName); +} + +static void on_key_down(void *user_data, Evas *e, Evas_Object *ewk_view, void *event_info) { Browser_Window *window = (Browser_Window *)user_data; @@ -171,44 +391,92 @@ on_key_down(void *user_data, Evas *e, Evas_Object *ewk_view, void *event_info) NULL }; static int currentEncoding = -1; - Eina_Bool ctrlPressed = evas_key_modifier_is_set(evas_key_modifier_get(e), "Control"); + const Evas_Modifier *mod = evas_key_modifier_get(e); + Eina_Bool ctrlPressed = evas_key_modifier_is_set(mod, "Control"); + Eina_Bool altPressed = evas_key_modifier_is_set(mod, "Alt"); - if (!strcmp(ev->key, "F1")) { - info("Back (F1) was pressed\n"); + if (!strcmp(ev->key, "Left") && altPressed) { + info("Back (Alt+Left) was pressed"); if (!ewk_view_back(ewk_view)) - info("Back ignored: No back history\n"); - } else if (!strcmp(ev->key, "F2")) { - info("Forward (F2) was pressed\n"); + info("Back ignored: No back history"); + } else if (!strcmp(ev->key, "Right") && altPressed) { + info("Forward (Alt+Right) was pressed"); if (!ewk_view_forward(ewk_view)) - info("Forward ignored: No forward history\n"); + info("Forward ignored: No forward history"); } else if (!strcmp(ev->key, "F3")) { currentEncoding = (currentEncoding + 1) % (sizeof(encodings) / sizeof(encodings[0])); info("Set encoding (F3) pressed. New encoding to %s", encodings[currentEncoding]); ewk_view_custom_encoding_set(ewk_view, encodings[currentEncoding]); } else if (!strcmp(ev->key, "F5")) { - info("Reload (F5) was pressed, reloading.\n"); + info("Reload (F5) was pressed, reloading."); ewk_view_reload(ewk_view); } else if (!strcmp(ev->key, "F6")) { - info("Stop (F6) was pressed, stop loading.\n"); + info("Stop (F6) was pressed, stop loading."); ewk_view_stop(ewk_view); - } else if (!strcmp(ev->key, "F7")) { + } else if (!strcmp(ev->key, "F7")) { Ewk_Pagination_Mode mode = ewk_view_pagination_mode_get(ewk_view); mode = (++mode) % (EWK_PAGINATION_MODE_BOTTOM_TO_TOP + 1); if (ewk_view_pagination_mode_set(ewk_view, mode)) - info("Change Pagination Mode (F7) was pressed, changed to: %d\n", mode); + info("Change Pagination Mode (F7) was pressed, changed to: %d", mode); else info("Change Pagination Mode (F7) was pressed, but NOT changed!"); + } else if (!strcmp(ev->key, "F8")) { + info("Create souce code window (F8) was pressed."); + Browser_Window *window = window_create(ewk_view, ewk_view_url_get(ewk_view), 0, 0, EINA_TRUE); + windows = eina_list_append(windows, window); + } else if (!strcmp(ev->key, "F11")) { + info("Fullscreen (F11) was pressed, toggling window/fullscreen."); + elm_win_fullscreen_set(window->elm_window, !elm_win_fullscreen_get(window->elm_window)); } else if (!strcmp(ev->key, "n") && ctrlPressed) { - info("Create new window (Ctrl+n) was pressed.\n"); - Browser_Window *window = window_create(DEFAULT_URL, 0, 0); + info("Create new window (Ctrl+n) was pressed."); + Browser_Window *window = window_create(NULL, DEFAULT_URL, 0, 0, EINA_FALSE); // 0 equals default width and height. windows = eina_list_append(windows, window); } else if (!strcmp(ev->key, "i") && ctrlPressed) { - info("Show Inspector (Ctrl+i) was pressed.\n"); + info("Show Inspector (Ctrl+i) was pressed."); ewk_view_inspector_show(ewk_view); + } else if (!strcmp(ev->key, "f") && ctrlPressed) { + info("Show Search Box (Ctrl+f) was pressed."); + search_box_show(window); } else if (!strcmp(ev->key, "Escape")) { - if (elm_win_fullscreen_get(window->elm_window)) + if (evas_object_visible_get(window->search.search_bar)) + search_box_hide(window); + else if (elm_win_fullscreen_get(window->elm_window)) ewk_view_fullscreen_exit(ewk_view); + } else if (ctrlPressed && (!strcmp(ev->key, "minus") || !strcmp(ev->key, "KP_Subtract"))) { + if (zoom_level_set(ewk_view, window->current_zoom_level - 1)) + window->current_zoom_level--; + info("Zoom out (Ctrl + '-') was pressed, zoom level became %.2f", zoomLevels[window->current_zoom_level]); + } else if (ctrlPressed && (!strcmp(ev->key, "equal") || !strcmp(ev->key, "KP_Add"))) { + if (zoom_level_set(ewk_view, window->current_zoom_level + 1)) + window->current_zoom_level++; + info("Zoom in (Ctrl + '+') was pressed, zoom level became %.2f", zoomLevels[window->current_zoom_level]); + } else if (ctrlPressed && !strcmp(ev->key, "0")) { + if (zoom_level_set(ewk_view, DEFAULT_ZOOM_LEVEL)) + window->current_zoom_level = DEFAULT_ZOOM_LEVEL; + info("Zoom to default (Ctrl + '0') was pressed, zoom level became %.2f", zoomLevels[window->current_zoom_level]); + } else if (ctrlPressed && !strcmp(ev->key, "s")) { + Eina_Strbuf *default_file = eina_strbuf_new(); + const char *home_path = getenv("HOME"); + const char *title = ewk_view_title_get(window->ewk_view); + eina_strbuf_append_printf(default_file, "%s/%s.mht", home_path ? home_path : "/home", title ? title : "title"); + info("Pressed (CTRL + S) : Saving Current Page."); + Eina_Stringshare *save_file_name = show_file_entry_dialog(window, "SAVE", eina_strbuf_string_get(default_file)); + if (!save_file_name) + return; + ewk_view_page_contents_get(ewk_view, EWK_PAGE_CONTENTS_TYPE_MHTML, save_page_contents_callback, (void *)save_file_name); + eina_strbuf_free(default_file); + } else if (ctrlPressed && !strcmp(ev->key, "l")) { + const char *home_path = getenv("HOME"); + Eina_Stringshare *open_file_name = show_file_entry_dialog(window, "LOAD", home_path ? home_path : "/home"); + if (!open_file_name) + return; + Eina_Strbuf *uri_path = eina_strbuf_new(); + eina_strbuf_append_printf(uri_path, "file://%s", open_file_name); + info("pressed (CTRL + L) : Loading Page %s", eina_strbuf_string_get(uri_path)); + ewk_view_url_set(ewk_view, eina_strbuf_string_get(uri_path)); + eina_strbuf_free(uri_path); + eina_stringshare_del(open_file_name); } } @@ -275,6 +543,8 @@ on_url_changed(void *user_data, Evas_Object *ewk_view, void *event_info) elm_entry_entry_set(window->url_bar, url); free(url); + + search_box_hide(window); } static void @@ -332,7 +602,7 @@ on_download_request(void *user_data, Evas_Object *ewk_view, void *event_info) } ewk_download_job_destination_set(download, eina_strbuf_string_get(destination_path)); - info("Downloading: %s\n", eina_strbuf_string_get(destination_path)); + info("Downloading: %s", eina_strbuf_string_get(destination_path)); eina_strbuf_free(destination_path); } @@ -373,6 +643,7 @@ on_fileselector_done(void *user_data, Evas_Object *file_selector, void *event_in static void on_file_chooser_request(void *user_data, Evas_Object *ewk_view, void *event_info) { + Evas_Object *bg; Browser_Window *window = (Browser_Window *)user_data; Ewk_File_Chooser_Request *request = (Ewk_File_Chooser_Request *)event_info; @@ -382,6 +653,11 @@ on_file_chooser_request(void *user_data, Evas_Object *ewk_view, void *event_info elm_win_title_set(elm_window, "File picker"); elm_win_modal_set(elm_window, EINA_TRUE); + bg = elm_bg_add(elm_window); + evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(elm_window, bg); + evas_object_show(bg); + File_Selector_Data *fs_data = (File_Selector_Data *)malloc(sizeof(File_Selector_Data)); fs_data->parent = window; fs_data->elm_window = elm_window; @@ -407,22 +683,145 @@ static void on_download_finished(void *user_data, Evas_Object *ewk_view, void *event_info) { Ewk_Download_Job *download = (Ewk_Download_Job *)event_info; - info("Download finished: %s\n", ewk_download_job_destination_get(download)); + info("Download finished: %s", ewk_download_job_destination_get(download)); } static void on_download_failed(void *user_data, Evas_Object *ewk_view, void *event_info) { - info("Download failed!\n"); + info("Download failed!"); } static void -on_favicon_received(const char *page_url, Evas_Object *icon, void *event_info) +on_color_changed(void *data, Evas_Object *obj, void *event_info) { - Browser_Window *window = (Browser_Window *)event_info; - if (strcmp(page_url, ewk_view_url_get(window->ewk_view))) - return; + int r, g, b, a; + + elm_colorselector_color_get(obj, &r, &g, &b, &a); + evas_object_color_set(data, r, g, b, a); +} + +static void +on_color_item_selected(void *data, Evas_Object *obj, void *event_info) +{ + int r, g, b, a; + Elm_Object_Item *color_item = (Elm_Object_Item *)event_info; + + elm_colorselector_palette_item_color_get(color_item, &r, &g, &b, &a); + evas_object_color_set(data, r, g, b, a); +} + +static void +on_color_picker_ok_clicked(void *data, Evas_Object *obj, void *event_info) +{ + int r, g, b, a; + Color_Selector *color_selector = (Color_Selector *)data; + + elm_colorselector_color_get(color_selector->elm_selector, &r, &g, &b, &a); + ewk_color_picker_color_set(color_selector->ewk_picker, r, g, b, a); +} + +static void +on_color_picker_cancel_clicked(void *data, Evas_Object *obj, void *event_info) +{ + int r, g, b, a; + + ewk_color_picker_color_get(data, &r, &g, &b, &a); + ewk_color_picker_color_set(data, r, g, b, a); +} + +static Eina_Bool +on_color_picker_dismiss(Ewk_View_Smart_Data *sd) +{ + Browser_Window *window = window_find_with_ewk_view(sd->self); + + evas_object_del(window->color_selector.elm_selector_window); + window->color_selector.elm_selector_window = NULL; + + return EINA_TRUE; +} + +static Eina_Bool +on_color_picker_request(Ewk_View_Smart_Data *sd, Ewk_Color_Picker *color_picker) +{ + int r, g, b, a; + Evas_Object *background, *rect, *box, *button_box, *rect_frame, *cs_frame, *ok_button, *cancel_button; + + Browser_Window *window = window_find_with_ewk_view(sd->self); + window->color_selector.elm_selector_window = elm_win_add(window->elm_window, "color selector", ELM_WIN_BASIC); + window->color_selector.ewk_picker = color_picker; + + elm_win_title_set(window->color_selector.elm_selector_window, "Color selector"); + + /* Show color view */ + background = elm_bg_add(window->color_selector.elm_selector_window); + evas_object_size_hint_weight_set(background, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(window->color_selector.elm_selector_window, background); + evas_object_show(background); + + box = elm_box_add(window->color_selector.elm_selector_window); + evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(window->color_selector.elm_selector_window, box); + evas_object_show(box); + + rect_frame = elm_frame_add(window->color_selector.elm_selector_window); + evas_object_size_hint_weight_set(rect_frame, EVAS_HINT_EXPAND, 0.3); + evas_object_size_hint_align_set(rect_frame, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_object_text_set(rect_frame, "Color View"); + elm_box_pack_end(box, rect_frame); + evas_object_show(rect_frame); + + rect = evas_object_rectangle_add(evas_object_evas_get(window->color_selector.elm_selector_window)); + elm_object_content_set(rect_frame, rect); + ewk_color_picker_color_get(window->color_selector.ewk_picker, &r, &g, &b, &a); + evas_object_color_set(rect, r, g, b, a); + evas_object_show(rect); + + /* Show color selector */ + cs_frame = elm_frame_add(window->color_selector.elm_selector_window); + evas_object_size_hint_weight_set(cs_frame, EVAS_HINT_EXPAND, 0.7); + evas_object_size_hint_align_set(cs_frame, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_object_text_set(cs_frame, "Color Selector"); + elm_box_pack_end(box, cs_frame); + evas_object_show(cs_frame); + + window->color_selector.elm_selector = elm_colorselector_add(window->color_selector.elm_selector_window); + elm_object_content_set(cs_frame, window->color_selector.elm_selector); + evas_object_show(window->color_selector.elm_selector); + + /* OK, Cancel Buttons */ + button_box = elm_box_add(window->color_selector.elm_selector_window); + elm_box_horizontal_set(button_box, EINA_TRUE); + evas_object_size_hint_min_set(button_box, 200, 50); + elm_box_pack_end(box, button_box); + evas_object_show(button_box); + + ok_button = elm_button_add(window->color_selector.elm_selector_window); + elm_object_text_set(ok_button, "OK"); + elm_box_pack_end(button_box, ok_button); + evas_object_show(ok_button); + + cancel_button = elm_button_add(window->color_selector.elm_selector_window); + elm_object_text_set(cancel_button, "Cancel"); + elm_box_pack_end(button_box, cancel_button); + evas_object_show(cancel_button); + + evas_object_smart_callback_add(ok_button, "clicked", on_color_picker_ok_clicked, &(window->color_selector)); + evas_object_smart_callback_add(cancel_button, "clicked", on_color_picker_cancel_clicked, window->color_selector.ewk_picker); + evas_object_smart_callback_add(window->color_selector.elm_selector_window, "delete,request", on_color_picker_cancel_clicked, window->color_selector.ewk_picker); + evas_object_smart_callback_add(window->color_selector.elm_selector, "changed", on_color_changed, rect); + evas_object_smart_callback_add(window->color_selector.elm_selector, "color,item,selected", on_color_item_selected, rect); + + elm_win_center(window->color_selector.elm_selector_window, EINA_TRUE, EINA_TRUE); + evas_object_resize(window->color_selector.elm_selector_window, 350, 500); + evas_object_show(window->color_selector.elm_selector_window); + + return EINA_TRUE; +} +static void +update_view_favicon(Browser_Window *window, Evas_Object *icon) +{ /* Remove previous icon from URL bar */ Evas_Object *old_icon = elm_object_part_content_unset(window->url_bar, "icon"); if (old_icon) { @@ -443,16 +842,15 @@ on_favicon_received(const char *page_url, Evas_Object *icon, void *event_info) } static void -on_view_icon_changed(void *user_data, Evas_Object *ewk_view, void *event_info) +on_view_favicon_changed(void *user_data, Evas_Object *ewk_view, void *event_info) { Browser_Window *window = (Browser_Window *)user_data; - /* Retrieve the view's favicon */ - Ewk_Context *context = ewk_view_context_get(ewk_view); - Ewk_Favicon_Database *icon_database = ewk_context_favicon_database_get(context); - const char *page_url = ewk_view_url_get(ewk_view); - Evas *evas = evas_object_evas_get(ewk_view); - ewk_favicon_database_async_icon_get(icon_database, page_url, evas, on_favicon_received, window); + Evas_Object* favicon = ewk_view_favicon_get(ewk_view); + update_view_favicon(window, favicon); + + if (favicon) + evas_object_unref(favicon); } static int @@ -498,6 +896,41 @@ on_url_bar_clicked(void *user_data, Evas_Object *url_bar, void *event_info) } static void +on_search_field_aborted(void *user_data, Evas_Object *search_field, void *event_info) +{ + Browser_Window *window = (Browser_Window *)user_data; + search_box_hide(window); + + /* Give focus back to the view */ + view_focus_set(window, EINA_TRUE); +} + +static void +on_search_field_activated(void *user_data, Evas_Object *search_field, void *event_info) +{ + Browser_Window *window = (Browser_Window *)user_data; + + const char *markup_text = elm_entry_entry_get(search_field); + char *text = elm_entry_markup_to_utf8(markup_text); + ewk_view_text_find(window->ewk_view, text, DEFAULT_SEARCH_FLAGS, MAX_SEARCH_COUNT); + free(text); + + /* Grab focus from the view */ + evas_object_focus_set(window->ewk_view, EINA_FALSE); + elm_object_focus_set(search_field, EINA_TRUE); +} + +static void +on_search_field_clicked(void *user_data, Evas_Object *search_field, void *event_info) +{ + Browser_Window *window = (Browser_Window *)user_data; + + /* Grab focus from the view */ + evas_object_focus_set(window->ewk_view, EINA_FALSE); + elm_object_focus_set(search_field, EINA_TRUE); +} + +static void on_back_button_clicked(void *user_data, Evas_Object *back_button, void *event_info) { Browser_Window *window = (Browser_Window *)user_data; @@ -518,6 +951,26 @@ on_forward_button_clicked(void *user_data, Evas_Object *forward_button, void *ev } static void +on_search_backward_button_clicked(void *user_data, Evas_Object *search_backward_button, void *event_info) +{ + Browser_Window *window = (Browser_Window *)user_data; + + char *text = elm_entry_markup_to_utf8(elm_entry_entry_get(window->search.search_field)); + ewk_view_text_find(window->ewk_view, text, DEFAULT_SEARCH_FLAGS | EWK_FIND_OPTIONS_BACKWARDS, MAX_SEARCH_COUNT); + free(text); +} + +static void +on_search_forward_button_clicked(void *user_data, Evas_Object *search_forward_button, void *event_info) +{ + Browser_Window *window = (Browser_Window *)user_data; + + char *text = elm_entry_markup_to_utf8(elm_entry_entry_get(window->search.search_field)); + ewk_view_text_find(window->ewk_view, text, DEFAULT_SEARCH_FLAGS, MAX_SEARCH_COUNT); + free(text); +} + +static void on_refresh_button_clicked(void *user_data, Evas_Object *refresh_button, void *event_info) { Browser_Window *window = (Browser_Window *)user_data; @@ -525,10 +978,10 @@ on_refresh_button_clicked(void *user_data, Evas_Object *refresh_button, void *ev Evas *evas = evas_object_evas_get(refresh_button); Eina_Bool ctrlPressed = evas_key_modifier_is_set(evas_key_modifier_get(evas), "Control"); if (ctrlPressed) { - info("Reloading and bypassing cache...\n"); + info("Reloading and bypassing cache..."); ewk_view_reload_bypass_cache(window->ewk_view); } else { - info("Reloading...\n"); + info("Reloading..."); ewk_view_reload(window->ewk_view); } } @@ -548,6 +1001,62 @@ on_ok_clicked(void *user_data, Evas_Object *obj, void *event_info) ecore_main_loop_quit(); } +static Eina_Stringshare * +show_file_entry_dialog(Browser_Window *window, const char *label_tag, const char *default_text) +{ + Evas_Object *file_popup = elm_popup_add(window->elm_window); + evas_object_size_hint_weight_set(file_popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_show(file_popup); + + Evas_Object *vbox = elm_box_add(file_popup); + evas_object_size_hint_weight_set(vbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(vbox, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_object_content_set(file_popup, vbox); + evas_object_show(vbox); + + Evas_Object *label = elm_label_add(window->elm_window); + elm_object_text_set(label, label_tag); + evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(label, EVAS_HINT_FILL, 0.5); + evas_object_color_set(label, 23, 45, 67, 142); + elm_box_pack_end(vbox, label); + evas_object_show(label); + + Evas_Object *fs_entry = elm_fileselector_entry_add(file_popup); + elm_fileselector_entry_is_save_set(fs_entry, EINA_TRUE); + evas_object_size_hint_align_set(fs_entry, EVAS_HINT_FILL, 0); + elm_fileselector_entry_path_set(fs_entry, default_text); + elm_object_text_set(fs_entry, "FileChooser"); + elm_box_pack_end(vbox, fs_entry); + evas_object_show(fs_entry); + + Evas_Object *hbox = elm_box_add(file_popup); + evas_object_size_hint_weight_set(hbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_box_horizontal_set(hbox, EINA_TRUE); + evas_object_size_hint_align_set(hbox, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_box_pack_end(vbox, hbox); + evas_object_show(hbox); + + Eina_Bool ok = EINA_FALSE; + Evas_Object *ok_button = elm_button_add(file_popup); + elm_object_text_set(ok_button, "OK"); + evas_object_smart_callback_add(ok_button, "clicked", on_ok_clicked, &ok); + elm_box_pack_end(hbox, ok_button); + evas_object_show(ok_button); + + Evas_Object *cancel_button = elm_button_add(file_popup); + elm_object_text_set(cancel_button, "Cancel"); + evas_object_smart_callback_add(cancel_button, "clicked", quit_event_loop, NULL); + elm_box_pack_end(hbox, cancel_button); + evas_object_show(cancel_button); + + ecore_main_loop_begin(); + + Eina_Stringshare *file_path = ok ? eina_stringshare_add(elm_fileselector_entry_path_get(fs_entry)) : NULL; + evas_object_del(file_popup); + return file_path; +} + static void on_javascript_alert(Ewk_View_Smart_Data *smartData, const char *message) { @@ -664,6 +1173,95 @@ on_javascript_prompt(Ewk_View_Smart_Data *smartData, const char *message, const return prompt_text; } +static void +on_popup_menu_discarded(void *user_data, Evas_Object *obj, void *event_info) +{ + // The user clicked outside the menu to discard it. + info("Popup menu was discarded."); + Browser_Window *window = (Browser_Window *)user_data; + ewk_popup_menu_close(window->popup.ewk_menu); +} + +static void +on_popup_menu_item_clicked(void *user_data, Evas_Object *obj, void *event_info) +{ + Browser_Window *window = (Browser_Window *)user_data; + Elm_Object_Item *item = (Elm_Object_Item *)event_info; + + info("Selected popup menu index: %u", elm_menu_item_index_get(item)); + ewk_popup_menu_selected_index_set(window->popup.ewk_menu, elm_menu_item_index_get(item)); + + // Close popup menu. + ewk_popup_menu_close(window->popup.ewk_menu); +} + +static void +popup_menu_populate(Evas_Object *elm_menu, Ewk_Popup_Menu *ewk_menu, void *user_data) +{ + const Eina_List* ewk_items = ewk_popup_menu_items_get(ewk_menu); + + void *data; + const Eina_List *l; + EINA_LIST_FOREACH(ewk_items, l, data) { + Ewk_Popup_Menu_Item *ewk_item = (Ewk_Popup_Menu_Item *)data; + switch (ewk_popup_menu_item_type_get(ewk_item)) { + case EWK_POPUP_MENU_SEPARATOR: + elm_menu_item_separator_add(elm_menu, NULL); + break; + case EWK_POPUP_MENU_ITEM: + if (ewk_popup_menu_item_is_label_get(ewk_item)) { + Elm_Object_Item *item = elm_menu_item_add(elm_menu, NULL, NULL, ewk_popup_menu_item_text_get(ewk_item), NULL, NULL); + elm_object_item_disabled_set(item, EINA_TRUE); + } else { + Elm_Object_Item *item = elm_menu_item_add(elm_menu, NULL, NULL, ewk_popup_menu_item_text_get(ewk_item), on_popup_menu_item_clicked, user_data); + const char *tooltip_text = ewk_popup_menu_item_tooltip_get(ewk_item); + if (tooltip_text && tooltip_text[0] != '\0') + elm_object_item_tooltip_text_set(item, tooltip_text); + elm_object_item_disabled_set(item, !ewk_popup_menu_item_enabled_get(ewk_item)); + elm_menu_item_selected_set(item, ewk_popup_menu_item_selected_get(ewk_item)); + } + break; + default: + info("Unrecognized popup menu item type!"); + break; + } + } +} + +static Eina_Bool +on_popup_menu_show(Ewk_View_Smart_Data *smartData, Eina_Rectangle rect, Ewk_Text_Direction text_direction, double page_scale_factor, Ewk_Popup_Menu *ewk_menu) +{ + Browser_Window *window = window_find_with_ewk_view(smartData->self); + + if (window->popup.elm_menu) + evas_object_del(window->popup.elm_menu); + + window->popup.elm_menu = elm_menu_add(window->elm_window); + window->popup.ewk_menu = ewk_menu; + evas_object_smart_callback_add(window->popup.elm_menu, "clicked", on_popup_menu_discarded, window); + + popup_menu_populate(window->popup.elm_menu, ewk_menu, window); + + info("Showing popup menu at (%d, %d)", rect.x, rect.y); + elm_menu_move(window->popup.elm_menu, rect.x, rect.y); + evas_object_show(window->popup.elm_menu); + + return EINA_TRUE; +} + +static Eina_Bool +on_popup_menu_hide(Ewk_View_Smart_Data *smartData) +{ + Browser_Window *window = window_find_with_ewk_view(smartData->self); + + if (!window->popup.elm_menu) + return EINA_FALSE; + + elm_menu_close(window->popup.elm_menu); + + return EINA_TRUE; +} + static Eina_Bool on_window_geometry_get(Ewk_View_Smart_Data *sd, Evas_Coord *x, Evas_Coord *y, Evas_Coord *width, Evas_Coord *height) { Browser_Window *window = window_find_with_ewk_view(sd->self); @@ -694,6 +1292,7 @@ on_fullscreen_accept(void *user_data, Evas_Object *obj, void *event_info) PermissionData *permission_data = (PermissionData *)user_data; evas_object_del(permission_data->permission_popup); + evas_object_focus_set(permission_data->ewk_view, EINA_TRUE); free(permission_data); } @@ -704,6 +1303,7 @@ on_fullscreen_deny(void *user_data, Evas_Object *obj, void *event_info) ewk_view_fullscreen_exit(permission_data->ewk_view); evas_object_del(permission_data->permission_popup); + evas_object_focus_set(permission_data->ewk_view, EINA_TRUE); free(permission_data); } @@ -753,7 +1353,7 @@ static Eina_Bool on_fullscreen_exit(Ewk_View_Smart_Data *sd) } static Evas_Object * -on_window_create(Ewk_View_Smart_Data *smartData, const Ewk_Window_Features *window_features) +on_window_create(Ewk_View_Smart_Data *smartData, const char *url, const Ewk_Window_Features *window_features) { int x = 0; int y = 0; @@ -768,12 +1368,12 @@ on_window_create(Ewk_View_Smart_Data *smartData, const Ewk_Window_Features *wind if (!height) height = window_height; - Browser_Window *window = window_create(NULL, width, height); + Browser_Window *window = window_create(smartData->self, url, width, height, EINA_FALSE); Evas_Object *new_view = window->ewk_view; windows = eina_list_append(windows, window); - info("minibrowser: location(%d,%d) size=(%d,%d)\n", x, y, width, height); + info("minibrowser: location(%d,%d) size=(%d,%d) url=%s", x, y, width, height, url); return new_view; } @@ -786,6 +1386,106 @@ on_window_close(Ewk_View_Smart_Data *smartData) } static void +context_menu_item_selected_cb(void *data, Evas_Object *obj, void *event_info) +{ + if (!data) { + info("ERROR: context menu callback data is NULL."); + return; + } + + Ewk_Context_Menu_Item *ewk_item = (Ewk_Context_Menu_Item *)data; + info("Selected context menu item: %s.", ewk_context_menu_item_title_get(ewk_item)); + ewk_context_menu_item_select(ewk_context_menu_item_parent_menu_get(ewk_item), ewk_item); + ewk_context_menu_hide(ewk_context_menu_item_parent_menu_get(ewk_item)); +} + +static void +context_menu_populate(Evas_Object* context_menu, Ewk_Context_Menu *ewk_menu, Elm_Object_Item *parent_item) +{ + if (!context_menu || !ewk_menu) { + info("ERROR: necessary objects are NULL."); + return; + } + + const Eina_List *list = ewk_context_menu_items_get(ewk_menu); + const Eina_List *l; + void *data; + + Ewk_Context_Menu_Item *ewk_item; + Elm_Object_Item *elm_menu_item; + Evas_Object *elm_check_item; + + EINA_LIST_FOREACH(list, l, data) { + ewk_item = (Ewk_Context_Menu_Item *)data; + switch (ewk_context_menu_item_type_get(ewk_item)) { + case EWK_ACTION_TYPE: + elm_menu_item = elm_menu_item_add(context_menu, parent_item, NULL, ewk_context_menu_item_title_get(ewk_item), context_menu_item_selected_cb, ewk_item); + break; + case EWK_CHECKABLE_ACTION_TYPE: + elm_check_item = elm_check_add(context_menu); + elm_menu_item = elm_menu_item_add(context_menu, parent_item, NULL, ewk_context_menu_item_title_get(ewk_item), context_menu_item_selected_cb, ewk_item); + elm_object_item_content_set(elm_menu_item, elm_check_item); + elm_check_state_set(elm_check_item, ewk_context_menu_item_checked_get(ewk_item)); + break; + case EWK_SUBMENU_TYPE: + elm_menu_item = elm_menu_item_add(context_menu, parent_item, NULL, ewk_context_menu_item_title_get(ewk_item), NULL, ewk_item); + if (elm_menu_item) + context_menu_populate(context_menu, ewk_context_menu_item_submenu_get(ewk_item), elm_menu_item); + break; + default: + continue; + } + elm_object_item_disabled_set(elm_menu_item, !ewk_context_menu_item_enabled_get(ewk_item)); + } +} + +static Eina_Bool +on_context_menu_show(Ewk_View_Smart_Data *sd, Evas_Coord x, Evas_Coord y, Ewk_Context_Menu *menu) +{ + Browser_Window *window = window_find_with_ewk_view(sd->self); + + if (!window || !menu) { + info("ERROR: necessary objects are NULL."); + return EINA_FALSE; + } + + window->context_menu.elm_menu = elm_menu_add(window->elm_window); + + if (!window->context_menu.elm_menu) { + info("ERROR: could not create menu widget."); + return EINA_FALSE; + } + + window->context_menu.ewk_menu = menu; + + context_menu_populate(window->context_menu.elm_menu, menu, NULL); + + info("Showing context menu at (%d, %d).", x, y); + elm_menu_move(window->context_menu.elm_menu, x, y); + evas_object_show(window->context_menu.elm_menu); + + return EINA_TRUE; +} + +static Eina_Bool +on_context_menu_hide(Ewk_View_Smart_Data *sd) +{ + Browser_Window *window = window_find_with_ewk_view(sd->self); + + if (!window || !window->context_menu.elm_menu) { + info("ERROR: necessary objects are NULL."); + return EINA_FALSE; + } + + elm_menu_close(window->context_menu.elm_menu); + evas_object_del(window->context_menu.elm_menu); + window->context_menu.elm_menu = NULL; + window->context_menu.ewk_menu = NULL; + + return EINA_TRUE; +} + +static void auth_popup_close(Auth_Data *auth_data) { ewk_object_unref(auth_data->request); @@ -918,8 +1618,9 @@ on_tooltip_text_set(void *user_data, Evas_Object *obj, void *event_info) Browser_Window *window = (Browser_Window *)user_data; const char *message = (const char*)event_info; - elm_object_tooltip_text_set(window->ewk_view, message); - elm_object_tooltip_show(window->ewk_view); + elm_object_tooltip_text_set(window->elm_window, message); + window->tooltip.text_set = EINA_TRUE; + window_tooltip_update(window); } static void @@ -927,7 +1628,9 @@ on_tooltip_text_unset(void *user_data, Evas_Object *obj, void *event_info) { Browser_Window *window = (Browser_Window *)user_data; - elm_object_tooltip_unset(window->ewk_view); + window_tooltip_hide(window); + elm_object_tooltip_unset(window->elm_window); + window->tooltip.text_set = EINA_FALSE; } static void @@ -960,14 +1663,20 @@ create_toolbar_button(Evas_Object *elm_window, const char *icon_name) return button; } -static Browser_Window *window_create(const char *url, int width, int height) +static Browser_Window *window_create(Evas_Object *opener, const char *url, int width, int height, Eina_Bool view_mode) { - Browser_Window *window = malloc(sizeof(Browser_Window)); + Browser_Window *window = calloc(1, sizeof(Browser_Window)); if (!window) { - info("ERROR: could not create browser window.\n"); + info("ERROR: could not create browser window."); return NULL; } + /* Initialize tooltip information */ + window->tooltip.show_timer = NULL; + window->tooltip.activated = EINA_FALSE; + window->tooltip.text_set = EINA_FALSE; + window->tooltip.shown = EINA_FALSE; + /* Create window */ window->elm_window = elm_win_add(NULL, "minibrowser-window", ELM_WIN_BASIC); elm_win_title_set(window->elm_window, APP_NAME); @@ -1043,6 +1752,46 @@ static Browser_Window *window_create(const char *url, int width, int height) elm_box_pack_end(horizontal_layout, home_button); evas_object_show(home_button); + /* Create Search bar */ + window->search.search_bar = elm_box_add(window->elm_window); + elm_box_horizontal_set(window->search.search_bar, EINA_TRUE); + evas_object_size_hint_min_set(window->search.search_bar, SEARCH_FIELD_SIZE + 2 * SEARCH_BUTTON_SIZE, 0); + evas_object_size_hint_align_set(window->search.search_bar, 0.0, EVAS_HINT_FILL); + elm_box_pack_end(vertical_layout, window->search.search_bar); + + /* Create Search field */ + window->search.search_field = elm_entry_add(window->elm_window); + elm_entry_scrollable_set(window->search.search_field, EINA_TRUE); + elm_entry_scrollbar_policy_set(window->search.search_field, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); + elm_entry_single_line_set(window->search.search_field, EINA_TRUE); + elm_entry_cnp_mode_set(window->search.search_field, ELM_CNP_MODE_PLAINTEXT); + elm_entry_text_style_user_push(window->search.search_field, "DEFAULT='font_size=14'"); + evas_object_smart_callback_add(window->search.search_field, "activated", on_search_field_activated, window); + evas_object_smart_callback_add(window->search.search_field, "changed", on_search_field_activated, window); + evas_object_smart_callback_add(window->search.search_field, "aborted", on_search_field_aborted, window); + evas_object_smart_callback_add(window->search.search_field, "clicked", on_search_field_clicked, window); + evas_object_size_hint_weight_set(window->search.search_field, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(window->search.search_field, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_box_pack_end(window->search.search_bar, window->search.search_field); + + /* Create Search backward button */ + window->search.backward_button = create_toolbar_button(window->elm_window, "arrow_up"); + evas_object_smart_callback_add(window->search.backward_button, "clicked", on_search_backward_button_clicked, window); + elm_object_disabled_set(window->search.backward_button, EINA_FALSE); + evas_object_size_hint_weight_set(window->search.backward_button, 0.0, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(window->search.backward_button, 1.0, 0.5); + evas_object_size_hint_min_set(window->search.backward_button, SEARCH_BUTTON_SIZE, SEARCH_BUTTON_SIZE); + elm_box_pack_end(window->search.search_bar, window->search.backward_button); + + /* Create Search forwardward button */ + window->search.forward_button = create_toolbar_button(window->elm_window, "arrow_down"); + evas_object_smart_callback_add(window->search.forward_button, "clicked", on_search_forward_button_clicked, window); + elm_object_disabled_set(window->search.forward_button, EINA_FALSE); + evas_object_size_hint_weight_set(window->search.forward_button, 0.0, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(window->search.forward_button, 1.0, 0.5); + evas_object_size_hint_min_set(window->search.forward_button, SEARCH_BUTTON_SIZE, SEARCH_BUTTON_SIZE); + elm_box_pack_end(window->search.search_bar, window->search.forward_button); + /* Create ewk_view */ Ewk_View_Smart_Class *ewkViewClass = miniBrowserViewSmartClass(); ewkViewClass->run_javascript_alert = on_javascript_alert; @@ -1054,30 +1803,51 @@ static Browser_Window *window_create(const char *url, int width, int height) ewkViewClass->fullscreen_exit = on_fullscreen_exit; ewkViewClass->window_create = on_window_create; ewkViewClass->window_close = on_window_close; + ewkViewClass->popup_menu_show = on_popup_menu_show; + ewkViewClass->popup_menu_hide = on_popup_menu_hide; + ewkViewClass->context_menu_show = on_context_menu_show; + ewkViewClass->context_menu_hide = on_context_menu_hide; + ewkViewClass->input_picker_color_request = on_color_picker_request; + ewkViewClass->input_picker_color_dismiss = on_color_picker_dismiss; Evas *evas = evas_object_evas_get(window->elm_window); - Evas_Smart *smart = evas_smart_class_new(&ewkViewClass->sc); - window->ewk_view = ewk_view_smart_add(evas, smart, ewk_context_default_get()); - ewk_view_theme_set(window->ewk_view, THEME_DIR "/default.edj"); + if (legacy_behavior_enabled) { + // Use raw WK2 api to create a view using legacy mode. + window->ewk_view = (Evas_Object*)WKViewCreate(evas, 0, 0); + } else { + Evas_Smart *smart = evas_smart_class_new(&ewkViewClass->sc); + Ewk_Context *context = opener ? ewk_view_context_get(opener) : ewk_context_default_get(); + Ewk_Page_Group *pageGroup = opener ? ewk_view_page_group_get(opener) : ewk_page_group_create(""); + window->ewk_view = ewk_view_smart_add(evas, smart, context, pageGroup); + } + ewk_view_theme_set(window->ewk_view, TEST_THEME_DIR "/default.edj"); if (device_pixel_ratio) ewk_view_device_pixel_ratio_set(window->ewk_view, (float)device_pixel_ratio); + ewk_view_source_mode_set(window->ewk_view, view_mode); + ewk_view_user_agent_set(window->ewk_view, user_agent_string); + + /* Set the zoom level to default */ + window->current_zoom_level = DEFAULT_ZOOM_LEVEL; Ewk_Settings *settings = ewk_view_settings_get(window->ewk_view); ewk_settings_file_access_from_file_urls_allowed_set(settings, EINA_TRUE); ewk_settings_encoding_detector_enabled_set(settings, encoding_detector_enabled); ewk_settings_frame_flattening_enabled_set(settings, frame_flattening_enabled); ewk_settings_local_storage_enabled_set(settings, local_storage_enabled); - info("HTML5 local storage is %s for this view.\n", local_storage_enabled ? "enabled" : "disabled"); + info("HTML5 local storage is %s for this view.", local_storage_enabled ? "enabled" : "disabled"); + elm_win_fullscreen_set(window->elm_window, fullscreen_enabled); ewk_settings_developer_extras_enabled_set(settings, EINA_TRUE); ewk_settings_preferred_minimum_contents_width_set(settings, 0); + ewk_text_checker_continuous_spell_checking_enabled_set(spell_checking_enabled); evas_object_smart_callback_add(window->ewk_view, "authentication,request", on_authentication_request, window); evas_object_smart_callback_add(window->ewk_view, "download,failed", on_download_failed, window); evas_object_smart_callback_add(window->ewk_view, "download,finished", on_download_finished, window); evas_object_smart_callback_add(window->ewk_view, "download,request", on_download_request, window); evas_object_smart_callback_add(window->ewk_view, "file,chooser,request", on_file_chooser_request, window); - evas_object_smart_callback_add(window->ewk_view, "icon,changed", on_view_icon_changed, window); + evas_object_smart_callback_add(window->ewk_view, "favicon,changed", on_view_favicon_changed, window); evas_object_smart_callback_add(window->ewk_view, "load,error", on_error, window); + evas_object_smart_callback_add(window->ewk_view, "load,provisional,failed", on_error, window); evas_object_smart_callback_add(window->ewk_view, "load,progress", on_progress, window); evas_object_smart_callback_add(window->ewk_view, "title,changed", on_title_changed, window); evas_object_smart_callback_add(window->ewk_view, "url,changed", on_url_changed, window); @@ -1090,20 +1860,38 @@ static Browser_Window *window_create(const char *url, int width, int height) evas_object_size_hint_weight_set(window->ewk_view, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(window->ewk_view, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_box_pack_end(vertical_layout, window->ewk_view); + elm_box_pack_before(vertical_layout, window->ewk_view, window->search.search_bar); evas_object_show(window->ewk_view); - if (url) + if (url && strcmp(url, "about:blank")) // Do not reset 'about:blank' as it would erase all previous document modifications. ewk_view_url_set(window->ewk_view, url); evas_object_resize(window->elm_window, width ? width : window_width, height ? height : window_height); evas_object_show(window->elm_window); + search_box_hide(window); view_focus_set(window, EINA_TRUE); + evas_object_event_callback_add(window->ewk_view, EVAS_CALLBACK_MOUSE_IN, on_mouse_in, window); + evas_object_event_callback_add(window->ewk_view, EVAS_CALLBACK_MOUSE_OUT, on_mouse_out, window); + evas_object_event_callback_add(window->ewk_view, EVAS_CALLBACK_MOUSE_MOVE, on_mouse_move, window); + evas_object_event_callback_add(window->elm_window, EVAS_CALLBACK_RESIZE, on_window_resize, window); + return window; } +static Ewk_Cookie_Accept_Policy +parse_cookies_policy(const char *input_string) +{ + if (!strcmp(input_string, "always")) + return EWK_COOKIE_ACCEPT_POLICY_ALWAYS; + if (!strcmp(input_string, "never")) + return EWK_COOKIE_ACCEPT_POLICY_NEVER; + if (strcmp(input_string, "no-third-party")) + info("Unrecognized type for cookies policy: %s.", input_string); + return EWK_COOKIE_ACCEPT_POLICY_NO_THIRD_PARTY; +} + static void parse_window_size(const char *input_string, int *width, int *height) { @@ -1136,15 +1924,21 @@ elm_main(int argc, char *argv[]) unsigned char quitOption = 0; Browser_Window *window; char *window_size_string = NULL; + char *cookies_policy_string = NULL; Ecore_Getopt_Value values[] = { ECORE_GETOPT_VALUE_STR(evas_engine_name), ECORE_GETOPT_VALUE_STR(window_size_string), + ECORE_GETOPT_VALUE_STR(user_agent_string), + ECORE_GETOPT_VALUE_BOOL(legacy_behavior_enabled), ECORE_GETOPT_VALUE_DOUBLE(device_pixel_ratio), ECORE_GETOPT_VALUE_BOOL(quitOption), ECORE_GETOPT_VALUE_BOOL(encoding_detector_enabled), ECORE_GETOPT_VALUE_BOOL(frame_flattening_enabled), ECORE_GETOPT_VALUE_BOOL(local_storage_enabled), + ECORE_GETOPT_VALUE_BOOL(fullscreen_enabled), + ECORE_GETOPT_VALUE_BOOL(spell_checking_enabled), + ECORE_GETOPT_VALUE_STR(cookies_policy_string), ECORE_GETOPT_VALUE_BOOL(quitOption), ECORE_GETOPT_VALUE_BOOL(quitOption), ECORE_GETOPT_VALUE_BOOL(quitOption), @@ -1178,15 +1972,18 @@ elm_main(int argc, char *argv[]) Ewk_Context *context = ewk_context_default_get(); ewk_context_favicon_database_directory_set(context, NULL); + if (cookies_policy_string) + ewk_cookie_manager_accept_policy_set(ewk_context_cookie_manager_get(context), parse_cookies_policy(cookies_policy_string)); + if (window_size_string) parse_window_size(window_size_string, &window_width, &window_height); if (args < argc) { char *url = url_from_user_input(argv[args]); - window = window_create(url, 0, 0); + window = window_create(NULL, url, 0, 0, EINA_FALSE); free(url); } else - window = window_create(DEFAULT_URL, 0, 0); + window = window_create(NULL, DEFAULT_URL, 0, 0, EINA_FALSE); if (!window) return quit(EINA_FALSE, "ERROR: could not create browser window.\n"); @@ -1198,3 +1995,4 @@ elm_main(int argc, char *argv[]) return quit(EINA_TRUE, NULL); } ELM_MAIN() + diff --git a/Tools/MiniBrowser/gtk/BrowserWindow.c b/Tools/MiniBrowser/gtk/BrowserWindow.c index 86b04461d..c95f49c98 100644 --- a/Tools/MiniBrowser/gtk/BrowserWindow.c +++ b/Tools/MiniBrowser/gtk/BrowserWindow.c @@ -29,6 +29,7 @@ #include "BrowserDownloadsBar.h" #include "BrowserSettingsDialog.h" +#include <gdk/gdkkeysyms.h> #include <string.h> enum { @@ -52,6 +53,8 @@ struct _BrowserWindow { WebKitWebView *webView; GtkWidget *downloadsBar; GdkPixbuf *favicon; + GtkWidget *fullScreenMessageLabel; + guint fullScreenMessageLabelId; }; struct _BrowserWindowClass { @@ -59,6 +62,7 @@ struct _BrowserWindowClass { }; static const char *defaultWindowTitle = "WebKitGTK+ MiniBrowser"; +static const char *miniBrowserAboutScheme = "minibrowser-about"; static const gdouble minimumZoomLevel = 0.5; static const gdouble maximumZoomLevel = 3; static const gdouble zoomStep = 1.2; @@ -66,12 +70,28 @@ static gint windowCount = 0; G_DEFINE_TYPE(BrowserWindow, browser_window, GTK_TYPE_WINDOW) +static char *getInternalURI(const char *uri) +{ + // Internally we use minibrowser-about: as about: prefix is ignored by WebKit. + if (g_str_has_prefix(uri, "about:") && !g_str_equal(uri, "about:blank")) + return g_strconcat(miniBrowserAboutScheme, uri + strlen ("about"), NULL); + + return g_strdup(uri); +} + +static char *getExternalURI(const char *uri) +{ + // From the user point of view we support about: prefix. + if (g_str_has_prefix(uri, miniBrowserAboutScheme)) + return g_strconcat("about", uri + strlen(miniBrowserAboutScheme), NULL); + + return g_strdup(uri); +} + static void browserWindowSetStatusText(BrowserWindow *window, const char *text) { -#if GTK_CHECK_VERSION(3, 2, 0) gtk_label_set_text(GTK_LABEL(window->statusLabel), text); gtk_widget_set_visible(window->statusLabel, !!text); -#endif } static void resetStatusText(GtkWidget *widget, BrowserWindow *window) @@ -114,7 +134,9 @@ static void settingsCallback(BrowserWindow *window) static void webViewURIChanged(WebKitWebView *webView, GParamSpec *pspec, BrowserWindow *window) { - gtk_entry_set_text(GTK_ENTRY(window->uriEntry), webkit_web_view_get_uri(webView)); + char *externalURI = getExternalURI(webkit_web_view_get_uri(webView)); + gtk_entry_set_text(GTK_ENTRY(window->uriEntry), externalURI); + g_free(externalURI); } static void webViewTitleChanged(WebKitWebView *webView, GParamSpec *pspec, BrowserWindow *window) @@ -261,6 +283,43 @@ static void webViewReadyToShow(WebKitWebView *webView, BrowserWindow *window) gtk_widget_show(GTK_WIDGET(window)); } +static gboolean fullScreenMessageTimeoutCallback(BrowserWindow *window) +{ + gtk_widget_hide(window->fullScreenMessageLabel); + window->fullScreenMessageLabelId = 0; + return FALSE; +} + +static gboolean webViewEnterFullScreen(WebKitWebView *webView, BrowserWindow *window) +{ + gchar *titleOrURI = g_strdup(webkit_web_view_get_title(window->webView)); + if (!titleOrURI) + titleOrURI = getExternalURI(webkit_web_view_get_uri(window->webView)); + gchar *message = g_strdup_printf("%s is now full screen. Press ESC or f to exit.", titleOrURI); + gtk_label_set_text(GTK_LABEL(window->fullScreenMessageLabel), message); + g_free(titleOrURI); + g_free(message); + + gtk_widget_show(window->fullScreenMessageLabel); + + window->fullScreenMessageLabelId = g_timeout_add_seconds(2, (GSourceFunc)fullScreenMessageTimeoutCallback, window); + gtk_widget_hide(window->toolbar); + + return FALSE; +} + +static gboolean webViewLeaveFullScreen(WebKitWebView *webView, BrowserWindow *window) +{ + if (window->fullScreenMessageLabelId) { + g_source_remove(window->fullScreenMessageLabelId); + window->fullScreenMessageLabelId = 0; + } + gtk_widget_hide(window->fullScreenMessageLabel); + gtk_widget_show(window->toolbar); + + return FALSE; +} + static GtkWidget *webViewCreate(WebKitWebView *webView, BrowserWindow *window) { WebKitWebView *newWebView = WEBKIT_WEB_VIEW(webkit_web_view_new_with_context(webkit_web_view_get_context(webView))); @@ -281,22 +340,43 @@ static gboolean webViewLoadFailed(WebKitWebView *webView, WebKitLoadEvent loadEv static gboolean webViewDecidePolicy(WebKitWebView *webView, WebKitPolicyDecision *decision, WebKitPolicyDecisionType decisionType, BrowserWindow *window) { - if (decisionType != WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION) - return FALSE; - - WebKitNavigationPolicyDecision *navigationDecision = WEBKIT_NAVIGATION_POLICY_DECISION(decision); - if (webkit_navigation_policy_decision_get_navigation_type(navigationDecision) != WEBKIT_NAVIGATION_TYPE_LINK_CLICKED - || webkit_navigation_policy_decision_get_mouse_button(navigationDecision) != 2) + switch (decisionType) { + case WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION: { + WebKitNavigationPolicyDecision *navigationDecision = WEBKIT_NAVIGATION_POLICY_DECISION(decision); + if (webkit_navigation_policy_decision_get_navigation_type(navigationDecision) != WEBKIT_NAVIGATION_TYPE_LINK_CLICKED + || webkit_navigation_policy_decision_get_mouse_button(navigationDecision) != GDK_BUTTON_MIDDLE) + return FALSE; + + // Opening a new window if link clicked with the middle button. + WebKitWebView *newWebView = WEBKIT_WEB_VIEW(webkit_web_view_new_with_context(webkit_web_view_get_context(webView))); + GtkWidget *newWindow = browser_window_new(newWebView, GTK_WINDOW(window)); + webkit_web_view_load_request(newWebView, webkit_navigation_policy_decision_get_request(navigationDecision)); + gtk_widget_show(newWindow); + + webkit_policy_decision_ignore(decision); + return TRUE; + } + case WEBKIT_POLICY_DECISION_TYPE_RESPONSE: { + WebKitResponsePolicyDecision *responseDecision = WEBKIT_RESPONSE_POLICY_DECISION(decision); + WebKitURIResponse *response = webkit_response_policy_decision_get_response(responseDecision); + const char *mimeType = webkit_uri_response_get_mime_type(response); + + if (webkit_web_view_can_show_mime_type(webView, mimeType)) + return FALSE; + + WebKitWebResource *mainResource = webkit_web_view_get_main_resource(webView); + WebKitURIRequest *request = webkit_response_policy_decision_get_request(responseDecision); + const char *requestURI = webkit_uri_request_get_uri(request); + if (g_strcmp0(webkit_web_resource_get_uri(mainResource), requestURI)) + return FALSE; + + webkit_policy_decision_download(decision); + return TRUE; + } + case WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION: + default: return FALSE; - - WebKitWebView *newWebView = WEBKIT_WEB_VIEW(webkit_web_view_new_with_context(webkit_web_view_get_context(webView))); - webkit_web_view_set_settings(newWebView, webkit_web_view_get_settings(webView)); - GtkWidget *newWindow = browser_window_new(newWebView, GTK_WINDOW(window)); - webkit_web_view_load_request(newWebView, webkit_navigation_policy_decision_get_request(navigationDecision)); - gtk_widget_show(newWindow); - - webkit_policy_decision_ignore(decision); - return TRUE; + } } static gboolean webViewDecidePermissionRequest(WebKitWebView *webView, WebKitPermissionRequest *request, BrowserWindow *window) @@ -396,6 +476,9 @@ static void browserWindowFinalize(GObject *gObject) window->favicon = NULL; } + if (window->fullScreenMessageLabelId) + g_source_remove(window->fullScreenMessageLabelId); + G_OBJECT_CLASS(browser_window_parent_class)->finalize(gObject); if (g_atomic_int_dec_and_test(&windowCount)) @@ -440,6 +523,11 @@ static void browser_window_init(BrowserWindow *window) gtk_entry_set_icon_activatable(GTK_ENTRY(window->uriEntry), GTK_ENTRY_ICON_PRIMARY, FALSE); updateUriEntryIcon(window); + /* Keyboard accelerators */ + GtkAccelGroup *accelGroup = gtk_accel_group_new(); + gtk_window_add_accel_group(GTK_WINDOW(window), accelGroup); + g_object_unref(accelGroup); + GtkWidget *toolbar = gtk_toolbar_new(); window->toolbar = toolbar; gtk_orientable_set_orientation(GTK_ORIENTABLE(toolbar), GTK_ORIENTATION_HORIZONTAL); @@ -483,9 +571,10 @@ static void browser_window_init(BrowserWindow *window) gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, -1); gtk_widget_show(GTK_WIDGET(item)); - item = gtk_tool_button_new_from_stock(GTK_STOCK_OK); + item = gtk_tool_button_new_from_stock(GTK_STOCK_REFRESH); g_signal_connect_swapped(item, "clicked", G_CALLBACK(reloadCallback), window); gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, -1); + gtk_widget_add_accelerator(GTK_WIDGET(item), "clicked", accelGroup, GDK_KEY_F5, 0, GTK_ACCEL_VISIBLE); gtk_widget_show(GTK_WIDGET(item)); GtkWidget *vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); @@ -513,13 +602,14 @@ static void browserWindowConstructed(GObject *gObject) g_signal_connect(window->webView, "mouse-target-changed", G_CALLBACK(webViewMouseTargetChanged), window); g_signal_connect(window->webView, "notify::zoom-level", G_CALLBACK(webViewZoomLevelChanged), window); g_signal_connect(window->webView, "notify::favicon", G_CALLBACK(faviconChanged), window); + g_signal_connect(window->webView, "enter-fullscreen", G_CALLBACK(webViewEnterFullScreen), window); + g_signal_connect(window->webView, "leave-fullscreen", G_CALLBACK(webViewLeaveFullScreen), window); g_signal_connect(webkit_web_view_get_context(window->webView), "download-started", G_CALLBACK(downloadStarted), window); WebKitBackForwardList *backForwadlist = webkit_web_view_get_back_forward_list(window->webView); g_signal_connect(backForwadlist, "changed", G_CALLBACK(backForwadlistChanged), window); -#if GTK_CHECK_VERSION(3, 2, 0) GtkWidget *overlay = gtk_overlay_new(); gtk_box_pack_start(GTK_BOX(window->mainBox), overlay, TRUE, TRUE, 0); gtk_widget_show(overlay); @@ -534,9 +624,12 @@ static void browserWindowConstructed(GObject *gObject) gtk_overlay_add_overlay(GTK_OVERLAY(overlay), window->statusLabel); gtk_container_add(GTK_CONTAINER(overlay), GTK_WIDGET(window->webView)); -#else - gtk_box_pack_start(GTK_BOX(window->mainBox), GTK_WIDGET(window->webView), TRUE, TRUE, 0); -#endif + + window->fullScreenMessageLabel = gtk_label_new(NULL); + gtk_widget_set_halign(window->fullScreenMessageLabel, GTK_ALIGN_CENTER); + gtk_widget_set_valign(window->fullScreenMessageLabel, GTK_ALIGN_CENTER); + gtk_widget_set_no_show_all(window->fullScreenMessageLabel, TRUE); + gtk_overlay_add_overlay(GTK_OVERLAY(overlay), window->fullScreenMessageLabel); gtk_widget_show(GTK_WIDGET(window->webView)); } @@ -582,7 +675,9 @@ void browser_window_load_uri(BrowserWindow *window, const char *uri) g_return_if_fail(uri); if (!g_str_has_prefix(uri, "javascript:")) { - webkit_web_view_load_uri(window->webView, uri); + char *internalURI = getInternalURI(uri); + webkit_web_view_load_uri(window->webView, internalURI); + g_free(internalURI); return; } diff --git a/Tools/MiniBrowser/gtk/CMakeLists.txt b/Tools/MiniBrowser/gtk/CMakeLists.txt new file mode 100644 index 000000000..14fd82f3f --- /dev/null +++ b/Tools/MiniBrowser/gtk/CMakeLists.txt @@ -0,0 +1,51 @@ +set(MINIBROWSER_DIR "${TOOLS_DIR}/MiniBrowser/gtk") +set(DERIVED_SOURCES_MINIBROWSER_DIR "${CMAKE_BINARY_DIR}/DerivedSources/MiniBrowser") + +file(MAKE_DIRECTORY ${DERIVED_SOURCES_MINIBROWSER_DIR}) + +set(MiniBrowser_SOURCES + ${DERIVED_SOURCES_MINIBROWSER_DIR}/BrowserMarshal.c + ${MINIBROWSER_DIR}/BrowserCellRendererVariant.h + ${MINIBROWSER_DIR}/BrowserCellRendererVariant.c + ${MINIBROWSER_DIR}/BrowserDownloadsBar.h + ${MINIBROWSER_DIR}/BrowserDownloadsBar.c + ${MINIBROWSER_DIR}/BrowserSettingsDialog.h + ${MINIBROWSER_DIR}/BrowserSettingsDialog.c + ${MINIBROWSER_DIR}/BrowserWindow.h + ${MINIBROWSER_DIR}/BrowserWindow.c + ${MINIBROWSER_DIR}/main.c +) + +set(MiniBrowser_INCLUDE_DIRECTORIES + ${DERIVED_SOURCES_MINIBROWSER_DIR} + ${DERIVED_SOURCES_DIR}/webkit2gtk + ${DERIVED_SOURCES_DIR}/ForwardingHeaders/webkit2gtk + ${DERIVED_SOURCES_DIR}/ForwardingHeaders + ${CMAKE_SOURCE_DIR}/Source + ${GTK3_INCLUDE_DIRS} + ${GLIB_INCLUDE_DIRS} + ${LIBSOUP_INCLUDE_DIRS} +) + +set(MiniBrowser_LIBRARIES + ${JavaScriptCore_LIBRARY_NAME} + WebKit2 + ${GTK3_LIBRARIES} + ${GLIB_LIBRARIES} +) + +add_custom_command( + OUTPUT ${DERIVED_SOURCES_MINIBROWSER_DIR}/BrowserMarshal.c + ${DERIVED_SOURCES_MINIBROWSER_DIR}/Browsermarshal.h + MAIN_DEPENDENCY ${MINIBROWSER_DIR}/browser-marshal.list + COMMAND glib-genmarshal --prefix=browser_marshal ${MINIBROWSER_DIR}/browser-marshal.list --body > ${DERIVED_SOURCES_MINIBROWSER_DIR}/BrowserMarshal.c + COMMAND glib-genmarshal --prefix=browser_marshal ${MINIBROWSER_DIR}/browser-marshal.list --header > ${DERIVED_SOURCES_MINIBROWSER_DIR}/BrowserMarshal.h + VERBATIM) + +add_definitions(-DWEBKIT_EXEC_PATH="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") +add_definitions(-DWEBKIT_INJECTED_BUNDLE_PATH="${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") + +include_directories(${MiniBrowser_INCLUDE_DIRECTORIES}) +add_executable(MiniBrowser ${MiniBrowser_SOURCES}) +target_link_libraries(MiniBrowser ${MiniBrowser_LIBRARIES}) +set_target_properties(MiniBrowser PROPERTIES FOLDER "Tools") diff --git a/Tools/MiniBrowser/gtk/GNUmakefile.am b/Tools/MiniBrowser/gtk/GNUmakefile.am index 50974ae2f..f42a30b79 100644 --- a/Tools/MiniBrowser/gtk/GNUmakefile.am +++ b/Tools/MiniBrowser/gtk/GNUmakefile.am @@ -9,10 +9,13 @@ Programs_MiniBrowser_CPPFLAGS = \ -I$(top_builddir)/DerivedSources/WebKit2/webkit2gtk \ -I$(top_builddir)/DerivedSources/WebKit2/webkit2gtk/include \ -DWEBKIT_EXEC_PATH=\"${shell pwd}/$(top_builddir)/Programs/\" \ + -DWEBKIT_INJECTED_BUNDLE_PATH=\"${shell pwd}/$(top_builddir)/.libs\" \ $(global_cppflags) \ $(javascriptcore_cppflags) \ + $(FREETYPE_CFLAGS) \ $(GLIB_CFLAGS) \ - $(GTK_CFLAGS) + $(GTK_CFLAGS) \ + $(LIBSOUP_CFLAGS) Programs_MiniBrowser_SOURCES = \ Tools/MiniBrowser/gtk/BrowserCellRendererVariant.h \ @@ -33,6 +36,7 @@ nodist_Programs_MiniBrowser_SOURCES = \ Programs_MiniBrowser_LDADD = \ libwebkit2gtk-@WEBKITGTK_API_MAJOR_VERSION@.@WEBKITGTK_API_MINOR_VERSION@.la \ + $(FREETYPE_LIBS) \ $(GLIB_LIBS) \ $(GTK_LIBS) \ $(LIBSOUP_LIBS) diff --git a/Tools/MiniBrowser/gtk/main.c b/Tools/MiniBrowser/gtk/main.c index c7367df9c..4592d76bb 100644 --- a/Tools/MiniBrowser/gtk/main.c +++ b/Tools/MiniBrowser/gtk/main.c @@ -31,7 +31,19 @@ #include <string.h> #include <webkit2/webkit2.h> +#define MINI_BROWSER_ERROR (miniBrowserErrorQuark()) + static const gchar **uriArguments = NULL; +static const char *miniBrowserAboutScheme = "minibrowser-about"; + +typedef enum { + MINI_BROWSER_ERROR_INVALID_ABOUT_PATH +} MiniBrowserError; + +static GQuark miniBrowserErrorQuark() +{ + return g_quark_from_string("minibrowser-quark"); +} static gchar *argumentToURL(const char *filename) { @@ -198,6 +210,33 @@ static gboolean addSettingsGroupToContext(GOptionContext *context, WebKitSetting return TRUE; } +static void +aboutURISchemeRequestCallback(WebKitURISchemeRequest *request, gpointer userData) +{ + GInputStream *stream; + gsize streamLength; + const gchar *path; + gchar *contents; + GError *error; + + path = webkit_uri_scheme_request_get_path(request); + if (!g_strcmp0(path, "minibrowser")) { + contents = g_strdup_printf("<html><body><h1>WebKitGTK+ MiniBrowser</h1><p>The WebKit2 test browser of the GTK+ port.</p><p>WebKit version: %d.%d.%d</p></body></html>", + webkit_get_major_version(), + webkit_get_minor_version(), + webkit_get_micro_version()); + streamLength = strlen(contents); + stream = g_memory_input_stream_new_from_data(contents, streamLength, g_free); + + webkit_uri_scheme_request_finish(request, stream, streamLength, "text/html"); + g_object_unref(stream); + } else { + error = g_error_new(MINI_BROWSER_ERROR, MINI_BROWSER_ERROR_INVALID_ABOUT_PATH, "Invalid about:%s page.", path); + webkit_uri_scheme_request_finish_error(request, error); + g_error_free(error); + } +} + int main(int argc, char *argv[]) { gtk_init(&argc, &argv); @@ -226,10 +265,13 @@ int main(int argc, char *argv[]) #ifdef WEBKIT_EXEC_PATH g_setenv("WEBKIT_INSPECTOR_PATH", WEBKIT_EXEC_PATH "resources/inspector", FALSE); #endif /* WEBKIT_EXEC_PATH */ + g_setenv("WEBKIT_INJECTED_BUNDLE_PATH", WEBKIT_INJECTED_BUNDLE_PATH, FALSE); // Enable the favicon database, by specifying the default directory. webkit_web_context_set_favicon_database_directory(webkit_web_context_get_default(), NULL); + webkit_web_context_register_uri_scheme(webkit_web_context_get_default(), miniBrowserAboutScheme, aboutURISchemeRequestCallback, NULL, NULL); + if (uriArguments) { int i; diff --git a/Tools/MiniBrowser/mac/BrowserWindowController.h b/Tools/MiniBrowser/mac/BrowserWindowController.h index 7ee89197b..482184b65 100644 --- a/Tools/MiniBrowser/mac/BrowserWindowController.h +++ b/Tools/MiniBrowser/mac/BrowserWindowController.h @@ -46,6 +46,8 @@ - (IBAction)toggleZoomMode:(id)sender; - (IBAction)togglePaginationMode:(id)sender; +- (IBAction)toggleTransparentWindow:(id)sender; + - (IBAction)dumpSourceToConsole:(id)sender; - (IBAction)find:(id)sender; diff --git a/Tools/MiniBrowser/mac/MainMenu.xib b/Tools/MiniBrowser/mac/MainMenu.xib index b713a00f5..f40e9bd2b 100644 --- a/Tools/MiniBrowser/mac/MainMenu.xib +++ b/Tools/MiniBrowser/mac/MainMenu.xib @@ -946,6 +946,14 @@ <reference key="NSOnImage" ref="35465992"/> <reference key="NSMixedImage" ref="502551668"/> </object> + <object class="NSMenuItem" id="489162377"> + <reference key="NSMenu" ref="865232259"/> + <string key="NSTitle">Transparent Window</string> + <string key="NSKeyEquiv"/> + <int key="NSMnemonicLoc">2147483647</int> + <reference key="NSOnImage" ref="35465992"/> + <reference key="NSMixedImage" ref="502551668"/> + </object> <object class="NSMenuItem" id="624939128"> <reference key="NSMenu" ref="865232259"/> <bool key="NSIsDisabled">YES</bool> @@ -1468,6 +1476,14 @@ </object> <int key="connectionID">575</int> </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">toggleTransparentWindow:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="489162377"/> + </object> + <int key="connectionID">578</int> + </object> </object> <object class="IBMutableOrderedSet" key="objectRecords"> <object class="NSArray" key="orderedObjects"> @@ -2142,6 +2158,7 @@ <reference ref="191469404"/> <reference ref="624939128"/> <reference ref="15772092"/> + <reference ref="489162377"/> </object> <reference key="parent" ref="816668511"/> </object> @@ -2215,6 +2232,11 @@ <reference key="object" ref="552626760"/> <reference key="parent" ref="720053764"/> </object> + <object class="IBObjectRecord"> + <int key="objectID">576</int> + <reference key="object" ref="489162377"/> + <reference key="parent" ref="865232259"/> + </object> </object> </object> <object class="NSMutableDictionary" key="flattenedProperties"> @@ -2317,6 +2339,7 @@ <string>57.IBPluginDependency</string> <string>571.IBPluginDependency</string> <string>573.IBPluginDependency</string> + <string>576.IBPluginDependency</string> <string>58.IBPluginDependency</string> <string>72.IBPluginDependency</string> <string>73.IBPluginDependency</string> @@ -2442,6 +2465,7 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> </object> </object> <object class="NSMutableDictionary" key="unlocalizedProperties"> @@ -2456,7 +2480,7 @@ <reference key="dict.values" ref="0"/> </object> <nil key="sourceID"/> - <int key="maxID">575</int> + <int key="maxID">578</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> @@ -2602,6 +2626,73 @@ </object> </object> <object class="IBPartialClassDescription"> + <string key="className">NSDocument</string> + <object class="NSMutableDictionary" key="actions"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>printDocument:</string> + <string>revertDocumentToSaved:</string> + <string>runPageLayout:</string> + <string>saveDocument:</string> + <string>saveDocumentAs:</string> + <string>saveDocumentTo:</string> + </object> + <object class="NSArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + <string>id</string> + </object> + </object> + <object class="NSMutableDictionary" key="actionInfosByName"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>printDocument:</string> + <string>revertDocumentToSaved:</string> + <string>runPageLayout:</string> + <string>saveDocument:</string> + <string>saveDocumentAs:</string> + <string>saveDocumentTo:</string> + </object> + <object class="NSArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBActionInfo"> + <string key="name">printDocument:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">revertDocumentToSaved:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">runPageLayout:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">saveDocument:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">saveDocumentAs:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">saveDocumentTo:</string> + <string key="candidateClassName">id</string> + </object> + </object> + </object> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">./Classes/NSDocument.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> <string key="className">NSDocumentController</string> <object class="NSMutableDictionary" key="actions"> <string key="NS.key.0">_openRecentDocument:</string> diff --git a/Tools/MiniBrowser/mac/WK1BrowserWindowController.m b/Tools/MiniBrowser/mac/WK1BrowserWindowController.m index 273adb518..4b2428a32 100644 --- a/Tools/MiniBrowser/mac/WK1BrowserWindowController.m +++ b/Tools/MiniBrowser/mac/WK1BrowserWindowController.m @@ -26,6 +26,7 @@ #import "WK1BrowserWindowController.h" #import <WebKit/WebKit.h> +#import <WebKit/WebViewPrivate.h> #import "AppDelegate.h" @interface WK1BrowserWindowController () @@ -48,6 +49,9 @@ - (void)dealloc { + [_webView setFrameLoadDelegate:nil]; + [_webView setUIDelegate:nil]; + [_webView setResourceLoadDelegate:nil]; [_webView release]; [super dealloc]; @@ -105,11 +109,6 @@ [_webView goForward:sender]; } -- (BOOL)isPaginated -{ - return NO; -} - - (BOOL)validateMenuItem:(NSMenuItem *)menuItem { SEL action = [menuItem action]; @@ -129,6 +128,8 @@ [menuItem setState:_zoomTextOnly ? NSOnState : NSOffState]; else if ([menuItem action] == @selector(togglePaginationMode:)) [menuItem setState:[self isPaginated] ? NSOnState : NSOffState]; + else if ([menuItem action] == @selector(toggleTransparentWindow:)) + [menuItem setState:[[self window] isOpaque] ? NSOffState : NSOnState]; return YES; } @@ -216,8 +217,36 @@ _zoomTextOnly = !_zoomTextOnly; } +- (BOOL)isPaginated +{ + return [_webView _paginationMode] != WebPaginationModeUnpaginated; +} + - (IBAction)togglePaginationMode:(id)sender { + if ([self isPaginated]) { + [_webView _setPaginationMode:WebPaginationModeUnpaginated]; + } else { + [_webView _setPaginationMode:WebPaginationModeRightToLeft]; + [_webView _setPageLength:_webView.bounds.size.width / 2]; + [_webView _setGapBetweenPages:10]; + } +} + +- (IBAction)toggleTransparentWindow:(id)sender +{ + BOOL isTransparent = ![[self window] isOpaque]; + isTransparent = !isTransparent; + + [[self window] setOpaque:!isTransparent]; + [[self window] setHasShadow:!isTransparent]; + + if (isTransparent) + [_webView setBackgroundColor:[NSColor clearColor]]; + else + [_webView setBackgroundColor:[NSColor whiteColor]]; + + [[self window] display]; } - (IBAction)find:(id)sender @@ -250,4 +279,16 @@ [[self window] setTitle:[title stringByAppendingString:@" [WK1]"]]; } +- (void)webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame +{ + NSAlert *alert = [[NSAlert alloc] init]; + [alert addButtonWithTitle:@"OK"]; + + alert.messageText = [NSString stringWithFormat:@"JavaScript alert dialog from %@.", frame.dataSource.request.URL.absoluteString]; + alert.informativeText = message; + + [alert runModal]; + [alert release]; +} + @end diff --git a/Tools/MiniBrowser/mac/WK2BrowserWindowController.m b/Tools/MiniBrowser/mac/WK2BrowserWindowController.m index 1731eb650..bb40dbf70 100644 --- a/Tools/MiniBrowser/mac/WK2BrowserWindowController.m +++ b/Tools/MiniBrowser/mac/WK2BrowserWindowController.m @@ -118,6 +118,8 @@ [menuItem setState:_zoomTextOnly ? NSOnState : NSOffState]; else if ([menuItem action] == @selector(togglePaginationMode:)) [menuItem setState:[self isPaginated] ? NSOnState : NSOffState]; + else if ([menuItem action] == @selector(toggleTransparentWindow:)) + [menuItem setState:[[self window] isOpaque] ? NSOffState : NSOnState]; return YES; } @@ -266,9 +268,25 @@ } } +- (IBAction)toggleTransparentWindow:(id)sender +{ + BOOL isTransparent = _webView.drawsTransparentBackground; + isTransparent = !isTransparent; + + [[self window] setOpaque:!isTransparent]; + [[self window] setHasShadow:!isTransparent]; + + _webView.drawsTransparentBackground = isTransparent; + + [[self window] display]; +} + - (IBAction)dumpSourceToConsole:(id)sender { WKPageGetSourceForFrame_b(_webView.pageRef, WKPageGetMainFrame(_webView.pageRef), ^(WKStringRef result, WKErrorRef error) { + if (!result) + return; + CFStringRef cfResult = WKStringCopyCFString(0, result); LOG(@"Main frame source\n \"%@\"", (NSString *)cfResult); CFRelease(cfResult); @@ -638,10 +656,13 @@ static void runOpenPanel(WKPageRef page, WKFrameRef frame, WKOpenPanelParameters 0, // didNewFirstVisuallyNonEmptyLayout 0, // willGoToBackForwardListItem 0, // interactionOccurredWhileProcessUnresponsive - 0, // pluginDidFail + 0, // pluginDidFail_deprecatedForUseWithV1 0, // didReceiveIntentForFrame 0, // registerIntentServiceForFrame 0, // didLayout + 0, // pluginLoadPolicy_deprecatedForUseWithV2 + 0, // pluginDidFail + 0, // pluginLoadPolicy }; WKPageSetPageLoaderClient(_webView.pageRef, &loadClient); @@ -700,9 +721,10 @@ static void runOpenPanel(WKPageRef page, WKFrameRef frame, WKOpenPanelParameters createNewPage, mouseDidMoveOverElement, 0, // decidePolicyForNotificationPermissionRequest - 0, // unavailablePluginButtonClicked + 0, // unavailablePluginButtonClicked_deprecatedForUseWithV1 0, // showColorPicker 0, // hideColorPicker + 0, // unavailablePluginButtonClicked }; WKPageSetPageUIClient(_webView.pageRef, &uiClient); } diff --git a/Tools/MiniBrowser/qt/BrowserWindow.cpp b/Tools/MiniBrowser/qt/BrowserWindow.cpp index d9de51974..8472d5cfd 100644 --- a/Tools/MiniBrowser/qt/BrowserWindow.cpp +++ b/Tools/MiniBrowser/qt/BrowserWindow.cpp @@ -104,6 +104,11 @@ void BrowserWindow::focusAddressBar() QMetaObject::invokeMethod(rootObject(), "focusAddressBar", Qt::DirectConnection); } +void BrowserWindow::toggleFind() +{ + QMetaObject::invokeMethod(rootObject(), "toggleFind", Qt::DirectConnection); +} + BrowserWindow* BrowserWindow::newWindow(const QString& url) { BrowserWindow* window = new BrowserWindow(m_windowOptions); @@ -113,14 +118,22 @@ BrowserWindow* BrowserWindow::newWindow(const QString& url) void BrowserWindow::updateVisualMockTouchPoints(const QList<QTouchEvent::TouchPoint>& touchPoints) { + if (touchPoints.isEmpty()) { + // Hide all touch indicator items. + foreach (QQuickItem* item, m_activeMockComponents.values()) + item->setProperty("pressed", false); + + return; + } + foreach (const QTouchEvent::TouchPoint& touchPoint, touchPoints) { - QString mockTouchPointIdentifier = QString("mockTouchPoint%1").arg(touchPoint.id()); - QQuickItem* mockTouchPointItem = rootObject()->findChild<QQuickItem*>(mockTouchPointIdentifier, Qt::FindDirectChildrenOnly); + QQuickItem* mockTouchPointItem = m_activeMockComponents.value(touchPoint.id()); if (!mockTouchPointItem) { QQmlComponent touchMockPointComponent(engine(), QUrl("qrc:///qml/MockTouchPoint.qml")); mockTouchPointItem = qobject_cast<QQuickItem*>(touchMockPointComponent.create()); - mockTouchPointItem->setObjectName(mockTouchPointIdentifier); + Q_ASSERT(mockTouchPointItem); + m_activeMockComponents.insert(touchPoint.id(), mockTouchPointItem); mockTouchPointItem->setProperty("pointId", QVariant(touchPoint.id())); mockTouchPointItem->setParent(rootObject()); mockTouchPointItem->setParentItem(rootObject()); diff --git a/Tools/MiniBrowser/qt/BrowserWindow.h b/Tools/MiniBrowser/qt/BrowserWindow.h index 0f30e2c99..2ecfc1453 100644 --- a/Tools/MiniBrowser/qt/BrowserWindow.h +++ b/Tools/MiniBrowser/qt/BrowserWindow.h @@ -45,6 +45,7 @@ public: void load(const QString& url); void reload(); void focusAddressBar(); + void toggleFind(); QQuickWebView* webView() const; QQuickWebViewExperimental* webViewExperimental() const; @@ -67,6 +68,7 @@ private: virtual void wheelEvent(QWheelEvent*); WindowOptions* m_windowOptions; + QHash<int, QQuickItem*> m_activeMockComponents; QVector<qreal> m_zoomLevels; unsigned m_currentZoomLevel; }; diff --git a/Tools/MiniBrowser/qt/MiniBrowser.qrc b/Tools/MiniBrowser/qt/MiniBrowser.qrc index e21eef341..3fa6208a0 100644 --- a/Tools/MiniBrowser/qt/MiniBrowser.qrc +++ b/Tools/MiniBrowser/qt/MiniBrowser.qrc @@ -4,6 +4,7 @@ <file>icons/checkbox_unchecked.png</file> <file>icons/contents_width.png</file> <file>icons/favicon.png</file> + <file>icons/find.png</file> <file>icons/folder.png</file> <file>icons/info.png</file> <file>icons/next.png</file> diff --git a/Tools/MiniBrowser/qt/MiniBrowserApplication.cpp b/Tools/MiniBrowser/qt/MiniBrowserApplication.cpp index d54cd669b..5915e7734 100644 --- a/Tools/MiniBrowser/qt/MiniBrowserApplication.cpp +++ b/Tools/MiniBrowser/qt/MiniBrowserApplication.cpp @@ -1,6 +1,7 @@ /* * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) * Copyright (C) 2010 University of Szeged + * Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). * * All rights reserved. * @@ -83,7 +84,7 @@ MiniBrowserApplication::MiniBrowserApplication(int& argc, char** argv) , m_windowOptions(this) , m_holdingControl(false) { - setOrganizationName("Nokia"); + setOrganizationName("QtProject"); setApplicationName("QtMiniBrowser"); setApplicationVersion("0.1"); @@ -110,6 +111,8 @@ bool MiniBrowserApplication::notify(QObject* target, QEvent* event) if (!browserWindow) return QGuiApplication::notify(target, event); + m_holdingControl = QGuiApplication::keyboardModifiers().testFlag(Qt::ControlModifier); + // In QML events are propagated through parents. But since the WebView // may consume key events, a shortcut might never reach the top QQuickItem. // Therefore we are checking here for shortcuts. @@ -123,19 +126,25 @@ bool MiniBrowserApplication::notify(QObject* target, QEvent* event) browserWindow->focusAddressBar(); return true; } + if ((keyEvent->key() == Qt::Key_F && keyEvent->modifiers() == Qt::ControlModifier) || keyEvent->key() == Qt::Key_F3) { + browserWindow->toggleFind(); + return true; + } } if (event->type() == QEvent::KeyRelease && static_cast<QKeyEvent*>(event)->key() == Qt::Key_Control) { foreach (int id, m_heldTouchPoints) - if (m_touchPoints.contains(id)) + if (m_touchPoints.contains(id) && !QGuiApplication::mouseButtons().testFlag(Qt::MouseButton(id))) { m_touchPoints[id].setState(Qt::TouchPointReleased); - m_heldTouchPoints.clear(); - sendTouchEvent(browserWindow, QEvent::TouchEnd, static_cast<QKeyEvent*>(event)->timestamp()); + m_heldTouchPoints.remove(id); + } else + m_touchPoints[id].setState(Qt::TouchPointStationary); + + sendTouchEvent(browserWindow, m_heldTouchPoints.isEmpty() ? QEvent::TouchEnd : QEvent::TouchUpdate, static_cast<QKeyEvent*>(event)->timestamp()); } if (isMouseEvent(event)) { const QMouseEvent* const mouseEvent = static_cast<QMouseEvent*>(event); - m_holdingControl = mouseEvent->modifiers().testFlag(Qt::ControlModifier); QTouchEvent::TouchPoint touchPoint; touchPoint.setPressure(1); diff --git a/Tools/MiniBrowser/qt/UrlLoader.cpp b/Tools/MiniBrowser/qt/UrlLoader.cpp index 8b330fdb9..a0658e983 100644 --- a/Tools/MiniBrowser/qt/UrlLoader.cpp +++ b/Tools/MiniBrowser/qt/UrlLoader.cpp @@ -28,6 +28,7 @@ #include "UrlLoader.h" #include "private/qquickwebview_p.h" +#include "private/qwebloadrequest_p.h" #include <QDebug> #include <QFile> @@ -42,14 +43,14 @@ UrlLoader::UrlLoader(BrowserWindow* browserWindow, const QString& inputFileName, m_checkIfFinishedTimer.setSingleShot(true); connect(&m_checkIfFinishedTimer, SIGNAL(timeout()), this, SLOT(checkIfFinished())); // loadStarted and loadFinished on QWebPage is emitted for each frame/sub-frame - connect(m_browserWindow->webView(), SIGNAL(loadStarted()), this, SLOT(frameLoadStarted())); - connect(m_browserWindow->webView(), SIGNAL(loadSucceeded()), this, SLOT(frameLoadFinished())); - connect(m_browserWindow->webView(), SIGNAL(loadFailed(QDesktopWebView::ErrorType, int, const QUrl&)), this, SLOT(frameLoadFinished())); + connect(m_browserWindow->webView(), SIGNAL(loadingChanged(QWebLoadRequest*)), this, SLOT(loadingChanged(QWebLoadRequest*))); + connect(this, SIGNAL(loadStarted()), this, SLOT(frameLoadStarted())); + connect(this, SIGNAL(loadFinished()), this, SLOT(frameLoadFinished())); if (timeoutSeconds) { m_timeoutTimer.setInterval(timeoutSeconds * 1000); m_timeoutTimer.setSingleShot(true); - connect(m_browserWindow->webView(), SIGNAL(loadStarted()), &m_timeoutTimer, SLOT(start())); + connect(this, SIGNAL(loadStarted()), &m_timeoutTimer, SLOT(start())); connect(&m_timeoutTimer, SIGNAL(timeout()), this, SLOT(loadNext())); } if (extraTimeSeconds) { @@ -129,3 +130,18 @@ bool UrlLoader::getUrl(QString& qstr) qstr = m_urls[m_index++]; return true; } + +void UrlLoader::loadingChanged(QWebLoadRequest* loadRequest) +{ + switch (loadRequest->status()) { + case QQuickWebView::LoadStartedStatus: + emit loadStarted(); + break; + case QQuickWebView::LoadStoppedStatus: + case QQuickWebView::LoadSucceededStatus: + case QQuickWebView::LoadFailedStatus: + default: + emit loadFinished(); + break; + } +} diff --git a/Tools/MiniBrowser/qt/UrlLoader.h b/Tools/MiniBrowser/qt/UrlLoader.h index 8ac58dfdd..a64548a02 100644 --- a/Tools/MiniBrowser/qt/UrlLoader.h +++ b/Tools/MiniBrowser/qt/UrlLoader.h @@ -35,6 +35,8 @@ #include <QTimer> #include <QVector> +class QWebLoadRequest; + class UrlLoader : public QObject { Q_OBJECT @@ -48,9 +50,12 @@ private Q_SLOTS: void checkIfFinished(); void frameLoadStarted(); void frameLoadFinished(); + void loadingChanged(QWebLoadRequest*); Q_SIGNALS: void pageLoadFinished(); + void loadStarted(); + void loadFinished(); private: void loadUrlList(const QString& inputFileName); diff --git a/Tools/MiniBrowser/qt/icons/find.png b/Tools/MiniBrowser/qt/icons/find.png Binary files differnew file mode 100644 index 000000000..b76afa398 --- /dev/null +++ b/Tools/MiniBrowser/qt/icons/find.png diff --git a/Tools/MiniBrowser/qt/qml/BrowserWindow.qml b/Tools/MiniBrowser/qt/qml/BrowserWindow.qml index e52b2f44b..b4b5bc092 100644 --- a/Tools/MiniBrowser/qt/qml/BrowserWindow.qml +++ b/Tools/MiniBrowser/qt/qml/BrowserWindow.qml @@ -1,6 +1,7 @@ /* * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) * Copyright (C) 2010 University of Szeged + * Copyright (c) 2012 Hewlett-Packard Development Company, L.P. * * All rights reserved. * @@ -54,7 +55,163 @@ Rectangle { addressLine.forceActiveFocus() addressLine.selectAll() } + function toggleFind() { + findBar.toggle() + } + Rectangle { + id: findBar + z: webView.z + 1 + y: navigationBar.y + anchors { + left: parent.left + right: parent.right + } + height: navigationBar.height + color: "#efefef" + visible: y > navigationBar.y + + Behavior on y {NumberAnimation {duration: 250}} + + function toggle() { + if (y == navigationBar.y) { + findTextInput.forceActiveFocus() + y += height + } else { + webView.forceActiveFocus() + y = navigationBar.y + find("",0); + } + } + function find(str, options) { + var findOptions = options | WebViewExperimental.FindHighlightAllOccurrences + findOptions |= WebViewExperimental.FindWrapsAroundDocument + webView.experimental.findText(str, findOptions) + } + + Connections { + target: webView.experimental + onTextFound: { + failedOverlay.visible = matchCount == 0 + } + } + Item { + anchors.fill: parent + Rectangle { + id: inputArea + height: 26 + anchors { + left: parent.left + right: prevButton.left + margins: 6 + verticalCenter: parent.verticalCenter + } + color: "white" + border.width: 1 + border.color: "#bfbfbf" + radius: 3 + Rectangle { + id: failedOverlay + anchors.fill: parent + color: "red" + opacity: 0.5 + radius: 6 + visible: false + } + TextInput { + id: findTextInput + clip: true + selectByMouse: true + horizontalAlignment: TextInput.AlignLeft + anchors.fill: parent + anchors.margins: 3 + font { + pointSize: 11 + family: "Sans" + } + text: "" + readOnly: !findBar.visible + function doFind() { + if (!findBar.visible) { + return; + } + if (findTextInput.text == "") { + failedOverlay.visible = false + } + findBar.find(findTextInput.text) + } + onTextChanged: { + doFind() + } + Keys.onReturnPressed:{ + doFind() + } + } + } + Rectangle { + id: prevButton + height: inputArea.height + width: height + anchors.right: nextButton.left + anchors.verticalCenter: parent.verticalCenter + color: "#efefef" + radius: 6 + + Image { + anchors.centerIn: parent + source: "../icons/previous.png" + } + + Rectangle { + anchors.fill: parent + color: parent.color + radius: parent.radius + opacity: 0.8 + visible: !parent.enabled + } + + MouseArea { + anchors.fill: parent + onPressed: { if (parent.enabled) parent.color = "#cfcfcf" } + onReleased: { parent.color = "#efefef" } + onClicked: { + findBar.find(findTextInput.text, WebViewExperimental.FindBackward) + } + } + } + Rectangle { + id: nextButton + height: inputArea.height + width: height + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + color: "#efefef" + radius: 6 + + Image { + anchors.centerIn: parent + source: "../icons/next.png" + } + + Rectangle { + anchors.fill: parent + color: parent.color + radius: parent.radius + opacity: 0.8 + visible: !parent.enabled + } + + MouseArea { + anchors.fill: parent + onPressed: { if (parent.enabled) parent.color = "#cfcfcf" } + onReleased: { parent.color = "#efefef" } + onClicked: { + findBar.find(findTextInput.text, 0) + } + } + } + } + } Rectangle { id: navigationBar color: "#efefef" @@ -213,6 +370,27 @@ Rectangle { } Rectangle { + id: findButton + height: parent.height + width: height + color: "#efefef" + radius: 6 + + Image { + anchors.centerIn: parent + opacity: 0.6 + source: "../icons/find.png" + } + + MouseArea { + anchors.fill: parent + onClicked: { + findBar.toggle() + } + } + } + + Rectangle { id: touchEventsButton height: parent.height width: height @@ -335,7 +513,7 @@ Rectangle { clip: false anchors { - top: navigationBar.bottom + top: findBar.bottom left: parent.left right: parent.right bottom: parent.bottom diff --git a/Tools/MiniBrowser/win/BrowserView.cpp b/Tools/MiniBrowser/win/BrowserView.cpp deleted file mode 100644 index 0a6858e35..000000000 --- a/Tools/MiniBrowser/win/BrowserView.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (C) 2010 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "StdAfx.h" -#include "BrowserView.h" - -#include "BrowserWindow.h" -#include <WebKit2/WKContextPrivate.h> -#include <WebKit2/WKURLCF.h> - -static const unsigned short HIGH_BIT_MASK_SHORT = 0x8000; - -BrowserView::BrowserView() - : m_webView(0) -{ -} - -// UI Client Callbacks - -static WKPageRef createNewPage(WKPageRef page, WKURLRequestRef request, WKDictionaryRef features, WKEventModifiers modifiers, WKEventMouseButton mouseButton, const void* clientInfo) -{ - BrowserWindow* browserWindow = BrowserWindow::create(); - browserWindow->createWindow(0, 0, 800, 600); - - return WKViewGetPage(browserWindow->view().webView()); -} - -static void showPage(WKPageRef page, const void *clientInfo) -{ - static_cast<BrowserWindow*>(const_cast<void*>(clientInfo))->showWindow(); -} - -static void closePage(WKPageRef page, const void *clientInfo) -{ -} - -static void runJavaScriptAlert(WKPageRef page, WKStringRef alertText, WKFrameRef frame, const void* clientInfo) -{ -} - -static bool runJavaScriptConfirm(WKPageRef page, WKStringRef message, WKFrameRef frame, const void* clientInfo) -{ - return false; -} - -static WKStringRef runJavaScriptPrompt(WKPageRef page, WKStringRef message, WKStringRef defaultValue, WKFrameRef frame, const void* clientInfo) -{ - return 0; -} - -static void setStatusText(WKPageRef page, WKStringRef text, const void* clientInfo) -{ -} - -static void mouseDidMoveOverElement(WKPageRef page, WKHitTestResultRef hitTestResult, WKEventModifiers modifiers, WKTypeRef userData, const void *clientInfo) -{ -} - -void BrowserView::create(RECT webViewRect, BrowserWindow* parentWindow) -{ - assert(!m_webView); - - static WKContextRef context = WKContextCreate(); - - m_webView = WKViewCreate(webViewRect, context, 0, parentWindow->window()); - - WKPageUIClient uiClient = { - kWKPageUIClientCurrentVersion, - parentWindow, /* clientInfo */ - 0, /* createNewPage_deprecatedForUseWithV0 */ - showPage, - closePage, - 0, /* takeFocus */ - 0, /* focus */ - 0, /* unfocus */ - runJavaScriptAlert, - runJavaScriptConfirm, - runJavaScriptPrompt, - setStatusText, - 0, /* mouseDidMoveOverElement_deprecatedForUseWithV0 */ - 0, /* missingPluginButtonClicked */ - 0, /* didNotHandleKeyEvent */ - 0, /* didNotHandleWheelEvent */ - 0, /* toolbarsAreVisible */ - 0, /* setToolbarsAreVisible */ - 0, /* menuBarIsVisible */ - 0, /* setMenuBarIsVisible */ - 0, /* statusBarIsVisible */ - 0, /* setStatusBarIsVisible */ - 0, /* isResizable */ - 0, /* setIsResizable */ - 0, /* getWindowFrame */ - 0, /* setWindowFrame */ - 0, /* runBeforeUnloadConfirmPanel */ - 0, /* didDraw */ - 0, /* pageDidScroll */ - 0, /* exceededDatabaseQuota */ - 0, /* runOpenPanel */ - 0, /* decidePolicyForGeolocationPermissionRequest */ - 0, /* headerHeight */ - 0, /* footerHeight */ - 0, /* drawHeader */ - 0, /* drawFooter */ - 0, /* printFrame */ - 0, /* runModal */ - 0, /* didCompleteRubberBandForMainFrame */ - 0, /* saveDataToFileInDownloadsFolder */ - 0, /* shouldInterruptJavaScript */ - createNewPage, - mouseDidMoveOverElement, - 0, /* decidePolicyForNotificationPermissionRequest */ - 0, /* unavailablePluginButtonClicked */ - 0, /* showColorPicker */ - 0, /* hideColorPicker */ - }; - - WKPageSetPageUIClient(WKViewGetPage(m_webView), &uiClient); - - WKViewSetIsInWindow(m_webView, true); -} - -void BrowserView::setFrame(RECT rect) -{ - HWND webViewWindow = WKViewGetWindow(m_webView); - ::SetWindowPos(webViewWindow, 0, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS); -} - -void BrowserView::goToURL(const std::wstring& urlString) -{ - CFStringRef string = CFStringCreateWithCharacters(0, (const UniChar*)urlString.data(), urlString.size()); - CFStringRef escapedString = CFURLCreateStringByAddingPercentEscapes(0, string, 0, 0, kCFStringEncodingUTF8); - CFRelease(string); - CFURLRef cfURL = CFURLCreateWithString(0, escapedString, 0); - CFRelease(escapedString); - - WKURLRef url = WKURLCreateWithCFURL(cfURL); - CFRelease(cfURL); - - WKPageRef page = WKViewGetPage(m_webView); - WKPageLoadURL(page, url); - WKRelease(url); -} diff --git a/Tools/MiniBrowser/win/BrowserView.h b/Tools/MiniBrowser/win/BrowserView.h deleted file mode 100644 index e170a7df7..000000000 --- a/Tools/MiniBrowser/win/BrowserView.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2010 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BrowserView_h -#define BrowserView_h - -#include <WebKit2/WebKit2_C.h> -#include <string> - -class BrowserWindow; - -class BrowserView { -public: - BrowserView(); - - void goToURL(const std::wstring& url); - - void create(RECT, BrowserWindow* parentWindow); - void setFrame(RECT); - - WKViewRef webView() const { return m_webView; } - -private: - WKViewRef m_webView; -}; - -#endif // BrowserView_h diff --git a/Tools/MiniBrowser/win/BrowserWindow.cpp b/Tools/MiniBrowser/win/BrowserWindow.cpp deleted file mode 100644 index b791d5bb5..000000000 --- a/Tools/MiniBrowser/win/BrowserWindow.cpp +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Copyright (C) 2010 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "StdAfx.h" -#include "BrowserWindow.h" -#include "MiniBrowser.h" -#include "Resource.h" - -#include <assert.h> -#include <commctrl.h> -#include <shlwapi.h> -#include <vector> -#include <wininet.h> - -using namespace std; - -BrowserWindow::BrowserWindow() - : m_window(0) - , m_rebarWindow(0) - , m_comboBoxWindow(0) -{ -} - -LRESULT CALLBACK BrowserWindow::BrowserWindowWndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam) -{ - LONG_PTR longPtr = ::GetWindowLongPtr(window, 0); - - if (BrowserWindow* browserView = reinterpret_cast<BrowserWindow*>(longPtr)) - return browserView->wndProc(window, message, wParam, lParam); - - if (message == WM_CREATE) { - LPCREATESTRUCT createStruct = reinterpret_cast<LPCREATESTRUCT>(lParam); - BrowserWindow* browserWindow = static_cast<BrowserWindow*>(createStruct->lpCreateParams); - browserWindow->m_window = window; - - ::SetWindowLongPtr(window, 0, (LONG_PTR)browserWindow); - - browserWindow->onCreate(createStruct); - return 0; - } - - return ::DefWindowProc(window, message, wParam, lParam); -} - -LRESULT BrowserWindow::wndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam) -{ - LRESULT lResult = 0; - bool handled = true; - - switch (message) { - case WM_ERASEBKGND: - lResult = 1; - break; - - case WM_COMMAND: - lResult = onCommand(LOWORD(wParam), handled); - break; - - case WM_SIZE: - onSize(LOWORD(lParam), HIWORD(lParam)); - break; - - case WM_DESTROY: - onDestroy(); - break; - - case WM_NCDESTROY: - onNCDestroy(); - break; - - default: - handled = false; - } - - if (!handled) - lResult = ::DefWindowProc(window, message, wParam, lParam); - - return lResult; -} - -void BrowserWindow::createWindow(int x, int y, int width, int height) -{ - assert(!m_window); - - // Register the class. - WNDCLASSEX windowClass = { 0 }; - windowClass.cbSize = sizeof(windowClass); - windowClass.style = 0; - windowClass.lpfnWndProc = BrowserWindowWndProc; - windowClass.cbClsExtra = 0; - windowClass.cbWndExtra = sizeof(this); - windowClass.hInstance = MiniBrowser::shared().instance(); - windowClass.hIcon = 0; - windowClass.hCursor = ::LoadCursor(0, IDC_ARROW); - windowClass.hbrBackground = (HBRUSH)::GetStockObject(WHITE_BRUSH); - windowClass.lpszMenuName = MAKEINTRESOURCE(IDR_MAINFRAME); - windowClass.lpszClassName = L"MiniBrowser"; - windowClass.hIconSm = 0; - - ::RegisterClassEx(&windowClass); - - ::CreateWindowW(L"MiniBrowser", L"MiniBrowser", WS_OVERLAPPEDWINDOW, x, y, width, height, 0, 0, MiniBrowser::shared().instance(), this); -} - -void BrowserWindow::showWindow() -{ - assert(m_window); - - ::ShowWindow(m_window, SW_SHOWNORMAL); -} - -void BrowserWindow::goToURL(const std::wstring& url) -{ - m_browserView.goToURL(url); -} - -void BrowserWindow::onCreate(LPCREATESTRUCT createStruct) -{ - // Register our window. - MiniBrowser::shared().registerWindow(this); - - // Create the rebar control. - m_rebarWindow = ::CreateWindowEx(0, REBARCLASSNAME, 0, WS_VISIBLE | WS_BORDER | WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | CCS_NODIVIDER | CCS_NOPARENTALIGN | RBS_VARHEIGHT | RBS_BANDBORDERS, - 0, 0, 0, 0, m_window, 0, createStruct->hInstance, 0); - REBARINFO rebarInfo = { 0 }; - rebarInfo.cbSize = sizeof(rebarInfo); - rebarInfo.fMask = 0; - ::SendMessage(m_rebarWindow, RB_SETBARINFO, 0, (LPARAM)&rebarInfo); - - // Create the combo box control. - m_comboBoxWindow = ::CreateWindowEx(0, L"combobox", 0, WS_VISIBLE | WS_CHILD | WS_TABSTOP | WS_VSCROLL | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | CBS_AUTOHSCROLL | CBS_DROPDOWN, - 0, 0, 0, 0, m_rebarWindow, 0, createStruct->hInstance, 0); - SendMessage(m_comboBoxWindow, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), MAKELPARAM(TRUE, 0)); - - REBARBANDINFO bandInfo; - bandInfo.cbSize = sizeof(bandInfo); - bandInfo.fMask = RBBIM_STYLE | RBBIM_TEXT | RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE; - bandInfo.fStyle = RBBS_CHILDEDGE | RBBS_GRIPPERALWAYS; - bandInfo.lpText = L"Address"; - bandInfo.hwndChild = m_comboBoxWindow; - - RECT comboBoxRect; - ::GetWindowRect(m_comboBoxWindow, &comboBoxRect); - bandInfo.cx = 100; - bandInfo.cxMinChild = comboBoxRect.right - comboBoxRect.left; - bandInfo.cyMinChild = comboBoxRect.bottom - comboBoxRect.top; - - // Add the band to the rebar. - int result = ::SendMessage(m_rebarWindow, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&bandInfo); - - // Create the browser view. - RECT webViewRect = { 0, 0, 0, 0}; - m_browserView.create(webViewRect, this); -} - -void BrowserWindow::onDestroy() -{ - MiniBrowser::shared().unregisterWindow(this); - - // FIXME: Should we close the browser view here? -} - -void BrowserWindow::onNCDestroy() -{ - delete this; -} - -void BrowserWindow::onSize(int width, int height) -{ - RECT rebarRect; - ::GetClientRect(m_rebarWindow, &rebarRect); - - // Resize the rebar. - ::MoveWindow(m_rebarWindow, 0, 0, width, rebarRect.bottom - rebarRect.top, true); - - RECT webViewRect; - webViewRect.top = rebarRect.bottom; - webViewRect.left = 0; - webViewRect.right = width; - webViewRect.bottom = height; - m_browserView.setFrame(webViewRect); -} - -LRESULT BrowserWindow::onCommand(int commandID, bool& handled) -{ - switch (commandID) { - case ID_FILE_NEW_WINDOW: - MiniBrowser::shared().createNewWindow(); - break; - case ID_FILE_CLOSE: - ::PostMessage(m_window, WM_CLOSE, 0, 0); - break; - case ID_DEBUG_SHOW_WEB_VIEW: { - HMENU menu = ::GetMenu(m_window); - bool shouldHide = ::GetMenuState(menu, ID_DEBUG_SHOW_WEB_VIEW, MF_BYCOMMAND) & MF_CHECKED; - - ::CheckMenuItem(menu, ID_DEBUG_SHOW_WEB_VIEW, MF_BYCOMMAND | (shouldHide ? MF_UNCHECKED : MF_CHECKED)); - - // Show or hide the web view. - HWND webViewWindow = WKViewGetWindow(m_browserView.webView()); - ::ShowWindow(webViewWindow, shouldHide ? SW_HIDE : SW_SHOW); - break; - } - default: - handled = false; - } - - return 0; -} - -bool BrowserWindow::handleMessage(const MSG* message) -{ - if (message->hwnd != m_comboBoxWindow && !::IsChild(m_comboBoxWindow, message->hwnd)) - return false; - - // Look for a WM_KEYDOWN message. - if (message->message != WM_KEYDOWN) - return false; - - // Look for the VK_RETURN key. - if (message->wParam != VK_RETURN) - return false; - - std::vector<WCHAR> buffer; - int textLength = ::GetWindowTextLength(m_comboBoxWindow); - - buffer.resize(textLength + 1); - ::GetWindowText(m_comboBoxWindow, &buffer[0], buffer.size()); - - std::wstring url(&buffer[0], buffer.size() - 1); - - if (url.find(L":") == std::wstring::npos) - url = L"http://" + url; - - m_browserView.goToURL(url); - - // We handled this message. - return true; -} diff --git a/Tools/MiniBrowser/win/BrowserWindow.h b/Tools/MiniBrowser/win/BrowserWindow.h deleted file mode 100644 index 1cf73503f..000000000 --- a/Tools/MiniBrowser/win/BrowserWindow.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2010 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BrowserWindow_h -#define BrowserWindow_h - -#include "BrowserView.h" -#include <string> - -class BrowserWindow { -public: - static BrowserWindow* create() - { - return new BrowserWindow; - } - - void createWindow(int x, int y, int width, int height); - void showWindow(); - - void goToURL(const std::wstring& url); - - bool handleMessage(const MSG*); - - const BrowserView& view() const { return m_browserView; } - HWND window() const { return m_window; } - -private: - BrowserWindow(); - - static LRESULT CALLBACK BrowserWindowWndProc(HWND, UINT, WPARAM, LPARAM); - - // Message handlers. - LRESULT wndProc(HWND, UINT, WPARAM, LPARAM); - void onCreate(LPCREATESTRUCT); - void onDestroy(); - void onNCDestroy(); - - void onSize(int width, int height); - LRESULT onCommand(int commandID, bool& handled); - - HWND m_window; - - HWND m_rebarWindow; - HWND m_comboBoxWindow; - BrowserView m_browserView; -}; - -#endif // BrowserWindow_h diff --git a/Tools/MiniBrowser/win/MiniBrowser.cpp b/Tools/MiniBrowser/win/MiniBrowser.cpp deleted file mode 100644 index 7e3d4888a..000000000 --- a/Tools/MiniBrowser/win/MiniBrowser.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) 2010 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "stdafx.h" - -#include "BrowserWindow.h" -#include "MiniBrowser.h" -#include <assert.h> - -MiniBrowser::MiniBrowser() - : m_instance(0) -{ -} - -MiniBrowser& MiniBrowser::shared() -{ - static MiniBrowser miniBrowser; - - return miniBrowser; -} - -void MiniBrowser::initialize(HINSTANCE instance) -{ - assert(!m_instance); - - m_instance = instance; -} - -void MiniBrowser::createNewWindow() -{ - static const wchar_t* kDefaultURLString = L"http://webkit.org/"; - - BrowserWindow* browserWindow = BrowserWindow::create(); - browserWindow->createWindow(0, 0, 800, 600); - browserWindow->showWindow(); - browserWindow->goToURL(kDefaultURLString); -} - -void MiniBrowser::registerWindow(BrowserWindow* window) -{ - m_browserWindows.insert(window); -} - -void MiniBrowser::unregisterWindow(BrowserWindow* window) -{ - m_browserWindows.erase(window); - - if (m_browserWindows.empty()) - ::PostQuitMessage(0); -} - -bool MiniBrowser::handleMessage(const MSG* message) -{ - for (std::set<BrowserWindow*>::const_iterator it = m_browserWindows.begin(), end = m_browserWindows.end(); it != end; ++it) { - BrowserWindow* browserWindow = *it; - - if (browserWindow->handleMessage(message)) - return true; - } - - return false; -} diff --git a/Tools/MiniBrowser/win/MiniBrowser.h b/Tools/MiniBrowser/win/MiniBrowser.h deleted file mode 100644 index c7b51778c..000000000 --- a/Tools/MiniBrowser/win/MiniBrowser.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2010 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef MiniBrowser_h -#define MiniBrowser_h - -#include <set> - -class BrowserWindow; - -class MiniBrowser { -public: - static MiniBrowser& shared(); - - void initialize(HINSTANCE); - - void createNewWindow(); - - void registerWindow(BrowserWindow*); - void unregisterWindow(BrowserWindow*); - - bool handleMessage(const MSG*); - - HINSTANCE instance() const { return m_instance; } - -private: - MiniBrowser(); - - HINSTANCE m_instance; - std::set<BrowserWindow*> m_browserWindows; -}; - -#endif // MiniBrowser_h diff --git a/Tools/MiniBrowser/win/MiniBrowser.rc b/Tools/MiniBrowser/win/MiniBrowser.rc deleted file mode 100644 index 0ff88b089..000000000 --- a/Tools/MiniBrowser/win/MiniBrowser.rc +++ /dev/null @@ -1,79 +0,0 @@ -// Microsoft Visual C++ generated resource script.
-//
-#include "resource.h"
-#include "winresrc.h" -
-/////////////////////////////////////////////////////////////////////////////
-// English (U.S.) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-#ifdef _WIN32
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-#pragma code_page(1252)
-#endif //_WIN32
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Menu
-//
-
-IDR_MAINFRAME MENU
-BEGIN
- POPUP "&File"
- BEGIN
- MENUITEM "&New Window\tCtrl+N", ID_FILE_NEW_WINDOW
- MENUITEM SEPARATOR
- MENUITEM "&Close", ID_FILE_CLOSE
- END
- POPUP "&Debug"
- BEGIN
- MENUITEM "&Show WebView", ID_DEBUG_SHOW_WEB_VIEW, CHECKED
- END
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Accelerator
-//
-
-IDR_MAINFRAME_ACCEL ACCELERATORS
-BEGIN
- "N", ID_FILE_NEW_WINDOW, VIRTKEY, CONTROL, NOINVERT
-END
-
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE
-BEGIN
- "resource.\0"
-END
-
-
-3 TEXTINCLUDE
-BEGIN
- "\r\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-#endif // English (U.S.) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
-
diff --git a/Tools/MiniBrowser/win/main.cpp b/Tools/MiniBrowser/win/main.cpp deleted file mode 100644 index ba09c9445..000000000 --- a/Tools/MiniBrowser/win/main.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2010 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "stdafx.h" - -#include "BrowserWindow.h" -#include "MiniBrowser.h" -#include <string> - -static bool shouldTranslateMessage(const MSG& msg) -{ - // Only these four messages are actually translated by ::TranslateMessage or ::TranslateAccelerator. - // It's useless (though harmless) to call those functions for other messages, so we always allow other messages to be translated. - if (msg.message != WM_KEYDOWN && msg.message != WM_SYSKEYDOWN && msg.message != WM_KEYUP && msg.message != WM_SYSKEYUP) - return true; - - wchar_t className[256]; - if (!::GetClassNameW(msg.hwnd, className, ARRAYSIZE(className))) - return true; - - // Don't call TranslateMessage() on key events destined for a WebKit2 view, WebKit will do this if it doesn't handle the message. - // It would be nice to use some API here instead of hard-coding the window class name. - return wcscmp(className, L"WebKit2WebViewWindowClass"); -} - -BOOL WINAPI DllMain(HINSTANCE dllInstance, DWORD reason, LPVOID) -{ - if (reason == DLL_PROCESS_ATTACH) - MiniBrowser::shared().initialize(dllInstance); - - return TRUE; -} - -extern "C" __declspec(dllexport) int WINAPI dllLauncherEntryPoint(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpstrCmdLine, int nCmdShow) -{ - // Create and show our initial window. - MiniBrowser::shared().createNewWindow(); - - MSG message; - while (BOOL result = ::GetMessage(&message, 0, 0, 0)) { - if (result == -1) - break; - - if (shouldTranslateMessage(message)) - ::TranslateMessage(&message); - - if (!MiniBrowser::shared().handleMessage(&message)) - ::DispatchMessage(&message); - } - - return 0; -} diff --git a/Tools/MiniBrowser/win/resource.h b/Tools/MiniBrowser/win/resource.h deleted file mode 100644 index b12b906f4..000000000 --- a/Tools/MiniBrowser/win/resource.h +++ /dev/null @@ -1,23 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by MiniBrowser.rc -// - -#define ID_FILE_NEW_WINDOW 32770 -#define ID_FILE_OPEN 32771 -#define ID_FILE_CLOSE 32772 -#define ID_DEBUG_SHOW_WEB_VIEW 32773 - -#define IDR_MAINFRAME 128 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NO_MFC 1 -#define _APS_NEXT_RESOURCE_VALUE 132 -#define _APS_NEXT_COMMAND_VALUE 32775 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 110 -#endif -#endif diff --git a/Tools/MiniBrowser/win/stdafx.cpp b/Tools/MiniBrowser/win/stdafx.cpp deleted file mode 100644 index c664e32be..000000000 --- a/Tools/MiniBrowser/win/stdafx.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2010 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -// stdafx.cpp : source file that includes just the standard includes -// MiniBrowser.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/Tools/MiniBrowser/win/stdafx.h b/Tools/MiniBrowser/win/stdafx.h deleted file mode 100644 index 2f531bb3f..000000000 --- a/Tools/MiniBrowser/win/stdafx.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2010 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#define STRICT -#define WIN32_LEAN_AND_MEAN - -#include <tchar.h> -#include <windows.h> - - - |