Merge "Re-apply fixes made in a patch set that were accidentally reverted on rebase"
Add .reportProblem() to submit reports

Change-Id: I55ffd8bfc7664ead3827ef6be178a0b6f3b991a1
Re-apply fixes made in a patch set that were accidentally reverted on rebase

In the change: I6781916822b4173ba906b9bc4c341219fbf10d82

71b97ec45bfdc675eda99284c2866d579f27439f was reversed when I submitted 1789545284494f1061b45b834e2c35232f314753

Change-Id: I6cc59a27817bfbe55c7cbf45bba746a4bd6c375f
Merge "Improve truncate and truncateRange to allow negative values"
Merge "Move the cursor to the end of newly inserted links"
Merge "Add page_touched to Parsoid URLs for cache busting and set cache param"
Merge "Fix the "list of US Presidents" bug"
Fix the "list of US Presidents" bug

I noticed this bug on [[List of Presidents of the United States]]. When
there's HTML that looks like "<td>Foo\n<meta/></td>", the converter will
collect the newline in wrappedWhitespace, then attempt to splice it out
and store it in internal data. But instead, it ends up splicing out the
/metaBlock element, which causes strange unbalanced input, which causes
an empty table in the node tree.

Change-Id: I79ed2fa9a834cc42759c7d21250d8842f563d38f
Improve truncate and truncateRange to allow negative values

Positive values will move the end, negative values will move the start

Change-Id: I566653664bf2a8a74781f1059a51873ab72560f9
Move the cursor to the end of newly inserted links

Inserted links happen when the cursor is not near a word, so we insert the target as text

Change-Id: I06c2c425d28db7ca61f13c438e25cc9c75f391f4
Add page_touched to Parsoid URLs for cache busting and set cache param

Parsoid support for this is in https://gerrit.wikimedia.org/r/38139

Change-Id: I5a128fe3599953d564b339b194b5466e2d324fd6
mw.ViewPageTarget: Move diff button logic, min-height for dialog.

Follows-up Ic77c5ce4 and I9d05ef6e.

Change-Id: I077172d590e53737691020c1265203134eea3c9c
Merge "Enable change makers by default"
Enable change makers by default

Change-Id: I7b5af42abe81cc5f41dd80692ac5d5ff007f99ed
And also use a 100s timeout for show changes

Change-Id: I437d125cd1944299991d80f22fdaedd490bcb45f
Set the save timeout to 100s as well

Change-Id: Ic01ffaae2a0c4bbe91bee7705c60f26b7b34d0f9
Added VisualEditor specific edit notices

Default message used is visualeditor-alphawarning

Configure in $wgVisualEditorEditNotices

Change-Id: Ie56dac47aa825dd7a2eb9f74be486ae4228672c6
Merge "Hide the show changes button when we are creating a page"
Hide the show changes button when we are creating a page

Change-Id: Ic77c5ce4757fd0cf6d7cdd9a991206b649fc2e5a
Merge "Check if there's a document before we try and set focus on it"
Check if there's a document before we try and set focus on it

Change-Id: Ia7776c70c2593e4524adab3a347230ee3cccad29
Add left margin to save dialog, visible with show changes

Change-Id: Iaadbfd30f7270fa90dc4adefc9855a55d087ce0c
Merge "Prevent Inspector frame from reloading on close."
Merge "Fix typo'ed documentation issue with gerrit change 38009"
Merge "Throw edit warning on cancel."
(bug 42920) Add the feedback tool

icons, comment.*, ve.ui.Icons-*
* Added comment icon

ve.init.mw.ViewPageTarget
* Refactored editNoticeButton into being just a tool
* Added feedback tool, which shares the editNoticeButton code
* Added feedback object construction in init constructor
* Added launching code to feedback tool

VisualEditor.i18n
* Renamed editnotices-button message to editnotices-tool to match changes in code
* Added feedback tool message

VisualEditor
* Added dependency on mediawiki.feedback
* Updated changed message key
* Added reference to new message

Change-Id: I813c89a505386a9b3206bfbcb176016e28a592cb
Adjustments and fixes for styles

* Made buttons use shared CSS code
* Stopped using <button> elements and got all browsers looking the same
* Fixed focus on text area issue - had to let the stack clear first

Change-Id: I6781916822b4173ba906b9bc4c341219fbf10d82
Fix typo'ed documentation issue with gerrit change 38009

Change-Id: I1238001949bae519d49428f98dcdd1428388aa0d
Merge "(bug 42937) Removing copy/pasted link annotations removes the original as well"
Merge "Create first VE Technical Debt bug entry for tracking, resolution"
(bug 42937) Removing copy/pasted link annotations removes the original as well

Basically a copy should be a deep copy, so this was a blatant mistake.

Change-Id: I702fb425783293c4ddde8b9ac568dfe6abc8f782
Remove FIXMEs resolved in 15c5495255f86dd8357a1b628c9d4b1e1af76e31

Change-Id: I03dcf9040bb40e5550e9ff56609d479715904a65
Add recursion guard back in

This was removed in I0873d906c058203b83b8d4bbe5a4b274f05a26fd because I had fixed another cause of the recursion - this is still needed however because the following still happens:

1. Link inspector is opened away from a word, so it goes into a mode that will insert text based on the chosen target
2. The link inspector is closed, causing a context change when the new annotated text is inserted
3. The context change event triggers the link inspector to close, leading us back to step 2
4. Browser dies in infinite loop hell

We may be able to fix this in a different way, like performing the document changes after the inspector has already closed by running it in a timeout. In any case, this works for now, and we can improve the design of this area of the code later on.

Change-Id: I7f3c17dad08521bb1ae7c2a1e8a4e21e2c4ba210
Create first VE Technical Debt bug entry for tracking, resolution

Change-Id: I47690b97c19ecc25b0f235036142fef9a2514e96
Prevent Inspector frame from reloading on close.

In the event the page explodes from a huge js error, prevent
the iframe from reloading to slightly reduce the confusion of the
user.

Change-Id: I0c88678437f0bad994fa97f4df63d8b288f69e7a
Merge "Fix tests for bug 42806 patch"
Merge "Alien support for IE"
Merge "Alter messages to pull in the links for messages from other messages"
Throw edit warning on cancel.

-Added reset and hide calls to deactivate to prevent problems
with the save dialog if the user exits to the view.
-Remove unneeded teardown routines from cancel.
-Calling deactivate without override.

Change-Id: I888019146186fb7cbc1ee2b8efee9a0c45286c23
Fix tests for bug 42806 patch

Repairs what 619043f8d1a57a75e179ce43adbd4ce90fa7d4f8 breaks

Change-Id: I2f98ca0dbb292d98dddc86b39c8916e76a5e9d8b
Alter messages to pull in the links for messages from other messages

Thanks to Siebrand for explaining what he wanted done.

PS2: Altered capitalisation.

Change-Id: If34045989f5d9fdfec7d8170828cdf5de8f25e46
Merge "(bug 42654) Implement Show changes in Save dialog."
Localisation updates from http://translatewiki.net.

Change-Id: I83f5a64f5e8742ca2b733d6c7a8c07af600594d8
Merge "Focus on document when notices are clicked"
Merge "(bug 42842) Do not call update (temporary solution to prevent error"
(bug 42842) Do not call update (temporary solution to prevent error

Solution: do not call update (temporary solution to prevent error - however content will never be at offset 0 - so it should never hurt)

Change-Id: I9ed6f9fbea23d5e2e55c56f8483321442049bd51
Localisation updates from http://translatewiki.net.

Change-Id: Ief397cfb05a3b19c472e63a63a03fce426db7674
(bug 42848) Notifications should not use db-variant of page titles

Change-Id: Ie84168cd2509a17c180c6143a87a18ae8bbb3d0a
(bug 42654) Implement Show changes in Save dialog.

Turned saveDialog-body into slide-based swapper.

Moved footer into saveDiaog-body so that the license text doesn't
stay under the diff-slide (and move body bottom padding to foot
top)

Wrapped buttons and title in a saveDialog-header and converted
closeButton from absolutely positioned to a floated layout.
This way the title doesn't need to be repositioned but will scooch
over if the prevButton gets shown/hidden.

Update API "diff" action to include table wrapper and table
header. Without it the mediawiki CSS for diff doesn't work
properly (needs colgroups for proper width of the "-" and "+" column etc)

Renamed -saving class to -disabled for consistency.

Set prop.disabled to really lock/unlock buttons, not just visual
(otherwise the click handlers are still triggered on click, can
potentially cause actions to be triggered when not expected)

Using a ve message for "Show your changes" title instead of
re-using core tooltip-savepage in a different context.

Diff slide triggers "auto width" on dialog (inline undo of width: 29em), keeping min-width, to allow it to expand as wide as needed.

Functions that I copied as base for onShowChanges and
onShowChangeError had some incorrect argument descriptions. Fixed
in both.

Note:
* Pass function to .off(), so that only that one is unbound
  instead of any "resize" handler on the page (by other extensions
  or gadgets or core)
* NB: ve.bind ($.proxy) preserves internal guid, so that $.Event
  can find the bound function by the original reference.
* keydown has an anonymous function, should either moved to
  prototype or namespaced, did latter for now, save enough and
  better than destructive .off('keydown')

Change-Id: I9d05ef6e3e2461bdcf363232f7b0fbad5e24f506
Focus on document when notices are clicked

Change-Id: I55e4eb74e12ded79d998d155d4688ce6a1b6ce66
Alien support for IE

We got lucky - the fact that our alien styling choice required phantom overlays had the nice side-effect of preventing the ability to focus the aliens. Therefore, as soon as we started ignoring IE to deliver nice alien handling for standards-compliant browsers, we inadvertently solved(?) the IE alien problem. I've touched up the styling to look nice in IE 9 (solid green phantoms) and IE 10 (stripes). Shield GIF switched to PNG because IE 10 renders the transparent GIF as solid red. Yeah, red.

Change-Id: I3bc69acba9ed883a823cdf722117b90966bc332b
Merge changes I75bcf984,If7bae5e2

* changes:
  (bug 37875) Scroll changes on paste
  Pasting a DocumentSlice sets the selection incorrectly
Merge "(bug 42839) Whitespace links"
(bug 42839) Whitespace links

* Collapse the new range returned by trimRange if it only contains whitespace

Change-Id: Id8461d435b22b745371a3a33caa3ea5b016c5b90
(bug 37875) Scroll changes on paste

This solves 2 issues:

1. Paste scrolls to the top of the editable box because we temporarily moved the focus to the paste container, and then moved it back. We solve this by saving/restoring the scroll position.
2. Scroll position adjusts vertically when pasting (using key repeat) because we handle pastes with a setTimeout and multiple paste jobs will pile up before they can be finished. We solve this by disallowing paste until we are done handling the previous one. In the case of key repeat this only is observable as slowing the repeat rate.

Thank you Christian for helping me solve this the old fashioned way - by sacrificing features you don't really need!

Change-Id: I75bcf9843b57cdff0db9b6dea62d66d4d76ac011
Pasting a DocumentSlice sets the selection incorrectly

ve.dm.Document
* 2 of the 3 paths of getSlice still returned arrays instead of ve.dm.DocumentSlice objects

ve.ce.Surface
* Translate the range using the insertion transaction and truncate it, so the cursor ends up just after the pasted content

Change-Id: If7bae5e254ec84a847c1d3527f74d9c09c2d82b4
Localisation updates from http://translatewiki.net.

Change-Id: Ie2ffad47f93de2a1b4093f297f9a7e76ccb523d0
Merge "Static composition of 'can' and 'not', may improve performance slightly"
Static composition of 'can' and 'not', may improve performance slightly

Or at least irritate Roan less…

Change-Id: I9ea503725133ed0971f3876f199e0858c35c5aa1
Merge "(bug 42806) Copy/paste errors on unbalanced data"
(bug 42806) Copy/paste errors on unbalanced data

ve.ce.Surface
* Switched to using getSlice instead of getData in copy and paste handlers
* Added try/catch which attempts to build a transaction with the unbalanced data first, but falls back on the balanced data otherwise

ve.dm.*Node
* Added default style attributes (now used by ve.dm.NodeFactory)

ve.dm.Document
* Fixed bugs in fixupInsertions where parentType was being set with an object rather than a string
* Made use of getDataElement
* Added adoption capability so that inserting a</h1><p>b into <p>c[cursor]d</p> results in <p>ca</p><p>bd</p> rather than throwing an exception
* Renamed getBalancedData to getSlice, now retuning a ve.dm.DocumentSlice object

ve.dm.DocumentSlice
* Introduced new container for balanced data and a range of the original context - useful for copy/paste

ve.dm.NodeFactory
* Added getDataElement method, which uses default attributes to create a boilerplate version of a data element

ve.dm.Document.test
* Updated getBalancedData test to be a getSlice test

demos/ve/index, VisualEditor, test/index
* Added references to ve.dm.DocumentSlice

Change-Id: Id9269a29e51ca213508de8f155d3feec5e5b0774
Merge "(bug 42836) Formatting drop-down updates"
(bug 42836) Formatting drop-down updates

The fix for bug 40339 supposedly modified when we emit contextChange events so that when the node changed, even if the context was the same, we consider it a context change (such as changing the heading level).

Unfortunately I was mentally absent when I wrote the patch and all it actually does it emit more select events.

Basically cb4877b0d013ab976635b857bca2e5f92340e014 - which does indeed fix the bug - doesn't do what it's commit message describes, but this fixes it.

Change-Id: I99d74f9ab0ddec15df41320389fe83de9b8b8d1e
Merge "(bug 42298) Handle URL encoding in MWInternalLinkAnnotation"
(bug 42298) Handle URL encoding in MWInternalLinkAnnotation

* Decode titles we get from Parsoid
* Encode titles we give to Parsoid
* Preserve the original encoded title if nothing meaningful changed (a.k.a. do not normalize unless we must)

Change-Id: If5d22e88904d6b2c438caac403ac2d78d440b017
Fix CSS syntax errors from If1e08bbf.

Change-Id: I38f33a065afbe37f931934017c11d5ceedb34176
Merge "Add qqq messages for missing i18n strings"
Add qqq messages for missing i18n strings

Also minor tweaks to existing wording for consistency.

Change-Id: I7ccdf036a5df8029bb2f47856c917055da081f0a
(bug 42801) Fixed by re-adding calls to disableRendering() (used to be lock()) and enableRendering() (used to be unlock()) - deleted accidentally in commit: 9c74c97808f0bc25a8305d215411a85f2d5cb1bd

Change-Id: Ia91a572c94cc3e9a81148b1484fc567941fa7c3e
Merge "Fixing paste from external sources"
Merge "(bug 42136) Use user prefs to set initial state of "Watch this"."
(bug 42136) Use user prefs to set initial state of "Watch this".

* Don't show at all if user isn't logged in
* Use "watch pages I create" and "watch pages I create" prefs
* If the user is already watching it, use that

Also updated relevant onMakeGlobalVariablesScript hook,
it was using old globals still, the hook has context as
of MediaWiki 1.19.

Change-Id: Ic3daf32505a745b3cccd0663a03bbf7f3885be84
Fixing paste from external sources

Since model.change now starts the surfaceObserver, a problem manifested where the surfaceObserver was observing the $('#paste') element (used for capturing and sanitizing pasted content from external sources). Simply switching the order of the transaction and the documentNode focus fixed the problem.

Change-Id: I1b542b546d7f3d97e2e954ca4b51ca74232b2877
(bug 37837) Spinner of death on error

* Reusing deactivate method to recover from load error
* Made deactivate resilient to some properties not being set yet (so we can call it on load error)
* Restoring save dialog state after save error

Change-Id: I6a697dc6bddeebecf4e2ab26805bee9f3754c714
Merge "Localisation updates from http://translatewiki.net."
Localisation updates from http://translatewiki.net.

Change-Id: I2fcfd71016937d9f1f2d70ac84e0f1d7cc552d5b
Merge "(bug 42487) Don't crash the converter for "<span>\n<p>Foo</p></span>""
(bug 38034) Implement MediaWiki's copyright warning

Logic taken from EditPage::getCopyrightWarning, but couldn't use
it directly because it doesn't give the message keys and wraps
the html.

Using the same logic and running the same hook, we'll get the same
message keys (and message parameters therefore) as EditPage would.

Also fixed these bugs (as they were more prominent now):
* Use Message::parse() instead of Message::plain()
* Set inLanguage properly instead of using the default
  (EditPage is user-localised, including this message, just like
  the rest of VE).
  Fixes bug 42764: minoredit/watchthis should be in user-language.

Change-Id: I84fee641162cdeed290092e56fb0e1d2562d833d
Merge "Add tooltips to close and remove inspector controls."
Merge "(Bug 40773) Clicking on minor edit now opens in a new tab."
Merge "(bug 42750) Save button says "Create page" when creating a new page"
(bug 42487) Don't crash the converter for "<span>\n<p>Foo</p></span>"

The converter was misbehaving when handling <p>s inside <span>s. This
can't be expressed in the linmod, but it would try to anyway. <span><p>
would result in too many paragraph closing elements, leading to an
exception in ve.dm.Document complaining about unbalanced input.
<span>\n<p> would result in an exception in the converter itself while
trying to perform whitespace preservation on the newline.

This change makes the converter detect these scenarios and alienate the
offending node. So <span><p>Foo</p></span> converts to a wrapper
paragraph containing an alienInline whose HTML is "<p>Foo</p>" and which
is annotated with a TextStyleSpanAnnotation.

ve.dm.Converter.getDomFromData():
* Change the criteria for alienBlock vs alienInline
** Only infer from the node type if we're in wrapping mode AND we're at
   the same level where the wrapping started (wrappingIsOurs). If the
   latter isn't the case, we can't split the wrapper in the block case
   because we're at the wrong level.
** Use alienInline not only if the branch is a content branch, but also
   if there are active annotations. This catches e.g. <li><b><p>
   (and generally <span><p> on the top level).
* Before converting a child element, check that the child isn't "bad".
  Bad children are non-content children in content branches, and
  non-content children encountered within a wrapper that we can't split.
  Only good children are converted, and bad children are alienated (cue
  Santa/Sinterklaas jokes).
* Add childIsContent and rename branchIsContent to branchHasContent

Change-Id: If420ae80ab0777424a9a5517335ef9d0170e87ae
Add tooltips to close and remove inspector controls.

Addresses (Bug 41153)

Change-Id: I6fa0bb8acafbc9e4e7763f9f0e158b853bc1afaa
Merge "(bug 41223) This temporary fix is not needed anymore."
(bug 41223) This temporary fix is not needed anymore.

Change-Id: Ia65b69f152396d42cd33b6d893c812076e7da6d3
(bug 42655) Fix - it might be not the long-term solution - but works for now.

Change-Id: I3165654afb4bf9203cd746ed8af241168d5946a0
(Bug 40773) Clicking on minor edit now opens in a new tab.

Since the link is generated by a MediaWiki message and as far as
I know, the target attribute cannot be added in wikitext.

Solution is to add the target attribute via jQuery in the
save dialog.

Change-Id: I4b6cdee64e7f8e3acb28b21c32c58254d63a8daf
(bug 42750) Save button says "Create page" when creating a new page

Change-Id: I25e07f531b911eef3cf55412862b163393d03d33
Merge "Rename and cleanup ve.ce.Surface locking state"
Rename and cleanup ve.ce.Surface locking state

Get rid of ve.ce.Surface.locked (and isLocked, lock, unlock) and instead introduce ve.ce.Surface.renderingEnabled (and isRenderingEnabled, enableRendering, disableRendering) which names are way less confusing and more specific. Also add use of isRenderingEnabled to ve.ce.ContentBranchNode.

Change-Id: I72e9e8f8dfbf43784d7e616369acc3e9649c715a
Fixing Pre-Annotations

Initializing range var in SurfaceObserver to use this.range instead of null to avoid passing wrong information to onContentChange.

Change-Id: I1d4e3fa2393166dad887077529351a479401bf4b
Add cancel button to VisualEditor MediaWiki integration.

Attempt to address (Bug 37845)

Change-Id: If1e08bbfbe4920e74f1c006e4fb18c8296ff6043
Merge "Depend on jqueryMsg for the visualeditor-editnotices-button message"
Depend on jqueryMsg for the visualeditor-editnotices-button message

This makes {{PLURAL}} work reliably

Change-Id: Id874202544e5b2513b438fe1f0668f845acb89cb
Get rid of ve.ce.Surface.sluggable - we are not using it anymore.

Change-Id: Ibcd6c7c1bae4f4dd7c3ac52719e17214dbae6558
Merge "Restore cursor after undo/redo"
Restore cursor after undo/redo

With the introduction of ActionFactory, we lost selection restoration. I've re-added it in the HistoryAction methods.

Change-Id: I018f9a9f85f5ce081e3b56c0f52aba24bc24cec5
Localisation updates from http://translatewiki.net.

Change-Id: Ia08d43f4355b029eb284dcf474b77a652e1cd3b6
Merge "(bug 42707) JS error when deleting across an inline alien"
Merge "(bug 41865) Save page behavior for oldid"
(bug 42707) JS error when deleting across an inline alien

ContentBranchNode shouldn't rerender on update, only on childUpdate.
When deleting across an inline node, update was emitted after the splice
had occurred in the DM but before the spice event was emitted that
caused the splice to happen in CE, leading to detached nodes and
associated sadness. See the bug for more details.

Change-Id: I2d44231b6e27efdb3f12967556cff174d9364d25
Demos: Fix for I53b041f8 fixing Idbff4c51 fixing I840f7242

Change-Id: I860b0441c055cb1f4c04dff7ffdb4f9fafd42cc1
(bug 41865) Save page behavior for oldid

ApiVisualEditor
* Reverted some of I223235a6ea8b4178c50beeaaedb709b2de7cf0b5 turned out to be full of problems - the race condition is only relevant to getting the HTML
* Fixed check for $content to be false before it was defined

ve.init.mw.ViewPageTarget
* Reverted some more of I223235a6ea8b4178c50beeaaedb709b2de7cf0b5 - wgCurRevisionId is not equal to oldid, it's equal to $title->getLatestRevId() - this was causing lots of oldid problems
* Added use of restored message
* Made save button not locked when using oldid
* Customized save buttons depending on oldid

ve.init.mw.Target
* Reverted even more of I223235a6ea8b4178c50beeaaedb709b2de7cf0b5 - we don't want to keep a copy of the wgCurRevisionId at all, we just want the oldid if it was given

VisualEditor.i18n, VisualEditor
* Added restored notification and restore save button label messages

Change-Id: I8b30c2a153911f44643e369b7c6a9b89c0fb2c5b
Fixing toolbar icons

This fixes the display of the toolbar icons in demos/ve/index.php

Change-Id: I53b041f8be3602f2a59d0c124dbebba83b1dfb72
Localisation updates from http://translatewiki.net.

Change-Id: I3c2b7aa0acb5240c174822e8f97b2a071085423a
Another fix for I7f26b47e9467e850c08b9c217c4f1098590de109

Feeling like I should have just reverted my merge at this point...

Change-Id: I94075e065ea1f1b80f19c750e25858496da6ed36
Fix for I7f26b47e9467e850c08b9c217c4f1098590de109

I overlooked this when I did the review.

Change-Id: I942ce92c0c8f847149bb24697fc1aab0e67b8c67
Merge "Clean up, fix errors on demos."
If more than one title in suggestions match, select the first item.

Addresses (Bug 42665)

Change-Id: I8c425b79e34e931beb78538146a035c25023ce8a
Clean up, fix errors on demos.

* Fix 404 error for ve.ui.Icons-{raster,vector}.css
  Follows-up 9563f08 / I840f72426f9a.

makeStaticLoader.php:
* Clean up old code.
* Error out early for missing module.
* Put i18n stuff in the right place
  (some modules access ve.msg from the global scope to
  assign status variables, for standalone on demos this was
  failing due to wrong load order)

Change-Id: Idbff4c5136d567da747d9ae373cd2f6c3ee7fb1c
init.Platform: Refactor parsed messages.

Rewrite VisualEditorMessagesModule:
* Replace copy-paste dump of user-css module with stuff for
  VisualEditor (class commend and module::$origin).
* Remove duplication between getMessages and getScript.
* Actually implement getModifiedTime so that the comment in
  getMessages() about cache invalidation is actually true
  Fixes bug 42670: ext.visualEditor.specialMessages cache broken

ve.init:
* Implement addParsedMessages and getParsedMessage so that we
  don't mix up plain messages with raw html messages (minoredit
  was previously overloaded in mw.msg storage with a parsed html
  message and retrieved though ve.msg, which is documented as
  retuning plain text, not raw html). This is now separated into
  a different method.
* Improved documentation of the other msg methods to emphasise
  their differences
* Removed redundant code in attachSaveDialog() that was
  (partially) already done in setupSaveDialog() and moved the
  remaining bits into it as well. Checked all callers of these and
  they are both only called from ViewPageTarget.prototype.onLoad
* Also implement them in the standalone platform implementation,
  with the html escaper based on mw.html.escape
* Update init.platform.getMessage to use undefined instead of
  discouraged 'if-in' statement.
* Add test suite.

demos/test:
* Re-run makeStaticLoader.php on test to add ve.init.Platform.test
* Re-run makeStaticLoader.php on demos and update i18n caller
  to use ve.init.platform.addParsedMessages (also moved out of the
  auto-generated block for easier updating)

Change-Id: I7f26b47e9467e850c08b9c217c4f1098590de109
Merge "(bug 42661) Initially hide context, then update after animation"
Merge "(bug 41929) Unlist button overzealously unlists the whole list"
Merge "Added destroy methods and called them on deactivate"
Merge "(bug 42469) Leading newlines in <pre>s get eaten"
(bug 42469) Leading newlines in <pre>s get eaten

HTML DOM has annoying behavior for <pre>s where .innerHTML eats the
first newline in a <pre>. Work around this by explicitly adding a
newline in the data->DOM converter if the <pre> already contained a
newline.

There is a separate bug in Parsoid that causes the newline to be lost
anyway, filed as bug 42666

Change-Id: Ia26cd4a4c61afbe439b0562deb7f24ee8b8147d7
Address error caused by changing focus from context menu to window.

DocumentNode element loses focus when the context is opened.
When clicking out of the context into window, polling error
occurs.

Change-Id: Ie8f8af763d221c59e47e8c240653f8b817c26f64
Merge "Don't phantomize inline aliens when dragging"
(bug 41504) ve.ce throws error when surface loses focus

ve.ce.Surface
* Used getModel() as per TODO
* Simplified code by pre-calculating 2 statements that were being used 4 times each
* Re-structured logic so that simple insertion and deletion are only possible if next and previous have a range, triggering complex change otherwise
* Added some documentation

ve.ce.SurfaceObserver
* Added checks for whether rangy found a branch node within the document or not before accessing it's node via .data() and made it so we are only performing DOM > document range conversion if we did
* Removed some commented out code

Change-Id: Iaaf30a5b201710ab4235e775f18808a8d512f1f9
(bug 41929) Unlist button overzealously unlists the whole list

ve.IndentationAction
* Fix incompatibility with working with multiple nodes by using surface fragments
* Bug was caused by unindent causing rebuilding, which for all groups other than the first meant their nodes were detached and broken

ve.ListAction
* Employ unindent in a loop to remove all list levels

This is all still a bit hacked together, the use of surface fragments saved us this time, but we need to refactor this code. Badly. Next year.

Change-Id: Idddef35230b04d64cf8338d53bbab730fadec2fc
Don't phantomize inline aliens when dragging

This will prevent inline alien phantoms from appearing while dragging. This was a usability enhancement identified by Inez/Christian.

Change-Id: Idf046db72e25875e899f5926ab7d50d2f514586b
Merge "(bug 40339) Out of bounds errors"
(bug 40339) Out of bounds errors

Detecting contextChange events was making assumptions about the previous state, and causing a mess of problems.

Solution: detect contextChange events in a smarter way.

We also now emit contextChange event when moving to a different node. This helps fix other issues because it's possible for the selection to be the same, but the node at that range to change, and that's a context change for sure. Example would be changing the heading level.

Change-Id: I99d6fa94fae76aa940077abc9b5beacd38eb7b0b
Removed all browser-specific box-shadow rules

These aren't needed for any of our target browsers anymore.

Change-Id: Idae4acb5f0f6387cad52f2ea7594dbad1929af59
(bug 42661) Initially hide context, then update after animation

Change-Id: I35a0c3359ffc1a62ee3c0456c33475e32189f4b4
Merge "Removed all browser-specific border-radius rules"
Removed all browser-specific border-radius rules

These aren't needed for any of our target browsers anymore.

Change-Id: I86d1964f163827673c090b67a472254b73e365a4
Merge "(bug 42220) Added support for edit notices, which appear on the toolbar"
Added destroy methods and called them on deactivate

This prevents memory waste when switching between read and visual editor tabs, which happens entirely on the client.

Change-Id: I31b50accac38d72a9367b9035504552dc0150104
(bug 42137) Sync availability of "minor edit" with MW backend.

Which for now is just "not when creating a new page". This is
already strictly enforced in the MediaWiki backend through EditPage.php, but not reflected in the Save dialog of VE yet.

Now the checkbox for Minor edit matches the logic for EditPage.

Change-Id: I9c659845feebb3e9bbf8e13ee67be27c6adb4321
Cleanup oldid: Use mw.config for page existence and revision id.

Use mw.config wgCurRevisionId for oldie instead of uri query.
That way it also set on regular views, and as a bonus it the
normalised value (e.g. if on a page with oldid in query but the id
doesn't exist or is somehow invalid, it won't use it).

Centralise page existence logic in JS and rename Target.oldId to
Target.pageRevId (to further indicate that it is always set, not
just on oldId views. To detect an oldId view, do a boolean check
on value from currentUri.query.oldid directly).

In PHP Api, move oldid logic to execute() method instead of
locally from the getHTML call. That way it is always set, avoids
hitting this bug in other methods instead of just getHTML().

Since the mw.Target constructor now retrieves the ID from
mw.config directly, the second argument was removed.

Change-Id: I223235a6ea8b4178c50beeaaedb709b2de7cf0b5
(bug 42553) Only replace url on veaction=edit if there is no other query

Change-Id: Ia63c937d3a0a68acaa178486ab439bc1ea9db8af
mw.Platform: Only show minor edit option if user has "minoredit" right

Had to make the retrieval of the Save dialog html template
asynchronous due to mw.user.getRights being asynchronous.

Entire block indented, ignore whitespace changes.

Also:
* Fixed 2 cases where ve.msg value was interpreted as HTML
instead of adding a text node directly.
* Alphabetically sorted the dependencies (after adding
  user.options and mediawiki.user).
* Removed redundant inline jshint comment, multistr is already
  tolerated from the central .jshintrc file.

Change-Id: Ie09bb5c8bdbfbb3ec0d4983b74d0697b941153e0
Merge "Init: Fix incorrect context for mw.msg.apply."
Merge "(bug 41159) Position of VisualEditor's "Create" tab is wrong."
(bug 42220) Added support for edit notices, which appear on the toolbar

ApiVisualEditor
* Including notices in response to parse actions

ve.init.mw.ViewPageTarget
* Added styles for editNoticeButton and editNotices

ve.init.mw.ViewPageTarget
* Added toolbarEditNoticeButton and toolbarEditNotices
* Combined toolbarEditNoticeButton and toolbarSaveButton setup
* Moved toolbar buttons setup to onLoad (it could vary per-parse now)
* Added tearDownToolbarButtons which fires on deactivate
* Renamed some instances of teardown to tearDown
* Added click handler for toolbarEditNoticeButton
* Added toolbarEditNotices setup method, called on load
* Made notices fade in and out, in by default on load if any
* Made notices hide when save dialog is opened

ve.init.mw.Target
* Added storing of notices on parse

icons, alert, ve.ui-Icons
* Added alert icon

VisualEditor.i18n, VisualEditor
* Added notices button message

Change-Id: I581bf5a005a9c18422f952d71064d17d0ba9b540
Localisation updates from http://translatewiki.net.

Change-Id: I2269608d54880f164e508b2c727e883da4593232
Init: Fix incorrect context for mw.msg.apply.

Context should be 'mw', not 'mw.msg'.
Also updated to using ve.bind instead and documented that ve.msg
cannot ve.bind because the reference 've.init.platform.getMessage'
does not exist yet at run time of the ve.js file.

Change-Id: I7eb692bdc4b63cc44fab118054d8eea05c2a71ff
Merge "Renamed API from ve-parsoid to visual editor"
(bug 41159) Position of VisualEditor's "Create" tab is wrong.

Change-Id: Id88a160621093e4db4cf01c0fa34793cc1a929b4
Merge "Add hover state to link inspector suggestion items."
Renamed API from ve-parsoid to visual editor

Change-Id: I3bfe2e813b31f9010010f63902b1e8e22f3bcd59
Add hover state to link inspector suggestion items.

Addresses (Bug 39977)

Change-Id: I159f86b070544f829ff801ac3ab913d36c5a0b30
Localisation updates from http://translatewiki.net.

Change-Id: I19ea12d771cb735d3ab29713c3170d8f832d0885
Merge "(bug 42555) Fixed onUpdate over-writing in ve.ce.HeadingNode"
Merge "Restyle suggestion dropdown into a single column."
(bug 42555) Fixed onUpdate over-writing in ve.ce.HeadingNode

When the content rendering stuff was moved to ve.ce.ContentBranchNode the onUpdate methods being used to update the DOM wrapper in ve.ce.HeadingNode was overlooked, so heading were not rendered on update anymore.

Change-Id: I994b8c43123c3cd02b9a550d5d7eac7d5052418e
Restyle suggestion dropdown into a single column.

* Permits longer page titles in suggestions without changing
  the width of the  dropdown.
* Addresses (Bug 40675)

Change-Id: Ie76a551970a040074b86c49bb44bda640ecd4845
(bug 42552) Link inspector close on selection change

The logic in ve.ui.LinkInspector.onUpdate was very flawed. This patch makes it so:
* When something happens, if there's an inspector open then so long as the selection hasn't changed the inspector is updated (such as the window being resized)
* If the selection does change, the inspector is closed
* If there's no inspector open, we try to show a menu of available inspectors

Change-Id: I859123a5fcd36bc2afb2e578f81f30a944c8583a
Merge "(bug 42401) Cursor movement fixes"
(bug 42401) Cursor movement fixes

ve.ce.Surface
* Added ve.ce.Surface.adjustCursor, which replaces repetitive and buggy code that was handling left and right arrow key presses
* New method only affects the selection target, so it won't collapse the selection on you - this was what caused bug 42401
* Made hasSlugAtOffset() actually return a boolean

ve.dm.Document
* Fixed turn-around issue in ve.dm.Document.getRelativeOffset - if the offset is already valid and we can't move in the direction we want, we should just leave it be, not turn around
* Since this method was being used by ve.ce.Surface to correct the cursor position on arrow key presses, it was causing the strange cursor jumping when you pressed an arrow key while at the edge of a document

ve.dm.SurfaceFragment
* Fixed typo where getAnnotationRangeFromSelection was preserving selection direction, but checking the wrong properties

ve.dm.Document.test
* Added tests that verify turn-around issue is fixed

Change-Id: Iba55cfc3d531e7d1333b78c94912ff22179aace8
Merge "Immediately provide default suggestions based on 0 results."
Immediately provide default suggestions based on 0 results.

Allows suggest tool to open immediately and provide new page and
external link suggestions for link inspector.

Resolves (Bug 42341)

Change-Id: I79bc3e31033b5c38c3ed6ab23e601476cb17ba8f
Localisation updates from http://translatewiki.net.

Change-Id: I773eb9c1114a64e83335024611612efd25d55dce
(bug 37828) Handle edit conflicts

ApiVisualEditor
* Added basetimestamp and starttimestamp to all methods where appropriate
* Added new serialize method which converts HTML to Wikitext

ve.init.mw.ViewPageTarget
* Added edit conflict handling
* Moved form value reading code into getSaveOptions method
* Prevented edit warning from appearing while submitting

ve.init.mw.Target
* Added serialize and submit methods
* Fixed some documentation
* Added support for baseTimeStamp and startTimeStamp

VisualEditor.i18n
* Added edit conflict confirmation box message

VisualEditor
* Included new edit conflict message to resource loader module

Change-Id: I002c5aa23704c1c46ef46fa1970a4254614b9eb1
(bug 42350) Delete and backspace broken around inline aliens in Firefox

ve.ce.Surface.handleDelete did not support inline elements. This patch resolves this by detecting them and using programatic delete instead of native browser delete.

Change-Id: I73215df88519450965be35d9e04cf4e621d1e90d
Revert "Localisation updates from http://translatewiki.net."

This reverts commit d18e70a818f7787233361881d0ce838488ae0195.

Change-Id: I0444abd84cc04be49d1cc983d78fe0016c4de0f2
Localisation updates from http://translatewiki.net.

Change-Id: I8f4559ee6462d7248bfc4aa1b0023619634b2ba5
Merge "(bug 42221) (bug 42142) Refactor init.mw setupSkinTabs."
Merge changes I4600e984,Id3cc053e

* changes:
  Render inline annotations in CE
  Fix rebase artefact in ve.dm.Node.getAttributes()
Render inline annotations in CE

Moved annotation rendering from ce.Textnode into the new
ce.ContentBranchNode class. This allows us to render annotations that
span across multiple nodes.

* Add ce.ContentBranchNode, inheriting ce.BranchNode
* Make ce.{Paragraph,Heading,Preformatted}Node inherit ce.ContentBranchNode
* Made ce.ContentBranchNode render its child nodes with anntations,
  using .getAnnotatedHtml() on the child nodes
* Put a default implementation for .getAnnotatedHtml() in ce.LeafNode
* Override this in ce.TextNode to do escaping and whitespace handling
* Removed rendering code from ce.TextNode (this.$ is now unused there)
* Removed ce.TextNode.onUpdate() and ce.BranchNode.clean(), now unneeded
* Have ce.BranchNode propagate update events from children, so
  ce.ContentBranchNode can rerender when its children change
* Update tests, add test case for escaping of &<>'"

Change-Id: I4600e984b287c6ff9267f4281d2f09bab9e1ad95
Fix rebase artefact in ve.dm.Node.getAttributes()

This caused it to always return {} when asked for all attributes with a
given prefix

Change-Id: Id3cc053e1911aebb2b7e60e3dd2f325ec7772a6c
Add message docs for 43684f88fce065bf0bceecff4b84eb761fc8c03e

Change-Id: I3aa5b7f594f3ea47baab0de3cc191ae5e0c39d03
(bug 42221) (bug 42142) Refactor init.mw setupSkinTabs.

* Remove the logic where we create a ve-edit button even though
  we know there is no native ca-edit button (bug 42142).
  This was previously in place to allow ve-editing a page while
  restricting source editing, but this is no longer wanted.

* Implement new tabLayout mode "add", which adds a VE tab.
  Previous default is now the "replace" mode, which replaces the
  native "Edit" tab and creates a "Edit source" link.

Change-Id: I3fe29c52b743837c2e1d66f25ccdca6115b8bd25
Merge "Added contextChange event to surface model, replacing annotationChange"
Merge "Handle annotated inline nodes in the converter"
Merge changes I1e0d7f95,I41948e85,Ie5b90988,Id556172d

* changes:
  Make annotating inline elements actually work
  Show annotations on nodes in demo debugger
  Store the data model element in the DM tree
  Only apply HTML attributes to DOM nodes that are "safe"
Handle annotated inline nodes in the converter

Was broken both on the way in and on the way out.

* Move alien restoration (data->DOM) out of the main getDomFromData()
  function and into getDomElementFromDataElement(). This means the
  comment about District 9 is gone (sniff), but moving this here ensures
  all code paths hit it (previously, it was assumed annotated nodes
  could never be aliens).
* In the DOM->data converter, add annotation application to
  getDataElementFromDomElement() (for content nodes) and createAlien()
  (for aliens). Previously, these nodes would not get annotations.
** ve.AnnotationSet doesn't have a constructor that takes an array, we
   should fix that.

Change-Id: I65f8e9a322111ca3af275bf9997b0b1e7ee93769
Make annotating inline elements actually work

The transaction builder would step around inline content elements when
building annotation transactions. This is now fixed.

I also tweaked the processor to tolerate attempts to annotate inline
closings. This allows the builder to generate simpler transactions,
because it doesn't have to step around the closing.

Change-Id: I1e0d7f95b38bad1b35b3e125a53350d2d126a7de
Show annotations on nodes in demo debugger

Change-Id: I41948e8549345c713f1bd0762b08807b8f7617da
Merge "(bug 42403) Add Parsoid prefix to POST requests too."
Store the data model element in the DM tree

This is cleaner than passing around the attributes separately, and it
allows us to access the annotations in dm.LeafNode as well.

Change-Id: Ie5b90988114835831cbe5cdccf63c7cd45719e31
Only apply HTML attributes to DOM nodes that are "safe"

* Added whitelist argument to setDomAttributes which allows filtering of attributes being set
* Added prefix argument to ve.dm.Node.getAttributes to allow extracting a subset of attributes by name prefix
* Added a whitelist to ve.ce.Node which was extracted from MediaWiki's Sanitizer class
* Replaced attribute copying code with a call to setDomAttributes using the whitelist argument, passing in attributes from a call to ve.dm.Node.getAttributes using the prefix argument

Also…

* Removed comment in constructor of ve.ce.Node, documentation for properties is usually in the getters/setters, and already was in this case
* Renamed ve.setDOMAttributes to ve.setDomAttributes
* Renamed ve.getDOMAttributes to ve.getDomAttributes
* Renamed ve.getDOMText to ve.getDomText
* Renamed ve.getDOMHash to ve.getDomHash
* Updated all callers of renamed methods

Change-Id: Id556172d5d18ea431044b9d402400e1f0e67a293
Merge "Fix tests for fda2e6c1b54a0139a3123de413f672e895ff3352"
Merge "(bug 42172) Tag edits made by VE"
Merge "(bug 42277) First character in empty document behaves strangely in Firefox"
Localisation updates from http://translatewiki.net.

Change-Id: I9d20942a1f9095ac9aeb4aa9868120f03e33dde5
(bug 42403) Add Parsoid prefix to POST requests too.

This is a port of Mark's https://gerrit.wikimedia.org/r/#/c/31348

Change-Id: I3a57992fdbeffad1df1d97239e98dbec52fdd5cb
Added contextChange event to surface model, replacing annotationChange

The contextChange event is fired when:
* Changes to insertion annotations
* Changes to which nodes are selected (start/end nodes have changed)
* Attributes have changed on any element (it's probably more expensive to detect if the changes are relevant than to just emit the event and let listeners do their thing)

This fixes most of the strange behavior with the toolbar not updating properly.

Change-Id: I5321d2e30bebd80987e0c779a9d8e061d8aa80bc
(bug 42404) Errors passing "incorrect" offsets to ve.ce.Surface.getNodeAndOffset

* Adjust offsets to correct positions before showing selection with them
* Throw an error inside of getNodeAndOffset if we can't find a match rather than mysteriously not retuning anything

Change-Id: Ia7347527e6466262e819f456404b32926fd95e34
Fix tests for fda2e6c1b54a0139a3123de413f672e895ff3352

Change-Id: I2725f3f775e092bafe7aa9dca71d2a9022f16db8
(bug 42172) Tag edits made by VE

Uses MW's built-in change tagging. Made this configurable so it can be
turned off if it looks like we're blowing up the tags system with the
volume of VE edits.

Change-Id: I63052d90772906e34021035de496a65fea7945f7
(bug 42277) First character in empty document behaves strangely in Firefox

This was because Firefox intially puts the selection before the first
paragraph, which translates to a model selection of (0,0). Typing with
the cursor at that position causes bad things to happen.

CE normally fixes up the selection when this happens, but it doesn't do
this automatically on initialization. So I added some code to ve.Surface
that causes this fixup to happen.

Change-Id: I0dcee3a29c1242c49ec30c743f1b69686fbb8436
The last ever mw.ext.ve jshint fixup

Change-Id: I262673214dd59e5bcaf4e0855e68728365b041fe
Localisation updates from http://translatewiki.net.

Change-Id: Ie008e85ee25d436c63e43dc68b79ad25a35f64e7
(bug 42402) Split out two cases so as not to throw an error

Logic called for A || B but then used both; this splits that into two distinct
code paths.

Change-Id: I959e0649fbd5b4f404b5804e26806ba51c31c836
Localisation updates from http://translatewiki.net.

Change-Id: If4f899438fdf8990bd35401fbd71fa6618d57754
(bug 42279) Inserted characters get annotated with empty set

Turns out this was actually a bug in addAnnotationsToData()

Change-Id: I0c9da662c091811e4053ab0ea2771c4a20b26e09
Fix even more inspector issues, and some ce ones as well

ve.dm.SurfaceFragment
* Removed flawed implementation of word mode for expandRange method and made use of new getNearestWordBoundary method in the document model

ve.dm.Surface
* Got rid of useInsertionAnnotations, which allowed disabling and enabling of insertion annotations - this isn't needed anymore because it was just a dirty hack around the improper starting and stopping of surface observer that's now solved more elegantly by emitting lock and unlock before committing or rolling back transactions
* Get annotations from the first character of the selection if the selection is not collapsed
* Only emit annotationChange events if it really changed

ve.dm.Document
* Added getNearestWordBoundary method which performs the work behind the surface fragment expandRange word method

ve.ce.SurfaceObserver
* Allow using an initial selection to avoid the observer thinking the selection has changed just because it started out with null
* Only emit selectionChange event if there was a meaningful change

ve.ce.Surface
* (bug 42279) Only annotate characters if insertion annotations are not empty
* Remove manual locking and unlocking, this is now done inside the change method of surface model
* Provide an initial selection to surface observer when we clear it
* Remove enabling and disabling of insertionAnnotations, this isn't needed anymore
* Stop/start observer on key presses that execute actions as well as those that have no special handling

ve.ce.Document
* Make getNodeFromOffsetand getSlugAtOffset return null when given -1 as an offset

Change-Id: Ibf6b26de299e54ae8688a2653bf5d5538927f8c3
(bug 42219) Fix for document sync issue

When working with a document containing only a slug in an empty paragraph, tree synchronization would break because it was trying to rebuild a non-existent text node.

This change makes the rebuild always occur on the outer range, rather than the inner range, which prevents absent text nodes from being asked to be rebuilt.

Thank you to Roan for debugging this for like 20 min.

Change-Id: I8c3dad921ace395f0694f77cec44305a680657fe
Localisation updates from http://translatewiki.net.

Change-Id: I86a9e953f42073deeecc237c53533462820ec39c
Merge "(bug 42124) Store comments in the meta-linmod"
Merge "(bug 42140) Don't force spaces to underscores in internal links"
Merge "(bug 42212) Fix JS error when inserting after alien at the end"
(bug 42121) Change markers lost for first paragraph on new page

When editing a new page, or loading an empty page into the editor, the
converter generates a paragraph so the document isn't completely empty.
This paragraph is then unwrapped on the way out, potentially destroying
change markers and generally producing strange HTML output.

Mark this paragraph with generated=empty rather than generated=wrapper,
and only unwrap it on the way out if it's still empty. This means we
cleanly round-trip empty documents (and empty list items and the like),
but if the user enters text, we create a paragraph like we're supposed
to.

Change-Id: Id0241221a67b769445676b833b5741320d99ea5f
(bug 42119) Handle alienation in wrapping mode properly

When alienating in wrapping mode, we need to look at the type of tag to
decide whether to create a wrapped alienInline, or to interrupt the
paragraph for an alienBlock.

This was being done just fine for the general alienation case
(unrecognized tag), but not for the special cases (mw:unrecognized,
about groups).

* Centralize the logic for ending a wrapper in stopWrapping()
* Move the wrapping-contingent block/inline detection logic into
  createAlien()
* Simplify the terrible if statement to decide whether a future decision
  requires us to stop wrapping. Instead, detect the cases in each code
  path separately and call stopWrapping() as appropriate
* Add tests

Change-Id: I4054584ae05e7d5daa71edead3e6a6588cf5d3bb
Merge "Add moar demo pages"
Merge "Make entity nodes work in CE"
Add moar demo pages

Change-Id: Id25803821ea0913f36a3c851c0542de12f7e408b
Display the lengths of model nodes in the demo debugging thingy

Also use .text() instead of .html() where appropriate

Change-Id: I9dcfd9c11c5c01f1459c48c8993c155203c94b13
Merge "(Bug 42335) Adding IE to the browser blacklist for the December release"
(Bug 42335) Adding IE to the browser blacklist for the December release

Unfortunately support for Internet Explorer is currently insufficient in the CE module
which means we have to kill it for December; it will return once we've worked out a way
around various bugs in IE.

Change-Id: I0b44ae2c1d75ffe748a5139ca74dcda615e12a6a
Merge "Fixed inspector behavior"
Make entity nodes work in CE

Check for all node classes in getOffsetFromTextNode(), not just
branches and aliens (an entity is neither)

Render entities with contenteditable=false. Without this, selection was
still broken, because:

Foo|€Bar was really <p>Foo<span>|€</span>Bar</p> which maps correctly.
Foo€|Bar was really <p>Foo<span>€|</span>Bar</p> which maps to the same,
which is incorrect.

With cE=false, the cursor can't be inside the span, so we get:
Foo|€Bar is really <p>Foo|<span>€</span>Bar</p> which maps correctly.
Foo€|Bar is really <p>Foo<span>€</span>|Bar</p> which maps correctly.

Change-Id: Iaf603346590a9ad553c152565eb203136be7a399
Fixed inspector behavior

ve.ui.Inspector
* Removed disabled state and interfaces - this isn't needed
* Renamed prepareSelection to onInitialize
* Using event emitter to run onInitialize, onOpen and onClose methods
* Left removal up to the child class to handle in the onClose method
* Replaced calls on context to close inspector to calling close directly
* Renamed prepareSelection stub to onInitialize
* Emitting initialize event from within the open method
* Added recursion guarding to close method
* Changed the close method's argument to be remove instead of accept - the more common case is to save changes, and the only time you wouldn't save changes is if you were to remove the annotation
* Moved focus restore to close method

ve.ui.Context
* Moved the majority of the code in openInspector and closeInspector to event handlers for onInspectorOpen and onInspectorClose
* Updated calls to closeInspector re: accept->remove argument change

ve.ui.LinkInspector
* Renamed prepareSelection to onInitialize and rewrote logic and documentation
* Removed unused onLocationInputChange method
* Moved restore focus (now it's in the inspector base class)

ve.dm.SurfaceFragment
* Added word mode for expandRange

ve.dm.Surface
* Added locking/unlocking while processing transactions - this was not an issue before because this was effectively being done manually throughout ce (which needs to be cleaned up) but once we started using the content action to insert content dm and ce started playing off each other and inserting in a loop - we already do this for undo/redo so it makes sense to do it here as well

ve.InspectorAction
* Updated arguments re: close method's accept->remove argument change

Change-Id: I38995d4101fda71bfb2e6fe516603507ce820937
Merge "(bug 42218) Add MWEntityNode"
(bug 42218) Add MWEntityNode

<span typeof="mw:Entity"> tags are now correctly represented in the
model, and rendered in CE. There are still issues with cursor movement
etc. in CE.

Because the prioritization mechanism for annotations vs nodes is broken
in the current "node API", I had to hack two special cases for mw:Entity
into the converter. I also had to change the converter to ignore the
children of inline nodes (this was a legitimate bug, but had never come
up before).

Change-Id: Ib9f70437c58b4ca06aa09f7272bf51d9c41b18f2
Fix message key, probably c&p error in I1cc00844

Change-Id: I4400ceeda59d76e433cda61c546a196cb3400ba8
Localisation updates from http://translatewiki.net.

Change-Id: Ie3c5ab02ac00f19f5f7b0bf2f65782eb748e990b
(bug 42124) Store comments in the meta-linmod

* Make converter generate meta nodes with 'style': 'comment'
* Handle style==='comment' in MetaBlockNode toDOM converter
* Add some comments to the meta test case
** Update other tests accordingly
* Change getDomElementSummary() to actually assert presence of comment
  nodes (specifically, all non-text child nodes)

Change-Id: Ieef9418f4c47df3541477d9420aa2ab8df6e3df1
(bug 42140) Don't force spaces to underscores in internal links

MWInternalLinkAnnotation was normalizing spaces to underscores. This is
bad. Instead, we now do the following:
* Normalize underscores to spaces for display purposes
* Store the original title without underscore/space mangling
* If the user didn't change the title (display title === original title
  with s/_/ /g), use the original title. Otherwise use the user's title
  verbatim, without normalizing either underscores or spaces.

Also, per a conversation with Gabriel, we now only restore hrefPrefix
when we're also restoring origTitle, otherwise Parsoid will barf.

Change-Id: Ia74a493b2bce96c9345b60ed692eeb2e43ebceff
Always apply inspected annotations to the right range

When you leave the inspector by changing the selection, we need to apply changes to the old selection.

ve.ui.Inspector
* Added initialSelection
* Change getMatchingAnnotations to use a given fragment rather than generating it's own
* Set initialSelection on open

ve.ui.Context
* Make hiding the context accept changes

ve.ui.LinkInspector
* Passing a fragment into getMatchingAnnotations now
* Using fragment API instead of actions API to control the range of the fragment

Change-Id: If6c8845285d87d0f144b15d50c38e192c797be59
Merge "Fixing Pre-Annotations"
Merge "Added undo-before-apply for new link annotations"
Added undo-before-apply for new link annotations

When the link inspector is used to create a new annotation, the text is annotated with the default link target derived from the selected text. Then if the inspector is used to change that value, yet another transaction is processed when the inspector is closed.

To avoid having to press undo 2x, this change makes the inspector undo it's first change before applying the changed annotation.

This change also introduces insert, remove and select content actions.

Change-Id: I3e29189158fb01336d6b053bc2a8bda2a91a0a46
Fixing Pre-Annotations

AnnotationAction and SurfaceFragment now use insertAnnotations.

ve.dm.Surface.test
* Removed test for annotate method (not needed anymore)

ve.dm.SurfaceFragment
* Now using getInsertionAnnotations method
* Added support for modifying insertion annotations when annotating a zero-length selection

ve.dm.Surface
* Moved in insertion annotations state from document model
* Added insertion annotation interface (enable, disable, areEnabled, get, set, add, and remove)
* Simplified handling of annotations on change
* Removed annotate method (not used anymore)

ve.dm.Document
* Removed insertion annotations (moved it to surface model)

ve.ce.Surface
* Cleaned up handleInsertion and changed it to use the insertion annotations interface on the surface model

ve.AnnotationAction
* Moved insertion annotation handling out of here since it's now included in the surface fragment

Change-Id: I047d656acf7fa1c63f726ca2b0801e1476f84f96
Cleanup var statements

Put non-assignment vars first

Change-Id: Id868976bc4d7c21032aef5020fe5fd0eb5df7a14
Merge "The great inspector and context rewrite of 2012"
(bug 42212) Fix JS error when inserting after alien at the end

TransactionProcessor was using parentOuterRange without checking whether
it was present, so it was exploding for indexInNode results.

Now checking for parentOuterRange presence, and falling back to
nodeOuterRange when missing.

This fix causes inconsistencies with zero-length text nodes. We should
fix these eventually, but for now I've just made the unit tests
tolerant of zero-length-text-node deviations.

Change-Id: Id9eadd57a0d5fcbaf009c0781da0a03928aebb31
Localisation updates from http://translatewiki.net.

Change-Id: I0fd2a0761ab62d22a4c76a218a85e82eb8cd0696
Localisation updates from http://translatewiki.net.

Change-Id: I24b10d41bc7ffac229c3335724df8edaf169f797
Localisation updates from http://translatewiki.net.

Change-Id: Ib32c20bdd01c5113a5600fa70a6c238ed1e8a347
Merge "(bug 42123) Add i18n for aliennated content tool tip."
(bug 42123) Add i18n for aliennated content tool tip.

Change-Id: Ibb98d256fb989cd69407b487df673ee22f8c9758
(bug 41947) Propagate change markers when unwrapping generated nodes

Editing the text of a list item results in a change marker on the
paragraph within that list item. However, that paragraph usually isn't
present in the HTML, so the converter unwraps it when converting back to
HTML, and the change markers are lost. Instead, transfer the change
markers to the <li>.

Change-Id: Id675075d19c08d69bc8e990174841dc393b749fc
Add ce.AlienNode to tests

Change-Id: I591501067732ae36c89da340398ad35e8d4b6e3d
Merge "Phantoms not vanishing on mouseout"
Localisation updates from http://translatewiki.net.

Change-Id: I7dcadb47a4996fb4995f349747c6331b3102cf50
Phantoms not vanishing on mouseout

If the mouse is moved too quickly, the phantoms have a tendency to stick. This change moves the event from phantom.mouseleave to surface.mousemove.

Change-Id: I2c7e7bdc838427d4355a6c0c13bafe3198636dbe
(bug 42134) Add shields after node is attached to the live DOM

This changeset introduces new variable property of ve.ce.Node called "live", which stores information whether or not given node is attached to the live DOM. When the value of this property changes event "live" is called.

Change-Id: I6d0ce923c25ff2c4015914f367582c9a15e62c65
Localisation updates from http://translatewiki.net.

Change-Id: Ida3f68c387b52b82a78519c6028c3046d6fe4417
Better Shield Logic

jQuery.css('float') returns different null values for Chrome and Firefox. This fix takes this into account and applies shields only to aliens and floated descendants.

Change-Id: I4c1db148043ee95991a17720dee8febad62c415a
Merge "Disable Table Editing"
Also increase the server-side timeout to 100s

Change-Id: Idff97fb7076251c481d1a8d7f83e6688ff0316d5
Disable Table Editing

Native contenteditable execCommands were being tried before the surface was attached to the DOM. This is necessary for disabling native contenteditable object editing and resizing.

Change-Id: Idff6a30432396726deb8a38356172380ea12fced
Merge "(bug 41722) Remove use of the Feedback tool for December release"
(bug 41722) Remove use of the Feedback tool for December release

We do not want to use the Feedback tool for the December release, as it does not
work cleanly with LiquidThreads and would strand most users in an unfamiliar
wiki and expect them to have more complex/technical responses than they are
likely to be able to give; instead, have just purged it entirely from the code
(except for i15d strings, per Roan).

Change-Id: Ieebdca3d365943d901e2df37228120fdcff50afd
Merge "Display overlay phantoms for inline blocks (no need to use shields)."
Merge "Support for node HTML attributes"
We'll want a 100s timeout, not 10s

Barack Obama takes 60s to parse, according to Gabriel

Change-Id: I1a63225c0961ca9d56dccd018d400831b1d528e9
Merge "Ignore hidden-ness of visualeditor-enable preference"
Ignore hidden-ness of visualeditor-enable preference

Needed to make the dark launch work

Change-Id: I1c6f22cb85fdd852bfcc9985d826032f128c6b82
Merge "Temporary quick fix for BugId 41223. It is just for release purpose and I will keep working on solid solution."
Temporary quick fix for BugId 41223. It is just for release purpose and I will keep working on solid solution.

Change-Id: I3f428f88b0e8d6d837f1dfd9d269ca3c99147ed7
Merge "<br> isn't a block element"
Merge "Rewrite ve-parsoid API module"
Rewrite ve-parsoid API module

* Factor out getHTML(), postHTML(), saveWikitext() and parseWikitext()
* Use the API to save instead of using doEdit() directly
** This fixes a lot of integration bugs
** Get rid of the blocked user check, edit API checks this
* Check the namespace parameter
* Require tokens and POST
* Add diff functionality

Change-Id: I31891d1485985629db4e39532fb34e0e7fe23796
Support for node HTML attributes

Walk through node model attributes and pick just the HTML ones, then apply them to the DOM element

Change-Id: I7e0ffd71023ad692fcad7386b853410747398793
Merge "Disable change marking by default"
Display overlay phantoms for inline blocks (no need to use shields).

Change-Id: Ife362035c43daf863a3b6a5f892dc928d1f6ec80
Merge "Alien Phantoms"
Alien Phantoms

This changeset adds a visual treatment to uneditable AlienBlockNodes to indicate to the editor that the elements are uneditable. To deal with odd shapes, the alien's shields are cloned and added to a phantom container. The phantom container and the phantoms themselves may be styled appropriately.

Change-Id: I7ad52707966bc18be627aa4269725004edba86cd
Localisation updates from http://translatewiki.net.

Change-Id: I9477f99e345a0dd998e890c945b4bfaa2517077c
Disable change marking by default

It's causing problems with Parsoid in production

Change-Id: Id47493baafe1ec7f7c0e2bbdb2ea60a82913dfaf
<br> isn't a block element

Also remove commented-out <img>

Change-Id: I7dc9f3b23c15008047cad938ed3408f55ea568d2
Merge "(bug 41072) Add support for adding outer length in ve.ce offset getters"
Localisation updates from http://translatewiki.net.

Change-Id: I08515d4e1abab80d5182d3895f63cf42a231fb19
(bug 41072) Add support for adding outer length in ve.ce offset getters

ve.ce.getOffsetFromElementNode now supports adding outer length
of given node to status functions.

It is temporary solution that I will review in the future.

Change-Id: If779802156aa78dbced9d4c769e8e7877120b337
Merge "Fix JS error in unlisting"
Merge "Nicely highlightable alien nodes"
Nicely highlightable alien nodes

Browsers handle highlighting of our alien nodes differently. This change normalizes by hiding the native selection on the aliens, inserting blank image "shields" with native highlighting enabled.

Change-Id: Ica3576ef0e3c42b4aeae1da374cd1dc92f203d7d
Fix for ve.ce.BranchNode.setupSlugs - insert each slug only once

When using jQuery insertBefore and insertAfter make sure to pass as a parameter jQuery selection of only one element (first for insertBefore and last for insertAfter).

Change-Id: Id469ed775642ab5be8e274ab3cb7730899e9487a
Localisation updates from http://translatewiki.net.

Change-Id: I731ef8fa80d811ce2aea6f8a7cd4071ca81810af
Fix JS error in unlisting

The signature of getUnlistRanges() changed in the UI rewrite, but the
recursive call wasn't updated. This caused unlisting of lists that
contain lists to break and throw a JS error.

Change-Id: I990120a906868a5160561cff6b963f5ba5473427
Localisation updates from http://translatewiki.net.

Change-Id: I38b10dc8ebb5e080407b8241a8fa02f70670e820
Localisation updates from http://translatewiki.net.

Change-Id: I25fa8e1f8d2dc6006e2e803c9d3b2284e483e468
Merge "Add basic support for about groups"
Add basic support for about groups

About groups are HTML structures like the following:
<div about="#mwt1">....</div>
<span about="#mwt1">...</span>
<div about="#mwt1">...</div>
When about groups are alienated, they are now merged into one alien
node, rather than producing a separate alien node for each sibling.

This is very basic about group handling, because it only works for
groups of directly adjacent siblings (text nodes are permitted in
between, but nothing else) assumes all about groups are aliens (which
is currently true).

* Before processing an element in the DOM->data converter, perform about
  grouping on its children. This temporarily wraps about groups in
  <div data-ve-aboutgroup="value of about attribute">
* Extended createAlien() to handle single nodes as well as wrappers
  holding multiple nodes.
* In the data->DOM converter, temporarily wrap multi-node aliens in
  <div data-ve-multi-child-alien-wrapper="true"> . This makes the rest
  of the algorithm easier.

Change-Id: I2df5f62bc222b570fc11a89fe43d353f8363ead8
Added some more key bindings for IE and Mozilla support

Change-Id: Ic4bcd53d41fcd676d5929bfb94d0cbf3afb6968e
Merge "Mapped tab key to indentation action"
Mapped tab key to indentation action

* Added cancelable action return value to surface execute method

Change-Id: I57a58962399a46a0e41b4e95e438dc528770d619
Merge "(bug 41865) Make the save button available immediately for oldid pages"
Merge "Refactored commands into a registry"
Refactored commands into a registry

* Now ve.Factory inherits from the more general ve.Registry
* New class ve.CommandRegistry
* Refactored setupToolbar and command setup code into setupComands

Change-Id: Ic548e5de95b77889727362d3e66d7be83c12a603
Merge "Replaced command factory with new command class"
Replaced command factory with new command class

The port of mousetrap wasn't really what we needed. This is much simpler, matches the rest of our code, and does exactly what we need.

Change-Id: I67f413e097fc2d4078336edb14dd9440e771f196
Merge "Fixed line-height variations between sa and mw integrations"
Fixing native selection rendering for floats

This fixes a problem with how Chrome renders native selection around floated elements. By adding pseudo elements before and after block aliens, the rendering is fixed.

Change-Id: I7fdbb8f4c42e29d0574b308b8c5740066bb58e94
Merge "Flag pre nodes as having significant whitespace"
Merge "Made commandFactory tests not break anymore"
(bug 41865) Make the save button available immediately for oldid pages

Also consider making it say "Restore page" initially for oldid pages until a change is made

Change-Id: I9e5ce76520e091612afe4fbc0300cff8ca645335
Made commandFactory tests not break anymore

Sequences that were scheduled directly after each other, such as "a b c" and "1 2 3" would end up overlapping sometimes, producing "a b 1 c 2 3" which failed to trigger the correct commands.

Change-Id: I27bb60e856e9d692a21e1587dc227f8aeb5fcf4e
Merge "Made jquery.multiSuggest it's own RL module"
Localisation updates from http://translatewiki.net.

Change-Id: If8f9d437f9d1e33602514b7470f844352de36e06
Flag pre nodes as having significant whitespace

This causes the converter not to strip inner whitespace in them, and
causes CE to suppress the whitespace mangling logic that is normally
applied (↵ for newlines, ➞ for tabs, alternating &nbsp;s for spaces).

Change-Id: I738a750c91a4ca4836c485e282865bb7525bf30a
Made jquery.multiSuggest it's own RL module

* Also updated resource paths in tests and demo pages

Change-Id: Ic21b678f91ed8d1fe1c7ac2a53d89270aacf7c26
Merge "Removed introduction of global variable"
Localisation updates from http://translatewiki.net.

Change-Id: Ib247815a3a047e5950155cd3c2421ed9b1e2afc0
Removed introduction of global variable

resetSequences was being called in the context of window instead of a contextFactory

Change-Id: I1b9ee25547bd18d59eac4b991ecc813b81f92a4c
Fixed line-height variations between sa and mw integrations

* Also fixed format drop-down's preformatted label styling

Change-Id: I983ff71959f5e78e52fbe4c585db20357b7ca2d5
Add change marking for Parsoid's benefit

* Add map of change markers per offset to Transaction
* Map is populated by TransactionProcessor
* Markers are reversed on rollback
* Removals aren't marked, Parsoid can detect these using DSR
  discontinuities

Change-Id: I2290886ab411c6ad6162044ed85c091313613e51
Merge "Styling aliens with a yellow background; preventing absolute positioning"
Merge "Integration revamp for December release"
Merge "Fixed font-size issues for monobook integration"
Styling aliens with a yellow background; preventing absolute positioning

Change-Id: I86fbbda841d69beeabf4e683de3b032fb70b1ac6
Fixed font-size issues for monobook integration

Change-Id: If71fbd186979777b73c84f64610c8485017de654
Localisation updates from http://translatewiki.net.

Change-Id: I750fc83b0530d867e0d2614b0615cbcb83c6ba72
Merge "Improved the responsiveness of the context menu"
Improved the responsiveness of the context menu

* Added selectionStart and selectionEnd events to ve.ce.Surface
* Switched from debouncing model change events to just ignoring
  model change events while the user is in selection mode
  (dragging mouse or pressing shift+arrow keys)
* Fixed bug with callout appearing on resize.

Change-Id: I3bb9952867a983a4f7612964ff719a1179dd0fc6
Integration revamp for December release

* Remove VisualEditor namespace, and restrictions on it
** For MW.org these will be moved to mediawiki-config
* Add $wgVisualEditorNamespaces
* Add visualeditor-enable preference and respect it
* Use $skin->getTitle() rather than $wgTitle
* Remove "Sandbox" from i18n message
* Remove duplicate enforcement of VE namespace from JS

Change-Id: I956f68c2dde55e4063530fcc7c90eda048e0d78b
Merge "Introduce meta-linmod"
Removed ve.init's dependencies on ve.ui styles

* Things broke when ve.ui stuff was refactored
* Save dialog is now completely stand-alone

This is an alterantive to Ib028e6967e8d2e158b05fd7582620c21cf9b85fb
which I believe is a better approach.

Change-Id: I7cb52d0750e859c4052e2008d929d197b88b9877
Localisation updates from http://translatewiki.net.

Change-Id: I7f53cf692b95cd76f530c3289f9a2ee85b3e68ea
Localisation updates from http://translatewiki.net.

Change-Id: I43b3d022da55878430e42ea9a0ce85f5c616441a
Introduce meta-linmod

* ve.dm.Converter still generates metaInline/metaBlock elements as
  before, it's not affected by this change
* ve.dm.Document constructor splits its input into "real" data and
  metadata
** Metadata is stored in this.metadata (the meta-linmod) as a sparse
   array of arrays, with an element for each offset in this.data
** this.data itself does not contain the metadata
** This means the node tree also doesn't contain the metadata
** Which means CE doesn't know about it at all
* All splice operations on the linear model are sent through
  ve.dm.Document.spliceData(), which performs the splice and syncs the
  meta-linmod
** Metadata in the removed range is reaped and added to the metadata for
   the offset immediately following the removal
* ve.dm.Document.getFullData() splices the linmod and meta-linmod back
  into each other; this "full data" is then fed back to ve.dm.Converter

Change-Id: Ief6dfd5b59cc13a8457993ed85c725413029c4fb
Merge "Base for inspectors & context menu to operate on 0 length selection."
Base for inspectors & context menu to operate on 0 length selection.

* Allow inspector to open with 0 length selection.
* Allow context menu to open with 0 length selection.
* Fixed bug in doc.getAnnotationsFromRange on zero length selection:
  Method now returns annotations from start vs empty annotation set.

Change-Id: I3937c5c2824c7396d0c3ee11c13ffecdbed6052a
Merge "Cleanup tool API"
Cleanup tool API

* Moved to tool specific configuration to static properties (left tool instance specific stuff in the constructors)
* Added documentation for tool configurations
* Centralized typePattern matching for inspectors

Change-Id: Ieacf61b320c10fd37ea69a05e543313fa990b403
Fix ve.batchSplice() to behave in line with docs

* Actually return the spliced data like the docs claim we do
* Remove false claim that offset can be negative
* Add that data=[] && remove=0 is invalid; native splice() doesn't allow
  this, and there is a case where we call native splice() directly
* Add tests

Change-Id: I90e77c1b22ea1c36cb61e89ea47831885a0b1cb9
Merge "Fix copyObject/copyArray behavior with null values"
Merge "Add InspectorFactory to tests"
Fix copyObject/copyArray behavior with null values

Previously copyObject and copyArray would silently drop null values,
which is bad, especially considering we have example data for meta nodes
that has { 'key': null } somewhere.

Also added a test case that failed prior to this change.

Change-Id: I4f233cce041fbf38f701c494f1f78ac3d8535d88
Add InspectorFactory to tests

Tests were completely broken because the link inspector threw a JS error
when trying to register itself with the nonexistent inspector factory.

Change-Id: I8a47222f0a5a37348262ed939b37fbc47d14e222
Localisation updates from http://translatewiki.net.

Change-Id: I68ad405772ddbb85e56524563decfc8c0aeb8740
Fix bug where link inspector / context overlay would no longer show.

Change-Id: I73281dc32eae5660662898d0290468434e7326d9
Localisation updates from http://translatewiki.net.

Change-Id: If8b4ce3c06dd78c26d44d0f73d00f3bdeac0226b
Localisation updates from http://translatewiki.net.

Change-Id: Ib9b8748fc9c687f17669d983373758006c47db91
(bug #41434) Converting format across 2 lists with paragraphs in between fail

Thanks to Roan for suggesting this fix.

Change-Id: I754dc34fbd3aaf2bdcb78bf89bfc896b612b4ee6
Really properly initialize static member before adding stuff to it

Kill them console log errors 'til they're dead.

Change-Id: I7329f4c869f46a9ef664af8ab49cb2504abdf972
Properly initialize static member before adding stuff to it

This was causing a console error

Change-Id: Ic394cf4d4821bd7c03fd32bb9e202801dccde085
Merge "Whitespace and comment cleanup on ve.ce.SurfaceObserver"
Merge changes I0de5d327,I589ecba3,I840f7242,Ie786fa3d,I04723499,Ibde934d5,I993f4cbe

* changes:
  Add commands to ve.Surface
  Tools changes
  UI context reorganization, inspector rewrite, iframe refactor, icon generalization
  Add ve.Action, ve.ActionFactory, subclasses
  Add ve.dm.Surface.has{Past,Future}State, add docs
  Add ve.dm.Node.hasAttributes()
  Add ve.dm.Node.hasMatchingAncestor()
Add commands to ve.Surface

First stab at a simple command interface. This and commandFactory
will be refactored significantly before this code is put into
action.

Change-Id: I0de5d3271198c987baf06fb3011aebdc1671f498
Tools changes

* Rewrite of all tools, dramatically simplifiying them and decreasing
  duplication
* Tools are now created using a tool factory instead of
  a make-shift facility built into the toolbar
* All UI object have a surface or a toolbar reference instead of a
  surface view

Change-Id: I589ecba36bf715b452d03c8fd5c0547dc3c1dc61
UI context reorganization, inspector rewrite, iframe refactor, icon generalization

* Only show the inspector if the selected text has an inspectable annotation
* Replace the inline menu with a toolbar containing inspectable annotations
* Change the appearance of the inspector to match new mockups
* Add the trash can icon for removing annotations
* Move iframe handling code into a class that manages all that nonsense

Change-Id: I840f72426f9a9e50054a28de950393f0e9913153
Add ve.Action, ve.ActionFactory, subclasses

Moved implementation of all the tools into a reusable action
system. To execute an action just call

surface.execute( actionName, method, param1, param2, ... );

This helps keep tools simple, and opens the door to key commands
reusing the same code.

Change-Id: Ie786fa3d38d1ea17d39b5dfb8eeeb5f2256267ce
Add ve.dm.Surface.has{Past,Future}State, add docs

Will be used by the history tools in a future commit, providing
a reasonable interface to this information rather than the tool
reaching into private members.

Change-Id: I0472349968e9b48ec17eb47b6845ec9ccf3811e2
Add ve.dm.Node.hasAttributes()

Will be used in future commits to reduce duplication.

Change-Id: Ibde934d5a55b980010e84b6242f8d968e88cea54
Add ve.dm.Node.hasMatchingAncestor()

Will be used in future commits to avoid traversing up the tree and
comparing type and attributes.

Change-Id: I993f4cbe20018406dbb4a3c9d1ce2f8766f8e1ba
(bug 37843) Trying to edit a blank page fails

Explicitly check for false, because the empty string does not signify a
failure.

Change-Id: I8857d39e1a20080c8419c6165be2b5ad0cdbacd2
Localisation updates from http://translatewiki.net.

Change-Id: I12c7cea5120485b963ea1dad105fbab579426485
Add ve.dm.SurfaceFragment.getAnnotations()

Change-Id: Ifb731e8fdd0f111f5da4ac0d882adaad3f48fdce
Merge "Fix annotation object creation in SurfaceFragment"
Whitespace and comment cleanup on ve.ce.SurfaceObserver

Change-Id: Ice4058f1041f3d0118c7955122b8ea4d538790e0
Merge "Test: Enforce # of expected assertions."
Merge "Documentation fixes"
Test: Enforce # of expected assertions.

Change-Id: I041c792d1841f69677f8c7d38f67108475a0afc9
Merge "Localisation updates from http://translatewiki.net."
Localisation updates from http://translatewiki.net.

Change-Id: Ib8b826ea7d5d2b6080d71a9cf2fc4ac6f375bd6a
Merge "Fix JS error in ve.setProp()"
Fix JS error in ve.setProp()

Attempting to descend into a string or number would cause a JS error,
because we would attempt to create prop[arguments[i]] as an empty object
(which is ignored), then try to descend into it (which blows up because
it's undefined, even though we've just set it). Guard against this by
explicitly checking for non-object-ness.

Change-Id: Ie65550baaae0ab88476c9a1ff40cc136090740a0
Fix number of doc sync tests

Follow up to I84f0368b1d7b601ed0766806607152dc97f34603

Change-Id: Ic1e9de1e755b8966b6e964b01b00f4d99d27245e
DocumentSynchronizer fix and cleanup

* Adjust the range in the annotation synchronizer, otherwise we emit
  events for the wrong node
* Expanded test suite to the point where it was able to catch the bug
  caused by not adjusting annotated ranges
* Removed selection.length === 0 check, no longer needed because
  selectNodes() now throws an exception in this case
* Added a FIXME comment about duplicate update events that occur when
  length adjustments are combined with something else
* Add a few more comments

Change-Id: I84f0368b1d7b601ed0766806607152dc97f34603
Merge "Actually use nodeOuterRange, selectNodes() has provided this forever"
Merge "Reorganize text-only replacement detection"
Merge "Guard transactions against double commit/rollback"
Merge "No longer copy data in ve.dm.Document constructor"
Actually use nodeOuterRange, selectNodes() has provided this forever

Change-Id: Ie1d3cbb6e475248927d10f411cf383f701a3ad71
Reorganize text-only replacement detection

* Lift node assignment out of the if/else
* Flip the condition so we detect text-only replacements rather than
  non-text-only replacements
* Additionally assert that there is exactly one selected node, and that
  it is a text node

Change-Id: Iaaddf532f06709e860ac44457470e6d8bfcb6dd9
Guard transactions against double commit/rollback

* Store the applied state in the Transaction
* Store the Transaction in the TransactionProcessor (previously, only
  its operations were stored)
* Have commit() and rollback() throw exceptions when passed transactions
  with the wrong applied state
* Add tests for this behavior

Change-Id: I27b7a96fdf4d3555d78f64c05a03702ea560c802
No longer copy data in ve.dm.Document constructor

The data array is now taken by reference, and the caller must perform
any copying required.

Changed tests to make a deep copy of shared data sets (mostly
ve.dm.example) before passing them to ve.dm.Document().

Change-Id: Iedc64f9fd9cd689640de9a19379cf5f3db94a2bb
Remove 'internal' property from DM nodes

There's no use case for keeping a deep copy of the 'internal' property
in the node tree, and it was breaking some of my new tests concerning
change markers. We could keep internal data in the node tree if we
wanted to, but to be correct we'd have to synchronize every time we
changed it, which is a pain.

Change-Id: I024de1ff8b6b6154da82c103c4bb21db8ff2ec14
Fix annotation object creation in SurfaceFragment

Also add a comment about how the way data is passed to a new annotation
needs to be improved

Change-Id: I693e4f5632b4eae0d2ee3468ee979454314f6364
Documentation fixes

Change-Id: I5020623ba59cd9d1794b7d1f97d3adf77b833d6e
Merge "ve.ui.CommandFactory: Initial implementation"
ve.ui.CommandFactory: Initial implementation

Based on https://github.com/ccampbell/mousetrap.

Cleaned up to fit our coding standards, pass JSHint, and assume
jQuery's fixes where possible (e.g. no need for an addEvent
utility, no need for filling e.target, e.which, etc. cross-browser
which jQuery.Event already does).

Initially all were local functions in the constructor, but to
allow some customisations in subclasses moved various methods
to the prototype instead and marked with @private.

Really, only .register() must be called from the outside. The rest
assumes normalisation etc. or might break things if called
incorrectly.

Change-Id: Ic69a3c70759052094aefbeab623d885f8b118e14
Standards: Fix global variables and pass JSHint.

Follows-up:
* IK 714e29d30fb81054c885abe0a3e4edee40d8d75e
* IK 3b8a5ae4d549ba9e92b540d250b3eaf669ee2d30
* IK 72eb2825e5bfb1ee63dba29004bb9bbb2a96ef57
* RK 7fe7182f43ca5c18e844213d73387b1f55674490
* ...

Change-Id: I671f08e4899bfb9508cef272190ec72721a0af9a
Upstream: jQuery 1.8.2, QUnit 1.10.0.

* http://code.jquery.com/jquery-1.8.2.js
* http://code.jquery.com/qunit/qunit-1.10.0.js
* http://code.jquery.com/qunit/qunit-1.10.0.css

Change-Id: Id254d377557ee690acfd44cf6b33a5f60f152f6e
Merge "Add parentOuterRange to selectNodes() output"
Merge "Rename property "timeout" to "timeoutId" - more descriptive."
Localisation updates from http://translatewiki.net.

Change-Id: I7646f89310781f0da59173347886b1a12776edae
Rename property "timeout" to "timeoutId" - more descriptive.

Change-Id: I198d07e3c59ba1283085135f45882ce606bb2389
Merge "Removed htmlTagName and htmlAttributes from hash"
Merge "Fix for native deletion - it was breaking document (model and view) when deleting really fast (holding the key for example). This solution completely fix the problem, however it is not optimal - stop and start is called more often than should be."
Removed htmlTagName and htmlAttributes from hash

This was only causing data bloat and also errors because htmlTagName and htmlAttributes are only set if the annotation was constructed from an HTML element

Change-Id: I3d36bca6cd0194e1a4456bb51156117f70b96b13
Add parentOuterRange to selectNodes() output

This is the outer range of the parent of the node, if known. We'll need
this for change marking: when resizing a text node, for instance, we
need to mark its containing parent. This way we get the containing
parent's element's offset for free (selectNodes already tracks it in
currentFrame) rather than having to compute it with another traversal.

Change-Id: Ia335d8080ea9d414ab9f89b943e2ea0cd11d7df3
Merge "Make the debug tool (Dump all data) compatible with ve.AnnotationsSet (instead of array)"
Merge "Do reference comparison in selectNodes() tests and fix test data"
Merge "Add missing var statement"
Make the debug tool (Dump all data) compatible with ve.AnnotationsSet (instead of array)

Change-Id: I0ff131d69933a0fe98232410eb7be72ea2492066
Do reference comparison in selectNodes() tests and fix test data

Some tests were using the wrong node in the expected data, but because
only the summaries were compared, this would succeeed as long as the
type and length were equal (and paragraphs of length 1 are quite common
in our test data). Fixed equalNodeSelection() to compare each node by
reference as well as comparing the summaries. If one of the equality
tests fails, the summaries will still be displayed as expected/actual
data (even though they might be equal), and the message will  have
"(reference equality for selection[3].node)" appended to it.

This change broke the tests because a few test cases had bad data, fixed
those in this commit as well.

Change-Id: Iab420cf29d47f7368c8a9ce79f6309efae75685c
Add ve.setProp()

Change-Id: I6f932917f8e6321e9c415900b70404406af96d5c
Add missing var statement

Change-Id: I573e952c60550c29bf7958c221899b72a934fb0c
(bug 41055) Fixing large content copy and paste from external source for Firefox/Windows

Change-Id: I7169566cca486eb5085922c5ac8d932c60a7dcbb
Fix for native deletion - it was breaking document (model and view) when deleting really fast (holding the key for example). This solution completely fix the problem, however it is not optimal - stop and start is called more often than should be.

Change-Id: Ied5b34f92056407311aa1e84fbff35943138987f
Merge "Fix selectNodes() bug reported by Inez"
Fix selectNodes() bug reported by Inez

For <p>1<br/>2</p>, selectNodes([2,2]) correctly returned the end of the
first text node, but selectNodes([4,4]) returned index 2 in the
paragraph (i.e. between the break node and the second text node). The
correct behavior is to return the start of the second text node, i.e.
the mirror image of the behavior for [2,2].

Fixed this by applying the startBetween/endBetween logic only if the
relevant adjacent node is wrapped (or if it's missing). In the code,
this is expressed as !(adjacent node present && adjacent node wrapped).

Change-Id: Ie3b7fdf1de38ee253a798a7a73bc89734f4ca4fa
"Is there data?" a.k.a. Insert data only if there is a data to be inserted.

Change-Id: If5957c38668f4dedcba72fc79f9a273614c6dce3
Merge "Fix bug in ve.ce.BrancNode.setupSlugs. It was removing slugs from the DOM, but not from the internal (this.slugs) collection, so getSlugAtOffset was returning incorrect information."
Fix bug in ve.ce.BrancNode.setupSlugs. It was removing slugs from the DOM, but not from the internal (this.slugs) collection, so getSlugAtOffset was returning incorrect information.

Change-Id: I0307d2dfe5c62f992287532ef8925fead2899c58
Wrap inline elements properly

The HTML "1<br/>2" was being converted to a linmod that looked like
"<p>1</p><br></br><p>2</p>". This commit fixes the wrapping logic such
that the result is "<p>1<br></br>2</p>" instead. In general, inline
nodes (content nodes) should not interrupt the wrapping, but block nodes
should.

This creates a problem for alien nodes: normally, we determine whether an
alien node is a block alien or an inline alien based on context, but if
we're in wrapping mode we're unsure of the context. We can't tell the
difference between "1<tt>Foo</tt>2" (should be wrapped as one, because
tt is inline) and "1<figure></figure>2" (1 and 2 should be wrapped
separately, because figure is block) using context alone, so in these
cases (and ONLY in these cases) we look up whether the HTML tag in
question is an inline tag or a block tag and use that to decide.

Change-Id: I75e7f3da387dd401d9b93e09a21751951eccbb83
Merge "Fixing location of ve.ce.CenterNode.js and adding comma between variable declarations"
Fixing location of ve.ce.CenterNode.js and adding comma between variable declarations

Change-Id: If54e314f47860ac30060bec6b3f5997ed3709e0b
(Bug 41120) Missing coma. Who knows how it happened...

Change-Id: I4c0a65cc751bf378368df9f8b793f672fb7cca15
Whitespace and comment cleanup for dm annotation classes

* Added comments to classes and methods
* Quieted a jshint warning
* Broke some long lines
* Replaced instances of "var\t" with "var "

Change-Id: I1d617ed9e5180f1a3dff42078fb5debb5d718407
Merge "Fix exception when deleting all text (Ctrl+A Backspace)"
(Bug 41120) When getOffset is called for a slug offset there is no need to traverse DOM - we can simply just call getSlugAtOffset and use that information.

Change-Id: I46b21ca0d3ca11d72c77feeb884f7d92a201de36
Merge "Fix JS error in DocumentSynchronizer when adding to an empty document"
Merge "Get annotations from first character of a range"
Merge "Fix path issues with missing files, inconsistent subset in demo, test & mediawiki."
(bug 41092) Fixing cut

Surface was being accidentally locked when we actually want the surface to re-render.

Change-Id: I1d20faec8e55934e1fff7534c7d8cfe94d19031d
Ignore backspace keypress

Firefox triggers a keypress event for backspace. We handle backspace in keydown, so this keypress event should be ignored.

Change-Id: I6a481dbd5df0cf4558a5f1975717ca809250ccda
Fix path issues with missing files, inconsistent subset in demo, test & mediawiki.

* CenterNode missing in ResourceLoader registry
* UI classes and rangy not in static test/index.html
* Transaction and TransactionProcessor listed twice

Added a maintenance script that generates the <script> and <link> tags for all
files in the same order everywhere.

Change-Id: I5d22d33769b4e356e8065d295505f6f9a8b0bea8
(bug 33064) Ignore non-content keypresses

Ignore keypress handling for any keypress with e.which of 0.

Change-Id: Ifa8a562eb882b337bad466183849ba9871605653
Get annotations from first character of a range

If you select some text and start typing, we will now remove the content in the range and new content will be annotated with the annotations from the first character in the deleted range. This is similar to other editors.

Change-Id: I46ced52665ab10f9b724dbb225df5687c18a4c3a
Fix exception when deleting all text (Ctrl+A Backspace)

Exception was caused by passing -1 to getAnnotationsFromOffset(). So
check for -1 before passing it in; getNearestContentOffset() can
legitimately return -1 if there are no content offsets in the document,
which occurs when the document is empty.

I was originally going to change getNearestContentOffset(start - 1, -1)
to getRelativeContentOffset(start, -1), but Inez correctly pointed out
that that would have unwanted results when near an inline node.

Change-Id: Ife4b497b1c5fd04d411bb25cea99e6ea2abf146f
Fix JS error in DocumentSynchronizer when adding to an empty document

This was reproducible by blanking the entire document (Ctrl+A Delete),
then undoing that (Ctrl+Z). AFAIK that's the only way to trigger an
insertion on a document that is completely empty.

Change-Id: I22252d5972a413dff614880a90c4c6b22e79672d
Fix bold and italic key commands in surfaceView.

Change-Id: Iefc436a27285fd811b9d1ac2c684160fe7818a30
Added support for Ime in IE. In IE when starting IME sequence 'compositionStart' is called to late, but fortunatelty we can do all necessary job in handler for 'keyDown'.

Change-Id: Id6f15015c45afd81cf8e74d3e03f7fa21611862d
Merge "Reversed the default value of autoSelect in surface fragments"
Fix UI for annotation API changes

Change-Id: Ib8341436ba966628c93854a742d8b3a5b45a1d83
Added multiple name registration to ve.Factory

Also changed from using "type" to "name" to make it less specific and added a test to make sure it's working.

Change-Id: I150a7ab1a57b3df85b459dbc411c2eaefe08b5bb
Merge "Add a missing reference to file ve.dm.SurfaceFragment.js inside index.php for standalone demo."
Reversed the default value of autoSelect in surface fragments

Arguments with default truthy arguments are evil

Change-Id: I3fb972af1b8f52837497950281c537fe09eb7975
Fix context icon in surfaceView

Change-Id: I742b6df25679827fd0e3096a58bb5291c5f4f77d
Fix standalone demo.

Change-Id: Ieef15ad3edc039b205e5e4e870311927384be561
Add a missing reference to file ve.dm.SurfaceFragment.js inside index.php for standalone demo.

Change-Id: I12c134a4a2e2bbec271ade5d211c48939cfc9a5f
New annotation API: update tests

Change-Id: I301a1d89c33dd68197d629d187a9a5be8cbf3852
New annotation API: ve.ce.TextNode integration

Finally getting rid of .annotationRenderers, yay!

Change-Id: I17cb2598de9747d1e3b68ff18ebb02efd56c04c3
New annotation API: ve.dm.Converter integration

The annotation-related code in the converter is greatly simplified
because the API itself takes care of almost everything already.

Change-Id: Ib48f52bad6b650a05dc4e7ef82db4158c19b3cf5
New annotation API: convert existing annotations

This changes ve.dm.LinkAnnotation to be a generic annotation for <a>
tags, and adds ve.dm.MWInternalLinkAnnotation and
ve.dm.MWExternalLinkAnnotation as MW-specific subclasses. This nicely
splits out the MW-specific parts in LinkAnnotation, and ideally we'd
also move these files somewhere else to reflect their MW-specificity,
but I haven't gotten to that yet.

Similarly, ve.dm.TextStyleAnnotation is now a generic base class for
simple tag-only-no-metadata annotations, and it has 11 subclasses, one
for each tag we support. This is quite a bit more verbose than the
previous code, but I think it's cleaner and more flexible. I considered
writing a function that would generate a TextStyleAnnotation subclass,
then calling that 11 times, but that's not possible if we want to keep
named functions for the constructors.

Change-Id: Ifba10153eef40280e44025dd72d4e9d9f33b0632
New annotation API: Annotation and AnnotationFactory classes

Fleshes out ve.dm.Annotation to a class. Annotations in the linear model
will be instances of a subclass of ve.dm.Annotation. Annotations are
defined by subclassing ve.dm.Annotation and registering this subclass
with ve.dm.AnnotationFactory.

ve.dm.AnnotationFactory keeps track of which annotation classes are known,
and has code to match an HTML element to an annotation class, for use in
the converter.

Change-Id: I68802bdb8736ced1f9e04ee49c623944b448141c
Merge "Revert "No longer create zero-length text nodes""
Revert "No longer create zero-length text nodes"

Inez asked for this to be merged but now says it's broken

This reverts commit 7702ec10dcdf994d1c884fa38a6f809447ddf658
Refactored method ve.ce.Surface.handleInsertion. Now handling slug and insertion annotations is combined.

Change-Id: I70494c185addcf4d07d385dc1e9745aca2f9d05b
Merge "Added missing reference to SurfaceObserver in VisualEditor.php"
Merge "Support for pre-unannotating test"
Merge "Native cursor movement"
Native cursor movement

The cursor will move natively when it can, allowing for word jumping with alt/ctrl keys. Special conditions exist for slugs and node boundaries that result in programatic movement.

Change-Id: Ife156bf94d8192ddd322c016ca8359855b17d7fc
Added missing call to surfaceObserver.clear();

Change-Id: I64eeeef8339d5765d5ce732e660eeba35482d7d3
Support for pre-unannotating test

Removing check for insertAnnotations length because it's also important to know if we're pre-unannotating text.

Change-Id: I7fab39ca353d7656de3ce2985a821cb54384100e
Added missing reference to SurfaceObserver in VisualEditor.php

Change-Id: I05c93f55e2fd3677fdea2a03da0e5135808058fa
Merge "Introduce new method in ve.ce.Surface called handleInsertion that is responsible for the magic around inserting content with new annotation, or in a slug, or with IME."
Merge "No longer create zero-length text nodes"
Introduce new method in ve.ce.Surface called handleInsertion that is responsible for the magic around inserting content with new annotation, or in a slug, or with IME.

Change-Id: Ia558376d3e509d15a0746297a9dd29d09beec652
Merge "Add ve.getProp()"
Merge "Support custom hashes in ve.getHash()"
Merge "Add ve.getOpeningHtmlTag()"
Merge "Add setDOMAttributes()"
Add ve.getProp()

Change-Id: Iad9f53ae252acbeb2842645e6e66c0dfc7618f9f
Support custom hashes in ve.getHash()

Change-Id: I9193472773b999b45ce850a609ad5fe141421dbf
Add ve.getOpeningHtmlTag()

Utility function to generate an opening HTML tag. Needed to integrate
the new annotation API with ve.ce.TextNode

Change-Id: I6804bbf6f79346fde1887fa82d29ec5cd0342d60
Add setDOMAttributes()

Change-Id: I1406998400c4f7f3d0983a43e3f86afe4ffd29a6
Merge "Added reversed boolean for translateOffset"
Added reversed boolean for translateOffset

Previously, Undo used a transaction's lengthDifference to calculate the selection to display after the transaction was undone. Now, translateOffset with the reversed boolean set to true will properly translate the inverse of a transaction's selection change. Fixes bug #40538

Change-Id: I110bc0cbb5824547842efd391b9f2948b037b758
No longer create zero-length text nodes

We were populating empty content nodes with zero-length text nodes to
make round-trip tests in the test suite work (otherwise blanking a
paragraph leaves behind a zero-length text node whereas creating an
empty paragraph does not), but the empty nodes are causing problems in
CE apparently.

* Do not create empty text nodes when constructing a node tree
* Be more careful with text-only replacements:
** Don't resize a text node to zero, remove it instead
** There may not be a text node to resize at all, build it in that case
** Switch nodeRange to nodeOuterRange, this was probably broken before

Tests:
* Change test case for zero-length text node to assert that there is
  *no* zero-length text node :)
* Remove a test case concerning an empty text node from the
  ve.ce.TextNode suite

Change-Id: Ie677457f2f0a7823a517ba3077b844ef52a20fcc
Created simple debug tool - that compares data between DOM and Model - very useful while working on SurfaceObserver and text insertion stuff.

Change-Id: Id30513fc64a947ab7ef0474882ace750f41624b8
inheritClass: Implement inherited 'static' property for classes.

Previously tests for inheritClass (and other object management
utilities) were absent (as they were copied from upstream K-js).

I've copied the upstream test suite for this method here and
extended it with tests for this new feature.

Had to add es5:true to .jshintrc due to a bug in JSHint.
Repeated the setting in ve.inheritClass for future reference.

Source: https://github.com/Krinkle/K-js/blob/master/test/K.test.js

Change-Id: I63ac620d6ce7832ebfee454ddf7b7c90f6eb6121
Merge "Add missing return in ve.getDOMAttributes()"
Merge "Removing onKeyPress return statement"
Removing onKeyPress return statement

Also switched to using surfaceObserver and cleaned up some trailing whitespace.

Change-Id: If9a2b390e86f54b4c5ddfd499eefb31f0ab2c96f
ve.Factory: No need for a-b-c workaround, createObject and apply.

This works just fine, as also previously tested/proven by
ve.cloneObject, which uses the same concept of creating an object
identical to what invoking the constructor with "new" would do,
but without invoking the constructor function (which has side-
effects).

Except in this case we do invoke the constructor function, but
we can't use new in ve.Factory because of the arbitrary number of
arguments.

Added a test to assert that 3+ arguments and that instanceof
work as expected.

Change-Id: If0add3da7475886e476900044acda2ba7d01fb11
Fix constructor names; remove redundant hasOwnProperty.

Add some missing constructor names and rename the ones with a
lowercase 'v'.

I previously changed Object.create and others to using hasOwn,
but that turned out to be useless. The thought at the time was
to only use the native one if it really is a native one (and not
a polyfill from another script), however in then hasOwn is only
relevant on prototypes and when negated. For static members it
would be an own-property either way.

Follows-up:
* Id6783fcfc35a896db088ff424ff9faaabcaff716 (metanode)
* Iab763954fb8cf375900d7a9a92dec1c755d5407e (object-management)

Change-Id: Ia6ef597e5e5453277472dfc23f25d2878b68b7f6
Add missing return in ve.getDOMAttributes()

Change-Id: I659667a0424bf166cee95b743469e716ff11f3d9
Update ve.ce.Surface to call SurfaceObserver.stop/start/clear instead of stopPolling/startPolling/clearPollData.

Change-Id: I164599dd34304a3eaef285859a66428cf839accb
Merge "Changed method name to setAutoSelect to avoid collision"
Merge "Got tests working again"
Merge "Created QUnit tests for ve.Document.selectNodes method (mode "branches")"
Changed method name to setAutoSelect to avoid collision

Plus, this is more consistent with the rest of the method names

Change-Id: I713f1bfc28d22cc259ce5dba69ea053817fd43f8
Small clean-up in ve.ce.Surface constructor.

Change-Id: I679511cd0b22192213873ceca5d8410b56d5def9
Created QUnit tests for ve.Document.selectNodes method (mode "branches")

Change-Id: Iee243ffe1a71a23a3ad540421a0cbbb973433f58
Fix minor bug with incorrect usage of hasSlugAtOffset.

Change-Id: I413fc5850cd7bcae9b1d955eb951394e1ed9df36
Start using ve.ce.SurfaceObserver inside ve.ce.Surface. Moved methods getOffsetOfSlug, getOffsetFromElementNode, getOffsetFromTextNode and getOffset to ve.ce.js and made them static.

Change-Id: If6ce0ae10c494392cc384341cc87b61658d4934a
Retire ve.ce.Surface.render variable and instead of it use variable "locked" via methods lock(), unlock() and isLocked().

Change-Id: Ic476a51e9e7766bd2793c2a7d773734cf9bcd0b6
Initial import of ve.ce.SufaceObserver

Change-Id: Ifc14a6cc30e46c8ae99c59dcb916795c603329ed
Setup variable ve.debug to true when ve.debug.js is loaded.

Change-Id: I22309ddfda8271456665eb40c4b698c160061de4
Got tests working again

I think what happened here is I added the skeleton code, Kranitor came through and removed the unused arguments, then I merged in my implementations without pulling, then pushed - git merged cleanly, the arguments I thought were there were not there, and tests broke.

Change-Id: I5aa2968fef164c774a10db83a6df1753c93cd2dc
Add 'branches' mode to ve.Document.selectNodes method. Tests TBD.

Change-Id: Id466b9452fd0b515831a2536ccc32caa339ee885
Created method getSlugAtOffset in ve.ce.Document and ve.ce.BranchNode, refactored the way how slugs are added.

Change-Id: I8006c7e6e1dd3c640939bf08f39192615b2e5343
Merge "Fix transaction bug with Roans help."
Alter the target of the Feedback link to be the right page.

Specifically, go to [[mw:VisualEditor/Feedback]] rather than [[mw:Visual editor/
Feedback]], as the primary set of pages on MWwiki have been moved some time ago
and right now we're stranding users' feedback messages at the wrong place.

Change-Id: Ia2ba0dad7d1bf0d1633fe2704a2e8354285c66da
Localisation updates from http://translatewiki.net.

Change-Id: If2b2b1822e7973ca7c087b5ed72582ac874d9943
Localisation updates from http://translatewiki.net.

Change-Id: Ib1f0420f7f0752a002dac31a30b2aa00704858d4
Fix transaction bug with Roans help.

Fixes (Bug 40339)

Change-Id: Ice26bf08071cba5c5500aa9196ade169381a9aea
Merge "Using getRelativeContentOffset for insertAnnotations"
Merge "Add utility function to get DOM attributes as a plain object"
Merge "Added surface model lock and unlock events"
Added surface model lock and unlock events

This allowed me to move ve.ce.Surface particulars (such as the starting, stopping and clearing of polling) out of the UI code.

Also cleaned up some switch statements.

Change-Id: I7b85e42a4e01f8d76237d995e25275f2424541ea
Add utility function to get DOM attributes as a plain object

Change-Id: I64abfb7479ae687f95e604f1df48dfe8439176ed
Using getRelativeContentOffset for insertAnnotations

Previously, we were looking one offset to the left to load the insertAnnotations. This would fail at the beginning of a document that began with a slug, and probably other cases too. Now using getRelativeContent offset.

Change-Id: I31b24e2ccfa9fda2ce7fb19d1221f8708a96083f
Merge "Make getDomText() return an empty string for slugs"
Merge "Throw an error for bad offsets in getNodeFromOffset()"
Make getDomText() return an empty string for slugs

Slugs aren't represented in the model at all, but in the DOM they do
contain a single character (&nbsp; or &#xFEFF;), so we have to override
the return value of getDomText() to be empty.

Change-Id: Ic93cb694b0632bc81d8d0749149e4d739232ed48
Add exception to getAnnotationsFromOffset() for easier debugging

Change-Id: Ief1209267d2d6f91f8572e4fa15a49e886bc0a30
Throw an error for bad offsets in getNodeFromOffset()

Will ease debugging of bug 40463

Change-Id: I3fbacb3e6e2f242c1584f51581d2b4e7c4bdd4dc
Localisation updates from http://translatewiki.net.

Change-Id: I0299961a807fee46db9502de70a9e5e268fa0f32
Merge "Made save dialog float with toolbar"
Added callout icon

Change-Id: I1641c91a2729ada40ccada6b85e9f0e46e1d0c21
Made save dialog float with toolbar

Change-Id: I6c66c3817669adcee6314c16fcf49ef1a8db7b65
Merge "Create method ve.Range.isCollapsed() and added some tests for ve.Range class."
Create method ve.Range.isCollapsed() and added some tests for ve.Range class.

Change-Id: I866b00db196a768460b32766b82fbdf896a48fdd
Insert Annotations

Change-Id: Ibc927730a668cdcea9c90fe4fc2cb3db4d20480e
Really remove all, not just half

Iterating forwards while removing from an array is a good way to get half way there and be confused as hell.

Change-Id: I74db84eee87c73d8e035f6dc8a92be0d0b9b3dad
Removed a single space.

Change-Id: Id4f96d980306e00b81a13441c38a3913ae312535
Merge "Icon improvements"
Icon improvements

* Added some new icons (to be used soon in the inspector redesign)
* Added right-to-left icons for lists
* Renamed some icons for future RTL use

Change-Id: I10e3e3fcda82786e3064176e7eefe211b88db95c
Merge "Fixed ve.OrderedHashSet.filter"
Fixed ve.OrderedHashSet.filter

Was cloning the original set, then adding to it - resulting in always containing the whole set in any match.

Also using test instead of exec since exec returns a string result, which under strange circumstances could return a falsy result, despite the RegExp finding a match.

Change-Id: I09a7cb264521d58f02d6ff2547edad9a740b23b2
Localisation updates from http://translatewiki.net.

Change-Id: If0cf357aa5959daa90ad09e8da71e397bffc1fdc
Merge "re: AnnotationSet, fix JS error in getFirstLinkAnnotation."
Localisation updates from http://translatewiki.net.

Change-Id: I9b406a429ed4d868e915599b95ea7f51b0734b27
re: AnnotationSet, fix JS error in getFirstLinkAnnotation.

Change-Id: I6a3cb4eb2164bf1c4c8f715e42117ac06cccac04
Merge "Regression fix, clearing only link annotations when creating link."
Regression fix, clearing only link annotations when creating link.

Clearing only existing selected links when:
1) Creating a link
2) Pressing clear button

Change-Id: I4b1bcd9a3ac177b2f9b4af2d562d4c4fec09d5c5
Merge "re: AnnotationSet, annotationButtonTool properly clears annotation."
re: AnnotationSet, annotationButtonTool properly clears annotation.

Surface model annotate method previously cleared basic tool annotation objects.
Now that bold and other annotations have htmlAttributes from parsoid,
we must gather annotations by type from selection and iterate through
to properly clear.

Change-Id: Id53bf5733078524ae5aac376e01b9679eb8c32df
Merge "ve.dm.SurfaceFragment: Implement wrapNodes and wrapAllNodes"
ve.dm.SurfaceFragment: Implement wrapNodes and wrapAllNodes

Change-Id: I378f0aad0286a6c90adeb4602a57d6617154e8b6
Merge "Added CSS rules back in to put the menu above/below"
Merge "Use inspector specific icon css files vs entire icon set css."
Merge "Added missing annotation types to domElementTypes array"
Merge "Whitespace and comments"
Use inspector specific icon css files vs entire icon set css.

Change-Id: I9c519abc478ac22976a8d86aac461d90c92c8a57
Localisation updates from http://translatewiki.net.

Change-Id: I5459a7fab1821322e27ba2df65a76704208f142f
Added CSS rules back in to put the menu above/below

Change-Id: I34d9031c04bed4944d2b3cd184fed021fc31d4a9
Merge "Optimize UI tool state updates."
Optimize UI tool state updates.

Rather than each tool requesting annotations, and nodes pertaining to selection,
Emitted event supplies annotations and nodes to each tool's update method.

Using select vs. of traverseLeafNodes for code optimization.
Better documentation for updateTools()

Removed unneeded code.

Change-Id: I7c0baa1cc0f7fb731d6e28b175a76e931e9e2961
Merge "Add a node type for meta nodes"
Whitespace and comments

* Added documentation for ve.AnnotationSet
* Replaced uses of "// Inheritance" with "// parent Constructor"
* Added "// Mixin constructor" where needed
* Added missing section comments like "/* Static Methods */"
* Cleaned up excessive newlines (matching /\n\n\n/g)
* Put unnecessarily multi-line statements on a single line

Change-Id: I2c9b47ba296f7dd3c9cc2985581fbcefd6d76325
Merge "Documentation & clean up"
Documentation & clean up

* Commands for Sublime:

  Find*: "(\* @[a-z]+) ([^{].*) \{(.*)\}"
  Replace: "$1 {$3} $2"

  Save all && Close all

  Find: " function("
  Replace: " function ("

  Save all && Close all

  Find: "Intialization"
  Replace: "Initialization"

  Save all && Close all

* Consistent use of types (documented in CODING.rm):
  - Merged {Integer} into {Number}.
  - Merged {DOM Node} into {DOMElement}.

* Remove work-around /*jshint newcap: false */ from ve.js
  Calling Object() as a function to to use the internal
  toObject no longer throws a newcap warning in JSHint.
  It only does that normal functions now .

  (e.g. var a = Cap(); or var a = new uncap();)

* Add missing annotations (@static, @method, ..).

* Remove unused variables

* Remove null-assignments to variables that should just be
  undefined. There's a few variables explicitly set to null
  whereas they are set a few lines under and not used otherwise
  (e.g. 'tx' in ve.ce.Surface.prototype.onPaste)

Change-Id: I0721a08f8ecd93c25595aedaa1aadb0e08b83799
(bug 38548) Switch undo / redo buttons for RTL.

Rename the graphic files to more generic names to make them
flippable by CSSJanus.

Change-Id: Ide2540f2f281367909f7f2c7943c9106c0b36699
Localisation updates from http://translatewiki.net.

Change-Id: Ia06fd498d1325185f688a143af9dbe2c7062a189
Merge "(Bug 33094) Disallow invalid page titles in LinkInspector."
(Bug 33094) Disallow invalid page titles in LinkInspector.

Detecting page status in a similar way as WikiEditor inspector.
Disabled accept button now behaves appropriately.
Accept button status is now evaluated on enter or submit.

Change-Id: Ibfef6ffd87cb9a71e37242d6214d0f8e3af2e2c0
Localisation updates from http://translatewiki.net.

Change-Id: Iec8a768270d2e573312d848c7a686ba8bf7ec3a6
Localisation updates from http://translatewiki.net.

Change-Id: Id662844ddf5f62c54f9ac2931289a37d64daec10
Merge "Revert "Added 'bytes' remaining to edit summary dialog.""
Revert "Added 'bytes' remaining to edit summary dialog."

This reverts commit 75c0cdbd381a0d3ec16d26c7668087e611182bfe
Merge "Added 'bytes' remaining to edit summary dialog."
Added 'bytes' remaining to edit summary dialog.

Addresses (Bug 40035)

Change-Id: Iad94ea32b62aef2e1875fa2709b6303b88c9c137
Merge "Hiding inspector iframe by additionally setting height and width to 0."
Added missing annotation types to domElementTypes array

Change-Id: I595bce18c4a18397fdb7c91b4b033cad40e57008
Pressing enter key in edit summary no longer submits save form.

Fixes (Bug 40034)

Change-Id: I5b1cca3dc97686982b8dde907c827dc6e031c312
Add a node type for meta nodes

This node type represents <meta> or <link> (transparently, based on the
style attribute). I had to make two node types for this and hack the
toData conversion code directly into ve.dm.Converter, because we don't
have native support for node types that can be both inline and block.
(We should add this in the node API rewrite.)

The CE implementation renders a placeholder (with the same styles as an
alien node) right now. I'm not sure how nice that is, but it's better
than rendering raw <meta>/<link> tags.

This whole thing is a total pile of hacks to make VE deal with
<meta>/<link> tags until we have a proper node types API.

Change-Id: Id6783fcfc35a896db088ff424ff9faaabcaff716
Hiding inspector iframe by additionally setting height and width to 0.

Addresses iframe bug regression

Change-Id: I498b793277fcfaeca15adffc9f33c31734dade93
Localisation updates from http://translatewiki.net.

Change-Id: I24aab36d264b542380c0a494c659f7f662eb6aee
Merge "Fixed multiple bugs with Context Icon appearing when not relevant."
Fixed multiple bugs with Context Icon appearing when not relevant.

Icon appears when scrolling and resizing window.
	Instead of always setting the context on scroll and resize, bind to the
	updateContextIcon method.
Icon appears when selecting a non content data offset.
	Changed logic to show icon changed to content length vs range difference.

Move Link inspector getSelectionText to ve.dm.document getText.
Rationale, more bits of the code depend on evaluating content.
Added new ve.Range truncate method.
Remove getSelectionText, using truncate range & document.getText instead.

Change-Id: Ibd3e99c923f18d2c96a86d92e74e2e9ebd49c85f
Merge "Added links to annotation set classes for demo"
Merge "Fix bugs in whitespace preservation for aliens"
Localisation updates from http://translatewiki.net.

Change-Id: I07696c01128e9b21755b5f279bc03ca8898e1ca0
Added links to annotation set classes for demo

Change-Id: I1584eb22a177871d1f18761cf4ec35d8961b2b91
Fix bugs in whitespace preservation for aliens

This was broken in three different ways:
* On the way in, we were applying whitespace to an array of elements
  rather than the actual element, so the whitespace wasn't stored.
* Whitespace processing on the way out was skipped for aliens because
  they had their own code path. Refactored this so alien openings and
  regular openings share much more code, including whitespace output.
* Somewhat unrelatedly, innerPost output was broken for paragraphs
  containing inline elements, because the inline elements' processing
  polluted lastOuterPost. Discovered this because my test with inline
  aliens also happened to be the first test of whitespace preservation
  in paragraphs with inline content elements. Fixed by explicitly
  skipping content nodes when outputting whitespace.

Fixed these issues and added a test case.

Change-Id: I8edb61a008e60ace886b1a841b3417682ec39c32
Merge "(bug 39753) UI restores #toc as inline-block instead of table."
Rename ve_foo_bar back to VeFooBar per discussion

Change-Id: Ibf6d4f08c4761727b2e3952a76e474c8221b38f9
(bug 39753) UI restores #toc as inline-block instead of table.

* Follows-up 656439240d6536fe07dd09cd85f7bda056704aac

Change-Id: I57532e556eafe783c8638b25fce502a158597c97
Merge "Fix global scope leakage in the Transaction tests"
Fix global scope leakage in the Transaction tests

Change-Id: I9283acb6179d0be84dadca8ad4e58d5cdd6e3bae
Fix order-of-annotation tests for hrefPrefix

Change-Id: I9fffad6cd0b186a070fec34fd0f827a5875a5d67
Shared closure around utility functions in ve.js

In preparation of pushing the object-management branch, which
will need more shared variables (for efficiency) creating
a shared closure. To avoid a spegetti of immediately-invoked
functions that return functions (like ve.getObjectValues and
ve.getObjectKeys).

Less duplication of code and faster execution.

First I had the closure around it as-is but then I figured it'd
be faster to have a local reference to ve (instead of having to
go through implied globals for references to other ve.*)

So I made it a local variable and then exposed it. That way
anything inside referring to each other stays within the same
scope.

Review with ignore-whitespace for clarity.

Change-Id: I415d8635db6d82cf239f0364ccc2d63a61bd5a6d
Merge "Alienate everything with an unrecognized mw: type."
Merge "Also add clone functionality, undefined guard and tests to ve.copyObject()"
Also add clone functionality, undefined guard and tests to ve.copyObject()

Change-Id: I84ca938cbedf93bfd1c73da16bf9d0d96b3bc749
Add tests asserting ordering of annotations works

Change-Id: Iada85b95914a8728ca809ebab9a42723c1e7a02c
Manage annotations in ve.AnnotationSet object

Introduced the ve.AnnotationSet class to manage sets of annotations. This
is a generalization of ve.OrderedHashSet, a class that manages a set
using an array and an object keyed by hash.

Converted everything that stores, tracks or passes around annotations to
use ve.AnnotationSet. In particular, this means the linear model now
contains AnnotationSets instead of hash-keyed objects.

This allows us to maintain the order of annotations in the linear model,
and will help fix bugs with annotation ordering and splitting.

Change-Id: I50975b0a95f4cc33017a0b59fdede9ed1eff0124
Merge "Plug new vector icons / styles into inspector iframe."
Alienate everything with an unrecognized mw: type.

Currently this is done in a hacky way because we don't have a real
registry of RDFa types for node types, so we just hardcode the list of
recognized types (only links currently).

Change-Id: I5afcc55701fc6fa0ee2a360dcf5ca62b065292f5
(bug 39558) Implement byteLimit

* Also clean up ve.init.mw.ViewPageTarget...setupSaveDialog
  Consistently use viewPage instead of 'this' inside this
  function. The reason it is locally aliased is because there is
  other 'this'es used here. Using them mixed is even more
  confusing.
- No need for ve.bind, other handlers in this function also
  just use viewPage instead of binding this.

Change-Id: I25e93862a39134961bf80835f46cbf531d8109e0
Plug new vector icons / styles into inspector iframe.

Change-Id: Ibd5227de6b74c51f31093e64a4404d5830e84a4e
Merge "Convert the last two uses of $.toJSON to ve.getHash"
Expanded isSomethingFishy function

No need to declare the function inline and then run the function 2x on the same data

Change-Id: I41c57f2aa6e38316edb54dd0c7ebb5726d83ebcf
Remainder JSHint fixes on modules/ve/*

[jshint]
ce/ve.ce.Surface.js: line 670, col 9, Too many var statements.
ce/ve.ce.Surface.js: line 695, col 6, Missing semicolon.
ce/ve.ce.Surface.js: line 726, col 22, Expected '===' and instead saw '=='.
ce/ve.ce.Surface.js: line 726, col 41, Expected '===' and instead saw '=='.
ce/ve.ce.Surface.js: line 733, col 13, Too many var statements.
ce/ve.ce.Surface.js: line 734, col 24, Expected '===' and instead saw '=='.
ce/ve.ce.Surface.js: line 1013, col 13, Too many var statements.
ce/ve.ce.Surface.js: line 1019, col 17, Too many var statements.
ce/ve.ce.Surface.js: line 1023, col 18, Too many ar statements.
ce/ve.ce.Surface.js: line 1027, col 13, Too many var statements.
dm/annotations/ve.dm.LinkAnnotation.js: line 70, col 52, Insecure '.'.
dm/ve.dm.Converter.js: line 383, col 29, Empty block.
dm/ve.dm.Converter.js: line 423, col 33, Empty block.

Commands:
 * jshint .
 * ack '(if|else|function|switch|for|while)\('
 * Sublime Text 2:
   Find(*): (if|else|function|switch|for|while)\(
   Replace: $1 (
 * ack '  ' -Q # double spaces, except in certain comments

Change-Id: I8e34bf2924bc8688fdf8acef08bbc4f6707e93be
Center Ellpisis for long page titles. Misc positioning fixes.

MultiSuggest:
Added CSS Ellipsis config option which provides CSS to suggestion items.

LinkInspector:
-Configured multiSuggest for page suggestions with CSS ellipsis off and removed CSS definitions.
Instead, using jquery.autoEllpisis plugin for centered position ellipsis. (Bug 39591)
-Temporary tweak to link input padding to prevent text from overlapping down arrow.
Down arrow soon to be implemented differently.

RTL Fixes:
-MultiSuggest overlay positions correctly by setting a width.
-MultiSuggest background image position fix.

Change-Id: I806ead5a2c2621589f76cfb2b03805cbd0b0a18a
Merge "Improved icons"
Merge "Fix error in ve.copyArray() and add tests"
Fix error in ve.copyArray() and add tests

Change-Id: I05e7971d05dfa3118db97d76f51985f64d994d8b
ve.dm.Converter.test: Add hrefPrefix (follows-up I33eab356)

* Tests were failing since I33eab356.

Change-Id: I1fed0e3e21ea379a583ccd4f611212940264d106
Localisation updates from http://translatewiki.net.

Change-Id: I8e40afc93c7cde4b7814b11f5c967195f491ff46
Merge "Preserve the leading ./ and ../ in internal link hrefs"
Preserve the leading ./ and ../ in internal link hrefs

Previously we were just discarding them, but that causes round-trip
issues with Parsoid

Change-Id: I33eab356d77acb3c13dc9da94f773915464ef690
Improved icons

* Moved icons into Illustrator (used to be in Photoshop)
* Added SVG icons too
* Added support for devices with pixel ratio > 1 (they use SVG)
* Cleaned up icons (little rendering errors here and there)
* Organized icons into their own folder
* Increased the horizontal margin of the down arrows in the formatting (in the toolbar) and location (in the link inspector) drop down menus

Change-Id: I29b7084c9b1145051b2a76f514cfca9826d53ddb
Convert the last two uses of $.toJSON to ve.getHash

Change-Id: Iff033590a6033a8de88dc571481442a819146c90
Also copy cloneable objects in ve.copyArray()

Change-Id: I572afc282557bab059df0b2a4fd0347336531409
Added tests for removeContent and insertContent

Also fixed the arguments given to insertContent and double-translating the range

Change-Id: I7cb7dcfcee1c88f2052c63e31a0ed37eaaf645ab
Make translateRange() map the offset immediately before an insertion to after the insertion rather than before

This will cause ve.dm.SurfaceFragment.prototype.insertContent() to place
the selection after the insertion as well.

Change-Id: Ifa7e627daceb90408422eb58c110d475f34ba1e2
Localisation updates from http://translatewiki.net.

Change-Id: Ibfa61b9fa71e39ba49da7e8d7aa219e09068d8e1
Localisation updates from http://translatewiki.net.

Change-Id: Ia754b201c3972aea20f224a2698c611da585066e
Cleaned up uses of jQuery to create and appendTo/prependTo

* Separated DOM changes from creation of elements
* Always using parsing for element creation with known attributes
* Always using attr or addClass for variable attributes

Change-Id: Id101f56594014786892d382d06c658f416224a9c
Finally getting rid of all the es-* stuff and other cruft

* Switched a lot of classes from es-* to ve-ui-*
* Removed all the DOM structure left over from the old sandbox demo
* Got rid of transparent backgrounds
* Added menu font-size rule to stand-alone target
* Moved some rules around that were in the wrong places
* Got rid of some unused/unneeded methods in the mw target (attach and detach surface methods)
* Added active class to context icon with shallower shadow effect so it doesn't break your spacial perception when you click on it
* Renamed the iframe and iframe wrapper elements so it's easier to see where they came from
* Removed unused CSS rules
* Fixed some uses of prop( 'class', … ) to addClass

Change-Id: I54a660ca0baf0baa4463faca7a1edcf648130b6b
Fixed position and size of toolbar in Apex skin

Change-Id: I520eb03a6b000c70d3b4892b25eeda7e43f85897
Merge "A bit of cleanup in the inspector and suggestion code"
A bit of cleanup in the inspector and suggestion code

* function() -> function ()
* ){ -> ) {
* Quoted JSON keys (Look the other way Timo!)
* Using more descriptive group names, which also avoid using "new" as a key
* Line breaks at 100 columns using 4 spaces/tab
* Not setting classes on suggestion items that have no effect (such as 'external' on a div - even on an <a> tag this isn't enough to get the style because it's not inside #content)

Change-Id: I37032fa8ba93adb7b719d9797f9b1b806359cc13
Merge "Catching transactions that were not being committed."
Merge "Move caching mechanism out of multiSuggest plugin to linkInspector"
Merge "Refactor ve.getHash: Stabilize cross-browser differences; + unit tests"
Merge "Removed Parsoid-related files from .gitignore"
Merge "Added a comment about possible i18n messages"
Localisation updates from http://translatewiki.net.

Change-Id: I84c1980c59751f0d991e856e119aada213ddb1d4
Removed Parsoid-related files from .gitignore

Change-Id: If2ec4211bfc6a733e255c593195049ef4ee9ea1e
Localisation updates from http://translatewiki.net.

Change-Id: I2843c4c92219cd44c2dc0abb3348299de5c2c956
Added a comment about possible i18n messages

For easier grepping, according to
https://www.mediawiki.org/wiki/L10n#Using_messages

Change-Id: Ib766fd9c10ddbe9fd16ccec9b9866457117b3e70
Catching transactions that were not being committed.

Change-Id: Ic75b07f279e4db30f6730f10b31c66d506cb94e8
Move caching mechanism out of multiSuggest plugin to linkInspector

Fixed issue where overlay would be incorrectly positioned if built
from previous caching method.

Change-Id: Id7c3ba211d5344292da47917a9bd06654823ee87
Localisation updates from http://translatewiki.net.

Change-Id: Ib3d803feb528209e485abec62032a2c9200e1089
Merge "Fixed bug with selecting multi suggest item with the enter key."
Merge "Very simple (and a little bit messy) debug tool that dumps not HTML table linear model, view tree and model tree."
Fixed bug with selecting multi suggest item with the enter key.

No longer does selecting an item with the enter key repopulate
the drop down.

Change-Id: I372f319ba41c348d667eb3a60e2f8a7c5efad235
Merge "Bug 37904 - Show info in title of link tags"
Bug 37904 - Show info in title of link tags

Internal links use the title, other links use the href

Change-Id: I1a1cfd70c222dd1d686b46cd702edf2e9d0e5bae
Very simple (and a little bit messy) debug tool that dumps not HTML table linear model, view tree and model tree.

Change-Id: I625047fbb99c0d63e1ac6865b7e9cddf4ab72a2e
Merge "Also strip ./ in addition to ../"
Fixing enter to leave list

Pressing enter in an empty last list item should remove the list item and add a paragraph. Transaction was not being committed.

Change-Id: I0b173125d48f629eab923e051648d2036bb8956c
Also strip ./ in addition to ../

This is necessary because Parsoid is now prefixing all hrefs with ./

Change-Id: I18c4b7470cfa1dd174e25cc921bf7d4daf5ffc55
Merge "Bug 37821 - Add support for oldid"
Fix for method of retrieving anchor node in ve.ce.BranchNode.onSplice method.

In current implementation ve.ce.TextNode can be represented by more then one DOM node (TEXT_NODE and or ELEMENT_NODE) - for instance "Lorem <b>Ipsum</b> est" (TEXT, ELEMENT, TEXT).

Change-Id: I6530cbf1273ad1b1de3599c3eb929eb7abc2d59e
Localisation updates from http://translatewiki.net.

Change-Id: Icdb82599ce5f66d0a6768e973b1ee6103bc9d242
Merge "Set inspector container height and width to 0 on close."
Bug 37821 - Add support for oldid

* Added oldid param to the API
* Added oldId argument to ve.init.mw.ViewPageTarget
* Added redirect when saving an oldid page (which adds a new revision)
* Added venotify param to allow notifications even when redirected
* Added creation notification
* Added page title to saved/created notification

Change-Id: I9e957e6f5bc7920093481ffe3c33e299f87ce50a
Set inspector container height and width to 0 on close.

Addresses (Bug 38655)

Change-Id: I93076314bab521fdbc16c5441de4496c4d0b04de
Merge "Cleaned up some CSS in ve.ui.Surface.css"
Cleaned up some CSS in ve.ui.Surface.css

Got rid of some commented out code we aren't going to use and fixed the order of arguments to background position to x, y

Change-Id: I4e638c33b053dd916681dc91c8c0d7cff224375d
Added monobook support

* Added style for monobook
* Added monobook to whitelisted skins
* Made ve.init.mw.ViewPageTarget resilliant to vector and monobook-like skins

Change-Id: Ia39e034229204ae5f1f70dce5d74c6c4db42277b
Merge "Bug 38902 - Error on onbeforunload"
Merge "Bug 38857 - UserAgent blacklisting"
Bug 38902 - Error on onbeforunload

Just had to make sure the surface was still around before using it.

Change-Id: I13a2f02d256937b7da3aca3ad3c3404bd8f31244
Bug 38857 - UserAgent blacklisting

Add ?vewhitelist to the URL to override this - useful when testing in a blacklisted browser.

Blacklist:
- msie < 9
- firefox < 11
- safari < 5
- chrome < 19
- opera *
- netscape *
- blackberry *

Change-Id: I6ebb3f7a7d56d395e5fe5c7c9129b606f97aeaab
Bug 33175 - Copy dir and lang from #mw-content-text div to document

This resolves the content direction issues identified in bug 33175

Change-Id: Iaf61fb9e8ad0ba3ab70ffa00c75da4c6f01aad61
Merge "Localisation updates from http://translatewiki.net."
Localisation updates from http://translatewiki.net.

Change-Id: I01ac351e671f27f8f1645c740fc0726d32df118c
Merge "Support for <center> tag"
Support for <center> tag

Change-Id: I0d64561dd82b8377ee7491103e81569eaca22fee
Merge "Fixing ve.log and ve.dir for IE"
Fix syntax error in 9d7f4e94b5e57df8e74bdfc4606f2d82e30e1724

Change-Id: Ia063de19bf54cb32d4a72304f3289c6c7fa669ca
Merge "Fix ve.ce.getDomText to work with <br/> tags by making it skip not contenteditable=false but all leaf nodes."
Fix ve.ce.getDomText to work with <br/> tags by making it skip not contenteditable=false but all leaf nodes.

Change-Id: I9e728e091a3021840dac07e9601fc764e7750c49
Merge "Floating toolbar fixes"
Fixing ve.log and ve.dir for IE

Change-Id: Ieee1aec3e6ea45f3eecdea53e3691ebe19306a33
Merge "IE triggers keyPress for Esc. We should not delete selected text when this keyPress happens."
Merge "Context module cleanup."
Context module cleanup.

-Changed es class prefixes to ve.

-Organized Context & Inspector construction.

-Updated comments & Whitespace.

Change-Id: I4a387621e5147e72d3869ff46eef4790091442c0
Merge "Now caching build params in jquery.multiSuggest."
Merge "Remove references to data-mw-gc"
Localisation updates from http://translatewiki.net.

Change-Id: I3ef4cffe640a7d94342dd8d6db4825c46f1ec4d3
Now caching build params in jquery.multiSuggest.

Fixes (Bug 39511)

Some code cleanup.

Change-Id: I92244c22199d08131f55bfca0c3fa49acccfd963
Fix grammar.

Change-Id: Iceee6e5bf5956eb6e8917c7537207fd3fb43d103
Fix transact event handle in ve.dm.SurfaceFragment to handle array of transactions being passed as the argument (instead of just one transaction as it was before).

Change-Id: Ic8f26424594cbd4a89da7e4eefb825977f440786
Remove references to data-mw-gc

data-mw-gc is ancient and unused. We do need to detect and alienate
generated nodes, but that is now based on RDFa types. Removing the
data-mw-gc stuff for now because it doesn't work anyway, will replace it
with proper detection later.

Replaced instances of data-mw-gc in the test suite with unregistered
node types.

Change-Id: If3f5898d382a436fa57929013264c53af5e840ba
IE triggers keyPress for Esc. We should not delete selected text when this keyPress happens.

Change-Id: I8028ba960d7e7ea15e56701850cd214bacc6a232
Merge "(bug 39512) Fix regression in I277ad5fe3f64e07c1bbf49007d6bbaecc90b7466"
Floating toolbar fixes

* Added more support for making dynamic skin changes in vector (based on media queries) get applied to the toolbar while it's floating
** Added animation for toolbar wrapper margins
** Added resize handler to update left and right positions on the toolbar when it's floated
 * Changed from using generic "float" and "bottom" class names which are likely going to get re-used elsewhere and cause issues

Change-Id: Ic596b2b8aceb8a2d81539e197ef4d6e17326a87a
(bug 39512) Fix regression in I277ad5fe3f64e07c1bbf49007d6bbaecc90b7466

.childNodes is live, so iterating over it ends up skipping every other
child

Change-Id: I54ac480eca8e7ed36d299d68670a97ff176f3ebd
Merge "Some basic link inspector style changes"
Some basic link inspector style changes

Some of the HTML structure in the suggestions might need to be changed to pull off pixel-perfect reproduction of the original design, but this gets us very close.

Change-Id: Ie574577af4815e4f0fc9f8a03e57759dd9dfff84
Localisation updates from http://translatewiki.net.

Change-Id: I3e177e5f9d9b969f0a895bbb06593dcf2980fbb3
Merge "Fix JS error about out-of-bounds selection setting"
Merge "Handle uneditable nodes in ve.ce.getDomText()"
Merge "Losslessly compress png images"
Localisation updates from http://translatewiki.net.

Change-Id: I38ced0ec8bfc5700c2914c488ab1bb3ce79a7a0a
Losslessly compress png images

Change-Id: Ie0b52dcb75157a35468a1cf208f85a5adc5fc98e
Merge "Switching proxy to bind"
Switching proxy to bind

This enables keyboard combos like alt-backspace and control-delete

Change-Id: I9a191977ae4ec824a9778a875e8abb706fc96a84
Handle uneditable nodes in ve.ce.getDomText()

There is a TODO about this but these were never handled. This lack of
handling caused weird offset issues when editing paragraphs containing
inline aliens, because the text of the inline alien was returned.
Instead, return an appropriate number of characters so the offset logic
keeps working.

Removed the textContent||innerText code because it would bypass the
uneditable node logic: paragraphNode.textContent would return the text
of the entire paragraph (including any aliens), and we'd never descend
into the paragraph to reach the alien node.

Change-Id: Ia05755755dd5380cb9a0b5a0334c6721b4e0d3b7
Fix JS error about out-of-bounds selection setting

Don't try to restore the selection after the removal part of
onContentChange, because the removal may have caused that selection to
now be out of bounds. We also don't need to set the selection there at
all, because the insertion does it anyway (where it is safe).

Change-Id: I7b340b18dd8efc77d1df78007161720c29866cb6
Merge "Multiple Transactions"
Multiple Transactions

Make ve.dm.Surface.change accept array of transactions as a parameter (instead of just one) and use it in complex content removal (handled in Surface view).

Change-Id: I453b3606cefe140db206f5a2d2c9036bcbd639c9
Merge "Added saving "spinner" icon to save dialog"
Merge "Fix JS error for inline aliens"
Added saving "spinner" icon to save dialog

Change-Id: Ie6ef43378b1a0a18c504efe7bb850d7c9de1bbeb
Merge "VE multiSuggest bug fixes."
Fixed the text in the edit summary box being the wrong font and size

In Firefox at least...

Change-Id: I236902cde51ac6e25e4edc738fa4a80977d39d29
Fix JS error for inline aliens

The error occurred after pressing backspace in a paragraph that
contained an alienInline node (or other inline node). It happened
because ve.ce.BranchNode.clean() called this.$.empty(), which destroyed
all element data in the paragraph's children, including the
.data('node') property which associates the DOM node with the CE tree
node. Use .detach() instead.

Change-Id: I563c936a706a1d1711e6333404c6ca8e6ebf8eeb
VE multiSuggest bug fixes.

-Using keydown on arrows allows preventDefault which stops the cursor movement in the input.

-Consolidated Keydown bindings, no longer unbinding keydown, instead checking for visible state first.

-Using case insensitive comparison for selected item.

-Changed use of ve.inArray to ve.indexOf because method name was changed.

-Moved clear break into suggestion container rather than after it.
Added margin bottom on suggestion container for category separation.

Change-Id: I2bd1db049a948db189194037dc8e38dfe884c197
Merge "Added MW page suggestion functionality."
Added MW page suggestion functionality.

Created jQuery plugin MultiSuggest which builds a categorized dropdown
under specified input box.

Revised inspector to no longer be an iframe but to contain an Iframe.
This reduces xbrowser issues with positioning and toggling inspector
container.

Added Inspector overlay element for positioning arbitrary elements
over the iFrame.  This prevents growing the iframe to arbitrary lenghts.

Change-Id: I8efbbd091b0b24a19a4b73aa122d21a329cf97e4
Merge "Design changes for save dialog"
Merge "Added check for empty document to avoid error"
Added check for empty document to avoid error

When the document is empty, there is no last branch, and it causes an error because the code was assuming there was always going to be a last branch.

Change-Id: I371dce89db6258d30a11022c1bdb11830f59505d
Design changes for save dialog

* Summary label is now placeholder text
* Edit summary and options are visually connected
* Added summary length count-down label
* Removed check-mark icons from toolbar and dialog save buttons
* Made toolbar and dialog save buttons the same size
* Reduced line-height and margins of license information
* Changed from X icon for close (which might be confused with cancel) to ^ icon for collapse

Change-Id: Ib1711f49af8929be12796aecdea49467b726856e
Merge "Utilizing RL skinStyles for skin-specific ve.init styles"
Merge "Fixed scroll and selection issues"
Utilizing RL skinStyles for skin-specific ve.init styles

Change-Id: I4b2ed55289be5dceee3e3fbdf305b4ff81d80189
Merge "Added some unit tests for ve.dm.SurfaceFragment"
Fixed scroll and selection issues

* When you visit the page with url# (empty target) it scrolls down - which made setting the URL of the namespace tab to # really bad, plus it was useless since we already handle that click using JS
* Found that this.$toolbarWrapper wasn't pointing to the right place because of a missing .end() call at the end of a chain of jQuery madness

Change-Id: I7dc6953e39d4081f1b91a351bb830e4c18f7b988
Added notification on save

Change-Id: I362275eb38655401bc48b3209189776e9e37619a
Merge "There's no such thing as ghosts, just sneaky array references"
Added some unit tests for ve.dm.SurfaceFragment

Also:
* Made a fragment with a null range become a null fragment
* Fixed incorrect order of arguments for binding a handler to transact event
* Added getters for surface, document and range
* Fixed several instances of passing a document instead of a surface into the constructor of a new surface fragment
* Fixed closest mode in expandRange - needed to check if parent existed before checking for it's type
* Fixed uses of ve.Transaction (doesn't exist) that were supposed to be uses of ve.dm.Transaction (does exist)

Change-Id: Ide13d9d2d1637399188c98c2e8b6e0826caeecc4
Merge "Strip generated <p> tags in dataToDom"
Merge "Remove attributes from DocumentNode constructor"
Merge "Rename fringeWhitespace to internal"
There's no such thing as ghosts, just sneaky array references

When a document is created, it should take it upon itself to make sure it has a new reference to the data using slice, not place this on the caller. Callers that do not use slice will often find strange and mysterious things going on and not know why. The real reason is that multiple documents sharing a reference to the same data array leads to seriously messed up behavior.

Change-Id: Ic4e25fcd9bf3f41a805003520a8f38e2768f5dbf
Localisation updates from http://translatewiki.net.

Change-Id: I558a95e9778009f8b6f380e8f6e4e0e68b243ba5
Remove attributes from DocumentNode constructor

'document' is an unwrapped node type, so a document cannot have
attributes in the linear model

Change-Id: Ifb0b5a189a65b71925b0fb379bd544d19102ed01
Strip generated <p> tags in dataToDom

domToData wraps bare content in paragraph elements, which were then
converted to <p> tags by domToData. With this fix, HTML with "missing"
<p> tags actually round-trips through the editor correctly now, rather
than having <p> tags added wherever VE believes they should exist.

* Mark generated paragraph elements with .internal.generated = 'wrapper'
** This signifies the wrapper was generated but its contents were not,
   so the right thing to do when converting back to HTML is to remove
   the wrapper and keep the contents. We might want to use other values
   of generated in the future.
* Unwrap nodes with generated=wrapper when converting to HTML

Tests:
* Add 'generated': 'wrapper' as appropriate. Only affects 1 test
* Remove 'normalizedHtml' for this test because it is no longer needed
** Need to keep 'normalizedHtml' for now because we normalize hrefs
* Eventually the main example should test bare content, but that
  requires touching a lot of stuff. The main example could use some
  beefing up anyway.

Change-Id: I277ad5fe3f64e07c1bbf49007d6bbaecc90b7466
Rename fringeWhitespace to internal

This allows us to put other internal data in there in the future. Also
passing it through the Node constructor properly now.

* ve.dm.Node
** Rename fringeWhitespace property to internal
** Add internal parameter to constructor
** Remove setFringeWhitespace()
* Increase the number of parameters passed through by ve.Factory to 3
* Pass through .internal from linmod to nodeFactory in ve.dm.Document
* ve.dm.Converter
** Rename .fringeWhitespace to .internal.whitespace and make it an array
** Store a temporary reference to .internal in domElement.veInternal
* Add internal to all node constructors except TextNode

Tests:
* Update for fringeWhitespace->internal rename
* Add third parameter to ve.Factory tests
* Add .internal to getNodeTreeSummary

Change-Id: If20c0bb78fee3efa55f72e51e7fc261283358de7
Merge "Localisation updates from http://translatewiki.net."
Localisation updates from http://translatewiki.net.

Change-Id: Iea020c974b1ef1296a376443644a2739882c4c0a
Changed initial surface range to (0, 0)

This makes a lot more sense when you start making a surface fragment from a new surface, because a null range would seem to have unpredictable behavior.

Change-Id: I85210878deca3067960fa4a14e2a760e55f67e4e
Added support for apex skin

* Made vector specific styles only active in the vector skin
* Added apex specific styles
* Removed override of text size for document node
* Added stylesheet for stand-alone to specify text size for document node

Change-Id: I8a57918912499f9453a5692ff45a04a16ed34cde
Localisation updates from http://translatewiki.net.

Change-Id: I62837bf0a53c30136991c0dc08ff2d4ca656180f
Added key-sorting to make hashes referentially transparent

To do this, we are using the replacer callback of JSON.stringify, which is supported by all of our target browsers including IE8. We are also leaning on Object.keys and Array.reduce, the latter of which required adding a new fallback implementation for some browsers which do not support it yet.

Change-Id: Ifa285ca3da4d94d962464f09414591532bbea79c
Merge "Update LinkAnnotation for Parsoid href changes"
Localisation updates from http://translatewiki.net.

Change-Id: I1f9f93597c3f4dbbe1b2ec6fc2a264e005459158
Merge "Added setSelection to ve.dm.Surface"
Update LinkAnnotation for Parsoid href changes

Because the Parsoid prefix format changed from /mw:Foo to /mw/Foo , the
href format for internal links has changed from "/Foo" to "Foo". So the
href is now simply the title, except that it may be preceded by one or
more "../" if the title of the page we're on contains a '/'.

So instead of stripping the leading slash from internal link hrefs and
putting it back on the way out, only strip any leading "../"s and dump
the titles directly into the hrefs on the way out.

Also update the link test case for this, and add a test case for the ../
stripping.

Change-Id: I3e0bdde20f22cda34eb45fc351de5e780419b6a2
Merge "Update API for Parsoid prefix changes"
Merge "Recognize ExtLink/URL and ExtLink/Numbered in LinkInspector"
Merge "SimpleWikiLink is no longer used by Parsoid, remove it from VE"
Added setSelection to ve.dm.Surface

This is a convenience method which also can improve code readability.

Change-Id: If71b83b2861d195b58915f81dc614e2718e75d95
Recognize annotation types with multiple slashes correctly

Annotation types with more than one slash such as 'link/ExtLink/URL'
weren't being processed correctly because .split( '/', 2 ) throws away
everything after the second slash. Instead, don't pass a limit to
.split(); the code for reconstructing a slash-separated string from
multiple components was already in place.

Also add test cases for URL links and numbered links.

(Do you like the lines-of-code to lines-of-test ratio in this commit,
Trevor? ;) )

Change-Id: I7add87396447a01b1c23a4f9bfd63d2e8fd861ce
SimpleWikiLink is no longer used by Parsoid, remove it from VE

Change-Id: I7f19304dc8bd6819992756a704e215d31f8b2e7e
Recognize ExtLink/URL and ExtLink/Numbered in LinkInspector

Change-Id: Ib13fd3396132695a844db6151296c52fa5f96032
Update API for Parsoid prefix changes

The format for wiki prefixes in Parsoid has changed from /mw:Pagename to
/mw/Pagename . Update the API module and the config+docs for this
change. The default value of the prefix ('localhost') should still work
for stock localhost setups.

Change-Id: Ic6f3793d175106cc1fae17980d20add63c3f783f
Localisation updates from http://translatewiki.net.

Change-Id: Ie0d1225ad71927cdbed90e6ba8f87c0298f5cad8
Merge "Strip and preserve inner leading&trailing whitespace in the linear model"
Merge "Refactor ve.js utilities and improve documentation"
Localisation updates from http://translatewiki.net.

Change-Id: I325f7ef2b5292cf37193a3e5a2fb6eb842730786
Localisation updates from http://translatewiki.net.

Change-Id: I14cd9b220dea6589c073f1e0924c4e298116049d
Strip and preserve inner leading&trailing whitespace in the linear model

This makes things like
== Foo ==
* Bar
render without the leading and trailing spaces, while still
round-tripping those spaces.

* Added a .fringeWhitespace property to the linear model and ve.dm.Node
** Object containing innerPre, innerPost, outerPre, outerPost
** Only inner* are used right now, outer* are planned for future use
** Like .attributes , it's suppressed if it's an empty object
* In getDataFromDom():
** Store the stripped whitespace in .fringeWhitespace
** Move emptiness check up: empty elements with .fringeWhitespace have
   to be preserved
** Move paragraph wrapping up: .fringeWhitespace has to be applied to
   the generated paragraph, not its parent
** Add wrapperElement to keep track of the element .fringeWhitespace has
   to be added to; this is either dataElement or the generated paragraph
   or nothing, but we can't modify dataElement because it's used later
* In getDomFromData():
** When processing an opening, store the fringeWhitespace data in the
   generated DOM node
** When processing a closing, add the stored whitespace back in
* In the ve.dm.Document constructor, pass through .fringeWhitespace from
  the linear model data to the generated nodes

Tests:
* Change one existing test case to account for this change
* Add three new test cases for this behavior
* Add normalizedHtml field so I can test behavior with bare content

Change-Id: I0411544652dd72b923c831c495d69ee4322a2c14
Merge "Localisation updates from http://translatewiki.net."
Localisation updates from http://translatewiki.net.

Change-Id: I242c44591ce116c751f1594859cdd1aeaf46128d
Clean up a few commas and some indentation

The commas were resulting from converting this:
var foo = 3,
	bar = 5;

to this:

foo = 3,
bar = 5;

Change-Id: I0223b34a30d947c6a51f0601727b0c3850239e66
Fix replaceNonBreakingSpace() to not modify the linear model

It was replacing spaces with &nbsp;s in its copy of a slice of linmod
data, but the copy was a shallow copy, so when modifying annotated
spaces it would modify the actual data. Fixed by detecting this case and
cloning the character's array before modifying it.

Change-Id: Ic96ed34605a302af18f274a0faa6d0f650f5b771
Added isNoOp to ve.dm.Transaction

Also added some checks in content branch conversion to make sure that converting from and to the same thing results in a no-op

Change-Id: Ie47520d666e45a77d12c7ebb9457aef7ab6b8097
Fixed reversal of next and previous polling results

Change-Id: I504040044721603ae48a844e3f78d735f2c3159d
Merge "Fix up c0ea02c0bfc1a3d481a4e2e82c2dc779cab2ed66"
Fix up c0ea02c0bfc1a3d481a4e2e82c2dc779cab2ed66

Was stripping whitespace before and after annotations as well

Change-Id: Ie49319c15e68de6855fef2beadec0a11beea3ec6
Localisation updates from http://translatewiki.net.

Change-Id: Ie0f00988ceddd22a995782669570c554bb00b276
Merge "Fix up 62d08588050f576b0728800067b97d41b7eec9fa"
Fix up 62d08588050f576b0728800067b97d41b7eec9fa

* Per Krinkle's comment, be tolerant of missing .htmlAttributes
* Drop .htmlAttributes if no attributes, fixes some tests

Change-Id: I65589a8b489e19a7c8a41ba2f4a57e68fc52684c
Rename external link RDFa types to keep up with Parsoid

Change-Id: Ie232a575339a16431cbd1ee216998d1f6bf52d78
Merge "Make use of new jshint options"
Make use of new jshint options

* Restricting "camelcase":
  No changes, we were passing all of these already

* Explicitly unrestricting "forin" and "plusplus"
  These are off by default in node-jshint, but some distro of jshint
  and editors that use their own wrapper around jshint instead of
  node-jshint (Eclipse?) may have different defaults. Therefor
  setting them to false explicitly. This also serves as a reminder
  for the future so we'll always know we don't pass that, in case
  we would want to change that.

* Fix order ("quotemark" before "regexp")

* Restricting "unused"
  We're not passing all of this, which is why I've set it to false
  for now. But I did put it in .jshintrc as placeholder.
  I've fixed most of them, there's some left where there is no clean
  solution.

* While at it fix a few issues:
 - Unused variables ($target, $window)
 - Bad practices (using jQuery context for find instead of creation)
 - Redundant /*global */ comments
 - Parameters that are not used and don't have documentation either
 - Lines longer than 100 chars @ 4 spaces/tab

* Note:
 - ve.ce.Surface.prototype.onChange takes two arguments but never
   uses the former. And even the second one can be null/undefined.
   Aside from that, the .change() function emits
   another event for the transaction already. Looks like this
   should be refactored a bit, two more separated events probably
   or one that is actually used better.
 - Also cleaned up a lot of comments, some of which were missing,
   others were incorrect
 - Reworked the contentChange event so we are no longer using the
   word new as an object key; expanded a complex object into multiple
   arguments being passed through the event to make it easier to work
   with and document

Change-Id: I8490815a508c6c379d5f9a743bb4aefd14576aa6
Strip leading and trailing whitespace in text

Right now this means things like headings and list items are rendered
nicer (without the whitespace), but also get their whitespace normalized
when saving back. I'll submit code tomorrow that preserves this
whitespace.

Submitting this now because it's needed to make <br>s look reasonable

Change-Id: I4b5e5ad8ee1bbe2f1eaf0fb860dd59f6e401dc3d
Merge "Added basic ve.dm.SurfaceFragment class"
Added basic ve.dm.SurfaceFragment class

Lots left to do here, but this is the future API for working with documents

Change-Id: I7b7e705ad4d922f37c327042051634a61dc8be66
Removing redundant overrides for canHaveSlug* methods

Change-Id: I2bfd08eab1cd45a193d91540bc0602549884fa89
Merge "Add ve.dm.BreakNode to represent <br>"
Add ve.dm.BreakNode to represent <br>

Change-Id: I3825199c3c8cbe3b50c01e03f39f20cef7c55a28
Preserve HTML attributes for textStyle/* annotations

The new annotation API will do this too; this is a temporary hack to fix
the bugs caused by stripping attributes.

This code doesn't actually render the attributes, but the new annotation
API will.

Change-Id: Ic0ddf822fe02f101f2e825080c6bcc2a03115974
Merge "Rename wikiLink to WikiLink everywhere"
Rename wikiLink to WikiLink everywhere

Was causing link inspector breakage

Change-Id: Idf12f90aec9cbd2ddca47c66eb9e6e705a0e48f5
Localisation updates from http://translatewiki.net.

Change-Id: I5ea0797c64d08bd8d198140cefcaece5d217aa7c
This should never happen, but if it does, lets make sure we know

In the past, this has cause things to break in mysterious ways

Change-Id: I2fcf1e2a9cf776a9ab9b3969d9ec552e23120e79
After much research on error objects, native = good, custom = bad

Stack traces, line numbers, etc. All the approaches I've seen are bad hacks. This is the best way to go.

Change-Id: Ib12e9d2ecfe610bcc89d046005e35cc13efa3d99
Merge "Throw ve.Error instead of string literals"
Throw ve.Error instead of string literals

Throwing strings is bad because it doesn't include a lot of important
information that an error object does, such as a stack trace or where
the error was actually thrown from.

ve.Error inherits directly from Error. In the future we may create
more specific subclasses and/or do custom stuff.

Some interesting reading on the subject:
* http://www.devthought.com/2011/12/22/a-string-is-not-an-error/

Change-Id: Ib7c568a1dcb98abac44c6c146e84dde5315b2826
Quick link inspector fix to support recently changed types.

Change-Id: I095968db70b2f523cdd50d51242268894aa7ddec
TODO: Link Inspector needs to support all 6 link types.
Merge "(bug 38125) ve.init.mw.ViewPageTarget: Preserve original query"
(bug 38125) ve.init.mw.ViewPageTarget: Preserve original query

* Use 'href' of #ca-edit instead of constructing it manually.
  MediaWiki's output of #ca-edit already takes care of all needed
  queries, including "oldid" (bug 38125).

* Misc clean up:
 - Use .get() instead of accessing the array directly.

* Clean up setupSkinTabs and add more inline documentation.

Change-Id: I7d702a3eb1f9ce23a5e3c9e846b00da5cead386e
Clean up: Single quotes

* There were only 3 files with single quotes, fixed them all.

* Added option to .jshintrc (be sure to use the latest version of
  node-jshint since this is a fairly new addition to the library).

Change-Id: I8bf8895ce56bf86e3bed244279a9d32269e44763
Javascript, unlike PHP doesn't need double quotes for \n

This just cleans up a few places where single quotes should have been used instead of double quotes.

Change-Id: I6c53652e71ab96842ed5bb41fb1e0b8c923eb25d
Puttin' em white-spacers where they aught'a be

function() -> function ()
){ -> ) {

Change-Id: I20a85fcf79d7aec64f7f2559e84c0279550d4eea
Pass a (configurable) interwiki prefix to Parsoid

Change-Id: Id71e52836a367e0688f6c41e2c2e4d16b1b733ad
Added some inline aliens to complex demo - helpful for testing

Change-Id: I3063096145994abd36493e7ee182fdd7b48e1bf2
Merge "Added <alienblock> to complex demo document"
Added <alienblock> to complex demo document

Change-Id: Ic26c916a02b1e4f45990d099ff7c12b90734e906
Merge "Oops, we were missing a slash here"
Oops, we were missing a slash here

Change-Id: I14da5070dbd3286e548eded8a71660777a566a83
Merge "Kill all but one of the Parsoid compat hacks, we don't need them any more"
Kill all but one of the Parsoid compat hacks, we don't need them any more

Also remove traces of Parsoid workarounds in tests. Tests are now
passing, yay :)

Change-Id: I8a59fc92c567c3595849e3e9377ce6eb6acde280
Fix weird bug that was suddenly happening on the live site

When closing annotation nodes, we weren't popping them off
annotationStack. Not sure where this came from, but the code was
definitely bad and this fixes it.

Change-Id: I6d805e9aca3778666212135f76ff34c6baacbbc8
Kranitor #004: MediaWiki-specific clean up and minor fixes

* Default value of wgVisualEditorParsoidURL is broken.
  Slash is needed, else Api will request to
  http://hostnamePageName
  Roan says double slashes are okay, and look cleaner than string
  search checks etc.

* Use .clone() for mw.Uri instead of converting to string
  and letting mw.Uri parse it, again. Clone creates a basic
  instance and copies over properties internally (deep copy,
  no references).

* No need for hasOwnProperty (and its potential issues)

* Code clean up
 - Whitespace consistency
 - Variable hosting
 - Remove redundant `return false;` statements in event handlers
   e.preventDefault() is a jQuery.Event method that takes care
   of cross-browser issues.
 - Same for e.keyCode||e.which thing, this is already normalized
   by jQuery.Event
 - Add missing parameter to setTimeout
 - Consistent order in success/error handlers in $.ajax options

Change-Id: I5bc24e0cbdf01b3704d4ccb0b45b3052e3b58694
Cleanup - all jshint conditions are now met

Also:
* Removed a lot of dead code in Surface that was used in the now dead and gone sandbox.
* Changed from throwing an exception when calling getBalancedData on a range that produces no results from selectNodes to just returning []

Change-Id: Icf27094724eae5b90eec21308f9e26afe877e3ee
Localisation updates from http://translatewiki.net.

Change-Id: I9bb5eec5bd85199665e5c54204ed8d569736aad7
Localisation updates from http://translatewiki.net.

Change-Id: Iee2052f36157e24e1c2f830703613e29d9750f7c
Merge "Fixed problem with closing context menu on document blur."
Fixed problem with closing context menu on document blur.

When editor surface loses focus, now checking to see if an inspector
is set or a menu is open prior to closing the context.

This ruling ensures more rational context icon / child menu behavior.

Change-Id: Ic4b74bb51e811e264a2109a3c1c5a8ae503a8c49
Remove the parser from the VE repo

* Parsoid now lives in the Parsoid extension / repo:
https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/extensions/Parsoid.git
* Adjusted AUTHORS and README to be more VE-specific

Change-Id: Iaa70a8d09a0fce9f415f0f1ec853165c37559809
Merge "Register QUnit tests suites in MediaWiki to run from Special:JavaScriptTest"
Merge "Kranitor #3: jQuerlyfornication ft. The Cascaders"
Merge "Refactored and cleaned up Sanitizer + bug fix."
Merge "Refactored duplicated code in Util"
Refactored and cleaned up Sanitizer + bug fix.

* Moved all constants to a singleton constants object
* Moved couple methods to mediawiki.Util.js
* Fixed url regexp bug -- relative urls weren't being matched
  but, this bug escaped through because the previous url regexp
  had a typo (which means url sanitization wasn't being done by
  the previous code).  This also means we have to either find
  sanitizer tests or add new ones so these bugs are caught.  Maybe
  parserTests.txt is not the right place for this?

Change-Id: Ia05e1d1596bb9bc4a9eb21d7c77248f5626a710e
Merge "Sanitize html tags not on a whitelist."
Merge "Continued port of the PHP sanitizer."
Merge changes I2d8954f6,I2ea56054

* changes:
  Link handling improvements
  Some more attribute accessor/shadow methods
Link handling improvements

* Dynamically select piped / simple wikilinks in the serializer
* Use generic attribute shadowing, drop sHref
* Actually handle modifications to non-piped wikilinks
* Properly escape anything that looks like a percent-encoded char
* Add stripSuffix utility method
* Fix a bunch of JSHint warnings in the serializer in particular

Change-Id: I2d8954f6b665093676ccc5dd5437ea9b37c014ad
Some more attribute accessor/shadow methods

Change-Id: I2ea56054cfd534c7cca7567742438b86eef326ab
Refactored duplicated code in Util

Change-Id: I05d02b73cd35b4b61843fdc17e97a4a8c5d0e8b6
Sanitize html tags not on a whitelist.

* Need auditing to see if the whitelist is complete.
* Added <gallery> and <tag> to the whitelist since they seem to
  come from some extensions and parser tests depend on them.
  May need to use parsoid config or parser hooks/extension info
  to extend sanitizer whitelist.  For now, probably okay.

Change-Id: Id9ecdd96843e8f6ca65e8666807dec1015443d49
Register QUnit tests suites in MediaWiki to run from Special:JavaScriptTest

* Also update test/index.html with latest minimalistic format
* Update test suite hardcoded paths to match the definition in
  VisualEditor.php for ResourceLoader
* Issues:
 - 'jquery/jquery.json.js' should not be loaded directly,
   using a dependency instead.
 - Load scripts from the <head> in test/index.html so that
   code that depends on document being ready is catches instead of
   silently being ignored.

Change-Id: I5ad7390137f4d17c153a1bf69f19c4869c08e323
Move ve.init and ve.init.Platform to the base module, where they belong

Change-Id: I4547bbaa784401a6ca158daac787af23b50715c7
Flag MW-specific code in LinkInspector

Change-Id: I1a85c4c9f5ca0522c2d5491993fad7f05d3a1203
Merge "Bug 36200 - VisualEditor: Sticky selection popup"
Fixed the following bugs with save dialog.

-Bug 38042
Save dialog description field doesn't respond to 'Enter' or 'Return' keys

-Bug 38621
Pressing 'Esc' in Save-dialog should exit saving, return to editor

Change-Id: I9c43c6c9f2f2b538becc4fbbce1eda6e918d4879
Merge changes I4855fce2,Idabdbf25

* changes:
  Do underscore/space conversion in internal link targets
  Get link title from href by stripping article path
Merge "Make VE work again with the link RDFa changes in Parsoid"
Added ve.init.platform with MediaWiki and stand-alone implementations

This should make it much simpler to keep MediaWiki specifics out of VisualEditor, which will in turn make it easier to integrate VisualEditor into another platform.

Change-Id: I073e9737b37c28af889f2457d10b082cefd0d63b
Continued port of the PHP sanitizer.

* CSS sanitization code now ported.
* Could use non-port review another day to see if the ported code makes
  sense and has any gotchas.
* More sanitizer parser tests now green.
* Could use a lot more aggressive addition of parser tests.

Change-Id: I9df003540bd31f327f5307472c9f7dcbbe7b4342
Do underscore/space conversion in internal link targets

Convert underscores in the href attribute to spaces in the linear model,
and back to underscores when going back to HTML. This ensures the link
targets displayed to and edited by the user look nice

Change-Id: I4855fce28ad8b724284c53881abc7b99b59b9079
Bug 36200 - VisualEditor: Sticky selection popup

Clearing context icon when editor loses focus.
-Reproduce problem by selecting text, then click outside of
the editor.  Selection is lost, and context icon is stuck.

Change-Id: I4b321f16cea73ec0e51540c0e71f265ab47514e9
Get link title from href by stripping article path

This means we don't have to rely on data-rt.sHref. It also means that
we'll now be showing the canonical link target in the link inspector
rather than the link target as entered by the user, but that's fine.

Also change test to have href differ from sHref to show that we use
href.

Change-Id: Idabdbf2579663ef1efb47d6a73f39743c9f64f3b
Make VE work again with the link RDFa changes in Parsoid

This is ugly but makes things work again. I intend to clean this up once
we have a better attribute API

* Recognize mw:WikiLink, mw:SimpleWikiLink, mw:ExtLink,
 mw:NumberedExtLink and mw:UrlLink
* Support is incomplete because we can't get to the annotation text with
  the current API
* Preserve all unhandled attributes rather than special-casing data-mw
* Update remaining code using data-mw (sHref and stx extraction) to
  account for the data-mw -> data-rt rename
* Update tests accordingly

Change-Id: Ia13d3008a6d4cdc8828f9acda5aa797566bc597f
Merge "Rename data-rt to data-parsoid"
Merge "Mention the page name in timing information log message"
Merge "Minor: trace output tweak + code refactoring"
Fix parserTests include paths

The recent directory move broke parserTests, fix it for now. Will need
refixing once me migrate to our own repo.

Change-Id: I014001cd6904d1dea3f9417c9cde9c80ab079232
Rename data-rt to data-parsoid

* Quite unique according to google, and more obvious
* Also adjust parserTests to ignore mw:Nowiki and mw:Placeholder spans

Change-Id: I340e85092b60a65b4053a40bf8c238e26cb49c96
Merge "Code and comment cleanup in the ve module"
Minor: trace output tweak + code refactoring

Change-Id: Ic8f51749e84edb7741f5bcea467d647682ef1958
Merge "Bug 38657 - VisualEditor: User should be able to select text in the save dialog."
Merge "First pass porting PHP's sanitizer to Parsoid"
Merge "(bug 37905) Make unlisting unlist all list levels"
Bug 38657 - VisualEditor: User should be able to select text in the save dialog.

- Attaching save dialog to toolbar wrapper vs toolbar itself.
- Attaching surface specific toolbar wrapper vs all toolbar wrappers
in the case of multiple editors on the page.

Change-Id: Ic81f5a680f5593c71c27b7d47fe246487eebd4a3
Code and comment cleanup in the ve module

Change-Id: Ifec72c3992db2ad222a1a89c5172d4089afd865b
First pass porting PHP's sanitizer to Parsoid

* Ported attribute sanitization code (and related functions) from
  core/includes/Sanitizer.php
* Added dummy flags and set to true (use of rdfa, microdata attrs,
  and html5 mode).
* Removed couple whitelisted sanitizer tests.
* A few sanitizer tests now pass.
* More work to be done.

Change-Id: I19c92bbfcb57f3e97a7af1b7c5f63772e427dae4
Merge "Switching to localStorage for copy and paste, remove test"
Switching to localStorage for copy and paste, remove test

Change-Id: I555b8756afb53680d60f2068b8615787c60e9d8f
Merge "Use killall -9 instead of just kill"
Use killall -9 instead of just kill

This makes sure that the new sigterm handler doesn't keep node hanging around

Change-Id: I26a1df3fcc5ec9c3f90c57f7621238ef77a2f089
Merge "Add robots.txt so that our service is not crawled"
Add robots.txt so that our service is not crawled

Change-Id: I20c78537f665606c51a687657fd422b8b471f453
Merge "Bug 33088 - VisualEditor: Editing a part of text of a link doesn't work"
Bug 33088 - VisualEditor: Editing a part of text of a link doesn't work

(or this shouldn't be allowed)

-Revised method for for returning all link annotations in a
selection.  Now properly clearning all selected links.

-Trimming whitespace from selection
-Modifying selection if it doesn't contain annotated range
-Disabled link creation only if target is blank.  This allows
Existing link text to be modified while having the same target.

Change-Id: I7255dcf1c88fa1cd6e7edbc3baa82cd4c72a95d1
Merge "Fix position of context icons."
Moved text node test to the correct directory

Change-Id: I6c2146cd051e9e992e6a30a2d5f83d337d454387
Merge "Added the missing "Node" to alien dm class names"
Merge "Move test files"
Fix position of context icons.

-Added RL embed for images

Change-Id: Id92e3cfe31376e18a924acc983ab17a2bcca837a
Merge "Fix bug in getCoveredSiblingGroups(): forgot to decrement i at the end"
Move test files

Change-Id: Id0a0bd5b4a91f702cad34e9f5e7f2121763abffd
(bug 37905) Make unlisting unlist all list levels

This means that when unlisting (unwrapping) a list, all of its child
lists are unwrapped too.

Change-Id: I7456ddf289dc15a662a4e1fabdeae283d31cd311
Fix bug in getCoveredSiblingGroups(): forgot to decrement i at the end

Change-Id: Iaba268e01000ac5a7ccfc6dfe23db624408e5234
Merge "Parsoid: move tests/parser to modules/parser/test"
Merge "Add generic attribute accessors"
Merge "Added very simple "debug" tool to demo page."
Merge "Inspector box shadow was a bit too dramatic, adjusted styles."
Merge "Bug 38655 - VisualEditor: White box syndrome strikes back!"
Inspector box shadow was a bit too dramatic, adjusted styles.

Change-Id: Ie0f066f62b363df645c072ee174000991258574e
Bug 38655 - VisualEditor: White box syndrome strikes back!

-Hide / show inspector with visibility vs display property
for iframe cross browser compatibility.

Change-Id: Ibdd0250872c42d74d6ff7d22abdf9d838962acc1
Merge "Restore arrow-down to original size because it is needed in context menu."
Merge "Change addInterwiki to setInterwiki, the method name changed"
Merge "Fix childNodeTypes for table"
(bug 37980) Cutting all text and repasting it breaks the editor

This was caused by a bug in fixupInsertion that caused it to believe
that inserting something like "a</p><p>b</p><p>c" into the middle of an
empty paragraph was invalid.

This commit fixes the fixupInsertion bug, which fixes the
select-all-cut-paste behavior in Chrome. It's still broken in Firefox
because of selection-related issues, but I'll split that out into a
different bug report.

Change-Id: I767f5d37ec7e511778ae9ca8283ec4b26c728298
Restore arrow-down to original size because it is needed in context menu.

Add element for arrow icon in dropdown tool and new css rules which
support RTL.

Change-Id: I4193f9cac7af7b84cf8400e9bdcbcb4967b57932
Add generic attribute accessors

* addAttribute and getAttribute do the obvious and simple thing
* addNormalizedAttribute remembers an unnormalized version of an attribute and
  supports change detection for the normalized attribute
* getAttributeSource retrieves the original attribute if there was a
  normalized version which was not changed, or the current value (potentially
  based on the normalized version) otherwise. For use by the
  WikitextSerializer.

Change-Id: I72533cf6cfff1ddb88be2501653c7c47d270898c
Added the missing "Node" to alien dm class names

Change-Id: Ia18d3ede612e2ab8054feb6d94d3587a605e47c2
Mention the page name in timing information log message

Change-Id: I7bf03dcae63734b14499aac77933e8eac5445db2
Merge "Explicitly redirect stderr so that it works when restarted from cron"
Explicitly redirect stderr so that it works when restarted from cron

Change-Id: I22550bbde926024e03123274ae7e960f663bd44b
Merge "Append, don't truncate"
Append, don't truncate

Change-Id: If01d6e343f57965f5d0e6ad0a7000da882257b6a
Merge "Explicitly redirect nohup output to nohup.out"
Explicitly redirect nohup output to nohup.out

Change-Id: Ia4b4143cd4fc7e6b41fd2ee1a0161d1fe9c4ddd8
Added some Arabic text to complex demo - to make testing bi-directional text easier.

Change-Id: I9d5ed8a4d3e57cece0c6dda5e14850151bb0e9da
Parsoid: move tests/parser to modules/parser/test

In preparation for the big extraction of Parsoid out of VisualEditor,
we'll start by moving the tests into the parsoid location.

Change-Id: I4a926ee4aad1490d4f769d44e91af80842b881f0
Added very simple "debug" tool to demo page.

Change-Id: I3df694187089ac4caa2287b55e3a51755cdec2c7
Change addInterwiki to setInterwiki, the method name changed

Change-Id: Ibd255f41b686757378e349fdddbe6b60329d8070
Merge "Use various RDFa types for links"
Merge "Added html2wt command-line option to parse.js"
Renamed ext.Util.js to mediawiki.Util.js

Change-Id: I909847686c8239a0b00cbaa9a0b1583826ee1487
Addressed review comments from recently merged debug_output branch.

* Got rid of mergeProperties monkey-patch from core-upgrade.
* Reformatted class defns in mediawiki.parser.defines.js.
* Protected unconditional tokenization of list handler output with an
  env.trace check.
* Other minor formatting fixes to respect 80-100 column code width
  guideline.

Change-Id: Ida769e0e239b01a813b2d30a65aba60216262a43
Use various RDFa types for links

* the used RDFa types for links are now identical to those listed in
  http://www.mediawiki.org/wiki/Parsoid/RDFa_vocabulary, and are supported for
  serialization
* Editors are responsible for adjusting the type when converting between link
  types. Adding a caption to an mw:UrlLink for example should convert it into
  an mw:ExtLink.

Update: rebased on top of trace patches

Change-Id: Ie1b882e2b3fbad08be94769e1167dccd8dfea65d
Update test README

Change-Id: Icc4f26804295d48bcf244e61ef7654e31b05b306
Implement plain image mw:Image and eliminate data-gen

* Source-based round-tripping now uses typeof="mw:Placeholder" instead of
  data-gen.
* mw:Image is supported for round-tripping, but not yet for modifications as
  it is still source-based

Change-Id: Ie5cf4e54de0163168c25c2b5c09380657a15970f
Merge "Added Jasmine specs to Parsoid."
Merge changes Ife2f840b,I657b1f33,I9d6a03cc,Ib81f96b8,Ia7469b4f,I160ba0c4,I03ae705b,I8343e5c0,I3ab637b7,I50346029

* changes:
  Additional work on readable tokenizer debug output
  Added 'href' key to anonymous KV wikilink and isbn attribute.
  Removed utility functions from mediawiki.parser.environment
  Added utility methods to ext.Util.js
  Added missing var keyword
  In trace mode, wrap transform to output trace info
  Output chunk tokens to console only in trace mode
  Further refinement of readable pretty-printing of tokens.
  More fixes on the way to readable debug/trace output.
  Added mergeProperties function to Object.prototype
Added html2wt command-line option to parse.js

* A quick way to see how a html fragment serializes
* Minor JSHint tweaks.

Change-Id: I901398ec15700905c53de6f39cde93400b2f964a
Merge "(bug 38545) Fix RTL position of the drop-down arrow"
(bug 38545) Fix RTL position of the drop-down arrow

In RTL interface the drop-down arrow overlaps with the text.

The arrow was positioned explicitly in relation to the left margin, and this
can't work in a flipped RTL environment. I changed the position to "right"
and modified the arrow image a bit.

Some visual tweaks to the arrow may still be needed. Another option can be
to convert the image to SVG or to use a character like ▼.

Change-Id: Ib09a2a20b150de6e8a9531fc0db7dfffe4e95525
Merge "Remove trailing commas"
Remove trailing commas

Change-Id: Iffd10561fbf2a5bc92acb50b9827a19016c623d6
Merge "Make an example localsettings.js file."
Fix childNodeTypes for table

Change-Id: I0981fab7687f98859550b2ab4413a490f96d3fe3
Merge "First pass updating debug output"
Merge "Deglobalisation"
Merge "Added .txt to README so it opens nicely in all operating systems"
Merge "Output processing time to console (only for article parsing)"
Added .txt to README so it opens nicely in all operating systems

Change-Id: I78abaa295c5e9c4d547e9daa258651667b80358e
Localisation updates from http://translatewiki.net.

Change-Id: I99e10118e36c7129ba122d51931596d376bd86c7
Deglobalisation

Change-Id: I7665cc13be0457ee9932f7e96b8be7eef496e49a
addInterwiki doesn't exist, use setInterwiki

Change-Id: I844842141033bb7b7d76487934d5c2cdf58a7270
Make an example localsettings.js file.

The current installation instructions suggest reading ParserService.js
to create localsettings.js. Adding this example file should make
the installation a bit easier - the user will simply have to copy
the example file to the target name and edit it.

Also fixed the line ending in the .gitignore entry for localsettings.js.

Change-Id: Ia4f16ac636cbd3473837f439c699e5e3e9950e9e
Prepend a colon to internal links to Category: and File: pages

Change-Id: I77570ea6ec9f29b5d5eb06b518cb08a1b2cea0b2
Factored out building the annotation into a separate function.

Also cleaned up some var statements.

Change-Id: I819cd9b783da71f407fe7b6b862e98f5e0cfa3c2
Additional work on readable tokenizer debug output

* Added custom toString functions for extlink and wikilink
* Other minor tweaks

Change-Id: Ife2f840bfa0e77a86acdfdbfb574a230c9bd29dd
First pass updating debug output

Change-Id: I1e0953d7b26b962e3758dd1091e87a5361257abc
Added 'href' key to anonymous KV wikilink and isbn attribute.

* This makes wikilink attrs more similar to ext links.
* Added 'content' key to ISBN links, but couldn't add it to regular
  wikilinks yet because of complexity of how they are handled in
  the rest of the pipeline.  Changing this requires fixing up other
  parts down the pipeline -- something for later.
* Fixed up wikilink handler to use named lookup for 'href' and
  'tail' rather than positional lookup.  Content lookup is still
  positional as before.

Change-Id: I657b1f338d38df3cfdfa99f27ac46e7fe1c9fd65
Removed utility functions from mediawiki.parser.environment

* these functions have already been added to ext.Util.js
* removed a couple jshint warnings.
* minor code restructuring in tokensToString and comments
  to better indicate what is going on.

Change-Id: I9d6a03cc35075e1a64d8fac9e167a3ce4ccd9424
Added utility methods to ext.Util.js

* Copied over utility methods from mediawiki.parser.environment.js
  to ext.Util.js.
* Moved over utility method from mediawiki.parser.defines.js to
  ext.Util.js.
* Converted Util to be a singleton object rather than an allocatable
  class.  There is no reason to allocate a new utility class everywhere
  since this utility object has no useful state.
* Fixed up use of utility methods to use Util rather than env.

Change-Id: Ib81f96b894f6528f2ccbe36e1fd4c3d50cd1f6b7
Added missing var keyword

Change-Id: Ia7469b4f43bc0b34f045792561d4ee24f9228773
In trace mode, wrap transform to output trace info

- Added extra debug_name parameter to addTransform which is
  used in addTransform to output useful trace info.

Change-Id: I160ba0c45f681149375e32ab19f97baa439b09a8
Output chunk tokens to console only in trace mode

Change-Id: I03ae705bf2679233c4d4b07c25915edd8110a2e8
Further refinement of readable pretty-printing of tokens.

Change-Id: I8343e5c0e2a17116920b8585ce8e5d9bc8826286
More fixes on the way to readable debug/trace output.

Change-Id: I3ab637b7790c359255b8bc0ad5716da12bb25884
Added mergeProperties function to Object.prototype

Change-Id: I50346029a9bd8a7d2cf954b0cca011f73a6fae07
Merge "Start to use the tokenCollector for links"
Merge "Rename addInterwiki to setInterwiki and add removeInterwiki complement"
Bug 33163 - VisualEditor: Floating toolbar should not be displayed when the edit area is entirely off-screen

- Added limits to toolbar float, Toolbar will not go past the last node in editor.
- Added bottom mode to allow toolbar to stick above the last node until the scroll position
is above the last node.
- Actually checking toolbar config now and setting float when flag is set.
- Gave float method for top toolbar a better name.

Change-Id: Ic39c5402fa7a05e13c5e81722d8729d93776d7e9
Merge changes I5ad15ca4,Id88c0fc9,I9c7dbaf2,I99885ee4,I93b2a309

* changes:
  Do not put slugs after nested lists
  Split canHaveSlug() into canHaveSlugBefore() and canHaveSlugAfter()
  Make Enter in an empty list item unindent
  Let Tab and Shift+Tab trigger indentation again
  Work around crazy list rendering bug in Firefox
Merge "First stab at list indent/outdent"
Do not put slugs after nested lists

But still put slugs before them. Done by overriding canHaveSlugAfter()
in ve.ce.ListNode.

Eventually this should be configurable and MediaWiki-specific

Change-Id: I5ad15ca4085a2d730add4954acbea358819b3986
Split canHaveSlug() into canHaveSlugBefore() and canHaveSlugAfter()

These determine whether a node can have a slug before and after,
respectively. The default implementation in ve.ce.Node is to use the
same rules for both, but individual node types can override this.

I'll need this to suppress slugs after nested lists but not before them.

Change-Id: Id88c0fc98aca7c7f52ce990ed9b8c42181ef6d18
Make Enter in an empty list item unindent

For pressing Enter in an empty list item at the end of a top-level list,
this has the same result as the previous code, but if you're in a nested
list it has the effect of jumping down a level. A previous incarnation
of this change just made Enter insert more list items ad infinitum if
you were in a nested list, but I think this is better.

This fixes a bug where pressing at the end of a nested list inserted a
paragraph in an invalid location

Change-Id: I9c7dbaf29a98f84926ed3a05e71c6294926dfce2
Let Tab and Shift+Tab trigger indentation again

Fix the commented-out code: it caused unindent to be triggered by just
pressing Shift. ASCII 16 is "data link escape", no idea where that came
from, so I removed it and used e.shiftKey instead.

Also check whether indent/outdent is even possible before doing it.
Currently this is done in a very hacky way (by checking the state of the
indent button), ideally we'd refactor things such that toolbar tools can
listen for keydowns and intercept them, that would make the code much
cleaner and we wouldn't have this problem.

Change-Id: I99885ee4b8a79cd24c4958c188addfc2b0453b03
Work around crazy list rendering bug in Firefox

After indenting or outdenting a list item in a numbered list, the
numbering wasn't updated. So if you had:
1. One
2. Two
3. Three

and you indented "Two", you'd get:
1. One
     1. Two
3. Three

Adding or removing items in the list using the keyboard, or even
inspecting the list in Firebug (!), would trigger a renumbering and fix
the list to display "2. Three". But then the same issue would occur in
in reverse when outdenting "Two" (either using undo or using the
outdent button):
1. One
2. Two
2. Three

The workaround is to force a reflow by requesting the height (thank you
Timo). Implemented this in an override of onSplice() in ve.ce.ListNode, so
the list is detached and reattached every time children are spliced into
or out of it.

I haven't managed to come up with a minimal test case for this, not even
by putting a list in a contentEditable div and doing the same DOM
operations that ve.ce does from a setTimeout callback.

Change-Id: I93b2a309034c411a7b4e4b6c6bd4ef9d473999eb
First stab at list indent/outdent

This works pretty well, the only problems I found are:
* when selecting multiple list items, only the first is in/outdented
* there's no special handling for child lists, so the behavior for
  in/outdenting list items that have a child list can look weird, but
  it's consistent

Also needs more documentation

Change-Id: I6f4f3725e57a590196d7d638a77b87ea85586dc8
Moved summary functions into custom assertions

Also updated tests to use the new assert as an argument style

Change-Id: I3c82b4b068134bba755ae4a5c26f5bb98d400c43
Fix selectNodes bug where selecting </li><li> returned an empty result

* When ascending back up the stack, check for a start between two closings
* Also check for an end between two openings
* This introduces code duplication but selectNodes() is full of that
  already. I'll have to do a duplication cleanup soon
* Add test case for </li><li>
* Update existing test case that covered a </li>

Change-Id: Ifc80585ce0e0d6988bc54228602c69f0d519200a
After finding a zero-length selection between nodes, return immediately

Change-Id: I04568e053e82c6d6effc370de5edee5d749e3ae6
Fix bug with nested lists in getCoveredSiblingGroups()

For nested lists, this function would return multiple groups where one
was wholly contained in the other, use offsets to prevent that from
happening.

Change-Id: Ib03bb1c81712d805cc263c2975cc3942de63d2ed
Merge "Fixed issue where #sitesub was being shown even if it wasn't originally"
Merge "Converted some instances of "var\t" to "var ""
Revised inspector iframe construction to allow multiple inspectors
to be added.  Create inspector elements in the propper document
scope.  Restore inspector css classnames to camel case for proof
that inspectors are being created in the correct document scope.
Previously, inspector elements created in the wrong document scope
would have css rules applied only if class names were lowercase.
Issue only surfaced in Webkit browsers.  Though, this implementation
is more future proof and will help prevent future inspector bugs.
Patch 3) Fixed global variable definition and mistake with
inspectorDoc

Change-Id: I36c0d078aea10d919689768878004a19f7f89b55
Converted some instances of "var\t" to "var "

Change-Id: I02154e0381d5ae65b482bbcfc21ac93d0bf30d86
Bug 33088 - VisualEditor: Editing a part of text of a link doesn't work (or this shouldn't be allowed)

-Selection of part of a link now modifies selection to entire link
range on inspection.
-Retaining selection direction on new range
Only partial fix to bug as previous link annotation is not
yet properly cleared.

Bug 33053 - VisualEditor: Link creation should not include trailing
spaces, and should provide a suggestion based on selected text
-Created method to return a new range without outer spaces.
-Retaining selection direction on new range.
-Enhancement needed for link suggestion.

Bug 33108 - VisualEditor: Highlighted trailing whitespace should
not have styles applied
-Modified trim method to retain selection, added call to trim
range on annotate method.

Change-Id: I92f264e19350c62b7c2ac3cd9e78af0071afef5c
Start to use the tokenCollector for links

Now that we have access to the contents we can more easily compare the content
with link targets. This is still to do- this commit only converts the link
handler to work on the collected tokens.

* Start to implement latest RDFa spec from
  http://www.mediawiki.org/wiki/Parsoid/RDFa_vocabulary
* Capitalize types, add mw:Entity type for html entities
* Detect changes to entities using tokenCollector and srcContent

Change-Id: I45429f4b930858a16e166ef8377c8f6f5114c414
Removed some whitespace

And added a license to some files that didn't have it yet

Change-Id: I3a7e60374d1198d369a0475b8f65f7415012a337
Changed to use MIT license per agreement with the VisualEditor team

This license change is aimed at maximizing the reusability of this code
in other projects. VisualEditor is more than just an awesome editor for
MediaWiki, it's the new editor for the entire internet.

Added license and author files, plus mentions of the license to all
VisualEditor PHP, JavaScript and CSS files. Parser files have not been
modified but are effectively re-licensed since there's no overriding
license information. 3rd party libraries are not changed, but are all
already MIT licensed.

Change-Id: I895b256325db7c8689756edab34523de4418b0f2
Merge "Added support for hacky use of dl before tables."
Added support for hacky use of dl before tables.

* This is the equivalent of commit a0746946 to
  core/includes/Parser.php

Change-Id: Id093e39dabad29cb275bd21325d39bfeb7709d98
Merge "JSHint: Added dotfiles and fixed tons of linting warnings."
JSHint: Added dotfiles and fixed tons of linting warnings.

* "onevar" warning sometimes solved by just merging var statements
  other times solved by making it a function declaration instead
  of a function expression.
* Also fixed several '_this' variable names in ve.es.Surface to
  more descriptive names, and enabled warnings for dangling _
  in identifiers.

Change-Id: I7d411881e3e06cf9a7fe56d689c29375881a81de
Merge "Add localhost prefix pointing to http://localhost/w by default"
Add localhost prefix pointing to http://localhost/w by default

Change-Id: Ie77eff2997ea1e00dde3f2868e3c585221de42f4
Merge "Updated QUnit to 1.10.0pre."
Updated QUnit to 1.10.0pre.

* https://github.com/jquery/qunit/commit/e98069ad587bb3063b1c978891177f9280fb4415

Change-Id: If20e067a7ae8bd0e419de5e0977eec9cb5590ac9
Merge "Document GPL license for Parsoid"
Document GPL license for Parsoid

This is just to avoid re-licensing along with VE. We want to be compatible
with MediaWiki core to make sure a closely-integrated C port is still
GPL-compatible. We could consider adding MIT to the JS implementation after
porting to C.

Change-Id: Ia83e8620e26c95625793438c4c5e8ddcf2702368
Merge "When the main server process is killed, kill the children too"
Merge "Fixed typo in checking for console.log capability"
Fixed typo in checking for console.log capability

Change-Id: I4a3b88e4fd7d57344673572cae24eff5c6078574
Merge "Renamed ve.ce.Document.css to ve.ce.DocumentNode.css to match it's contents"
Renamed ve.ce.Document.css to ve.ce.DocumentNode.css to match it's contents

Change-Id: I3d7504dfda27309f631a5856ffa4aacd13b6edc7
Merge "(bug 37819) Put minoredit, watchthis messages in specialMessages too so wikitext in it is displayed correctly"
Merge "Removed Special:VisualEditorSandbox and refactored demo"
Removed Special:VisualEditorSandbox and refactored demo

Also renamed ext.visualEditor.editPageInit to
ext.visualEditor.viewPageTarget

Change-Id: I8bdd04b3442067e87bccbc60dd4947aae1c7dfd2
Merge "Made toolbar and dialog save buttons more visible"
Collect tokens in a tokencollector and use cb for processing

This is work in progress, but committed for now so I can use it for links and
tweak it while doing so.

Change-Id: I757277f6efacda6d9432ca57542a957f597a98de
(bug 37819) Put minoredit, watchthis messages in specialMessages too so wikitext in it is displayed correctly

Change-Id: I5fbb7a6ff0de50744bfd5816ebf7d06f04c315b8
Merge "Rename data-mw into data-rt"
Changed add/remove/get transforms.

* This code change is an attempt to address the FIXME about constant
  resorting of transformations in _getTransforms.  This caches sorted
  transformations and selectively clears/updates the cache on add/remove.

Change-Id: If24a807b84d494aa4e5597339039a5573a30905e
Output processing time to console (only for article parsing)

Change-Id: I1bef9fb6f0007505914cb7fd48da68ef3b36481d
Rename data-mw into data-rt

This hopefully makes it clearer that data-rt contains private round-trip info
instead of semantically interesting data.

Change-Id: I03b476ed112a4b627c9871ee3677c450f943429a
Strip data-gen in parserTests

Change-Id: I1d3629b4d5487ff8735444069a4004fb74f926ef
When the main server process is killed, kill the children too

Change-Id: If07a8c290d5c1d4ac977222fe8cd25ef345c4132
Merge "Bug fix and minor code cleanup."
Bug fix and minor code cleanup.

Change-Id: Ic446c8822bf1b8a859e045119782d7b8a40c5544
Merge "Encapsulate token collection"
Encapsulate token collection

* Arbitrary predicate support for the termination of collection mode
* tokens as property of the collector instead of a state-global thing

Change-Id: Ibcb342bc64a76fece9b04a760ea56c7878e67cad
Merge "Serializer fixes"
Serializer fixes

* Fixed image serializer to deal with missing 'v' value in a k-v pair
  representing an image attribute.
* Added fix to deal with bare <li>'s (without surrounding <ul> tags)

NOTE: The second fix is required currently to deal with bugs in the parser
as it deals with complex cases.  But, in the future, we could deal with
this in one of the following ways:
(a) The serializer expects a well-formed DOM and all cleanup will be
    done as part of external tools/passes.
(b) The serializer supports a small set of exceptional cases and bare
    list items could be one of them
(c) The serializer ought to handle any DOM that is thrown at it.

Yet to be resolved.

Change-Id: Ib585e5c9f2a8a80854740ce0211bde705f9fd6f4
Merge "Fixed parser and serializer to deal with a 4+ length dash sequence."
Fixed parser and serializer to deal with a 4+ length dash sequence.

Change-Id: If7caaefec1ad55e7604712ef959ff0c843392adf
Rename addInterwiki to setInterwiki and add removeInterwiki complement

This makes it clear that setInterwiki can modify existing mappings, and adds a
similar method for the removal of existing mappings.

Change-Id: Ic603a4b2ccec35d086513fa7cf711702bfb2baa0
Merge "Make the parser service slightly more robust against serializer failures"
Make the parser service slightly more robust against serializer failures

Change-Id: I50624a56fd0319f6acb6fd1c171c7c6f92a97d31
Localisation updates from http://translatewiki.net.

Change-Id: If3eb2da9334602f2faad227bf1dbd43047d244e0
Fixed issue where #sitesub was being shown even if it wasn't originally

To test, add "#siteSub { display:block; }" to MediaWiki:Common.css

Change-Id: I73a80abf5f0de4ceedd47efd043afabf4b8efc0f
Made toolbar and dialog save buttons more visible

Also made the dialog save button keyboard navigable through the tab key

Change-Id: I2f14c2da30b2bae8987264c851def488f0725458
Merge "Add Christian, Rob and Subbu to the extension authors list"
Merge "Bug 37811 - VisualEditor: editing toolbar float trigger also triggers contextView icon, although there is no context to act on -Remove unused updateContext method. -Added check for selection length in contextView set method."
Bug 37811 - VisualEditor: editing toolbar float trigger also triggers contextView icon, although there is no context to act on
-Remove unused updateContext method.
-Added check for selection length in contextView set method.

Change-Id: I1d5791c69deea80c54cff3e021ba4c90cdac2cc4
Merge "Bug 38008 - VisualEditor: Tooltips for formatting menu are broken Fixed inconsistency with message name being used for format dropdown"
Add Christian, Rob and Subbu to the extension authors list

Change-Id: Ifc2d683e510b3f6e76037ac67a559586fc971dc5
Merge "Made extendClass accept a variadic list of base classes to extend with"
Merge "Added feedback button to toolbar"
Merge "Updated Readme to have sane content"
Merge "Removed unused variables"
Merge "Fix link inspector css in new version of chrome. Chrome engine modifies CSS names to lowercase when inside iframe..."
Merge "Rename ve.ce.BranchNode.doSlugs -> ve.ce.BranchNode.addSlugs"
(bug 37848) Fixing delete key at end of document, removing whitespace.

Change-Id: I64cc9e7a3251b7326b104cd3b8ecb0d07240cd77
Bug 38008 - VisualEditor: Tooltips for formatting menu are broken
Fixed inconsistency with message name being used for format dropdown

Change-Id: Id1e3dd1fe61177d7592b449e227ef2527f4d30a1
Fix link inspector css in new version of chrome.
Chrome engine modifies CSS names to lowercase when inside iframe...

Change-Id: I9cd8ccba011d82549ad71acd2b18c6241ec47ca4
Localisation updates from http://translatewiki.net.

Change-Id: I290bb2718632f30a58eb7b9f58fbc9abe8ba86f2
Added Jasmine specs to Parsoid.

* This is especially useful for running DOM -> wikitext tests.
* Run npm install to install dependencies.
* Add new specs in specs/ (see headings.spec.js for example).
* Run all specs with "node specs.js"
* With existing specs, this should fail one assertion.
  - The failing assertion is fixed in the bug-33089 branch.

Change-Id: I084868206a48ba6b69e6e3e85d94d0207a166ae0
Rename ve.ce.BranchNode.doSlugs -> ve.ce.BranchNode.addSlugs

Change-Id: I162067be5a544817e36986eeb0acd0497d37f443
Serializer fix for empty headings (BUG-33089)

Change-Id: Ia7b018335ac9e31938052473fc47ce38443fdeb4
Localisation updates from http://translatewiki.net.

Change-Id: I0f7baec21f97895e08f640177734433b01e89e81
Localisation updates from http://translatewiki.net.

Change-Id: I8557e0cb1952664163beaed7cf71c64116808e10
Merge "Removed playground"
Merge "Fix for Bug 37913"
Abstract out chunk emission from tokenizer

Patch by Adam Wight, fixes bug #35377.

Change-Id: I183baeed8dd78e7d3c775f44d62bec8e6f9fc608
Fix for Bug 37913

* Strips the first paragraph tag in a list item or table cell context
  if there are no attributes on it and stx:html is not set

Change-Id: I74988645fe505c662f86488e32d0f11d464ffe41
Merge "Up entity name length limit even further"
Up entity name length limit even further

There are some really long names in
http://www.w3.org/2003/entities/2007xml/unicode.xml

Change-Id: I0138c9610bb288cd8f29e3600b8a21f932e7bcd9
Merge changes I2c9f102f,I55aa649b

* changes:
  Match named entities with up to eight chars
  Insert separation between adjacent pres
Match named entities with up to eight chars

The longest entries in
http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references.

Change-Id: I2c9f102fe6a905e339e12520d08c1b1b0a4002d8
Merge "Escape ampersands in entities from plain text DOM content"
Insert separation between adjacent pres

Change-Id: I55aa649b4e076cae32b3c970d6384ab2ed4cdd6c
Escape ampersands in entities from plain text DOM content

Change-Id: I0826077cf48b67e38a525090be66411c38d7b65f
Localisation updates from http://translatewiki.net.

Change-Id: If6dab08c26f7c6b8d136c6c530171c2ecc989b77
More thumb roundtripping fixes.

* Looks like I misled myself in commit 88fc91 -- that wikitext
  roundtripped perfectly because it went through the 'src' route
  because it was a thumbnail with an explicit image which doesn't
  go through renderThumb -- so, the serializer simply spit out the
  original 'src' string and hence perfect rt :).
* More whitespace preserving fixes in LinkHandler.
* Also changed resource value in the img tag to use the original
  filename rather than the normalized capitalized filename.
* 2 more parsertests rt -- now upto 400.

Change-Id: I144a6486dd9d07da8a74a68700fe96c78d192826
Prettified Wikitext Constants hash

* Something to be said for code alignment - easier on the eye!
* Maybe a good case for breaking mediawiki coding guidelines.
* But, happy to abandon commit if not useful. :)

Change-Id: I1133af488f572ac7f8727be9108e08e14c4e6420
Next round of image roundtripping fixes

* Changed PrefixImageOptions so that thumb and thumbnail are
  distinct key-value pairs.  Without this fix, cannot distinguish
  between thumb=foo.jpg and thumbnail=foo.jpg
* Fixed link handler so whitespace is preserved around prefixed image
  options.
* Fixed figure handler to process the 3 different kind of image options:
  size, simple image options, and prefixed image options.
* There is a hack/fixme for "upright: aspect" prefixed image option
  which needs to be looked into.
* Still need to fix uppercasing of the image resource name.

With these fixes, the following wikitext roundtrips perfectly
(after newline breaks are removed)

[[Image:Foo.jpg|thumbnail = 'baby.jpg'|100x100px|center| alt =bbbbb|
upright=true|bottom|link='http://foo.bar'|
This is a [[Linked Caption]] in the image]]

Change-Id: I6606df56874c2b97f00f08cb6bbeaec9878167d3
Created a constants object for extracting wikitext markup properties.

* For now, extracted image markup options out of the link handler.
* This info will also be used by the serializer.
* More properties/global constants can be moved into this structure
  over time.

Change-Id: I4cfbfd703f42e93fbad52b38b435f68d8a5c22ee
Localisation updates from http://translatewiki.net.

Change-Id: I94ed36e57eb19d184f5212eae9178aafbd695474
Minor tweaks/fixes to LinkHandler

* Minor refactoring
* Cleared src in dataAttribs in renderThumb since we can serialize
  thumbs now (or at least we can once all bugs are fixed and missing
  pieces are handled).

Change-Id: If18865801cdd3d89c1477e68bfa3e13107c45b40
Source-based round-tripping for behavior switches

Change-Id: I46d12d338314a8dbfdc9a8448a74680e67c3a720
Simple source-based round-tripping for category links

Change-Id: I5a8a03e74a95c6dceda432f0356cce6a3af77c67
Add generic source round-trip mode, and use it for plain images (for now)

Anything with data-gen="both" and dataAttribs.src defined serializes to
dataAttribs.src and drops its contents (if any). We can use this to round-trip
elements we don't properly parse or serialize yet. Without RDFa info, the
editor will not touch the contents after encountering data-gen="both".

Change-Id: Ia39e5fdd765c2c9b36f26313455685d29f118839
Merge "Fix round-tripping of invalid external links somewhat"
Fix round-tripping of invalid external links somewhat

* Don't consider them for auto-numbered links
* Don't insert a trailing space if the content is empty

These links are still wrapped in nowiki on round-tripping since the
valid/invalid url determination is done in the LinkHandler and not the
Tokenizer as it is configuration-dependent. Not incorrect for rendering (and
perhaps easier to understand for humans too), but might still introduce a
dirty diff. We'll still need reconciliation / damage tracking in the end ;)

Change-Id: I959ebc1b7f81d110a1141bb38ba5ee97f52ebf96
Merge changes I27bdc9c5,Ic09972bb

* changes:
  Update nowiki handling to latest spec; some fixes to it
  Default to two preceding newlines for headings for better readabilty
Merge "Fix a crasher in unbalanced heading tokenization"
Update nowiki handling to latest spec; some fixes to it

346 round-trip tests are passing now (up from 343).

Change-Id: I27bdc9c5e010a13c2b4dddc6f263cbf9d3adac36
Removed unused variables

Change-Id: I7fa9e60c6feba5eb5b705d64c8f3aa192aae89ee
Default to two preceding newlines for headings for better readabilty

This only applies to newly created headings, so headings with a single newline
preceding them will be round-tripped that way.

Change-Id: Ic09972bbd25c3934b53f6fd3b5be5a0c3185c2af
Fix a crasher in unbalanced heading tokenization

Example input:

=== foo ==

Old result:
http://www.mediawiki.org/w/index.php?title=VisualEditor:Test&diff=prev&oldid=554403

Change-Id: I0bc135884833607cedb62ec9c045310df3649dd8
Updated Readme to have sane content

Change-Id: Id13f6995adb5b9969bccbbea16a8f0a858f78224
Added feedback button to toolbar

Change-Id: I1f857e46430eae0d5d4ace181475881bc5495309
First pass serializing image thumbs.

* Collect all figure tokens and process them as a chunk
* This effectively mimics context-sensitive DOM walking,
  but since we need serialization supported on a token stream,
  we cannot use real DOM walking.  The current technique should
  also work on a token stream.
* There is a FIXME about the image filename being capitalized.
  This needs fixing in the parser or some other way of recognizing
  original unnormalized filenam.

Amended by gwicke:
* Build option list and join it with pipe to avoid stray trailing pipe
* Satisfy JSHint's weird preference to have '&&' and '||' at the end of the line

Change-Id: I1e5f6600f297fcdf81e3227a82ca3b71d4e97fc3
Merge "Rename data-mw-gc to data-gen. Credit to James!"
Merge "Add basic tsr on indent-pre end tag"
Rename data-mw-gc to data-gen. Credit to James!

Change-Id: Iacbe20b355ddf5f12fffb71ff4dd978ac4364928
Merge "Removing some logging"
Merge "(bug 36201) Control-K triggers link inspector"
(bug 36201) Control-K triggers link inspector

Change-Id: I0ffd237ce51d1899d2151fb76243e818c5f5cfb8
Merge "Bugzilla:37804 - Double bound events were causing double backspace bugs"
Merge "Bugzilla:33093 - Shift-Enter splits at paragraphs instead of list items"
Add basic tsr on indent-pre end tag

This is a zero-length tsr for now (and thus not 100% correct), but will do the
job for starttag / endtag range establishment

Change-Id: Iedd50ad319aa8d5916434fb6744deb04e031e456
Merge changes Idfa5d6a8,I700142a5

* changes:
  Represent nowiki as span instead of meta
  Round-trip html entities and introduce data-mw-gc attribute
Merge "Code cleanup and more newline fixes."
Code cleanup and more newline fixes.

* Removed dead commented out code.
* Cleaned up newline handling in serializer some more.
* Now, onNewLine and onStartOfLine reflect serializer state
  more accurately.
* No implicit new lines for explicit html tags.
* 9 more roundtrip tests now green.

Change-Id: I9f640de2ae769c7472538fa687400dc8a40c2b2d
Merge "Small (and incomplete) fix to table cell tsr"
Small (and incomplete) fix to table cell tsr

Change-Id: I14347939de32af698d7ce0b649165982908c49aa
Represent nowiki as span instead of meta

Change-Id: Idfa5d6a8ee7b2d17205779361ca69d075a79964d
Round-trip html entities and introduce data-mw-gc attribute

297 round-trip tests are passing with this patch.

TODO:
* generalize data-mw-gc handling in the serializer for any tag
* use data-mw-gc="both" and data-mw.src: 'the wikitext' for round-tripping of
  wikitext structures, optionally with some presentational (but read-only)
  content
* use span and data-mw-gc="both" for nowiki

Change-Id: I700142a56818977c20c8c06e6a5f2e77a708d25e
Removed playground

Change-Id: I3b5000381a2dbcfa7453613877695ed5a53fee4c
Added tokenizer support for ----

Change-Id: Idc5519350d11ae91b2ec64553f847d56e22d63bb
Deleted dead PEG productions

Change-Id: I9b859f79f9900b3d320aa1ad0283a4b5ae6c4331
Localisation updates from http://translatewiki.net.

Change-Id: Ibe3268c865a843b5756f00fb396cac62cc37a09d
$COMMITMSG

Change-Id: Ieed1cb99b47c0032295ec1a259bb7b5f3d926ac3
Use _inNewlineContext method instead of bare onNewline

This makes sure that we escape start-of-line syntax when needed, since
onNewline is often not yet set.

Discussion / background:
[19:18] <subbu> this will fix it, but, i think this is asking for another
minor refactoring of these flags ... because this is a subtle fix which means
it might be possible to make it clearer.  onNewline is one true in on
direction, i.e. if true, we are in a new line state, but if we are in a
newline context, onNewline is not true, which is why this new method is
needed.
[19:19] <subbu> i dont know if it is possible, but it seems like it shoudl be
possible.  but, something for later.
[19:20] <subbu> badly phraed.  "onNewline" ==> in new line context, but if in
new line context, onNewline may be false.
[19:20] <gwicke> we should perhaps update it as early as possible instead
[19:21] <subbu> i cannot today, but possible monday.  i am heading out in
about 15-30 mins.
[19:22] <gwicke> will need to check all conditions depending on it in
_serializeToken
[19:22] <subbu> oh, i misunderstood you :)
[19:22] <gwicke> and if there are cases where the onNewline / onStartOfLine
state could be reverted later
[19:23] <subbu> you were referring to the flag, i thought you meant we should
fix this sooner than later.
[19:23] <gwicke> yes, I wasn't terribly clear
[19:23] <gwicke> you wrote something about following productions swallowing
newlines, but I think we don't actually do that any more
[19:24] <gwicke> I'm quite optimistic that updating those flags much earlier
would work
[19:25] <subbu> yes, it could fix it.
[19:26] <subbu> you might be right reg. swallowing.  it was happening earlier.
but, not right now, after single-line mode and other fixes.

Change-Id: Ic1d8141c04eb54a59977d0ba87bcf06bafd421e0
Explain reasoning behind number of worker calculation

Change-Id: I92ae0bb6e02caef98b0d68de4424e775d8922651
Entity-escape [<>] in text content

This should not really be needed if the tokenizer did not decode html entities
on the fly. It is still a quick way to make sure no htmlish content can be
inserted even with the current decoding.

The next step and proper fix is to make entity decoding either optional in the
tokenizer (flag-controlled), or move it to a later stage in the token
processing pipeline.

Change-Id: Ife093dcfb95113763dab5635b098c795d3550586
Added documentation + minor code refactoring

* Renamed defaultOptions to initialState
* Got rid of unused state property
* Added comments explaining how state attributes
  and tag handler flags are used
* Refactored listItemHandler check into functions and
  added FIXME possible rewriting of that check.
* Protected serializeDOM in a try-catch handler to
  catch exceptions and output the exception to the console.

Change-Id: I3d351c06e4b86baeb5a55243b11dbfa9baca5bb7
Removing some logging

Change-Id: I2876e56d2e3680d21877103618e59afec1c81ef9
Bugzilla:37804 - Double bound events were causing double backspace bugs

Change-Id: I589185d077e1efe6fb2c0457a290a8ac9ce8bceb
Bugzilla:33093 - Shift-Enter splits at paragraphs instead of list items

Change-Id: Ie32e878cf9c71f7179143c631a01c0e2e671ed18
Localisation updates from http://translatewiki.net.

Change-Id: Ia8bb7afcc50438516fe32cf3ae1f2d2235fb22de
Made extendClass accept a variadic list of base classes to extend with

Change-Id: I6d2307ce39da47ad2673dd439789a2f74632c59f
Fixed drop-down menu to match items more carefully

Change-Id: Ibd46861be243d2872f4edaa9a182d3931d4f9fab
Merge "Adjust oldRange in the rebuildNodes call as well"
Merge "When trying to turn list items into headings, unlist them"
When trying to turn list items into headings, unlist them

This requires splitting the list and unwrapping the items

Change-Id: Ie77fe00d2396e4f7d2f1b28bfc0b0301255454a4
Adjust oldRange in the rebuildNodes call as well

This fixes a bug Trevor reported where selecting from a list item across
a heading and into a paragraph, pressing backspace, then clicking undo
caused an exception.

Change-Id: Id2851271529e10548f6979a030a198054aa1c48f
Merge "You know what, just don't render hrefs, these links aren't clickable anyway"
Merge "Added support for localsettings.js and improved logging of instance status"
You know what, just don't render hrefs, these links aren't clickable anyway

Change-Id: If5f0c9a2fa41f09569195fe7807aba9a8207a3c9
Merge "Use title for rendering internal links, and guard against undefined"
Use title for rendering internal links, and guard against undefined

Change-Id: I18a4e5e06303fcd9540fde8c3b21fe8f8887417e
Merge "Reconcile the order and completeness of textStyles in 2 different places"
Added support for localsettings.js and improved logging of instance status

Change-Id: Ia46ebb89fd704afe185ee13b726fb4ec044dff81
Escape the href attribute on links

Change-Id: I3edaa5c9346f5c8c222c482bcb190acad2bac24d
No need to apply selection in this transaction

Change-Id: Ia1ea5800dfbe5d89ef2fe22462712d8a558e5e3b
In Firefox hitting enter fires both events - keydown and keypress. We want to ignore key press for enter.

Change-Id: I49d19267cc6115342aadf11ea720e82bbf65ddb2
Reconcile the order and completeness of textStyles in 2 different places

ve.ce.TextNode listed textStyle annotations that didn't actually exist,
and failed to recognize some that did exist (such as span; bug 37808).

Added all annotations to both places. <span> tags are now tolerated by
the editor in that it doesn't crash anymore, but they're displayed (and
saved!) without any attributes, so <span style="color:yellow;">y</span>
doesn't show a yellow 'y' in the editor and is saved back as
<span>y</span> .

Change-Id: Iaae11ad5044150fa904010983ff83579cb37733d
Merge "Undo and redo keyboard shortcuts"
Undo and redo keyboard shortcuts

Change-Id: Ia1e9db52f6fb2da79be28cdedaaf0dffc6097dc9
Merge "Don't use custom handling for left and right arrow while metaKey is pressed as well."
Don't use custom handling for left and right arrow while metaKey is pressed as well.

Change-Id: I7e2f73ab085b877169f4a29bec04a294d6e13a2a
Actually block blocked users in the Parsoid API

Change-Id: I29b938bb5c1ea00886cb2b0ab04121e4d4cd1890
Merge "Fix display of edit summary message in save dialog"
Merge "In case of IE use non-breaking spaces inside slugs instead of invisible separators - as in different browsers."
Fix display of edit summary message in save dialog

Fixed by adding the specialMessages module which is only loaded once the
editor loads. Then after it's loaded we use the summary message from
there to update the (possibly broken) summary message in the save
dialog.

Change-Id: I67f5c59501cdf7c66c925cef8d4dd42b0f2cfde3
In case of IE use non-breaking spaces inside slugs instead of invisible separators - as in different browsers.

Change-Id: Ib6ae077206de1ad772e47e212a9f276f6b0081e0
Localisation updates from http://translatewiki.net.

Change-Id: I2167a11b9b72f2ef575553af0d8f343d0b7044b6
If siteNotice is visible, add class and slide it up.  On ve exit,
SlideDown fast if hidden by ve

Change-Id: I2a4104590de15da1302181a68d38bf271bcca249
Merge "Tear down the beforeUnload handler when redirecting after page creation"
Merge "Fix external link inspector"
Merge "Move visualeditor-loadwarning message to the correct module"
Merge "Create init methods which hide and restore siteNotice if present."
Create init methods which hide and restore siteNotice if present.

Change-Id: I2fbc74ae46474cdb2559ecaa083cc7353b050937
Tear down the beforeUnload handler when redirecting after page creation

Change-Id: If182eb62068c3c585a98535cc6761d98ad7dd56d
Fix external link inspector

Wasn't loading the link target due to a typo

Change-Id: I77533f949363e79dab9b478e6ba10d05b9486acc
Move visualeditor-loadwarning message to the correct module

Change-Id: Iad34c389cf162d2c0182c25df5fd8c96da4f155a
Merge "Fix problem in hasSlugAtOffset when a given offset is out of range of the document - so no node is returned from getNodeAtOffset"
Fix problem in hasSlugAtOffset when a given offset is out of range of the document - so no node is returned from getNodeAtOffset

Change-Id: I91951528c21ddd57f56d7f4854d0e626d96e04a1
Merge "Aggressive keyboard shortcut fix for all browsers and platforms"
Aggressive keyboard shortcut fix for all browsers and platforms

Change-Id: Ic9e6359a06752861a05526dba090b08ccd39b83f
Fix for drawing selection in IE - temporary approach

Change-Id: Ia944e4c96b1d1d78274f9c23e7120954f694ca08
Merge "Rename watch to watchpage, per https://gerrit.wikimedia.org/r/12423"
Merge "Fixed output of translateOffset when collapsing a range"
Rename watch to watchpage, per https://gerrit.wikimedia.org/r/12423

Change-Id: Ic38ea27ead9f98b22b1fbbad5dcbb8de2205f51a
Fixed output of translateOffset when collapsing a range

Change-Id: Ifb40dd1f9de557d4237660f5fb7119d6aa940c65
Firefox has some crazy bindings for browser features. This prevents it and properly annotates.

Change-Id: Ide294efda8b661e16f24cc1f3584a8f08785ff5b
Support dt/dd transitions in the middle of the stack

Change-Id: I1d75caa7782d02a2c33413a078e99b17ccc4141c
Fix definition list parsing and round-trip single vs. multi-line dt/dd

* Removed murky ' :' -> '&nbsp;:' replacement in tokenizer. This breaks four
  parser tests, and should be fixed in a token stream transformer or DOM
  postprocessor. This replacement clashes with round-tripping, and is not
  terribly important visually.
* Added stx:row annotation to single-line dt/dd pairs and use it to preserve
  single-line syntax in the serializer. There is no attempt yet to support the
  addition of nested lists in an originally single-line dd. We'd need to look
  ahead in the serializer to support this. Perhaps the editor can simply drop
  data-mw in that case.
* Switched default dt/dd serialization to multi-line. This supports all nested
  lists and multiple dds.
* Don't close dls when switching from dt to dd or back in the token stream
  ListHandler.

Overall 290 round-trip tests are passing now (up from 284, some due to &nbsp;,
some due to lists). The number of passing parser tests dropped slightly from
303 to 297 (or 301/295 on weekdays other than Thursday).

Change-Id: I85ff40571833713388c6523e6a4ba2e94daa3807
Improve nested definition list serialization

Basically only prefix all bullets if the serialization output is going to be
in start-of-line context. The test for that is currently inline, but should
perhaps be factored out to a method or state flag instead.

We could alternatively consider to return the start-of-line prefix and let it
be used in _serializeToken in case we end up in start-of-line context.

This patch also fixes a newline issue on input like this:

:d1
::: d3

Both the list and list item handlers now set the startsNewline flag
dynamically depending on the context, so that we don't depend on the
suppression of newlines from list syntax by the singleLineMode any more.

There is still an extra newline inserted between list items in the following
example:

;t1 :d1
;;t2 ::d2

This looks like a bug in the produced DOM and not in the serializer, since the
outer definition list is closed and re-opened between d1 and t2.

Change-Id: I78e3a1ef34cf9159d5a1e86fb64c774ff111e71d
Empty elements only use the start handler info

Thus move the 'endsLine' attribute to the start section.

Change-Id: I8490d866b84aa99205ca9e8e3ee137026fb18501
Add localhost interwiki prefix by default, and fix links after default change

It would be nicer if the editor used an explicit prefix instead of relying on
the Parsoid default. I left the default pointing to mediawiki.org for now, but
will switch it back to en.wikipedia.org after the release to fix existing
links pointing to the service.

Change-Id: I2abae56f171f62e789d31bba78155afd0eccd142
Fixed pressing backspace in a slug, now we just move the cursor to some nearby content

Change-Id: Idaf61264fb493169cfef1c48613036c292d590f0
Merge changes I44515c86,Ife902ace,Ia6510de1

* changes:
  Got rid of iteration to get the surface
  Removed attach and detach methods from ve.ce.Node
  Track adjustments in DocumentSynchronizer and apply them to oldRange
Got rid of iteration to get the surface

Also added a safety check to make it easier to spot a regression

Change-Id: I44515c867852f2f726be74161f6b8e466c0933da
Removed attach and detach methods from ve.ce.Node

Added some needed functionality in ve.Node to make up for this

Change-Id: Ife902aceb4e8535411dc653ae61087aecf67a0c6
Track adjustments in DocumentSynchronizer and apply them to oldRange

This is needed because oldRange is relative to the state of the model before any changes were made, but when we call selectNodes() it's gonna operate on a partially updated model tree.

This is a genuine bug in DocumentSynchronizer proper, which means I owe the entire team lunch

Change-Id: Ia6510de19df02e961c7f25fb8e7833abceb8d25b
Merge "Fix adjustment of newRange in TransactionProcessor"
Merge "Fix minor bug with space replacement in TextNode"
Fix adjustment of newRange in TransactionProcessor

* Adjust both start and end for preceding operations
* Adjust end for the current operation as well

Change-Id: I2f96d609bddf3788aa5700ad1f0b46208f3517d7
Fix minor bug with space replacement in TextNode

Change-Id: Iafdc59d9fd8654444079e55a2ad36a40cc21fa4c
Better support for left & right arrow keys

Change-Id: Iad56f8179d3ed90828e31ad0203a5cec9e9d2458
Merge "Properly hide and show inspectors."
Merge "Allow initial value to be accepted in link inspector if it is the default text."
Merge "Logic for moving cursor left and right programmatically"
Merge "Support protocol-relative URLs in the link inspector"
Merge "Fixing backspace when at the beginning of the document."
Merge "Pressing enter in the last listItem, if empty, will exit the list"
Merge "Support for insertion in slugs."
Properly hide and show inspectors.

Change-Id: I1de85c8364df67bf547b4fec498829e61f7ab07f
Logic for moving cursor left and right programmatically

Change-Id: I48844cfbebaf3933ad61dc462ab5ea73be45a8aa
Fix the exception that is thrown when document is passed as a start parameter to traverseLeafNodes method.

Change-Id: Ie8c5a0fd9ad8e003fef706fdf61749499ad27e31
Allow initial value to be accepted in link inspector if it is the
default text.

Change-Id: Ife8e8742b57bc9ff75cf147d6abc913f2a2ada7c
Support protocol-relative URLs in the link inspector

Change-Id: I78ed64d90e562de1a972807c16196f10d805b959
Fixing backspace when at the beginning of the document.

Change-Id: Ib4c463c6a1eb27897a39c96c46617047d8ee4325
Support for insertion in slugs.

Change-Id: I8e144206520b59271edf854020b87ce947fe0559
Pressing enter in the last listItem, if empty, will exit the list

Change-Id: I084fabac09654adf50db97b554e937d2772f9a37
Merge "Added onbeforeunload handler which warns before someone leaves the page if they have unsaved changes"
Merge "Added getSelectionText method to link inspector so that the default text for a link is the selected text. patchset 2 - add case for if data offset is an object, be sure it is a string prior to adding it.  truncate to 255 chars. patchset 3 - actually add the patched file Change-Id: Ibddf942c2a0ba3412d93cf9730f74eb858025fad"
Added getSelectionText method to link inspector so that the default
text for a link is the selected text.
patchset 2 - add case for if data offset is an object, be sure it
is a string prior to adding it.  truncate to 255 chars.
patchset 3 - actually add the patched file
Change-Id: Ibddf942c2a0ba3412d93cf9730f74eb858025fad
Merge changes I949eebf8,Iba69ee62

* changes:
  Use mediawiki.org as the default source in production
  Revert "Added localhost to available sources and made it default"
Added onbeforeunload handler which warns before someone leaves the page if they have unsaved changes

Change-Id: I0ffb17987ee40995f7f7e3ffc386aa71c9db37a7
Use mediawiki.org as the default source in production

Change-Id: I949eebf82ea152b545e6f10764ba4a9865b46144
Revert "Added localhost to available sources and made it default"

We need to keep master deployable, and obviously this won't deploy
right. For now you'll need to keep a local hack in your own Parsoid, and
later we should have a settings file.

This was also breaking people's dev installs because not everyone uses
http://localhost/mediawiki

This reverts commit 0e0d9fbb5060a91dd8ddd343f8ec2eca873d01fd.

Change-Id: Iba69ee62432d8e5f489ee31d9280961a90b79c20
Fixing handleEnter to allow splitting headlines

Change-Id: I4f75ee1b454f66c4b112a1ab59386994bb249792
Merge "Disable indentation button tool, doesn't work yet"
Merge "Remove old cruft in contentEditable/ , hasn't been touched since Feb 9"
Merge "Use getClonedElement() rather than manually building a node"
Remove old cruft in contentEditable/ , hasn't been touched since Feb 9

Change-Id: I4a823898be6c311bf49d2b019f6e3ea3810efa5b
Merge "Hide each inspector in the iframe, works for now. Will need to be rewritten for multiple inspectors"
Merge "i18n for error messages"
Merge "Document how to remove attributes"
i18n for error messages

Change-Id: Ib0d3350985a64df28a4a2d2c5e68d7dc341330b3
Fix off-by-one bug in the ve.msg's fallback $1 replacement

Change-Id: I62df4ce4b801c7eec5c08958e1c3b4f835f60957
Cleaned up selection and focus code for inspectors

Change-Id: Iee1a3525015967f1de461c9e0ebea84834346172
Move slugs logic into doSlugs since it is being used in onSplice and in cleanup methods.

Change-Id: I10395bbdfd71fda2913e6da736189f0ff8216702
Merge "Keyboard shortcuts for bold and italic"
Keyboard shortcuts for bold and italic

Change-Id: I12b80134152bbbbd2dfa42b32fec072cde29baa5
Hide each inspector in the iframe, works for now.
Will need to be rewritten for multiple inspectors

Change-Id: If94b60d4a1024bdbcdba24f94e318a29341bf18a
Merge "Fix method hasSlugAtOffset to return true when length of the element is 0"
Merge "Add slugs inside empty branch nodes so cursor can be correctly placed."
Merge "Removed trailing whitespace and other cruft"
Use getClonedElement() rather than manually building a node

Change-Id: I3d6390830c6a01235e55b1484e161d1f6737ac01
Merge "Modified handleEnter to insert a paragraph above/below a non-paragraph if at the edges"
Modified handleEnter to insert a paragraph above/below a non-paragraph if at the edges

Change-Id: Icfe650890ceb32f77c79347bebdf8be9612cfdbb
Merge "Typo fixes throughout the codebase"
Merge "When there is a selection range, pressing arrow keys should not remove the selection in Firefox."
When there is a selection range, pressing arrow keys should not remove the selection in Firefox.

Change-Id: I93bca05dd0f37fd8f87eba3f407a68c922ed66e3
Merge "Add commented-out tab key support for indentation button tool"
Add commented-out tab key support for indentation button tool

Change-Id: I4741182bb79becf08288287142a930ddf7f547ad
Disable indentation button tool, doesn't work yet

Change-Id: I582289067139e3e1b7ef14c32d82373d1a1c2b5a
Document how to remove attributes

Change-Id: I9a30a6510d62fb2ee4e6341ef74f2f5558125e72
Apparently every object in FF has a watch() method.  Added better
Checking for this for when mw.page.watch module is not loaded.

Change-Id: I67688288dba59aa52bba9d538682374a15169285
Fix method hasSlugAtOffset to return true when length of the element is 0

Change-Id: Icf43eb6adfcc45eaf1ae8ff146a029546341ba33
Add slugs inside empty branch nodes so cursor can be correctly placed.

Change-Id: I075a76da50bd4927c3832a660fdf96bbd250e3b0
Removed trailing whitespace and other cruft

Change-Id: I8c439d2a272e01b9e26bfd6b13d9e600d324930b
Merge "Pressing backspace or delete at boundary of dislike nodes will cause adoption"
Merge "Set defaultrebase=0"
Pressing backspace or delete at boundary of dislike nodes will cause adoption

Change-Id: Idd6cd40c8d4f34081851fc9ea1cc70037915244b
Set defaultrebase=0

Change-Id: I2fa95fa141d12068df5e6f8c1a12bf67112123e8
If user is anonymous, mw.page.watch is not loaded.  Only call
method if module is loaded.

Change-Id: Ieb549b701f05f1dab322baa79d59366225f42727
Typo fixes throughout the codebase

And a missing semicolon

Change-Id: I8487525ae2a7fa8f58e00c92c7dff600d9bd9520
Broke the grouping functionality of ve.ui.ListButtonTool.list method into ve.Document.getCoveredSiblingGroups

Also fixed unlisting to not break when unlisting a range that includes things that are not list nodes

Change-Id: Ib9d4ea851c3ed9bf72a93aa87e470ce40c308453
* Replace spaces at the beginning and at the end of text node with &nbsp;
* Alternate double spaces with &nbsp, "  " -> " &nbsp;"

Change-Id: Ib4351ed6263e69f0d98957c2d0d8411e040fece7
Localisation updates from http://translatewiki.net.

Change-Id: I3ffd8a577c903e11ebe767cd5ae93c0f969b81f6
Update list tool updateState method so that if you have nodes not
contained by a list node the button is off.  Button is now only toggled on
if all nodes in selection have a parent list node.
Patchset 2 - cleanup whitespace
Change-Id: Ia9adc39c0d5c75e2e96580f0e172f5b602540ac3
Merge "First attempt at the definition list bug (work in progress)"
Add ve.dm.Transaction.translateOffset() and translateRange()

Change-Id: I21bde38056862a1de167646f6cf3030e38d3497b
First attempt at the definition list bug (work in progress)

The main issue is that the bullets from dd/dt were not stored on the stack. I
added a separate field for it in each stack entry, which now fixes the basic
indent case without (afaik) breaking anything else.

There are still some newline issues, and the need to handle the single-line
dd/dt vs. the multi-line variant.

Change-Id: I65939c05e2c5dde0789bf8aefd7651161a2f137c
Localisation updates from http://translatewiki.net.

Change-Id: Id220344eada7ebd6fadc9c44f164888c3f3e3d71
Add Hook for 'watch' event triggered on MW watch link or icon
to update save dialog checkbox with correct watched state.
Call mw.page.watch.updateWatchLink onSave to refresh icon
with watched state.
Patchset 2- updated event name
Change-Id: I23ef1aad9c8ace13df1b9a6bf0bfeddb9d8bcb37
Merge "Rewrote listification"
Rewrote listification

Now handles wrapping or converting properly, in any combination

Change-Id: If8b573f576555c9129f8316bc9f06557eda06e85
Merge "After creating a page, refresh the page rather than going back"
Automatically bind and unbind context's window event bindings on documentNode focus and blur

Change-Id: Ie43165da49a36a7d0d13a52318d9c5438dad9605
Change state variable so updates work more than once

Change-Id: I7c701761b09e96e01e26164080d22cafe43019e0
After creating a page, refresh the page rather than going back

We can't go back in this case because the action tabs etc. will be wrong

Change-Id: I8e26c43b7735ea8a2ef010bd4141f0ee8d4b1c68
Merge "Improve preformatted text handling"
Fix residual selectNodes() breakage from fc4ba3019a1a15f479d6e7cc6a3104e635a1a886

Change-Id: Icc317eab71d4e360905e902a0ae7cc88deab4cbe
Fix ve2 paths in RL modules and tests

Change-Id: I435b9902209348beba83f399ae165d179e954ccb
Merge "Update JS and CSS references in demo to point to new location - ve instead of ve2"
Switch path from ve2 to ve help with Dmrewrite merge

Change-Id: I8fbbfcb3e47a9319398af7262effc1f7cf3df51f
Improve preformatted text handling

* Don't escape html-syntax pre content for now; Should parse this with a new
  pre content production later (which needs to be split out of the regular pre
  production in the tokenizer)
* Protect indent-pre content from start-of-line syntax escaping
* Preserve extra leading spaces in the tokenizer
* Two more (now 284) round-trip tests are passing

Change-Id: I199b89c0ee7fae12546df10c1b5117c97caccac5
Clean up serializer newline handling a bit further

Queued newlines and new trailing newlines were not cleanly separated so far,
which caused some trailing newlines to be consumed for needed leading
newlines. This change fixes several newline bugs, taking the number of passing
round-trip tests from 276 back up to 282.

Change-Id: Idb4706e15ce71e63085033e3f3f29557915c11a8
Fix definition lists with multiple dds

Fixed a bug in the list handler for multiple dds in a definition list. Also
fixed a few JSHint warnings.

Change-Id: I3e883786698a9521347fc2a5e6420646318813a7
Fix a few round-tripping and list issues

At least partly fixes some bugs in
http://www.mediawiki.org/wiki/Parsoid/Bug_test_cases. 276 round-trip tests are
passing.

* Fixes
  http://www.mediawiki.org/wiki/Parsoid/Bug_test_cases#extra_newline_after_empty_dd,
  except for lost newline in 'working' example before next heading
* Fixes newlines in definition lists
  (http://www.mediawiki.org/wiki/Parsoid/Bug_test_cases#dd_indentation etc),
  but does not fix missing / incorrect bullets for those

Change-Id: I21f66e265e43e1d1a4c7da70984a9984b8e6d0dd
Update JS and CSS references in demo to point to new location - ve instead of ve2

Change-Id: I7d5c7888ec4c0923a42c25cf86799b0d07427acf
ve2 -> ve in the tests directory too

Change-Id: I30b56b1c43202d8cb6af397d2813b19b1a71d30e
Merge branch 'dmrewrite'

This merges essentially all editor development in the past two months

Change-Id: I2c8653effc4dbb01a6b99a2ac2b87d83fbafa405
Move ve2/ back to ve/

Change-Id: Ie51d8e48171fb1f84045d1560ee603cee62b91f6
Fix selectNodes() bug: empty range at the start of a node returned []

Because of the end>=left condition, the loop was exiting right before
hitting the startBefore case, so use end>=left-1 instead.

Fixing this exposed another bug that caused nodeRange and nodeOuterRange
to be off by one: we need to increment left after storing it in
startOffset, not before

Change-Id: I54e18fb2119c8caefb4f7a7f2be43c6129afc4c0
Fix single-line mode for nested lists

Known issue: breaks round-tripping of :;;;::. That test is normally disabled
anyway, so we can fix it later.

Change-Id: I7954271311bfb7e71caae59d8177e3f04a9ebbca
Switch back to line-based diff, refineDiff hides some diffs

Change-Id: Ia422b67d2a9010d583780f77df60fb19eab18239
Merge "Revert "Fixed newline stripping in rtve mode.""
Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite
Merge remote-tracking branch 'origin/master' into dmrewrite

Conflicts:
	VisualEditor.i18n.php
	api/ParserService.js
	modules/parser/mediawiki.WikitextSerializer.js

Change-Id: I47b299ff3a6d948dcbeaf53cde5786362b23f66c
Cleanup

Change-Id: I4af98700e5c4739d749ec95abc111710208d2177
Update the code to account for the fact that sHref is now a string

and update tests to reflect the recent changes in link handling

Change-Id: Ie1a3e409c22c09f104c244b1db4764fd202fc885
Make external links (mostly) work

This handles internal and external links separately, only setting
'title' for the former and only 'href' for the latter.

On the way out, detect external links using a simple regex (needs
improvement). Also don't write sHref any more per Gabriel's request.

Change-Id: Ibc2436d0a12de1d027e116f181db640cbcf3d522
Prevent the newline hacks from adding newlines before a link

We might be able to get rid of these altogether but I'd rather not touch
this too much for now

Change-Id: I0b55af017df7d9dc023b2d23ecd4f891cb75946b
Prevent the converter from creating empty list items

Change-Id: Iae7d5d791d09400f7d3d799043efe6b8714465ec
Fixed ve.dm.Surface tests that broke when setSelection was deprecated

Change-Id: I7319067cff0e088f70726c826a0c01be47aec808
Fixed class names to match what's in the DOM now, fixes inspector positioning

Change-Id: I0e15c4a9a50b5894a31b1d37251adb3fd4893539
Clean up sHref handling a bit

* sHref is now always a string
* fixes crasher when sHref is not set

Change-Id: If5756948ac6bc26c2d7c04d970b5aba5331cb8bb
Remove the context menu stuff when tearing down

Change-Id: I7332d449e428aeec8952f7c70d325db7c5d5366a
Made context menu not open after selection ends over top of it

Also fixed some of the positioning to stay correct while scrolling and resizing a window

Change-Id: I40d57b4fb035aea0b43b998251a93a83a46b9735
Wikitext escaping and quite complete source range tracking

* Started to add more complete tag source range (tsr) annotations to most
  start / empty tags. These replace the old sourcePos and sourceTagPos
  annotations, and look more promising for general round-tripping than block
  source ranges (bsr). See
  http://www.mediawiki.org/wiki/User:GWicke/Parsoid_source_ranges for some
  notes on this.
* Added an escapeWikitext method in the serializer that tokenizes supposedly
  text-only content from the DOM with the tokenizer and wraps runs of returned
  non-text tokens into nowiki tags. The source corresponding to non-text
  tokens is retrieved using the tsr annotations.
* Removed old (unused) table productions to avoid confusion.
* 276 round-trip tests are passing, vs. 283 without escaping.

Known issues:
* harmless for now, can be improved later: urllinks in external link captions
  are wrapped in nowiki. Example HTML:

<a rel='mw:extLink' href="http://example.com">http://example2.com</a>

* some start-of-line syntax in wiki-syntax preformatted blocks might be
  wrapped into nowiki when that would not really be needed. Example HTML DOM:

<pre>
* foo
* bar
</pre>

Change-Id: I01c34aedd5c566614d36924add47a6a960e91987
remove on transact proxy as only listening to change

Change-Id: Ifb809a24427f9970fd9a885507fdb376b2dad509
Added i18n messages to mw.msg fallback

Change-Id: Ic4b44eb6ab31392fa727f14ec38800fe6b185d44
Fixed drop-down styling to avoid wrapping

Now that the message keys are showing in the demo we can see how bad things look if the drop-down label is too big and wraps

Change-Id: I776a7e480a3f6240c0929f2f50a865c2de4ec0a5
Introduced ve.msg, an alias for mw.msg if it's available

Change-Id: I67c737e585033edc565e2d941c5a729836a2dbec
Fixed the history buttons to be locked out when disabled

Change-Id: Ie68737a271c683ba0e196d910ef562ac1313c69b
Rewrite updateState for listButtonTool

Change-Id: I690ce70304ed49e71836297c701eceb2269d9b97
Convert content branches to paragraphs before wrapping them in a list

Change-Id: I987a92e838b817dfe7afbcaae19c03b9437f7b66
Allow retry after load failure

Change-Id: Ib0766427013a20e70cca3c17c29246d25690079f
Improved error handling and locked the save dialog save button while saving

Change-Id: I57483f242ef81e17ec1c9d30871c07c2a177a590
Actually fix the error in the previous commit

Change-Id: I5dd841692b2f39c807527dbeb116c904c7cb0994
Use jQuery for lastChild as well, for consistency and to prevent errors

Change-Id: Ia024dbc5ca60e857987aeb652a9c8af5d423c2d0
Set sHref on links on the way out

This fixes handling of internal links, but this code needs more love

Change-Id: I2424d23bd7e795bd7c9cc3443fe4ec4001f2a8c9
Don't add newlines to text nodes inside lists

Change-Id: Ife11f7b87ab540a8a99f13315f889c2aa41a6a32
Add link inspector page title message

Change-Id: I31437946398482e953b027300a421a2bd83c5073
Revert "Fixed newline stripping in rtve mode."

This reverts commit bb7d7c09a58e0ae3651cc8b616788f1ba100036c
Reduced selecting on the documentNode

Change-Id: I6f90e931eedad518d6716cb965606b8fb9387f1e
Reset the save dialog between uses

Also fixed the watchList binding for loading the right state

Change-Id: I25822ba9dfb25d5f8ade765baf6ae69adc9d40ae
Fixed newline stripping in rtve mode.

- Only strip newlines after ">" chars (still not robust,
  but better than stripping everywhere). This prevents
  useless/incorrect diffs in rtve mode and lets us identify
  real bugs.

Change-Id: Iab7b41c4b3d6351c090f8d3a3070330325e876d4
write update and unlist method for list button tool

Change-Id: Ie1f0f8755aac7058d93890e13efefb3c63ee9710
Crusade against hardcoded English, i18n for everything

Change-Id: Ibc658e5f67a373394a4ba149e9b9003f3803023a
Fix inconsistent parameter lists for loadError and saveError events

Change-Id: I7d195793f05f98ff3218f494ef78f9981f6b716f
Fix typos in license text

Change-Id: I0777955b976c2a5d11e5cde78d12b403b8ec7828
Fix method docs for change(), you can't actually pass multiple transactions

Change-Id: I24dd0bd009cd2a7588d8bd45c4580460d49271c7
Improve handling for enter key - and support typing "on the selection" by removing selection first.
Replace every second space with &nbsp; and do the same for the first space and last space.
Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite
Fixed remaining uses of transact to change

Change-Id: I63c8fb183be8b37db85ed386d7bf33633e821f80
Adjusted fades and cleaned up URI objects

Change-Id: I2c6d5758c958ddc222293152707f13d7ae560343
Switched to using "pageName" instead of "title" since page names include the namespace prefix, so it's more correct

Change-Id: Icd1a76ad317fc88f7895654ec1c41144c2695648
Work around broken .clone in mw.Uri

Change-Id: I5e3605c626fc3429c332feab839f555d279e11f7
Make the API module handle missing pages and page creations

Change-Id: I91a43888435011b62e62cf4dde744b23a4ea65d6
Make the converter not return an empty document

Various parts of DM and CE choke on completely empty documents, so
return an empty paragraph instead.

Change-Id: I67062b66a44efe53a1bdaf60907653f0cc55dd25
If the page doesn't exist, create a "Create" tab, not an "Edit" tab

Change-Id: Ic9fa936ac96539ca65e2d570a2c5419dc19334df
Remove userCan hook that had no effect

This hook tried to enforce $wgNamespaceProtection , but that's a core
config variable that's already enforced by MediaWiki itself

Change-Id: I15a40d92e0296eb60054d9845d5c42b880a8f278
Fixed post-save behavior

Change-Id: Ib9bb5d725b1cba2f3e8eb9aa9cf4f2dd2fc87229
Was checking the wrong thing for undefined

Change-Id: I11b813fe8708ef03db2f8b884b3766d8cbe887ce
Added section edit link functionality from diff pages

Change-Id: I2dce543d352f4e086b96c65e53f1a90ef58072fb
Early version of support for typing in "slug" (turning it into paragraph)
Fix problem with turning elements of one type into elements of another type.
Switch diff algo back to diffWords by default

Faster than diffChars, and still easier to read than diffLines.

Change-Id: Id450a2f8a098bb0a71ccf54616f82dad4f25441c
Cleanup in ve.ce.Surface - no significant changes
Fix ListButtonTool to use method "change" instead of old "transact"
Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite
Ported method debounce from underscore.js to ve.
Redirect through the view page when coming from a diff page

Also added URL mixup using window.history.replaceState

Change-Id: If84998b0fe945d82fdfa9a8c88391db30286e972
Fix minor bug in ve.log
Converted more uses of console.log to ve.log

Change-Id: Id41130de088e56dbe8774689317002baa66f5950
Added veaction param which auto-initializes the editor

Made edit tabs rendered on non view pages work correctly by routing them to the view page with an extra param that auto-initializes the editor

Change-Id: I4fd9106c8b45c6fc79af9ccb44e18944e9b9d8b9
Improve newline handling for comments and nowiki/noinclude tags

* Added a newlineTransparent flag to handlers that prevents changes to the
  onNewline status, so that content following it is still considered to be in
  start-of-line context. This fixes a few rt tests where a comment or nowiki
  tag is at the start of the line, and following content should end up on the
  same line.
* 283 rt parser tests are now passing.

Change-Id: Ie58dcb9e5e9af9000fff61c2e1db5d8649ffc3f6
Using resource loader debug scripts to unstub ve.log

Also added ve.dir and converted use of console.log to ve.log

Change-Id: Ibbfd78b6ece163f54f40e997c79a01de6609c2b4
Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite
Introduce new method in Surface model called "change" and get rid of "setSelection" and "transact". Start using new method in Surface view - which right away fixes two bugs - typing at the and of the document, and typing in newly created paragraph/heading.
Major cleanup, fixes and refactoring of ve.init

This solves lots of issues in the integration work, and also makes it much easier to extend this class to integrate it into other skins

Change-Id: I3b3c5b22a5664e6cf37e429cc0ac3be2e75b630f
Made the first paragraph in a list item have no margins or padding to simulate raw text

Change-Id: I7e0aeb9a15db4a56f2a3552430c0da0202f97a97
Serializer refactoring

* tokens are not modified any more (they are supposed to be immutable)
* handler info is now split in start / end objects and potentially a 'make'
  method; added more flags to govern the newline behavior of different tags
* added a generic singleLine mode for single-line syntactical environments
* switched the web service to line-based diffs to avoid issues when diffing
  the round-trip results of [[:en:Programming language]]
* 280 round-trip tests are passing now

Change-Id: I74b8ffbf69643c5d6e5ec852ec58e680c9018901
Fixing ve.log for IE9

Change-Id: Idfcb68abcdae606a4fd78bfec51cb18a8fb495a2
Couple minor bug fixes in serializer

Change-Id: I961e2f4e7609cc6b264eaf494b39497401cdc55c
Experimental /_rtve/ round-trip test mode for web API

This mode strips all newlines from the html source before serializing it back
to wikitext, thus simulating newline-less DOM output from the VE. This
simplistic method also strips newlines in preformatted text, which will show
up as noise in the diff. This simple mode is still useful for the
identification of basic newline-less DOM serialization issues.

An improved version could try to approximate the VE's behavior more closely by
only stripping some newlines.

Due to the experimental nature this mode is not linked from the index page for
now.

Change-Id: I1dfec7ec3e6c12b7de4bbb9ff6f2d8b7834e2857
Emit SpaceCharacters token for HTML5 'space' chars

HTML5 defines space characters as [ \r\n\t\f] in
http://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#space-character.
It treats these specially in a few contexts. As an example, the foster
parenting algorithm does not apply to space characters.

As a result, this change fixes the round-tripping of spaces between table
tags, which were previously moved before the table.

Change-Id: I32ab29275a9f824fc66d8286638eb42748cfc9a5
First pass redoing serialization code to handle newline requirements
from Parsoid HTML output as well as VE HTML output.  There are still
some newline related failures from parser tests that needs fixing, but
this is getting close.  So committing for now so other eyes can make the
bugs shallow :).

Change-Id: Ia6a218ee9fb3e18fe0573c89ff3a4236779e1e64
Removed newline normalization between paragraphs.

Change-Id: Ifd55db73c8fe2b3e952066a75cba2f8e13c58430
Fix for href handling.

- Check if href for links has the wgScriptPath prefix before
  attempting to strip it from the href.

Change-Id: I844151ef7317476668d1306b96a2aec5a56fd0f1
Updated newline handling around lists and nested lists.

- Something like this:
    <ul><li>1</li><li>2<ul><li>2.1</li><li>2.2<ul><li>2.2.1</li><li>2.2.2</li></ul></li><li>2.3</li></ul></li><li>3</li></ul>
  now serializes properly to:

    *1
    *2
    **2.1
    **2.2
    ***2.2.1
    ***2.2.2
    **2.3
    *3

  So does this form which is what the above wikitext parses to:
    <ul><li>1
    </li><li>2
    <ul><li>2.1
    </li><li>2.2
    <ul><li>2.2.1
    </li><li>2.2.2
    </li></ul></li><li>2.3
    </li></ul></li><li>3
    </li></ul>

- Lists (and nested lists) are not entirely newline-insensitive.
  They still depend on newlines *between* lists.  The opening
  <ul> tag for non-nested lists should always start on a new line.
  So, for example,
    <ul><li>foo</li></ul><ul><li>bar</li></ul>
  will serialize to:
    *foo
    *bar
  which is incorrect.  But,
    <ul><li>foo</li></ul>
    <ul><li>bar</li></ul>
  will correctly serialize to:
    *foo

    *bar

Change-Id: I13a0290368574865957bcf57aebab488fbbb7026
Minor code refactoring

Change-Id: Ib7f70a3ac42e3d5a5985e9a9bcffa313bdac289b
Localisation updates from http://translatewiki.net.

Change-Id: I9099f8cd45dd932a9daac0404c310aad37a14768
Fixed/updated newline handling for <p> tags

- More pieces are now simplified and all(?) newline handling
  is now centralized in the serializeToken function.

- This commit fixes bugs in rt-ing some code snippets
    ----------
    Ex 1: foo<p>bar</p>baz
    ----------

- This commit fixes bugs serializing VE generated html
    ----------
    Ex 2: <p>foo</p><pre>bar</pre> ==> foo\n bar
    ----------

- But, this round of fixes introduces RT failures for certain
  code examples in parserTests.txt.  In all these failing cases,
  inline text/html is embedded within a generated <p> tag during
  parsing.  If these generated <p> tags can have a "gc:1" attribute
  added to them, we can properly serialize them to the original
  form.
    ----------
    Ex 3: foo<pre>bar</pre>
          Parsed HTML: <p>foo</p><pre>bar</pre>
    ----------
  Note how this parsed HTML is identical to what the VE outputs
  in Example 2 above.  So, without the gc:1 attribute, we now
  have conflicting requirements on the example same HTML.
  This increases confidence in the correctness of my commit here.

Change-Id: I86beadec91c445a7f8a6d36a639b406697daa0a2
Refix <pre> serialization.

- Effectively reverted fix from f882a651533b99de4791a328b1b20227c14bc830
  and added a new fix.

Change-Id: I8b81e26525a5f1a22acaf2c7067f2dcd9b962818
Improved, simplified newline handling in wikitext serializer.

- Eliminated newline handling from several places in code and
  mostly isolated it to serializeToken thus simplifying newline
  handling logic.
- Fixing some bugs in the process: # of green roundtrip tests
  went up by 5 (294 --> 299) but actually introduced failures on
  a few originally succeeding tests (additional leading/trailing
  newlines on the entire test output).
- Added bonus: made list serializing (mostly) insensitive to
  newlines between tags.  So, all the following DOM serialize
  identically to the following wikitext:

  *foo
  *bar

  ----------
  <ul><li>foo</li><li>bar</li></ul>

  ----------
  <ul>
  <li>foo</li>
  <li>bar</li>
  </ul>
  ----------
  <ul>

  <li>
  foo

  </li>

  <li>
  bar</li>

  </ul>
  ----------

Change-Id: I76be56c4b2789039dff5f47de4659746882e45d6
Couple minor bug fixes in serializer

Change-Id: I961e2f4e7609cc6b264eaf494b39497401cdc55c
Experimental /_rtve/ round-trip test mode for web API

This mode strips all newlines from the html source before serializing it back
to wikitext, thus simulating newline-less DOM output from the VE. This
simplistic method also strips newlines in preformatted text, which will show
up as noise in the diff. This simple mode is still useful for the
identification of basic newline-less DOM serialization issues.

An improved version could try to approximate the VE's behavior more closely by
only stripping some newlines.

Due to the experimental nature this mode is not linked from the index page for
now.

Change-Id: I1dfec7ec3e6c12b7de4bbb9ff6f2d8b7834e2857
Emit SpaceCharacters token for HTML5 'space' chars

HTML5 defines space characters as [ \r\n\t\f] in
http://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#space-character.
It treats these specially in a few contexts. As an example, the foster
parenting algorithm does not apply to space characters.

As a result, this change fixes the round-tripping of spaces between table
tags, which were previously moved before the table.

Change-Id: I32ab29275a9f824fc66d8286638eb42748cfc9a5
First pass redoing serialization code to handle newline requirements
from Parsoid HTML output as well as VE HTML output.  There are still
some newline related failures from parser tests that needs fixing, but
this is getting close.  So committing for now so other eyes can make the
bugs shallow :).

Change-Id: Ia6a218ee9fb3e18fe0573c89ff3a4236779e1e64
Actually fix getRange() this time. Hopefully.

Change-Id: I583a9c2c1ae01370988b4a34ddbf7d3d231e0a74
Using empty pseudo selector and blank image dataURI to battle IE's ridiculous hasLayout bug.

Change-Id: I2acec8ff4d7444726b94c46fc53c0085457c959e
Start/stop poll handling for cut and paste

Change-Id: I8a9dcad6f320bdc90b79bfeaad10622543483ffa
Write a better debounced onSelect method for showing the context
view icon after select events are finished being fired.

Change-Id: I4e1307b90eed14b1c9167830018e50b9c7832ae6
Forgot to add dl as a sublist type

Change-Id: Ie04904ffdaf20402dbb22ebe96bcaf2db9ea8b8a
Add a TODO note about preventDefault in alien nodes

Change-Id: I9aa0c6bec1587bdc65f1585c9ea3562c6d2153e6
Add a TODO to the image code about width&height

Change-Id: I75569c1191a7846567e4a4af2dbcd45449cb729c
Fix domWrapperElementType entries in ce that were out of sync with dm

Change-Id: I2684af71af803bc4b57e43a48986bdfced383193
Fix the newline workarounds (for Parsoid newline handling) for headings

* Parsoid outputs bare newlines after a heading unless it's followed by
  a <p>, so strip leading and trailing newlines in all bare text
* Adding a leading newline in <p>s is only needed if preceded by a
  heading, don't add it otherwise
* Headings need a bare newline after them unless followed by a <p>
* Headings also need a bare newline before them if preceded by a <pre>

Change-Id: Ib02f800b26453541604e920fbb3845c51cdc6dea
Apply <p> tag workaround to <dd> and <dt> too

Change-Id: Ie639c8fd740adc8d9fa26d61ebae2716e41eb2ba
Fix indentation of comment, remove commented-out debugger statements

Change-Id: I7db94e262100cb83be382de4ac4858a1535bc9f5
Clear state of contextview when there is no selection length.
Make context update method work on single call

Change-Id: I2b7f3a31ea5ca1530f927a7e11827d583f134ffb
Fix context icon update method

Change-Id: I1100e53a0bf4364d6435f648b06ce0be7851e8db
More dirty hacks to deal with Parsoid's behavior re newlines in <p>s

This strips certain newlines added by Parsoid so they don't end up in
the linear model, and puts them back in on the way out so Parsoid
doesn't freak out and produce invalid wikitext

Change-Id: I256aaded4229c915868dc868ec6eaa1a73e00be1
Don't produce an invalid range

I know this code is still being worked on but I felt like I should put
this in anyway, it might save the person working on it some work

Change-Id: I1535399b3798cd8de2fc5334cd1eac64b71e8821
When deleting, collapse the selection before issuing a transaction

This is needed because there are onTransact event handlers that use the
selection and expect it to be up-to-date. The previous behavior caused a
bug when pressing backspace at the end of the document, because the old
selection (at the end) was invalid in the context of the updated
document.

Change-Id: I159e37894d14d437f46495604c14804c0a13e84e
Don't add empty annotation objects when inserting text

Empty annotation objects are unexpected by the rest of the data model
and cause weird breakage in the converter, resulting in inserted text
being in its own paragraph

Change-Id: I63de37c3c5e19ac650e7c7f2d1a0bfab21d45da9
Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite
Start polling in async mode after document node is focused
Rewrite listButtonTool list and unlist methods.
Need to rewrite updateState method and polish unlist.

Change-Id: Ia18e038b4941a32f176747e00ed1881887cb1a8d
Typo. Sorry )-:
Cleanup to startPolling, stopPolling and clearPollData
Starting and stopping polling for Enter

Change-Id: I398b6df242009f105bdb2214120779e6c5e57856
Little bit of a cleanup to stopPolling, startPolling and clearPollData
fixing timer var name

Change-Id: Ica8d20942908f6a5fb78206873c4036e4ac7d77b
Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite
Stop and start polling for undo and redo

Change-Id: I041f4c1d28a44797101da278c70e5e1759ebe6d2
Fix typo rawr

Change-Id: Ib80b5e62aa4053c070ebdd065f327b54a30dc90f
Removed newline normalization between paragraphs.

Change-Id: Ifd55db73c8fe2b3e952066a75cba2f8e13c58430
Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite
Attach handlers to mousedown, mouseup and keydown events on document node focus and disattach on document node blur.
Fix missing adjustment in TransactionProcessor

I forgot to adjust a range based on this.cursor for this.adjustment .
This indirectly caused Rob to get an exception when trying to wrap
the last node in the document, because the unadjusted range was past the
end of the document.

Change-Id: If9d5b76568fae25ba2c0f405f1c4fcdd8d879e4f
Fix for href handling.

- Check if href for links has the wgScriptPath prefix before
  attempting to strip it from the href.

Change-Id: I844151ef7317476668d1306b96a2aec5a56fd0f1
Restored animated toolbar positioning

Change-Id: Ie7d44c6cd0fc459cfd02b6a68fa317ceadac7e7b
Fix broken getRange() function, wasn't skipping the opening element

Change-Id: Ib02cf9d22ba612e1cee02a4dd75f106907b74949
Don't blow away attributes coming from toDataElement()

This fixed a bug where an <h2> element with HTML attributes would be
converted to a 'heading' element with those HTML attributes but without
the 'level' attribute, which indirectly caused an exception somewhere in
ve.ce

Change-Id: I8bf32ff0d8e0f9d016b2abc6cb31824df05bdfc2
Updated newline handling around lists and nested lists.

- Something like this:
    <ul><li>1</li><li>2<ul><li>2.1</li><li>2.2<ul><li>2.2.1</li><li>2.2.2</li></ul></li><li>2.3</li></ul></li><li>3</li></ul>
  now serializes properly to:

    *1
    *2
    **2.1
    **2.2
    ***2.2.1
    ***2.2.2
    **2.3
    *3

  So does this form which is what the above wikitext parses to:
    <ul><li>1
    </li><li>2
    <ul><li>2.1
    </li><li>2.2
    <ul><li>2.2.1
    </li><li>2.2.2
    </li></ul></li><li>2.3
    </li></ul></li><li>3
    </li></ul>

- Lists (and nested lists) are not entirely newline-insensitive.
  They still depend on newlines *between* lists.  The opening
  <ul> tag for non-nested lists should always start on a new line.
  So, for example,
    <ul><li>foo</li></ul><ul><li>bar</li></ul>
  will serialize to:
    *foo
    *bar
  which is incorrect.  But,
    <ul><li>foo</li></ul>
    <ul><li>bar</li></ul>
  will correctly serialize to:
    *foo

    *bar

Change-Id: I13a0290368574865957bcf57aebab488fbbb7026
Fix clear button tool.  Getting / clearing all annotations

Change-Id: I2fc2da20da149cd5fdf3f2cd33aeed2e033fd979
Add ve.log, ve.debug and change rendering animation debug effect used in TextNode.
Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite
Fix bug with losing selection direction.
Added support for clicking section edit links

Also now hiding the TOC with animation

Change-Id: Ia355d4104e0bfc276fe0c08d6faa2719e3556c06
Debounced contextView icon on selection in surfaceView.
Squashed old list button methods, list & unlist.

Change-Id: Ic522c761636b2126990ee194b7a441e8bf0396aa
Minor code refactoring

Change-Id: Ib7f70a3ac42e3d5a5985e9a9bcffa313bdac289b
Merge "Localisation updates from http://translatewiki.net."
Localisation updates from http://translatewiki.net.

Change-Id: I9099f8cd45dd932a9daac0404c310aad37a14768
Fixed/updated newline handling for <p> tags

- More pieces are now simplified and all(?) newline handling
  is now centralized in the serializeToken function.

- This commit fixes bugs in rt-ing some code snippets
    ----------
    Ex 1: foo<p>bar</p>baz
    ----------

- This commit fixes bugs serializing VE generated html
    ----------
    Ex 2: <p>foo</p><pre>bar</pre> ==> foo\n bar
    ----------

- But, this round of fixes introduces RT failures for certain
  code examples in parserTests.txt.  In all these failing cases,
  inline text/html is embedded within a generated <p> tag during
  parsing.  If these generated <p> tags can have a "gc:1" attribute
  added to them, we can properly serialize them to the original
  form.
    ----------
    Ex 3: foo<pre>bar</pre>
          Parsed HTML: <p>foo</p><pre>bar</pre>
    ----------
  Note how this parsed HTML is identical to what the VE outputs
  in Example 2 above.  So, without the gc:1 attribute, we now
  have conflicting requirements on the example same HTML.
  This increases confidence in the correctness of my commit here.

Change-Id: I86beadec91c445a7f8a6d36a639b406697daa0a2
Handle aliens correctly in the converter

Previously, data-mw-gc (generated content) elements were unconditionally
converted to alienInline nodes, and unrecognized elements were
unconditionally converted to alienBlock nodes. This is wrong and
produced weird results when I started experimenting with <code> tags.

Instead, I made both gc and unknown element trigger alienation, but the
decision of whether we generate an alienInline or an alienBlock node is
separate and is based only on whether we're inside a content node.

Change-Id: I12335337c3fa60c725ae7bcfbfb52a1dda153fb5
Most of backspace and delete support, methods for starting and stopping polling.

Change-Id: Ic387d9eed3a1368dd70c7a86c7b9761400c76f93
Refix <pre> serialization.

- Effectively reverted fix from f882a651533b99de4791a328b1b20227c14bc830
  and added a new fix.

Change-Id: I8b81e26525a5f1a22acaf2c7067f2dcd9b962818
Special handling in pollChanges loop for case when node is null.
Block triple click (select node) - temporary - as long as we don't have robust support for it.
Improved, simplified newline handling in wikitext serializer.

- Eliminated newline handling from several places in code and
  mostly isolated it to serializeToken thus simplifying newline
  handling logic.
- Fixing some bugs in the process: # of green roundtrip tests
  went up by 5 (294 --> 299) but actually introduced failures on
  a few originally succeeding tests (additional leading/trailing
  newlines on the entire test output).
- Added bonus: made list serializing (mostly) insensitive to
  newlines between tags.  So, all the following DOM serialize
  identically to the following wikitext:

  *foo
  *bar

  ----------
  <ul><li>foo</li><li>bar</li></ul>

  ----------
  <ul>
  <li>foo</li>
  <li>bar</li>
  </ul>
  ----------
  <ul>

  <li>
  foo

  </li>

  <li>
  bar</li>

  </ul>
  ----------

Change-Id: I76be56c4b2789039dff5f47de4659746882e45d6
Use ve.ce.getDomText and ve.ce.getDomHash instead of ve.ce.Surface.getDOMText and ve.ce.Surface.getDOMHash.
Fix bugs in getDomText method.
OMG. We have typing, autocorrect and spellcheck working. (Still no IME and still may break cut/paste)
Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite
Set data.title based on sHref so LinkInspector can use it

Change-Id: I7589740ec5661afd7c8dd0f54e955d170e3096e6
Hack around Parsoid bug in link handling

Parsoid ignores sHref when converting back to wikitext, so we have to
set the href attribute to "/$title"

Change-Id: I1068116c0be72197619d0df3b4d1231a3879fa14
Fix return value of ve.ui.LinkInspector.getSelectedLinkAnnotations()

Was returning a single annotation, but all callers were expecting an
object.

Change-Id: I55be083e5451f4ace5e54dfecb904ae53041054b
Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite
Needs copyArray instead of copyObject, d'oh

Change-Id: Ic185d328a87579262458fe24fd01539c495f09a2
Improved appearance of activating and deactivating editor

Also prevented double-initializing

Change-Id: I9e64eb1f331489f6acee469fdab64133d817e7b1
Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite
Removed duplicate update event on length change and cleaned up some methods that were being called by symbolic operation name

Change-Id: Ica623d1c5619b8268eb97f631e09f9e2f5b67bf0
Moved history tracking into a startable/stoppable service

And made it not start on it's own, but be started by ve.Surface - this makes it so it's not polling in the unit tests, for instance

Change-Id: I940df04d392fd134d18847949efe0e2232328323
Copy objects in newFromWrap() to prevent reference pollution

Change-Id: Ia1f71341342bea44f6ca08088a1276d54187b22a
Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite
Make method ve.dm.Document.addAnnotationsToData accept collection of annotations as a param - instead of an array
Add newFromWrap(), ported 98% verbatim from the old code

Change-Id: I81fc74b1d23bc6b60e476bfefbae4d7d9a9bf5f6
Fix partial undo of ab0c37 in 2ea103

Change-Id: I42225802c45b3867a2aafd40e6941754b1b415b4
Whitespace fixes (jshint was tweaking out)

Change-Id: Id75a097ae4958029caf0a0315343c2fab9c99b89
Fixed use of "pre", "preformatted" is the correct symbolic name

Change-Id: Ifc7e8e3291b8dd29a7fa4c42529bb4fd36a6ed9a
Merge branch 'refs/heads/master' into dmrewrite
Removed context menus on tear down of surface

There needs to be a proper tear down system for ve at some point

Change-Id: I6454423ab96a15932695fbc5429d9e731acc9071
Using wikiLink instead of internal to match actual documents

Change-Id: I24b9c0a5f27ed8f4a7861090ab4049c4614cea78
Make save dialog initially hidden

Change-Id: I8fc4bd67f16266d9355fe639487728ad91ad6ede
Cleaned up toolbar annotation updates

Change-Id: I8cefd6c871ed6d1ad71f64eb66236de1b8b719b5
Real cross browser fix for invisible iframe bug.

Change-Id: Ia2d3c83562542aaaddf0b81dfeaef9aa408aaed3
Removed unused parser pipeline construction

Change-Id: Id2a7dde895b7c3fbf776a2035009686afd4301df
Minor code cleanup

Change-Id: Ic5d99b6c483841310b0c295c1c30246f907455b4
Fixed round-tripping of interwiki links.

Change-Id: If0427b9865b3e9cf8c0ad0b4efaebc9f9f7fb865
Revert default tokenization result from null to ''

* As part of an earlier fix, I had changed default value of 'res'
  to null instead of ''.  But, this was potentially buggy because
  the previous check was (res !== '') which could be triggered
  by return values of handlers.  By changing the check to null,
  I was effectively changing the code paths for those handlers that
  returned ''.

Change-Id: I2302023be7422ce4fb384ff5a50fe53fa7732855
Minor code refactoring

Change-Id: Iec3cb4d83d16174371f0b1f3f23b1056aeed458e
Add suggested development configuration in comments

Change-Id: I3ec8c5326faced6d4b5c878f26f37a281b03bd95
Fix inspector close bug where iframe was blocking editor below
Fix Inspector bug which prevented applying a link annotation to data
already containing annotations.

Change-Id: I6f315d50805c8c71f2155f955ea5674a7ce98656
rewrite comment

Change-Id: Ibc8aab4843ecc0211149aa673d312384e9bd668e
On transact, redraw selection

Change-Id: Ia2f82dd1516113a3c6e77377fec19047fcbd32d0
Merge remote-tracking branch 'origin/master' into dmrewrite
Merge "Remove a few entries we now care about from the whitelist"
Fix serialization of <pre> tags

Change-Id: I7ae95e7ec06167d0c1bfdaba3d0c67d941043299
Fix clearButtonTool

Change-Id: I92e55efb9c82f4d2ef55a71bea318cdc7495c2ea
Fix js error

Change-Id: I3424f205649345a97a7f4d28c4c040c3c3bb6aa7
Rewrite document annotation getters to return collection objects
vs arrays

Change-Id: Ib48a39fff501cdb769f5b9b9fc7717805b74236e
Updating tools on transactions.  Working towards finishing clear
button

Change-Id: I7b6f8cae04fc181b7c8c61d4977e42480e608829
Got rid of wrapping whitespace (like \n and \t) in a span that made text white

This was causing some issues when you started typing there, and it's not clear that the white text is really the best way to go anyways

Change-Id: I8a9d6571ea204603729e96b7ff77184279a31a95
Made save page button only work when an edit is made

Also added confirmation dialog for abandoning unsaved changes

Change-Id: I3388a8f7def9bee5eda32b97ef78e9565a7e33ea
Changed use of getSurfaceModel to getModel and surfaceModel to model

Also cleaned up other stuff that was a little wonky

Change-Id: I6769b0cb53adb9fd4a9411937084efb03a6e3029
Binding to 'before paste' for IE only

Change-Id: I3e3125d2faf75ea79e7f4c4d86fa1ccd666074b6
Enter key handling

Change-Id: I1b5f901a542328c3ae7c19a5cd816112dcac4042
Merge branch 'refs/heads/master' into dmrewrite

Conflicts:
	.gitignore

Change-Id: I73ff881ef3beef702748a2bfffee9e1661004f86
Fixed missing arg, kept stuff from saving

Change-Id: I6c02b2a009f03b2d9e293591166819743fe7ee24
Fixed some minor-ish UI stuff

Change-Id: Ibc3fa2fb7ce9193703263ab708ce18f6aefe5b09
Fixed drop-down arrow placement

Change-Id: Ia9ce735a7938c2db0bad28b44384cf7d206a2023
Fix some comment typos

Change-Id: I58e21bb4cb75580369b89a10cf324c100ed15724
Factor out redundant getNodeFromOffset() call

Change-Id: Ie01282447fab589466554f7c637515289cf570af
Rip out the offset map

The offset map was broken from the start because it wasn't updated when
adjusting the length of a text node, and if we fix that bug it's
doubtful whether the costs of updating the offset map outweigh the
benefits, especially considering that adjusting the length of a text
node is something we do for almost every keypress. If it turns out
having an offset map does make sense, we can always reintroduce it
later.

Change-Id: I59e8bc154f7d07aa1bab2f473c13ff466d0e463f
Update tests for Parsoid workarounds

Change-Id: Ifc7e7dc53eafa62af5652a2dba6cdc1fad199b4c
Make the LinkAnnotation code a bit more robust

Change-Id: I42603788cf112541df67811858bd8854dd224b24
Terrible hacks to work around Parsoid bugs

This makes my test document round-trip cleanly though, yay!
Clear button tool now properly clearning selection annotations.
Create method to return matched annotations button tool pattern.

Change-Id: I5ba2369f1ec81a74570bcfeb1ee86bb7ef07e691
Modify FormatDropDownTool to use new transaction builder
newFromContentBranchConversion

Change-Id: Ifcec60ed57c7c92a5c08219d5f046e904300d5c2
Made use of ve.proxy instead of surface having it's own implementation

Other cleanup as well

Change-Id: I5de5c048e341dd3dc3ef222ae5686c49e51a32a5
Renamed EditPageTarget to ViewPageTarget (since it's targeting view pages, not edit pages, duh...)

Change-Id: I810de87940e0d061c59d32de6654f1f2431f8d82
Added ve.dm.Transaction.newFromContentBranchConversion

Change-Id: I0e272b24dddae028e44d4c693297b1875000ef57
Added normalization to ranges given to selectNodes

Change-Id: I11b7d9b4f8359ab60c1a2f0443dea209a3735711
Added getRange and getOuterRange to ve.dm.Node

Change-Id: If1b226d7944335e9b78d59433e322faf5d48382e
Refactored serializeToken method and added special-case handling of
paragraphs in lists.

* We need to look at other special-case handling requirements of
  html tags in lists (and other contexts like tables).

Change-Id: I84b8402d90a186c9075c2d45263c94377312927a
Port static method addAnnotationsToData from ve to ve2
Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite
Properly clearing link annotations now

Change-Id: I2342ad496566e6d7f6e39a30f70af1f886398069
Guard against passing undefined into ve.compareObjects(), was causing errors
Changed loading graphic, added focus on load

Change-Id: I2d91c25edc7b759f07fe1581953fa0e5baecb51c
Fix link annotation from inspector by changing link type to wikiLink

Change-Id: I5b3497755c6a13e2767f59cc5c95b3e4b43b3be7
Animated the margin of the first heading and fixed animation of save dialog

Change-Id: If4a37aa9e35d9d507577643e4bd40ea4fa3dfad8
Fixed dependency on mw, now demo works again

Change-Id: I26599e065a521cf08a16f5a65e36960a692421e9
Localisation updates from http://translatewiki.net.

Change-Id: I632b12009951716606f71530485ffc7ef377213d
Bring link converter in line with Parsoid

Parsoid outputs rel="mw:wikiLink" or rel="mw:extLink", so we convert that to link/wikiLink and wiki/extLink respectively.

Also preserve the data-mw attribute; we probably need to do this more generally but this'll do for now.

Change-Id: I32e570bffa5a73a733a120d52cfd8b75d3191e02
Remove stray debugger statement

Change-Id: Ie7c37e658d6d6bc15d5d7c24b2f5cd13945c5243
Fix escaping in API module

Let Http::post() handle the escaping of equals signs and newlines in the post data

Change-Id: I5ec91a7532918c807795442aaa0bc1c1a79c5705
Added node_modules and node error log file to git ignore

Change-Id: I9006d1e4bfd266fb470fe9143995c5dda112ac43
Refactored veCore class into ve.init and ve.init.EditPageTarget

Change-Id: I52ef09aee38471ca49f3f4a845daf02e6dcc024c
Move inspectors into iframe loaded in contextView.
TODO- needs cleanup

Change-Id: I62d86260b48ef570ce18833dee3390ec9fff47e1
Cleaned up styles for editor in both demo and sandbox/integration

Change-Id: I9b4a3727fd04b3c3ff3f297c6656db2592856173
Undo and Redo

Change-Id: I2d7c1bfd164a42e5d52001054e52e47ca245ad18
Using MediaWiki facility for HTTP post

Change-Id: If800c4ecbcbecc8560bfd3e704e03acac2ac71d9
jQuery expects a string for the data, not a DOM element

Change-Id: I16b6f00952a2d9e38d631409b9bf3dd7ada644e7
Revert "Support for basic text insertion - typing"

This reverts commit 21056ff5ec0d984e17b2680c5a210a5fc107d7bc.

Change-Id: I86bb28d868b2c931f4b6e18ba5023a8a75b40231
Support for basic text insertion - typing
Added localhost to available sources and made it default

We should probably add some sort of LocalSetting.php type system for environment specific settings like this and git ignore it

Change-Id: I362296ea286d0348e023d1673bba55e098229280
Switched to using MediaWiki facility for getting data over HTTP

Change-Id: I37aa48713632f7272b98c40bc6771ee23b068414
Added real round-tripping, instead of canned HTML

Change-Id: I73cef900e0777352e34818396c1e5d6f218da967
Fixed link conversions to match parser

Change-Id: I67838a8c05729e4d32e6e2dfca53c7d457143ce3
Fixed multi-auto-wrapping issue and added tests to track regressions

Roan mostly wrote this

Change-Id: Id292c84a4da97d6608aa7c17ab6a4cf5a2e3f409
Added rendering for link/unknown

Change-Id: I47cdc8679c533f15059b290bf30ae74518dce724
Fixed element summaries to not rely on HTML serialization, which can render attributes in any order and tends to differ between browsers

Change-Id: I9cb7c3d26efaf983f667c9490cc4be0ea2fe5ab5
Adding node_modules and npm-debug.log to ignore list

Change-Id: Iaff0fc74cec2566d13b346a051994da318b87ec5
Delete HTMLConverter and update demo&sandbox

Also update the demo and sandbox for ve.{dm,ce}.TableSectionNode

Change-Id: I5a73a8250d283e8666b93561ce9e9374739936a5
Merge branch 'refs/heads/master' into dmrewrite
Add a tableSection to the example data and update offsets and stuff in almost all tests

This fixes the converter tests.

Change-Id: I72f6d6c103c3a8bbee201c070a2f7c1bfe401235
Make tableCell represent both <td> and <th>

Adding a 'style' attribute which is set to either 'data' or 'header'

This breaks even more tests because of missing style attributes

Change-Id: I0a75d8c1578b4414eeae8c484f6c4d6f8a59472a
Add ve.dm.TableSectionNode and ve.ce.TableSectionNode

Yes, this breaks a bunch of tests, because tableRows are now required to be inside tableSections

Change-Id: Idb52d988df69173647c85f7602344650456e078e
Throw an exception when attempting to annotate a closing element

Change-Id: Ifd4e49ee05e74db8bec754a6c1f79c969c1f2eac
Fix bug in fixupInsertion()

When a text node was closed (either by encountering a non-text node or by reaching the end of the document), the fixupStack would not be processed. This led to attributes being dropped when nodes were split because of text being inserted into them

Change-Id: I41f6d20e0c1bfc8d8689b7e6325e724dd8156ab1
Test getDomFromData using getDataFromDom's tests

Move the test cases for getDataFromDom out into ve.dm.example and use them to test getDomFromData as well

Change-Id: Ib33854a7a1e8cb6a8ebf2c5b88cd5c17e25644b2
Finish implementing ve.dm.Converter and document it

* Add code to handle elements and annotations
* Drop support for aliens from getDomElementFromDataElement() and move it into getDomFromData()
* Implement getDomElementFromDataAnnotation()
* Document a few functions

Change-Id: Ic6a418cbf9d7d1ad96299d7d3633970a876c6103
Fix typo in LinkAnnotation

Change-Id: Idfb969a73c59aef1acf54edd61d555cdc295534c
Cleaned up some useless/unused functions

Change-Id: I6aa5d0ed3d21993ed653ee64b4928ef98874db2d
Fix bug in getAnnotationsFromRange where if the range length was 0
it would return no annotations.

Change-Id: Iec33366b2a1249122a21617d6681ae039557c2fe
Updating model selection after cut and paste

Change-Id: Iefaec5a3d705c6caae76941bc05810152d870bb8
Fixed alienInline and alienBlock conversion (was missing closings)

Change-Id: Ie8e51eb8d9a452c656aebf341071da5627dd80b5
Added support for alienInline nodes

Change-Id: I15b9cbcdb66b966dca28edcb26bf5d54a4f17be6
Put getSelectionRect method back in surface view.

Change-Id: Iaec899bec157ef39810d391b2ed51d4f8fe3be9d
Init rangy in case of Toshiba
Annotate button redraws selection after annotation
Added contextView hooks to select listener in toolbar.

Change-Id: I598fe715dd84976862eed63e4f55cb6bc6e75b18
Fixing copy and paste

Change-Id: I57ead6a6d831aa739df49960f97cb2f91f672730
Fix some JS errors in the ve.ui code

Change-Id: I57057369f56dc20b56231ed4bbe34816c3c718d7
Add ve.dm.Document.getBalancedData()

Change-Id: I2420ef5369b9eae053962898b64dd7324e714bbd
Factor out element cloning into a getClonedElement() function

Change-Id: Id6024c15d4d9c9141bc4e1afa39fce29992b8647
Localisation updates from http://translatewiki.net.

Change-Id: I29672237acf0ab18963bdd46702b53c675e00b4c
Merge branch 'dmrewrite' of ssh://review/mediawiki/extensions/VisualEditor into dmrewrite
Define min-height for P and HX tags - needed when those tags are empty.

Change-Id: I0ba1c950cc06b3ff040c208c1b9a4970b2f73493
Roan officially does not owe the team lunch (at this precise moment)

Change-Id: I90a6198da97ea90f60d9668c21d7386984a03ff0
Merge branch 'dmrewrite' of ssh://review/mediawiki/extensions/VisualEditor into dmrewrite
Simplify example document that we are currently using in our sandbox (now
it does not include Alien nodes and Images - because we are not going to
support them for June release).

Change-Id: I229e4b5f2881714252699f23aef164655fa8bcf6
Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite
Simplified demo HTML (no images or aliens)

Change-Id: If882086eeccf27a55f1ff7ae0d3657c17268c23e
Added accidently removed registrations for events handling.

Change-Id: I6e5df649909b025f7e7aeb35ff9e8ff0b7fcd5f9
Improvements to selection mechanism.

Change-Id: I031dd3493832034c985b15bf213cafe2c4813136
Delete from ce.BranchNode code that is not needed anymore.

Change-Id: I64f869a9fd54d089d2c6a31d827ddaccb9ece900
Merge branch 'dmrewrite' of ssh://review/mediawiki/extensions/VisualEditor into dmrewrite
Added a test for removing all the content of a paragraph in the middle of a document

Change-Id: Ibbbc401a6484616dca52133b605d643ba3f810eb
Link talk page separately

Change-Id: Ib839f619e7e14ccf0ef698fc2e780ef4b0d65505
Add a 'report issue' link below round-trip results

Change-Id: I5e3a785a328af0debcf83dc2038b5e5417fa5158
Mention citations as not round-tripping

Change-Id: I57e25f6f4072bae2f5681b8611e98f899875d1e2
Add hint on where to support issues in web service entry page

* Explain what we are currently interested in and link to
  :mw:Talk:Parsoid/Todo.

Change-Id: I747c6ee8a021a7a73ec91b73281c1c679a00da8f
Improve interwiki config a bit

* Moved wikipedia default prefixes to environment
* Added 'addInterwiki' method
* Adjusted link handling normalizeTitle to reflect this

Change-Id: If5b2314cc36346b6da8649ed410457a612d80a22
Make it easier to configure the default wiki, and add support for mediawiki.org

* mw:Foo now loads pages from mediawiki.org
* The default prefix still is 'en'. You can switch this to 'mw' in ParserService.js.

Change-Id: I1208667e6114bd711b7988a8b3adb32ffab70969
Remove a few entries we now care about from the whitelist

They are mostly about whitespace, but there is also a debatable quote test
that outputs an empty bold element at the end of the line. We should perhaps
strip this empty bold in the QuoteTransformer, as the preservation of an empty
bold tag in round-tripping does not seem to be too useful.

Change-Id: I1d8f3ebabcd9f6249e5170de420ba52e8aea22ca
Fixed bugs handing/transforming quotes

- Three bugs that were messing up quote transformations.
- Now, the following cases are handled properly:

  * ''foo'''
  * '''foo''
  * ''foo''''
  * ''''foo''

  These tests (and other quote tests) have to be added to core parser
  tests file.

- One more parser test green.

Change-Id: I4f93e8910639f546bfc9304becab17d26d5529de
Undo and Redo support

Change-Id: Icdbebccefe3cc162b9ff6c0d978d5e4fc1f2c561
Merge branch 'dmrewrite' of ssh://review/mediawiki/extensions/VisualEditor into dmrewrite
Change calls to getElementType() (which doesn't exist) to getType()

Change-Id: I894835a0178beddce480c48917700090b31c80b2
Comment out robs selection test stuff

Change-Id: I251de0935f733915042684d186da57b43bc35c51
Fix linkInspector tool

Change-Id: I89fa17b1a72c3f45bce5a11b49aa5445c5990f68
Added implementation for ve.dm.Converter.getDataFromDom

Change-Id: I8561d4a00ba630b86fb7bcd3e347fe2c6c2f6aa3
Annotation buttons now working
Created new document method to determine if a specific annotation
object is inside an annotation array.

Change-Id: Id645929cbf31030b8b0fcacb8dfb36e61aaad129
Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite
Consecutive spaces

Change-Id: I3f51ce0a2ee0a78e56c55de94bd45796b400680d
Delete old ApiQueryParseTree module, unused

Change-Id: Ib39ce97a44fe63a8f38efc4935a215b5d2b854fa
Quick hack to make Parsoid URL configurable

Change-Id: Id314ee13f4e7cc3d0efa3f55d89165acf79109f0
Add a test case for a complex removal

Change-Id: I9e57bf2f1381b1da196308f1cd27c9be58bf8509
Maintain a transaction-wide offset adjustment

This fixes a bug where the second replace operation in a transaction
would cause the rebuild of the wrong range, or the adjustment of the
wrong text node.

Change-Id: I9b1c68d84999d538fe10bb193f4dfdd694121d2a
Add zero-length text nodes to empty content nodes

This is needed to make the results of certain transactions' tree sync
round-trip cleanly through the ve.dm.Document constructor

Change-Id: I2ab0758ec6bd7afba5b6645c7330f9fa2d45205d
Localisation updates from http://translatewiki.net.

Change-Id: Ieb79571c97e1158414ecccbc8d5e984382f2cce5
Shallow-copy annotation objects in HTMLConverter

This fixes an annotation contamination issue that was causing Rob's
tests to throw exceptions

Change-Id: Ic5171d600b0b2ff97cc569e1e6f9488fab177c7c
Fix typo in variable name

Change-Id: I6772555da86a186ec2421d01f82de14463061362
Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite
Fix up some tools to not break on selection,  added some test selection
stuff to sandbox

Change-Id: Ic97144e634111c489507814c6634c66831726191
Rewrite newFromRemoval() using 'covered' mode

Change-Id: If0736aff6d194ec09c2a109f046dd6362ddc64fb
Add 'covered' mode in selectNodes

Change-Id: I4d24c011ce7a94bc75508dea410fb0ed9ebce6a1
Make selectNodes tests actually compare nodeOuterRange

Change-Id: I5c251eb6972e8064ab7e9b2cb9fe2e93060c830f
Fix broken input data in selectNodes tests

Change-Id: I8b81d23d8c501d8f0db5d2922ed3408a6c9033b0
Fix stupid typo in selectNodes()

Change-Id: I1e308c9f3a6e6eb8fe7fe8ae3c6abf7cc3a84d09
Make pushReplace([], []) do nothing

Change-Id: Ifa8df99f376ce22add9d06e76831e8b661e6ddbf
Created secondary method for getMatchingAnnotations
new static method looks for annotation in annotation object.
ve2 Cleanup on annotate method and surface model.
Partially revive UI tools by exchaning old method usage
for ve2 methods.

Change-Id: Id0ac58330292d76801bbcf1d71a919b493f8ab9e
Strip \r from form input- we normalize everything to Unix

Change-Id: I5cd255e1a7ab9958f120fad408362e6f709e4b91
Added getHtmlElementFromDataElement and getDataElementFromHtmlElement

Change-Id: Ie5f4fd86612b5a6c34b5843d1e9a521edc626a63
Use diffChars instead of diffWords, as the former misses some changes

The improved merge algorithm now makes diffChars output more palatable. Things
could still be improved by collecting single-character 'neutral' changes in a
block of 'add' changes and converting them to adds / removes.

Change-Id: I8439e8acab4360c08b89d9ce8a6b8523e7a0a210
Used a more robust heuristic for merging consecutive diffs

- Check if consecutive diffs are separate by 1 word in addition
  to max 3 chars.  This takes care of diffs introduced by template diffs
  separated by the template name and creates a clean single diff.

Change-Id: I9181d2ed9a07bee6ca5d5ebd6ddea84f7e2cecac
Up the diff merge size heuristic a bit and always use the same algorithm

Change-Id: I707c8a55ed1758cdd591d2fc95e03a360c8e76d1
Make modified newlines visible by replacing empty lines with a space

Change-Id: If7b811245e0d01a7a147ab54c3801fc1754730a9
Swap ins/del in the diff

Change-Id: Id336d713d1767a4b7859b158f2c2ddf9adc11cfb
Add core-upgrade

Change-Id: I5ad0955e8272d376f009f89461bed310978b25e4
Merge "Improve the handling of newlines for round-tripping"
Merge "Update patched html5 library to version 0.3.8"
Improve the handling of newlines for round-tripping

An improvement, but there still are some extra newlines inserted after
paragraphs. Example input:

-------

Foo:
{|
|foo
|}
-------

Extra newlines are inserted after the Foo: and the foo in the table. They are
not fed as tokens or text to the tree builder, so there is likely a bug in the
html5 library or JSDom.

Change-Id: I83eb6180e3cd1c4e7f9b15b31d339e1d32bccd3f
Update patched html5 library to version 0.3.8

Change-Id: I321d9a58ea1af33842a606fc8706938093a8330f
Improvement to the refineDiffs function to improve diff quality.

* Attempt to accumulate consecutive add-delete pairs
  with "short text" separating the pairs.  This is equivalent to
  the <b><i> ... </i></b> minimization to expand range of
  <b> and <i> tags, except there is no optimal solution except
  as determined by heuristics ("short text": <= 2 chars).

Change-Id: I408e318c315eba18aac4051ed84d77e3e092d497
Merge changes I5d98c704,Ib8d3de75

* changes:
  A few tweaks to link round-tripping
  Use word diff if --color is enabled
Simpler implementation of flatten.

* Possibly more efficient under heavy GC load -- untested.
* No change in time and memory use for single file parsing.

Change-Id: Id2f3f65cc0e5f38ed968bbda60b97e46523e700e
A few tweaks to link round-tripping

* Moved the tail attribute to the second attribute (a bit cleaner)
* Disallowed newlines in the tail production
* Improved the selection of round-tripped href vs. generated content vs. href
  in the serializer
* renamed state.linkTail to state.dropTail

Change-Id: I5d98c704b6ea566011e22237786f8da17548570f
Use word diff if --color is enabled

Change-Id: Ib8d3de75ac306974abfdaca22bfc7b69bc62891d
Reapply typo fixes from c0e1991 , were undone in b0f6f64

Change-Id: If84e13b91781ed96d3bd9e94171e16020c65ea42
Fix bug in selectNodes's logic for traversing back up the tree

Change-Id: I0fc5a2ad2c9a8d162e8ddbf3cc6d31684d364928
Track html syntax in block_tag production

Change-Id: If560523644f007485809762f12216e08fb3c3ed3
Fix wgScriptPath in round-trip mode without interwiki

Change-Id: I7cc80b7be1afffc586a2ea45d21303e9ba07c0d4
Support interwiki links, and some cleanup

Change-Id: I205c53a03f5230e3ef9100487f4934f97bdc179a
Very basic interwiki support

Pages titles with a wikipedia interwiki prefix now load the page from
corresponding Wikipedia. Links in a page then stay within the given language.

Note that Parsoid currently makes no effort to recognize localized namespaces,
so it won't render media files, categories etc correctly.

Change-Id: I7bc4102e81a402772ea23231170734d580ea15b9
Made pushRetain do nothing if you give it 0 and throw an exception if you give it a negative length

Change-Id: Ib9955660b05a04503325ddb20f9e9a525b4d6832
Added nodeOuterRange to selectNodes

Change-Id: I9ef0c383fbb2515c752d2d3c52e8632aac73d811
Added tests for transactions that deal with removing alien nodes

Change-Id: Id36413c62386dbe5ebc8c8b3a1d3c5e301a8175a
Typo fixes and missing 'var' in newFromRemoval()

Change-Id: Ibb984d862670b5386ff76fc55ef3322f695b6ae1
fixupInsertion() variable documentation and cleanup

Functional changes (fixes):
* Make writeElement() also update parentNode and parentType for openings
* Also add to fixupStack when opening a wrapper for a text node

Non-functional changes (cleanup&docs):
* Document all variables at the beginning of the function
* Group variables according to where/how they're used
* Move expectedType into writeElement()
* Kill node, duplicates parentNode unnecessarily
* Kill paragraphOpened, was misnamed and unnecessary
* Rename closedElements to reopenElements

Change-Id: Ie5b4e4f30b267943048fdc170accb29139039192
Retain attributes when reopening closed nodes

* Push entire elements onto openingStack rather than type strings
* When closing an element, build a clone of the opening and push it onto
  closedElements, then insert that clone when reopening the element

Change-Id: I8b0fb44394aed6c471dc6dacaab03e44c2333733
Add ve.dm.Node.getAttributes() to get a reference to the attributes object

Change-Id: Ic2463d4f7053a5f6defd212f04deb5ea71542843
Add some more tests for newFromInsertion

Change-Id: I3c403928a8176d8685e48a63759fefec4657ca96
fixupInsertion fixes, wrapping content works now

Change-Id: I1eee6afcffbf09955578b7f0534aa5b7234802df
Document annotate method in surface model.
Comment cleanup

Change-Id: Ifd3eeab9046f376529a827dfafdc28506845ac15
Create tests for surface model annotate method.
Fix up surface model tests

Change-Id: I02b57edc5c3faeb39e0b3c1f473f03fbd49d85b4
Rewrite annotate as more low level method in Surface model.
TODO: follow up with annotate tests

Change-Id: If0e68bd3a09840b1e5f3e8d85fd22a8c10134b58
Pre and link target improvements

* Don't explicitly add the newline in the pre, as we preserve newline tokens
  now. This avoids doubling of newlines when round-tripping.
* Use the sHref attribute even if the href contains spaces.

Change-Id: I8bec8fbfd6a7836bf2e5eec20869a0edd95c93b6
Fix list handler issues

Lists interrupted by non-empty lines would not close the list properly.
Register for any token instead of just for newlines and close the list if no
listItem follows the newline.

Change-Id: I1743901e3db541bbeda78d17707db943e6ceb9b9
Optionally round-trip sHref in data-mw

If the href would not denormalize, add a copy of the original href in data-mw
and use it to preserve non-conventional capitalization etc.

Change-Id: Ifef50eec7343b0e6b0ba66b6d19a8a3e8c9f8001
Don't set the data-mw attribute if the object is actually empty.

Change-Id: I984f1b44bba67d7a9f1a709738d14c0ee02f69a9
Actually replace all underscores in wikilink target

Change-Id: I633f8d6e4f639aff90fd456600376b7c6515fd50
Fix padleft / padright (mis)use as substr

Change-Id: I0645e11c8ef8b550ad35300d1904788940fc748a
Add round-trip form and split out rt diffing

Change-Id: I3bc8ad7f273937ce6c767b8d7bbccdc86cbd93b4
Diff refinement fixes

Change-Id: I11c69de0fdcd636ccd11cd0b6cb16c5acdb188b3
Switch back to word-based diff

The char-based diff looked good in some pages, but yielded terrible results in
others. The word-based algo is more consistent overall.

Change-Id: I7f2d40315ad96df037c2d9a1d50739e3d21b6c81
Fix a crasher in the serializer

A tail containing regexp syntax (a ? in [[:en:Main Page]]) would crash the
serializer. Use substr instead.

Change-Id: I8519aec9c07dfe31893d676b1c936a42d2af74a0
Create a 'refinement diff' algorithm

The word or char-based algorithm does not scale well beyond 5k chars or so. We
now perform a line-based diff and then continue to diff the line differences
using the char-based algorithm. This gives a char-based diff even for bigger
inputs.

Change-Id: Iec87ca56540060e4df2859ba54c992e7ff5cfe10
Revert to line diff, word diff explodes on some pages

Change-Id: Ic338498b47bb6b6c98fa6280f44464cd70a48b1b
Some more web service tweaks

* Stay in round-trip mode in HTML DOM output
* Return DOM, wikitext and diff as soon as they are available

Change-Id: I7f8f44cfe8eed63a521d1318d116c22232cb6b1b
Snazzy html word diff for roundtrip view

Also show the HTML DOM, Wikitext output and diff.

Change-Id: Ibe744fbc895239f4e48f6e0e2f2b2f345c0845bd
Update web service start page documentation

Change-Id: I38efc5a9d5b919c6168cf97d0efbae9db967e351
Add ApiRequest

Change-Id: I5f2a1cb65223a68f10bc63903000248efca05586
Retrieve content from the main namespace instead of templates

Change-Id: Id917fa617d6fba1e1b290b2ed20c24aed24d39d2
Improve newline-before-paragraph round-tripping support

Change-Id: I9176a97f9695018650d9a63b89514c07e0d6be90
Very basic round-trip test mode for the API

Returns both the resulting wikitext and the diff with the original input.

Change-Id: Iad25039beb054a84e1ad51ffa9fee924db49c60b
Some more switch fixes

Change-Id: If1a6086348c45a73a941bc8e6728ef75d002be50
Handle link tails properly.

- Added a tail json attribute for wikiLinks
- During serialization, this attribute is used to strip the tail from
  the link target and render it after the link

  [[hen]]s ==> <a ... data-mw="{gc:1, tail: 's'}" ...>hens</a>
           ==> [[hen]]s

- 2 more roundtrip tests green

Change-Id: I84f3dabaf0271f7a67641a00148467daa8310eb0
Added ve.dm.Node.getOffset

Change-Id: I4fb99040af44c063ad3b6489f2fd895d843fcf0c
Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite
Support for pasting into a range

Change-Id: I13e29caba4d912db2477a2c3c4edeca5d21d06b4
Add MakeGlobalVariablesScript hook to add new global, vePageWatched.
This allows us to check the watchlist checkbox on save dialog.
Added watchlist toggling to ve save api.
Added some i18n messages to core integration.

Change-Id: Ibed8edb2c59ad49e1738c937c3bea518238d0845
Cut, copy, and paste now working with images

Change-Id: Ic3b99d39bd41a8fe39e015ca05d159a5a4ea2b15
Fixed bug serializing wikilinks with implicit link text.

* Simple fix but greens 10 more roundtrip tests.

Change-Id: I7f82d788a10bd83e0e3215568c2168081c332c50
Merge branch 'dmrewrite' of ssh://review/mediawiki/extensions/VisualEditor into dmrewrite
Fixed ve.dm.Transaction.newFromRemoval so it supports trimming off extra openings and closings

Change-Id: Icbcf4129a51aa92d47aa89738facd0d288337cbd
Merge branch 'dmrewrite' of ssh://review/mediawiki/extensions/VisualEditor into dmrewrite
Fix up #switch a bit

* Re-establish the value-only default
* Fix value expansion

Change-Id: I32e62789b25bbe17a74c564e41e9101ad5528fb7
Merge "Tokenizer backtracking cache bug fix and memory savings"
Merge "First pass implementing a general tag minimization routine"
Tokenizer backtracking cache bug fix and memory savings

* The state of syntax stops is now properly included in the cache key for the
  tokenizer-internal backtracking cache. This fixes some mis-parses when
  re-parsing a bit of text with different flags.
* Clear the backtracking cache after each toplevelblock. This drops the peak
  memory usage when expanding [[:en:Barack Obama]] from ~380M to ~110M.

Change-Id: Icdb879cae5907e4595903dd6acba2e686e8c2e4b
More cleanup, removed ObjectAnnotation (they are inline elements now)

Change-Id: I2c53c145eed1a801392c954001de7641f928216c
Cleanup

Change-Id: Ida9c94d5aa410ee699b706492f444a6449922ede
Simplified converters data structures

Change-Id: I1734bc7e06462595ea2f27715948fbb3d9e552ad
Created save dialog in core integration
Stash content element styles and remove transitions
Working towards a cleaner saving experience

Change-Id: Ic67022456f46b2bef56a9b0ccfcf93c3283573c4
Added foundation for new converter

* Added converters to all relevant node implementations
* Added new annotation objects with their own factory

Change-Id: I9870d6d5eac45083929d74d2e58917d0939ca917
Merge branch 'dmrewrite' of ssh://review/mediawiki/extensions/VisualEditor into dmrewrite
Changed use of "factory" to "nodeFactory" to make way for other kinds of factories

Change-Id: I96db0f28bb220f1c3b23990824e9523278cb8f9b
Added ve.dm.Transaction.newFromRemoval

Also:
* Refactored tests
* Added tests for ve.dm.Transaction.newFromInsertion
* Added tests for ve.dm.Transaction.newFromRemoval
* Fixed problems with ve.dm.Transaction.newFromInsertion
* Added ve.dm.Node.canBeMergedWith which is partially a port of ve.Node.getCommonAncestorPaths merged with canMerge from within ve.dm.DocumentNode.prepareRemoval from the old ve codebase

Change-Id: Ibbc3887d08286d8ab33fd6296487802d65b319fa
First pass implementing a general tag minimization routine

* This routine attempts to rewrite the DOM to maximize tag overlap
  and thus minimize tag uses.

* This takes as input a set of tags which participate in the
  minimization.

* Tested on the following example
  <b><i><u><s>BIUS</s></u></i></b><b><i><s>BIS</s></i></b><b><u><s>BUS</s></u></b><u><i>UI</i></u>
  with multiple combinations of the 2^4 possible variations of i,b,u,s
  tags: [], ['i','b','u','s'], ['i'], ['b','s'], ['i','b','u']

  - But, I am not fully sure if this implements the right behavior when
    only a subset of inline tags are provided.  Needs discussion and tweaking
	 as necessary.

* Also tested on few others:
  <b>B</b><b><i>BI</i></b><b><i><u>BIU</u></i></b><b><i><u><s>BIUS</s></u></i></b>
  <s><i><b>SIB</s></i></b><s><i><u>SIU</u></i></s><i><u>IU</u></i><i>I</i>

* The previous pairwise tag rewriting version fails on several of these
  examples, so this new version is a definite improvement.

* No change in parserTests run (203 passing before and after).

* Possible improvements that could/should be undertaken:
  - get rid of useless/idempotent add/remove of nodes that don't change
    the DOM.
  - ensure that node attributes post-restructuring are correct.

Change-Id: Ib4a8b39583fa96a2be880a77021ca81cefa06484
Fix buggy replace behavior when inserting content that contains nodes

Copy-pasting things like "text<IMAGE>moretext" failed spectacularly,
this commit fixes that.

* Check for content rather than structure in the inserted/removed data
* In the content case
** Run selectNodes() over the removal range, rather than just the cursor
*** i.e. no longer assume that content replacements only affect one node
** If there is structure involved, rebuild all affected nodes

Change-Id: I80e40b5b7c514a3fb105d57e4a17770d0fefaaea
Add ve.dm.Document.isContentData()

Some of the replacement code was assuming that "does not contain
elements" and "is content" were the same. They're not any more, because
we have content nodes (like image) now, so I need a separate function
to distinguish between these cases.

Change-Id: I206ccdf082b7baddf99d382eb3cdd77ea34fb479
Fix bug in ve.dm.Document constructor for input ending with text

If the last element of the input data array was text, the resulting text
node would have length=0 rather than the expected length value.

Change-Id: I3d089a80b8a447a12ba411b2e11c1b84f14f2959
Load DocumentSynchronizer as well

Change-Id: I93b8ee6fa07c5195e1f32928b2b8989a531fb03d
Revert part of last template syntax tweak

Change-Id: I084e1210577f80c3b96020d57cfa5c68eb5d139b
Make canUserEditPage() static

This shuts up a strict standards notice

Change-Id: I59ce775169965531dd10051418c927b769613abb
Add special handling in getOffset method for a case when cursor is inside slug - required in IE

Change-Id: I27ae78632e7b28921f5fe4214d2fee658c37b564
Restrict edit access to VisualEditor namespace to sysops
To allow non sysops to save via VE, refactored ve save api
to use doEdit which bypasses namespace protection.
Add edit link in view nav for non sysop so that they may edit
Add View source link in dropdown for non sysops
Add Edit source link in dropdown for sysops
Cleaned up some of the integration core code
UI tweaks

Change-Id: Ib4249bc5fb7ffa6410e4f2d278aafbb871800981
Introduce two different types of slugs - inline and block - this is in order to fix bug in IE with placing cursor inside slug by clicking next to it

Change-Id: Idf31a742ee98067688becf46b357c25cd10ddbc6
Refactoring and performance optmization to method getNodeAndOffset - previously named getDOMNodeAndOffset

Change-Id: I067331f539bc86779c98be38e6a56ca04137c70f
Added getNodeFromOffset to ce

WARNING: This is not as fast as the implementation of getNodeFromOffset in dm

Change-Id: I5fbe9b6edc66169b9caaa6751fde1b7b752814d1
NOTE: ve.ce.getNodeFromOffset and ve.dm.getNodeFromOffset should be renamed to getBranchNodeFromOffset to clarify that they only return branch nodes.
Removed aliases for node type constants, on the client we have them already in Node

Change-Id: Id68dd43930a51a857e73af0215fd215c89e9bbbe
Refactoring and performance optimizations to getOffset method in Surface view.

Change-Id: I8b57c9dc069894c82a6bafc5f282aefda505d061
Fixed scroll jumping when pasting

Change-Id: I9607dee6d1b0ca1820a9da5f48966310214e5edf
Using string constants for node types

Change-Id: I2d18d4f54c776e299bc10206386b655605dae839
Another tokenizer robustness improvement

This patch fixes a tokenizer syntax error encountered on
[[:en:Template:JacksonvilleWikiProject-Member]] and [[:en:Template:Infobox
former country]] by allowing optional whitespace before start-of-line template
syntax.

Change-Id: Ic214a731de58bf766e51f23d5e24ea2ce6788f58
Don't eat '}}' in generic attributes and similar productions

This fixes some syntax errors, at least one in Template:Geobox.

Change-Id: I32338febe25d0833c1d9bc4de293cd15b4cbb7be
Check out old results before running tests

Change-Id: Ia56aec22194a14c94620237041c30c269ac2e56a
Preserve original newlines in HTML and serialization

254 round-trip tests (up from 184) are now passing.

Also:
* tweaked runtests.sh slightly (use less -R instead of -r).
* made sure the EOFTk is preserved in phase 3 transforms

Change-Id: I1de22186bdb78e52019370e43f096877005b8f5a
Working (but dirty) implementation of getOffset, getDOMNodeAndOffset and handlers for keydown/mousedown - to be refactored very soon

Change-Id: I57923218fc8e5f3e1cdde339cdc1cb5e859cdedf
Merge branch 'dmrewrite' of ssh://review/mediawiki/extensions/VisualEditor into dmrewrite
Set contenteditable=false for Alien wrappers (both inline and block)

Change-Id: I5fd8fcfd0b6d98b525a75b3818cc77e3aca833c9
Restrict ext.visualEditor.core to the VisualEditor namespace in the hook

Change-Id: I169052bd9a1a38ab0352cca4bf8006a66db381f0
Support for plain text paste

Change-Id: I60846900d61b50138fe06dacee4693166e59651e
Remove edit token Ajax api request, get edit token from wgUser on save

Change-Id: Idb51da271d3eca61230d9948fc82190383fc7143
IE and its silly events

Change-Id: I81f46eca20cc5197305cbd355751c4c90e3b670b
Support for paste

Change-Id: Id0a3d5d421aef56eb3296a56d00686ef7d07b433
Switch tabs from read to edit when loading editor.
On cleanup, switch tabs back

Change-Id: Iefb47536e21cd7763c0d75c976109aeb2cbecf50
Created VE parsoid API save action.
Save action
1) posts html to parsoid service in exchange for wikitext
2) saves wikitext
3) returns parsed content.
On save, VE is hidden and page content is replaced.
Demoing save in toolbar, followup commit will redesign save options

Change-Id: Ibfbe52de08e3483e1a33f0740c03f96ec2b7f90a
Add method hasSlugAtOffset to ve.ce.BranchNode

Change-Id: Id107bf890710096bb49111ae3d0d60e3315ecb89
Fixed bug in isStructuralOffset which didn't consider neighboring a non-content leaf to be a structural offset

This was caused by the fact that a non-structural leaf can not have children, which makes it appear incompatible as a sibling to an arbitrary structural element (like a paragraph) but since it can not contain content we can check that instead.

Change-Id: Ie3c58b4b43f2aa6921f8f82aa82511e231207854
Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite
Create base integration core module
Works on VisualEditor Namespace
Created VE api wrapper for parsoid service to roundtrip pages

Change-Id: I3f2967730c1a3ece31b7262a46bef31ea8b38613
Support for copying

Change-Id: Icf4665f9c48896e26cb536af033ca55410af49db
Basic rt support for indent pre variant

* Added a generic stx_v 'syntax variant' round-trip attribute
* For pre, use stx:'html' vs. no syntax annotation. This might not be 100%
  safe for arbitrary html input, so we might want to flip this to stx:'wiki'
  later.
* 181 round-trip tests passing

Change-Id: If6080917a3a7c069066db3db60efe59b1f6c28d8
Slightly improve formatting of web service; test commit message tweak

Change-Id: Ibac3ce3dd9aa2c4faf11eed351fea941ebf1e4b3
Use '/bin/sh' instead of '/bin/bash'

Bash omits the time output for some reason. We would like to keep a record of
performance too.

Change-Id: I7c435b1cf2e2f237f78a45b2819a195a240e3aa4
Support definition lists with empty definition

Change-Id: I81c39a7e49f2ea7ce32cdd3600caeb5eb9f50d84
Add a small test runner with result archiving in git repo

Supports both -> HTML DOM and round-trip testing. Displays the diff to the
last results using less -r.

Change-Id: Ib3fbadeda3c8f4f7e3d2e6e5236a73ff7a773623
Properly round-trip dd/dt; 178 round-trip tests passing.

Need to track variable whitespace before elements to make some more tests
pass.

Change-Id: Ia86535d6f352e2ffe7965547cd506b0dbb6dfba2
Added handles for mouse events (down, up, move). Implemented method SurfaceView.getOffset and applied significant fixes to SurfaceView.getDOMNodeAndOffset.

Change-Id: I06cbfa9e0e7afc7aaf19d5cda8b91fe93aeb51f8
Fix methods getNearestStructuralOffset and getNearestContentOffset for case of passing offsets that are already structural or content

Change-Id: I23cd2daab9cef181b01131b3b9c6ead5ec47f9f4
Just for purpose of testing add some hardcoded border and cellspacing to all tables

Change-Id: I97ff937d7e7d6a91ee3f411d7f77d5e3798ba567
Add class ve-ce-imageNode to all image nodes, also comment out mousedown event handler

Change-Id: I7565d8822bbe0547e731df1859cdde4ac78de6f2
Make example demo document even more complicated

Change-Id: I9e0406fed859c5d848a5ea52a906d24e1671f458
Copied CSS styles from ve to ve2

Change-Id: Iabd5ee3edde5747952c4b78ef6e9cd5949016050
Image nodes are not draggable

Change-Id: Ie1080045939af7c9b7ac8c30527ad6057fe7e3f6
Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite
Using invisible space character in slugs

Change-Id: I36752f4bea96bad61dedfbbb4fc00422d773227b
Added copying of .data( 'node' ) from old wrappers to new wrappers on wrapper updates

Change-Id: Ibd9535bd9ebb712910d963eedc5941f8512aaf8d
Moved ve.ve.BranchNode.canNodeHaveSlug to ve.ce.Node.prototype.canHaveSlug

Change-Id: I6d5d9ca5a1c9878acb15e9526feb94986822b491
Added missing documentation to methods in ve.ce.BranchNode

Change-Id: If6833e3d639e0455025762987b7f41a43892ca4a
Focus can now be set in slugs using showCursor or showSelection.

Change-Id: I12ab361a30d277a4752579bf885fd37bc46b32ed
Replaced static array with real logic inside of ve.ce.BranchNode.canNodeHaveSlug

Also added more static config getters and fixed some typos in prototype definitions

Change-Id: Ib9093a625b944e6a4ca4da50c51fb475b5895b8d
Moved "is slug gable" functionality to a static method of ve.ce.BranchNode

Also optimized some query stuff

Change-Id: I5675258c6e276a1ba410dcf1ee111392140a04eb
Made getRelativeOffset return -1 if no valid offset is found in document

Change-Id: If4cef5fe800b241c3efe1d27cdf01cd1ceef2248
Added more test cases for the unrestricted option of getRelativeStructuralOffset and getNearestStructuralOffset

Change-Id: I1ab99f1ed050950b40dd4c34abd81a43a4099a49
Add missing JS files references to demo

Change-Id: I6f85942622b151932d10ab322e5d1ba8b4fbcee3
Resolve subpage links, and remove hack for H: titles

Change-Id: I6c9c64179274e5c1641a3b127ac3b273a3c5254e
Notes on missing parser functions, more error reporting tweaks

Change-Id: Ib6ce60cf1b55671a6ff57aa47edb5787ec3aefea
Add self alias

Change-Id: I47682f407da6b554179611c7d0f63f882ab5a871
A few (partly hackish) improvements

* Very basic support attribute key-value pairs emitted from templates
* Add TALKPAGENAME stub implementation
* Only show 'no revisions' message for top-level pages

Change-Id: I4b4ac0c7b2c0531ac4b39f0f49f4217302576ab9
More tweaks to the intro message

Change-Id: I059ba4fc584eae45092376b5b2258df7ed52b55c
Add a longer welcome/help message and a link to the Parsoid docs

Change-Id: I39e4873908bc0619738353a55577aa81abb76287
Sanity check for tokens being an array

Change-Id: Ia4e4071e1469c31e3b320d854500938bb0245f82
Fake fullpagename et al a bit better

Change-Id: I85ddf9e88e5f8ac274f371bea0879600997001e4
Fix non-existing revision error reporting

Change-Id: I6b8687bcde98b92d9d6217a738a177db279fd006
Report missing revisions when retrieving templates

Change-Id: I9f33acafc4d3fbd062125d824e2614dafd4cd5a0
Keep going on tokenizer errors

Change-Id: I76fab4528f89b425845aef1685b3a54ddfeceef4
Improve shell wrapper for parsoid service

Change-Id: I92c536af60613705229faea97a26d1486d4730a1
Use text/x-mediawiki content type, and handle tokenizer errors without --debug

Change-Id: I154cd344306aa05ada7ff30f631d487f39fa9739
Added getRelativeOffset and several wrappers around it

Change-Id: Ifd10922366650165bc4c21ea8cfdd2f9b7163432
Define better example/testing article in Sandbox

Change-Id: I5df37d7e3477bd49e69f44c4902810bca66734b7
Merge branch 'dmrewrite' of ssh://review/mediawiki/extensions/VisualEditor into dmrewrite
Define better example/testing article in Sandbox

Change-Id: Id9ce12f8977b94aca98823fdcb86a0840565579d
Added optional "unrestricted" argument to isStructuralOffset

Using this argument will only return true if the offset is a place you can add any element to (hence the unrestricted part of it). This is good for testing if a paragraph could potentially be inserted there.

Change-Id: I6cc91da437c52493de03eb687b28966198270fea
Added method proxy to ve.ce.Surface

Change-Id: I2373df4c738b49685a897c8e13acebdd7ccb3e00
Refactor mechanism of adding slugs in before and after particular nodes in branch

Change-Id: I8b3f4a9b27ff09d569f366c32f96e7e8191487c0
Implement newFromInsertion()

Mostly just wraps around fixupInsertion()

Change-Id: I5c9128439b9ed29b112590c0004a749f9b529346
Rough first stab at ve.dm.fixupInsertion()

This code still needs a lot of work, but it seems to work for most
cases. Things that still need to be done:
* Documentation and comments
* Handling of content and text nodes
** Use Trevor's isContent/canContainContent code which I don't have yet
* Preserve attributes when reopening closed elements
* Tests :)

Change-Id: I3bc16c964ef158693490a61ce12beb21e6fe2a9d
Remove pushInsert() and pushRemove()

The 'insert' and 'remove' operations weren't implemented in the
transaction processor and were a holdover from the old DM
implementation.

Also migrated the tests, especially those that asserted that consecutive
insert/remove operations were combined (this is no longer the case now
that they are replace operations)

Change-Id: I2379fe92b331c5316f70f4b695397da41581cce9
Localisation updates from http://translatewiki.net.

Change-Id: Ida79fff5a8ef258ef2c8b8f666909618c3ab21d2
Moving alien node styling to CSS file

Change-Id: I21e4593b81669b48cec831236398866f89616f9a
Fix a debug print reference error

Change-Id: Ic26d29aced4129c3dd718c4751dadb62a0be1a27
Updated demo and fixed HTML converter

Removed hard-coding of alien nodes, now aliens are automatically used for anything unknown, and block or inline aliens are selected based on whether the parent element can contain content or not.

Change-Id: I5d2a521ead4f4c96cb44d084a5c160cc20d8048e
Capital T in second part of Content-Type

Change-Id: I20a9af9a8c0e05e96c77c9ac7566ea7bc1a6dabd
Improve the serializer and its output display in the web service

Change-Id: Id3ca96846cad42517d7d4bada8f4bb250d54247b
Add an extra newline before headings, and ignore favicon.ico requests

Change-Id: Ibacac3453afefa5dbe803c1e0260e8c943785f12
Start slightly more workers than there are CPUs

Change-Id: I7381e09ead0420d5d0b8c7dd3045c88c3cbfaa87
Make sure pageName is set in the web service, and handle empty page name in parser function

Change-Id: I5d36eefecc2f35a860d00a8960004f8e651ed17c
Add some checks against undefined tokens returned from async transforms

Change-Id: Ie19537083b96b1b2e12e1c4b65a7a044753c18ac
Fix an external link regression, and add server shell wrapper and setup docs

Change-Id: I9a4f7690e98313d003a2fec35324ed70556e6461
Basic parser / serializer web service

* After installing Parsoid (sudo npm install -g in modules/parser), run 'node
  server.js' from the api directory and navigate to http://localhost:8000/ and
  follow the directions. You can start to navigate the English wikipedia at
  http://localhost:8000/Main_Page, or manually enter wikitext or HTML DOM to
  convert.
* Uses the express framework, could also use just connect
* Uses the cluster module to manage workers per-core and restart those on
  failure

Change-Id: I443f2996ed3df00826b038b7476a2f966ab0c425
No end delimiter after template row attributes

Change-Id: Iba304fb797d221e2d65ae055d266bff2f6301df8
Link round-tripping and other improvements

* Changed RDFa for links according to
  http://www.mediawiki.org/wiki/Parsoid/RDFa_vocabulary
* Added basic support for internal/external link serialization
* Moved numbering of external links from tokenizer to LinkHandler
* Added round-tripping for generic HTML tags
* Replaced nowiki tag with <meta typeOf="mw:tag" content="nowiki"> and <meta
  typeOf="mw:tag" content="/nowiki"> for now.
* 154 round-trip tests passing (node parserTests.js --roundtrip).

Change-Id: I16c4db21b1b543ee57c73e569c83025b64664542
Restructured static node rules

Change-Id: I7023e1f334694d59767491f1010e7c4c59c0ce54
Cleanup Sanxbox.js

Change-Id: Id8ba1aacecdbb5d31888e289d23ab03a16346c60
Prepare for MediaWiki integration
Create context instance in surface.
Move over getSelectionRect into ce.surface
Cleanup ve.surface contstructor class
Move linmod/html test objects to sandbox.js

Change-Id: I0cf602ef991100bf6128c68750b02a00566911dc
Include jquery.json.js in both demos to fix error

Change-Id: Ic5810536317e6de8a23232b602aced877412b1ea
Copy ui modules to ve2
Switch sandbox demo to use new ui modules
Update VisualEditor.php to use ve2 modules
SpecialPageSandbox working

Change-Id: I8261d6bf6ceb6ae7b7bfa5f61aec6a0121906765
Added annotation and attribute tests for transaction constructors

Change-Id: I61e5f37b1f866afc4a3b9a18cd6e7e7a08e0958f
Fixed case on mapping to $.toJSON

* Also made uses of JSON.stringify use ve.getHash

Change-Id: I05dc0374e05b72c798ae0fd44239e5f8bb45ca52
Modify getAnnotationsFromOffset to account for annotated leaf nodes.
Refactor remaining annotation methods
Refactor tests to use correct annotation types

Change-Id: Ia3ce42b3d11296b4d63277e0e2a1997d23236613
Merge branch 'master' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite
Merge "Round-trip nowiki"
Merge "Serializer and table round-tripping improvements"
Merge "Add .gitignore"
Round-trip nowiki

Change-Id: I5f7e6a43f5fdc1708ee710b2a601b20db733452c
Serializer and table round-tripping improvements

* added stx: 'html' round-trip information for html tags
* added t_stx: 'row' info for row-wise table wiki syntax, and support for it
  in the serializer
* the first table row is implicit in wikitext
* renamed lastToken to prevToken in serializer
* strip first newline in an initial chunkCB

Change-Id: I014b046539d1b674d830551c5fd1b74a67f81993
Merge "Support table captions and properly delimit the end of table options"
Add .gitignore

Change-Id: I48c8b2939ef7c749a9b0a718f77e58238c01889e
Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite
Making showCursor work again!

Change-Id: I97e1570ffba368e570b69085daa2798b8b2725f9
remove hasChildren method as I was using it to debug something on
previous commit.  change traverseLeafNode test name to follow
ve2 test naming scheme

Change-Id: I8b953e3405f42cd58a80da676ac9b16d64f5e72d
Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite
ported traverseLeafNodes and tests to new dm

Change-Id: I98487267d6e3efc9e0c07a02b3d5acc8f8cdb4c6
Disable objectResizing and inlineTableEditing within execCommand

Change-Id: I06406bfd56e01e72b157fd8cb50da8d6173edc25
Logic for adding 'slugs' before, after and between nodes in certain cases

Change-Id: I91a1c58bdb7819503a9eb24221d6a358c804b57e
Support table captions and properly delimit the end of table options

Change-Id: I15eb8df19528cfceadfee368370501b30f0e36a0
Use outerHTML to serialize unhandled DOM node in serializer

Change-Id: I37350712c9450c34025740a8d6de51344739c2b7
Fix first bug caught by new roundtrip mode for parserTests

Change-Id: Id152fd29606d8ee34ac300945f41e2a5f48f087f
Merge "First pass updating parserTests to verify dom->wikitext serialization."
First pass updating parserTests to verify dom->wikitext serialization.

- Just a quick first pass updating the parserTests.js script so we can
  test DOM -> wikitext serialization (but which in effect really tests
  roundtripping).
- There is no output normalization yet which is needed for now since we
  are not yet preserving white-space.

Change-Id: Ie52058e0dc3330f852c24fa05641dced19f950e0
Added newFromAttributeChange and newFromAnnotation

Change-Id: I1e85ccee3fa1591867fea52359508bfa99bad7df
Made tests a bit stricter before iterating over annotations

Change-Id: I7c7f11395cfb4ad392bad9380119b647c0c1b629
Refactored getMatchingAnnotations and it's tests, and added offsetContainsMatchingAnnotations

Change-Id: I9098ef8d9c7f3a4f5db112cfdcb9edb7ffd17b80
oops

Change-Id: I485e6f51c4184c557187f1ef104adc11c3ba3950
New demo for cursor placement

Change-Id: I7740e6e0dfc7ddda8b7062bfcac3900811e8653b
Fix getAnnotatedRange to return propper contained range.
Fixed tests

Change-Id: I305eb81644fb3c804455b4fc13bdabcce97ea471
Whitespace fixes and removed some console.log statements

Change-Id: Ifcf8a496fb4b649cbf3ce07290b8f6dda60f179d
Whitespace fixes

Change-Id: I691c4e16cf22de8dce0858cdcad522d1f6cfef72
Merged ve.dm.DocumentFragment and ve.dm.Document

* Also fixed lots of whitespace issues and some global variable introductions

Change-Id: Ia6c82ef0c3b5c4938cf72afa86da6d79e4cb385a
Added skeletons for transaction builders

Change-Id: Iabb2707d20c8b645ffef683f9d8160911c6dc92f
Rewrite getMatchingAnnotations to return a hashmap of matching anntations
in the new DM.  Change method name getAnnotationRange from offset to
getAnnotatedRangeFromOffset.  Write tests

Change-Id: I7028803065409e271ceced73e4803954d4a956dc
Renamed items to itemCount for better code readability.

Change-Id: I53851c07a4746928fddec4b3737136f081d49178
Track list prefixes in the list start handler and use them to output
serialized text in list item handlers.

Change-Id: Ic7562d531d2313bedcf3b7450b4f28f02bc2b5a3
Strip RDFa attributes in parserTests

We are adding some extra information in those, which should not make tests
fail.

Change-Id: I42cca596330252efeff5d51508f97ef1c566475b
Start to handle links

Change-Id: I1fb975910651820fd889d77152562fd4fbcb5db8
Use single _serializeToken handler for both DOM and tokens

Change-Id: I45e1d90b53a5ddc678f7744f27274bebcfc375fe
Simplistic wikitext round-tripping with parse.js --wikitext

Lists are a bit tricky, as nested lists are not wrapped in a separate list
item. Should work now though.

Change-Id: I2e5f29f6afa6bdd2d5e5c0c5d019b70c611b73d1
Whitespace fixes and cleanup

Change-Id: Id2220009ed7af7e895990dd4bb373b43d6089b7b
Remove getScope(), no longer used

Change-Id: I79e067a8e6b3eb151d3ebe1dfc3aaebe242aed39
Rethink of structural replacement code

Splits and merges now work, or at least the tests for it pass

The strategy I used is to gather the affected ranges for each of the
following:
* removed stuff
* the entirety of each node touched by a non-zero removal
* if the inserted data busts out of its parent, the entirety of that
  parent node (the 'scope')
then get the covering range of all those ranges, and rebuild that.

Change-Id: I7c3b421abc0ba134157ac8b59042675bb1b5073c
Add ve.Range.coveringRange()

Change-Id: Ifd9932d7a9f9dae2354fa7aa75cee2e3e639ef42
Rename removeLevel to insertLevel

Change-Id: I339c830547d19af0b04927e1ebccd0468c9e2a20
Rewrite data model methods needed for ui tools
getAnnotationRangeFromOffset and offsetContainsAnnotation
which deprecated getAnnotationBoundaries, and getIndexOfAnnotation
write unit tests for proof

Change-Id: I6c0d4e3ca96dd569b1909cd22fce68c3a6fe382c
Don't eat newline tokens in the ListHandler

This fix only affects following transforms, of which there are few right now.
Also removed a stray token mutation in QuoteTransformer.

Change-Id: Id6d4adce944b06fc1a3651cfbf63fc2670125225
Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite
Another test for HTMLConverter

Change-Id: I9b0fa2de44381b363fb6e612884f9911996e941b
Added merge test for ve.dm.TransactionProcessor

Also added 2 paragraphs at the end of the example document and updated related tests accordingly

Change-Id: Idd294cbe3975d0a04069e55682a91417160e538a
Compositionstart added into the mix to catch IME and Alt+0135 style key combinations

Change-Id: I5e4c3c69d139f3d4d86cb2429b8a6e4ebf98010c
Removed html5 parser patch no longer needed with 0.3.8

Change-Id: Id8c23d34e8cca49a360f536e792144a85a8468a3
Switching from parentElement to parentNode for IE support

Change-Id: I46dbac1201450af6ba24eab55d3134683ac04036
New playground demo for testing hijackability of keypresses  when there is a selection

Change-Id: I63e067ca921491286f18b15c593c3e265946dfa8
Add a new wikitext serializer, with limited functionality.

This isn't finished at all, but Gabriel wants to take a crack at it,
so here it is!

Change-Id: I9732aa141f7c69a28c8f5978cb18180e93cb9eda
Greatly simplified selection and node tree comparison tests

By first summarizing a node tree or node selection and then using the normal deepEqual function we are able to take advantage of native QUnit functionality to make diagnosing a problem easier under failing conditions and reduce the verbosity of the output under passing conditions.

Change-Id: I4af5d69596cf5459aa32f61ee6d5b8355233c3df
Add comment about bug that makes tests accidentally pass

Change-Id: I842ffe00bdad025797f9c71f550efd24d2ce39da
Improve verbosity of selectNodes test descriptions

* Make nodeSelectionEqual() accept a desc parameter and use it for
  building descriptions
* Put the array element number in the desciption too
* Add descriptions for selectNodes tests and pass them through

Change-Id: Icd2894d11516234598cbd984cc8d88f705bfc1d6
Improvements to nodeTreeEqual():

* Don't crash if b.children has a different length than expected
* Don't crash if b.children is absent but expected
* Check if b.children is present when it's not expected
* Add assertion when neither a.children not b.children are present; this
  makes the number of assertions for leaves equal to the number of
  assertions for branches
* Check attributes too
* Accept a desc parameter, and add node paths (like
  list/listItem/paragraph/text) to the descriptions
* Use desc parameter for all calls (some tests were already using it,
  even though it didn't actually exist)

Change-Id: Ic56d27d20377e7f4fdfa038fdf4ebe00dcb3e062
Added a replace test that splits elements

Change-Id: Ifb9c42c36611b2b936a48b911e9786e2105da09c
Support splitting nodes in replace tree sync

This means inserting things like </p><p> are now synced correctly and
split the paragraph in the model tree. Merges (removing e.g. </p><p>)
aren't supported yet.

Also, this needs tests, Trevor tells me he's working on porting replace
tests from the old ve/ directory

Change-Id: Ic5050849d7d007a1696dc36548654979aedb53a8
Fix bug causing replacement tree sync to adjust the wrong node

The tree sync for content replacements was adjusting the parent of the
text node affected, rather than the text node itself. This was because
it called getNodeFromOffset(), which returns branch nodes. Switched it
to use selectNodes() in leaves mode

Change-Id: I50a9be18151a1b75815ab19b787b16b6be385bf9
Fix bug in selectNodes: input (0,0) returned []

This was because the while loop was never entered as end >= left was
true from the start. Convert the while loop to a do-while loop to make
sure it runs at least once

Change-Id: I9c6436a7b296e65a36b8301095b6edd00507d321
New playground test for inspectors in iframes

Change-Id: I5f0aeb01da789030117028ff4cb014f4c07fab8d
Rename some tests

Change-Id: Ie0c50023a17fead64eb28e6184f70a32b626eaff
Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite
Fixes typo, need to check if object is empty, not if it's an object

Related to: 14a4c7b780601cc59257c50ae4734144390db7dc

Change-Id: Iede66d1e01ed010705362611e90fb4b13e7e4a1c
Add tests for getAnnotationsFromRange

Change-Id: I51aebb54d3d65c3160ac48e9ee971183fb3885bb
Fixed annotation processing to support leaf nodes and detect more errors

Also added lots of tests

Change-Id: I45fe4fb569d9050d7d79f71f777d82f5b34fdd11
Removed more trailing whitespace in multi-line comment blocks

Continues cleanup work done in e0de881a8a102155f8e4b0a1e5226e7adaeba80f

Change-Id: I7165a8f8c4b468793d936fe695de92335c106271
give array bulider loop better names

Change-Id: I67f5b89b3e58f052c197732a1298c60ec6b8fd89
Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite
Optimize getAnnotationsFrom dramatically by less object manipulation
Now returning an empty array when a non annotated character is found
in the range.  No longer looping through each annotation, simply
comparing to previous characters annotations and trimming differences.
Write additional test.

Change-Id: I41d2422a931a74325693edca409aed6d5da20ba8
Fix botched rename: opReplacement -> opInsert

Change-Id: I34091dbbc9a46466823ee7407f151fd67112ee03
Removed trailing whitespace in multi-line comment blocks

JSHint and various git tools complain about this, so let's just do away with them altogether

Change-Id: I731866bd21f1ee0088fb0a71df3abf92692aca23
Added transparent 1px image to make unit tests not show HTTP errors

Change-Id: I800e98ae6c47121ec652c34bd678e54e7efcb77c
Removed debugger statement from 5b9a2645a6180223cc88d24df6076f74244b1e09

Change-Id: I047b0c89a7420a86b9350a8d0c0fc8aec695227f
Refactored ve.dm.TransactionProcessor tests to use data-providers

Change-Id: I0535f3ac56b6037712d731c71fc68c56ae7ea614
Localisation updates from http://translatewiki.net.

Change-Id: Ia63ca00e00816c1cd807532fc4589738f7a0be7b
Optimize getAnnotationsFromOffset with ve.getObjectValues

Change-Id: I2150335b6f0fa305c1d1bc93e50d30d874c76345
Added ve.getObjectValues

Could maybe be optimized with map or something?

Change-Id: I033804e893bfa93f991dee9efefaa2c2d1740627
Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite
Added ve.getObjectKeys which falls back to Object.keys if present

Change-Id: I9eedf93239b22497fe6fe6497e20b1fe0525de9c
Rewrite getAnnotationsFromOffset to work with new Linear Model.
Properly init variables in getAnnotationsFromRange
Polish up tests.

Change-Id: Idc231998ce27e3a1c64363e862da22c837ea2ca2
use proper assertion in getAnnotationsFromOffset

Change-Id: I41b5cfa3628d5a2ed6d3f59d157ebe372585059c
Rewrote tests for ve.dm.Transaction to use a data provider

Change-Id: I7ecf09c627b96b4c84824152bd178fb36c1ce348
Fix up wrapping on getAnnotationsFromRange test

Change-Id: I793cd33b88f7c7f3a17d6fbfb80218438aa878af
Rewrite DocumentFragment getAnnotationsFromRange method
Write unit tests for getAnnotationsFromRange

Change-Id: I82ff15e97378c07e5c555a72231da4161a72993c
Port getScope() from the old VE code and add tests for it

Change-Id: I8c34fed919e60fa1b8cb6a13cb9ca98f3e695421
Remove outdated comment

Change-Id: I3a5db50aafa01d07bfb34359dfbe73812b3a7ab5
Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite
Adding a little test that reports range info with alien nodes

Change-Id: I89be397431767100cc6749c284edeef1a80a4e8e
Renamed uses of "replacement" to "insert"

Change-Id: I69ad0f84e8fefe1715339068b7685958f8f8546f
Removing data from annotations when empty, more tests for HTMLConverter

Change-Id: I3c3e234e9392e4afdcb4c8bc748aaa74a1fb30ca
Added tests to getRelativeContentOffset

Also fixed a typo in the implementation

Change-Id: I86855795009e34d42a3a5857addc5ccb6366130f
Whitespace changes

Change-Id: I9ae27bee1207282d0f07d9a05584628cb8061683
Remove broken test, need to refactor

Change-Id: I7963454032eceec73cf5a5d71f4d3a173627bfc3
Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite
Write better test for DocumentFragment getAnnotationsFromOffset
Fix errors in example test data
Remove whitespace

Change-Id: Ibb2b5c0851d6abac9974035753b95354b3c8dd5e
Port structural replace code from the old VE code

This makes TransactionProcessor work for regular replacements, as well
as insertions and deletions of self-contained pieces of data. This does
NOT yet work for inserting and deleting unbalanced data
(splitting/merging nodes).

I've tested this from the console for insertions and deletions and
simple replacements, but I haven't tested wrappings. We should write a
bunch of unit tests for this some time :)

Change-Id: Ic2fd75d1cf2e127bc9ae58debce67576be2c912f
Use index and indexFromNode (from selectNodes()) in DocumentSynchronizer

This makes insertions work (using indexFromNode), and eliminates the
indexOf() call (using index)

Change-Id: Ibfa77353af99534edc324c0e314c8b95c5136d8b
Add indexInNode to selectNodes() output

This is for the case where we have a zero-length range in between two
siblings, and we need to know what index that corresponds to in order to
be able to insert nodes there (rebuildNodes() will use it for this
purpose)

Change-Id: I357d1cd665667a76f955a10b8d9d2810976cdbd7
selectNodes() fixes:

* Initialize startOffset to 0 not 1, don't know what I was thinking
* Use currentFrame for nodeRange instead of parentFrame, don't know what
  I was thinking there either
* If the returned node has no parent (is the document node), don't
  attempt to access parentFrame and don't set index

Change-Id: Iad969a7c29436cdf4151ead7e9d3d8e2a30befb3
Throw an exception when DocumentFragment gets unbalanced input

Change-Id: Ie891bd7ea4d9e9b1c84e7a0390f1af39c0e55fd4
Ported isContentOffset, isStructuralOffset, isElementData, containsElementData and getRelativeContentOffset

Tests for all but getRelativeContentOffset are done too

Change-Id: Iee953647ec89e13259ae2a402c50c809f93bc655
Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite
Fixing updateDomWrapper test

Change-Id: I93f5ceb96a9212652aa93eeebaf91ad1c5704ae5
Fix nodeSelectionEqual() so it doesn't explode when a and b have unequal lengths

Change-Id: Idb84bc1238576c711a201cdbf05f63a7b603a819
Fix the selectNodes() bug that Inez reported

Selecting a zero-length range at the start or end of a text node
(e.g. (1,1)) would return the text node's parent instead of the text
node

Change-Id: I7fe089bf66b93185dd3415eff53aa7e04e3ffdb2
Document the stack properties used in selectNodes()

Change-Id: Ibaf178830a0b7b99a4ab1c0ec09283bd3dd552e0
Fix startOffset computation in selectNodes()

* Needs to be initialized to 1, not 0
* Needs to be stored *after* left is incremented to account for an
  opening

Change-Id: I7978ae241578a8a17120e494684e6e93626a8529
Fix typo in selectNodes()

Change-Id: I320728bafa289290c4c2a91fee736a8afb17be80
Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite
Basic test for HTMLConverter

Change-Id: Ie3fa3e036b92052305288c64edca8f404afded72
Add 'index' and 'nodeRange' to selectNodes() output

Change-Id: I38712545b713cc24663ebec3fe3e5c8741b4fad7
Fix spelling of 'equivalent'

Change-Id: I0a444059c187ab5608aeca85a85c147ad1d69de6
Removed duplicate node rules from tests

These methods are wrappers for the model methods where the rules are actually being applied

Change-Id: I08be359010fa9fa81cd3a8aa5152083f92dc0b9c
Fixed test so it doesn't break when nodes add classes in their constructors

Change-Id: Ib2f7bcedcf61a9b98da0e3e889f309f271483064
Don't set classes on non-wrapped elements

* Text nodes do not have a wrapper to set classes on
* Use CSS class names that are equivalent to JS class names, swapping . with -

Change-Id: I49c877dd5c9b5dd2a9afad3137f12b14883043a1
Fix fatal error in parse.js

Trying something trivial like echo 'Hello world' | node parse.js
would throw TypeError: Function.prototype.apply: Arguments list has wrong type

Change-Id: Ia0a1154b0f3edbfb1f228a1d2072fced1b147141
Don't eat end token in ListHandler, and lazier Quote handler registration

* Setting the rank on tokens is still used currently, but will be phased out
  in favor of setting it on chunks. Tokens will be immutable to allow sharing
  and caching without a need for cloning.
* Only register for newline and end tokens in QuoteTransformer when active.

Change-Id: I2c45bc7e4a105219a1404ab221eed7f242128f1e
Basic support for Alien node in HTMLDom -> LinMod converter

Change-Id: Ie9b08027c58694022a7b01609d25d720bfb35873
Added missing reference to ve.Document.js

Change-Id: I893442dcb1518c4c05e29fe29aece82ac04fe5c8
Store reference to view node (ve.ce.Node) in jQuery data of it's wrapper

Change-Id: I84920b20346b4ef5e1203d834bf4c3fb9657ae69
Merge branch 'dmrewrite' of ssh://review/mediawiki/extensions/VisualEditor into dmrewrite
Get Alien node (leaftnode) working - it reads its content from attribute
'html'

Change-Id: Idd84da9af61369277df18fee577032de765b1205
Massive refactor of node trees, generalizing lots of previously dm only stuff

Change-Id: I9dbb7094f86338ea2e725ad29f66e9e4ca2b52ed
Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite
Images and tables working with HTMLConverter

Change-Id: I2e45eeddf031d00b006498f9b2fb4840a2f6df44
Added tests for document synchronizer

Change-Id: If114e3fc962598f7ea8f7f8ec8975a3b0d2d83e6
Cleanup/refactor/documentation work for ve.dm.DocumentSynchronizer

Change-Id: I5f70460e0d4496c91d92b83025fdf9ae1d9dece6
Added basic test for ve.dm.DocumentSychronizer

Change-Id: Ieea96aaf0477b4d9ba7e59f5cf6f20f4b867a419
* Ported getAnnotationsFromOffset into DocumentFragment
* Wrote unit test for getAnnotationsFromOffset

Change-Id: Ie88b15ac6c16838b2d2bf9a2d83ca2952f5df817
Fixed naming in test moved from ve.dm.DocumentFragment to ve.dm.Document

Change-Id: I6843e452b0222632d1d244568bd75f3b229b4954
Removed use of expected in conjunction with ve.dm.example.*Equal methods

Change-Id: I48108f3fac7dda32344e105b7c52483cd2a84ef9
Cleanup and renaming

Change-Id: Ie0b742029f95e1475d58bb38b790bae3110259b0
Don't use data.length in selectNodes()

I was using data.length to check if the range was out of bounds, but
this is a problem when using selectNodes() inside of tree sync code
(which happens when performing rebuilds). While tree sync is in
progress, the model tree and the linear model don't match, so we
shouldn't be looking at the linear model for information about the model
tree. Instead, get the length of the DocumentNode and use that.
`

Change-Id: I11a378544ce1281a89cdcd4363c5cb1bf56f3434
Add rebuild action to DocumentSynchronizer

Change-Id: I379ceef3829026c4b4157e59243b7663b6c7ab2f
Emit an 'update' event in addition to an 'annotation' event

Change-Id: Idab673bce4fa4b10816d753020adae40598c8b7a
Make TransactionProcessor actually use DocumentSynchronizer

Change-Id: If0ac69026fa34430d811de5f7ca0748d9b1e01cc
Add a 'siblings' mode to selectNodes(), and add tests for it

Change-Id: Ib3fd3ee5aba7aab7c26193a2a9c48612f624862a
Merge "List markup is created during the sync23 phase."
List markup is created during the sync23 phase.

This makes it possible to transclude list items from a template.

Note: "5 quotes" test is broken by this patch, it appears that ListHandler
newline processing is changing some state which mysteriously affects the
QuoteTransformer.  This is ominous, hopefully there's a simple explanation...

gwicke: fix a bug in tokenizer triggered by definition lists like this:
**; foo : bar

Change-Id: I4e3a86596fe9bffcbfc4bf22895362c3bf742bad
Added some documentation to ve.dm.DocumentSynchronizer constructor

Change-Id: Ib24f0101e60b34af292d46d3ea866859a89a18f5
Cleanup of HTMLConverter

Change-Id: I145bfbbb8b759ea33eef291b53daf935e97ac341
Added more tests for selectNodes

Change-Id: Ibd9672fb9b6ce682905d20f9346fada6fb47b380
Fix bugs in selectNodes(), tests pass now

Also fix one instance of bad expected data in a selectNodes test

Change-Id: Ie226b237cf537143bce2f6b1e531b9067b140cb4
Change 'leaf' to 'leaves' and document it

Change-Id: I09d5995d3d9bf82670802f0efe849f40be2a18a3
Fix rebuildNodes tests, were messing up ve.dm.example

Fixed by operating on a copy of the data instead

Change-Id: Ia2607d94f07b8d43e8c98ae8a94c34df90081508
Added additional test to rebuildNodes, now testing rebuilding after a change

Change-Id: I669457389bf742c100dec5205b972f6d1e14ef44
Simplified selectNode tests

Change-Id: I878fd430b24661fc11c953b3303e395cdd617006
Added another falling selectNodes test

Change-Id: I1f18b0af956c98a5facaf12a88fd94ca76e50a65
Changed selectNodes test to desired behavior (which fails atm)

Change-Id: I79eb5caaa3e2193e2309d37dc1d0ca67c2602836
Added documentation and tests for ve.dm.Document.selectNodes

Also:
* Broke node lookup method out into ve.dm.example.lookupNode
* Added ve.dm.example.nodeSelectionEqual

Change-Id: I437cdd3f3154d10782f03f78df6d5c457ecfc845
Add two more cats to demo/example article

Change-Id: I25757965ffdfceed2c85c9d76ce58af3d23716f2
First implementation of selectNodes()

Currently only implements mode=='leaves', i.e. traverse all leaf nodes.
Seems to work from casual testing, but is missing unit tests. See also
other TODO comments in this commit

Change-Id: I41292c21c627a18af7985e8ef9e23c7b14252b21
Whitespace and syntax fixes

Change-Id: I5a553272c1faf1e83a5e8be8ecf7911a11ec27a8
Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite
Add an isWrapped property and make getOuterLength use it

This gets rid of the length == outerLength-2 hack in getDataFromNode()
and will make it easier to implement similar logic in selectNodes()

Change-Id: I1294350b67ca3eefde2b7fe9fea0bc6d8b90f772
Line-length fixes

Change-Id: I5258ad2e550313a95ae5b7bba951992db2db966c
Localisation updates from http://translatewiki.net.

Change-Id: Id437c4a45e8bd39d12f0865e1c37553ed8b896b7
Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite
Support for new annotation format

Change-Id: Ib873981792d2cb4d78a3e4805287c48b3de78558
Added canHaveChildren and canHaveGrandchildren to all nodes

Change-Id: Ibe53292f7269736750e03da49e5bb5913c0124ab
Fixes for Roan's crazy half-baked commit

Change-Id: Ic104debc3a941e4cf8e4dca19633dcad04a0fe0a
Added attribute add and remove tests and cleaned some things up

Change-Id: If339e0b59a8cdd90a151128138cec85b902681a8
Removed unused attributes in example data

Change-Id: I0ce52456113e6efc5d879041270e06fd0b6bdebe
Adding HTML DOM -> Linear Model converter

Change-Id: Iae109d75e64321a7fe4ee8492d79ef5481716246
Queue and deduplicate events in DocumentSynchronizer

Change-Id: I90577cd078c3d0b6706f5f827b66b46a450e7086
- Optimize surface model and write unit tests

Change-Id: I8de24c840c5aa2d4232e6e2cc5f72cbd30be96b4
Merge branch 'dmrewrite' of ssh://review/mediawiki/extensions/VisualEditor into dmrewrite
Fix method getDocument in dm.Surface and start using it

Change-Id: I613b1e938cd0d8f3a6ac8a48121901287c8fc5af
Initial stab at DocumentSynchronizer

Change-Id: I7176fd7235a82a6314bf431d00870d9ddb40f370
Refactored dom wrapper functionality in ce nodes

* Moved implementation of getting and updating a DOM wrapper to ve.ce.BranchNode
* Updated ve.ce.BranchNode tests
* Renamed ve.NodeFactory.createNode to ve.NodeFactory.create
* Added  ve.NodeFactory.lookup which gets the constructor of a type
* Added attribute pass-through to ve.dm.BranchNodeStub

Change-Id: I8f5b7d3d3ae616cc5f39828b24b655163d782ae5
Removed bubbling update events in dm and ce node trees and splice events from ce branches

The bubbling update events are not needed with ce or dm, but were once upon a time useful for es, this just eliminates some unused cruft that was costing extra function call overhead.

Change-Id: Ia16d0f4cd74c84cded5caecada33ee83d0882f30
Split Broke DefinitionListNode out of ListNode and DefinitionListItemNode out of ListItemNode

* Makes it simpler in the linear model because we don't have to use style: "item" for regular list items and style: "definition" for definition lists
* Enforces correct nesting through existing node rules systems
* Updates tests accordingly

Change-Id: I64d80af938e325f1961226505bdc386bb35ccdda
Implement basic replace processor

* Implement basic TransactionProcessor.replace(), only does content
  replacements
* Add ve.dm.Document.containsElementData()
* Fix bug in attribute()
* Write basic tests for attribute() and replace()

Change-Id: Ie9c22aec3f2631be5b0bd66790408ad283565491
Improve template / tplarg precedence in tokenizer

Change-Id: If9b24b42ea223e0f30f906a83496d73ec60c4a0d
Use upright option, including the 0.75 default width

Change-Id: Iacdf6173e0ee8f58ca4385fd9b2cde77b2fdf3c4
Removed recursive rendering calls in favor of 100% event driven updates

Change-Id: I636222518e4cbeddb1c02901b79a9dcb09eeb952
Added tests for getModel, getParent, attach and detach on ve.ce.Node

Change-Id: I064b2a13cbfe7a7ebc11af83fb7744ebbad39da1
- fix demo styling for docs list

Change-Id: I5e5d16fe9a002e3cafd01138ad9b92ff987178d6
rename surfaceModel to model in ce.Surface

Change-Id: I5d49915b4645464729ab1e4552982cbd38f712b1
removed margin-top for documentNode

Change-Id: I6e888ca858bc2d9e6772150715b10ab157f84b46
Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite
- extend surface model and surface view with event emitter
- added surface view base methods
- enabled toolbar in ve.Surface

Change-Id: Ib6a62ef2509712f812f262283c45bb30c8f97ef1
Making document contenteditable

Change-Id: If79bb8c69431e07de2a42cc5b565b3093c29c4cd
Added some styles to the demo to add spacing around stuff in the header

Change-Id: Id2e205e9a02dd9b040a40fa4f5ca14891e21d838
Added charset meta tag to demo

Change-Id: I544bdc446262f03bd15790a9cf6d7f9c2f9dcd55
Merge branch 'dmrewrite' of ssh://review/mediawiki/extensions/VisualEditor into dmrewrite

Conflicts:
	modules/ve2/ve.Surface.js

Change-Id: I1c81426203f01fa2f698819bf6c63a3afd1239c9
Get more tags/nodes working in the demo

Change-Id: I5335fbbe15d010a73a06f24bc56ebb3c3c6bd2d7
Fixed mistakes in the linear and tree example models

Change-Id: Id19ac7b2efb5c5f3147a4abf5e62fab3044b5fd7
Move linearModel object into sandbox.js

Change-Id: Ia87e6fb13abab31f14f997f8ba7a9b631f6fb667
Added new node types

Change-Id: I6b5f2e5a7dbdb7c59b4799d44f7924c5594c0e34
Rendering works in very basic version

Change-Id: I8789860fe82f2e7db1e503889e20ce51de57bfa2
Including ve.NodeFactory.js

Change-Id: Iac47ea5486c5c631084d2f0d184ab8c84dfd6696
Updates to script includes in demo index.

Change-Id: I7c8859461c06ebce0d79633d52108d5a2714118a
Merge branch 'dmrewrite' of ssh://review/mediawiki/extensions/VisualEditor into dmrewrite
Missing keyword: new

Change-Id: Id65d30d702e991620e0d454fa000c438f4738b41
Create new instance of dm.Document

Change-Id: I6265079f725e58e55c0e86767aab0911862f5489
- Port surface constructor into dmrewrite.
- Create document model object linear model instead of wikidom

Change-Id: I16307c290ead3e4b29dfbd1b76759e4c19c3fc8b
Added ve.dm.Surface, ve.ce.Surface, ve.ce.Document

Change-Id: I382730e1a9f1abcb4b42499267c8dcaf76fc64e1
Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite
Added tests for getDataFromNode

Change-Id: Ic762832dcdda3bdaf92dbd989659235fdff73596
- write tests for ve.dm.BranchNode setDocument

Change-Id: I7aa2dc0ff5a9b7b7f190da29ac62a5e9c7817dbc
Added tests for getOffsetFromNode

Change-Id: I4dc06e9ea3b634fbd5034df721162098441ea368
Minor fixes to getHtml method in TextNode

Change-Id: I53c873b6e307d53cc87c2e111ab99f694972b17b
Minor fixes to getHtml method in TextNode

Change-Id: I4d0b1a0295071ead413d68945310d3a4ef6fe7e4
Handle upright option properly

Change-Id: I831fcccf874f9a0505e88eb76d269b1d2f68e3e0
Add basic # REDIRECT handling

Change-Id: I71f659201c1d5de4a528ddfac7f65bf20a89f97d
Only specify the width for thumbnails to keep the aspect ratio

Change-Id: I4e55ff719da6cb58f396ad6043e46acaed4a504d
Reduce debugging overhead a bit, and provide default internal image size

Change-Id: I345af8c5905a5fa747f9ed342ba2ba8c1026d044
Forward-port Cite extension

* Adapted Cite extension to use current interfaces and token formats
* Improved TokenCollector

Change-Id: I20419b19edd9bbad2c2abf17a2ff1411b99c0c04
Minot fix

Change-Id: If10f9135f9bf33af17be6f8a2db59433d9898944
Big refactoring to TextNode to make it work with new format of storing
annotations.

Change-Id: If84fcfdd04ff42e9b2449e1c8186d64fec4fb1ac
Merge branch 'dmrewrite' of ssh://review/mediawiki/extensions/VisualEditor into dmrewrite
Very dirty but working version of getHtml method for TextNode (with bunch
of tests that are passing now).

Change-Id: Ie76bd59bc0a5e10e2a3b3e014b2d0e4701fcc368
Removing unused code

Change-Id: I23213531eeef95110d0a3d1e2476449c580b55b7
Removed console.log

Change-Id: I7cd2e1cf5e1cf7a2e9864090cfab391faba10997
Made render for ce leaf nodes abstract and added a test for it

Change-Id: Iee228d5f1a18a5c9618680fa81ab132a85472fa6
Fixed incorrect class name for method typo

Change-Id: I82390896ef7136bfc8ed8734d8bd9014e756af5e
Removed unused method (using factory instead)

Change-Id: I0ed9260d261b7e4c19e5d57f70331aef1a341cdf
Added ve.getHash and ported ve.Json

Change-Id: I4a5d86426902e0473cdb0f98c3d121eed607f93c
Added insertion and removal tests to ve.ce.BranchNode.onSplice

Change-Id: Ic4fc51f3f8f869b03e9ae0fced88c74d2ddf4388
Added removal test for ve.ce.BranchNode.onSplice

Change-Id: I54b622fa05ce02965a2ae48fc78958b6408bca4d
Get rid of range parameter in ve.ce.TextNode.prototype.getHtml as it is
not being used anyway.

Change-Id: I7c54d35001fa0db6d7ab9d12f35ab2d841016f0d
Created a test file for ve.ce.TextNode and fixed some minor issues.

Change-Id: Ifbf6b7ba2a27eedf6d5d4f6cb06b98c38eb52c5b
Moved getOffsetFromNode to ve.dm.BranchNode

* Also updated a call to getOffsetFromNode in ve.dm.Document

Change-Id: Ief8f9e532e39cd1051d7f3b6df6ed341747098e5
Added test for replaceDomWrapper and onSplice in ve.ce.BranchNode

* Also fixed calls to addListenerMethod
* Also routed adding children in the constructor of ve.dm.BranchNode to the splice method
* Renamed types of ve.dm stub nodes to avoid collisions (since we have to register ce nodes by the same names for them to be generated by onSplice)

Change-Id: Ia2e75cf0a62186cc0e214683feb25c619590318a
Added test for whitespacePattern, getDomText and getDomHash in ce

* Also fixed some naming typos in the units under test

Change-Id: I17f753a122f94dd16f7783f60b5c0eb1c6d3e480
Removed global variable introduction

Change-Id: I331b19cafeb20610f7b42bacaff20757a342dffc
Ported getDomText and getDomHtml from ve to ve2

Change-Id: I3547d95c2749543eae745722ceddaa0a969e4e80
Added update handlers to heading, list, list item and image ce nodes

* Also renamed convertDomElement to replaceDomWrapper in ve.ce.BranchNode
* Also added extra documentation for node rules

Change-Id: Ia8ac6be34e2b021be96974ac1ba9119bd8077d60
Made text nodes not rely on a wrapper

By using this.$ as a selection of contiguous top-level nodes (text or otherwise) we can avoid wrapping each text node in a span

Change-Id: I141c2df8f13646db3fff0da93d218c2dcf154c8a
Merge remote-tracking branch 'origin/master' into dmrewrite

Change-Id: I43a3cd999ec0a5d3d05ee1e5bb71c450d485bc01
Consolidated before/after attach/detach events

Change-Id: I4220715ac4505152fb30ac2d5664a0ffb2b846f5
Fix variable name typo

Change-Id: Icfd42a5ee00e14f2485a93a5817f0f7f3e701234
Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite
Lots of ce porting, got text nodes fully supported

* Fixed constructor of ve.ce.BranchNode which was calling the wrong method to perform an onSplice and with the wrong arguments
* Removed/renamed events emitted from ve.ce.BranchNode.onSplice
* Reintroduced .$ to all ce nodes
* Ported over functionality for DOM node type variance used in headings, lists and list items
* Moved the old ve.ce.Content guts to ve.ce.TextNode
* Added getOffsetFromNode and getDataFromNode to ve.dm.DocumentFragment
* Added setDocument and getDocument to dm nodes

Change-Id: I185423ba2f1a858dde562cb2f5bc3852aec930db
Add TransactionProcessor tests, and fix TP to make them pass

* Add .process() and its helpers from ve1
* Fix applyAnnotations()
** Use data[i] rather than data[j]
** Don't add empty annotation objects for no reason
** Remove empty annotation objects
*** I thought this wasn't needed, but it is needed for clean rollbacks
* Remove unused second parameter in applyAnnotations() call

Change-Id: Ia338f62d2eaf2a76f8ef653eead05bc44757a122
Fixed test name to match method name

Change-Id: I06a4e63c5032b74253bcc3a1cd4e36f48d3f424a
Added initial ce nodes

Change-Id: Ibdcb4502a8fdc5b1a6c22ae0e9c42c86b3a7d4dc
Added skeleton tests for ce nodes

Change-Id: I1f5988b31fdef1bf5c5f9266d0bfa8da91d97c3a
Added basic ve.ce nodes

* Also removed beforeSplice and afterSplice in favor of just plain splice which is the same as afterSplice used to be - beforeSplice was never used and it was making things more complex looking than needed

Change-Id: Icbbc57eac73a2a206ba35409ab57b3d1a49ab1a5
Added ve.ce.NodeFactory and tests

Also added tests for initialization of factories at ve.ce.factory and ve.dm.factory

Change-Id: Ic6ac74aab86ecdfd4f094d9bb1fa16de930387b7
Moved canHaveChildren and canHaveGrandchildren back to ve.NodeFactory

This is generally useful information, not only for dm

Change-Id: I9511467285e9594b4a7aa659bf65bb0417da25a1
Added documentation to static rules on ve.dm nodes

They are used by ve.dm.factory so this might make it easier for people to understand what's going on.

Change-Id: I490627e3bfc55ca9c96fdc4f5d047737b6a3db8c
Split node factory into dm specific implementation

* Added support for asking if a given node type can have children or grandchildren and what types of nodes can be it's parent or child
* Removed canHaveChildren methods from leaf and branch nodes and converted use of them to depend on factory to read static rules from constructor lookup by type

Change-Id: I9769f95647066576416bacb791c4b68dd0285b35
Added more canHaveChildren tests

These are needed to make sure the base classes behave correctly, the ones in sub classes are needed to make sure the prototypes of the base class are correctly inherited

Change-Id: I334cc3ce1c4c0ce2eed23c79e8877332a953f7c3
Added getOuterLength tests for text and document nodes

Neither of these nodes have elements around them, so they must override the default behavior of ve.dm.Node

Change-Id: I19c02c210bfc04b6e2ee1a37b8890e84a236eee3
Got rebuildNodes tests working

* Moved node tree assertion to ve.dm.example
* Added rebuildNodes test
* Fixed some typos in rebuildNodes

Change-Id: I4853ded4b062aaa3758435093368bc23667ca3bf
Fixed length calculations and added tests for node tree

Image nodes are leafs, so providing an empty array to their children/length "contents" constructor argument ends up setting the numeric length to [], which casts to an empty string in arithmetic, causing all further calculations to be concatenations instead of additions.

Change-Id: I40e1ea2295f6095318bc4c24185cadfdfb684557
Added getOuterLength override to ve.dm.BranchNode

Also fixed use of getElementLength which should be getOuterLength

Change-Id: I794a4624fca60b3f2e2dde7f8c51db2da526436b
Fixed node tree example

* Indexes for attribute references were off (the comments that were previously wrong before were relied on and cause this to also be wrong)
* Tree should start with a document node

Change-Id: Ia8e4faa4bcb25db797ff97f6e798ba253adfe535
Added comments and tests for canHaveChildren

Change-Id: I0b9538a89cba4c36d1a8af7395476b9612d18637
Fixed numbering in comments in example data

Change-Id: I009f1f32294cce3f154ac3c88e1fa6b2a50a7d1e
Merge branch 'dmrewrite' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor into dmrewrite
Renamed rootNode to documentNode and added tests

Within ve.dm.DocumentFragment it makes more sense to call the root node (which is always a document node) a document node, especially since there may be a different node used as a root.

This commit also adds test for getDocumentNode and getNodeFromOffset which uses the offset map.

Change-Id: Ic4609233cedc41f7e5a5f8fdb0e6178652c95554
Mostly-finished TransactionProcessor

Change-Id: I7d2cd684fafa16c85d0d9c9ad2b6d42d7e6f1448
Get rid of selectionDirection. Introduce getDirection() methdo in
ve.Range.

Change-Id: Iaf11b2dbfb7ae82a7f54ee205cd6cdc8ee235aef
Created a named method inside a Surface (instead of anonymouse one) to
handle logic for rangeChange event handler.

Change-Id: Ief32e647f9399e3ea47c5613902cebcbaaf4874c
Added test for getOffset map

And fixed ve.dm.DocumentFragment constructor to generate a correct offset map which creates references to branch nodes only

Change-Id: If9e515be0c63d272bfed9bf4da625a48edd36f48
Fixed test module name typo

Change-Id: Ie65c26ec27fc8d8a9d792d41b0dd7deffbd59171
Renamed batchedSplice to batchSplice

Change-Id: If7b2b56f9eb79f810461fc49bbdc9aa860461662
Fixes for 44fe109f14ad29abbdd131b951e017bc6f886c52 which mistakingly added .children to a few uses of batchedSplice

Change-Id: I2c876a66b64c6f1ae3cbd1577b7e1102618997ba
Added test data and fixed test suite links

Change-Id: Idb5de70b58c525a67f16b21f7adc53214af9b486
Reduce the need for token cloning slightly

Change-Id: I31c71bddca4855afdffc3fe5c8d759cfa1994d86
Merge "Build out ve.Surface constructor to support  multiple editor instances Now setting up multiple toolbars per config Tools & Modes are now configurable per toolbar per instance Base elements are created on demand and no longer id specific Note: There are some bugs with multiple instances."
Removed "prototype." prefix from test names

Change-Id: I9d8993c95782b700d0b8b45b253a3c4c689381a5
Clone cached tokens, and fix switch for empty needle

Change-Id: I63946e5a56f6fd7dd30d00b12d36032dd1dd0017
Simplify transformToken slightly, and fix JSHint warnings

Change-Id: I95769ed063ea855a9109148f5db83ea43f423e56
Make .to more consistent and add optional parentCB arg

* parentCB (if set) is called with { async: true } if expansion is going to be
  asynchronous.
* Strings are handled efficiently
* all value parameter chunks can now be converted using .to().

Change-Id: Ib013e1bc3d8e7f692009038209db6a056887326e
Add .to('text/plain/expanded', cb) support and convert ifeq to use it

Change-Id: I99c78de12fed41ba36811402f7ecacb420391d70
Accept wikilink parameters with dangling equal ('|arg=|')

Change-Id: Ib4f6d186da2a74522b17c377dac5c9a7de7e5861
Disable preformatted text from indents in template args

Change-Id: I84144d3fab6541ed264d9b092806c8bf9de6e8b2
First go at ve.dm.Document and ve.dm.DocumentFragment

Change-Id: I6099ec0dbdac8d00cdde138b6b9a1b3a5781daea
Introduce new method called "proxy" in surfaceView to avoid using the same
construct with anonynous function over and over.

Change-Id: I1e96cf1efaa6fa5d551fdfa8bb5a80c31e519579
Build out ve.Surface constructor to support  multiple editor instances
Now setting up multiple toolbars per config
Tools & Modes are now configurable per toolbar per instance
Base elements are created on demand and no longer id specific
Note: There are some bugs with multiple instances.

Change-Id: Id0bbbca2d1b76fd2db3f3b0f9abd90194930b610
Fixes for the template fetch retry feature

Change-Id: Id36cb02c535d07f4f2cdd54ae682b6a144a2faa9
Fix --wikidom and --linearmodel parse.js options; retry on template fetch failures

Change-Id: I444397936fd87971fe085df4b467089367e9ffa6
'Obama finally expands' ;) Misc fixes and documentation updates

* [[:en:Barack Obama]] can now be expanded in 77 seconds using 330MB RAM,
  while it would prevously run out of RAM after ~30 minutes. Wohoooo!
  The token transform framework rework really paid off.
* 303 parser tests are passing in the new record time of 5.5 seconds. Two more
  tests are passing since these tests expect the day of the week to be
  Thursday.  Won't be the case tomorrow.

Change-Id: I56e850838476b546df10c6a239c8c9e29a1a3136
Rename text/wiki and tokens/wiki to text/x-mediawiki and similar

Change-Id: I70113629f4633685cd6db3914303a15e4c79a50a
Remove dead parser pipeline code

Change-Id: I802f1798d5163c1ce82d648f739c2e79b17eda41
Merge "Biggish token transform system refactoring"
Merge "Fix typo"
Biggish token transform system refactoring

* All parser pipelines including tokenizer and DOM stuff are now constructed
  from a 'recipe' data structure in a ParserPipelineFactory.

* All sub-pipelines of these can now be cached

* Event registrations to a pipeline are directly forwarded to the last
  pipeline member to save relatively expensive event forwarding.

* Some APIs for on-demand expansion / format conversion of parameters from
  parser functions are added:

  param.to('tokens/expanded', cb)
  param.to('text/wiki', cb) (this does not work yet)

  All parameters are additionally wrapped into a Param object that provides
  method for positional parameter naming (.named() or conversion to a dict
  (.dict()).

* The async token transform manager is now separated from a frame object, with
  the frame holding arguments, an on-demand expansion method and loop checks.

* Only keys of template parameters are now expanded. Parser functions or
  template arguments trigger an expansion on-demand. This (unsurprisingly)
  makes a big performance difference with typical switch-heavy template
  systems.

* Return values from async transforms are no longer used in favor of plain
  callbacks. This saves the complication of having to maintain two code paths.
  A trick in transformTokens still avoids the construction of unneeded
  TokenAccumulators.

* The results of template expansions are no longer buffered.

* 301 parser tests are passing

Known issues:

* Cosmetic cleanup remains to do
* Some parser functions do not support async expansions yet, and need to be
  modified.

Change-Id: I1a7690baffbe8141cadf67270904a1b2e1df879a
Merge "Add --wikidom flag to parse.js"
Add --wikidom flag to parse.js

Also remove unused import of DOMConverter

Change-Id: I1eabe6bf9935970c1f049681b52e867a510ea77a
Implement ve.NodeFactory and add tests

Change-Id: I34fdf24c0099072fe5f7178400abbc323be975d4
Don't instantiate classes in ve.extendClass(), it's unnecessary

Change-Id: Iebb9c871750a19a806ebdd911e1ef476a0acaddc
Rename ve.dm.NodeFactory to ve.NodeFactory

Change-Id: Ic2a0389ca4855ac1afc3fb9a151145fea2b4795e
Add a note that I need to implement insert and remove as replace

Change-Id: Id076921707bf6295a6bbac3264fa0074178e9321
Added more nodes and removed canHave[Grandc|C]hildren methods

Replacing them with static members on each node type

Change-Id: I455debf880bef4e280eea072364f5f57308ec2b1
Merge "Modify rangeChange event to save selection direction. Renamed Selection method to more suitable name. Misc cleanup Patchset 2, whitespace cleanup Patchset 3: Change values used with selection direction to -1 or 1 1 for left to right (normal) -1 for right to left (opposite) Change-Id: If9ecc721ace1c7550903170f92395947f1ccc22c"
Modify rangeChange event to save selection direction.
Renamed Selection method to more suitable name.
Misc cleanup
Patchset 2, whitespace cleanup
Patchset 3: Change values used with selection direction to -1 or 1
1 for left to right (normal)
-1 for right to left (opposite)
Change-Id: If9ecc721ace1c7550903170f92395947f1ccc22c
Merge "Put a space in the toolbarDropdownTool-label div for default Addresses dropdown tool ui inconsistency on load"
Added skeleton class for ve.dm.NodeFactory

Roan will finish the rest

Change-Id: I8da5c493b13f00ca9abdc94ef20e0d2923893d28
Update lengthDifference in ve.dm.Transaction.pushReplace()

This makes the tests pass

Change-Id: Iede7f47183378d80419f616ff62732a07d136d87
Add tests for ve.dm.Transaction

These are currently broken because pushReplace() doesn't update the
lengthDifference

Change-Id: If0b611b7228c54ed15551514e773865be343e63a
Remove documentation for nonexistent parameter

Change-Id: I3237eca92d5962a415c596da84cd3f51d3d8cebb
Remove the parameter from the ve.dm.Transaction constructor

It's not being used at all, and it's broken because
this.lengthDifference is set to zero regardless of what length
difference the operations passed into the constructor might cause

Change-Id: I3b7a312a1920347e7bf34df88a05bf6f2ff11f7d
Copy ve.dm.Transaction.js from modules/ve

Change-Id: I629376bfa935ff120d93d8cfc020884524a0ae2f
Added tests for all exceptions

We are now checking for the exception messages as well.

Change-Id: I3a306ce9fe82afe6fd1e46a2e4da4d0a70952688
Improved test coverage for ve.dm.BranchNode.splice and ve.dm.TwigNode.splice

* Changed splice to check all elements about to be inserted are allowed before inserting any of them so that catching an exception leaves you in a sane state
* Fixed the order of execution of parent class constructors in ve.dm.LeafNode and ve.dm.TwigNode so that canHaveChildren and canHaveGrandchildren produce correct values and added tests to ensure these methods are correctly inherited in subclasses
* Added tests that check for exceptions when adding nodes that can have children to nodes that can not have grandchildren
* Added test that check for events being emitted before and after splicing, including that beforeSplice should be emitted even in cases where a splice fails and throws an exception because the nodes are incompatible (but afterSplice is not called in this case) since beforeSplice might modify the nodes in some way before the compatibility tests are run

Change-Id: Id12aea995a42c26ff63a74ae3d31f2bf455759e3
A few fix ups for fd49e8d

* Moved getParent and getRoot from ve.dm.Node back to ve.Node
* Fixed use of getElementLength that should have been changed to getOuterLength, but was changed to getLength (oops)

Change-Id: Ibe5b855aef533dcd493f762a8a02c6a11ce6e7de
Added more tests for ve.*Node and ve.dm.*Node classes

In this commit several methods (child node add/remove and parent/root modification) were also moved to ve.dm.BranchNode ve.dm.Node respectively. ve.Node and ve.BranchNode are immutable. ve.dm.Node and ve.dm.BranchNode are mutable. Other subclasses of ve.Node and ve.BranchNode should implement functionality to mimic changes made to a data model.

Change-Id: Ia9ff78764f8f50f99fc8f9f9593657c0a0bf287e
Put a space in the toolbarDropdownTool-label div for default
Addresses dropdown tool ui inconsistency on load

Change-Id: I855ac15e939fa895adb67daaeb45aadbac01f10b
Modify VE constructor to have the default set of tool configuration
Configuration options are to extend base options in the constructor.

Change-Id: Ic430a6489d8cf9a703e374c3f416feaf0e3d2521
Added some basic coverage for ve.*Node classes

* prototype.canHaveChildren
* prototype.canHaveGrandchildren
* prototype.getType
* prototype.getParent
* prototype.getRoot
* prototype.setRoot
* prototype.attach
* prototype.detach

Change-Id: I920f7c9504e467f4818df537608760165c28d432
Setup tests, which are still empty

Had to fix a few namespace typos too

Change-Id: I3ebdc418f374bd3e151c516e1c0cfe85398772f0
Initial commit of data model rewrite

Ground-up rewrite of the data model. Putting this in the ve2 directory for now so we still have the old code floating around.

Main changes so far in this rewrite:
* Renamed hasChildren() to canHaveChildren()
* Added canHaveGrandchildren()
* Added a new node type TwigNode that can have children but not grandchildren (so all of its children must be LeafNodes)
* Implemented push/pop/shift/unshift as wrappers around splice()
* Renamed getElementType() to getType(). Nodes now take a string as a type, and the element stuff is gone and won't be back
* Removed clearRoot(), replaced it with setRoot( this ) where needed

Change-Id: I23f3bb1b4a2473575e5446e87fdf17af107bacf6
Delay some token duplication until actual mutation happens

This is a bit better than cloning tokens wholesale, but not by much. There is
a lot of potential for much better per-token caching with reduced token
cloning. Need to map out all dependencies besides token attributes expanded
from template parameters or other scoped state. Even if tokens themselves
don't need transformation, they might still need to be considered for other
token transformers, so simply keeping the final rank won't quite work even if
the token itself is fully transformed. As a minimum, a shallow clone would
need to be made and the rank reset (as in env.cloneTokens).

Change-Id: I4329113bb21750bae9a635229ed1b08da75dc614
Add tokenizer cache and clone token state on mutation

* Added an LRU cache (using the lru-cache node module) for tokenizer output
* Mutation of nested attributes now replaces the containers. A shallow copy of
  tokens is sufficient to isolate token transformations. Need to investigate
  if we can actually get away without isolation and re-transformation for most
  ordinary tokens.

Change-Id: I9136b1d7a1fbcc538183a319d4ecaa290d616fdf
Merge "Removed line-height from preview panel"
Merge "Improved the appearance of the warning at the top of the editor"
More tweaks: safesubst and image options

* Ignore safesubst for now
* Remove an unneeded whitelist entry
* Make sure the caption is not lost for thumbs (fix to last commit) and remove
  debug print

Change-Id: I243584ed0838cf7c3b4110fe9cdf869272477312
Improve image option handling

Change-Id: If1376766f41ff1288bfe2af19beecd3299c09a01
Add ve2 directory for rewriting code in

Change-Id: Id71ba248c73baa05e5fbeb8ad91f9225c1d1f412
Fix typo

Function was renamed but error message wasn't updated

Change-Id: I61a9effa8dedcbdbc75c5c6842fb05f909561327
Don't work around html5 library tokenizer attribute reordering

The HTML5 parser we are using to normalize expected HTML output in parserTests
reverses the order of attributes (see
https://github.com/aredridel/html5/pull/53 for the fix). Remove whitelist
entries concerned with this and use the proper order in external image
attributes.

Change-Id: If1868cae05396a150757c85a20473ab756cbcd97
Collected tweaks

* less verbose logging in noinclude processing and template expansion
* Give priority to the processing of templates transcluded from transclusions
  to get closer to depth-first processing. This serves to minimize memory
  usage from queued-up tokens.
* Increase the maximum outstanding requests per template retrieval. 10000
  amazingly proved too low a limit on some big pages.
* Only process a single template request callback at a time for now
* Add a debug print in the treebuilder wrapper
* Don't treat multiple comments on a single line as a single comment to match
  the PHP parser's behavior

Change-Id: I9a86b6d7bec3b9e1f17415daf1bf74170240721a
Small tweak in comment about onlyinclude forcing buffered expansion

Change-Id: Ib324e24c51c97e07e6737bf23f16db07043b69ab
Disallow &lt; and &gt; in external link urls

Change-Id: Id865c3d46b33b182bb5b244e77e815c0afd7fa49
Implement urlencode parser function

Change-Id: I4fca3134c9c3eb9a7d6f3360be6de054fb47477c
Match the empty string as whitespace too

Change-Id: I1a8ed882021804f62855b9db4368270feebbfc16
Merge "Add and update an offset map in DocumentNode"
Add and update an offset map in DocumentNode

This has some TODOs still but I want to land it now anyway, and fix the
TODOs later.

* Add this.offsetMap which maps each linear model offset to a model tree node
* Refactor createNodesFromData()
** Rename it to buildSubtreeFromData()
** Have it build an offset map as well as a node subtree
** Have it set the root on the fake root node so that when the subtree
   is attached to the main tree later, we don't get a rippling root
   update all the way down
** Normalize the way the loop processes content, that way adding offsets
   for content is easier
* Add rebuildNodes() which uses buildSubtreeFromData() to rebuild stuff
* Use rebuildNodes() in DocumentSynchronizer
* Use pushRebuild() in TransactionProcessor
* Optimize setRoot() for the case where the root is already set correctly

Change-Id: I8b827d0823c969e671615ddd06e5f1bd70e9d54c
Merge "Cleanup terms used in annotation method"
Increase number of callbacks per reactor iteration to 4

In experiments this dropped the memory consumption further, and reduces the
queuing overhead in the node reactor.

Change-Id: I9409b6ca863b43b7557663bbec9572365059c078
Drastically reduce memory usage for template-heavy pages

Only call back a few callbacks per reactor iteration from the template fetch
request queue. This changes the expansion pattern from a (memory intensive)
breadth-first expansion to something quite close to depth-first expansion.
Additionally, retrieved pages are quickly added to the page cache so that a
lot of request queuing is avoided in favor of synchronous expansion from the
cache. On pages like Barack Obama that previously ran out of memory after
consuming node's 1.6G heap limit, expansion now runs in relatively constant
100-300M resident (so far, still running).

Change-Id: Ie34a1eeff00d868416de45ef8d289898258f560c
Convert external link syntax stops to stack

Eat unbalanced external link parts within template parameters. This does not
produce the same output as the PHP parser
(try echo '{{YouTube}}' | node parse.js), but preserves a level of sanity.
Need to check how common this is for external links. If it is rare enough,
moving the ']' after the parser function manually would fix the rendering for
the YouTube case.

Change-Id: I597d808efff36baa22191e7946a0061cc31120e8
Cleanup terms used in annotation method

Change-Id: I509a1f1b680cc8a2973188f0ed7c7d67b8a15f4f
Fix up FormatDropdownTool
Effectively stopping & starting polling prior to conversion
Getting Selection from model
Reselecting after conversion (TODO: modify selection to entire block ?)

Change-Id: I9ba331b5393bf568cc8d137646b43244ae2640a8
Elminiated isSelection method
Determine actual selection from model by checking length

Change-Id: I1c58a4de31b26d49b55c7a2c55c9c6462741bdfb
Improved the appearance of the warning at the top of the editor

Change-Id: I38e2295f38ab8be101dba2dca251ed27ae65e5c2
Merge "Removed unused fake cursor div"
New Method isSelection() in Surface View
Used to properly hide/show Context menu and UI elements.

Change-Id: I8b3750c270651498b7e6c54a1921f5012cf33ea6
Token stream transform improvements

* add past paths for empty arguments etc
* cache attribute token transform pipelines
* fix bugs in TokenCollector and NoIncludeOnly handler, and improve its
  efficiency by only registering for 'end' tokens on demand
* Remove empty reset methods from a few handlers
* Add a simple 'ap' debug print function that makes it easy to only print some
  debug prints by temporarily changing 'dp' to 'ap'
* Improvements and bug fixes in AttributeExpander

Change-Id: Ie69729c8f62d48bba922712e44ebce484c621c50
Track inclusion status on CachedTokenPipeline

Non-include attribute pipelines are not cached for now. Adding separate
caching for non-include attribute pipelines is very likely worth it, but
deferred for now.

Change-Id: I13f949d9f0a04536f9ccfcb73a2be69c5c08be01
Add simple warning to indicate that VE is still in early dev.

Change-Id: Iea2abf9660556eca1d981fbbaab30d75a813e92d
Removed unused fake cursor div

This was an artifact from experimentation with multiple cursors long long ago in a land far far away

Change-Id: I14491c4adbd40bb8df4b1c31725cb1621351bef2
On annotate, get current selection from model
Fixes link annotation, and any annotation that pops up an inspector as selection is lost.

Change-Id: Idd8812b05f4fddfa4e613dea28a1a8421792656d
Merge "Set inclusion flag for attribute transform managers too"
Migrate tools from SurfaceObserver Class
ContextView positioning, Italic, and Bold annotations working

Change-Id: Ifc68bd61c8f27b6a14d314dc2999753af6e0ee04
Set inclusion flag for attribute transform managers too

Change-Id: Ice15d8fde6de4a3e850a028db9917e976218fc43
Support noinclude/includeonly/onlyinclude in attributes

Fun test case:
{|
|-<includeonly>
foo
</includeonly>
|Hello
|}

Change-Id: I353bb287d3967ade549fbcb4ae64511a1f1f7e36
Fixes to template expansion / token transform managers, 296 tests passing.

* Convert isNoInclude logic to positive isInclude throughout and set it
  properly on attribute pipelines. Also don't cache non-include pipelines.
* Add a --pagename parameter to parse.js, which sets the page name in the
  environment. This is then returned by {{PAGENAME}}. Not the final solution,
  but useful for taxobox testing as taxons are selected based on PAGENAME.
* Add rudimentary pagenamebase parser function

Change-Id: If9c0be4c255200d0f2a30f02e5619437b4fd8f12
Nominate more HTML5 sectioning and heading elements for block-level treatment

Block-level (in HTML4 lingo) elements are not wrapped into paragraphs.

Change-Id: I4a01c9721be30b526172952915d528dea79e2f30
Improve template tokenization in template arguments

Taxobox tables now render pretty much correctly.

Change-Id: I5a0564138ff0c688d8a5a69b7867646fd3763946
Add some support for alignment of thumbs

Change-Id: I70570f48423628f7a87a35647698a66a5f413088
Removed line-height from preview panel

This is not needed because the line height is no longer being forced in the editable view

Change-Id: Ic759e6e15dd6f2462cb6dbc26ba0f245821e1c15
Add basic thumb rendering support

* DOM based on Wikia's thumb output: HTML5, clean caption without magnify
  icon.
* basic RDFa annotations, but most options additionally in data-mw object-
  might want to move more (or all?) of those into RDFa data using meta tags.
* no support yet for framed or other formats, image scaling etc
* also tweaked some config options in the environment

Change-Id: Ie461fcdce060cfc2dec65cc057709ae650ef3368
Merge "Improve parameter tokenization support especially for table rows"
Fix copy / paste errors for setStyle method in ListNode and ListeItemNode

Change-Id: Ifc8183e047398fd7f4b0436e61768992a3a94612
Merge "Changed to using structured lists"
Make toolbar and context menu works

Change-Id: Ice981390b22a257158b3417dda3a1945d777cb14
getLeafNode is now a static method and should be called as a static method

Change-Id: I4f079523add81ef14537c950b29436422e1de850
Merge changes from branch ce-poll

Change-Id: Id7602ed33a09720c53310a032d2824395b82ff7f
Merge changes from branch ce-poll

Change-Id: Ibb6da1ac5229ed5afeda1a3944fe7deff3bfb9a7
Just a test

Change-Id: I74fb371a26b4b6068fee593bf7e6ee950080bca8
Changed to using structured lists

This makes it possible to get identical rendering in the editor, but may make other things more complex. The Wikitext serializer is no longer compatible for rendering lists so it's been stubbed out. Also the way the toolbar works with lists is broken, so that's been disabled. The HTML serializer has been fixed to work correctly and no-longer-used styles have been removed.

Change-Id: If156f55068b1f6d229b3fa789164f28b2e3dfc76
Improve parameter tokenization support especially for table rows

Change-Id: I961d69e228b96adc69ea9acb3733d13f5898602d
Merge "Remove behaviors var in tokenizer, now handled in token handler"
Merge "Updated CSS classes and rules for CE, which for the most part uses native elements"
Remove behaviors var in tokenizer, now handled in token handler

Change-Id: I68eeff3f05ce29c13e347c2cd7ea6519e58b0e03
Merge ""magic words" are tokenized and used to set parser.environment flags"
Updated CSS classes and rules for CE, which for the most part uses native elements

Also:
* Simplified ve.ce.Surface.getLeafNode, which may be better to just be removed and be used inline in the few places it's being used.
* Removed method wrapper for static function ve.ce.Surface.getLeafNode

Change-Id: I1d4cf0bb7ecc8f07f030753e40a13ebef7d02daa
Fix fetch-parserTests (it is in path instead of fs)

Change-Id: I169502079ea2609a4f4af776b15767cf0c3ec8b5
"magic words" are tokenized and used to set parser.environment flags

behavior switches are converted to tokens which set parser.environment flags during the async transformation stage.

The next step would be for handlers in the sync23 stage to generate the TOC, section edit links, and so on according to these directives.

No tests written, because the switches are consumed and don't appear in rendered html.  We can test the magic word layout controls individually, once they're implemented.

Another small change was to store option flags directly in the environment object, not that it makes much difference.

Change-Id: I863fbf4be1a17d2f6c31158298dd301f19ae1137
As much as I have loved writing Makefiles...  I've replaced its functionality with package.json, mostly so we can avoid non-node dependencies.  This is one of the recommended practices.  We should consider moving tests/parser into modules/parser/tests, other node projects keep all module code in one directory.

Explained in the README how to use npm to load the dependencies and run tests.  Too bad about NODE_PATH...

Don't try to find parserTests.txt in assorted places--if it isn't present, fetch from gerrit.  You can symlink from core if you're developing on both parsers, and the fetch script will not overwrite.

Use __dirname in parserTests.js to allow the script to run independent of current working directory.

Change-Id: I4c8b884e91f4fdeae385c7697aff768bdd199dd5
Revert "Another test"

This reverts commit ee713b22064a8e138f42102123c6f856e98de111.

Change-Id: I799acb3dd50182a29707244b45c1458f76270eca
Another test

Change-Id: Iaec9a70fd2d6e8a71e4d68d3992d149d94c32517
Revert "Another test commit that should not go through"

This reverts commit 09dac9fd585cf5aecea401ef2a532247f6fae4b2.

Change-Id: Id9a081f857c84900ccb1450cd6080aafa7678989
Another test commit that should not go through

Change-Id: Id2f32aaa44c9f33e3ec88a08ef7cb4bf65491ce3
Revert "This commit should not go through"

This reverts commit 04885078894a68424c1d6c62e2a63ab0c0a77123.

Change-Id: I5f10899743a2ca3e68330afcd8957816e009a857
This commit should not go through

This is just a test to see if I am allowed to push directly to master without being an administrator.

Change-Id: I9692f09e747448a1874a085bef061632391d0e2c
Revert "Testing: this commit should NOT go through"

This reverts commit 8a8abc01fc856cf547b5b3a164a7d97056080e6e.

Change-Id: I8052732dbd5fe4c3acbbd6b75d3e7cae0862c927
Testing: this commit should NOT go through

Change-Id: I318565bc965735efe8415240dcbddbc538361528
Improvements for template / -argument precedence; support for empty params

Change-Id: Id0894ccbedfa47fa3658817ca65119a2af76be3e
Disallow '[' in generic attribute names

This avoids interpreting something like

! [[foo|bar]]

as

<th [[foo=''>bar]]</th>.

Change-Id: If59708fa90eb0117a15b2b6446890d1ae19a857c
Fix table headings in template parameters

Change-Id: Icdfc5655968fc845230ad7638124309d6b8c1ada
Don't eat newline / space in template parameters

..so that block_lines can match.

Change-Id: I4c464dc44249f40e4aa280df35fb726bfce3a745
Merge "Add HTML DOM -> linear model converter"
Improve support for table / template interaction

Match pairs of {{!}} or | for template productions, but not a mix of the two.
Example:

{{#if:1|{{!}}-
{{!}} {{#if:1|style="color: red"{{!}}|}}
}}

Note that the style parameter ends up as the *key* of an empty-valued
attribute on the table cell currently.

Change-Id: I5f9357dd1645ef97b0af89f32e8d92ae49218c72
JSHint cleanups and parser function argument handling improvements

Parser functions which only accept positional arguments now return both the
key and value of arguments. Complete attributes (key and value) for templates
and the like from parser functions are not yet supported though.

Change-Id: I3f81bb35acd27186222ce6d5217e820042527c01
Cleanup of white space, missing semi-colons, line breaks, etc.

Change-Id: Ifa96a9f70fa8d149a4c403521aaa88a3e0546ef0
On selection, update selection in the model.  Fixes selection.clone() error.

Change-Id: Ibd5cf0398002e5fbb2c50549e4a7043ba8fd00a7
Fixed surfaceView undefined error

Change-Id: Iba3ae54b4e508afbfa132e0f0b2b0b237e685395
Add links in sandbox and demo to ve.dm.DocumentSychronizer.js

This was caused by added this dependency in the code without adding the links to the sandbox and demo

Change-Id: I7b2f0129a28dfd8655dfbce8688cfb3920c690fd
Merge "Magic links and behavior switch tokenization by Ori Livneh"
Shorten data-mw-rt to data-mw and clean up whitelist

Instead of a proliferation of data-mw-* attributes, it should be easier to
stash all private / non-semantic round-trip information in a JSON object
stored in data-mw.

Change-Id: Id200a6a8789fa152f29ea530e5a24b6ee7b4b285
Magic links and behavior switch tokenization by Ori Livneh

Commit first patch by Ori, lets 288 parser tests pass. Yay!

Change-Id: Iac8c3d1ad1984900350b20f7e725c40618a1e8ba
Change path to parserTests from phase3 to core after switch to git.

Change-Id: Ie13f678eaa81447e98db5c8c394ab103caad8454
Added ve.Surface, a wrapper around an editor instance

* This high level surface object is responsible for creating & managing editor instances
* Revised Sandbox demo to invoke in this way.

Change-Id: I4043779af9a2ab964deaf26079a992e82ebeef27
Replaced es with ce for Sandbox and main demo

* Configured VisualEditorSandbox to use es
* Reconfigured the ce demo to share the sandbox module
* Removed es demo
* Renamed ce demo to ve (es is broken anyways)

Patchset 2: squashed in https://gerrit.wikimedia.org/r/3953

Change-Id: If8d13bf7011616d222be78899b23186859d5ed70
Add HTML DOM -> linear model converter

Also, in ParserPipeline:
* Import the LM converter and expose it through getLinearModel()
* Fix getWikiDom() to actually work (still unused)

In parse.js:
* Add --help option that prints usage information (was unreachable)
* Add --linearmodel option to output linear model JSON instead of HTML

Change-Id: Ic534e03ff40a7c9117bb63f0c635a4213d5e3406
* Get parser tests from GitWeb, not Subversion.

Change-Id: I39f933b9e0320dc62736da07ce097ec1badec9aa
Add tree synchronization for replace

To handle replace operations that are not themselves consistent (these
are common, for instance when replacing an opening element in one place,
then replacing the closing element somewhere else), we process
subsequent replace operations inside the first one until things are
balanced again, then issue a single rebuild for the whole thing.

Change-Id: Ide4613f046fabfeeef383138c39e350b1b710033
adding clearState function for tools and using clearState if no selection exists

Originally committed in SVN as r114418 by Christian, missed the git
conversion

Change-Id: I56e91c170670519fa2b482a4b7f30cdcbc8ff163
Add .gitreview file

Change-Id: I560b114511927c6dcdb7fd379af81f7f6d6ca38e
Fully revert r114142, was previously reverted in Collection only
Fix many more occured typos
svn:eol-style native
make clear button tool work with annotate method in ce surface
Make LinkInspector works (using annotate method in SurfaceView)
Use on and off insteaf of bind and unbind.
CE surface has no hidden input, removed input focus
No more endless looping! And fix getSelectionRect to return document relative coordiantes instead of viewport relative.
adapt LinkInspector to use surfaceObserver for selection
fixes to ie ce test demo
3d flip demo and nested contenteditable tests for IE
add surfaceObserver on select methods to ui toolbar and surfaceView for responding to select event. tools now updating to selected node annotations. revise getSelectionRect to return actual start & end pos. context icon properly showing on range selection
svn:eol-style native
Enable support for block-level wiki constructs in template arguments. This
gets a bit closer to supporting table fragments passed through template
arguments. Next, we'll need a way to indicate start-of-line position to
enable sol block-levels in template parameters. 

Example:

{|
{{#if: true|{{!}}Table cell|}}
|}
adding test files for IE table resize handling
Put the invert state / method (commit or rollback) in the TransactionProcessor object and no longer pass it as a parameter to each operation. This makes it easier for operations to execute other operations.
Factor out process() into nextOperation() and executeOperation()
Add a test for unwrapping and rewrapping
Rewrite the rebuild action to take two ranges rather than a node and some data.
Break out pushAction() into separate functions for each action. This will allow me to change the rebuild action to take totally different parameters.
Remove the offset adjustment feature from DocumentSynchronizer. It gets in the way when I try to use this class in TransactionProcessor.
Move computation of missing offset from pushAction() to synchronize(), and only compute offsets for actions that require them. This also fixes an issue where offsets computed by pushAction() would be adjusted incorrectly by pushAction().
Make DocumentSynchronizer clear the queue after it's done with it
Convert syntactical break flags for templates from counters to the stack
variant to fix the precedence for {{!}} (break on these inside table content,
but not in template options within tables).
Improve support for {{!}}, and don't produce a pre for indented tables.
Support {{=}}.
Use <h[1-6]> tags for rendering headings (instead of divs)
fix dropdown tool to use selection from ce surfaceView
Replace CursorObserver and ContentObserver with SurfaceObserver
Localisation updates for core and extension messages from translatewiki.net
replacing showCursorAt calls with correct showCursor method
node modules required: request & jshashes
Move link types to data-mw-rt, and support some more template tokenization
edge cases. For example, the PHP parser treats | foo | = bar | as | foo = bar |,
believe it or not ;)
Add tests for list split tree sync
removing min height attribute to fix IE bug
preventing native contenteditable resizing tools
rework context icon positioning for CE surface using new getSelectionRect method
small fix: getSelectionRange was breaking the surface layer, changed to saved state member
port over select event listener, and updateSelection methods for setting and removing context icon, add getSelectionRect method for context icon position
switch to getSelectionRange and fixing IME native menu
Improved template tokenization. The parser can now template-expand
[[:en:Barack Obama]] without exceeding 1.7GB of memory (which is the node
limit).
Tolerate more newlines and spaces in templates, and support templates and
comments in urls.
Refactor syntactic stops into an object and add a stack variant for option
values.
svn:eol-style native
Localisation updates for core and extension messages from translatewiki.net
Fix some usages of splice.apply in the data model to use
ve.batchedSplice(). Added FIXME comments for occurrences outside of DM
Make ContentObserver pass information about content when emiting change event.
More cleanup
More cleanup (jshint complaints)
Cleanup
Initial import of CursorObserver and ContentObserver (not being used yet).
Removed duplicate static methods and members that were copied to ve.dm - lets just leave them in ve.dm.DocumentNode for now.
Updated QUnit
Added test for ve.dm.DocumentSynchronizer that exercises multi-action synchronizations
Add test for replacing a table with a list. This only works because
nesting validity isn't checked yet (lists inside lists are illegal
IIRC), but for now it tests the reversal of the order of the closing
tags nicely
Add a check for the length of unwrapOuter, and add a test for each
exception
Make prepareWrap() use the data from the model rather than the unwrap
parameters. This fixes the case where rolling back a list unwrap would
restore the list items without their attributes
Add tests for unwrapping a list

This also excercises unwrapEach. One of the tests is still subtly broken
in that the attributes on the listItems aren't preserved, I'll fix that
next.
Fix stupid typos so wrapEach actually works
Fix cursor adjustment in replace()
Implement prepareWrap and add tests for it
Add documentation for to-be-written prepareWrap function
Add tests for content replacements
Add a very simple transaction builder for content replacements
Implement the replace operation for the linear model
Factor the batched splice code out from ve.insertIntoArray() into a
separate function
Add replace operation
Fixed name of test suite to match actual class name
Added more tests for ve.dm.DocumentSynchronizer and fixed some bugs along the way
Temporary fix for template tokenization, especially needed for 
[[Template:Cite core]].
svn:eol-style native
Percent-encode spaces in URLs, so that they are recognized as valid URLs later
on.
A few fixes to parser functions and template expansion. Trim whitespace off
template arguments, let the last duplicate key win and fake pagenamee slightly
better.
Improvements for image option handling.
A bit more documentation and naming cleanup in the tokenizer wrapper.
Added some basic tests for resize and insert. Fixed some bugs in both of those code paths along the way.
Typo in file name
preserve range after applying annotation
Get rid of showCursorAt method. And replace calls to it with calls to showCursor.
Added getDOMNodeAndOffset and showSelection methods to Surface. Ohhh and little wrapper around it - showCursor.
removing usage of rangy anchornode for determining rendering scope - using model and autoRender
Small refactoring. Changed method name, from Surface.getSelection to Surface.getSelectionRange.
replacing cursor after annotating works
Added sketch for ve.dm.DocumentSynchronizer which is a utility object for queueing up actions to be performed on the model tree such as deletion, insertion, rebuilding, resizing and updating of node. Using this approach, we can collect actions across multiple steps, and then normalize them to avoid duplicate work and mutate the model tree in a single step.
Token representation clean-up. Now all tokens are differentiated using
constructors instead of type attributes.
port over annotation methods from ES to CE, remove unused renderDomNode method
cleanup whitespace
Delegate responsibility for resetting the token rank to transforms, if full
re-processing in a phase is wanted. By default, after a token type change or
the return of multiple tokens only the remaining transforms with higher ranks
are applied.

Updated a few comments as well.
A few minor documentation updates.
Set allTokensProcessed flag for async callbacks from the template expander.
Start re-transformation as soon as possible in TokenAccumulator._returnTokens
to maximize IO concurrency. Signal that all tokens are fully transformed to
callbacks called from TokenAccumulator._returnTokens. The result should be a
single re-transformation when entering the callback chain, and only if the
transform does not signal that it took care of full transformation itself.
Template expansion would set this flag, as the nested transform pipeline
processes all tokens to the end of phase async12.
Fixes for multi-transformer expansion in AsyncTransformManager. Added argument
to callback which lets transforms indicate if their returned tokens are fully
processed for their phase. If not, the callback re-processes them so that any
remaining transforms are applied.
adding autoRender property to SurfaceView to enable/disable automatic rendering of view when model is updated
Fixed some jshint complaints and enforced 100char line endings
Update class names, from ve.es to ve.cs, and update code that uses those classes
Rename bunch of files from ve.es.* to ve.ce.* (and update references)
Copy files from ve/es to ve/ce and update references
Fix some svn:mime-type with value "application/octet-stream" to more specific values
Improve generic attribute expansion before external link processing, and make
wgUploadPath configurable. Also change the hard-coded fall-back image sizes to
sensible defaults. This breaks three parser tests until image size retrieval
from the wiki is implemented.
Accept empty table cell attribute sections, and consider percent-encoded %2525
valid. 270 tests passing.
Reworked percent encoding handling for URIs to get closer to the 'url
construction' part of the HTML5 spec:
http://www.whatwg.org/specs/web-apps/current-work/multipage/urls.html#url-manipulation-and-creation

Removed a few whitelisted test cases that are now passing directly.

The encoding canonicalization could also be moved to the Sanitizer. Doing this
early in token stream processing however has the advantage of providing further
transformations uniform data to work with. We could even consider to move this
even further into the tokenizer.
enable CE demo toolbar, added annnotation and renderDomNode methods
Fix invalid external link representation. 268 tests passing.
prevent insert for stand alone command key.
Support external images wrapped in a clickable link using bracketed external
link syntax. 265 tests passing.
A few improvements to external link and image handling. 264 tests passing.
Change wikilink tokenization strategy to split on pipes. This makes it
possible to support template / template argument expansion in image options,
and causes little trouble for wikilinks. Non-image wikilinks with multiple
text pipes are quite rare in the dumps, and concatenating description tokens
with a plain '|' is quite easy. 261 parser tests passing.
minor changes: remove whitespace and add semicolons
Fixed tests that were broken by r112150.
Namespaces to the rescue.
Use some options primitively.
Parse image options.
Improvements to changes polling mechanism
Added basic support for enter key
event binding cleanup
adding paste fixes to cut handler
Fix bug in Chrome when moving cursor with left/right arrow in between <table> and textnode
better cut-copy-paste support
Fix couple of poll interval bugs in Surface and add new parameter called 'byref' to method getAnnotationsFromOffset which makes it return array references instead of copy of arrays.
adding cut-copy-paste
Cleanup for JSLint
Explicitly pass parameter global=true to getOffset method
Added getSelection method to Surface
Add productions for image option tokenization, and prepare to call those from
the LinkHandler token stream transformer.
Collect some statistics while grepping.
Hack up some rudimentary image rendering. Using jshashes for the md5, and
a few hard-coded image image sizes ;) 262 tests passing.
More work on wiki link rendering and general wiki title / namespace
functionality.
Migreate text input method from playground to ce and ce demo
More image compression of extensions with WMF interest
Start to move wikilink expansion to a separate async token transformer.
Capturing the regexp is no longer necessary, and speeds up the grepper. Also
tweaked the multi-line ISBN regexp slightly.
Add a misc regexp file for dump grepping.
Support capturing regexps in dumpGrepper.
re-enabling native browser spellcheck
adding bidirectional text for testing
svn:eol-style native
Improve grepper documentation.
Tweak martian regexp and grepper output format.
Finish color highlighting for dump grepper / fix broken commit r112592.
Actually commit onlyinclude, as already announced in r112592.
Implement onlyinclude transformer. 254 tests passing.
fixed my typo follow up r112555
Improved support for spellchecker
cleanup previous commit. follow up r112552
prototype RTL text mode cursor handling. Need to complete the unicode regular expression, and make helper methods for RTL boundary
Input implementation that seems to work in IE, FF and Chrome (all tested on Windows only)
Input implementation that seems to work in IE, FF and Chrome (all tested on Windows only)
Detecting if change to text is coming from keyboard or spellcheck
prevent dragging and dropping text - can be removed later if operation supported via model
added a left positioning to input to properly position ime context menu
Add martian-endtags regexp wrapper around dumpGrepper.
Add a simple dump grepper using DumpReader. Useful to inform parser design
decisions, and as a way to exercise the dump reader in preparation for tests
over full dumps.
Tweak dumpReader to work with current libxmljs and stdin 'data' events.
New approach for handling input in ContentEditable - compare not only plain text but also hash of DOM structure of the particular leafnode (it let's detect spellcheck weird behaviour and react to it)
fix typo which prevented readInterval from stopping onBlur
Testing new approach figure out where the change is coming from based on the cursor offset, not based on key events
minor fixes: removed whitespace, added semicolon
follow up to r112276, fixed bug which prevented word selection
very minor fixes
Fixed bug when moving cursor with click.  Calling showCursor after input regains focus prevents browser from freakishly scrolling
Rework general input to no longer clear during IME.  Polling interval for non keyDown text comparison. Chunked text insertion for all normal keys which makes nice transactions and clears input.
Recogonize if input came from spellcheck or from keyboard (Chrome)
Fix relative paths to js files
Move playground to demos subdirectory
Move playground to demos subdirectory
Move playground to demos subdirectory
Move playground to demos subdirectory
svn:eol-style native
Input implementation that seems to work in IE, FF and Chrome (all tested on Windows only)
Added support for respecting new lines in pre-formatted blocks - using Shift+Enter will show this in action!
Use flag 'isime' to correctly detect keyboard input in firefox.
Implementation of setinterval loop that checks for changes in contenteditable content
Initial implementation of logic to recognize if edit is coming from keyboard or somewhere else (spellcheck)
Replaced "set" and "clear" method for attribute transactions with "replace" method, which allows correct reversion. Also fixed list item tools to correctly use the new function signature.
Simple and temporary playground to work on retrieving content changes from content editable element.
Follow-up to r112116, accidentally committed from subdirectory.
Green two more parser tests by implementing some parser functions.
Add some support for functionhooks in test parser and parserTests.js, and
tweak a few parser functions.
Basic fall-through support for #switch parser function
Cleanup and commenting.
Speed up flatten slightly by avoiding garbage for already flat arrays. Also,
use simple string concatenation instead of arrays as the strings tend to be
few and short.
Reduce debug print overhead, roughly a 10% speed-up on parserTests.
Remove some more unused code and tidy up some more.
Fix the bug in the inline_breaks replacement, and write another switch-based
version, which is slightly faster and shorter. Performance is improved by
about 5% for parserTests.
Tidy up and comment the tokenizer a bit more. Start to move code into
mediawiki.tokenizer.js module, and pass a reference to parse(). Faster
inline_breaks production using a JS function which seems to be generally
correct, but still breaks five tests when enabled. Seems to be some weird
interaction with peg.js, possibly something to do with caching.
Add list of HTML5 and deprecated HTML3/4 elements in preparation for
end-of-potential-extension rules; Support indented tag-wrapped pre blocks.
Comment and minor code tweaks.
* Instead of sorting attributes, whitelist the one parserTest where it matters.
Revert "* Always sort attributes (+1 test pass)."

This reverts commit 45ca281da8eef8030bdd1986418cb914fc9a717c.
Push transformer setup a bit further into the attribute pipeline.
Add some comments to the Sanitizer
Set up token stream transformers from a map of phases per input content type.
Not yet applied to attribute pipeline creation. 249 tests passing.
* Always sort attributes (+1 test pass).

  The performance impact for .sort is quite small (12.079s => 12.158s)
  and Sanitizer is probably one of the more accessible places to do this.
* Rudimentary CSS validation; +4 tests pass. (Bug 2304, 3244).
* Convert __patched-html-parser to .coffee.

  Note that the compiled .js file (generated by "make"/"make test")
  is still under version control so folks can work on the project
  even without a running "coffee" command in PATH.

  Also updated README to mention coffee-script and "make test".
* Add a "make test" target that auto-fetches parserTests.txt.
* Locally apply the HTML5.Marker.type patch.

  This is needed until https://github.com/aredridel/html5/issues/44
  is merged into the upstream "html5" module.
Detail comments about next steps and divide parser functions in those that
need more information from the wiki and readily implementable items.
Reject match for invalid urlencoded code points.
turning off native spellcheck for now
Tweaked template parameters a bit further, and made the self-closing tag
protection a bit less trigger-happy.
Protect self-closing tags in generic attribute production.
Prepare for the support of tables (and later generally block-level elements)
in template parameters. 244 tests passing.
Improve support for generic attribute names coming from
templates/templateargs.
Improve support for single-line attributes with preprocessor support. 243
tests passing.
Port urlencoded char support to preprocessor-supporting link target
production, and remove old link_target production.
Replace console.log with console.warn in all debug statements
Changed the way widths are calculated when rendering lines of text. Now we let the browser do it's normal layout thing, and use a set of floated divs to figure out the effective line width. Using this technique, we pretty much support floating content from a rendering perspective. Interaction is still a problem however.
Fix named wikilink options (image options really) in template arguments, and
speed up template parameter parsing by eliminating some backtracking. 238
tests passing (unchanged).
request is automatically installed by jsdom. Follow-up to r111459. Thanks
Hashar!
Tweak comment about request module
New approach to text input and IME (part I)
Commenting out fake cursor for now, fixing paste binding
creating showFakeCursorAt method and cleaning up code
Localisation updates for core and extension messages from translatewiki.net
Render real <b> and <i> tags insteaf of <span>s
* Add custom toString methods for tokens to aid debugging
* Convert all attributes into strings in Sanitizer
* Use strict comparison against empty string in tokenizer
* Add very simple sitename parserfunction
* 138 tests passing
Reformat Date.replaceChars
Strip trailing newlines from included templates
Prefix all internal data- attributes with data-mw- and adjust the whitelist
and test output normalization accordingly. 235 tests passing.
Add some support for ideographic spaces in external links, support the
int: namespace alias and perform some normalization on the MediaWiki namespace
prefix.
Localisation updates for core and extension messages from translatewiki.net
Remove WikiDom default serialization and --html argument from parse.js
wrapper. HTML ist now the only supported format. The DOMConverter is now no
longer used. Roan, feel free to remove / butcher it for direct HTML to linear
model conversion.
Move data-* annotations into separate object on tokens, that is then
serialized into a single data-mw-rt attribute if present. Update parserTests
to ignore this attribute for comparisons with expected parser output.

A few more tweaks and notes are thrown into this commit too. 233 tests are
passing now.
Working prototype of insertion of the text with annotations
Get rid of console.logs
Add new method: getDOMText
fake cursor demo
svn:eol-style native
Fix showCursorAt method - missing "break;"
Use more interesting wikidom as example article in Content Editable demo
removing cut-copy-paste demo
Some comments and reshuffling in the grammar, and a typo in the
AttributeExpander.
reorginization of event handlers
ve.js isn't the edit surface, that's es.js :)
local variable
bugzilla is on https only (though it will redirect)
local variable
Improve support for preprocessor functionality in attributes; Support
multi-line xmlish tags with preprocessor stuff in attributes.
Fix a bug in wikilink with trail tokenization.
Move attribute expansion back to separate handler, as this makes it easier to
only expand used branches selected by parser functions. Template (and
-argument) expansion is simply registered before general expansion.

Additionally, a few more simple time-based magic words are added in
ParserFunctions.
removing beforepaste event for now. it was hyper
using transact
First implementation of IME for content editable
paste handler no longer causes fast viewport shift when pasting
layout tweaks
using execcommand to undo cut - model controls mutation
Enable support for general preprocessor functionality in attribute keys and
values. This includes comments, templates and template arguments.

This also replaces the specialized expansion logic in the TemplateHandler. The
removal of link validation lets one more parser test fail for now. External
link target validation will need to be implemented in the token stream handler
for links. This is noted as TODO in
https://www.mediawiki.org/wiki/Future/Parser_development#Token_stream_transforms.
fixing scroll after paste
removing offset override
adding overflow hidden to allow clicking on floated elements
working on getSelection and getOffset for triple click
Display "wikitext" pane by default in content editable demo
cut support
copy and paste support
Implement: surfaceView.showCursorAt(int n)
Delete scanBoundaries method from Content, as it does not make sense anymore for content editable approach
Get getSelection in contenteditable working
Cleanup Surface.js - only functionality that is needed for content editable
Make paragraphs in content editable use real <p> tags
ie paste support
test page for copy and paste support
Added missing CSS and PNG so ce demo does not complain anymore.
Cleanup ve.es.Content.js for ContentEditable and setup toolbar as empty (as there is no working functionality for now)
svn:eol-style native
Reorganized demo and demo-ce into demos/es and demos/ce
Merge r110853
Normalize the title in localurl. 232 tests passing.
Clean up transform callback interface
Pluck a few low-hanging fruit in external link tokenization, and add a simple
localurl parser function implementation. 230 parser tests now passing.
External links don't nest.
Fix parserTests summary with filtering enabled
removing outline from contenteditable
tweaks to margins
Adapt ContentEditable code to new schema of directories and files
Fixed backspace - another issue related the r110805 (or as we are now calling it, "The Great Code Migration of 2012")
Minor fixes (line length breaking, jshint nagging, etc)
work on copying and pasting
Updated unit tests in response to structural changes in r110805
Get wikitext preview pane to work in contentEditable
Fixed image file links from sandbox.css to images supplied by es and ui packages
Migrated es.* to new ve.* namespace which is more structured, and will make it easier to keep data model, edit surface, user interface and content editable work separated cleanly
Temporarily disable the sanitizer and start to support preprocessor
functionality (comments, templates, template arguments) in arbitrary
attributes. The grammar for this is still quite rough, will need to
consolidate that area.
Improve toJSON handlers to include all properties
svn:eol-style native
Fix nowiki tokenization regression introduced r110495
Add custom JSON serializers for tokens that include a type attribute
Playground for IME (switch from textarea to contenteditable div)
Playground for IME
table cell styling
experimentation with table editing
adding ce-leafNode class to leaf nodes
Fix showCursorAt method for bug of ">=" vs ">"
changes to margins
floating table
Get rid of "position: relative" - it breaks selection in contentEditable
switching back to fully contenteditable for tables, disabling handles in firefox, changing title tag
Don't replace spaces with &nbsp; in content editable
contenteditable false for tables - true for table cells
removing outline from contenteditable elements
tweaking margins
Render paragraphs as a <p> tags (indtead of <div>)
Port contentEditable demo to EditingSurface layout
adding resources for table rendering
Port contentEditable demo to EditingSurface layout
adding table to hybrid demo
Localisation updates for core and extension messages from translatewiki.net
Remove type attribute for tag tokens.
Push token format conversion a bit further along, and add defines that were
missing in last commit.
Add --debug and --trace options to parserTests as well.
Change token format to plain strings for text tokens, and specific objects for
other tokens. This is only the first half of the conversion. The next step is
to drop the type attribute on most tokens and match on the constructor in the
token transform machinery.
Remove some modules normally bundled with node.js from dependencies, and
remove some older ones that are only used in currently-dead code.
Add source for #time implementation in comment
testing commit access
adding range pixel position detection
As promised, reorganize insert() so the order of cases makes more sense (from simple to complex)
A few more debug helpers including a --trace mode for light debugging. Some
improvements to parser functions on the way to support the cite extensions.
Preparation for generic template and template arg in attribute support. 222
parser tests now passing.
Fix test #30: was failing because getScope() was broken and insert() didn't account for the case of inserting something like </list><list> at a structural offset. All tests are now passing, yay!

* Fix getScope()
** Drop the -1 which caused the result to be off by one level
** Prevent JS errors from occurring if bad input causes the loop to try to traverse up above the root node
* insert()
** Detect the case where the input data tries to close the containing element; in that case, we'll get scope != node
** Move the getNodeFromOffset() and getScope() calls up and out of the conditionals
** Remove unnecessary parent==model conditional, no longer needed now that getScope() can safely handle things that try to traverse too far up
** Add some comments to explain what's going on. I'll restructure this function a bit more shortly
added dependencies to README
should be in contents
if error, do not tell remote users what the actual command was
first pass at an API method that returns wikidom. Shells out to node. Some issues with XML API result formatting but works fine in JSON
Localisation updates for core and extension messages from translatewiki.net
A few minor tweaks to reduce memory usage
svn:eol-style native
Proof of concept for cursor repositioning - showCursorAt method
Small refactoring to getOffset method in SurfaceView
Basic support for backspace button
Basic support for "enter" key
Modify color of browser native selection
Fix offsets in example wikidom document
Hybrid of ContentEditable and Wikidom - initial import
Test commit
Skip traversal of leaf nodes if there aren't any children
* Emit token chunks for top-level block elements by patching the source of the
tokenizer
* Fix a bug uncovered by this
* Increase the number of outstanding listeners on a single download to 10000
A few parser function fixes and maximum template expansion in environment
config.
Bug fixes and a first stab at a #time parser function. You can expand the main
page like this:

cd extensions/VisualEditor/modules/parser
echo '{{:Main Page}}' | node parse.js
echo '{{:Main Page}}' | node parse.js --html
echo '{{:Main Page}}' | node parse.js --debug

Even the date-based includes work somewhat, although they don't yet accept
passed-in dates.
A bit of template expansion bug fixing and parser function documentation
Add some commandline switches to parse.js. Supports switching on/off debug
mode and a selection of html/WikiDom serialization.
Implement a few parser functions. 220 parser tests now passing.
Support empty template arguments and default values in arg expansion
Remove a few stray debug prints and disable debugging in parse.js
* NoInclude and IncludeOnly improvements
* Tokenizer support for templates and template args in template arguments and titles
* Async attribute expansion fixes
Fix a bug in TokenCollector, and misc tweaks for template expansions.
Collapse all requests per template into a single outstanding request using an
event-emitting TemplateRequest object and a request queue.
Add some rudimentary noinclude / includeonly support and fix up
TokenCollector.
Minor cleanup in TemplateHandler
Fix async template expansion, so we can now render simple pages with templates
directly to WikiDom from enwiki using a commandline like this:

  echo '{{User:GWicke/Test}}' | node parse.js

Wohoo!

Complex pages with templates won't render properly yet, as noinclude /
includeonly and parser functions are not yet implemented. As a result, the
parser will run out of memory or hit the currently low expansion depth limit
as it tries to expand documentation for all templates.
Eventify parser tests and parse.js commandline wrapper to actuallly allow
async template fetching. Async expansion is not yet fully debugged, but at
least the preconditions for that are now there.
Make template fetching somewhat functional on node with Inez' help, but
disable it by default in parserTests as it tries to fetch all sorts of parser
functions and is not yet fully supported in parserTests. The next step will be
to build a list of parser functions (to avoid fetching them as templates) and
pushing the event interface into parserTests.
Fix comment to reflect the actual regexp/spec in the JS version as well.
Add the start of a minimal sanitizer stage, that only strips IDN ignored
characters from host portions of links hrefs for now. This module needs to be
filled up with pretty much everything Sanitizer.php does, including tag and
attribute whitelists and attribute value sanitation (especially for style
attributes).

We'll also need to think about round-tripping of sanitized tokens.
Eat '[[[' as plain text token, makes it 212 passing.
Accept IPv6 (and IPv4) addresses in the tokenizer, so another test passes.
Trim whitespace off template titles and argument names. 209 parser tests now
passing.
Fix template argument expansion. 200 parser tests now passing.
Localisation updates for core and extension messages from translatewiki.net
Clean up 'END' token handling a bit.
Use isBlockTag in DOMPostProcessor
Misc improvements, now 196 parser tests passing.

* Add handler for post-expand paragraph wrapping on token stream, to handle
  things like comments on its own line post-expand
* Add general Util module
* Fix self-closing tag handling in HTML5 tree builder
Localisation updates for core and extension messages from translatewiki.net
First template expansion tests start working, and a bug fix in
DOMPostProcessor paragraph wrapper. 187 parser tests now passing.
Template expansion now enabled and somewhat working, but template fetching
still fails all the time.
Results of early template expansion debugging. Still disabled by default, but
getting closer.
More work towards template expansion.

* Created AttributeTokenTransformManager for generic attribute conversion, and
  removed { title, template argument {key, value} } expansion from
  TemplateHandler.
* Added caching for attribute and input sub-pipelines. Especially attribute
  pipelines would otherwise be recreated for each attribute value and key.
Localisation updates for core and extension messages from translatewiki.net
More token transform and pipeline setup refactoring to support template
expansion better.
Localisation updates for core and extension messages from translatewiki.net
A bit of cleanup in ParserPipeline, with better and more consistent support
for multiple input types.
Add generic 'collect all tokens between delimiter tokens and call a transform
function on it' util for synchronous transformation phases. This can be used
to implement parser hooks (aka extension tags) besides other things.
Two batteries worth of token transform manager refactoring.

* TokenTransformDispatcher is now renamed to TokenTransformManager, and is
  also turned into a base class
* SyncTokenTransformManager and AsyncTokenTransformManager subclass
  TokenTransformManager and implement synchronous (phase 1,3) and asynchronous
  (phase 2) transformation stages.
* Communication between stages uses the same chunk / end events as all the
  other token stages.
* The AsyncTokenTransformManager now supports the creation of nested
  AsyncTokenTransformManagers for template expansion.
  The AsyncTokenTransformManager object takes on the responsibilities of a
  preprocessor frame. Transforms are newly created (or potentially resurrected
  from a cache), so that transforms do not have to worry about concurrency.
* The environment is pushed through to all transform managers and the
  individual transforms.
Localisation updates for core and extension messages from translatewiki.net
Handle default for template arg expansion, add template fetch functionality
and tweak a few minor things in the grammar and QuoteTransformer.
Add template expansion handler skeleton, not yet functional. Also note
improvements needed in the tokenizer template handling.
Localisation updates for core and extension messages from translatewiki.net
w/s
re r106536 remove !transparent
Fix quote handling and tweak the whitelist a bit. 'any' token registrations
are now merged with specific registrations by rank. Not yet clear if that is a
good idea overall, need to check use cases when implementing template expansion
and other functionality.

183 parser test now passing.
Fix up constructors in EventEmitter inheritance and tweak a few more comments.
Fix JSHint warnings (mostly about comment indentation) from r108012.
Hook up the DOMPostProcessor using events as well, and rename the subscription
methods to tell a story. Also document idea on how to dynamically configure
the pipeline depending on event registrations in comment.
Clean up comments in TokenTransformDispatcher and mark private methods with
underscore.
Add trailing newline in commandline parser wrapper
Rename ParseThingy to ParserPipeline and fix up broken WikiDom generation and
commandline runner.
Land big TokenTransformDispatcher and eventization refactoring.

The TokenTransformDispatcher now actually implements an asynchronous, phased
token transformation framework as described in
https://www.mediawiki.org/wiki/Future/Parser_development/Token_stream_transformations.

Additionally, the parser pipeline is now mostly held together using events.
The tokenizer still emits a lame single events with all tokens, as block-level
emission failed with scoping issues specific to the PEGJS parser generator.
All stages clean up when receiving the end tokens, so that the full pipeline
can be used for repeated parsing.

The QuoteTransformer is not yet 100% fixed to work with the new interface, and
the Cite extension is disabled for now pending adaptation. Bold-italic related
tests are failing currently.
Localisation updates for core and extension messages from translatewiki.net
Localisation updates for core and extension messages from translatewiki.net