Commit graph

3098 commits

Author SHA1 Message Date
Michael James Gratton
355e4d37c1 Make ClientWebView-based tests execute a bit faster.
* test/client/components/client-web-view-test.vala: New explicit tests
  for init'ing the WebContext and loading default resources.

* test/client/components/client-web-view-test-case.vala:
  Init the WebContext and load resources in the constructor rather than
  fixture setup, so it only happens once per suite, not once per
  test. Update subclasses to do same.

* test/client/composer/composer-web-view-test.vala: Add an explicit test
  for loading ComposerWebView resources.
2017-02-01 00:41:45 +11:00
Michael James Gratton
998fe70554 Update some test code attributions. 2017-02-01 00:41:45 +11:00
Michael James Gratton
d56b1c7f3b Don't build and run tests by default.
* CMakeLists.txt: Remove tests from default target list.

* test/CMakeLists.txt: Don't depend on the client executable, just the
  resources file.
2017-02-01 00:41:45 +11:00
Michael James Gratton
67762f22cb Really fix JS error calling ComposerWebView::save_selection.
* ui/composer-web-view.js: Increment must be in brackets.
2017-02-01 00:41:45 +11:00
Michael James Gratton
4f33fb288a Fix some more issues on earlier GTK versions.
* src/client/composer/composer-link-popover.vala:
  Gtk.Popover::set_default_widget is only available in GTK+ 3.18,
  Gtk.Widget::set_tooltop_text param can't be null in earlier GTK vala
  bindings.
2017-02-01 00:41:45 +11:00
Michael James Gratton
d41e74ffe3 Fix some compilation issues on older vala/gcc/GTK+ setups.
* src/client/composer/composer-link-popover.vala (ComposerLinkPopover):
  Replace calls to GTK 3.22-specific ::popdown() with ::hide().

* src/engine/util/util-js.vala (Geary.JS): Replace '\v' literal,
  unsupported on at least valac 0.30.1 and gcc 5.4, with ordinal equiv.
2017-02-01 00:41:45 +11:00
Michael James Gratton
d74fcd2e2c Fix conversation message not shrinking when collapsing quotes.
* ui/conversation-web-view.js (ConversationPageState::createControllableQuotes):
  Since WK does not want to seem to reduce the value of offsetHeight for
  the HTML element when a quote is collapsed, calculate the difference
  and manually update the preferred height.

* ui/client-web-view.js (PageState::updatePreferredHeight): Allow the new
  preferred height to be passed in as a param.
2017-02-01 00:41:45 +11:00
Michael James Gratton
8bf68bd345 ComposerLinkPopover UI polish.
* src/client/composer/composer-link-popover.vala
  (ComposerLinkPopover::show): Focus URL entry on being shown.

* ui/composer-link-popover.ui: Replace URL entry text label with an
  accessibility name. Refine the tooltip for the insert button, add notes
  to translators about it.
2017-02-01 00:41:45 +11:00
Michael James Gratton
5163b5198d Stop the insert link popover being dismissed when selecting text.
* src/client/composer/composer-web-view.vala (ComposerWebView): Add
  ::save_selection and ::free_selection to allow the selection to be
  saved when inserting a link. Thunk calls to JS.
  (ComposerWebView::insert_link): Add selection id param, pass through to
  JS.

* src/client/composer/composer-widget.vala
  (ComposerWidget::new_link_popover): Manage saving the editor's
  selection, passing its id when inserting a link, freeing it
  again. Convert into an async method so we can wait for the selection id
  to get back from the WebProcess, update call sites.
  (ComposerWidget::on_insert_link): Disconnect and reconnect selection
  changed signal so the popover isn't dismissed when the selection does
  change/

* ui/composer-web-view.js (ComposerPageState): Implement new
  ::saveSelection, ::freeSelection and selectionId param on ::insertLink.
2017-02-01 00:41:45 +11:00
Michael James Gratton
7f75a7e944 Fix messages with "html { height: 100%; }" set getting 1px-high views.
Partially reverts commit d4e2b84.

* ui/conversation-web-view.css: Reinstate triggering CSS 2.1 §
  10.6.7. for the HTML element.
