Commit graph

23 commits

Author SHA1 Message Date
Michael Gratton
ec3057daf7 ConversationWebView: Fix plain text emails sometimes being too wide
Using `whitespace: pre-wrap` to format plain text email sometimes
causes additional width to be allocated by the plain text blocks that
then does not get used due to the constraints on the HTML element.
The allocated space remains however and hence an un-needed horizontal
scrollbar appears.

Using `break-spaces` instead seems to help since it allows breaks after
a space character, leading to the additional space not otherwise being
allocated.
2020-10-17 15:08:10 +11:00
Michael Gratton
7b0146274c Conversation.WebView: Convert to using messages for JS → client comms 2020-10-13 00:02:09 +11:00
Jonathan Haas
bfe504fed3 Make sure we match the whole link text as URL and not only some part. Add some symbols to be invalid in domains. Add 3 tests. 2019-04-27 11:52:51 +02:00
Konstantin Kharlamov
585c7ba5bc conversation-web-view: de-globalize a variable
Implicitly declared variables in JS are global by default.

Fixes LGTM warning: "Variable header is used like a local variable, but
is missing a declaration."

Signed-off-by: Konstantin Kharlamov <Hi-Angel@yandex.ru>
2019-03-23 13:42:36 +03:00
john
7a37a4650b Fix serveral things for the MR 2019-02-12 14:49:44 +08:00
john
6c53e003bc A small typo... 2019-02-10 12:37:19 +08:00
john
46cd8baed1 Avoiding add signal into the EmailRow, but translate seems hard to do since the webview is in the inside of message. 2019-02-10 12:19:05 +08:00
john
cb01fafe3f 成功定位坐标 2019-02-09 11:09:56 +08:00
Michael Gratton
0f554d2371 Fix select-quoting not preserving newlines in some cases
If the common ancestor of the quoted text is the plain-text-message DIV
itself, the isDescendant test fails and the style to preserve new lines
is not maintained. This adds a non-strict check to isDescendant and
enables that when checking the common ancestor node and a test case for
it.
2019-02-02 15:07:41 +11:00
Michael Gratton
c83f07a9f1 Minor tweaks for ConversationPageState.isDescendantOf
Use uppercase since that is what the DOM for HTML defaults to, use
nodeName rather than tagName for cases when there the check is false and
ancestor is the document element, add unit tests.
2019-02-02 15:07:41 +11:00
Alex Henrie
b9f984e65e Check class name in ConversationPageState.isDescendantOf 2019-01-08 20:15:48 -07:00
Alex Henrie
698f61e6e5 Print common headers when printing messages 2018-09-26 18:43:46 -06:00
Michael Gratton
00e7834082 Revert "Merge branch 'print-headers' into 'master'"
This reverts merge request !45
2018-09-23 02:18:24 +00:00
Alex Henrie
2b2c587e6c Print common headers when printing messages 2018-09-22 09:48:51 -06:00
Michael James Gratton
96c16d8b78 Fix more issues hiding/showing collapsed quotes.
* ui/conversation-web-view.js
  (ConversationPageState::createControllableQuotes): Only add control
  buttons if the quote is controllable. Calculat the height difference up
  front, not in the control button's click handler, so the value is
  correct.
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
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
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
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
a72d845b35 Fix some dumb bugs in ConversationPageState::getSelectionForQuoting().
* ui/conversation-web-view.js: Fix prviously brace-less if block
  indentation, minor cleanup.
2017-02-01 00:41:43 +11:00
Michael James Gratton
5b8c68f5fa Implement getting message selection for quoting and selection in WK2.
* src/client/conversation-viewer/conversation-web-view.vala
  (ConversationWebView): Remove has_selection method since we are
  using the signal to specify if a selection was found or not. Update
  call sites to use that.
  (ConversationWebView::get_selection_for_find,
  ConversationWebView::get_selection_for_quoting): Implement using calls
  to web process JS methods.

* src/client/application/geary-controller.vala
  (GearyController::create_reply_forward_widget): If we have a possible
  message view to quote from, handle constructing the compser widget
  asynchronously, when we know if we have a quote or not.

* src/client/conversation-viewer/conversation-viewer.vala:
  (ConversationViewer::on_find_mode_changed): Handle getting text
  selection for finds asynchonously.

* src/client/components/client-web-view.vala
  (ClientWebView::get_string_result): New helper for getting string
  values from JS calls.

* src/client/conversation-viewer/conversation-email.vala
  (ConversationEmail::get_selection_for_quoting,
  ConversationEmail::get_selection_for_find): Handxle errors when
  obtaining selections from a message view.

* src/client/conversation-viewer/conversation-message.vala: Remove
  methods that were simply passed through to the web view anyway. Update
  call sies.

* src/client/web-process/util-conversation.vala: Port all remaining
  functions to JS, remove.

* bindings/vapi/javascriptcore-4.0.vapi: Add methods needed to get
  strings out of WebKit.JavascriptResult instances.

* ui/conversation-web-view.js: Implement selection functions in JS, minor
  cleanup.
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