Is D flip flop equivalent to frequency mixer (difference frequency) for square waves?
An XOR gate makes a good mixer, producing the sum and difference of two input squarewaves. If you only want the difference term, then the output must be low pass filtered, so is then in the analogue domain. This method is capable of producing a good difference signal even when the high frequency signals have jitter on them, due to the output low pass filter. If you want a digital output, you must follow the low pass filter with a Schmitt input buffer.

A D-latch taking one signal as D and the other as clock can produce a frequency difference of sorts, but it would be very susceptible to phase jitter on the inputs, when the two input signals are in approximately the same phase, and its setup and hold times are being violated. With clean signals, you may get reasonable transitions. With jittery signals, you would get many random up/down output transitions instead of one clean one at each change of output state.

What I've just written about a D-latch is true if the two input signals are asynchronous. In the specific case of them both being PWM signals generated from the same microcontroller by internal PWM counters, this method of generation could mean that the signals will always meet setup and hold times at the D-latch, which would make it work perfectly.