building webkit on windows phone 8 - c#

I have some html containing WEBKIT content which needs to be rendered on Windows Phone 8 browser and Windows 8 Store apps webview. As windows 8 and wp8 browser control doesn't support webkit.
is there any way where:
I can map webkit to IE specific tags internally in code and then calling Webview.NavigateToString(html).
As Webkit is Open source, Can I build webkit to dll and use it as a control in my WP8/W8 to render Webkit html?
If there is any better way other than this, please suggest...
Thanks!

By webkit "content" and "specific tags" I'm assuming that you're referring to -webkit specific prefixes in the CSS.
There is no way to map these to anything that can be automatically converted to the IE specific equivalent.
Building your own browser (which is essentially what you'd be doing if you got the webkit code compiling for the phone) is likely to be masses of work. Much more than modifying the code you are displaying.
The best approach is to simply include the IE equivalent version of the vendor specific extension where one exists. This is the same as you would do if you had content that you wanted to take advantage of such extensions and run on multiple browsers. (i.e. Firefox and Opera also.)
You should also seriously consider if you need things to look identical on multiple devices. (Hint. you don't.) Your time may be better served by ensuring you are displaying content which looks appropriate on the appropriate device, rather than trying to use the code for getting something to display in a specific way on one device/browser to work on another.

Related

how to create a webbroswer in wpf that supports all the sites and scripts and play video?

I have to create a webbroswer in wpf that supports all the sites and scripts and play video , I have created but some site got crashed and not supporting .
Please provide solution.
What you ran into are probably error dialogs caused by JavaScript script errors. WPF WebBrowser control currently doesn't support disabling these dialogs and ignoring the errors. The WebBrowser control is based on Internet Explorer core and will have a hard time dealing with broken JavaScript, webpages will also sometimes report the web browser as old and inform the visitor about it, like FlipKart does.
One solution is to use WindowsFormsHost and host a Windows Forms equivalent - WebBrowser control - in it. The WF WebBrowser offers a property called SupressScriptErrors, which is not implemented by the WPF WebBrowser. That will hide the error dialogs for you, but you will still occasionaly receive a warning from the website saying they don't support the web browser used. That is out of your control unless you want to take a route of hacking the control to send a different User-Agent string and that will only fool broken UA detection, feature detection will still fail for things like HTML5 video, WebRTC and the like. More on this here.
You can also choose to embed Gecko (Firefox rendering engine) or Chromium. see here for more information on embedding alternative rendering cores as an alternative to IE COM wrapper offered by the framework.
Edit: this is also a possible solution, as it would seem. You will have to test it for yourself, though. I expect it to have less overhead than the WindowsFromHost element and although this uses reflection to develop against implementation, not interface, my opinion is it's safe to say the underlaying API in unlikely to change.

Windows Runtime access file from JavaScript in WebView

I am using Three.js to try and implement a cross platform 3D model viewer. At the moment I have got it working and embedded in my XAML and C# application for Win 8.1 and Windows Phone 8.1 with a WebView. At the moment I am using C# code to load models (triangle meshes) from files on the device as well as a bundled file. The problem is that this means that I have to invoke a JavaScript function from C# for every triangle that I want to add and this makes the UI unresponsive for a while. I have tried to run the script async and to run the loader async but it does not really help because the all the JS function calls need to be handled by the Core Dispatcher otherwise I get an invalid thread access exception. In the beginning I did not realize this and thought it would be simpler and of higher performance to do loading in C#. I will now probably have to redo the loader in JS...
What I need to ask now is for some information as of how I should access the files from of JavaScript. I know Windows RT supports its file access API from JS but I am guessing this is more for entire JS applications because it does not seem to work from inside the WebView*. I would also prefer something more cross platform though as this also needs to work for Windows Desktop, iOS, Android and probably Mac and Linux too, so what would be my best option for this?
*I have tried the JS at http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.pickers.fileopenpicker.aspx in my WP 8.1 application but no file selector appears. My the WebView does seem to freeze up though but I also don't get any exceptions or so popping up.
PS. I have a sort of feeling that it might come down to me having to copy files to a temp folder that JS can access. This would not be ideal as copying will waste time but if it's my only option then I will probably have to go for it. If this my only option I would appreciate some help with implementing it because JavaScript is really not my language and I'm only using it because of Three.JS...
As soon are you're using the WebView you end up in a situation where you need to post messages back and forward between your host app (the C# code, assuming you didn't rewrite it) and the website you're hosting in the WebView. The two basically function in isolation from each other.
Can you not load your geometry using the documentation of the Three.js format? It looks to be available here: https://github.com/mrdoob/three.js/wiki/JSON-Geometry-format-4
That way you can proxy the entire geometry across vs. each individual triangle.

Request.Browser.Version returns 7 for IE on Surface Pro?

I'm developing an MVC app.
If I (on my Surface Pro) goes to http://www.whatbrowser.org/ it correctly says IE 10.
But if I go to my MVC app and print out the Request.Browser.Version, it returns 7.
Any idea why? Is Request.Browser.Version broken?
Thanks
Some of this is touched on in Detect Internet explorer browser version problems.
Last I knew Request.Browser uses the *.browser files that come with the installs of ASP.NET, and easily get out of date. Microsoft releases updates to them every so often, but not often enough. Currently there are some issues with webform pages breaking on IE10 without updated browser files.
Like the comments have said, browser detection is very broken. If you need to detect the browser, at the very least shy away from using the user agent string, and seriously consider why you need to know exactly what browser is used.
Request.Browser.Version doesn't always return the 'correct' browser version for IE because of many factors including compatibility view, meta tags etc.
You would be better off detecting browser capabilities instead. Further reading here: http://msdn.microsoft.com/library/3yekbd5b
As a personal preference, it would be best to detect the OS instead of the browser. Most of the common HTML5/CSS3 features are supported in IE9 and above and IE9 requires Windows Vista and up. The best way to do this using the User Agent is by checking the Trident. If there is compatibility view enabled via the browser or by using meta tags by the app itself, the wrong 'version' is returned but the Trident remains correct.
PS. This isn't fool proof but this would work most of the time.
Further reading about Trident here: http://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx#PltToken

Render page within winforms with one of the installed browsers?

I wanted to make my own "editor" to for html, css, etc, where on one side I have the code and on the other how it looks like on the browser.
I know within c# we have the handy System.Windows.Forms.WebBrowser() that could do that for me but I wanted to be able to make it render as if it was using ie or ff or chrome browsers.
How could I render the page some how as if it was using one of
those (considering they are installed and available within the
computer but to open on the c# winforms) ?
You would have to use the rendering engine that the other browsers use. For example, Chrome and Safari use Webkit. Getting this to work for older browsers like IE6, 7, will be much harder, since they don't release their layout engine. IE9 has a feature that lets you render a page as an older browser, but I'm not sure if you can use that feature using the WebBrowser control.

Is there any better web browser control in C# (.NET)?

I need JavaScript working almost perfectly in my application that should be able to access web content and let user take a control of it. However, webbrowser component pops new windows in separate instance / application of Internet Explorer and dotBrowser doesn't work with JavaScript properly.
Please, give me some advice - I'd even take some working example and enhance it with function I need it for.
Give a look to GeckoFX, is on open-source component for embedding the Mozilla Gecko (Firefox) in .NET applications.
I could be mistaken, but I believe new windows can be controlled (or at least suppressed) using the Web Browser control in .NET. Have a look at the NewWindow event.
I have had experience embedding both WebKit (Apple Core, used in Chrome) and XULRunner (Gecko) cores in .NET winforms applications. Let me give you some advice:
GeckoFX is your best bet. It is licensed under MPL and it works pretty much out of the box.
Follow the instructions carefully and pull the exact XUL version that is indicated. I would say it works better than the WebBrowser control. There is some talk of a significant delay when loading XUL for the first time but I've found it to be negligible. Branding and the like is fully customizable via external files.
WebKit is embeddable with SwiftDotNet. If all you need is solid javascript performance then this may be an option. If you need to be able to download files, then you have some work cut out for you.
Your downside with both routes is a nasty ~7-8mb overhead, even with compression (although I was able to get 6.5mb with lz compression in NSIS). If you are not creating distributable consumer-facing software then this may not be a problem for you.

Categories