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_line_height(uint32_t opv, css_style *style,
  18.                 css_select_state *state)
  19. {
  20.         uint16_t value = CSS_LINE_HEIGHT_INHERIT;
  21.         css_fixed val = 0;
  22.         uint32_t unit = UNIT_PX;
  23.  
  24.         if (isInherit(opv) == false) {
  25.                 switch (getValue(opv)) {
  26.                 case LINE_HEIGHT_NUMBER:
  27.                         value = CSS_LINE_HEIGHT_NUMBER;
  28.                         val = *((css_fixed *) style->bytecode);
  29.                         advance_bytecode(style, sizeof(val));
  30.                         break;
  31.                 case LINE_HEIGHT_DIMENSION:
  32.                         value = CSS_LINE_HEIGHT_DIMENSION;
  33.                         val = *((css_fixed *) style->bytecode);
  34.                         advance_bytecode(style, sizeof(val));
  35.                         unit = *((uint32_t *) style->bytecode);
  36.                         advance_bytecode(style, sizeof(unit));
  37.                         break;
  38.                 case LINE_HEIGHT_NORMAL:
  39.                         value = CSS_LINE_HEIGHT_NORMAL;
  40.                         break;
  41.                 }
  42.         }
  43.  
  44.         unit = css__to_css_unit(unit);
  45.  
  46.         if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
  47.                         isInherit(opv))) {
  48.                 return set_line_height(state->computed, value, val, unit);
  49.         }
  50.  
  51.         return CSS_OK;
  52. }
  53.  
  54. css_error css__set_line_height_from_hint(const css_hint *hint,
  55.                 css_computed_style *style)
  56. {
  57.         return set_line_height(style, hint->status,
  58.                         hint->data.length.value, hint->data.length.unit);
  59. }
  60.  
  61. css_error css__initial_line_height(css_select_state *state)
  62. {
  63.         return set_line_height(state->computed, CSS_LINE_HEIGHT_NORMAL,
  64.                         0, CSS_UNIT_PX);
  65. }
  66.  
  67. css_error css__compose_line_height(const css_computed_style *parent,
  68.                 const css_computed_style *child,
  69.                 css_computed_style *result)
  70. {
  71.         css_fixed length = 0;
  72.         css_unit unit = CSS_UNIT_PX;
  73.         uint8_t type = get_line_height(child, &length, &unit);
  74.  
  75.         if (type == CSS_LINE_HEIGHT_INHERIT) {
  76.                 type = get_line_height(parent, &length, &unit);
  77.         }
  78.  
  79.         return set_line_height(result, type, length, unit);
  80. }
  81.  
  82.