Ejemplo n.º 1
0
css_error css__cascade_border_spacing(uint32_t opv, css_style *style, 
		css_select_state *state)
{
	uint16_t value = CSS_BORDER_SPACING_INHERIT;
	css_fixed hlength = 0;
	css_fixed vlength = 0;
	uint32_t hunit = UNIT_PX;
	uint32_t vunit = UNIT_PX;

	if (isInherit(opv) == false) {
		value = CSS_BORDER_SPACING_SET;
		hlength = *((css_fixed *) style->bytecode);
		advance_bytecode(style, sizeof(hlength));
		hunit = *((uint32_t *) style->bytecode);
		advance_bytecode(style, sizeof(hunit));

		vlength = *((css_fixed *) style->bytecode);
		advance_bytecode(style, sizeof(vlength));
		vunit = *((uint32_t *) style->bytecode);
		advance_bytecode(style, sizeof(vunit));
	}

	hunit = css__to_css_unit(hunit);
	vunit = css__to_css_unit(vunit);

	if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
			isInherit(opv))) {
		return set_border_spacing(state->computed, value,
				hlength, hunit, vlength, vunit);
	}

	return CSS_OK;
}
Ejemplo n.º 2
0
css_error css__cascade_pitch(uint32_t opv, css_style *style, 
		css_select_state *state)
{
	css_fixed freq = 0;
	uint32_t unit = UNIT_HZ;

	if (isInherit(opv) == false) {
		switch (getValue(opv)) {
		case PITCH_FREQUENCY:
			freq = *((css_fixed *) style->bytecode);
			advance_bytecode(style, sizeof(freq));
			unit = *((uint32_t *) style->bytecode);
			advance_bytecode(style, sizeof(unit));
			break;
		case PITCH_X_LOW:
		case PITCH_LOW:
		case PITCH_MEDIUM:
		case PITCH_HIGH:
		case PITCH_X_HIGH:
			/** \todo convert to public values */
			break;
		}
	}

	unit = css__to_css_unit(unit);

	if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
			isInherit(opv))) {
		/** \todo pitch */
	}

	return CSS_OK;
}
Ejemplo n.º 3
0
css_error css__cascade_color(uint32_t opv, css_style *style, 
		css_select_state *state)
{
	bool inherit = isInherit(opv);
	uint16_t value = CSS_COLOR_INHERIT;
	css_color color = 0;

	if (inherit == false) {
		switch (getValue(opv)) {
		case COLOR_TRANSPARENT:
			value = CSS_COLOR_COLOR;
			break;
		case COLOR_CURRENT_COLOR:
			/* color: currentColor always computes to inherit */
			value = CSS_COLOR_INHERIT;
			inherit = true;
			break;
		case COLOR_SET:
			value = CSS_COLOR_COLOR;
			color = *((css_color *) style->bytecode);
			advance_bytecode(style, sizeof(color));
			break;
		}
	}

	if (css__outranks_existing(getOpcode(opv), isImportant(opv), state, 
			inherit)) {
		return set_color(state->computed, value, color);
	}

	return CSS_OK;
}
Ejemplo n.º 4
0
css_error css__cascade_azimuth(uint32_t opv, css_style *style,
		 css_select_state *state)
{
	css_fixed val = 0;
	uint32_t unit = UNIT_DEG;

	if (isInherit(opv) == false) {
		switch (getValue(opv) & ~AZIMUTH_BEHIND) {
		case AZIMUTH_ANGLE:
			val = *((css_fixed *) style->bytecode);
			advance_bytecode(style, sizeof(val));
			unit = *((uint32_t *) style->bytecode);
			advance_bytecode(style, sizeof(unit));
			break;
		case AZIMUTH_LEFTWARDS:
		case AZIMUTH_RIGHTWARDS:
		case AZIMUTH_LEFT_SIDE:
		case AZIMUTH_FAR_LEFT:
		case AZIMUTH_LEFT:
		case AZIMUTH_CENTER_LEFT:
		case AZIMUTH_CENTER:
		case AZIMUTH_CENTER_RIGHT:
		case AZIMUTH_RIGHT:
		case AZIMUTH_FAR_RIGHT:
		case AZIMUTH_RIGHT_SIDE:
			/** \todo azimuth values */
			break;
		}

		/** \todo azimuth behind */
	}

	unit = css__to_css_unit(unit);

	if (css__outranks_existing(getOpcode(opv), isImportant(opv), state, 
			isInherit(opv))) {
		/** \todo set computed azimuth */
	}

	return CSS_OK;
}
Ejemplo n.º 5
0
css_error css__cascade_volume(uint32_t opv, css_style *style,
                              css_select_state *state)
{
    css_fixed val = 0;
    uint32_t unit = UNIT_PCT;

    if (isInherit(opv) == false) {
        switch (getValue(opv)) {
        case VOLUME_NUMBER:
            val = *((css_fixed *) style->bytecode);
            advance_bytecode(style, sizeof(val));
            break;
        case VOLUME_DIMENSION:
            val = *((css_fixed *) style->bytecode);
            advance_bytecode(style, sizeof(val));
            unit = *((uint32_t *) style->bytecode);
            advance_bytecode(style, sizeof(unit));
            break;
        case VOLUME_SILENT:
        case VOLUME_X_SOFT:
        case VOLUME_SOFT:
        case VOLUME_MEDIUM:
        case VOLUME_LOUD:
        case VOLUME_X_LOUD:
            /** \todo convert to public values */
            break;
        }
    }

    unit = css__to_css_unit(unit);

    if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
                               isInherit(opv))) {
        /** \todo volume */
    }

    return CSS_OK;
}
Ejemplo n.º 6
0
css_error css__cascade_opacity(uint32_t opv, css_style *style, 
		css_select_state *state)
{
	uint16_t value = CSS_OPACITY_INHERIT;
	css_fixed opacity = 0;

	if (isInherit(opv) == false) {
		value = CSS_Z_INDEX_SET;

		opacity = *((css_fixed *) style->bytecode);
		advance_bytecode(style, sizeof(opacity));
	}

	if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
			isInherit(opv))) {
		return set_opacity(state->computed, value, opacity);
	}

	return CSS_OK;
}
Ejemplo n.º 7
0
css_error css__cascade_font_family(uint32_t opv, css_style *style, 
		css_select_state *state)
{
	uint16_t value = CSS_FONT_FAMILY_INHERIT;
	lwc_string **fonts = NULL;
	uint32_t n_fonts = 0;

	if (isInherit(opv) == false) {
		uint32_t v = getValue(opv);

		while (v != FONT_FAMILY_END) {
			lwc_string *font = NULL;
			lwc_string **temp;

			switch (v) {
			case FONT_FAMILY_STRING:
			case FONT_FAMILY_IDENT_LIST:
				css__stylesheet_string_get(style->sheet, 
					*((css_code_t *) style->bytecode), 
					&font);
				advance_bytecode(style, sizeof(css_code_t));
				break;
			case FONT_FAMILY_SERIF:
				if (value == CSS_FONT_FAMILY_INHERIT)
					value = CSS_FONT_FAMILY_SERIF;
				break;
			case FONT_FAMILY_SANS_SERIF:
				if (value == CSS_FONT_FAMILY_INHERIT)
					value = CSS_FONT_FAMILY_SANS_SERIF;
				break;
			case FONT_FAMILY_CURSIVE:
				if (value == CSS_FONT_FAMILY_INHERIT)
					value = CSS_FONT_FAMILY_CURSIVE;
				break;
			case FONT_FAMILY_FANTASY:
				if (value == CSS_FONT_FAMILY_INHERIT)
					value = CSS_FONT_FAMILY_FANTASY;
				break;
			case FONT_FAMILY_MONOSPACE:
				if (value == CSS_FONT_FAMILY_INHERIT)
					value = CSS_FONT_FAMILY_MONOSPACE;
				break;
			}

			/* Only use family-names which occur before the first
			 * generic-family. Any values which occur after the
			 * first generic-family are ignored. */
			/** \todo Do this at bytecode generation time? */
			if (value == CSS_FONT_FAMILY_INHERIT && font != NULL) {
				temp = state->computed->alloc(fonts, 
					(n_fonts + 1) * sizeof(lwc_string *), 
					state->computed->pw);
				if (temp == NULL) {
					if (fonts != NULL) {
						state->computed->alloc(fonts, 0,
							state->computed->pw);
					}
					return CSS_NOMEM;
				}

				fonts = temp;

				fonts[n_fonts] = font;

				n_fonts++;
			}

			v = *((uint32_t *) style->bytecode);
			advance_bytecode(style, sizeof(v));
		}
	}

	/* Terminate array with blank entry, if needed */
	if (n_fonts > 0) {
		lwc_string **temp;

		temp = state->computed->alloc(fonts, 
				(n_fonts + 1) * sizeof(lwc_string *), 
				state->computed->pw);
		if (temp == NULL) {
			state->computed->alloc(fonts, 0, state->computed->pw);
			return CSS_NOMEM;
		}

		fonts = temp;

		fonts[n_fonts] = NULL;
		
		if (value == CSS_FONT_FAMILY_INHERIT) {
			/* The stylesheet doesn't specify a generic family,
			 * but it has specified named fonts.
			 * Fall back to the user agent's default family.
			 * We don't want to inherit, because that will 
			 * incorrectly overwrite the named fonts list too.
			 */
			css_hint hint;
			css_error error;
			
			error = state->handler->ua_default_for_property(
					state->pw, CSS_PROP_FONT_FAMILY, &hint);
			if (error == CSS_OK) {
				lwc_string **item;

				value = hint.status;
		
				for (item = hint.data.strings; 
						item != NULL && (*item) != NULL;
						item++) {
					lwc_string_unref(*item);
				}

				if (hint.data.strings != NULL) {
					state->computed->alloc(
							hint.data.strings, 
							0, state->computed->pw);
				}
			}

			if (value == CSS_FONT_FAMILY_INHERIT) {
				/* No sane UA default: assume sans-serif */
				value = CSS_FONT_FAMILY_SANS_SERIF;
			}
		}
	}

	if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
			isInherit(opv))) {
		css_error error;

		error = set_font_family(state->computed, value, fonts);
		if (error != CSS_OK && n_fonts > 0)
			state->computed->alloc(fonts, 0, state->computed->pw);

		return error;
	} else {
		if (n_fonts > 0)
			state->computed->alloc(fonts, 0, state->computed->pw);
	}

	return CSS_OK;
}
Ejemplo n.º 8
0
css_error css__cascade_cursor(uint32_t opv, css_style *style,
                              css_select_state *state)
{
    uint16_t value = CSS_CURSOR_INHERIT;
    lwc_string **uris = NULL;
    uint32_t n_uris = 0;

    if (isInherit(opv) == false) {
        uint32_t v = getValue(opv);

        while (v == CURSOR_URI) {
            lwc_string *uri;
            lwc_string **temp;

            css__stylesheet_string_get(style->sheet,
                                       *((css_code_t *) style->bytecode),
                                       &uri);
            advance_bytecode(style, sizeof(css_code_t));

            temp = realloc(uris,
                           (n_uris + 1) * sizeof(lwc_string *));
            if (temp == NULL) {
                if (uris != NULL) {
                    free(uris);
                }
                return CSS_NOMEM;
            }

            uris = temp;

            uris[n_uris] = uri;

            n_uris++;

            v = *((uint32_t *) style->bytecode);
            advance_bytecode(style, sizeof(v));
        }

        switch (v) {
        case CURSOR_AUTO:
            value = CSS_CURSOR_AUTO;
            break;
        case CURSOR_CROSSHAIR:
            value = CSS_CURSOR_CROSSHAIR;
            break;
        case CURSOR_DEFAULT:
            value = CSS_CURSOR_DEFAULT;
            break;
        case CURSOR_POINTER:
            value = CSS_CURSOR_POINTER;
            break;
        case CURSOR_MOVE:
            value = CSS_CURSOR_MOVE;
            break;
        case CURSOR_E_RESIZE:
            value = CSS_CURSOR_E_RESIZE;
            break;
        case CURSOR_NE_RESIZE:
            value = CSS_CURSOR_NE_RESIZE;
            break;
        case CURSOR_NW_RESIZE:
            value = CSS_CURSOR_NW_RESIZE;
            break;
        case CURSOR_N_RESIZE:
            value = CSS_CURSOR_N_RESIZE;
            break;
        case CURSOR_SE_RESIZE:
            value = CSS_CURSOR_SE_RESIZE;
            break;
        case CURSOR_SW_RESIZE:
            value = CSS_CURSOR_SW_RESIZE;
            break;
        case CURSOR_S_RESIZE:
            value = CSS_CURSOR_S_RESIZE;
            break;
        case CURSOR_W_RESIZE:
            value = CSS_CURSOR_W_RESIZE;
            break;
        case CURSOR_TEXT:
            value = CSS_CURSOR_TEXT;
            break;
        case CURSOR_WAIT:
            value = CSS_CURSOR_WAIT;
            break;
        case CURSOR_HELP:
            value = CSS_CURSOR_HELP;
            break;
        case CURSOR_PROGRESS:
            value = CSS_CURSOR_PROGRESS;
            break;
        }
    }

    /* Terminate array with blank entry, if needed */
    if (n_uris > 0) {
        lwc_string **temp;

        temp = realloc(uris,
                       (n_uris + 1) * sizeof(lwc_string *));
        if (temp == NULL) {
            free(uris);
            return CSS_NOMEM;
        }

        uris = temp;

        uris[n_uris] = NULL;
    }

    if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
                               isInherit(opv))) {
        css_error error;

        error = set_cursor(state->computed, value, uris);
        if (error != CSS_OK && n_uris > 0)
            free(uris);

        return error;
    } else {
        if (n_uris > 0)
            free(uris);
    }

    return CSS_OK;
}