Commit graph

2725 commits

Author SHA1 Message Date
Ed Sanders bffa0df53f Prevent deletion of FocusableNodes from a collapsed selection
Instead select the node and require the user to press delete
again if they really meant to delete the node.

Also test cases!

Bug: 55336
Change-Id: I66520e18740e78ce6313f9b31bb575d06b91bea8
2013-10-09 17:41:31 +02:00
jenkins-bot 846414f215 Merge "Destroy test surfaces" 2013-10-08 09:19:03 +00:00
Ed Sanders c752215896 Destroy test surfaces
Also make sure surface observers are detached so they don't try to
poll the CE when it has been destroyed. This was causing exceptions
to be thrown in test runners.

Change-Id: Ic8864a73f3ee04da6018f552b1aa68748d7ffba7
2013-10-08 11:16:10 +02:00
jenkins-bot 3a9ca9260f Merge "Fix initialisation errors in EventSequencer" 2013-10-07 23:48:19 +00:00
David Chan 9004a66274 Fix initialisation errors in EventSequencer
ve.EventSequencer.js:
* Initialise listener lists to []
* Call afterLoop listeners even if there are no after listeners

Change-Id: I63a0bafa74f2c3135bd3ca75adc91a57c19319ed
2013-10-08 00:24:45 +01:00
Ed Sanders 972c9a46b7 Make the save dialog an actual dialog
Major changes:
* Create a MW specific save dialog class
* Widgetize save dialog elements
* Simplification of viewPageTarget

Minor changes:
* Added getWindow method to windowSet and setTitle methods to window class
* Add transition css properties to dialog styles

Bug: 48566
Bug: 50722
Bug: 51918
Bug: 52175
Bug: 53313
Change-Id: I8c0db01fb8477a9b3d3dfe2a6073ac67869ce40e
2013-10-07 15:59:00 -07:00
jenkins-bot 5a1a960b19 Merge "EventSequencer: New hooks for useful moments" 2013-10-07 22:24:13 +00:00
David Chan e515017827 EventSequencer: New hooks for useful moments
ve.EventSequencer.js - Implement new types of event listener:
* onLoop( f ) to set a listener for the start of the event loop
* afterLoop( f ) to set a listener for the end of the event loop
* afterOne( f ) to set a one-time listener for after an event
* afterLoopOne( f ) to set a one-time listener for the end of the event loop

Change-Id: Ie388e0e9edcfccaa20e04c649a8b85d028ddde9c
2013-10-07 22:21:21 +00:00
jenkins-bot 574264d2d5 Merge "The amazing mystery of scrollTop and onscroll" 2013-10-07 20:37:44 +00:00
Trevor Parscal 9303648406 The amazing mystery of scrollTop and onscroll
What I learned today:
* Window doesn't have a scrollTop property, body does (that's why animate
  doesn't work on window)
* jQuery.scrollTop() doesn't work on body (in firefox) but works on
  window everywhere
* jQuery.scrollTop() uses scroll offset, not the scrollTop property
* Body doesn't have an onscroll event, window does

What I really learned today:
* Browsers are very poorly designed

Objective:
* Make clippable elements properly resize in Firefox when scrolled

Diagnosis:
* Scroll events were not being emitted from the scrollable container
  after the merge of Ifec0dae598f7fd99270588bd8ca77777a07e9669 because
  such events are not emitted from body tags, only scrollable divs and
  windows
* jQuery.scrollTop was giving incorrect values when called on the body
  instead of the window, so also due to the aforementioned change, the
  clipping was being calculated incorrectly

Treatment:
* Add $clippableScroller property, which is either a scrollable div or
  the window (could this have side-effects if someone did something
  ridiculous like made the body absolutely positioned and overflow:auto?
  Yes, but I have no other option and that's a strange edge case don't
  you think?)
* Use $clippableScroller for listening to scroll events and getting the
  scrollTop value from jQuery

Bug: 55343
Change-Id: I819aba60b200059886b347115fda437b3dc9cb7a
2013-10-07 13:25:02 -07:00
jenkins-bot 1e0c24da49 Merge "Make dialogs, inspectors windows and window sets generic" 2013-10-07 18:55:07 +00:00
Trevor Parscal 4aa86d0f87 Make dialogs, inspectors windows and window sets generic
Objective:
* Remove surface dependencies in dialogs, inspectors, windows and window sets
* Introduce surface-specific versions of dialogs, inspectors and window sets