2017-02-01 00:41:45 +11:00
Michael James Gratton
5624269386 Ensure strings passed to WebProcess via JS get escaped.
* src/client/components/client-web-view.vala (ClientWebView): Add ::call
  method that takes a Callable object. Replace all existing uses of
  ::run_javascript with that.

* src/engine/util/util-js.vala (Geary.JS): Add ::escape_string function,
  Callable object for constructing safe, well-formed JS calls.
2017-02-01 00:41:45 +11:00
Michael James Gratton
c1ceaa9868 Clamp ConversationWebView height again to avoid crashes displaying large images. 2017-02-01 00:41:44 +11:00
Michael James Gratton
3e203a9c19 Set a specific disk cache dir for the web process.
* src/client/application/geary-controller.vala
  (GearyController::open_async): Pass new cache dir through to
  ClientWebView::init_web_context. Update avatar cache dir name to remove
  redundancy.

* src/client/components/client-web-view.vala
  (ClientWebView::init_web_context): Add additional cache dir para and
  update call sites. Use to construct a WebsiteDataManager
  instance. Construct a new WebContext using the data manager, and use
  that instead of the default one when creating new ClientWebView
  instances.
2017-02-01 00:41:44 +11:00
Michael James Gratton
7135f3b2fb Make embedded composer scrolling resebmle something closer to 0.11's.
* src/client/composer/composer-embed.vala: Use scroll events captured on
  the composer to manage the height of the composer, and forward through
  to the conversation viewer's scrolled window and the editor as
  needed. Remove code dependent on the editor having a scrolled
  window (it doesn't) or access to the DOM (we don't).
2017-02-01 00:41:44 +11:00
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
9e171d0db1 Remove composer's scrolled window since WebView now scrolls internally.
We can't easily wrap ComposerWebView in a GtkScrolledWindow, since we
don't any notifications that the cursor has moved offscreen and hence the
view needs to be scrolled, so let the view do its own scrolling.

* ui/composer-widget.ui: Replace editor_scrolled with editor_container,
  update uses.
2017-02-01 00:41:44 +11:00
Michael James Gratton
6433582903 Only use HTML preferred height for conversation web view, not composer's.
* src/client/components/client-web-view.vala
  (ClientWebView::preferred_height): Make preferred_height a public
  property so it can be accessed outside the class. Move
  ::get_preferred_height and ::get_preferred_width to
  ConversationWebView. Tidy up ::on_preferred_height_changed a bit.
2017-02-01 00:41:44 +11:00
Michael James Gratton
0541436a77 Add some missing files and fix some ordering issues in po/POTFILES.in. 2017-02-01 00:41:44 +11:00
Michael James Gratton
b24291defe Break containing blockquotes when Enter pressed in composer.
* ui/composer-web-view.js (ComposerPageState): Break any blockquote
  elements under the cursor when Enter is pressed, unless Shift is also
  down.

* src/client/web-process/util-composer.vala: Removed, no longer used.
2017-02-01 00:41:44 +11:00
Michael James Gratton
c2ebfa1e39 Disable ComposerWebView UI and signals while it is being modified tosend. 2017-02-01 00:41:44 +11:00
Michael James Gratton
848558f368 Reenable converting plain text URLs to links in HTML documents.
* src/client/composer/composer-web-view.vala (ComposerWebView): Rename
  ::linkify_document since it really only applies to editor content. Make
  an asyc method so we can wait until its finished. Update call
  sites. Thunk call to JS.

* src/client/web-process/util-composer.vala,
  src/client/web-process/util-webkit.vala: Remove unused code.

* ui/composer-web-view.js (ComposerPageState):  Add ::linkifyContent
  method and ::linkify static method. Add unit tests.
2017-02-01 00:41:44 +11:00
Michael James Gratton
e22ece508c Replace two composer IPC calls for indenting with a single one.
* src/client/composer/composer-web-view.vala (ClientWebView): Replace
  ::undo_blockquote_style with ::indent_line.

* src/client/composer/composer-widget.vala (ComposerWidget::on_indent):
  Call new ::indent_line method, rather than doing a execCommand and a
  second JS thunking call to fix the markup.

