diff --git a/.gitignore b/.gitignore index 221b769edf2..0b64efbbda0 100644 --- a/.gitignore +++ b/.gitignore @@ -55,22 +55,6 @@ Sessionx.vim /unminified-js -# Hololens artifacts -support/hololens/x64/ -support/hololens/ARM/ -support/hololens/ARM64/ -support/hololens/ServoApp/x64/ -support/hololens/ServoApp/ARM/ -support/hololens/ServoApp/ARM64/ -support/hololens/ServoApp/Generated Files/ -support/hololens/ServoApp/BundleArtifacts/ -support/hololens/ServoApp/support/ -support/hololens/ServoApp/Debug/ -support/hololens/ServoApp/Release/ -support/hololens/packages/ -support/hololens/AppPackages/ -support/hololens/.vs/ - # Layout debugger trace files layout_trace* diff --git a/Cargo.lock b/Cargo.lock index 4cb6c042dc8..9ae7f56e829 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4251,26 +4251,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "openxr" -version = "0.12.2" -source = "git+https://github.com/servo/openxrs.git?branch=secondary-views-2#87c0186c88f6e2bc22dbbe0bf5c02afc60fc37ef" -dependencies = [ - "libc", - "libloading 0.6.1", - "openxr-sys", - "winapi", -] - -[[package]] -name = "openxr-sys" -version = "0.8.2" -source = "git+https://github.com/servo/openxrs.git?branch=secondary-views-2#87c0186c88f6e2bc22dbbe0bf5c02afc60fc37ef" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "orbclient" version = "0.3.42" @@ -7085,15 +7065,12 @@ dependencies = [ "gl_generator 0.13.1", "gvr-sys", "log", - "openxr", "serde", "sparkle", "surfman", "surfman-chains", "time 0.1.45", "webxr-api", - "winapi", - "wio", ] [[package]] diff --git a/README.md b/README.md index a90e136ddeb..ae363bb5703 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ manually, try the [manual build setup][manual-build]. - Download and run [`rustup-init.exe`](https://win.rustup.rs/) then follow the onscreen instructions. - Install [chocolatey](https://chocolatey.org/) - Run `mach bootstrap` - - *This will install CMake, Git, Ninja, NuGet, Python and the Visual Studio 2019 Build Tools + - *This will install CMake, Git, Ninja, Python and the Visual Studio 2019 Build Tools via choco in an Administrator console. It can take quite a while.* - *If you already have Visual Studio 2019 installed, this may not install all necessary components. Please follow the Visual Studio 2019 installation instructions in the [manual setup][manual-build].* diff --git a/Xargo.toml b/Xargo.toml deleted file mode 100644 index 894a551a277..00000000000 --- a/Xargo.toml +++ /dev/null @@ -1,7 +0,0 @@ -[target.x86_64-uwp-windows-msvc.dependencies] -std = { features = ["panic-unwind"] } - -# https://github.com/rust-lang/rust/issues/65313 -[target.aarch64-uwp-windows-msvc.dependencies] -std = { features = ["panic-unwind"] } - diff --git a/components/config/Cargo.toml b/components/config/Cargo.toml index f909dc08d13..b33e2c608ac 100644 --- a/components/config/Cargo.toml +++ b/components/config/Cargo.toml @@ -6,9 +6,6 @@ license = "MPL-2.0" edition = "2018" publish = false -[features] -uwp = [] - [lib] name = "servo_config" path = "lib.rs" diff --git a/components/config/basedir.rs b/components/config/basedir.rs index c587d82f769..fbae2a7edca 100644 --- a/components/config/basedir.rs +++ b/components/config/basedir.rs @@ -35,14 +35,9 @@ pub fn default_config_dir() -> Option { Some(config_dir) } -#[cfg(all(target_os = "windows", not(feature = "uwp")))] +#[cfg(all(target_os = "windows"))] pub fn default_config_dir() -> Option { let mut config_dir = ::dirs_next::config_dir().unwrap(); config_dir.push("Servo"); Some(config_dir) } - -#[cfg(all(target_os = "windows", feature = "uwp"))] -pub fn default_config_dir() -> Option { - None -} diff --git a/components/config/tests/prefs.rs b/components/config/tests/prefs.rs index fd42bf7e047..63d4475769b 100644 --- a/components/config/tests/prefs.rs +++ b/components/config/tests/prefs.rs @@ -244,7 +244,7 @@ fn test_set_all_error_on_unknown_field() -> Result<(), Box> { Ok(()) } -#[cfg(not(any(target_os = "android", feature = "uwp")))] +#[cfg(not(target_os = "android"))] #[test] fn test_default_config_dir_create_read_write() { let json_str = "{\ diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml index d4095bf6f19..839b7be0169 100644 --- a/components/script/Cargo.toml +++ b/components/script/Cargo.toml @@ -21,7 +21,6 @@ default = ["unrooted_must_root_lint"] webgl_backtrace = ["canvas_traits/webgl_backtrace"] js_backtrace = [] refcell_backtrace = ["accountable-refcell"] -uwp = ["js/uwp"] xr-profile = ["webxr-api/profile"] [build-dependencies] diff --git a/components/servo/Cargo.toml b/components/servo/Cargo.toml index 2d3d46cc8c0..4e4b8da58d3 100644 --- a/components/servo/Cargo.toml +++ b/components/servo/Cargo.toml @@ -26,7 +26,6 @@ no-wgl = ["canvas/no-wgl"] no_static_freetype = ["webrender/no_static_freetype"] profilemozjs = ["script/profilemozjs"] refcell_backtrace = ["script/refcell_backtrace"] -uwp = ["servo_config/uwp", "script/uwp"] webdriver = ["webdriver_server"] webgl_backtrace = [ "script/webgl_backtrace", diff --git a/components/servo/lib.rs b/components/servo/lib.rs index 434ebe5b33e..25d89187f0c 100644 --- a/components/servo/lib.rs +++ b/components/servo/lib.rs @@ -141,49 +141,14 @@ mod media_platform { use super::ServoMedia; use servo_media_gstreamer::GStreamerBackend; - #[cfg(feature = "uwp")] - fn set_gstreamer_log_handler() { - use gstreamer::{debug_add_log_function, DebugLevel}; - - debug_add_log_function(|cat, level, file, function, line, _, message| { - let message = format!( - "{:?} {:?} {:?}:{:?}:{:?} {:?}", - cat.get_name(), - level, - file, - line, - function, - message - ); - match level { - DebugLevel::Debug => debug!("{}", message), - DebugLevel::Error => error!("{}", message), - DebugLevel::Warning => warn!("{}", message), - DebugLevel::Fixme | DebugLevel::Info => info!("{}", message), - DebugLevel::Memdump | DebugLevel::Count | DebugLevel::Trace => { - trace!("{}", message) - }, - _ => (), - } - }); - } - #[cfg(any(windows, target_os = "macos"))] pub fn init() { - // UWP apps have the working directory set appropriately. Win32 apps - // do not and need some assistance finding the DLLs. - let plugin_dir = if cfg!(feature = "uwp") { - std::path::PathBuf::new() - } else { - let mut plugin_dir = std::env::current_exe().unwrap(); - plugin_dir.pop(); + let mut plugin_dir = std::env::current_exe().unwrap(); + plugin_dir.pop(); - if cfg!(target_os = "macos") { - plugin_dir.push("lib"); - } - - plugin_dir - }; + if cfg!(target_os = "macos") { + plugin_dir.push("lib"); + } let backend = match GStreamerBackend::init_with_plugins( plugin_dir, @@ -196,10 +161,6 @@ mod media_platform { }, }; ServoMedia::init_with_backend(backend); - #[cfg(feature = "uwp")] - { - set_gstreamer_log_handler(); - } } #[cfg(not(any(windows, target_os = "macos")))] diff --git a/ports/libsimpleservo/api/Cargo.toml b/ports/libsimpleservo/api/Cargo.toml index 7ab22fb261a..149284e6a6e 100644 --- a/ports/libsimpleservo/api/Cargo.toml +++ b/ports/libsimpleservo/api/Cargo.toml @@ -48,7 +48,6 @@ no_static_freetype = ["libservo/no_static_freetype"] no-wgl = ["libservo/no-wgl"] profilemozjs = ["libservo/profilemozjs"] refcell_backtrace = ["libservo/refcell_backtrace"] -uwp = ["libservo/uwp", "webxr/openxr-api"] webdriver = ["libservo/webdriver"] webgl_backtrace = ["libservo/webgl_backtrace"] xr-profile = ["libservo/xr-profile"] diff --git a/ports/libsimpleservo/api/build.rs b/ports/libsimpleservo/api/build.rs index 16337042c3c..23401cc2ac4 100644 --- a/ports/libsimpleservo/api/build.rs +++ b/ports/libsimpleservo/api/build.rs @@ -49,22 +49,6 @@ fn main() { let mut pkg_prefs = PathBuf::from(env!("CARGO_MANIFEST_DIR")); pkg_prefs.push("../../../resources/package-prefs.json"); let pkg_prefs: Value = serde_json::from_reader(File::open(&pkg_prefs).unwrap()).unwrap(); - if target.contains("uwp") { - // Assuming Hololens build - let to_merge = pkg_prefs - .as_object() - .unwrap() - .get("hololens") - .unwrap() - .as_object() - .unwrap(); - for (key, value) in to_merge.iter() { - prefs - .as_object_mut() - .unwrap() - .insert(key.clone(), value.clone()); - } - } let file = File::create(&dest.join("prefs.json")).unwrap(); serde_json::to_writer(file, &prefs).unwrap(); } diff --git a/ports/libsimpleservo/api/src/lib.rs b/ports/libsimpleservo/api/src/lib.rs index 7f4950d099b..f3706aaba23 100644 --- a/ports/libsimpleservo/api/src/lib.rs +++ b/ports/libsimpleservo/api/src/lib.rs @@ -267,12 +267,9 @@ pub fn init( // Initialize surfman let connection = Connection::new().or(Err("Failed to create connection"))?; - let adapter = match create_adapter() { - Some(adapter) => adapter, - None => connection - .create_adapter() - .or(Err("Failed to create adapter"))?, - }; + let adapter = connection + .create_adapter() + .or(Err("Failed to create adapter"))?; let surface_type = match init_opts.surfman_integration { SurfmanIntegration::Widget(native_widget) => { let native_widget = unsafe { @@ -824,79 +821,6 @@ struct ServoWindowCallbacks { } impl EmbedderMethods for ServoEmbedderCallbacks { - #[cfg(feature = "uwp")] - fn register_webxr( - &mut self, - registry: &mut webxr::MainThreadRegistry, - embedder_proxy: EmbedderProxy, - ) { - use ipc_channel::ipc::{self, IpcReceiver}; - use webxr::openxr; - debug!("EmbedderMethods::register_xr"); - assert!( - self.xr_discovery.is_none(), - "UWP builds should not be initialized with a WebXR Discovery object" - ); - - #[derive(Clone)] - struct ContextMenuCallback(EmbedderProxy); - - struct ContextMenuFuture(IpcReceiver); - - impl openxr::ContextMenuProvider for ContextMenuCallback { - fn open_context_menu(&self) -> Box { - let (sender, receiver) = ipc::channel().unwrap(); - self.0.send(( - None, - EmbedderMsg::ShowContextMenu( - sender, - Some("Would you like to exit the XR session?".into()), - vec!["Exit".into()], - ), - )); - - Box::new(ContextMenuFuture(receiver)) - } - fn clone_object(&self) -> Box { - Box::new(self.clone()) - } - } - - impl openxr::ContextMenuFuture for ContextMenuFuture { - fn poll(&self) -> openxr::ContextMenuResult { - if let Ok(result) = self.0.try_recv() { - if let ContextMenuResult::Selected(0) = result { - openxr::ContextMenuResult::ExitSession - } else { - openxr::ContextMenuResult::Dismissed - } - } else { - openxr::ContextMenuResult::Pending - } - } - } - - if openxr::create_instance(false, false).is_ok() { - let discovery = - openxr::OpenXrDiscovery::new(Box::new(ContextMenuCallback(embedder_proxy))); - registry.register(discovery); - } else { - let msg = - "Cannot initialize OpenXR - please ensure runtime is installed and enabled in \ - the OpenXR developer portal app.\n\nImmersive mode will not function until \ - this error is fixed."; - let (sender, _receiver) = ipc::channel().unwrap(); - embedder_proxy.send(( - None, - EmbedderMsg::Prompt( - PromptDefinition::Alert(msg.to_owned(), sender), - PromptOrigin::Trusted, - ), - )); - } - } - - #[cfg(not(feature = "uwp"))] fn register_webxr( &mut self, registry: &mut webxr::MainThreadRegistry, @@ -1002,13 +926,3 @@ impl ResourceReaderMethods for ResourceReaderInstance { vec![] } } - -#[cfg(feature = "uwp")] -fn create_adapter() -> Option { - webxr::openxr::create_surfman_adapter() -} - -#[cfg(not(feature = "uwp"))] -fn create_adapter() -> Option { - None -} diff --git a/ports/libsimpleservo/capi/Cargo.toml b/ports/libsimpleservo/capi/Cargo.toml index 31fda31e4e8..6cb2d98e7ef 100644 --- a/ports/libsimpleservo/capi/Cargo.toml +++ b/ports/libsimpleservo/capi/Cargo.toml @@ -43,7 +43,6 @@ native-bluetooth = ["simpleservo/native-bluetooth"] no-wgl = ["simpleservo/no-wgl"] profilemozjs = ["simpleservo/profilemozjs"] refcell_backtrace = ["simpleservo/refcell_backtrace"] -uwp = ["simpleservo/uwp"] webdriver = ["simpleservo/webdriver"] webgl_backtrace = ["simpleservo/webgl_backtrace"] xr-profile = ["simpleservo/xr-profile"] diff --git a/python/requirements.txt b/python/requirements.txt index eadb8a3e549..ee7c5dcf411 100644 --- a/python/requirements.txt +++ b/python/requirements.txt @@ -36,9 +36,6 @@ six == 1.15 # For sending build notifications. notify-py == 0.3.42 -# For formatting C++ files. -clang-format ~= 16.0.0 - # A few more requirements for tidy. voluptuous == 0.12.1 PyYAML == 5.4 diff --git a/python/servo/build_commands.py b/python/servo/build_commands.py index 48563efee94..126509a8e8b 100644 --- a/python/servo/build_commands.py +++ b/python/servo/build_commands.py @@ -143,48 +143,6 @@ class MachCommands(CommandBase): env['PKG_CONFIG_ALLOW_CROSS'] = "1" - if self.is_uwp_build: - # Ensure libstd is ready for the new UWP target. - check_call(["rustup", "component", "add", "rust-src"]) - - # Don't try and build a desktop port. - libsimpleservo = True - - arches = { - "aarch64": { - "angle": "arm64", - "gst": "ARM64", - "gst_root": "arm64", - }, - "x86_64": { - "angle": "x64", - "gst": "X86_64", - "gst_root": "x64", - }, - } - arch = arches.get(target_triple.split('-')[0]) - if not arch: - print("Unsupported UWP target.") - sys.exit(1) - - # Ensure that the NuGet ANGLE package containing libEGL is accessible - # to the Rust linker. - servo.util.append_paths_to_env(env, "LIB", angle_root(target_triple, env)) - - # Don't want to mix non-UWP libraries with vendored UWP libraries. - if "gstreamer" in env['LIB']: - print("Found existing GStreamer library path in LIB. Please remove it.") - sys.exit(1) - - # Override any existing GStreamer installation with the vendored libraries. - env["GSTREAMER_1_0_ROOT_" + arch['gst']] = path.join( - servo.platform.windows.get_dependency_dir("gstreamer-uwp"), arch['gst_root'] - ) - env["PKG_CONFIG_PATH"] = path.join( - servo.platform.windows.get_dependency_dir("gstreamer-uwp"), - arch['gst_root'], "lib", "pkgconfig" - ) - if 'windows' in host: process = subprocess.Popen('("%s" %s > nul) && "python" -c "import os; print(repr(os.environ))"' % (os.path.join(vs_dirs['vcdir'], "Auxiliary", "Build", "vcvarsall.bat"), "x64"), @@ -448,17 +406,15 @@ class MachCommands(CommandBase): for lib in libs: print("WARNING: could not find " + lib) - # UWP build has its own ANGLE library that it packages. - if not self.is_uwp_build: - print("Packaging EGL DLLs") - egl_libs = ["libEGL.dll", "libGLESv2.dll"] - if not package_generated_shared_libraries(egl_libs, build_path, servo_exe_dir): - status = 1 + print("Packaging EGL DLLs") + egl_libs = ["libEGL.dll", "libGLESv2.dll"] + if not package_generated_shared_libraries(egl_libs, build_path, servo_exe_dir): + status = 1 # copy needed gstreamer DLLs in to servo.exe dir if has_media_stack: print("Packaging gstreamer DLLs") - if not package_gstreamer_dlls(env, servo_exe_dir, target_triple, self.is_uwp_build): + if not package_gstreamer_dlls(env, servo_exe_dir, target_triple): status = 1 # UWP app packaging already bundles all required DLLs for us. @@ -507,7 +463,7 @@ class MachCommands(CommandBase): return status @Command('clean', - description='Clean the target/ and python/_virtualenv[version]/ and support/hololens/ directories', + description='Clean the target/ and python/_virtualenv[version]/ directories', category='build') @CommandArgument('--manifest-path', default=None, @@ -526,43 +482,12 @@ class MachCommands(CommandBase): print('Removing virtualenv directory: %s' % virtualenv_path) shutil.rmtree(virtualenv_path) - self.clean_uwp() - opts = ["--manifest-path", manifest_path or path.join(self.context.topdir, "Cargo.toml")] if verbose: opts += ["-v"] opts += params return check_call(["cargo", "clean"] + opts, env=self.build_env(), verbose=verbose) - @Command('clean-uwp', - description='Clean the support/hololens/ directory', - category='build') - def clean_uwp(self): - uwp_artifacts = [ - "support/hololens/x64/", - "support/hololens/ARM/", - "support/hololens/ARM64/", - "support/hololens/ServoApp/x64/", - "support/hololens/ServoApp/ARM/", - "support/hololens/ServoApp/ARM64/", - "support/hololens/ServoApp/Generated Files/", - "support/hololens/ServoApp/BundleArtifacts/", - "support/hololens/ServoApp/support/", - "support/hololens/ServoApp/Debug/", - "support/hololens/ServoApp/Release/", - "support/hololens/packages/", - "support/hololens/AppPackages/", - "support/hololens/ServoApp/ServoApp.vcxproj.user", - ] - - for uwp_artifact in uwp_artifacts: - artifact = path.join(self.get_top_dir(), uwp_artifact) - if path.exists(artifact): - if path.isdir(artifact): - shutil.rmtree(artifact) - else: - os.remove(artifact) - def notify(self, title: str, message: str): """Generate desktop notification when build is complete and the elapsed build time was longer than 30 seconds. @@ -612,36 +537,6 @@ class MachCommands(CommandBase): notification.send(block=False) -def angle_root(target, nuget_env): - arch = { - "aarch64": "arm64", - "x86_64": "x64", - } - angle_arch = arch[target.split('-')[0]] - - package_name = "ANGLE.WindowsStore.Servo" - - import xml.etree.ElementTree as ET - tree = ET.parse(os.path.join('support', 'hololens', 'ServoApp', 'packages.config')) - root = tree.getroot() - for package in root.iter('package'): - if package.get('id') == package_name: - package_version = package.get('version') - break - else: - raise Exception("Couldn't locate ANGLE package") - - angle_default_path = path.join(os.getcwd(), "support", "hololens", "packages", - package_name + "." + package_version, "bin", "UAP", angle_arch) - - # Nuget executable command - nuget_app = path.join(os.getcwd(), "support", "hololens", "ServoApp.sln") - if not os.path.exists(angle_default_path): - check_call(['nuget.exe', 'restore', nuget_app], env=nuget_env) - - return angle_default_path - - def otool(s): o = subprocess.Popen(['/usr/bin/otool', '-L', s], stdout=subprocess.PIPE) for line in map(lambda s: s.decode('ascii'), o.stdout): @@ -757,7 +652,7 @@ def package_gstreamer_dylibs(cross_compilation_target, servo_bin): return True -def package_gstreamer_dlls(env, servo_exe_dir, target, uwp): +def package_gstreamer_dlls(env, servo_exe_dir, target): gst_root = servo.platform.get().gstreamer_root(cross_compilation_target=target) if not gst_root: print("Could not find GStreamer installation directory.") @@ -775,48 +670,31 @@ def package_gstreamer_dlls(env, servo_exe_dir, target, uwp): "glib-2.0-0.dll", "gmodule-2.0-0.dll", "gobject-2.0-0.dll", + "graphene-1.0-0.dll", "intl-8.dll", + "libcrypto-1_1-x64.dll", + "libgmp-10.dll", + "libgnutls-30.dll", + "libhogweed-4.dll", + "libjpeg-8.dll", + "libnettle-6.dll.", + "libogg-0.dll", + "libopus-0.dll", + "libpng16-16.dll", + "libssl-1_1-x64.dll", + "libtasn1-6.dll", + "libtheora-0.dll", + "libtheoradec-1.dll", + "libtheoraenc-1.dll", + "libusrsctp-1.dll", + "libvorbis-0.dll", + "libvorbisenc-2.dll", + "libwinpthread-1.dll", + "nice-10.dll", "orc-0.4-0.dll", "swresample-3.dll", "z-1.dll", - ] - - gst_dlls += windows_dlls(uwp) - - if uwp: - # These come from a more recent version of ffmpeg and - # aren't present in the official GStreamer 1.16 release. - gst_dlls += [ - "avresample-4.dll", - "postproc-55.dll", - "swscale-5.dll", - "x264-157.dll", - ] - else: - # These are built with MinGW and are not yet compatible - # with UWP's restrictions. - gst_dlls += [ - "graphene-1.0-0.dll", - "libcrypto-1_1-x64.dll", - "libgmp-10.dll", - "libgnutls-30.dll", - "libhogweed-4.dll", - "libjpeg-8.dll", - "libnettle-6.dll.", - "libogg-0.dll", - "libopus-0.dll", - "libpng16-16.dll", - "libssl-1_1-x64.dll", - "libtasn1-6.dll", - "libtheora-0.dll", - "libtheoradec-1.dll", - "libtheoraenc-1.dll", - "libusrsctp-1.dll", - "libvorbis-0.dll", - "libvorbisenc-2.dll", - "libwinpthread-1.dll", - "nice-10.dll", - ] + ] + windows_dlls() missing = [] for gst_lib in gst_dlls: @@ -831,7 +709,7 @@ def package_gstreamer_dlls(env, servo_exe_dir, target, uwp): return False # Only copy a subset of the available plugins. - gst_dlls = windows_plugins(uwp) + gst_dlls = windows_plugins() gst_plugin_path_root = os.environ.get("GSTREAMER_PACKAGE_PLUGIN_PATH") or gst_root gst_plugin_path = path.join(gst_plugin_path_root, "lib", "gstreamer-1.0") @@ -868,7 +746,7 @@ def package_msvc_dlls(servo_exe_dir, target, vcinstalldir, vs_version): "msvcp140.dll", "vcruntime140.dll", ] - if target_arch != "aarch64" and "uwp" not in target and vs_version in ("14.0", "15.0", "16.0"): + if target_arch != "aarch64" and vs_version in ("14.0", "15.0", "16.0"): msvc_deps += ["api-ms-win-crt-runtime-l1-1-0.dll"] # Check if it's Visual C++ Build Tools or Visual Studio 2015 diff --git a/python/servo/command_base.py b/python/servo/command_base.py index 58f8197d6a2..508afb35593 100644 --- a/python/servo/command_base.py +++ b/python/servo/command_base.py @@ -205,7 +205,6 @@ class CommandBase(object): self.context = context self.features = [] self.cross_compile_target = None - self.is_uwp_build = False self.is_android_build = False def get_env_bool(var, default): @@ -510,11 +509,6 @@ class CommandBase(object): extra_path += [path.join(self.msvc_package_dir("llvm"), "bin")] env.setdefault("CC", "clang-cl.exe") env.setdefault("CXX", "clang-cl.exe") - if self.is_uwp_build: - env.setdefault("TARGET_CFLAGS", "") - env.setdefault("TARGET_CXXFLAGS", "") - env["TARGET_CFLAGS"] += " -DWINAPI_FAMILY=WINAPI_FAMILY_APP" - env["TARGET_CXXFLAGS"] += " -DWINAPI_FAMILY=WINAPI_FAMILY_APP" arch = effective_target.split('-')[0] vcpkg_arch = { @@ -523,8 +517,6 @@ class CommandBase(object): "aarch64": "arm64-windows", } target_arch = vcpkg_arch[arch] - if self.is_uwp_build: - target_arch += "-uwp" openssl_base_dir = path.join(self.msvc_package_dir("openssl"), target_arch) # Link openssl @@ -674,11 +666,6 @@ class CommandBase(object): help='Build for Android. If --target is not specified, this ' 'will choose a default target architecture.', ), - CommandArgument( - '--uwp', - group="Cross Compilation", - action='store_true', - help='Build for HoloLens (x64)'), CommandArgument('--win-arm64', action='store_true', help="Use arm64 Windows target"), CommandArgumentGroup('Feature Selection'), CommandArgument( @@ -725,9 +712,7 @@ class CommandBase(object): ] def configuration_decorator(self, *args, **kwargs): - self.configure_cross_compilation( - kwargs['target'], kwargs['android'], - kwargs['uwp'], kwargs['win_arm64']) + self.configure_cross_compilation(kwargs['target'], kwargs['android'], kwargs['win_arm64']) self.features = kwargs.get("features", None) or [] self.configure_media_stack(kwargs['media_stack']) @@ -743,15 +728,8 @@ class CommandBase(object): self, cross_compile_target: Optional[str], android: Optional[str], - uwp: Optional[str], win_arm64: Optional[str]): # Force the UWP-enabled target if the convenience UWP flags are passed. - if uwp and not cross_compile_target: - if win_arm64: - cross_compile_target = 'aarch64-uwp-windows-msvc' - else: - cross_compile_target = 'x86_64-uwp-windows-msvc' - if android is None: android = self.config["build"]["android"] if android: @@ -765,7 +743,6 @@ class CommandBase(object): self.setup_configuration_for_android_target(cross_compile_target) self.cross_compile_target = cross_compile_target - self.is_uwp_build = uwp or (cross_compile_target and "uwp" in cross_compile_target) self.is_android_build = (cross_compile_target and "android" in cross_compile_target) if self.cross_compile_target: @@ -783,7 +760,6 @@ class CommandBase(object): not self.cross_compile_target or ("armv7" in self.cross_compile_target and self.is_android_build) or "x86_64" in self.cross_compile_target - or "uwp" in self.cross_compile_target ): media_stack = "gstreamer" else: @@ -825,10 +801,6 @@ class CommandBase(object): features.append("native-bluetooth") - if self.is_uwp_build: - features.append("no-wgl") - features.append("uwp") - if with_layout_2020 or (self.config["build"]["layout-2020"] and not with_layout_2013): features.append("layout-2020") elif "layout-2020" not in features: @@ -847,8 +819,6 @@ class CommandBase(object): if with_debug_assertions or self.config["build"]["debug-assertions"]: env['RUSTFLAGS'] = env.get('RUSTFLAGS', "") + " -C debug_assertions" - if self.is_uwp_build: - cargo_args += ["-Z", "build-std"] return self.call_rustup_run(["cargo", command] + args + cargo_args, env=env, verbose=verbose) def android_support_dir(self): @@ -934,7 +904,6 @@ class CommandBase(object): check_call(["rustup", "component", "add", "--toolchain", toolchain, component]) needs_toolchain_install = self.cross_compile_target \ - and not self.is_uwp_build \ and self.cross_compile_target.encode("utf-8") not in check_output( ["rustup", "target", "list", "--installed", "--toolchain", toolchain] ) diff --git a/python/servo/gstreamer.py b/python/servo/gstreamer.py index 42da291e9f0..637ad3700ca 100644 --- a/python/servo/gstreamer.py +++ b/python/servo/gstreamer.py @@ -78,18 +78,12 @@ GSTREAMER_PLUGINS = [ ] -def windows_dlls(uwp): +def windows_dlls(): libs = list(GSTREAMER_DYLIBS) - NON_UWP_DYLIBS = [ - "gstnet", - "gstsctp", - ] - if uwp: - libs = filter(lambda x: x not in NON_UWP_DYLIBS, libs) return [f"{lib}-1.0-0.dll" for lib in libs] -def windows_plugins(uwp): +def windows_plugins(): # FIXME: We should support newer gstreamer versions here that replace # gstvideoconvert and gstvideoscale with gstvideoconvertscale. libs = [ @@ -98,25 +92,6 @@ def windows_plugins(uwp): "gstvideoscale", "gstwasapi" ] - NON_UWP_PLUGINS = [ - "gstnice", - # gst-plugins-base - "gstogg", - "gstopengl", - "gstopus", - "gstrtp", - "gsttheora", - "gstvorbis", - # gst-plugins-good - "gstmatroska", - "gstrtpmanager", - "gstvpx", - # gst-plugins-bad - "gstdtls", - "gstwebrtc", - ] - if uwp: - libs = filter(lambda x: x not in NON_UWP_PLUGINS, libs) return [f"{lib}.dll" for lib in libs] @@ -156,7 +131,7 @@ def write_plugin_list(target): if "apple-" in target: plugins = [os.path.basename(x) for x in macos_plugins()] elif '-windows-' in target: - plugins = windows_plugins('-uwp-' in target) + plugins = windows_plugins() print('''/* This is a generated file. Do not modify. */ pub(crate) static GSTREAMER_PLUGINS: &[&'static str] = &[ diff --git a/python/servo/package_commands.py b/python/servo/package_commands.py index 092b94f7a30..d0e7d84a67a 100644 --- a/python/servo/package_commands.py +++ b/python/servo/package_commands.py @@ -12,7 +12,6 @@ from __future__ import absolute_import, print_function, unicode_literals from datetime import datetime from github import Github -import base64 import hashlib import io import json @@ -22,7 +21,6 @@ import shutil import subprocess import sys import tempfile -import xml from mach.decorators import ( CommandArgument, @@ -85,10 +83,6 @@ PACKAGES = { def packages_for_platform(platform): target_dir = get_target_dir() - if platform == "uwp": - yield r'support\hololens\AppPackages\ServoApp\FirefoxReality.zip' - return - for package in PACKAGES[platform]: yield path.join(target_dir, package) @@ -150,13 +144,8 @@ class PackageCommands(CommandBase): default=None, action='store_true', help='Create a local Maven repository') - @CommandArgument('--uwp', - default=None, - action='append', - help='Create an APPX package') - @CommandArgument('--ms-app-store', default=None, action='store_true') def package(self, release=False, dev=False, android=None, target=None, - flavor=None, maven=False, uwp=None, ms_app_store=False): + flavor=None, maven=False): if android is None: android = self.config["build"]["android"] if target and android: @@ -171,14 +160,10 @@ class PackageCommands(CommandBase): env = self.build_env() binary_path = self.get_binary_path( release, dev, target=target, android=android, - simpleservo=uwp is not None ) dir_to_root = self.get_top_dir() target_dir = path.dirname(binary_path) - if uwp: - vs_info = self.vs_dirs() - build_uwp(uwp, dev, vs_info['msbuild'], ms_app_store) - elif android: + if android: android_target = self.config["android"]["target"] if "aarch64" in android_target: build_type = "Arm64" @@ -698,100 +683,3 @@ class PackageCommands(CommandBase): update_brew(packages[0], timestamp) return 0 - - -def setup_uwp_signing(ms_app_store, publisher): - # App package needs to be signed. If we find a certificate that has been installed - # already, we use it. Otherwise we create and install a temporary certificate. - - if ms_app_store: - return ["/p:AppxPackageSigningEnabled=false"] - - def run_powershell_cmd(cmd): - try: - return ( - subprocess - .check_output(['powershell.exe', '-NoProfile', '-Command', cmd]) - .decode('utf-8') - ) - except subprocess.CalledProcessError: - print("ERROR: PowerShell command failed: ", cmd) - exit(1) - - pfx = None - if 'CODESIGN_CERT' in os.environ: - pfx = os.environ['CODESIGN_CERT'] - - if pfx: - open("servo.pfx", "wb").write(base64.b64decode(pfx)) - run_powershell_cmd('Import-PfxCertificate -FilePath .\\servo.pfx -CertStoreLocation Cert:\\CurrentUser\\My') - os.remove("servo.pfx") - - # Powershell command that lists all certificates for publisher - cmd = '(dir cert: -Recurse | Where-Object {$_.Issuer -eq "' + publisher + '"}).Thumbprint' - certs = list(set(run_powershell_cmd(cmd).splitlines())) - if not certs: - print("No certificate installed for publisher " + publisher) - print("Creating and installing a temporary certificate") - # PowerShell command that creates and install signing certificate for publisher - cmd = '(New-SelfSignedCertificate -Type Custom -Subject ' + publisher + \ - ' -FriendlyName "Allizom Signing Certificate (temporary)"' + \ - ' -KeyUsage DigitalSignature -CertStoreLocation "Cert:\\CurrentUser\\My"' + \ - ' -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.3", "2.5.29.19={text}")).Thumbprint' - thumbprint = run_powershell_cmd(cmd) - elif len(certs) > 1: - print("Warning: multiple signing certificate are installed for " + publisher) - print("Warning: Using first one") - thumbprint = certs[0] - else: - thumbprint = certs[0] - return ["/p:AppxPackageSigningEnabled=true", "/p:PackageCertificateThumbprint=" + thumbprint] - - -def build_uwp(platforms, dev, msbuild_dir, ms_app_store): - if any(map(lambda p: p not in ['x64', 'x86', 'arm64'], platforms)): - raise Exception("Unsupported appx platforms: " + str(platforms)) - if dev and len(platforms) > 1: - raise Exception("Debug package with multiple architectures is unsupported") - - if dev: - Configuration = "Debug" - else: - Configuration = "Release" - - # Parse appxmanifest to find the publisher name and version - manifest_file = path.join(os.getcwd(), 'support', 'hololens', 'ServoApp', 'Package.appxmanifest') - manifest = xml.etree.ElementTree.parse(manifest_file) - namespace = "{http://schemas.microsoft.com/appx/manifest/foundation/windows10}" - identity = manifest.getroot().find(namespace + "Identity") - publisher = identity.attrib["Publisher"] - version = identity.attrib["Version"] - - msbuild = path.join(msbuild_dir, "msbuild.exe") - build_file_template = path.join('support', 'hololens', 'package.msbuild') - with open(build_file_template) as f: - template_contents = f.read() - build_file = tempfile.NamedTemporaryFile(delete=False) - build_file.write( - template_contents - .replace("%%BUILD_PLATFORMS%%", ';'.join(platforms)) - .replace("%%PACKAGE_PLATFORMS%%", '|'.join(platforms)) - .replace("%%CONFIGURATION%%", Configuration) - .replace("%%SOLUTION%%", path.join(os.getcwd(), 'support', 'hololens', 'ServoApp.sln')) - .encode('utf-8') - ) - build_file.close() - # Generate an appxbundle. - msbuild_args = setup_uwp_signing(ms_app_store, publisher) - subprocess.check_call([msbuild, "/m", build_file.name] + msbuild_args) - os.unlink(build_file.name) - - # Don't bother creating an archive that contains unsigned app packages. - if not ms_app_store: - print("Creating ZIP") - out_dir = path.join(os.getcwd(), 'support', 'hololens', 'AppPackages', 'ServoApp') - name = 'ServoApp_%s_%sTest' % (version, 'Debug_' if dev else '') - artifacts_dir = path.join(out_dir, name) - zip_path = path.join(out_dir, "FirefoxReality.zip") - archive_deterministically(artifacts_dir, zip_path, prepend_path='servo/') - print("Packaged Servo into " + zip_path) diff --git a/python/servo/platform/base.py b/python/servo/platform/base.py index 65731ba0364..a1bce7e3bb8 100644 --- a/python/servo/platform/base.py +++ b/python/servo/platform/base.py @@ -25,14 +25,9 @@ class Base: def set_gstreamer_environment_variables_if_necessary( self, env: Dict[str, str], cross_compilation_target: Optional[str], check_installation=True ): - # Environment variables are not needed when cross-compiling on any - # platform other than Windows. UWP doesn't support GStreamer. GStreamer - # for Android is handled elsewhere. - if cross_compilation_target and ( - not self.is_windows - or "uwp" in cross_compilation_target - or "android" in cross_compilation_target - ): + # Environment variables are not needed when cross-compiling on any platform other + # than Windows. GStreamer for Android is handled elsewhere. + if cross_compilation_target and (not self.is_windows or "android" in cross_compilation_target): return # We may not need to update environment variables if GStreamer is installed diff --git a/python/servo/platform/windows.py b/python/servo/platform/windows.py index c687d0abf4e..063170a2555 100644 --- a/python/servo/platform/windows.py +++ b/python/servo/platform/windows.py @@ -22,8 +22,6 @@ DEPENDENCIES = { "llvm": "15.0.5", "moztools": "3.2", "openssl": "111.3.0+1.1.1c-vs2017-2019-09-18", - "gstreamer-uwp": "1.16.0.5", - "openxr-loader-uwp": "1.0", } URL_BASE = "https://gstreamer.freedesktop.org/data/pkg/windows/1.16.0/" diff --git a/python/servo/testing_commands.py b/python/servo/testing_commands.py index dfd0795d1ca..81d84a4a896 100644 --- a/python/servo/testing_commands.py +++ b/python/servo/testing_commands.py @@ -36,10 +36,7 @@ from mach.decorators import ( import servo.util import tidy -from servo.command_base import ( - CommandBase, - call, check_call, check_output, -) +from servo.command_base import CommandBase, call, check_call from servo.util import delete from distutils.dir_util import copy_tree @@ -48,9 +45,6 @@ PROJECT_TOPLEVEL_PATH = os.path.abspath(os.path.join(SCRIPT_PATH, "..", "..")) WEB_PLATFORM_TESTS_PATH = os.path.join("tests", "wpt", "tests") SERVO_TESTS_PATH = os.path.join("tests", "wpt", "mozilla", "tests") -CLANGFMT_CPP_DIRS = ["support/hololens/"] -CLANGFMT_VERSION = "15" - TEST_SUITES = OrderedDict([ ("wpt", {"kwargs": {"release": False}, "paths": [path.abspath(WEB_PLATFORM_TESTS_PATH), @@ -301,14 +295,10 @@ class MachCommands(CommandBase): self.install_rustfmt() rustfmt_failed = self.call_rustup_run(["cargo", "fmt", "--", "--check"]) - print("Checking C++ files for tidiness...") - env = self.build_env() - clangfmt_failed = not run_clang_format(env, ["--dry-run", "--Werror"]) - - if rustfmt_failed or clangfmt_failed: + if rustfmt_failed: print("Run `./mach fmt` to fix the formatting") - return tidy_failed or manifest_dirty or rustfmt_failed or clangfmt_failed + return tidy_failed or manifest_dirty or rustfmt_failed @Command('test-scripts', description='Run tests for all build and support scripts.', @@ -414,12 +404,9 @@ class MachCommands(CommandBase): return wpt.manifestupdate.update(check_clean=False) @Command('fmt', - description='Format the Rust and CPP source files with rustfmt and clang-format', + description='Format the Rust and CPP source files with rustfmt', category='testing') def format_code(self): - env = self.build_env() - run_clang_format(env, ['-i']) - self.install_rustfmt() return self.call_rustup_run(["cargo", "fmt"]) @@ -613,20 +600,6 @@ class MachCommands(CommandBase): [run_file, "|".join(tests), bin_path, base_dir]) -def run_clang_format(env, args): - gitfiles = check_output( - ['git', 'ls-files'] + CLANGFMT_CPP_DIRS, - universal_newlines=True).splitlines() - files = [line for line in gitfiles if line.endswith(".h") or line.endswith(".cpp")] - clang_cmd = "clang-format.exe" if sys.platform == "win32" else "clang-format" - - if not files: - return True - - returncode = call([clang_cmd] + args + files, env=env) - return returncode == 0 - - def create_parser_create(): import argparse p = argparse.ArgumentParser() diff --git a/resources/package-prefs.json b/resources/package-prefs.json index 035f08714ee..d419d7e4586 100644 --- a/resources/package-prefs.json +++ b/resources/package-prefs.json @@ -5,13 +5,6 @@ "linux": {}, "android": {}, "windows": {}, - "hololens": { - "_comment": "settings specific to Hololens/UWP builds", - "devtools.server.enabled": true, - "dom.webxr.enabled": true, - "shell.homepage": "https://servo.org/hl-home/", - "gfx.subpixel-text-antialiasing.enabled": false - }, "vr": { "_comment": "settings specific to VR builds", "dom.webvr.enabled": true, diff --git a/servo-tidy.toml b/servo-tidy.toml index b5cd9468f6c..88c1b553971 100644 --- a/servo-tidy.toml +++ b/servo-tidy.toml @@ -134,7 +134,6 @@ files = [ directories = [ # Upstream "./support/android/apk", - "./support/hololens", "./tests/wpt/harness", "./tests/wpt/tests", "./tests/wpt/mozilla/tests/mozilla/referrer-policy", diff --git a/support/hololens/.gitignore b/support/hololens/.gitignore deleted file mode 100644 index 83e187f2139..00000000000 --- a/support/hololens/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -/Generated Files -ServoApp.vcxproj.user -bin -obj diff --git a/support/hololens/ServoApp.sln b/support/hololens/ServoApp.sln deleted file mode 100644 index 0706a4d316d..00000000000 --- a/support/hololens/ServoApp.sln +++ /dev/null @@ -1,35 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28307.705 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ServoApp", "ServoApp\ServoApp.vcxproj", "{0EAB7D8B-97FD-4C92-8BB2-D5691B3D5ABD}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|ARM64 = Debug|ARM64 - Debug|x64 = Debug|x64 - Release|ARM64 = Release|ARM64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {0EAB7D8B-97FD-4C92-8BB2-D5691B3D5ABD}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {0EAB7D8B-97FD-4C92-8BB2-D5691B3D5ABD}.Debug|ARM64.Build.0 = Debug|ARM64 - {0EAB7D8B-97FD-4C92-8BB2-D5691B3D5ABD}.Debug|ARM64.Deploy.0 = Debug|ARM64 - {0EAB7D8B-97FD-4C92-8BB2-D5691B3D5ABD}.Debug|x64.ActiveCfg = Debug|x64 - {0EAB7D8B-97FD-4C92-8BB2-D5691B3D5ABD}.Debug|x64.Build.0 = Debug|x64 - {0EAB7D8B-97FD-4C92-8BB2-D5691B3D5ABD}.Debug|x64.Deploy.0 = Debug|x64 - {0EAB7D8B-97FD-4C92-8BB2-D5691B3D5ABD}.Release|ARM64.ActiveCfg = Release|ARM64 - {0EAB7D8B-97FD-4C92-8BB2-D5691B3D5ABD}.Release|ARM64.Build.0 = Release|ARM64 - {0EAB7D8B-97FD-4C92-8BB2-D5691B3D5ABD}.Release|ARM64.Deploy.0 = Release|ARM64 - {0EAB7D8B-97FD-4C92-8BB2-D5691B3D5ABD}.Release|x64.ActiveCfg = Release|x64 - {0EAB7D8B-97FD-4C92-8BB2-D5691B3D5ABD}.Release|x64.Build.0 = Release|x64 - {0EAB7D8B-97FD-4C92-8BB2-D5691B3D5ABD}.Release|x64.Deploy.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {E7A46429-FCAF-424D-B65F-A6395E915F23} - EndGlobalSection -EndGlobal diff --git a/support/hololens/ServoApp/App.cpp b/support/hololens/ServoApp/App.cpp deleted file mode 100644 index 721324ae120..00000000000 --- a/support/hololens/ServoApp/App.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -#include "pch.h" -#include "App.h" -#include "BrowserPage.h" - -using namespace winrt::Windows::ApplicationModel; -using namespace winrt::Windows::ApplicationModel::Activation; -using namespace winrt::Windows::Foundation; -using namespace winrt::Windows::UI::Xaml; -using namespace winrt::Windows::UI::Xaml::Controls; -using namespace winrt::Windows::UI::Xaml::Navigation; -using namespace winrt::ServoApp; -using namespace winrt::ServoApp::implementation; - -App::App() { - InitializeComponent(); - Suspending({this, &App::OnSuspending}); - -#if defined _DEBUG && \ - !defined DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION - UnhandledException( - [this](IInspectable const &, UnhandledExceptionEventArgs const &e) { - if (IsDebuggerPresent()) { - auto errorMessage = e.Message(); - __debugbreak(); - } - }); -#endif -} - -void App::createRootFrame( - Frame &rootFrame, bool prelaunchActivated, - winrt::Windows::Foundation::IInspectable const &args) { - auto content = Window::Current().Content(); - if (content) { - rootFrame = content.try_as(); - } - - if (rootFrame == nullptr) { - rootFrame = Frame(); - - rootFrame.NavigationFailed({this, &App::OnNavigationFailed}); - - if (prelaunchActivated == false) { - if (rootFrame.Content() == nullptr) { - rootFrame.Navigate(xaml_typename(), args); - } - Window::Current().Content(rootFrame); - Window::Current().Activate(); - } - } else { - if (prelaunchActivated == false) { - if (rootFrame.Content() == nullptr) { - rootFrame.Navigate(xaml_typename(), args); - } - Window::Current().Activate(); - } - } -} - -void App::OnLaunched(LaunchActivatedEventArgs const &e) { - Frame rootFrame{nullptr}; - this->createRootFrame(rootFrame, e.PrelaunchActivated(), - box_value(e.Arguments())); -} - -void App::OnActivated(IActivatedEventArgs const &args) { - if (args.Kind() == Windows::ApplicationModel::Activation::ActivationKind:: - CommandLineLaunch) { - auto cmdLineArgs{args.as()}; - auto cmdLineStr = cmdLineArgs.Operation().Arguments(); - Frame rootFrame{nullptr}; - this->createRootFrame(rootFrame, false, nullptr); - auto page = rootFrame.Content().try_as(); - page->SetArgs(cmdLineStr); - return; - } - - if (args.Kind() == - Windows::ApplicationModel::Activation::ActivationKind::Protocol) { - auto protocolActivatedEventArgs{args.as< - Windows::ApplicationModel::Activation::ProtocolActivatedEventArgs>()}; - - Frame rootFrame{nullptr}; - - auto content = Window::Current().Content(); - bool isRunning = content != nullptr; - if (!isRunning) { - this->createRootFrame(rootFrame, false, nullptr); - } else { - rootFrame = content.try_as(); - } - auto page = rootFrame.Content().try_as(); - page->LoadFXRURI(protocolActivatedEventArgs.Uri()); - } -} - -void App::OnSuspending(IInspectable const &, SuspendingEventArgs const &) { - // FIXME: Apps can be suspended for various reasons, not just closing them. - // * Figure out how to save state like the current URL so it can be - // restored if necessary. - // * Determine if the user has actually closed the app and shutdown. - /*auto content = Window::Current().Content(); - Frame rootFrame = content.try_as(); - auto page = rootFrame.Content().try_as(); - page->Shutdown();*/ -} - -void App::OnNavigationFailed(IInspectable const &, - NavigationFailedEventArgs const &e) { - throw hresult_error(E_FAIL, hstring(L"Failed to load Page ") + - e.SourcePageType().Name); -} diff --git a/support/hololens/ServoApp/App.h b/support/hololens/ServoApp/App.h deleted file mode 100644 index f0d4c5ca855..00000000000 --- a/support/hololens/ServoApp/App.h +++ /dev/null @@ -1,24 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -#pragma once -#include "App.xaml.g.h" - -namespace winrt::ServoApp::implementation { -using namespace winrt::Windows::Foundation; -using namespace winrt::Windows::UI::Xaml; -using namespace winrt::Windows::ApplicationModel; -using namespace winrt::Windows::ApplicationModel::Activation; - -struct App : AppT { - App(); - - void createRootFrame(Controls::Frame &, bool, IInspectable const &); - void OnLaunched(LaunchActivatedEventArgs const &); - void OnActivated(IActivatedEventArgs const &); - void OnSuspending(IInspectable const &, SuspendingEventArgs const &); - void OnNavigationFailed(IInspectable const &, - Navigation::NavigationFailedEventArgs const &); -}; -} // namespace winrt::ServoApp::implementation diff --git a/support/hololens/ServoApp/App.idl b/support/hololens/ServoApp/App.idl deleted file mode 100644 index f72eff58eb1..00000000000 --- a/support/hololens/ServoApp/App.idl +++ /dev/null @@ -1,3 +0,0 @@ -namespace ServoApp -{ -} diff --git a/support/hololens/ServoApp/App.xaml b/support/hololens/ServoApp/App.xaml deleted file mode 100644 index 333b37f88b7..00000000000 --- a/support/hololens/ServoApp/App.xaml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - diff --git a/support/hololens/ServoApp/Assets/LargeTile.scale-100.png b/support/hololens/ServoApp/Assets/LargeTile.scale-100.png deleted file mode 100644 index a4e2641eec2..00000000000 Binary files a/support/hololens/ServoApp/Assets/LargeTile.scale-100.png and /dev/null differ diff --git a/support/hololens/ServoApp/Assets/LargeTile.scale-200.png b/support/hololens/ServoApp/Assets/LargeTile.scale-200.png deleted file mode 100644 index 07563b4da79..00000000000 Binary files a/support/hololens/ServoApp/Assets/LargeTile.scale-200.png and /dev/null differ diff --git a/support/hololens/ServoApp/Assets/LargeTile.scale-400.png b/support/hololens/ServoApp/Assets/LargeTile.scale-400.png deleted file mode 100644 index 64d79e3bd6a..00000000000 Binary files a/support/hololens/ServoApp/Assets/LargeTile.scale-400.png and /dev/null differ diff --git a/support/hololens/ServoApp/Assets/SmallTile.scale-100.png b/support/hololens/ServoApp/Assets/SmallTile.scale-100.png deleted file mode 100644 index 39be2badd1d..00000000000 Binary files a/support/hololens/ServoApp/Assets/SmallTile.scale-100.png and /dev/null differ diff --git a/support/hololens/ServoApp/Assets/SmallTile.scale-200.png b/support/hololens/ServoApp/Assets/SmallTile.scale-200.png deleted file mode 100644 index da531151c1b..00000000000 Binary files a/support/hololens/ServoApp/Assets/SmallTile.scale-200.png and /dev/null differ diff --git a/support/hololens/ServoApp/Assets/SmallTile.scale-400.png b/support/hololens/ServoApp/Assets/SmallTile.scale-400.png deleted file mode 100644 index 59e25f586b8..00000000000 Binary files a/support/hololens/ServoApp/Assets/SmallTile.scale-400.png and /dev/null differ diff --git a/support/hololens/ServoApp/Assets/SplashScreen.scale-100.png b/support/hololens/ServoApp/Assets/SplashScreen.scale-100.png deleted file mode 100644 index 60411e81c4c..00000000000 Binary files a/support/hololens/ServoApp/Assets/SplashScreen.scale-100.png and /dev/null differ diff --git a/support/hololens/ServoApp/Assets/SplashScreen.scale-200.png b/support/hololens/ServoApp/Assets/SplashScreen.scale-200.png deleted file mode 100644 index 0d49ee32270..00000000000 Binary files a/support/hololens/ServoApp/Assets/SplashScreen.scale-200.png and /dev/null differ diff --git a/support/hololens/ServoApp/Assets/SplashScreen.scale-400.png b/support/hololens/ServoApp/Assets/SplashScreen.scale-400.png deleted file mode 100644 index bda01e2abc1..00000000000 Binary files a/support/hololens/ServoApp/Assets/SplashScreen.scale-400.png and /dev/null differ diff --git a/support/hololens/ServoApp/Assets/Square150x150Logo.scale-100.png b/support/hololens/ServoApp/Assets/Square150x150Logo.scale-100.png deleted file mode 100644 index a04dc27b495..00000000000 Binary files a/support/hololens/ServoApp/Assets/Square150x150Logo.scale-100.png and /dev/null differ diff --git a/support/hololens/ServoApp/Assets/Square150x150Logo.scale-200.png b/support/hololens/ServoApp/Assets/Square150x150Logo.scale-200.png deleted file mode 100644 index 4fa3dcc499d..00000000000 Binary files a/support/hololens/ServoApp/Assets/Square150x150Logo.scale-200.png and /dev/null differ diff --git a/support/hololens/ServoApp/Assets/Square150x150Logo.scale-400.png b/support/hololens/ServoApp/Assets/Square150x150Logo.scale-400.png deleted file mode 100644 index 51839dc40bd..00000000000 Binary files a/support/hololens/ServoApp/Assets/Square150x150Logo.scale-400.png and /dev/null differ diff --git a/support/hololens/ServoApp/Assets/Square44x44Logo.altform-unplated_targetsize-16.png b/support/hololens/ServoApp/Assets/Square44x44Logo.altform-unplated_targetsize-16.png deleted file mode 100644 index 0b9c24698ab..00000000000 Binary files a/support/hololens/ServoApp/Assets/Square44x44Logo.altform-unplated_targetsize-16.png and /dev/null differ diff --git a/support/hololens/ServoApp/Assets/Square44x44Logo.altform-unplated_targetsize-24.png b/support/hololens/ServoApp/Assets/Square44x44Logo.altform-unplated_targetsize-24.png deleted file mode 100644 index c5ee080199a..00000000000 Binary files a/support/hololens/ServoApp/Assets/Square44x44Logo.altform-unplated_targetsize-24.png and /dev/null differ diff --git a/support/hololens/ServoApp/Assets/Square44x44Logo.altform-unplated_targetsize-256.png b/support/hololens/ServoApp/Assets/Square44x44Logo.altform-unplated_targetsize-256.png deleted file mode 100644 index 1a1b5b6cd80..00000000000 Binary files a/support/hololens/ServoApp/Assets/Square44x44Logo.altform-unplated_targetsize-256.png and /dev/null differ diff --git a/support/hololens/ServoApp/Assets/Square44x44Logo.altform-unplated_targetsize-32.png b/support/hololens/ServoApp/Assets/Square44x44Logo.altform-unplated_targetsize-32.png deleted file mode 100644 index 4c6448a66dc..00000000000 Binary files a/support/hololens/ServoApp/Assets/Square44x44Logo.altform-unplated_targetsize-32.png and /dev/null differ diff --git a/support/hololens/ServoApp/Assets/Square44x44Logo.altform-unplated_targetsize-48.png b/support/hololens/ServoApp/Assets/Square44x44Logo.altform-unplated_targetsize-48.png deleted file mode 100644 index a2d34067395..00000000000 Binary files a/support/hololens/ServoApp/Assets/Square44x44Logo.altform-unplated_targetsize-48.png and /dev/null differ diff --git a/support/hololens/ServoApp/Assets/Square44x44Logo.scale-100.png b/support/hololens/ServoApp/Assets/Square44x44Logo.scale-100.png deleted file mode 100644 index 47844024c7e..00000000000 Binary files a/support/hololens/ServoApp/Assets/Square44x44Logo.scale-100.png and /dev/null differ diff --git a/support/hololens/ServoApp/Assets/Square44x44Logo.scale-125.png b/support/hololens/ServoApp/Assets/Square44x44Logo.scale-125.png deleted file mode 100644 index 26715f1ed48..00000000000 Binary files a/support/hololens/ServoApp/Assets/Square44x44Logo.scale-125.png and /dev/null differ diff --git a/support/hololens/ServoApp/Assets/Square44x44Logo.scale-150.png b/support/hololens/ServoApp/Assets/Square44x44Logo.scale-150.png deleted file mode 100644 index a7dd8f65ec3..00000000000 Binary files a/support/hololens/ServoApp/Assets/Square44x44Logo.scale-150.png and /dev/null differ diff --git a/support/hololens/ServoApp/Assets/Square44x44Logo.scale-200.png b/support/hololens/ServoApp/Assets/Square44x44Logo.scale-200.png deleted file mode 100644 index b7d25e371d0..00000000000 Binary files a/support/hololens/ServoApp/Assets/Square44x44Logo.scale-200.png and /dev/null differ diff --git a/support/hololens/ServoApp/Assets/Square44x44Logo.scale-400.png b/support/hololens/ServoApp/Assets/Square44x44Logo.scale-400.png deleted file mode 100644 index 4961ca89b48..00000000000 Binary files a/support/hololens/ServoApp/Assets/Square44x44Logo.scale-400.png and /dev/null differ diff --git a/support/hololens/ServoApp/Assets/Square44x44Logo.targetsize-16.png b/support/hololens/ServoApp/Assets/Square44x44Logo.targetsize-16.png deleted file mode 100644 index 0b9c24698ab..00000000000 Binary files a/support/hololens/ServoApp/Assets/Square44x44Logo.targetsize-16.png and /dev/null differ diff --git a/support/hololens/ServoApp/Assets/Square44x44Logo.targetsize-24.png b/support/hololens/ServoApp/Assets/Square44x44Logo.targetsize-24.png deleted file mode 100644 index c5ee080199a..00000000000 Binary files a/support/hololens/ServoApp/Assets/Square44x44Logo.targetsize-24.png and /dev/null differ diff --git a/support/hololens/ServoApp/Assets/Square44x44Logo.targetsize-256.png b/support/hololens/ServoApp/Assets/Square44x44Logo.targetsize-256.png deleted file mode 100644 index 1a1b5b6cd80..00000000000 Binary files a/support/hololens/ServoApp/Assets/Square44x44Logo.targetsize-256.png and /dev/null differ diff --git a/support/hololens/ServoApp/Assets/Square44x44Logo.targetsize-32.png b/support/hololens/ServoApp/Assets/Square44x44Logo.targetsize-32.png deleted file mode 100644 index 4c6448a66dc..00000000000 Binary files a/support/hololens/ServoApp/Assets/Square44x44Logo.targetsize-32.png and /dev/null differ diff --git a/support/hololens/ServoApp/Assets/Square44x44Logo.targetsize-48.png b/support/hololens/ServoApp/Assets/Square44x44Logo.targetsize-48.png deleted file mode 100644 index a2d34067395..00000000000 Binary files a/support/hololens/ServoApp/Assets/Square44x44Logo.targetsize-48.png and /dev/null differ diff --git a/support/hololens/ServoApp/Assets/StoreLogo.scale-100.png b/support/hololens/ServoApp/Assets/StoreLogo.scale-100.png deleted file mode 100644 index a07356b4fae..00000000000 Binary files a/support/hololens/ServoApp/Assets/StoreLogo.scale-100.png and /dev/null differ diff --git a/support/hololens/ServoApp/Assets/StoreLogo.scale-200.png b/support/hololens/ServoApp/Assets/StoreLogo.scale-200.png deleted file mode 100644 index aa394af3818..00000000000 Binary files a/support/hololens/ServoApp/Assets/StoreLogo.scale-200.png and /dev/null differ diff --git a/support/hololens/ServoApp/Assets/StoreLogo.scale-400.png b/support/hololens/ServoApp/Assets/StoreLogo.scale-400.png deleted file mode 100644 index dfd110c3f7c..00000000000 Binary files a/support/hololens/ServoApp/Assets/StoreLogo.scale-400.png and /dev/null differ diff --git a/support/hololens/ServoApp/Assets/Wide310x150Logo.scale-100.png b/support/hololens/ServoApp/Assets/Wide310x150Logo.scale-100.png deleted file mode 100644 index b3d10361ef5..00000000000 Binary files a/support/hololens/ServoApp/Assets/Wide310x150Logo.scale-100.png and /dev/null differ diff --git a/support/hololens/ServoApp/Assets/Wide310x150Logo.scale-200.png b/support/hololens/ServoApp/Assets/Wide310x150Logo.scale-200.png deleted file mode 100644 index 5c7e06b1dc8..00000000000 Binary files a/support/hololens/ServoApp/Assets/Wide310x150Logo.scale-200.png and /dev/null differ diff --git a/support/hololens/ServoApp/Assets/Wide310x150Logo.scale-400.png b/support/hololens/ServoApp/Assets/Wide310x150Logo.scale-400.png deleted file mode 100644 index 94a9d390bd2..00000000000 Binary files a/support/hololens/ServoApp/Assets/Wide310x150Logo.scale-400.png and /dev/null differ diff --git a/support/hololens/ServoApp/Bookmarks.cpp b/support/hololens/ServoApp/Bookmarks.cpp deleted file mode 100644 index a421dfe6ed6..00000000000 --- a/support/hololens/ServoApp/Bookmarks.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -#include "pch.h" -#include "Bookmarks.h" - -namespace winrt::servo { - -using namespace Windows::Storage; -using namespace Windows::UI::Core; -using namespace Windows::Foundation; -using namespace Windows::Data::Json; -using namespace Windows::ApplicationModel::Core; - -Bookmarks::Bookmarks() { - db = winrt::single_threaded_observable_vector(); - auto x = Concurrency::create_task([=] { - auto storageFolder = ApplicationData::Current().LocalFolder(); - auto bm_file = storageFolder.GetFileAsync(L"bookmarks.json").get(); - bool file_exist = - storageFolder.TryGetItemAsync(L"bookmarks.json").get() != nullptr; - if (file_exist) { - auto content = FileIO::ReadTextAsync(bm_file).get(); - JsonValue out = JsonValue::Parse(L"[]"); - if (!JsonValue::TryParse(content, out)) { - return; - } - auto list = out.GetArray(); - std::vector bookmarks; - for (auto value : list) { - auto obj = value.GetObject(); - auto name = obj.GetNamedString(L"name"); - auto url = obj.GetNamedString(L"url"); - bookmarks.push_back(box_value(ServoApp::Bookmark(url, name))); - } - auto dispatcher = CoreApplication::MainView().CoreWindow().Dispatcher(); - dispatcher.RunAsync(CoreDispatcherPriority::High, [=] { - db.ReplaceAll(bookmarks); - BuildIndex(); - }); - } - }); -} - -bool Bookmarks::Contains(const hstring &url) { return mIndex.count(url) > 0; } - -void Bookmarks::Set(hstring url, hstring title) { - auto bm = box_value(ServoApp::Bookmark(url, title)); - if (Contains(url)) { - auto index = mIndex.at(url); - db.SetAt(index, bm); - } else { - db.Append(bm); - } - InvalidateDB(); -} - -hstring Bookmarks::GetName(const hstring &url) { - auto index = mIndex.at(url); - ServoApp::Bookmark bm = unbox_value(db.GetAt(index)); - return bm.Name(); -} - -void Bookmarks::Delete(const hstring &url) { - auto index = mIndex.at(url); - db.RemoveAt(index); - InvalidateDB(); -} - -void Bookmarks::BuildIndex() { - mIndex.clear(); - int i = 0; - for (auto bm : db) { - auto url = unbox_value(bm).Url(); - mIndex.insert_or_assign(url, i++); - } -} - -void Bookmarks::InvalidateDB() { - BuildIndex(); - WriteSettings(); -} - -IAsyncAction Bookmarks::WriteSettings() { - auto storageFolder = ApplicationData::Current().LocalFolder(); - auto file = co_await storageFolder.CreateFileAsync( - L"bookmarks.json", CreationCollisionOption::ReplaceExisting); - JsonArray list; - for (auto boxed_bm : db) { - auto bm = unbox_value(boxed_bm); - JsonObject bookmark; - bookmark.Insert(L"name", JsonValue::CreateStringValue(bm.Name())); - bookmark.Insert(L"url", JsonValue::CreateStringValue(bm.Url())); - list.Append(bookmark); - } - FileIO::WriteTextAsync(file, list.Stringify()); -} - -} // namespace winrt::servo diff --git a/support/hololens/ServoApp/Bookmarks.h b/support/hololens/ServoApp/Bookmarks.h deleted file mode 100644 index 040a3155f1f..00000000000 --- a/support/hololens/ServoApp/Bookmarks.h +++ /dev/null @@ -1,38 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -#pragma once - -#include "pch.h" -#include "Bookmark.g.h" - -namespace winrt::servo { - -using namespace winrt::Windows::Foundation; - -class Bookmarks { - -public: - Bookmarks(); - bool Contains(const hstring &url); - hstring GetName(const hstring &url); - void Set(hstring url, hstring title); - void Delete(const hstring &url); - const Collections::IObservableVector &TemplateSource() { - return db; - }; - -private: - IAsyncAction WriteSettings(); - void BuildIndex(); - void InvalidateDB(); - // Array of Bookmarks as defined in the IDL - // An IObservableMap would be better, but this is not supported in XAML+winrt: - // See https://github.com/microsoft/microsoft-ui-xaml/issues/1612 - Collections::IObservableVector db; - // ... so we have an additional map that link a url to the index in the array: - std::map mIndex; -}; - -} // namespace winrt::servo diff --git a/support/hololens/ServoApp/BrowserPage.cpp b/support/hololens/ServoApp/BrowserPage.cpp deleted file mode 100644 index a8417d8a759..00000000000 --- a/support/hololens/ServoApp/BrowserPage.cpp +++ /dev/null @@ -1,544 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -#include "pch.h" -#include "strutils.h" -#include "BrowserPage.h" -#include "BrowserPage.g.cpp" -#include "Bookmark.g.cpp" -#include "ConsoleLog.g.cpp" -#include "Devtools/Client.h" - -using namespace std::placeholders; -using namespace winrt::Windows::Foundation; -using namespace winrt::Windows::UI::Xaml; -using namespace winrt::Windows::UI::Core; -using namespace winrt::Windows::UI::ViewManagement; -using namespace winrt::Windows::ApplicationModel::Core; -using namespace winrt::Windows::ApplicationModel::Resources; -using namespace winrt::Windows::ApplicationModel::Resources::Core; -using namespace winrt::Windows::UI::Notifications; -using namespace winrt::Windows::Data::Json; -using namespace winrt::Windows::Data::Xml::Dom; -using namespace winrt::Windows::Storage; -using namespace winrt::servo; - -namespace winrt::ServoApp::implementation { - -BrowserPage::BrowserPage() { - InitializeComponent(); - BindServoEvents(); - mLogs = winrt::single_threaded_observable_vector(); - - auto ctx = ResourceContext::GetForCurrentView(); - auto current = ResourceManager::Current(); - auto tree = current.MainResourceMap().GetSubtree(L"PromotedPrefs"); - for (auto s : tree) { - hstring k = s.Key(); - std::wstring wk = k.c_str(); - std::replace(wk.begin(), wk.end(), '/', '.'); - hstring v = s.Value().Resolve(ctx).ValueAsString(); - mPromotedPrefs.insert(std::pair(wk, v)); - } -} - -void BrowserPage::BindServoEvents() { - servoView().OnURLChanged([=](const auto &, hstring url) { - mCurrentUrl = url; - urlTextbox().Text(url); - UpdateBookmarkPanel(); - }); - servoView().OnTitleChanged([=](const auto &, hstring title) { - if (title.size() > 0) { - mCurrentTitle = {title}; - } else { - mCurrentTitle = {}; - } - UpdateBookmarkPanel(); - }); - servoView().OnHistoryChanged([=](bool back, bool forward) { - backButton().IsEnabled(back); - forwardButton().IsEnabled(forward); - }); - servoView().OnServoPanic([=](const auto &, hstring /*message*/) { - mPanicking = true; - CheckCrashReport(); - }); - servoView().OnLoadStarted([=] { - mCurrentUrl = {}; - mCurrentTitle = {}; - urlbarLoadingIndicator().IsActive(true); - transientLoadingIndicator().IsIndeterminate(true); - reloadButton().IsEnabled(false); - reloadButton().Visibility(Visibility::Collapsed); - stopButton().IsEnabled(true); - stopButton().Visibility(Visibility::Visible); - devtoolsButton().IsEnabled(true); - CheckCrashReport(); - UpdateBookmarkPanel(); - }); - servoView().OnLoadEnded([=] { - urlbarLoadingIndicator().IsActive(false); - transientLoadingIndicator().IsIndeterminate(false); - reloadButton().IsEnabled(true); - reloadButton().Visibility(Visibility::Visible); - stopButton().IsEnabled(false); - stopButton().Visibility(Visibility::Collapsed); - }); - bookmarkPanel().Opening([=](const auto &, const auto &) { - if (!mCurrentUrl.has_value()) { - return; - } - hstring url = *mCurrentUrl; - auto resourceLoader = ResourceLoader::GetForCurrentView(); - if (!mBookmarks.Contains(url)) { - auto label = resourceLoader.GetString(L"bookmarkPanel/addedTitle"); - bookmarkPanelLabel().Text(label); - mBookmarks.Set(url, bookmarkPanelTitle().Text()); - } else { - auto label = resourceLoader.GetString(L"bookmarkPanel/editTitle"); - bookmarkPanelLabel().Text(label); - } - bookmarkPanelTitle().SelectAll(); - }); - servoView().OnCaptureGesturesStarted([=] { - servoView().Focus(FocusState::Programmatic); - navigationBar().IsHitTestVisible(false); - }); - servoView().OnCaptureGesturesEnded( - [=] { navigationBar().IsHitTestVisible(true); }); - urlTextbox().GotFocus(std::bind(&BrowserPage::OnURLFocused, this, _1)); - servoView().OnMediaSessionMetadata( - [=](hstring /*title*/, hstring /*artist*/, hstring /*album*/) {}); - servoView().OnMediaSessionPosition( - [=](double /*duration*/, double /*position*/, double /*rate*/) {}); - servoView().OnMediaSessionPlaybackStateChange([=](const auto &, int state) { - if (state == Servo::MediaSessionPlaybackState::None) { - mediaControls().Visibility(Visibility::Collapsed); - return; - } - mediaControls().Visibility(Visibility::Visible); - playButton().Visibility(state == Servo::MediaSessionPlaybackState::Paused - ? Visibility::Visible - : Visibility::Collapsed); - pauseButton().Visibility(state == Servo::MediaSessionPlaybackState::Paused - ? Visibility::Collapsed - : Visibility::Visible); - }); - servoView().OnDevtoolsStatusChanged( - [=](DevtoolsStatus status, unsigned int port, hstring token) { - mDevtoolsStatus = status; - mDevtoolsPort = port; - mDevtoolsToken = token; - }); - Window::Current().VisibilityChanged( - [=](const auto &, const VisibilityChangedEventArgs &args) { - servoView().ChangeVisibility(args.Visible()); - }); - - auto obsBM = - mBookmarks.TemplateSource().as>(); - obsBM.VectorChanged(std::bind(&BrowserPage::OnBookmarkDBChanged, this)); -} - -void BrowserPage::OnURLFocused(IInspectable const &) { - urlTextbox().SelectAll(); -} - -void BrowserPage::OnURLKeyboardAccelerator( - IInspectable const &, Input::KeyboardAcceleratorInvokedEventArgs const &) { - urlTextbox().Focus(FocusState::Programmatic); -} - -void BrowserPage::LoadFXRURI(Uri uri) { - auto scheme = uri.SchemeName(); - std::wstring raw{uri.RawUri()}; - if (scheme == FXR_SCHEME) { - auto raw2 = raw.substr(FXR_SCHEME_SLASH_SLASH.size()); - servoView().LoadURIOrSearch(raw2); - SetTransientMode(false); - } else if (scheme == FXRMIN_SCHEME) { - auto raw2 = raw.substr(FXRMIN_SCHEME_SLASH_SLASH.size()); - servoView().LoadURIOrSearch(raw2); - SetTransientMode(true); - } else { - log(L"Unexpected URL: ", uri.RawUri().c_str()); - } -} - -void BrowserPage::SetTransientMode(bool transient) { - servoView().SetTransientMode(transient); - navigationBar().Visibility(transient ? Visibility::Collapsed - : Visibility::Visible); - transientLoadingIndicator().Visibility(transient ? Visibility::Visible - : Visibility::Collapsed); -} - -void BrowserPage::SetArgs(hstring args) { servoView().SetArgs(args); } - -void BrowserPage::Shutdown() { servoView().Shutdown(); } - -/**** USER INTERACTIONS WITH UI ****/ - -void BrowserPage::OnBackButtonClicked(IInspectable const &, - RoutedEventArgs const &) { - servoView().GoBack(); -} - -void BrowserPage::OnForwardButtonClicked(IInspectable const &, - RoutedEventArgs const &) { - servoView().GoForward(); -} - -void BrowserPage::OnReloadButtonClicked(IInspectable const &, - RoutedEventArgs const &) { - servoView().Reload(); -} - -void BrowserPage::OnStopButtonClicked(IInspectable const &, - RoutedEventArgs const &) { - servoView().Stop(); -} - -void BrowserPage::OnHomeButtonClicked(IInspectable const &, - RoutedEventArgs const &) { - servoView().GoHome(); -} - -// Given a pref, update its associated UI control. -void BrowserPage::UpdatePref(ServoApp::Pref pref, Controls::Control ctrl) { - auto value = pref.Value(); - auto type = value.as().Type(); - if (type == PropertyType::Boolean) { - ctrl.as().IsChecked(unbox_value(value)); - } else if (type == PropertyType::Double) { - ctrl.as().Value( - unbox_value(value)); - } else if (type == PropertyType::Int64) { - ctrl.as().Value( - (double)unbox_value(value)); - } else if (type == PropertyType::String) { - ctrl.as().Text(unbox_value(value)); - } - auto stack = ctrl.Parent().as(); - auto font = winrt::Windows::UI::Text::FontWeights::Normal(); - if (!pref.IsDefault()) { - font = winrt::Windows::UI::Text::FontWeights::Bold(); - } - stack.Children().GetAt(0).as().FontWeight(font); - stack.Children().GetAt(2).as().IsEnabled(!pref.IsDefault()); -} - -void BrowserPage::OnSeeAllPrefClicked(IInspectable const &, - RoutedEventArgs const &) { - BuildPrefList(); -} - -// Retrieve the preference list from Servo and build the preference table. -void BrowserPage::BuildPrefList() { - prefList().Children().Clear(); - bool promoted = !seeAllPrefCheckBox().IsChecked().GetBoolean(); - preferenceSearchbox().Visibility(promoted ? Visibility::Collapsed - : Visibility::Visible); - preferenceSearchbox().Text(L""); - // It would be better to use a template and bindings, but the - // takes too long to generate all the items, and - // it's pretty difficiult to have different controls depending - // on the pref type. - auto resourceLoader = ResourceLoader::GetForCurrentView(); - auto resetStr = - resourceLoader.GetString(L"devtoolsPreferenceResetButton/Content"); - for (auto pref : servoView().Preferences()) { - std::optional description = {}; - if (promoted) { - auto search = mPromotedPrefs.find(pref.Key()); - if (search == mPromotedPrefs.end()) { - continue; - } - description = {search->second}; - } - auto value = pref.Value(); - auto type = value.as().Type(); - std::optional ctrl; - if (type == PropertyType::Boolean) { - auto checkbox = Controls::CheckBox(); - checkbox.IsChecked(unbox_value(value)); - checkbox.Click([=](const auto &, auto const &) { - auto upref = servoView().SetBoolPref(pref.Key(), - checkbox.IsChecked().GetBoolean()); - UpdatePref(upref, checkbox); - }); - ctrl = checkbox; - } else if (type == PropertyType::String) { - auto textbox = Controls::TextBox(); - textbox.Text(unbox_value(value)); - textbox.KeyUp([=](const auto &, Input::KeyRoutedEventArgs const &e) { - if (e.Key() == Windows::System::VirtualKey::Enter) { - auto upref = servoView().SetStringPref(pref.Key(), textbox.Text()); - UpdatePref(upref, textbox); - } - }); - ctrl = textbox; - } else if (type == PropertyType::Int64) { - // Note: These are *not* under Windows::UI:Xaml namespace. - auto nbox = Microsoft::UI::Xaml::Controls::NumberBox(); - nbox.Value((double)unbox_value(value)); - nbox.SpinButtonPlacementMode( - Microsoft::UI::Xaml::Controls::NumberBoxSpinButtonPlacementMode:: - Inline); - nbox.ValueChanged([=](const auto &, const auto &) { - int val = (int)nbox.Value(); - auto upref = servoView().SetIntPref(pref.Key(), val); - UpdatePref(upref, nbox); - }); - ctrl = nbox; - } else if (type == PropertyType::Double) { - auto nbox = Microsoft::UI::Xaml::Controls::NumberBox(); - nbox.Value(unbox_value(value)); - nbox.ValueChanged([=](const auto &, const auto &) { - auto upref = servoView().SetIntPref(pref.Key(), (int64_t)nbox.Value()); - UpdatePref(upref, (Controls::Control &)nbox); - }); - ctrl = nbox; - } - if (ctrl.has_value()) { - auto stack = Controls::StackPanel(); - stack.Tag(winrt::box_value(pref.Key())); - stack.Padding({4, 4, 4, 4}); - stack.Orientation(Controls::Orientation::Horizontal); - auto key = Controls::TextBlock(); - key.Text(promoted ? *description : pref.Key()); - key.Width(350); - if (!pref.IsDefault()) { - auto font = winrt::Windows::UI::Text::FontWeights::Bold(); - key.FontWeight(font); - } - stack.Children().Append(key); - ctrl->Width(300); - ctrl->Margin({4, 0, 40, 0}); - stack.Children().Append(*ctrl); - auto reset = Controls::Button(); - reset.Content(winrt::box_value(resetStr)); - reset.IsEnabled(!pref.IsDefault()); - reset.Click([=](const auto &, auto const &) { - auto upref = servoView().ResetPref(pref.Key()); - UpdatePref(upref, *ctrl); - }); - stack.Children().Append(reset); - prefList().Children().Append(stack); - } - } -} - -void BrowserPage::OnPrefererenceSearchboxEdited( - IInspectable const &, Input::KeyRoutedEventArgs const &) { - auto input = preferenceSearchbox().Text(); - for (auto element : prefList().Children()) { - auto ctrl = (Controls::Control &)element; - if (input.size() == 0) { - ctrl.Visibility(Visibility::Visible); - } else { - auto tag = ctrl.Tag(); - std::wstring key = static_cast(unbox_value(tag)); - bool not_found = key.find(input) == std::wstring::npos; - ctrl.Visibility(not_found ? Visibility::Collapsed : Visibility::Visible); - } - } -} - -void BrowserPage::ClearConsole() { - Dispatcher().RunAsync(CoreDispatcherPriority::High, [=] { mLogs.Clear(); }); -} - -void BrowserPage::OnDevtoolsMessage(DevtoolsMessageLevel level, hstring source, - hstring body) { - Dispatcher().RunAsync(CoreDispatcherPriority::High, [=] { - auto glyphColor = UI::Colors::Transparent(); - auto glyph = L""; - if (level == servo::DevtoolsMessageLevel::Error) { - glyphColor = UI::Colors::Red(); - glyph = L"\xEA39"; // ErrorBadge - } else if (level == servo::DevtoolsMessageLevel::Warn) { - glyphColor = UI::Colors::Orange(); - glyph = L"\xE7BA"; // Warning - } - mLogs.Append(make(glyphColor, glyph, body, source)); - }); -} - -void BrowserPage::CheckCrashReport() { - Concurrency::create_task([=] { - auto pref = servo::Servo::GetPref(L"shell.crash_reporter.enabled"); - bool reporter_enabled = unbox_value(std::get<1>(pref)); - auto storageFolder = ApplicationData::Current().LocalFolder(); - bool file_exist = - storageFolder.TryGetItemAsync(L"crash-report.txt").get() != nullptr; - if (reporter_enabled && file_exist) { - auto crash_file = storageFolder.GetFileAsync(L"crash-report.txt").get(); - auto content = FileIO::ReadTextAsync(crash_file).get(); - Dispatcher().RunAsync(CoreDispatcherPriority::High, [=] { - auto resourceLoader = ResourceLoader::GetForCurrentView(); - auto message = resourceLoader.GetString(mPanicking ? L"crash/Happening" - : L"crash/Happened"); - crashTabMessage().Text(message); - crashReport().Text(content); - crashTab().Visibility(Visibility::Visible); - crashTab().IsSelected(true); - ShowToolbox(); - }); - } else { - Dispatcher().RunAsync(CoreDispatcherPriority::High, [=] { - crashTab().Visibility(Visibility::Collapsed); - devtoolsTabConsole().IsSelected(true); - }); - } - }); -} - -void BrowserPage::OnDismissCrashReport(IInspectable const &, - RoutedEventArgs const &) { - Concurrency::create_task([=] { - auto storageFolder = ApplicationData::Current().LocalFolder(); - auto crash_file = storageFolder.GetFileAsync(L"crash-report.txt").get(); - crash_file.DeleteAsync().get(); - }); - HideToolbox(); -} - -void BrowserPage::OnSubmitCrashReport(IInspectable const &, - RoutedEventArgs const &) { - // FIXME -} - -void BrowserPage::OnDevtoolsDetached() {} - -void BrowserPage::ShowToolbox() { - if (toolbox().Visibility() == Visibility::Visible) { - return; - } - toolbox().Visibility(Visibility::Visible); - CheckCrashReport(); - BuildPrefList(); - auto resourceLoader = ResourceLoader::GetForCurrentView(); - if (mDevtoolsStatus == DevtoolsStatus::Running) { - hstring port = to_hstring(mDevtoolsPort); - if (mDevtoolsClient == nullptr) { - DevtoolsDelegate *dd = static_cast(this); - mDevtoolsClient = std::make_unique(L"localhost", port, - mDevtoolsToken, *dd); - } - mDevtoolsClient->Run(); - std::wstring message = - resourceLoader.GetString(L"devtoolsStatus/Running").c_str(); - hstring formatted{format(message, port.c_str())}; - OnDevtoolsMessage(servo::DevtoolsMessageLevel::None, L"", formatted); - } else if (mDevtoolsStatus == DevtoolsStatus::Failed) { - auto body = resourceLoader.GetString(L"devtoolsStatus/Failed"); - OnDevtoolsMessage(servo::DevtoolsMessageLevel::Error, L"", body); - } else if (mDevtoolsStatus == DevtoolsStatus::Stopped) { - auto body = resourceLoader.GetString(L"devtoolsStatus/Stopped"); - OnDevtoolsMessage(servo::DevtoolsMessageLevel::None, L"", body); - } -} - -void BrowserPage::HideToolbox() { - prefList().Children().Clear(); - toolbox().Visibility(Visibility::Collapsed); - ClearConsole(); - if (mDevtoolsClient != nullptr) { - mDevtoolsClient->Stop(); - } -} - -void BrowserPage::OnDevtoolsButtonClicked(IInspectable const &, - RoutedEventArgs const &) { - if (toolbox().Visibility() == Visibility::Visible) { - HideToolbox(); - } else { - ShowToolbox(); - } -} - -void BrowserPage::OnBookmarkDBChanged() { - Dispatcher().RunAsync(CoreDispatcherPriority::High, - [=] { UpdateBookmarkPanel(); }); -} - -void BrowserPage::UpdateBookmarkPanel() { - if (mCurrentUrl.has_value()) { - bookmarkButton().IsEnabled(true); - if (mBookmarks.Contains(*mCurrentUrl)) { - bookmarkPanelIcon().Symbol(Controls::Symbol::SolidStar); - auto name = mBookmarks.GetName(*mCurrentUrl); - bookmarkPanelTitle().Text(name); - } else { - bookmarkPanelIcon().Symbol(Controls::Symbol::OutlineStar); - auto label = mCurrentTitle.value_or(*mCurrentUrl); - bookmarkPanelTitle().Text(label); - } - } else { - bookmarkButton().IsEnabled(false); - } - if (mBookmarks.TemplateSource().Size() == 0) { - bookmarkToolbar().Visibility(Visibility::Collapsed); - } else { - bookmarkToolbar().Visibility(Visibility::Visible); - } -} - -void BrowserPage::OnBookmarkEdited(IInspectable const &, - Input::KeyRoutedEventArgs const &e) { - if (e.Key() == Windows::System::VirtualKey::Enter) { - UpdateBookmark(); - } -} - -void BrowserPage::OnBookmarkClicked(IInspectable const &sender, - RoutedEventArgs const &) { - auto button = sender.as(); - auto url = winrt::unbox_value(button.Tag()); - servoView().LoadURIOrSearch(url); -} - -void BrowserPage::RemoveBookmark() { - mBookmarks.Delete(*mCurrentUrl); - bookmarkPanel().Hide(); -} - -void BrowserPage::UpdateBookmark() { - mBookmarks.Set(*mCurrentUrl, bookmarkPanelTitle().Text()); - bookmarkPanel().Hide(); -} - -void BrowserPage::OnJSInputEdited(IInspectable const &, - Input::KeyRoutedEventArgs const &e) { - if (e.Key() == Windows::System::VirtualKey::Enter) { - auto input = JSInput().Text(); - JSInput().Text(L""); - mDevtoolsClient->Evaluate(input); - } -} - -void BrowserPage::OnURLEdited(IInspectable const &, - Input::KeyRoutedEventArgs const &e) { - if (e.Key() == Windows::System::VirtualKey::Enter) { - servoView().Focus(FocusState::Programmatic); - auto input = urlTextbox().Text(); - auto uri = servoView().LoadURIOrSearch(input); - urlTextbox().Text(uri); - } -} - -void BrowserPage::OnMediaControlsPlayClicked(IInspectable const &, - RoutedEventArgs const &) { - servoView().SendMediaSessionAction( - static_cast(Servo::MediaSessionActionType::Play)); -} -void BrowserPage::OnMediaControlsPauseClicked(IInspectable const &, - RoutedEventArgs const &) { - servoView().SendMediaSessionAction( - static_cast(Servo::MediaSessionActionType::Pause)); -} - -} // namespace winrt::ServoApp::implementation diff --git a/support/hololens/ServoApp/BrowserPage.h b/support/hololens/ServoApp/BrowserPage.h deleted file mode 100644 index a1e120955ac..00000000000 --- a/support/hololens/ServoApp/BrowserPage.h +++ /dev/null @@ -1,134 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -#pragma once - -#include "BrowserPage.g.h" -#include "Bookmark.g.h" -#include "ConsoleLog.g.h" -#include "ServoControl/ServoControl.h" -#include "Devtools/Client.h" -#include "Bookmarks.h" - -namespace winrt::ServoApp::implementation { - -using namespace winrt::servo; -using namespace winrt::Windows; -using namespace winrt::Windows::Data::Json; -using namespace winrt::Windows::Foundation; -using namespace winrt::Windows::UI::Xaml; -using namespace winrt::Windows::UI::Xaml::Media; - -static const hstring FXR_SCHEME = L"fxr"; -static const hstring FXR_SCHEME_SLASH_SLASH = L"fxr://"; -static const hstring FXRMIN_SCHEME = L"fxrmin"; -static const hstring FXRMIN_SCHEME_SLASH_SLASH = L"fxrmin://"; - -struct BrowserPage : BrowserPageT, public DevtoolsDelegate { -public: - BrowserPage(); - - void OnForwardButtonClicked(IInspectable const &, RoutedEventArgs const &); - void OnBackButtonClicked(IInspectable const &, RoutedEventArgs const &); - void OnReloadButtonClicked(IInspectable const &, RoutedEventArgs const &); - void OnStopButtonClicked(IInspectable const &, RoutedEventArgs const &); - void OnHomeButtonClicked(IInspectable const &, RoutedEventArgs const &); - void OnDevtoolsButtonClicked(IInspectable const &, RoutedEventArgs const &); - void OnBookmarkClicked(IInspectable const &, RoutedEventArgs const &); - void OnUpdateBookmarkButtonClicked(IInspectable const &, - RoutedEventArgs const &) { - UpdateBookmark(); - }; - void OnRemoveBookmarkButtonClicked(IInspectable const &, - RoutedEventArgs const &) { - RemoveBookmark(); - }; - void OnBookmarkEdited(IInspectable const &, - Input::KeyRoutedEventArgs const &); - void OnJSInputEdited(IInspectable const &, Input::KeyRoutedEventArgs const &); - void OnURLEdited(IInspectable const &, Input::KeyRoutedEventArgs const &); - void OnSeeAllPrefClicked(IInspectable const &, RoutedEventArgs const &); - void OnURLFocused(IInspectable const &); - void - OnURLKeyboardAccelerator(IInspectable const &, - Input::KeyboardAcceleratorInvokedEventArgs const &); - void Shutdown(); - void LoadFXRURI(Uri uri); - void SetArgs(hstring); - void OnDismissCrashReport(IInspectable const &, RoutedEventArgs const &); - void OnSubmitCrashReport(IInspectable const &, RoutedEventArgs const &); - void OnMediaControlsPlayClicked(IInspectable const &, - RoutedEventArgs const &); - void OnMediaControlsPauseClicked(IInspectable const &, - RoutedEventArgs const &); - void OnPrefererenceSearchboxEdited(IInspectable const &, - Input::KeyRoutedEventArgs const &); - void OnDevtoolsMessage(DevtoolsMessageLevel, hstring, hstring); - void ClearConsole(); - void OnDevtoolsDetached(); - Collections::IObservableVector ConsoleLogs() { return mLogs; }; - Collections::IObservableVector Bookmarks() { - return mBookmarks.TemplateSource(); - }; - void RemoveBookmark(); - void UpdateBookmark(); - -private: - void SetTransientMode(bool); - void UpdatePref(ServoApp::Pref, Controls::Control); - void CheckCrashReport(); - void BindServoEvents(); - void ShowToolbox(); - void HideToolbox(); - void BuildPrefList(); - void UpdateBookmarkPanel(); - void OnBookmarkDBChanged(); - DevtoolsStatus mDevtoolsStatus = DevtoolsStatus::Stopped; - unsigned int mDevtoolsPort = 0; - hstring mDevtoolsToken; - bool mPanicking = false; - std::unique_ptr mDevtoolsClient; - Collections::IObservableVector mLogs; - std::map mPromotedPrefs; - std::optional mCurrentUrl; - std::optional mCurrentTitle; - servo::Bookmarks mBookmarks; -}; - -struct ConsoleLog : ConsoleLogT { -public: - ConsoleLog(Windows::UI::Color glyph, hstring g, hstring b, hstring s) - : mGlyph(g), mSource(s), mBody(b) { - mGlyphColor = UI::Xaml::Media::SolidColorBrush(glyph); - }; - SolidColorBrush GlyphColor() { return mGlyphColor; }; - hstring Glyph() { return mGlyph; }; - hstring Source() { return mSource; }; - hstring Body() { return mBody; }; - -private: - SolidColorBrush mGlyphColor; - hstring mGlyph; - hstring mSource; - hstring mBody; -}; - -struct Bookmark : BookmarkT { -public: - Bookmark(hstring url, hstring name) : mName(name), mUrl(url){}; - hstring Name() { return mName; }; - hstring Url() { return mUrl; }; - -private: - hstring mName; - hstring mUrl; -}; - -} // namespace winrt::ServoApp::implementation - -namespace winrt::ServoApp::factory_implementation { -struct BrowserPage : BrowserPageT {}; -struct ConsoleLog : ConsoleLogT {}; -struct Bookmark : BookmarkT {}; -} // namespace winrt::ServoApp::factory_implementation diff --git a/support/hololens/ServoApp/BrowserPage.idl b/support/hololens/ServoApp/BrowserPage.idl deleted file mode 100644 index 4579d937a70..00000000000 --- a/support/hololens/ServoApp/BrowserPage.idl +++ /dev/null @@ -1,26 +0,0 @@ -namespace ServoApp -{ - [default_interface] - runtimeclass BrowserPage : Windows.UI.Xaml.Controls.Page - { - BrowserPage(); - Windows.Foundation.Collections.IObservableVector ConsoleLogs{ get; }; - Windows.Foundation.Collections.IObservableVector Bookmarks{ get; }; - } - - runtimeclass ConsoleLog - { - ConsoleLog(Windows.UI.Color glyphColor, String glyph, String body, String source); - Windows.UI.Xaml.Media.SolidColorBrush GlyphColor{ get; }; - String Glyph{ get; }; - String Body{ get; }; - String Source{ get; }; - } - - runtimeclass Bookmark - { - Bookmark(String name, String url); - String Name{ get; }; - String Url{ get; }; - } -} diff --git a/support/hololens/ServoApp/BrowserPage.xaml b/support/hololens/ServoApp/BrowserPage.xaml deleted file mode 100644 index 2b1c6b0e121..00000000000 --- a/support/hololens/ServoApp/BrowserPage.xaml +++ /dev/null @@ -1,261 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -