Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * This file is part of LibCSS
  3.  * Licensed under the MIT License,
  4.  *                http://www.opensource.org/licenses/mit-license.php
  5.  * Copyright 2009 John-Mark Bell <jmb@netsurf-browser.org>
  6.  */
  7.  
  8. #include "bytecode/bytecode.h"
  9. #include "bytecode/opcodes.h"
  10. #include "select/propset.h"
  11. #include "select/propget.h"
  12. #include "utils/utils.h"
  13.  
  14. #include "select/properties/properties.h"
  15. #include "select/properties/helpers.h"
  16.  
  17. css_error css__cascade_border_spacing(uint32_t opv, css_style *style,
  18.                 css_select_state *state)
  19. {
  20.         uint16_t value = CSS_BORDER_SPACING_INHERIT;
  21.         css_fixed hlength = 0;
  22.         css_fixed vlength = 0;
  23.         uint32_t hunit = UNIT_PX;
  24.         uint32_t vunit = UNIT_PX;
  25.  
  26.         if (isInherit(opv) == false) {
  27.                 value = CSS_BORDER_SPACING_SET;
  28.                 hlength = *((css_fixed *) style->bytecode);
  29.                 advance_bytecode(style, sizeof(hlength));
  30.                 hunit = *((uint32_t *) style->bytecode);
  31.                 advance_bytecode(style, sizeof(hunit));
  32.  
  33.                 vlength = *((css_fixed *) style->bytecode);
  34.                 advance_bytecode(style, sizeof(vlength));
  35.                 vunit = *((uint32_t *) style->bytecode);
  36.                 advance_bytecode(style, sizeof(vunit));
  37.         }
  38.  
  39.         hunit = css__to_css_unit(hunit);
  40.         vunit = css__to_css_unit(vunit);
  41.  
  42.         if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
  43.                         isInherit(opv))) {
  44.                 return set_border_spacing(state->computed, value,
  45.                                 hlength, hunit, vlength, vunit);
  46.         }
  47.  
  48.         return CSS_OK;
  49. }
  50.  
  51. css_error css__set_border_spacing_from_hint(const css_hint *hint,
  52.                 css_computed_style *style)
  53. {
  54.         return set_border_spacing(style, hint->status,
  55.                 hint->data.position.h.value, hint->data.position.h.unit,
  56.                 hint->data.position.v.value, hint->data.position.v.unit);
  57. }
  58.  
  59. css_error css__initial_border_spacing(css_select_state *state)
  60. {
  61.         return set_border_spacing(state->computed, CSS_BORDER_SPACING_SET,
  62.                         0, CSS_UNIT_PX, 0, CSS_UNIT_PX);
  63. }
  64.  
  65. css_error css__compose_border_spacing(const css_computed_style *parent,
  66.                 const css_computed_style *child,
  67.                 css_computed_style *result)
  68. {
  69.         css_fixed hlength = 0, vlength = 0;
  70.         css_unit hunit = CSS_UNIT_PX, vunit = CSS_UNIT_PX;
  71.         uint8_t type = get_border_spacing(child, &hlength, &hunit,
  72.                         &vlength, &vunit);
  73.  
  74.         if ((child->uncommon == NULL && parent->uncommon != NULL) ||
  75.                         type == CSS_BORDER_SPACING_INHERIT ||
  76.                         (child->uncommon != NULL && result != child)) {
  77.                 if ((child->uncommon == NULL && parent->uncommon != NULL) ||
  78.                                 type == CSS_BORDER_SPACING_INHERIT) {
  79.                         type = get_border_spacing(parent,
  80.                                         &hlength, &hunit, &vlength, &vunit);
  81.                 }
  82.  
  83.                 return set_border_spacing(result, type, hlength, hunit,
  84.                                 vlength, vunit);
  85.         }
  86.  
  87.         return CSS_OK;
  88. }
  89.  
  90.