tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 2611e042756c377114b9a36d0692868611a0fcfb
parent 7de6069b192fedf00e5a25031dfa8d62e7043e9f
Author: Lee Salzman <lsalzman@mozilla.com>
Date:   Thu, 16 Oct 2025 21:53:55 +0000

Bug 1994806 - Better RecordedFilterNodeSetAttribute bool serialization. r=aosmond

Differential Revision: https://phabricator.services.mozilla.com/D268936

Diffstat:
Mgfx/2d/RecordedEventImpl.h | 25++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/gfx/2d/RecordedEventImpl.h b/gfx/2d/RecordedEventImpl.h @@ -1743,13 +1743,23 @@ class RecordedFilterNodeSetAttribute }; template <typename T> + void WritePayload(const T& aValue) { + mPayload.Assign(reinterpret_cast<const uint8_t*>(&aValue), sizeof(T)); + } + + void WritePayload(const bool& aValue) { + uint8_t data = aValue ? 1 : 0; + mPayload.Assign(&data, 1); + } + + template <typename T> RecordedFilterNodeSetAttribute(FilterNode* aNode, uint32_t aIndex, T aArgument, ArgType aArgType) : RecordedEventDerived(FILTERNODESETATTRIBUTE), mNode(aNode), mIndex(aIndex), mArgType(aArgType) { - mPayload.Assign(reinterpret_cast<const uint8_t*>(&aArgument), sizeof(T)); + WritePayload(aArgument); } RecordedFilterNodeSetAttribute(FilterNode* aNode, uint32_t aIndex, @@ -4440,11 +4450,6 @@ inline void RecordedMaskSurface::OutputSimpleEventInfo( OutputSimplePatternInfo(mPattern, aStringStream); } -template <typename T> -void ReplaySetAttribute(FilterNode* aNode, uint32_t aIndex, T aValue) { - aNode->SetAttribute(aIndex, aValue); -} - inline bool RecordedFilterNodeSetAttribute::PlayEvent( Translator* aTranslator) const { FilterNode* node = aTranslator->LookupFilterNode(mNode); @@ -4452,16 +4457,18 @@ inline bool RecordedFilterNodeSetAttribute::PlayEvent( return false; } -#define REPLAY_SET_ATTRIBUTE(type, argtype) \ +#define REPLAY_SET_ATTRIBUTE_CAST(type, cast, argtype) \ case ARGTYPE_##argtype: \ if (mPayload.size() < sizeof(type)) { \ return false; \ } \ - ReplaySetAttribute(node, mIndex, *(type*)mPayload.data()); \ + node->SetAttribute(mIndex, cast(*(type*)mPayload.data())); \ break +#define REPLAY_SET_ATTRIBUTE(type, argtype) \ + REPLAY_SET_ATTRIBUTE_CAST(type, , argtype) switch (mArgType) { - REPLAY_SET_ATTRIBUTE(bool, BOOL); + REPLAY_SET_ATTRIBUTE_CAST(uint8_t, bool, BOOL); REPLAY_SET_ATTRIBUTE(uint32_t, UINT32); REPLAY_SET_ATTRIBUTE(Float, FLOAT); REPLAY_SET_ATTRIBUTE(Size, SIZE);