Change-Id: I2db59127d2085b02e173a3605e174317e419e213
2013-10-07 10:37:47 -07:00
jenkins-bot ac0f2ba092 Merge "Refactor out data processing from ve.dm.Document constructor" 2013-10-07 16:36:02 +00:00
Ed Sanders a8d84db0e8 Refactor out data processing from ve.dm.Document constructor
Also make collection of metadata and construction of nodes optional.

Change-Id: I02ba6d2199caccaf9fe9dcfba58eefa7b52c52b1
2013-10-07 17:26:21 +01:00
jenkins-bot 00b6de429b Merge "Use FlatLinearData for storing converter results" 2013-10-07 14:47:21 +00:00
Ed Sanders e9a8c62692 Remove PagedDialog from test files
Fix for patch I5efa2f893f4b which only removed one reference to the file.

Change-Id: I89b9f30ee8309e1cba0ed98a74238ba671b76a59
2013-10-07 10:57:42 +01:00
Ed Sanders 44b1fdebe4 Use FlatLinearData for storing converter results
Previously we returned ElementLinearData from the converter, then
stripped out the MetaLinearData. This meant that before processing
the ElementLinearData from the converter actually contained metadata
which is confusing.

The new document constructor stores the converter results in a
FlatLinearData object and simultaneously populates element and meta
data stores.

Also in this commit I have moved various methods from ElementLinearData
to FlatLinearData, from which ElementLinearData inherits.

Change-Id: I64561bde2c31d8f703c13ac7b0a0c5f7ade9f3d4
2013-10-06 20:27:32 +01:00
Ed Sanders 000cc4d6e3 Fixup for IconButtonWidget load order
Was loading out of order in test HTML.

Change-Id: Iac56fac0432ad634a3ce0c636c7b863b9ddc950e
2013-10-05 10:45:03 +01:00
jenkins-bot b4f415ecc4 Merge "Prevent context menu from flickering after FocusableNode redraw" 2013-10-05 00:26:00 +00:00
jenkins-bot b15374751e Merge "Toolbar action widgetization and UI refactoring" 2013-10-05 00:17:28 +00:00
Trevor Parscal 6ec34a3dee Toolbar action widgetization and UI refactoring
Objectives:

* Use widgets to render toolbar actions
* Remove labels next to help notices and edit notices buttons
* Add a close button to the help notices and edit notices

Overview:

* ve.ui.ButtonWidget is now abstract, use ve.ui.PushButtonWidget instead
* ve.ui.IconButtonWidget now inherits from ve.ui.ButtonWidget
* ve.ui.PopupWidget's display method no longer takes x and y arguments
* Fixup naming issues in MWCategoryPopupWidget
* Fixup naming issues with some ve-init-mw CSS classes
* Rename ve-mw/ui/styles/ve.ui.Widget.css to ve.ui.MWWidget.css
* Change uses of "callout" to "tail"
* Add hyperlink functionality to buttons
* Make buttons accessible through focusing, but make unfocusable by
  clicking
* Add head option to popup for rendering a title and close button

