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.
This commit is contained in:
Michael James Gratton 2017-01-19 01:48:03 +11:00
parent 617dd45393
commit 53caf43fca
5 changed files with 157 additions and 68 deletions

View file

@ -9,6 +9,7 @@ public class ComposerWebViewTest : ClientWebViewTestCase<ComposerWebView> {
public ComposerWebViewTest() {
base("ComposerWebViewTest");
add_test("edit_context", edit_context);
add_test("get_html", get_html);
add_test("get_text", get_text);
add_test("get_text_with_quote", get_text_with_quote);
@ -18,6 +19,14 @@ public class ComposerWebViewTest : ClientWebViewTestCase<ComposerWebView> {
add_test("get_text_with_nbsp", get_text_with_nbsp);
}
public void edit_context() {
assert(new ComposerWebView.EditContext("Helvetica,").font_family == "sans");
assert(new ComposerWebView.EditContext("Times New Roman,").font_family == "serif");
assert(new ComposerWebView.EditContext("Courier,").font_family == "monospace");
assert(new ComposerWebView.EditContext(",12").font_size == 12);
}
public void get_html() {
string html = "<p>para</p>";
load_body_fixture(html);