42 Commits
Author SHA1 Message Date
Philip Peitsch 85d3d09fee Use a multi-line text input trap so text2speech pauses for paragraphs
Screen readers tend to read input text elements as single lines, and do
not pause on new lines. Using a text area instead encourages some of these
to pause more naturally on paragraph boundaries.
2014-08-01 01:07:05 +10:00
Philip Peitsch 767a1934f3 Ensure a caret doesn't receive any new events after destroy is invoked
Deleting the caret before calling ensures there is no way for any external
sources to get access to the soon-to-be destroyed caret.

As part of tracking this down, scheduled tasks will now throw an error
if an attempt is made to trigger the task (either delayed or immediate)
after the particular instance has been destroyed.

This then showed that functions bound to browser events swallow errors
quietly, so additional logging was added to the EventManager delegation
code to ensure errors generated when processing an event are logged.
2014-06-11 20:33:32 +10:00
Friedrich W. H. Kossebau 1e2a4a8323 Normalize license headers of the webodf.js source files
* remove @license tag (to prevent Closure compiler keeping the comment)
* use copyright@kogmbh.com email address everywhere
* remove "additional permission", to be added only to released webodf.js
* separate license header by empty line from following content
2014-06-02 12:19:05 +02:00
Friedrich W. H. Kossebau fd020eee3f Use Error objects in callback passed to "destroy" methods
The currently plain undefined objects are not useful at all, because
the properties are undefined.
2014-04-11 13:53:10 +02:00
Philip Peitsch 37df608819 Unsubscribe event delegates when the EventManager is destroyed
To make this feasible, a consistent interface has been added to
compound and normal event delegates. This allows better impl
hiding from the rest of the EventManager class.
2014-03-26 10:44:50 +11:00
Philip Peitsch 1876e50626 Make compound event signal name less generic 2014-03-26 10:44:50 +11:00
Philip Peitsch 008c6e2513 Inline EventManager.blur as all uses are now internal 2014-03-26 10:44:30 +11:00
Philip Peitsch d2b7d63905 Move control of event trap inside the EventManager
Management of the event trap is not related to the IME. Moving the
coordination of the disabled and readOnly flags inside the EventManager
better hides these concepts from external consumers.
2014-03-26 10:41:22 +11:00
Philip Peitsch 7a6483495a Allow the event trap to receive focus in read-only mode
A disabled element is not able to become the document's activeElement.
The better way of setting the event trap to non-editable is through
the readOnly flag. This still allows focus to be passed to the trap.

During a mouse down event, the event trap should be disabled however
to ensure it doesn't capture the window selection.
2014-03-26 10:41:22 +11:00
Friedrich W. H. Kossebau 6232bd0917 prefix "draggable" element classname with "webodf-" 2014-03-10 15:43:48 +01:00
Aditya Bhatt db41d92cfa Inject srcElement property in CompoundEvents
for IE
2014-03-07 18:45:52 +01:00
Aditya Bhatt 47c1dd4e3c Avoid timer leaks: store and delete timers
in and from an object in the emitLongPressEvent
proxy.
2014-03-07 18:45:52 +01:00
Aditya Bhatt 77dcbf564a Just in case, to prevent any leaks due to interrupted
gestures, clear all longpress timers on EventManager.destroy()
2014-03-07 18:45:52 +01:00
Aditya Bhatt 50c6f3c194 Make EventManager adds a class touchEnabled
to the canvas element when it detects a touch
event (because simply sniffing for the existence
of touch events is not reliable).
2014-03-07 18:45:52 +01:00
Aditya Bhatt 92418f5eaf Make selections touch-modifiable with handles.
Two new compound events:
* 'drag', which depends on 'touchstart', 'touchmove',
and 'touchend. It fires whenever a finger is placed
on an element with class 'draggable', and then moved.
* 'dragstop', which depends on 'drag' and 'touchend'.
It fires whenever the finger is lifted after a drag
on a draggable element.

SessionController, upon encountering a drag event on
a selection handle, updates the shadow cursor's selection
to match the one prescribed by the handle movement, thus
being very fast.

