Initial pass at getting the HTML document's height from the web process.

* bindings/vapi/javascriptcore-4.0.vapi: Add some methods to
  GlobalContext for accessing JSValues as ints.

* src/client/components/client-web-view.vala
  (ClientWebView): Hook up UserContentManager script messages handler and
  handler implementation for "preferredHeightChanged", update the new
  preferred_height prop on the class, and queue a resize. Hook those
  values up to the GTK allocation machinery.
  (ClientWebView::get_int_result): Convenience method for getting an int
  from a JavascriptResult.
  (ClientWebView::get_preferred_height): Report back values as reported
  by messages from the script handler.
  (ClientWebView::register_message_handler): Convenience method for
  registering script messages handlers.

* src/client/conversation-viewer/conversation-web-view.vala
  (ConversationWebView): Remove now-redundant GTK allocation machinery.

* ui/client-web-view.js: Post a message to preferredHeightChanged when
  the page is sorta-kinda loaded.
This commit is contained in:
Michael James Gratton 2016-11-23 23:55:54 +11:00
parent 09c9a398f7
commit 26fe139e97
4 changed files with 62 additions and 34 deletions

View file

@ -6,6 +6,13 @@ namespace JS {
[CCode (cname = "JSGlobalContextRef")]
[SimpleType]
public struct GlobalContext {
[CCode (cname = "JSValueIsNumber")]
public bool isNumber(JS.Value value);
[CCode (cname = "JSValueToNumber")]
public double toNumber(JS.Value value, out JS.Value err);
}
[CCode (cname = "JSValueRef")]