Definition at line 1515 of file style.cpp. References SPIEnum::computed, SPIEnum::inherit, SPIEnum::set, and SPIEnum::value. Referenced by sp_style_merge_from_dying_parent(). { /* We assume that min computed val is 0, contiguous up to max_computed_val, then zero or more other absolute values, then smaller_val then larger_val. */ unsigned const min_computed_val = 0; unsigned const larger_val = smaller_val + 1; g_return_if_fail(min_computed_val < max_computed_val); g_return_if_fail(max_computed_val < smaller_val); if (parent.set && !parent.inherit) { if (!child.set || child.inherit) { child.value = parent.value; child.set = parent.set; // i.e. true child.inherit = parent.inherit; // i.e. false } else if (child.value < smaller_val) { /* Child has absolute value: leave as is. */ } else if ( ( child.value == smaller_val && parent.value == larger_val ) || ( parent.value == smaller_val && child.value == larger_val ) ) { child.set = false; /* * Note that this can result in a change in computed value in the * rare case that the parent's setting was a no-op (i.e. if the * parent's parent's computed value was already ultra-condensed or * ultra-expanded). However, I'd guess that the change is for the * better: I'd guess that if the properties were specified * relatively, then the intent is to counteract parent's effect. * I.e. I believe this is the best code even in that case. */ } else if (child.value == parent.value) { /* Leave as is. */ /** \todo * It's unclear what to do if style and parent specify the same * relative directive (narrower or wider). We can either convert * to absolute specification or coalesce to a single relative * request (of half the strength of the original pair). * * Converting to a single level of relative specification is a * better choice if the newly-unlinked clone is itself cloned to * other contexts (inheriting different font stretchiness): it * would preserve the effect that it will be narrower than * the inherited context in each case. The disadvantage is that * it will ~certainly affect the computed value of the * newly-unlinked clone. */ } else { unsigned const parent_val = parent.computed; child.value = ( child.value == smaller_val ? ( parent_val == min_computed_val ? parent_val : parent_val - 1 ) : ( parent_val == max_computed_val ? parent_val : parent_val + 1 ) ); g_assert(child.value <= max_computed_val); child.inherit = false; g_assert(child.set); } } }
|