Commit graph

13 commits

Author SHA1 Message Date
Michael James Gratton
5ff2d9b908 Calculate ClientWebView to include HTML element margins.
* ui/client-web-view.js (PageState::getPreferredHeight): Compute and use
  top and bottom when determining the height value.

* ui/conversation-web-view.css: Remove onerous style defaults now we
  can deal with HTML elements with margins.
2017-02-01 00:41:44 +11:00
Michael James Gratton
5dfcfe4c8e Update how ClientWebView HTML preferred size changes are sent to the app.
* ui/client-web-view.js (PageState): Use event listeners to send
  coalesced preferred height changes, rather than using polling. Call
  ::load on DOM loaded, not on complete page loaded, so in-place
  mutations take affect ASAP. Replace ::preferredHeightChanged with
  ::updatePreferredHeight method that checks that the height has changed
  before sending the message to the app.

* ui/composer-web-view.js: Remove loaded event handler, it's managed by
  the base class now.

* ui/conversation-web-view.js (ConversationPageState): Rename
  ::updatePreferredHeight to ::pollPreferredHeightUpdate to avoid name
  clash with parent class. Stop polling if no change has occurred after a
  number of repeated checks. Remove loaded event handler, it's managed by
  the base class now.
  (ComposerPageState::createControllableQuotes): Don't update preferred
  height at the end of the call since it will be handled by the DOM load
  event handler.
2017-02-01 00:41:44 +11:00
Michael James Gratton
805a052f1f Don't send JS selectionChanged message unless param value has changed. 2017-02-01 00:41:44 +11:00
Michael James Gratton
617dd45393 Remove use of underscores in client-web-view.js var names. 2017-02-01 00:41:44 +11:00
Michael James Gratton
636e514cda Minor code cleanup.
* src/client/components/client-web-view.vala (ClientWebView): Make some
  unnecessarily internal methods private.

* ui/*.js: Replace "var" with "let" where appropriate - i.e. almost
  everywhere.
2017-02-01 00:41:43 +11:00
Michael James Gratton
8864e2b7a7 Work around rendering quote controller buttons, enable expanding quotes.
* ui/conversation-web-view.js (ConversationPageState): Add
  ::updatePreferredHeight method to waitch for and update the web view's
  preferred height when it changes.
  (ConversationPageState::createControllableQuotes): Create quote
  controllers using the DOM so we can easily attach click handlers to
  it. Attach handlers to toggle the hide class and updated the preferred
  height.

* ui/client-web-view.js (PageState): Add ::getPreferredHeight method, use
  that to determine the preferred height of the page.

* ui/conversation-web-view.css: Import GTK+4 Adwaita button CSS to work
  around WebKitGTK+ Bug 166648. Tweak quote style a bit.
2017-02-01 00:41:43 +11:00
Michael James Gratton
431ebcb35f Re-implement message HTML cleaning in JS in the web extension for WK2.
* ui/conversation-web-view.js: New script, port old HTML cleaning code in
  vala to Javascript as new subclass of PageState. Instantiate that on
  page load.

* src/client/conversation-viewer/conversation-web-view.vala
  (ConversationWebView): Load and add new JS script for conversations.

* src/client/web-process/util-conversation.vala (Util.Conversation):
  Remove migrated and obsolete code.

* ui/client-web-view.js (PageState): Allow on-load behaviour to be
  overridden in subclasses.

* ui/CMakeLists.txt: Include new JS script.

* ui/conversation-web-view.css: Chase CSS class name changes.
2017-02-01 00:41:43 +11:00
Michael James Gratton
766d55e75d Reimplement selection_changed signal for WK2.
Add a "has_selection" param to avoid a second round-trip to the web
process to determine that.

* src/client/components/client-web-view.vala (ClientWebView): Add a
  selection_changed signal, register a JS message handler for the JS
  equivalent hook up firing the signal.

* src/client/web-process/web-process-extension.vala (GearyWebExtension):
  Send a JS selectionChanged message when the page's selection changes.

* src/client/composer/composer-widget.vala,
  src/client/conversation-viewer/conversation-email.vala,
  src/client/conversation-viewer/conversation-message.vala: Uncomment
  code that relied on the WK1 selection_changed signal, use signal param
  rather than DOM calls.

* ui/client-web-view.js: Implement sending the selectionChanged message.
2017-02-01 00:41:43 +11:00
Michael James Gratton
3068d1b0e5 Integrate preferred height JS code into PageState, tidy it up a bit.
* ui/client-web-view.js: Move emitPreferredHeightChanged() into PageState
  as ::preferredHeightChanged(). Add a explicit constructor, move
  instance properties into that. Add an interval timer to periodically
  update the preferred height until loaded.
2017-02-01 00:41:43 +11:00
Michael James Gratton
d002722a19 Re-implement remote image loading management for WebKit2.
* src/client/components/client-web-view.vala (ClientWebView): Register
  for new remoteImageLoadBlocked message from JS. Add new
  ::remote_image_load_blocked signal to notify when a remote image load
  was blocked. Add ::allow_remote_image_loading and ::load_remote_images
  methods to allow th app to manage image loading state.

* src/client/conversation-viewer/conversation-email.vala
  (ConversationEmail): Determine up front whether the message view should
  load remote images and flag that, rather than passing through the email
  flag and the contact store.

* src/client/conversation-viewer/conversation-message.vala
  (ConversationMessage): Rmeove contact_store and
  always_load_remote_images properties and related code, just let the
  parent email view advise whether remote images should be initially
  loaded and act accordingly. Look up to ClientWebView signal and methods
  to handle manual remote image loading management by the user. Remove
  some obsolete code.

* src/client/web-process/web-process-extension.vala (GearyWebExtension):
  Replace allow_prefix implementation for remote image management with
  explicit signalling to/from the application via JavaScript.

* ui/client-web-view.js: Add a new PageState object, add props and method
  to implement remote image loading management.

* ui/client-web-view-allow-remote-images.js: Monkeypatch to be used when
  remote images should be loaded by default.

* ui/CMakeLists.txt: Include new JS file.

* src/client/conversation-viewer/conversation-web-view.vala,
  src/client/web-process/util-conversation.vala,
  src/client/web-process/util-webkit.vala: Remove obsolete code.
2017-02-01 00:41:43 +11:00
Michael James Gratton
56651ed8c4 Inject ClientWebView script at document start.
* src/client/components/client-web-view.vala
  (ClientWebView::load_app_script): Set script injection time to the
  start of the document load.

* ui/client-web-view.js: Set an onload handler to report back the
  preferred height.
2017-02-01 00:41:43 +11:00
Michael James Gratton
26fe139e97 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.
2017-02-01 00:41:43 +11:00
Michael James Gratton
09c9a398f7 Load a default app script into ClientWebViews at construction time.
* src/client/application/geary-controller.vala
  (GearyController::open_async): Load the app script for ClientWebView at
  startup.

* src/client/components/client-web-view.vala
  (ClientWebView::ClientWebView): Ensure we actually have a
  UserContentManager instance to work with, add the app script to the
  manager for the instance.
  (ClientWebView::load_scripts): Actually load client-web-view.js.
  (ClientWebView::load_user_stylesheet): Helper method for this class and
  subsclasses for doing the actual script load from the app.

* ui/client-web-view.js: Add boilerplaye for new file.

* ui/CMakeLists.txt: Include client-web-view.js.
2017-02-01 00:41:43 +11:00