* ui/composer-web-view.js: Also replace ::undoBlockquoteStyle with new
  ::indentLine method. Add unit test.
2017-02-01 00:41:44 +11:00
Michael James Gratton
e06a73ebd6 Make web process extension console logging a bit less verbose. 2017-02-01 00:41:44 +11:00
Michael James Gratton
e0bff994fa Reenable composer attachment keyword checking.
* src/client/composer/composer-web-view.vala (ComposerWebView): Add
  ::contains_attachment_keywords that thunks to JS, remove uneeded
  ::get_block_quote_representation method.

* src/client/composer/composer-widget.vala (ComposerWidget): Remove
  attachment keywork checking related code, just call new method on
  editor to do the check.

* src/client/web-process/util-composer.vala,
  src/client/web-process/util-webkit.vala: Remove uneeded code.

* ui/composer-web-view.js (ComposerPageState): Implement new
  ::containsAttachmentKeyword method based on previous code. Add unit
  tests.
2017-02-01 00:41:44 +11:00
Michael James Gratton
3e36b5e961 Fix composer selecting whole lines when trying to select a word.
* src/client/composer/composer-web-view.vala
  (ComposerWebView::button_release_event): Chain up to the correct parent
  method.
2017-02-01 00:41:44 +11:00
Michael James Gratton
48d92fa67c Let focus escape composer web view using Ctrl+Tab/Ctrl+Shift+Tab.
* src/client/composer/composer-widget.vala: Let default keyboard
  shortcuts handle focus move.

* ui/composer-web-view.js: Don't consume Tab presses with Crtl/Alt/Meta
  modifiers.
2017-02-01 00:41:44 +11:00
Michael James Gratton
dec06d93be Clean up how composer loads content into its web view.
The main gist of this is to ensure that the composer's widgets are
constructed seperately to loading its content, and that we only ever call
ComposerWebView::load_html precisely once per composer instance.

* src/client/composer/composer-widget.vala: Remove referred message,
  quote text and draft flag param from constructor signature, move any
  calls that loaded data from them to new load method. Don't load
  anything into the editor here. Make loading the signature file async,
  and call new ComposerWebView::updateSignature method on the editor to
  update it.
  (ComposerWidget::load): New async message for loading content into the
  composer. Move related code from the constructor and GearyController
  here, make methods that were previously public for that private
  again. Tidy up calls a bit now that we have a single place from which
  to do it all, and can understand the process a bit better.
  (ComposerWidget::on_editor_key_press_event): Don't reload the editor to
  remove the quoted text, call new ComposerWebView::delete_quoted_message
  method on it instead.

* src/client/composer/composer-web-view.vala
  (ComposerWebView): Add ::delete_quoted_message ::update_signature
  methods, thunk to JS.
  (ComposerWebView::load_html): Add quote and is_draft parameters,
  construct HTML for the composer using apporporate spacing here, instead
  of relying on all the disparate parts from doing the right thing.

* src/client/application/geary-controller.vala
  (GearyController::create_compose_widget_async): Load composer content
  after adding it to the widget hierarchy, set focus only after
  everything is set up.

* src/engine/rfc822/rfc822-utils.vala (quote_email_for_reply,
  quote_email_for_forward): Don't add extra padding around quoted parts -
  let callers manage their own whitespace.

* test/client/components/client-web-view-test-case.vala
  (TestCase:load_body_fixture): Make HTML param non-nullable, update
  subclasses.

* ui/composer-web-view.js (ComposerPageState): Add ::updateSignature and
  ::deleteQuotedMessage method stubs.
2017-02-01 00:41:44 +11:00
Michael James Gratton
721ecd892e Fix composer web view not being focused on reply. 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
78d116d054 Update deceptive link popover to provide context and advice. 2017-02-01 00:41:44 +11:00
Michael James Gratton
2b5f94da7d Reenable basic deceptive link highlighting.
* bindings/vapi/javascriptcore-4.0.vapi (Object::get_property): Fix
  return type.

* src/client/conversation-viewer/conversation-message.vala (GtkTemplate):
  Hook up to new deceptive_link_clicked signal, remove old DOM-based
  implementation.

