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 <assert.h>
  9.  
  10. #include "bytecode/bytecode.h"
  11. #include "bytecode/opcodes.h"
  12. #include "select/propset.h"
  13. #include "select/propget.h"
  14. #include "utils/utils.h"
  15.  
  16. #include "select/properties/properties.h"
  17. #include "select/properties/helpers.h"
  18.  
  19. css_error css__cascade_text_decoration(uint32_t opv, css_style *style,
  20.                 css_select_state *state)
  21. {
  22.         uint16_t value = CSS_TEXT_DECORATION_INHERIT;
  23.        
  24.         UNUSED(style);
  25.  
  26.         if (isInherit(opv) == false) {
  27.                 if (getValue(opv) == TEXT_DECORATION_NONE) {
  28.                         value = CSS_TEXT_DECORATION_NONE;
  29.                 } else {
  30.                         assert(value == 0);
  31.  
  32.                         if (getValue(opv) & TEXT_DECORATION_UNDERLINE)
  33.                                 value |= CSS_TEXT_DECORATION_UNDERLINE;
  34.                         if (getValue(opv) & TEXT_DECORATION_OVERLINE)
  35.                                 value |= CSS_TEXT_DECORATION_OVERLINE;
  36.                         if (getValue(opv) & TEXT_DECORATION_LINE_THROUGH)
  37.                                 value |= CSS_TEXT_DECORATION_LINE_THROUGH;
  38.                         if (getValue(opv) & TEXT_DECORATION_BLINK)
  39.                                 value |= CSS_TEXT_DECORATION_BLINK;
  40.                 }
  41.         }
  42.  
  43.         if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
  44.                         isInherit(opv))) {
  45.                 return set_text_decoration(state->computed, value);
  46.         }
  47.  
  48.         return CSS_OK;
  49. }
  50.  
  51. css_error css__set_text_decoration_from_hint(const css_hint *hint,
  52.                 css_computed_style *style)
  53. {
  54.         return set_text_decoration(style, hint->status);
  55. }
  56.  
  57. css_error css__initial_text_decoration(css_select_state *state)
  58. {
  59.         return set_text_decoration(state->computed, CSS_TEXT_DECORATION_NONE);
  60. }
  61.  
  62. css_error css__compose_text_decoration(const css_computed_style *parent,       
  63.                 const css_computed_style *child,
  64.                 css_computed_style *result)
  65. {
  66.         uint8_t type = get_text_decoration(child);
  67.  
  68.         if (type == CSS_TEXT_DECORATION_INHERIT) {
  69.                 type = get_text_decoration(parent);
  70.         }
  71.  
  72.         return set_text_decoration(result, type);
  73. }
  74.  
  75.