Step 1: Recall what determines the texture of igneous rocks.
The texture of an igneous rock is mainly determined by the size of its mineral crystals.
Step 2: Relate crystal size to cooling rate.
- Slow cooling allows crystals to grow larger, producing a coarse-grained texture.
- Rapid cooling forms very small crystals, producing a fine-grained texture.
Hence, the texture mainly depends on the
\[
\boxed{\text{Rate of cooling of magma}.}
\]
Therefore,
\[
\boxed{(B)}
\]
is the correct answer.