Commit Graph
27 Commits
Author SHA1 Message Date
Philip Peitsch b501f033f0 Only re-render the selection overlay once per batch of requests
Also, decrease the maximum latency between a render request and when the
update is performed to be 0ms. The previous value of 200ms was quite
noticeable when indenting or unindenting paragraphs.
2014-01-31 10:28:14 +11:00
Philip Peitsch 3f2b2f0fb9 Support different selection view renderers
In certain cases it is useful to be able to swap out the technique used
to render cursor selections on the document. For example, SVG polygon
based rendering interacts badly with mouse events on the WebKit build
shipped on MacOS X 10.7.5.
2013-12-19 01:55:51 +11:00
Aditya Bhatt 30794a6253 Switch to SVG polygons for drawing a SelectionView.
Adds an SVG overlay that takes no pointer-events,
and uses a polygon element inside to it draw
selections with stroke and fill of the user's
color.
Removes the 3 divs used previously.
2013-12-13 00:37:13 +01:00
Jos van den Oever 163562a84d Generate list of JavaScript files in CMakeLists.txt.
Some types needed to be fixed due to the new file order.
2013-11-29 18:33:28 +01:00
Jos van den Oever 3c96e17009 Make sure the cursor always has a Range. 2013-11-26 16:56:01 +01:00
Jos van den Oever cb406f1c16 A number for Cursor related type annotations. 2013-11-26 16:55:59 +01:00
Philip Peitsch da9d6ac006 Re-add the shadow cursor's selection on document undo
This is an interm fix until a "grown-up" undo stack arrives.

The current undo implementation for single user replaces the document
content, which causes OdfCanvas to entirely clear and replace all
children in the parent element.

Most overlays are unaffected as they are re-added when the cursor is
redraw. The shadow cursor is not an added cursor however, and so after
an undo it stops functioning.
2013-11-19 23:36:52 +11:00
Philip Peitsch 6c7ef6a423 Add virtual selection overlays to the same parent as the annotations view
Virtual selection overlays were being added to the office:document
element. This is inconsistent with most other non-document UI overlays.
2013-11-19 23:35:49 +11:00
Philip Peitsch c1a8a41077 Hide range vs node BCR logic inside DomUtils 2013-11-19 20:25:17 +11:00
Philip Peitsch 381f622373 Detect IE10's buggy range client rects for an empty node
IE reports 0 client rects for an empty element, even if the
element has pre-specified fixed dimensions.

As part of this, a more advanced quirk detection system has been put in
place to make these easier to track.
2013-11-19 20:25:17 +11:00
Philip Peitsch 02113bfcf9 Ensure all arguments are passed to the tree walker (IE compatibility) 2013-11-19 20:25:17 +11:00
Philip Peitsch 8bf0740bc3 Don't use text nodes as tree-walker roots (IE compatibility)
IE10 will throw an exception if the root passed
into a tree walker is a text node.
2013-11-19 20:25:17 +11:00
Philip Peitsch c8180264f2 Hide selection overlays for a region selection
A region selection is made when the user clicks directly on an image or
another object that will have a custom frame drawn around the target. In
this case, the selection overlay should not be drawn on top.
2013-11-06 23:03:53 +11:00
Philip Peitsch 83cce0107d Draw selection overlay over space characters when selecting backwards
Selections going backwards (to the left in a LTR language) were not
allowing character elements such as spaces to be selected, as the
selection view was incorrectly using the right-side of the selection
rectangle.

