gecko-dev/layout/base
Kris Maglione 8d585408dc Bug 1473631: Part 0b - Add helper for registering instance methods as pref callbacks. r=njn
I also tried to avoid this change but, again, given the number of times I was
repeating the same pattern of defining a static method just to forward a
callback to an instance method, decided it was probably necessary. Without an
easy way to do this, people are more likely to register observers rather than
callbacks, for which we'll wind up paying a continued memory and performance
penalty.

This patch adds a helper which creates a type-safe preference callback
function which forwards calls to an instance method on its closure object.

The implementation is somewhat complicated, mainly due to the constraint that
unregistering a callback requires passing the exact same function pointer that
was used to register it. The patch achieves this by creating the callback
function as a template, with the method pointer as a template parameter. As
long as the Register and Unregister calls happen in the same translation unit,
the same template instance is guaranteed to be used for both.

The main difficulty is that, until C++ 17, there's no way match a value as a
template parameter unless you know its complete type, or can at least compute
its complete type based on earlier template parameters. That means that we
need a macro to extract the type of the method, and construct the template
with the full set of explicit parameters.

MozReview-Commit-ID: 10N3R2SRtPc

--HG--
extra : rebase_source : 7d0a8ddeb77e01d4a6f421459514e93bc0875598
2018-07-13 18:54:11 -07:00
..
crashtests Bug 1466638 - Implement support for ContainerLayerParameters::mOffset in nsDisplayImageContainer. r=mstange 2018-07-09 16:11:08 +12:00
doc Bug 1432017 - Remove AccessibleCaretEventHub::PostScrollState. r=mats 2018-02-23 22:05:49 +08:00
gtest Bug 1465585: Switch from mozilla::Move to std::move. r=froydnj 2018-06-01 10:45:27 +02:00
tests Bug 1462983: Check for redundant "loaded" messages from opened window, in test_bug607529.html. r=bz 2018-07-13 08:38:52 -07:00
AccessibleCaret.cpp
AccessibleCaret.h Bug 1455055 part 1. Convert nsIDOMEventListener to taking an Event, not an nsIDOMEvent. r=masayuki 2018-04-20 00:49:29 -04:00
AccessibleCaretEventHub.cpp Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
AccessibleCaretEventHub.h Bug 1387143 part 1. Stop using nsISelection in nsISelectionListener. r=mats 2018-05-08 13:52:35 -04:00
AccessibleCaretLogger.h
AccessibleCaretManager.cpp Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
AccessibleCaretManager.h Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
ArenaObjectID.h
ArenaRefPtr.h Bug 1465585: Switch from mozilla::Move to std::move. r=froydnj 2018-06-01 10:45:27 +02:00
ArenaRefPtrInlines.h Bug 1447483: Merge nsStyleContext and ServoStyleContext, rename to ComputedStyle. r=jwatt on a CLOSED TREE 2018-03-22 20:06:24 +01:00
AutoProfilerStyleMarker.h Bug 1465585: Switch from mozilla::Move to std::move. r=froydnj 2018-06-01 10:45:27 +02:00
CaretAssociationHint.h
FrameProperties.h
GeometryUtils.cpp Bug 1449670, part 1 - Convert IsNodeOfType(nsINode::eTEXT) to IsText(). r=bz 2018-04-12 15:41:00 -07:00
GeometryUtils.h
LayoutConstants.h Bug 1434478 part 4 - Factor out constants like NS_UNCONSTRAINEDSIZE so they can be used in headers without needing nsIFrame.h (idempotent patch). r=dholbert 2018-04-10 00:16:58 +02:00
LayoutLogging.cpp
LayoutLogging.h
MobileViewportManager.cpp Bug 1455055 part 1. Convert nsIDOMEventListener to taking an Event, not an nsIDOMEvent. r=masayuki 2018-04-20 00:49:29 -04:00
MobileViewportManager.h Bug 1449631 part 2. Remove nsIDOMEventTarget::RemoveEventListener. r=smaug 2018-04-05 13:42:40 -04:00
OverflowChangedTracker.h
PositionedEventTargeting.cpp Bug 1472523: Part 2 - Avoid unnecessary string copies in preference caches. r=njn 2018-06-30 23:07:30 -07:00
PositionedEventTargeting.h
PresShell.cpp Bug 1471107 - Get rid of assertion and handle the already-unsuppressed displayport case in PresShell. r=kats 2018-07-13 17:31:00 +00:00
PresShell.h Bug 962528 - Update the UI resolution synchronously to avoid painting the UI once at the wrong resolution when moving a window across screens of different resolutions, r=mstange. 2018-07-04 16:31:03 +02:00
PresState.ipdlh Bug 1443954 - Part 3: Add support for RefCounted types to IPDL, r=bz,froydnj,baku 2018-04-10 17:49:48 -04:00
RestyleManager.cpp Bug 1469354: Use the first continuation to get the layout parent style. r=mats 2018-06-25 02:50:44 +02:00
RestyleManager.h Bug 1459529: Remove UPDATE_STYLE. r=heycam 2018-05-15 18:44:29 +02:00
ScrollbarStyles.cpp
ScrollbarStyles.h
ShapeUtils.cpp Backed out 7 changesets (bug 1461046) for permafailing reftest on /reftests/css-invalid/select/select-disabled-fieldset-1.html a=backout 2018-06-02 05:07:03 +03:00
ShapeUtils.h Bug 1468590: Preemptively fix unified build bustage in layout/base. r=emilio 2018-06-13 20:39:58 +00:00
StackArena.cpp Bug 1469769 - Part 6: Replace non-failing NS_NOTREACHED with MOZ_ASSERT_UNREACHABLE. r=froydnj 2018-06-17 22:43:11 -07:00
StackArena.h
StaticPresData.cpp
StaticPresData.h
TouchManager.cpp bug 1429572, touch.target retargeting in shadow DOM, r=masayuki 2018-05-25 18:02:59 +03:00
TouchManager.h
UndisplayedNode.h Bug 1447483: Merge nsStyleContext and ServoStyleContext, rename to ComputedStyle. r=jwatt on a CLOSED TREE 2018-03-22 20:06:24 +01:00
UnitTransforms.h
Units.h Bug 1467873 - Fix FrameMetrics::CalculateCompositedRectInCssPixels(). r=kats 2018-06-09 16:33:26 -04:00
WordMovementType.h
ZoomConstraintsClient.cpp Bug 1455055 part 1. Convert nsIDOMEventListener to taking an Event, not an nsIDOMEvent. r=masayuki 2018-04-20 00:49:29 -04:00
ZoomConstraintsClient.h Bug 1449631 part 2. Remove nsIDOMEventTarget::RemoveEventListener. r=smaug 2018-04-05 13:42:40 -04:00
moz.build Bug 1438026 - Part 4: Remove the old nsPresState code completely, r=baku 2018-04-10 17:49:44 -04:00
nsAutoLayoutPhase.cpp
nsAutoLayoutPhase.h
nsBidi.cpp
nsBidi.h
nsBidiPresUtils.cpp Bug 1453795 - Layout - Initialize member fields in classes/ structures. r=dbaron 2018-07-12 09:42:14 +03:00
nsBidiPresUtils.h Bug 1447483: Merge nsStyleContext and ServoStyleContext, rename to ComputedStyle. r=jwatt on a CLOSED TREE 2018-03-22 20:06:24 +01:00
nsCSSColorUtils.cpp
nsCSSColorUtils.h
nsCSSFrameConstructor.cpp Bug 1473813: Don't make pseudo-elements replaced by content: url(..). r=bz 2018-07-16 18:06:39 +02:00
nsCSSFrameConstructor.h Bug 1472403: Simplify generated image content. r=bz,dholbert 2018-07-16 18:06:38 +02:00
nsCaret.cpp Bug 1455676 part 8. Remove nsIDOMNode usage from layout/. r=qdot 2018-05-29 22:58:48 -04:00
nsCaret.h Bug 1455676 part 8. Remove nsIDOMNode usage from layout/. r=qdot 2018-05-29 22:58:48 -04:00
nsChangeHint.h Bug 1430884 - Throttle nsChangeHint_UpdateContainingBlock on invisible element. r=birtles 2018-06-25 18:29:09 +09:00
nsCompatibility.h
nsCounterManager.cpp Bug 1449404 part 1. Get rid of nsIContent::SetText. r=mccr8 2018-03-28 18:01:46 -04:00
nsCounterManager.h
nsDocumentViewer.cpp Bug 1470930: Use enums for passing arguments for event dispatch. r=smaug 2018-06-26 18:22:06 +02:00
nsFrameManager.cpp Bug 1465585: Switch from mozilla::Move to std::move. r=froydnj 2018-06-01 10:45:27 +02:00
nsFrameManager.h Bug 1461299: Make ESM not point to unbound NAC in the hover / active chain. r=smaug 2018-05-15 10:43:46 +02:00
nsFrameTraversal.cpp Bug 1443672: Adjust a few .cpp files in layout to #include their own header first. r=emilio 2018-03-06 15:59:36 -08:00
nsFrameTraversal.h Bug 1413834 - part 1: Limit frame traversal and getting of next tabindex inside scope owned by document root, r=smaug 2018-01-26 17:47:44 +02:00
nsGenConList.cpp Bug 1414303: Make nsLayoutUtils::CompareTreePosition handle Shadow DOM in a sensible way. r=xidorn 2018-05-14 16:34:45 +02:00
nsGenConList.h Bug 1472443: Make StyleContentType an enum class. r=xidorn 2018-06-30 17:13:07 +02:00
nsIDocumentViewerPrint.h Bug 1449400 part 5 - Remove StyleSetHandle. r=emilio 2018-03-29 22:15:46 +11:00
nsIFrameTraversal.h
nsILayoutDebugger.h
nsILayoutHistoryState.idl Bug 1438026 - Part 3: Replace nsPresState with the new PresState type, r=baku 2018-04-10 17:49:44 -04:00
nsIPercentBSizeObserver.h
nsIPreloadedStyleSheet.idl
nsIPresShell.h Bug 1470267 - Store the visual viewport offset in nsIPresShell. r=botond 2018-07-11 17:24:56 -04:00
nsIPresShellInlines.h
nsIReflowCallback.h
nsIStyleSheetService.idl
nsLayoutDebugger.cpp Bug 1460491 - Part 1: Split nsDisplayItem::mVisibleRect into two members, one for each stated purpose. Gets rid of the save/restore since we no longer modify the building rect. r=jnicol 2018-05-16 15:56:32 +12:00
nsLayoutHistoryState.cpp Bug 1465585: Switch from mozilla::Move to std::move. r=froydnj 2018-06-01 10:45:27 +02:00
nsLayoutUtils.cpp Merge mozilla-central to inbound. a=merge CLOSED TREE 2018-07-12 12:33:01 +03:00
nsLayoutUtils.h Backed out 3 changesets (bug 1459937) for failing crashtest with Assertion failure: (IndexInFlow(aOldParent) < IndexInFlow(aNewParent)) on a CLOSED TREE 2018-07-15 10:06:23 +03:00
nsPresArena.cpp Bug 1467483 - Assert that PresArena is only used on the main thread. r=mattwoodrow 2018-06-07 22:39:11 +02:00
nsPresArena.h Bug 1406727 - Improve diagnostics in BuildDisplayList. r=froydnj 2018-02-06 12:21:31 +13:00
nsPresArenaObjectList.h Bug 1448535 part 2 - Remove arena-related code from style structs. r=emilio 2018-03-29 03:45:18 +11:00
nsPresContext.cpp Bug 1473631: Part 0b - Add helper for registering instance methods as pref callbacks. r=njn 2018-07-13 18:54:11 -07:00
nsPresContext.h Bug 1473631: Part 0b - Add helper for registering instance methods as pref callbacks. r=njn 2018-07-13 18:54:11 -07:00
nsQuoteList.cpp Bug 1472443: Make StyleContentType an enum class. r=xidorn 2018-06-30 17:13:07 +02:00
nsQuoteList.h Bug 1472443: Make StyleContentType an enum class. r=xidorn 2018-06-30 17:13:07 +02:00
nsRefreshDriver.cpp Bug 1475769 - Bail out from nsRefreshDriver::Tick before updating mMostRecentRefresh when the refresh driver is waiting for paint. r=mattwoodrow 2018-07-15 20:19:29 +09:00
nsRefreshDriver.h Bug 1475769 - Bail out from nsRefreshDriver::Tick before updating mMostRecentRefresh when the refresh driver is waiting for paint. r=mattwoodrow 2018-07-15 20:19:29 +09:00
nsStyleChangeList.cpp Bug 1449670, part 1 - Convert IsNodeOfType(nsINode::eTEXT) to IsText(). r=bz 2018-04-12 15:41:00 -07:00
nsStyleChangeList.h Bug 1447828 part 8 - Remove remaining uses of StyleBackendType as well as the type itself. r=emilio 2018-03-29 02:34:34 +11:00
nsStyleSheetService.cpp Bug 1474273 - Add xpc::CurrentNativeGlobal and use it instead of NativeGlobal(JS::CurrentGlobalOrNull(cx)). r=bz 2018-07-11 14:07:02 +02:00
nsStyleSheetService.h Bug 1447828 part 5 - Remove StyleBackendType uses from nsStyleSheetService. r=emilio 2018-03-29 02:34:34 +11:00