mediawiki-extensions-Visual.../modules/ve/ui
Timo Tijhof 14343c7bf7 ve.ui.Toolbar: Refactor floating logic for performance
== Renamed methods ==

* enableFloating  -> enableFloatable
* disableFloating -> disableFloatable
* setPosition     -> float
* resetPosition   -> unfloat

== Scroll and resize event ==

Timeline for scroll event reduced from about half a dozen
"Recalculate style" and various forced "Paint" down to 0.

New timeline for scroll is clean (for me: from ~35 to ~59 fps):
* 1 Event (scroll)
* 1 Composite Layer

The composite layer action is the browser changing the viewport
to a different portion of the document drawing. Exactly the one
thing a simple scroll should do.

Timeline for resize event is still pretty crowded and low fps,
but it has improved. Further improvement would likely be around
using requestAnimation and going outside ve.ui.Toolbar.

== Changes ==

* New: ve.ui.Toolbar#initialize.
  Similar to what surface has. Users of Toolbar should decide
  whether to call enableFloatable, append it to the DOM at some
  point and then call initialize() once.

* Don't compute offset() every time.
  Eliminated by doing it once in #initialize. These 'top' and
  'left' offsets do not change.

* Don't compute outerWidth() and $window.width() every time.
  Reduced by doing it once in #initialize to compute the 'right'
  offset. Updating it only on resize.

* Don't set 'top' every time.
  This is already in the stylesheet. It was never set to anything
  else so the abstraction for it in #float has been removed.
  This also made it obvious that code for "ve-ui-toolbar-bottom"
  was unused and left behind. Tha class was only ever being
  removed from something (never added).
  The one addClass call for it was in a condition that is always
  false ("if top > 0").

* Don't set 'left' every time.
  Eliminated by doing it once in #float.

* Don't set 'right' every time.
  Reduced by no longer doing it on scroll. Done once in #float,
  and on resize after computing the new value for it.

* Remove no-op style operations.
  Wrapped methods in if-floatable, if-floated etc. to reduce a
  fair amount of easily avoided re-paint overhead.

* Avoid double re-paint in mw.ViewPageTarget.
  Though we prevent a lot of redundant re-paints now, whenever
  we do repaint we want to do it in 1 repaint instead of 2.

  ve.ui.Toolbar emits #toolbarPosition, which tells
  mw.ViewPageTarget to update toolbarTracker which would read
  the new $bar style properties and copy them over to the
  $toolbarTracker. However, this read operation forces the browser
  to do an immediate re-paint half-way just for $bar.

  Browsers only repaint when style properties are changed and
  JS has yielded. The exception to this is JS reading style
  properties: in that case the browser is forced to do those
  deferred repaints directly and reflect the new values.

  We can avoid this double repaint by passing the updated values
  as data instead of requiring the receiver to read the DOM (and
  thus a keep the deferred repaint). Now toolbarTracker can use
  them directly whilst the browser hasn't even repainted $bar yet.

== Clean up ==

* Redundant "border-radius: 0". This would reset something, but
  it never does. None of the things it inherits from set a
  border-radius. There is one subclass where toolbar is used
  with a border-radius (".ve-ui-surfaceWidget .ve-ui-toolbar-bar"
  sets a border-radius) which overrides this on purpose, so the
  default of 0 is redundant.

* Pattern "if ( .. ) addClass() else removeClass()" changed to:
  "toggleClass( , .. )"

Bug: 52014
Change-Id: I9be855148962eee068a77fe83e98eb20bbdcfeec
2013-07-30 01:47:54 +02:00
..
actions doc: Clean up spacing that caused <pre> or broken <ul>/<ol> 2013-07-25 04:02:50 +02:00
dialogs Add padded option to layouts 2013-07-17 19:10:44 +00:00
elements doc: Clean up spacing that caused <pre> or broken <ul>/<ol> 2013-07-25 04:02:50 +02:00
inspectors Reset context menu on selection change while inspector is open 2013-07-15 23:51:40 +00:00
layouts Fix for scrollable panels 2013-07-17 17:17:01 -07:00
styles ve.ui.Toolbar: Refactor floating logic for performance 2013-07-30 01:47:54 +02:00
tools Code annotation button 2013-07-26 12:36:34 -07:00
widgets ve.ui.Toolbar: Refactor floating logic for performance 2013-07-30 01:47:54 +02:00
ve.ui.Action.js
ve.ui.ActionFactory.js
ve.ui.CommandRegistry.js
ve.ui.Context.js ve.ui.Toolbar: Refactor floating logic for performance 2013-07-30 01:47:54 +02:00
ve.ui.Dialog.js Single-click insertion 2013-07-15 23:42:56 +00:00
ve.ui.DialogFactory.js
ve.ui.Frame.js Reuse the rules variable 2013-07-10 17:21:07 -07:00
ve.ui.Inspector.js Transplant CSS from the main document to each iframe 2013-07-09 16:13:28 -07:00
ve.ui.InspectorFactory.js
ve.ui.js ve.ui.ViewRegistry annihilation 2013-06-26 16:52:10 -07:00
ve.ui.Layout.js
ve.ui.Surface.js ve.ui.Toolbar: Refactor floating logic for performance 2013-07-30 01:47:54 +02:00
ve.ui.Tool.js ve.ui.ViewRegistry annihilation 2013-06-26 16:52:10 -07:00
ve.ui.Toolbar.js ve.ui.Toolbar: Refactor floating logic for performance 2013-07-30 01:47:54 +02:00
ve.ui.ToolFactory.js Disable inspection of references with unknown contents 2013-06-27 20:34:32 -07:00
ve.ui.Trigger.js jshint: Fix trailing comma 2013-06-05 13:00:49 +02:00
ve.ui.TriggerRegistry.js
ve.ui.Widget.js
ve.ui.Window.js Transplant CSS from the main document to each iframe 2013-07-09 16:13:28 -07:00
ve.ui.WindowSet.js Don't depend on iframe load events 2013-06-25 23:12:58 +00:00