This is done by using the computed property value rather than the
literal attribute value when rendering href and src attributes.
Helpfully, this provides perfect URL resolution natively in the browser,
which means the document's <base> is respected and all that good stuff.
For GeneratedContentNodes, we also need to find all DOM elements inside
the rendered DOM that have href or src attributes and resolve those.
This is done in the new getRenderedDomElements() function, which the
existing cleanup steps (remove <link>/<meta>/<style>, clone for
correct document) were moved into.
In order to make sure that the computed values are always computed
correctly, we need to make sure that in cases where HTML strings
in data-mw are parsed, they're parsed in the context of the correct
document so the correct <base> is applied.
We still need to solve this problem for models that actually store and
edit an href or src as an attribute. I'll post more about that on
bug 48915.
Bug: 48915
Change-Id: Iaccb9e3fc05cd151a0f5e632c8d3bd3568735309
ContentBranchNode renderContents changes the browser selection, so we
need to change it back.
ve.ce.ContentBranchNode.js
* When rerendering, set a flag on ve.ce.Surface
ve.ce.Surface.js
* On model documentUpdate, reapply selection if flag set
Change-Id: Ib8a168e6ec674b9d8021423f21f7acca75c2fd7c
The SurfaceObserver lock guarded against setTimeout calls, but the lock
was only ever used synchronously.
Remove 'lock' and 'unlock' events. Instead, re-sync the SurfaceObserver
by listening to the 'documentUpdate' and 'select' events.
Signed-off-by: Roan Kattouw <roan.kattouw@gmail.com>
Change-Id: Ib15c39f3d25677da70625581b3b2765ae66994b4
...or really changeInternal(), so we can avoid adding undo transactions
to the undo stack.
Also get rid of the pattern where undo() and redo() return a selection
which the caller then has to restore, and instead just restore the
selection.
Bug: 53224
Change-Id: If5a3b4d4162e9f0713ee9cd26e79a66efe52770f
* Replace surface 'transact' event with 'documentUpdate' event
* Have surface listen for all document transactions and update selection
as appropriate (as well as emitting 'documentUpdate')
* Implement change() in terms of setSelection()
** Queue 'contextChange' events so contextChange is only emitted once
** Use this.transacting flag to prevent setSelection() (which is called
because the model emits transact events) from doing too much
** Behavioral change: lock/unlock now emitted separately for
transaction and selection changes
Change-Id: I44425d260ec70758f99d13f99e41f5c993d260c2
ve.dm.Surface.js:
* Stop emitting 'change' and remove its event documentation
ve.ce.Surface.js:
* Listen to 'select' instead of 'change'
* Perform a CE surface update after model-based keydown handling
ve.dm.Surface.test.js:
* Stop asserting that 'change' is emitted
Change-Id: I8f16289493e835d890709c6dfe093d04c18522b6
Math, hiero, language and alienextension are now each in their own
module. Kept the experimental module for backwards compatibility,
it just has all of its constituent modules as dependencies.
MWExperimentalTool.js was split up, and ExperimentalTool.js was
renamed to LanguageInspectorTool.js.
Change-Id: I63b49dfbdb59dc9a494049553cc0c01e89e48826
Because QUnit's inline diff is terrible for large diffs,
especially when there are block whitespaces changes.
Change-Id: I786fb981b02777ede38c4bee261f9e32f8f908ed
Instead, listen to 'select', or to 'transact' on the dm.Document.
This commit only fixes uses outside of the dm/ce.Surface ecosystem.
ce.Surface still listens to 'change'.
ve.init.mw.ViewPageTarget.js:
* Rename onSurfaceModelTransact to clearSaveDialogDiff and bind it to
the document's transact event instead
* Rename onSurfaceModelChange to checkForWikitextWarning and bind it
to the surface's transact event. This is needed because the function
inspects the surface's selection, which isn't yet in a consistent
state when the document's transact event fires
ve.ui.MWReferenceDialog.js:
* Rename onSurfaceChange to onDocumentTransact and rebind accordingly
ve.ce.ProtectedNode.js:
* Get rid of onSurfaceModelChange
* Instead, bind positionPhantoms to the document's transact event
directly, and only bind it while phantoms are visible
ve.ui.Context.js:
* Rename onChange to onModelSelect and rebind accordingly
* Rename afterChange to afterModelSelect
* Drop check for undefined selection, no longer needed now that we're
listening to a finer-grained event
ve.ce.Surface.test.js:
* Listen to 'select' instead of 'change'
Change-Id: Ifeb1a1fc5427696f2aae5441d4b54dde366793e0
It was previously emitted before the selection was updated and with the
old selection as a parameter. Instead, emit it afterwards, and make sure
it's emitted even if the selection changes because it was translated
for a transaction.
Also correct its event documentation, which seems to have been copied
from a UI class somewhere.
Change-Id: I521eff0095959572587c0ecffd24dbf322e12d82
Move selection change handling (closing the popup if open, and updating
the context toolbar) to .afterChange(). Every time .onChange() detects
a selection change, it schedules a call to afterChange(). These calls
are batched so that multiple selection changes in the same tick cause
afterChange() to be called only once.
Deferring these updates causes them to no longer occur while a 'change'
event is being emitted. This means that if an inspectors' close handler
calls .change(), that call is now no longer nested inside another
.change() call and doesn't run afoul of any render locks set by the
caller of the outer .change().
Bug: 54675
Change-Id: Iae2f41a83b5d64251a54e42303100e84a5c25561
AnnotationInspector changes the selection from both its open and close
handlers, which can cause recursive calls to .hide() and .update()
Change-Id: Ic334f9b8b335fe1aaac2dc98dc6ea9fd9d5707ff
Update checks if there's actually a context menu to show. We also need
to pass through the parameters for show.
This was causing the last-shown context menu to appears after resizing
an inline image (which has no context menu).
Change-Id: I8f46f71e2fba6896fe10054f0d2a679c6f23eb9c
Both the resize handles and the size label position themselves
using $resizable's relative offset, so we can optimise by
caching that result.
Change-Id: Ic225b15cfcece8d5c2e782e1e667d854f805c6fb
Because it can change. Currently the resize label is not
positioned correctly if you use three of four resize handles.
Change-Id: I1a28bc57fda1097c94047fd7690ad8d403cdd478
Instead use OO directly. Also remove ve.createObject, which is
unused now that ve.Registry and ve.Factory have been moved to oojs.
Change-Id: I3470b6660107ddd0bdf4a43c50d191a1bb1cc4d8
Instead of using @emits in both, use our custom @fires in
production (JSDuck 4), and in the future it'll just naturally
use the native one.
This way we can also index oojs without issues, which seems to
have started using @fires already.
Change-Id: I7c3b56dd112626d57fa87ab995d205fb782a0149
The previous recursion "guard" relied on the recursion to occur for
the function to work correctly, which was very confusing. Additionally,
it didn't actually work: if the inspector's onClose handler changed
the selection (which is common), .hide() would recurse and the recursion
guard didn't catch this (inspector wasn't undefined yet). Fortunately
all that did was call .close() on the inspector again, which was caught
by .close()'s own recursion guard.
Instead, simply use this.hiding as a recursion guard, and refactor the
function so it doesn't do two different things depending on whether it's
expecting recursion or not.
Change-Id: I09eb9229530468ee319ca53b730784a3f632375d