Unfortunately, in Chrome, a collapsed selection reports a width of 1px,
and using the left-side produces a rather odd looking overlap on the
previous character. To workaround this, the rectangle calculation now
uses the bounding client rectangle instead.
2013-11-06 23:03:53 +11:00
Philip Peitsch 608d144c84 Improve space selection rendering
Groups of spaces will be represented with space character elements which
are not considered or returned as part of the fetched text nodes. This
logic has now been adjusted to fetch all text elements, which will return
non-text node character element as well.
2013-11-06 23:03:52 +11:00
Philip Peitsch 49b1404b66 Improve robustness of virtual selection around collapsed whitespace
An individual range may have no client rectangles if it is not visible
on the screen. In text nodes, this often means a sequence of collapsed
whitespace, or discarded whitespace at the start or end of an element
with "display: block" properties (e.g., p or HTML div).
2013-10-29 20:21:51 +11:00
Philip Peitsch 0ff8872e91 Correct virtual cursor drawing location in FF when zoomed in or out
All virtual cursor calculations are now down using range bounding client
rects rather than element-based rectangles, so proper scaling can be
achieved.
2013-10-26 23:09:15 +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 0ef0f68407 Clean-up the selection view when removing it
When a cursor is removed from the document (e.g., exiting edit mode),
the most recent selection is left visible.

* Don't re-append the overlayBottom on destroy
2013-10-16 21:42:59 +11:00
Aditya Bhatt aeb1604e39 Added root-filtering of nodes in SelectionView.getFillerRect.
The filler rect is now calculated with extra
granularity, and getFillerRect now has different
code paths for various conditions. The computing
is quite fast because we do not walk over every
single node in the fillerRange, and only look
at the start and end siblings below the common
ancestor element in detail.
This fixes several annoying bugs:
* If you dragged a selection towards the right
just over a blinking cursor, it would extend
to the far right
* Drawing selections over annotation markers
caused them to have bad widths due to rects from
nodes that were not of the same root.
2013-10-15 11:44:24 +02:00
Aditya Bhatt 939517a74a Workaround for a webkit/blink bug where the clientRects
of a range that is collapsed at the last position of a
text node are empty.
This used to throw lots of errors when computing the
firstRect and lastRect in a SelectionView, when the mouse
moved near the ends of certain textnodes
2013-10-15 11:44:24 +02:00
Aditya Bhatt 958f3a0ccc Hide lastRect and fillerRect when the selection is just on one line 2013-10-15 11:44:24 +02:00
Aditya Bhatt dceba17489 Rerender visible SelectionViews when certain edits take place.
Adds a visible() method to SelectionView and rerenderSelectionViews to
SelectionViewManager.
2013-10-15 11:44:24 +02:00
Aditya Bhatt aae55aca50 * Add a new ShadowCursor class. This class is meant, for now, to only
hold the 'selected range' fed to it, like with any other OdtCursor. It
provides a minimal OdtCursor-like interface, with only the methods
absolutely required to make it work. It does not modify the DOM in any
way.
* Make the shadowCursor object an instance of ShadowCursor, not
OdtCursor. This is ideal because ShadowCursor does not modify anything
in the DOM, and therefore is safer and faster to use for tracking
browser selections. This makes backwards-selections work finally,
because now there are no anchor nodes to interfere with the selection
whilst dragging.
* With the introduction of the ShadowCursor, we no longer have the
selection range's endpoints coinciding the with beginning and end of the
respective startContainer and endContainer. Therefore, modify
getExtremeRanges to reflect this. If an endpoint of the selection range
does not lie within a TextNode, we latch on to the nearest text node
within.
* In the SessionController, call maintainShadowSelection() if the
selection might leak outside the allowed local root, so that the
window selection object remains root-confined.
* Clone ranges if they may be later modified.
Properly detach ranges once they are used in SelectionView, less
memory leaks.
2013-10-15 11:44:24 +02:00
Aditya Bhatt e94d3e431d Fix a little issue where partial selections of spans would select the
whole span, and add an explanation
2013-10-15 11:44:24 +02:00
Aditya Bhatt b426aab73f Add a SelectionView class that can be initialized with a cursor, a
SelectionViewManager that maintains SelectionView instances, and a
shadow cursor object that is an invisible caret-less cursor, fed to both
SessionController and SessionView, which follows the selection as it
changes.
Selections by each cursor are colored according to their memberid
2013-10-15 11:44:23 +02:00