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_z_index(uint32_t opv, css_style *style,
  18.                 css_select_state *state)
  19. {
  20.         uint16_t value = CSS_Z_INDEX_INHERIT;
  21.         css_fixed index = 0;
  22.  
  23.         if (isInherit(opv) == false) {
  24.                 switch (getValue(opv)) {
  25.                 case Z_INDEX_SET:
  26.                         value = CSS_Z_INDEX_SET;
  27.  
  28.                         index = *((css_fixed *) style->bytecode);
  29.                         advance_bytecode(style, sizeof(index));
  30.                         break;
  31.                 case Z_INDEX_AUTO:
  32.                         value = CSS_Z_INDEX_AUTO;
  33.                         break;
  34.                 }
  35.         }
  36.  
  37.         if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
  38.                         isInherit(opv))) {
  39.                 return set_z_index(state->computed, value, index);
  40.         }
  41.  
  42.         return CSS_OK;
  43. }
  44.  
  45. css_error css__set_z_index_from_hint(const css_hint *hint,
  46.                 css_computed_style *style)
  47. {
  48.         return set_z_index(style, hint->status, hint->data.integer);
  49. }
  50.  
  51. css_error css__initial_z_index(css_select_state *state)
  52. {
  53.         return set_z_index(state->computed, CSS_Z_INDEX_AUTO, 0);
  54. }
  55.  
  56. css_error css__compose_z_index(const css_computed_style *parent,
  57.                 const css_computed_style *child,
  58.                 css_computed_style *result)
  59. {
  60.         int32_t index = 0;
  61.         uint8_t type = get_z_index(child, &index);
  62.  
  63.         if (type == CSS_Z_INDEX_INHERIT) {
  64.                 type = get_z_index(parent, &index);
  65.         }
  66.  
  67.         return set_z_index(result, type, index);
  68. }
  69.  
  70.