When a dragstop event is encountered, the selection of
the shadow cursor is fed to the local member's cursor
via SelectionController, thus utilizing an op.
2014-03-07 18:45:52 +01:00
Aditya Bhatt 6f5d5fcb33 Add a CompoundEvent class which represents
an event that can be represented as a logical
composition of several events working together.

As a first usage of this class, the 'longpress' event
is introduced.
This event fires once when a finger is placed against the
screen for 400 milliseconds without moving or lifting.

Select a word when long-pressing on it.
2014-03-07 16:42:51 +01:00
Philip Peitsch d56180e1bc Unbreak display of IME text during composition
The text was not appearing when composing via the IME. It would not show
in the document until after the composition was complete.
2014-03-02 14:27:34 +11:00
Philip Peitsch 59c7af14c5 Subscribe to canvas events rather than sizer element in EventManager
The sizer element is replaced when an undo is performed, causing no
mouse move events to be reported after an undo. This breaks the shadow
cursor display.

There is no particular reason 67c1c23 changed the event binding to use
the sizer rather than the canvas element other than for consistency
with where the event trap was being added, so it is safe to revert
this particular modification.
2014-02-27 13:33:23 +11:00
Aditya Bhatt bad4703d50 Introduce IOSSafariSupport: Suppress auto-scrolling
on click-to-move when keyboard is open.

This is done by momentarily hiding and displaying
the eventTrap when the keyboard is opening.

IOSSafariSupport is a drop-in class that should
make webodf function well in iOS Safari without
having to do any special platform handling anywhere
else in the code.
2014-02-24 17:51:58 +01:00
Aditya Bhatt 1038583e85 Switch eventTrap from a <div> to an <input>
This prevents the appearance of various
'contextual' entries in a tooltip over
the caret in iOS.
2014-02-24 12:55:35 +01:00
Aditya Bhatt 67c1c23c24 Make only EventManager handle eventTrap in the
DOM.
Restore the eventTrap and focus on undo.
2014-02-20 17:35:09 +01:00
Friedrich W. H. Kossebau f7aa96ecd2 Add gui.EventManager.destroy() 2014-02-12 01:23:53 +01:00
Jos van den Oever 8e0b32525a Fix nullablility in a number of places.
And add a few unrelated clarifying comments.
2014-02-11 09:12:20 +01:00
Jos van den Oever f9734f5633 Make gui.EventManager 100% typed. 2014-02-08 10:37:22 +01:00
Jos van den Oever a9e64e645f Remove circular dependency between OdtDocument and OdtCursor.
OdtCursor does not depend on OdtDocument any more. In fact, it is not specific
to ODF any more so at some point it could be renamed.
2014-02-05 14:24:25 +01:00
Philip Peitsch 74a8df16c8 Correct subscription to the blur event
The blur event should always be on the event trap, as the event should
indicate when the local input is no longer active.
2014-02-03 21:53:01 +11:00
Friedrich W. H. Kossebau d2671e2a00 @returns -> @return 2014-01-31 15:33:43 +01:00
Philip Peitsch f01758db04 Use the textInput event to detect unhandled characters on Chrome & Safari
The textInput event provides a more accurate view of the resulting text
from a key press on Chrome and Safari. Use this as the fallback if the
key press event is ignored (e.g., user is inputing character code using
the Mac OS option key or Windows alt key).
2013-12-20 00:30:23 +11:00
Philip Peitsch 372485885a Workaround Safari post-composition key press event error
When composition session is ended on Safari under MacOS by pressing
another text char, Safari incorrectly reports the next keypress event’s
“which” value as the last compositionend data, rather than the new key
that was pressed.
2013-12-18 11:05:32 +11:00
Philip Peitsch 8b6ef8f6ff Support text input using the OS’s IME system
This change extends the use of the event trap to allow in-line character addition
using the OS's IME. The event trap will now be moved to within the local user's
cursor block, and will become visible when a composition start event is detected.

This has been tested on Chrome, FF & Safari on all platforms. In addition, this
enables support in FF on Android.

