tor-browser

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

commit fcd48a7b01e85ecdd92ec70de434aa63852d891f
parent 0b41720533a6c8c02ba0d8360956c59e2eda3536
Author: Lee Salzman <lsalzman@mozilla.com>
Date:   Thu, 16 Oct 2025 19:39:54 +0000

Bug 1994806 - Better RecordedFilterNodeSetAttribute bool serialization. r=aosmond

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

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

diff --git a/gfx/2d/RecordedEventImpl.h b/gfx/2d/RecordedEventImpl.h @@ -1743,13 +1743,24 @@ class RecordedFilterNodeSetAttribute }; template <typename T> + void WritePayload(const T& aValue) { + mPayload.Assign(reinterpret_cast<const uint8_t*>(&aValue), sizeof(T)); + } + + template <> + 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 +4451,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 +4458,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);