* src/client/conversation-viewer/conversation-web-view.vala
  (ConversationWebView): Add new deceptive_link_clicked signal and
  DeceptiveText enum, listen for deceptiveLinkClicked JS message and fire
  signal when received.

* src/client/util/util-webkit.vala (WebKitUtil): Add to_object util function.

* src/engine/util/util-js.vala (Geary.JS): Add to_object and get_property
  util functions.

* ui/conversation-web-view.js (ConversationPageState) Listen for link
  clicks, check for deceptive text and send message if found. Add unit
  tests for deceptive text check.

* test/js/composer-page-state-test.vala: Move ::run_javascript to parent
  class so new ConversationPageStateTest class can use it, adapt call
  sites to different parent signature.
2017-02-01 00:41:44 +11:00
Michael James Gratton
69da046ff3 Rework util code for extracting string/double values from JS.Values.
* src/client/util/util-webkit.vala (to_number, to_string): Move code for
  extracting actual vales to functions in engine/util/util-js.vala,
  rework to use those functions.
2017-02-01 00:41:44 +11:00
Michael James Gratton
b47899ac69 Fix conversation message link tooltips appearing in the wrong place.
* src/client/conversation-viewer/conversation-message.vala
  (ConversationMessage::on_mouse_target_changed): Unset the tooltip text
  when pointer exits a link.
2017-02-01 00:41:44 +11:00
Michael James Gratton
ab4fec91be Enable editing a link by clicking on it.
* src/client/composer/composer-widget.vala
  (ComposerWidget::on_button_press): Show a link popover on button
  release.

* src/client/composer/composer-web-view.vala (ComposerWebView): Add
  button_release_event_done signal to work around WK eating mouse events,
  fire it after default processing has occurred.

* ui/composer-web-view.js: Don't bother selecting a link on click, we
  are handling insertion and deletion without it fine now. Just cancel
  the event's default so link clicks are not activated.
2017-02-01 00:41:44 +11:00
Michael James Gratton
e4f50e1c36 Implement ComposerWebView::insert_link and ::delete_link.
* src/client/composer/composer-web-view.vala (ComposerWebView): Call
  new ComposerPageState methods for ::insert_link and ::delete_link.

* ui/composer-web-view.js (ComposerPageState): Add new ::insertLink
  and ::deleteLink methods, handle linking/unlinking both the
  current selection and the link under the text cursor, if nothing
  is selected.
2017-02-01 00:41:44 +11:00
Michael James Gratton
c476fdc6d1 Replace composer link dialog with a popover.
* src/client/composer/composer-link-popover.vala: New GtkPopover subclass
  for creating/editing links.

* src/client/composer/composer-web-view.vala (EditContext): Add is_link
  and link_uri properties, decode them from the message string, add
  decoding tests.
  (ComposerWebView): Add some as-yet un-implemented methods for
  inserting/deleting links.

* src/client/composer/composer-widget.vala (ComposerWidget): Add
  cursor_url for storing current text cursor link, update it from the
  cursor_context_changed signal param, rename hover_url to pointer_url to
  match. Add link_activated signal to let user's open links they are
  adding, hook that up in the controller. Rename
  ::update_selection_actions to ::update_cursor_actions, since that's a
  little more apt now, also enable insert link action if there is a
  cursor_url set as well as a selection. Remove ::link_dialog, replace
  with ::new_link_popover, hook up the new popover's signals there as
  appropriate.
  (ComposerWidget::on_insert_link): Create and show a lin popover instead
  of a dialog.

* ui/composer-web-view.js: Take note of whther the context node is a link
  and if so, also it's href. Include both when serialsing for the
  cursorContextChanged message. Add serialisation tests.

* ui/composer-link-popover.ui: New UI for link popover.
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
320134783c Add Geary.Inet::is_valid_display_host and tests. 2017-02-01 00:41:44 +11:00
Michael James Gratton
53caf43fca Replace ad-hoc ComposerWebView cursor signal param w/ structured object.
This lets us notify of more cursor editing context state in the future
without changing the signal signature.

