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_outline_color(uint32_t opv, css_style *style,
  18.                 css_select_state *state)
  19. {
  20.         uint16_t value = CSS_OUTLINE_COLOR_INHERIT;
  21.         css_color color = 0;
  22.  
  23.         if (isInherit(opv) == false) {
  24.                 switch (getValue(opv)) {
  25.                 case OUTLINE_COLOR_TRANSPARENT:
  26.                         value = CSS_OUTLINE_COLOR_COLOR;
  27.                         break;
  28.                 case OUTLINE_COLOR_CURRENT_COLOR:
  29.                         value = CSS_OUTLINE_COLOR_CURRENT_COLOR;
  30.                         break;
  31.                 case OUTLINE_COLOR_SET:
  32.                         value = CSS_OUTLINE_COLOR_COLOR;
  33.                         color = *((css_color *) style->bytecode);
  34.                         advance_bytecode(style, sizeof(color));
  35.                         break;
  36.                 case OUTLINE_COLOR_INVERT:
  37.                         value = CSS_OUTLINE_COLOR_INVERT;
  38.                         break;
  39.                 }
  40.         }
  41.  
  42.         if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
  43.                         isInherit(opv))) {
  44.                 return set_outline_color(state->computed, value, color);
  45.         }
  46.  
  47.         return CSS_OK;
  48. }
  49.  
  50. css_error css__set_outline_color_from_hint(const css_hint *hint,
  51.                 css_computed_style *style)
  52. {
  53.         return set_outline_color(style, hint->status, hint->data.color);
  54. }
  55.  
  56. css_error css__initial_outline_color(css_select_state *state)
  57. {
  58.         return set_outline_color(state->computed, CSS_OUTLINE_COLOR_INVERT, 0);
  59. }
  60.  
  61. css_error css__compose_outline_color(const css_computed_style *parent,
  62.                 const css_computed_style *child,
  63.                 css_computed_style *result)
  64. {
  65.         css_color color = 0;
  66.         uint8_t type = get_outline_color(child, &color);
  67.  
  68.         if ((child->uncommon == NULL && parent->uncommon != NULL) ||
  69.                         type == CSS_OUTLINE_COLOR_INHERIT ||
  70.                         (child->uncommon != NULL && result != child)) {
  71.                 if ((child->uncommon == NULL && parent->uncommon != NULL) ||
  72.                                 type == CSS_OUTLINE_COLOR_INHERIT) {
  73.                         type = get_outline_color(parent, &color);
  74.                 }
  75.  
  76.                 return set_outline_color(result, type, color);
  77.         }
  78.  
  79.         return CSS_OK;
  80. }
  81.  
  82.