Known issues
- No IME support on Chrome under Linux. The compositionend event emitted by Chrome
contains no data, so the input character can't be detected.
2013-12-18 11:05:32 +11:00
Philip Peitsch be6c4379f0 Let EventManager.focus restore positions for all scrollable parents
Scrollable parents that had no current scroll offset were being ignored.
This meant that the view could end up reset at a non-0 scroll offset when
focus was restored to the event trap.
2013-12-18 11:05:32 +11:00
Philip Peitsch c665b1a57f Workaround for Firefox selection.collapse bug
Attempting to collapse a selection if a content editable element is the
current activeElement for the document will cause the collapse call to
throw an exception.

https://bugzilla.mozilla.org/show_bug.cgi?id=773137
https://bugzilla.mozilla.org/show_bug.cgi?id=787305
2013-12-18 11:05:31 +11:00
Philip Peitsch a5173eaf71 Don't synchronize browser & WebODF selections unnecessarily
The window selection only needs to be synchronized with WebODF on a
mouse down operation. In all other cases, the selection doesn't need to
be maintained. Removing the selection most of the time significantly
helps performance as there is heavy costs to modifying part of a DOM
tree that is selected.

In order to allow cut/copy to continue to function, an event trap was
necessary that "holds" the selection after mouse-up. This is set as
content editable to allow the cut/copy events to be fired in Firefox and
Safari.
2013-12-05 17:35:42 +11:00
Philip Peitsch 1b72f4c35f Only process each mouse up & down event once at either canvas or window
Internet explorer will only trigger mouse events at the window level. If
the handler is bound to both window and canvas however, the event will
be processed twice in every other browser.

A solution to this is to track manually (without affecting the bubble or
other features on the event) that an event has been processed, and don't
process it a second time.
2013-11-21 01:50:23 +11:00
Philip Peitsch 571bb6366e Bind window-related events on direct element as well (IE compatibility)
These events will not bubble up to the window if consumed by the canvas
element.
2013-11-19 20:25:17 +11:00
Friedrich W. H. Kossebau c2a795e668 Update link to repo: now https://github.com/kogmbh/WebODF/ 2013-10-23 18:20:30 +02:00
Friedrich W. H. Kossebau 508570dab8 Add copy of the AGPL3 to sources (+ add to created zip files) 2013-10-21 17:55:16 +02:00
Philip Peitsch f4cc324fdf Ensure the tabIndex is reset when the local user's caret is re-added after undo/redo
During the recent event & focus refactor, the tab index was being set on
initialisation of the EventManager class, and would then be unset when
the local caret was removed. This meant that no new events would be sent
to WebODF (e.g., typing) after an undo.
2013-10-11 12:35:10 +02:00
Philip Peitsch a6dedeed4f Add additional scroll handling when canvas regains focus
The scroll position was only being restored if a local operation was
generated as part of the resume focus. Additional data needs to be saved
and restored of focus is simply stolen and then returned.

If no parent elements have a non-zero scroll, there is no offsets to
restore.
2013-10-09 23:22:11 +11:00
Philip Peitsch 04a5bee3b4 Re-implement focus-without-scroll behaviour in Chrome
Previous fix attempt for issue #44 had the unintented side effect of
stopping shift+click from expanding the selection (issue #109).

The scroll-on-change behaviour has actually already been modified as
part of 90d6776. The delay put in to CaretManager.ensureCaretVisible now
ensures the caret is scrolled into view correctly once focus has been
properly set. This eliminates the need for the hidden event trap.

Fixes issue #109

Relevant test:
https://chromium.googlesource.com/chromium/blink/+/ae8d18613905f501a3ce9ba83193fe77e920afbf/LayoutTests/fast/scrolling/scroll-element-into-view.html
2013-10-09 20:11:05 +11:00
Friedrich W. H. Kossebau 21f6a42d98 Fix crash in gui.EventManager.unsubscribe(), splice called on wrong object 2013-10-04 23:38:52 +02:00
Philip Peitsch 84e221082f Allow event focus to be returned to SessionController without scrolling to the top of the ODF canvas
Element.focus() has additional logic that attempts to bring the top of
the element into view. This causes the a document that has been vertically
scrolled to reset back to the top of the document each time an Editor
button is clicked.

This redesign abstracts the event management away, and uses an invisible
div as the primary event trap. Because the div is always visible and
centred, the browser does not perform any scrolling. Non-bubbling events
are automatically forwarded from the event trap to subscribers.

Fixes Issue #44
2013-10-04 19:24:13 +02:00