mediawiki-extensions-Visual.../modules/ve/ui/styles
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
..
images Cleanup code icon 2013-07-26 13:07:40 -07:00
ve.ui.Context.css Tool and context menu size and alignment fixes 2013-07-10 01:33:37 +00:00
ve.ui.css The great directory split of 2013 2013-07-02 20:51:38 -07:00
ve.ui.Dialog.css Ensure ve-ui-panelLayout-scrollable is actually scrollable 2013-07-20 13:21:05 +02:00
ve.ui.Element.css Stack panel, element mixins, cleanup 2013-03-28 12:40:01 -07:00
ve.ui.Frame.css Transplant CSS from the main document to each iframe 2013-07-09 16:13:28 -07:00
ve.ui.Icons-raster.css Merge "Code annotation icon" 2013-07-26 19:33:42 +00:00
ve.ui.Icons-vector.css Merge "Code annotation icon" 2013-07-26 19:33:42 +00:00
ve.ui.Inspector.css Remove dead CSS code 2013-07-10 01:32:57 +00:00
ve.ui.Layout.css Add padded option to layouts 2013-07-17 19:10:44 +00:00
ve.ui.Surface.css Make local overlays local to surface and remove insane z-indexes 2013-07-02 19:35:43 +00:00
ve.ui.Tool.css Tool and context menu size and alignment fixes 2013-07-10 01:33:37 +00:00
ve.ui.Toolbar.css ve.ui.Toolbar: Refactor floating logic for performance 2013-07-30 01:47:54 +02:00
ve.ui.Widget.css Reference dialog commingling 2013-07-18 14:14:14 -07:00
ve.ui.Window.css Transplant CSS from the main document to each iframe 2013-07-09 16:13:28 -07:00