How does a wallet use unconfirmed outputs as inputs after unconfirmed transactions?
Is the wallet using unconfirmed outputs as inputs here?


Yes.


  If so, how is it doing this


Except for coinbase transactions, transactions are independent of blocks. A transaction spending an unconfirmed input looks exactly the same as a transaction spending a confirmed input.

It's safe for Bitcoin-Qt to spend unconfirmed change because it knows that the input is valid and will be confirmed at some point (though probably slowly). It would not be safe for Bitcoin-Qt to spend unconfirmed inputs that it did not itself create because they might never confirm, resulting in permanently tied-up funds. (Very old versions of Bitcoin made this mistake, but it was corrected after widespread issues.)


  how can I do it using raw transactions?


You can create the transaction with createrawtransaction normally, but you'll need to give signrawtransaction some extra info about the unconfirmed transaction in its second parameter.