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>
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.
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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.