You're correct about the fact that shallow, preferrably one-level selectors are preferable - at least from the performance perspective, at least in theory. However in most cases rendering engine optimizations offset the otherwise miniscule performance overhead.
This is when ease of maintenance, readability and size of the stylesheet kicks in. Reduced specificity allows to recycle "partial" classes - if you look at the rendered markup, .ui-dialog will have a whole bunch of other classes applied to it:
ui-dialog ui-widget ui-widget-content ui-corner-all ui-front ui-draggable ui-resizable
Would it have been preferable to instead have all the properties applied in one rule? Definitely not from the developer point of view, that approach would have made it into a maintenance nightmare. Imagine changing a single presentational property and then having to backdate it to all "specific" rules like in your example!
The reasoning for qualifying the ansector selector (e.g. .ui-dialog .ui-dialog-content) is a lot more trivial, if not immediately obvious - to increase specificity of these selectors. For instance, .ui-helper-reset class basically anulls any previously set style since the rule is declared at the bottom of the css file:
.ui-helper-reset {
border: 0 none;
font-size: 100%;
line-height: 1.3;
list-style: none outside none;
margin: 0;
outline: 0 none;
padding: 0;
text-decoration: none;
}
To override any of those properties, a higher-specificity selector has to be used.
Personally I dislike this pattern - and I hope that code consistency contributed more to the reasoning behind such class structure.
.ui-dialogtakes up about 10 bytes? 10 bytes x 1 million downloads = 9 megabytes