Bug: 52386
Change-Id: Iea2c8df1be64d40f9c039873d89ee540cc56e687
2013-10-04 16:26:13 -07:00
Trevor Parscal 4a459e40a8 Remove surface dependencies from lookup widget
Objective:
* Use <body> instead of the closest surface overlay as the default
  overlay (wasn't actually being used anyway)
* Use this.$.offsetParent instead of closest surface when measuring
  parent frame offset to position text input menu

Change-Id: I04fc5ff1da4bafd342093922a5bd3b3a784b327c
2013-10-04 21:16:47 +00:00
jenkins-bot e1c49ace99 Merge "Refactor ve.ui.PagedDialog" 2013-10-04 20:25:43 +00:00
Kyle Florence 4efc6cadb7 Refactor ve.ui.PagedDialog
This commit extracts the page and outline handling logic from
ve.ui.PagedDialog (RIP) and moves it into two layouts: ve.ui.PagedLayout
and ve.ui.PagedOutlineLayout, respectively. These layouts are now implemented
inside the dialogs that used to mixin the ve.ui.PagedDialog class. This
brings a much cleaner separation of concerns between Dialogs and Layouts
and allows the use of page handling logic without the accompanying
outline logic.

Change-Id: I5efa2f893f4b7e962438b3aff34b737573bbd5ca
2013-10-04 12:09:15 -07:00
jenkins-bot b36c401ec7 Merge "Get rid of 'reversed' flag on transactions" 2013-10-04 06:18:06 +00:00
Roan Kattouw 10bf7b34ca Followup 571d6cac: when the selection changes, undo highlights
Ignoring all bounced change events led to the logic for unhighlighting
the previously selected FocusableNode being skipped. This caused a bug
where if you clicked a FocusableNode, it would stay highlighted even
if you then selected some text, until you highlighted another node
(which would then be highlighted forever, etc.)

Change-Id: Ia8d74ef85eaa47326d49ef6c0f395b44b90da4dc
2013-10-03 15:50:51 -07:00
jenkins-bot 2b46215a2c Merge "Make toolbars, toolgroups and tools toolFactory independent" 2013-10-03 22:42:58 +00:00
jenkins-bot 5ba2dcfe3c Merge "ve.Element: Fallback to body, window is not scrollable" 2013-10-03 22:27:37 +00:00
jenkins-bot c21c8556fc Merge "Make ve.Factory require static name property" 2013-10-03 22:03:26 +00:00
Trevor Parscal 61ddfb76e4 Make ve.Factory require static name property
Objective:
* Make ve.Factory behave like ve.NamedClassFactory
* Remove the only remaining use of ve.Factory (actions)
* Remove ve.NamedClassFactory

Change-Id: Ie302ef5ea31081de7ab0db6091058a59946aef4c
2013-10-03 14:52:19 -07:00
jenkins-bot c98624a7be Merge "When cloning the InternalList, pass through properties that aren't rebuilt" 2013-10-03 21:51:45 +00:00
Trevor Parscal 7297108a48 Make toolbars, toolgroups and tools toolFactory independent
Objectives:
* Pass a specific tool factory into a toolbar, allowing it to be used
  with different collections of tools and not depend on the
  ve.ui.toolFactory global
* Move syntax highlight editor tools to their own factory

Change-Id: I307bf180bd6817bc044bc474a77861e13f431ddb
2013-10-03 21:49:36 +00:00
Roan Kattouw 69ad031bff When cloning the InternalList, pass through properties that aren't rebuilt
InternalList.clone() assumed that all properties are automatically rebuilt
when a new document is built, but that's not true for .nextUniqueNumber
(or for .itemHtmlQueue for that matter). This meant that, in practice,
.nextUniqueNumber was being reset to 0 after auto/N numbers for existing
references had been assigned, but before assigning numbers to newly
created references. This caused all sorts of naming collision fun.

Bug: 54712
Change-Id: I1d087a5f3c23979d7d488e3ab32eb064ebc23e94
2013-10-03 14:43:20 -07:00
Trevor Parscal 1a7a5a9948 Allow menu tool groups to be wider if needed
Using a min-width instead of a width ensures it gets larger only if
needed.

Bug: 54870
Change-Id: I9953d21134d722547efa0cdbe32e1bc0c13d6093
2013-10-03 21:25:46 +00:00
Timo Tijhof f6d409e09b ve.Element: Fallback to body, window is not scrollable
Bug: 54928
Change-Id: Ifec0dae598f7fd99270588bd8ca77777a07e9669
2013-10-03 23:06:47 +02:00
jenkins-bot dd9511f249 Merge "Change ve.dm.DocumentSlice to a mixin to ve.dm.LinearData" 2013-10-03 18:45:55 +00:00
Ed Sanders 5c31d3215b Change ve.dm.DocumentSlice to a mixin to ve.dm.LinearData
Document slice only ever contained linear data, with extra functionality
to preserve the range. It pre-dated LinearData, but now we should
refactor it to reflect its purpose.

Change-Id: Ifc908f7526c83a43a51372c8d2494d7260e7facd
2013-10-03 19:38:59 +01:00
jenkins-bot 1a9f6489d7 Merge "Rename getDocumentSlice to cloneFromRange" 2013-10-03 18:19:13 +00:00
Ed Sanders 1957eb3e28 Rename getDocumentSlice to cloneFromRange
We already getSlice which returns a ve.dm.DocumentSlice, so using
the word slice in this method is very confusing. What we are actually
doing is creating a ve.dm.Document from a range. Also remove argument
overloading as it's not particularly helpful and would make the new
name a lie.

Change-Id: I93da3419510410b170396e6765fbe2a87f9795be
2013-10-03 12:48:01 +01:00
Roan Kattouw 6772f92e70 Get rid of 'reversed' flag on transactions
The way we implemented undoing transactions was horrible. We'd process
the original transaction, but with a reversed=true flag. That meant we
had to keep track of the 'reversed' flag everywhere, and use ternaries
like insert = reversed ? op.remove : op.insert; all over the place to
access transaction operations. Redo then worked by reapplying the
transaction. We would verify that this was OK by tracking whether the
transaction was in an applied state or an undone state.

This commit makes it so every transaction can only be applied once. To
undo, you obtain a mirror image of the transaction with tx.reverse(),
then apply that. To redo, you clone the original transaction with
tx.clone() and apply that. All the code that had to use ternaries to
check whether the transaction was being applied in reverse or not is
gone now, because you can only apply a given transaction forwards,
never in reverse.

Bonus:
* Make ve.dm.Document's .completeHistory a simple array of
  transactions, rather than transaction/boolean pairs
* In the protection of double application test, clone the example
  document properly; it modified ve.dm.example.data, which was "fine"
  because it ran .commit() and .rollback() the same number of times

Change-Id: I3050c5430be4a12510f22e20853560b92acebb67
2013-10-02 19:37:08 -07:00
Roan Kattouw 087fd6c348 Followup 5592ea26: bind native focus/blur events instead of jQuery events
In jQuery 1.8, if you focus something using jQuery, the jQuery focus
event fires before the jQuery blur event, which is wrong. If you focus
something natively, the events do fire in the correct order.
See http://jsfiddle.net/WGy9h/4/ .

Fortunately, the native events always fire in the correct order, so
listen to those instead. Normally, we're not concerned with the order,
but in ce.Surface we bind the same focus/blur handlers to a pair of two
nodes, and then if the focus moves from one to the other, we'll get
confused by the events being emitted in the wrong order.

Change-Id: Ia585b42b6deb74ba55a2d55ce1922b1e04d85e81
2013-10-02 17:59:51 -07:00
Ed Sanders 7d9eee7b5b Use element.textContent in ve.getDomElementSummary
.text() returns empty for comment nodes, where textContent returns
the contents of the comment node.

Change-Id: I5e2798a6dba9d0f8fc13d5c0f78fe1fd255f1ebe
2013-10-02 15:47:34 +01:00
Roan Kattouw 5592ea2602 Make cursoring over a FocusableNode work again
When you cursor onto a FocusableNode, it's selected, and we focus the
paste target as part of our hack to make copying FocusableNodes work
in Firefox. But then when you press the arrow key again, that event
isn't picked up by anything, and you can't move the cursor off the
FocusableNode using the keyboard.

Fixed by attaching the EventSequencer to this.$ (which is the parent
of $documentNode and $pasteTarget) and listening for focus/blur on
both $documentNode and $pasteTarget.

Bug: 54443
Change-Id: I7bddcfa9fa6f38908e315c97623bd27133daa98d
2013-09-30 18:16:41 -07:00
jenkins-bot 7052472c2b Merge "Don't bounce selection changes DM->CE" 2013-09-30 23:56:25 +00:00
David Chan 571d6cac59 Don't bounce selection changes DM->CE
ve.ce.Surface.js
* changeModelSelection: store selection temporarily for bounce detection
* onChange: do nothing if bounce is detected

Change-Id: I758e7a72a5690463f12f456419c6e471dd29a9db
2013-10-01 00:49:27 +01:00
jenkins-bot f2189a97b5 Merge "Add more tests for ve.ce.Surface#onContentChange" 2013-09-30 23:23:23 +00:00
jenkins-bot a3854ad50a Merge "Typing into an annotation next to a word break keeps annotation" 2013-09-30 23:21:29 +00:00
Roan Kattouw cf19aff8b1 Follow-up to 9b999622: don't slug paragraphs that contain just a text node
Bug: 54791
Change-Id: Ide8b5320fae2622085f183c771173ef7190406ed
2013-09-30 09:33:59 -07:00
jenkins-bot d1b3c89c7e Merge "ce.BranchNode: Insert slugs based on CE children length, not DM" 2013-09-29 17:14:43 +00:00
Timo Tijhof 9b99962215 ce.BranchNode: Insert slugs based on CE children length, not DM
Due to Firefox' Ctrl-A creating an outer selection (0,len) as
opposed to inner select like in Chrome (1,len-1), deleting leaves
the document completely empty (with no cursor anywhere in the
document).

However, setupSlugs() wasn't inserting a slug because the internal
list still existed (so this.model.length !== 0).

Using this.$.children().length instead.

Bug: 50947
Change-Id: I1517ebcc5b31e2544559b851174482b0c872b24b
2013-09-29 10:12:22 -07:00