* src/client/composer/composer-web-view.vala (ComposerWebView): Replace
  cursor_style_changed signal and cursorStyleChanged JS message with
  cursor_context_changed signal and cursorContextChanged message, add new
  EditContext inner class and pass as arg to new signal, update call
  sites. Move parsing of JS message to new inner class. Add unit tests,
  fix a font-family bug revealed by tests.

* ui/composer-web-view.js (ComposerPageState): Replace cursorFontFamily
  and cursorFontSize with a cursor context and new EditContext object to
  encapsulate them, update them from a node and serialise them. Add unit
  tests.
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
4e9104a79b Convert ComposerWidget destroy handler back to an overridden method. 2017-02-01 00:41:44 +11:00
Michael James Gratton
ceb6400e1c Ensure composer selection actions are not enabled when first opened.
* src/client/composer/composer-widget.vala (ComposerWidget): Rename
  on_selection_changed to update_selection_actions, call as needed. Tidy
  action init methods a bit.

* src/client/components/client-web-view.vala (ClientWebView): Add new
  has_selection property and keep it updated.
2017-02-01 00:41:44 +11:00
Michael James Gratton
f27dea1318 Update some composer action tooltips. 2017-02-01 00:41:44 +11:00
Michael James Gratton
b1d4eaa32f Implement milliseconds ctor and tests for Geary.TimeoutManager. 2017-02-01 00:41:44 +11:00
Michael James Gratton
b20b3cafad Update composer's draft manager lifecycle management.
* src/client/composer/composer-widget.vala
  (ComposerWidget::initialize_actions): Disable close-and-save by
  default, opening draft manager will enable it if needed.
  (ComposerWidget::restore_draft_state_async): Update doc comment noting
  use constraints, remove account param since we should be using the
  instance's instead. Update call site.
  (ComposerWidget::open_draft_manager_async): Don't try to close the
  manager beforehand, we should be able to manage that externally.
  (ComposerWidget::reopen_draft_manager_async): New async method to
  handle closing and reopening the draft manager in the appropriate
  order, since it's one caller is not async.
  (ComposerWidget::discard_and_exit_async): Only attempt to discard the
  draft if we have a draft manager. We need the guard since this may also
  get called even if drafts are not being saved.
  (ComposerWidget::set_header_recipients): Don't flag draft as having
  changed, these issues should only be cosmetic.
  (ComposerWidget::on_from_changed): Move to a more appropriate location
  in the source, just call ::reopen_draft_manager_async instead of trying
  to handle it here.
2017-02-01 00:41:44 +11:00
Michael James Gratton
f8957c4d7a Ensure draft is saved when envelope (from, to, etc) changes. Bug 726290.
* src/client/composer/composer-widget.vala (ComposerWidget): Rename
  subject changed handler to something more generic, hook that up to the
  to/cc/bcc & reply_to entries.

* ui/composer-widget.ui: Hook up multiple to on_envelope_changed, make
  subject entry use that as well.
2017-02-01 00:41:44 +11:00
Michael James Gratton
836efc926e Tidy up ComposerWidget::should_close().
* src/client/composer/composer-widget.vala (ComposerWidget): Add
  `can_save` property that defined what the composer's reqwuirements for
  being able to save a draft.
  (ComposerWidget::should_close): Use can_save rather than should_save to
  determine which confirmation dialog to show. When keeping, only save if
  we need to. Split up handling responses from 2 and 3 button dialogs so
  it's more clear what is going on in each case.
2017-02-01 00:41:44 +11:00
Michael James Gratton
034727cc04 Minor draft-related code cleanup. 2017-02-01 00:41:44 +11:00
Michael James Gratton
f4b7e69545 Only save a new draft if the current draft has not been saved.
* src/client/composer/composer-widget.vala (ComposerWidget): Add
  ::is_draft_saved field, update it as the draft manager's state changes,
  or if the message has been changed. Rename ::can_save to ::should_save
  to better reflect what it is used for, don't allow saving if a draft
  has been saved. Rename update_draft_state as a proper method, use it
  update initial state after opening draft manager, tidy up location of
  draft signal handlers.
2017-02-01 00:41:44 +11:00
Michael James Gratton
58b76ba958 Close the composer if the message is blank. Bug 743970. 2017-02-01 00:41:44 +11:00