# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
# 
# The contents of this file are subject to the Mozilla Public License
# Version 1.1 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
# 
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
# License for the specific language governing rights and limitations
# under the License.
# 
# The Original Code is Komodo code.
# 
# The Initial Developer of the Original Code is ActiveState Software Inc.
# Portions created by ActiveState Software Inc are Copyright (C) 2000-2007
# ActiveState Software Inc. All Rights Reserved.
# 
# Contributor(s):
#   ActiveState Software Inc
# 
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
# 
# ***** END LICENSE BLOCK *****

import textwrap

from codeintel2.util import CompareNPunctLast

CSS_ATTR_DICT = {
    'azimuth'   : [
            'behind',
            'center',
            'center-left',
            'center-right',
            'far-left',
            'far-right',
            'inherit',
            'left',
            'leftwards',
            'left-side',
            'right',
            'rightwards',
            'right-side',
            '!important',
        ],
    'background': [
            'bottom',
            'center',
            'fixed',
            'inherit',
            'left',
            'none',
            'no-repeat',
            'repeat',
            'repeat-x',
            'repeat-y',
            'rgb(',
            'right',
            'scroll',
            'top',
            'transparent',
            'url(',
            '!important',
            '#',
        ],
    'background-attachment': [
            'fixed',
            'inherit',
            'scroll',
            '!important',
        ],
    'background-color': [
            'inherit',
            'rgb(',
            'transparent',
            '!important',
            '#',
        ],
    'background-image': [
            'inherit',
            'none',
            'url(',
            '!important',
        ],
    'background-position': [
            'bottom',
            'center',
            'inherit',
            'left',
            'right',
            'top',
            '!important',
        ],
    'background-repeat': [
            'inherit',
            'no-repeat',
            'repeat',
            'repeat-x',
            'repeat-y',
            '!important',
        ],
    'border'    : [
            'dashed',
            'dotted',
            'double',
            'groove',
            'hidden',
            'inherit',
            'inset',
            'medium',
            'none',
            'outset',
            'rgb(',
            'ridge',
            'solid',
            'thick',
            'thin',
            '!important',
            '#',
        ],
    'border-bottom': [
            'dashed',
            'dotted',
            'double',
            'groove',
            'hidden',
            'inherit',
            'inset',
            'medium',
            'none',
            'outset',
            'rgb(',
            'ridge',
            'solid',
            'thick',
            'thin',
            '!important',
            '#',
        ],
    'border-bottom-color': [
            'inherit',
            'rgb(',
            '!important',
            '#',
        ],
    'border-bottom-style': [
            'dashed',
            'dotted',
            'double',
            'groove',
            'hidden',
            'inherit',
            'inset',
            'none',
            'outset',
            'ridge',
            'solid',
            '!important',
        ],
    'border-bottom-width': [
            'inherit',
            'medium',
            'thick',
            'thin',
            '!important',
        ],
    'border-collapse': [
            'collapse',
            'inherit',
            'separate',
            '!important',
        ],
    'border-color': [
            'inherit',
            'rgb(',
            'transparent',
            '!important',
            '#',
        ],
    'border-left': [
            'dashed',
            'dotted',
            'double',
            'groove',
            'hidden',
            'inherit',
            'inset',
            'medium',
            'none',
            'outset',
            'rgb(',
            'ridge',
            'solid',
            'thick',
            'thin',
            '!important',
            '#',
        ],
    'border-left-color': [
            'inherit',
            'rgb(',
            '!important',
            '#',
        ],
    'border-left-style': [
            'dashed',
            'dotted',
            'double',
            'groove',
            'hidden',
            'inherit',
            'inset',
            'none',
            'outset',
            'ridge',
            'solid',
            '!important',
        ],
    'border-left-width': [
            'inherit',
            'medium',
            'thick',
            'thin',
            '!important',
        ],
    'border-right': [
            'dashed',
            'dotted',
            'double',
            'groove',
            'hidden',
            'inherit',
            'inset',
            'medium',
            'none',
            'outset',
            'rgb(',
            'ridge',
            'solid',
            'thick',
            'thin',
            '!important',
            '#',
        ],
    'border-right-color': [
            'inherit',
            'rgb(',
            '!important',
            '#',
        ],
    'border-right-style': [
            'dashed',
            'dotted',
            'double',
            'groove',
            'hidden',
            'inherit',
            'inset',
            'none',
            'outset',
            'ridge',
            'solid',
            '!important',
        ],
    'border-right-width': [
            'inherit',
            'medium',
            'thick',
            'thin',
            '!important',
        ],
    'border-spacing': [
            'inherit',
            '!important',
        ],
    'border-style': [
            'dashed',
            'dotted',
            'double',
            'groove',
            'hidden',
            'inherit',
            'inset',
            'none',
            'outset',
            'ridge',
            'solid',
            '!important',
        ],
    'border-top': [
            'dashed',
            'dotted',
            'double',
            'groove',
            'hidden',
            'inherit',
            'inset',
            'medium',
            'none',
            'outset',
            'rgb(',
            'ridge',
            'solid',
            'thick',
            'thin',
            '!important',
            '#',
        ],
    'border-top-color': [
            'inherit',
            'rgb(',
            '!important',
            '#',
        ],
    'border-top-style': [
            'dashed',
            'dotted',
            'double',
            'groove',
            'hidden',
            'inherit',
            'inset',
            'none',
            'outset',
            'ridge',
            'solid',
            '!important',
        ],
    'border-top-width': [
            'inherit',
            'medium',
            'thick',
            'thin',
            '!important',
        ],
    'border-width': [
            'inherit',
            'medium',
            'thick',
            'thin',
            '!important',
        ],
    'bottom'    : [
            'auto',
            'inherit',
            '!important',
        ],
    'caption-side': [
            'bottom',
            'inherit',
            'left',
            'right',
            'top',
            '!important',
        ],
    'clear'     : [
            'both',
            'inherit',
            'left',
            'none',
            'right',
            '!important',
        ],
    'clip'      : [
            'auto',
            'inherit',
            'rect(',
            '!important',
        ],
    'color'     : [
            'inherit',
            'rgb(',
            '!important',
            '#',
        ],
    'content'   : [
            'close-quote',
            'counter(',
            'inherit',
            'no-close-quote',
            'no-open-quote',
            'open-quote',
            'url(',
            '!important',
            "",
            '',
        ],
    'counter-increment': [
            'inherit',
            'none',
            '!important',
        ],
    'counter-reset': [
            'inherit',
            'none',
            '!important',
        ],
    'cue'       : [
            'inherit',
            'none',
            'url(',
            '!important',
        ],
    'cue-after' : [
            'inherit',
            'none',
            'url(',
            '!important',
        ],
    'cue-before': [
            'inherit',
            'none',
            'url(',
            '!important',
        ],
    'cursor'    : [
            'auto',
            'crosshair',
            'default',
            'e-resize',
            'help',
            'inherit',
            'move',
            'ne-resize',
            'nw-resize',
            'n-resize',
            'pointer',
            'se-resize',
            'sw-resize',
            's-resize',
            'text',
            'url(',
            'wait',
            'w-resize',
            '!important',
        ],
    'direction' : [
            'inherit',
            'ltr',
            'rtl',
            '!important',
        ],
    'display'   : [
            'block',
            'compact',
            'inherit',
            'inline',
            'inline-table',
            'list-item',
            'marker',
            'none',
            'run-in',
            'table',
            'table-caption',
            'table-cell',
            'table-column',
            'table-column-group',
            'table-footer-group',
            'table-header-group',
            'table-row',
            'table-row-group',
            '!important',
        ],
    'elevation' : [
            'above',
            'below',
            'higher',
            'inherit',
            'level',
            'lower',
            '!important',
        ],
    'empty-cells': [
            'hide',
            'inherit',
            'show',
            '!important',
        ],
    'float'     : [
            'inherit',
            'left',
            'none',
            'right',
            '!important',
        ],
    'font'      : [
            '100',
            '200',
            '300',
            '400',
            '500',
            '600',
            '700',
            '800',
            '900',
            'bold',
            'bolder',
            'caption',
            'cursive',
            'fantasy',
            'icon',
            'inherit',
            'italic',
            'large',
            'larger',
            'lighter',
            'medium',
            'menu',
            'message-box',
            'monospace',
            'normal',
            'oblique',
            'sans-serif',
            'serif',
            'small',
            'smaller',
            'small-caps',
            'small-caption',
            'status-bar',
            'xx-large',
            'xx-small',
            'x-large',
            'x-small',
            '!important',
        ],
    'font-family': [
            'cursive',
            'fantasy',
            'inherit',
            'monospace',
            'sans-serif',
            'serif',
            '!important',
        ],
    'font-size' : [
            'inherit',
            'large',
            'larger',
            'medium',
            'small',
            'smaller',
            'xx-large',
            'xx-small',
            'x-large',
            'x-small',
            '!important',
        ],
    'font-size-adjust': [
            'inherit',
            'none',
            '!important',
        ],
    'font-stretch': [
            'condensed',
            'expanded',
            'extra-condensed',
            'extra-expanded',
            'inherit',
            'narrower',
            'normal',
            'semi-condensed',
            'semi-expanded',
            'ultra-condensed',
            'ultra-expanded',
            'wider',
            '!important',
        ],
    'font-style': [
            'inherit',
            'italic',
            'normal',
            'oblique',
            '!important',
        ],
    'font-variant': [
            'inherit',
            'normal',
            'small-caps',
            '!important',
        ],
    'font-weight': [
            '100',
            '200',
            '300',
            '400',
            '500',
            '600',
            '700',
            '800',
            '900',
            'bold',
            'bolder',
            'inherit',
            'lighter',
            'normal',
            '!important',
        ],
    'height'    : [
            'auto',
            'inherit',
            '!important',
        ],
    'left'      : [
            'auto',
            'inherit',
            '!important',
        ],
    'letter-spacing': [
            'inherit',
            'normal',
            '!important',
        ],
    'line-height': [
            'inherit',
            'normal',
            '!important',
        ],
    'list-style': [
            'armenian',
            'circle',
            'cjk-ideographic',
            'decimal',
            'decimal-leading-zero',
            'disc',
            'georgian',
            'hebrew',
            'hiragana',
            'hiragana-iroha',
            'inherit',
            'inside',
            'katakana',
            'katakana-iroha',
            'lower-alpha',
            'lower-greek',
            'lower-latin',
            'lower-roman',
            'none',
            'outside',
            'square',
            'upper-alpha',
            'upper-latin',
            'upper-roman',
            'url(',
            '!important',
        ],
    'list-style-image': [
            'inherit',
            'none',
            'url(',
            '!important',
        ],
    'list-style-position': [
            'inherit',
            'inside',
            'outside',
            '!important',
        ],
    'list-style-type': [
            'armenian',
            'circle',
            'cjk-ideographic',
            'decimal',
            'decimal-leading-zero',
            'disc',
            'georgian',
            'hebrew',
            'hiragana',
            'hiragana-iroha',
            'inherit',
            'katakana',
            'katakana-iroha',
            'lower-alpha',
            'lower-greek',
            'lower-latin',
            'lower-roman',
            'none',
            'square',
            'upper-alpha',
            'upper-latin',
            'upper-roman',
            '!important',
        ],
    'margin'    : [
            'auto',
            'inherit',
            '!important',
        ],
    'margin-bottom': [
            'auto',
            'inherit',
            '!important',
        ],
    'margin-left': [
            'auto',
            'inherit',
            '!important',
        ],
    'margin-right': [
            'auto',
            'inherit',
            '!important',
        ],
    'margin-top': [
            'auto',
            'inherit',
            '!important',
        ],
    'marker-offset': [
            'auto',
            'inherit',
            '!important',
        ],
    'marks'     : [
            'crop',
            'cross',
            'inherit',
            'none',
            '!important',
        ],
    'max-height': [
            'inherit',
            'none',
            '!important',
        ],
    'max-width' : [
            'inherit',
            'none',
            '!important',
        ],
    'min-height': [
            'inherit',
            '!important',
        ],
    'min-width' : [
            'inherit',
            '!important',
        ],
    'orphans'   : [
            'inherit',
            '!important',
        ],
    'outline'   : [
            'dashed',
            'dotted',
            'double',
            'groove',
            'hidden',
            'inherit',
            'inset',
            'invert',
            'medium',
            'none',
            'outset',
            'rgb(',
            'ridge',
            'solid',
            'thick',
            'thin',
            '!important',
            '#',
        ],
    'outline-color': [
            'inherit',
            'invert',
            'rgb(',
            '!important',
            '#',
        ],
    'outline-style': [
            'dashed',
            'dotted',
            'double',
            'groove',
            'hidden',
            'inherit',
            'inset',
            'none',
            'outset',
            'ridge',
            'solid',
            '!important',
        ],
    'outline-width': [
            'inherit',
            'medium',
            'thick',
            'thin',
            '!important',
        ],
    'overflow'  : [
            'auto',
            'hidden',
            'inherit',
            'scroll',
            'visible',
            '!important',
        ],
    'padding'   : [
            'inherit',
            '!important',
        ],
    'padding-bottom': [
            'inherit',
            '!important',
        ],
    'padding-left': [
            'inherit',
            '!important',
        ],
    'padding-right': [
            'inherit',
            '!important',
        ],
    'padding-top': [
            'inherit',
            '!important',
        ],
    'page'      : [
            'auto',
        ],
    'page-break-after': [
            'always',
            'auto',
            'avoid',
            'inherit',
            'left',
            'right',
            '!important',
        ],
    'page-break-before': [
            'always',
            'auto',
            'avoid',
            'inherit',
            'left',
            'right',
            '!important',
        ],
    'page-break-inside': [
            'auto',
            'avoid',
            'inherit',
            '!important',
        ],
    'pause'     : [
            'inherit',
            'ms',
            's',
            '!important',
        ],
    'pause-after': [
            'inherit',
            'ms',
            's',
            '!important',
        ],
    'pause-before': [
            'inherit',
            'ms',
            's',
            '!important',
        ],
    'pitch'     : [
            'high',
            'Hz',
            'inherit',
            'kHz',
            'low',
            'medium',
            'x-high',
            'x-low',
            '!important',
        ],
    'pitch-range': [
            'inherit',
            '!important',
        ],
    'play-during': [
            'auto',
            'inherit',
            'none',
            'url(',
            '!important',
        ],
    'position'  : [
            'absolute',
            'fixed',
            'inherit',
            'relative',
            'static',
            '!important',
        ],
    'quotes'    : [
            'inherit',
            'none',
            '!important',
            "",
            '',
        ],
    'richness'  : [
            'inherit',
            '!important',
        ],
    'right'     : [
            'auto',
            'inherit',
            '!important',
        ],
    'size'      : [
            'auto',
            'inherit',
            'landscape',
            'portrait',
            '!important',
        ],
    'speak'     : [
            'inherit',
            'none',
            'normal',
            'spell-out',
            '!important',
        ],
    'speak-header': [
            'always',
            'inherit',
            'once',
            '!important',
        ],
    'speak-numeral': [
            'continuous',
            'digits',
            'inherit',
            '!important',
        ],
    'speak-punctuation': [
            'code',
            'inherit',
            'none',
            '!important',
        ],
    'speech-rate': [
            'fast',
            'faster',
            'inherit',
            'medium',
            'slow',
            'slower',
            'x-fast',
            'x-slow',
            '!important',
        ],
    'stress'    : [
            'inherit',
            '!important',
        ],
    'table-layout': [
            'auto',
            'fixed',
            'inherit',
            '!important',
        ],
    'text-align': [
            'center',
            'inherit',
            'justify',
            'left',
            'right',
            '!important',
            "",
            '',
        ],
    'text-decoration': [
            'blink',
            'inherit',
            'line-through',
            'none',
            'overline',
            'underline',
            '!important',
        ],
    'text-indent': [
            'inherit',
            '!important',
        ],
    'text-shadow': [
            'inherit',
            'none',
            'rgb(',
            '!important',
            '#',
        ],
    'text-transform': [
            'capitalize',
            'inherit',
            'lowercase',
            'none',
            'uppercase',
            '!important',
        ],
    'top'       : [
            'auto',
            'inherit',
            '!important',
        ],
    'unicode-bidi': [
            'bidi-override',
            'embed',
            'inherit',
            'normal',
            '!important',
        ],
    'vertical-align': [
            'baseline',
            'bottom',
            'inherit',
            'middle',
            'sub',
            'super',
            'text-bottom',
            'text-top',
            'top',
            '!important',
        ],
    'visibility': [
            'collapse',
            'hidden',
            'inherit',
            'visible',
            '!important',
        ],
    'voice-family': [
            'child',
            'female',
            'inherit',
            'male',
            '!important',
        ],
    'volume'    : [
            'inherit',
            'loud',
            'medium',
            'silent',
            'soft',
            'x-loud',
            'x-soft',
            '!important',
        ],
    'white-space': [
            'inherit',
            'normal',
            'nowrap',
            'pre',
            '!important',
        ],
    'widows'    : [
            'inherit',
            '!important',
        ],
    'width'     : [
            'auto',
            'inherit',
            '!important',
        ],
    'word-spacing': [
            'inherit',
            'normal',
            '!important',
        ],
    'z-index'   : [
            'auto',
            'inherit',
            '!important',
        ],
}

CSS_PROPERTY_ATTRIBUTE_CALLTIPS_DICT = {
    'azimuth'               : """Audio: Spatial audio property for aural presentation""",
    'background'            : """Shorthand for setting the individual background properties""",
    'background-attachment' : """If background image is specified, this specifies whether it is fixed with regard to the viewport ('fixed') or scrolls along with the document ('scroll').""",
    'background-color'      : """Sets the background color of an element, either a <color> value or the keyword 'transparent', to make the underlying colors shine through""",
    'background-image'      : """Sets the background image of an element. When setting a background image, authors should also specify a background color that will be used when the image is unavailable. When the image is available, it is rendered on top of the background color""",
    'background-position'   : """If a background image has been specified, this property specifies its initial position""",
    'background-repeat'     : """If a background image is specified, this property specifies whether the image is repeated (tiled), and how""",
    'border'                : """Shorthand for border-width, border-style and border-color affecting all 4 borders""",
    'border-bottom'         : """Shorthand for border-width, border-style and border-color affecting the bottom border""",
    'border-bottom-color'   : """Sets the color of the bottom border""",
    'border-bottom-style'   : """Specifies the line style of a box's bottom border (solid, double, dashed, hidden, etc.)""",
    'border-bottom-width'   : """Sets the width of the bottom border of a box""",
    'border-collapse'       : """This property selects a table's border model.""",
    'border-color'          : """Sets the color of the four borders""",
    'border-left'           : """Shorthand for border-width, border-style and border-color affecting the left border""",
    'border-left-color'     : """Sets the color of the left border""",
    'border-left-style'     : """Specifies the line style of a box's left border (solid, double, dashed, hidden, etc.)""",
    'border-left-width'     : """Sets the width of the left border of a box""",
    'border-right'          : """Shorthand for border-width, border-style and border-color affecting the right border""",
    'border-right-color'    : """Sets the color of the right border""",
    'border-right-style'    : """Specifies the line style of a box's right border (solid, double, dashed, hidden, etc.)""",
    'border-right-width'    : """Sets the width of the right border of a box""",
    'border-spacing'        : """The lengths specify the distance that separates adjacent cell borders. If one length is specified, it gives both the horizontal and vertical spacing. If two are specified, the first gives the horizontal spacing and the second the vertical spacing. Lengths may not be negative.""",
    'border-style'          : """Specifies the line style of a box's four borders (solid, double, dashed, hidden, etc.)""",
    'border-top'            : """Shorthand for border-width, border-style and border-color affecting the top border""",
    'border-top-color'      : """Sets the color of the top border""",
    'border-top-style'      : """Specifies the line style of a box's top border (solid, double, dashed, hidden, etc.)""",
    'border-top-width'      : """Sets the width of the top border of a box""",
    'border-width'          : """Shorthand for setting 'border-top-width', 'border-right-width', 'border-bottom-width', and 'border-left-width' at the same place in the style sheet. If there is only one value, it applies to all sides. If there are two values, the top and bottom borders are set to the first value and the right and left are set to the second. If there are three values, the top is set to the first value, the left and right are set to the second, and the bottom is set to the third. If there are four values, they apply to the top, right, bottom, and left, respectively.""",
    'bottom'                : """Specifies how far a box's bottom content edge is offset above the bottom of the box's containing block""",
    'caption-side'          : """Specifies the position of the caption box with respect to the table box""",
    'clear'                 : """Indicates which sides of an element's box(es) may not be adjacent to an earlier floating box""",
    'clip'                  : """A clipping region defines what portion of an element's rendered content is visible""",
    'color'                 : """This property describes the foreground color of an element's text content""",
    'content'               : """This property is used with the :before and :after pseudo-elements to generate content in a document""",
    'counter-increment'     : """Indicates by how much the counter is incremented for every occurrence of the element. The default increment is 1. Zero and negative integers are allowed.""",
    'counter-reset'         : """Specifies the value that the counter is set to on each occurrence of the element""",
    'cue'                   : """Audio: Shorthand for setting 'cue-before' and 'cue-after'. If two values are given, the first value is 'cue-before' and the second is 'cue-after'. If only one value is given, it applies to both properties.""",
    'cue-after'             : """Audio: Sound to be played after the element to delimit it""",
    'cue-before'            : """Audio: Sound to be played before the element to delimit it""",
    'cursor'                : """Specifies the type of cursor to be displayed for the pointing device""",
    'direction'             : """Specifies the base writing direction of blocks and the direction of embeddings and overrides (see 'unicode-bidi') for the Unicode bidirectional algorithm.""",
    'display'               : """How the element is to be displayed, denotes the box type format""",
    'elevation'             : """Audio: Spatial elevation direction for aural presentation.""",
    'empty-cells'           : """Controls the rendering of borders around cells that have no visible content""",
    'float'                 : """Specifies whether a box should float to the left, right, or not at all""",
    'font'                  : """Shorthand for setting 'font-style', 'font-variant', 'font-weight', 'font-size', 'line-height', and 'font-family', at the same place in the style sheet""",
    'font-family'           : """Specifies a prioritized list of font family names and/or generic family names""",
    'font-size'             : """Describes the size of the font when set solid""",
    'font-size-adjust'      : """Specifies an aspect value for an element that will preserve the x-height of the first choice font in the substitute font""",
    'font-stretch'          : """Selects a normal, condensed, or extended face from a font family""",
    'font-style'            : """Sets normal (sometimes referred to as "roman" or "upright"), italic, and oblique faces within a font family""",
    'font-variant'          : """Can be used to select font casing 'normal' or 'small-caps'""",
    'font-weight'           : """Specifies the weight of the font""",
    'height'                : """Specifies the content height of boxes generated by block-level and replaced elements""",
    'left'                  : """This property specifies how far a box's left content edge is offset to the right of the left edge of the box's containing block""",
    'letter-spacing'        : """Specifies spacing behavior between text characters""",
    'line-height'           : """Specifies the minimal height of each generated inline box""",
    'list-style'            : """Shorthand notation for setting the three properties 'list-style-type', 'list-style-image', and 'list-style-position' at the same place in the style sheet""",
    'list-style-image'      : """Sets the image that will be used as the list item marker""",
    'list-style-position'   : """Specifies the position of the marker box in the principal block box""",
    'list-style-type'       : """Specifies appearance of the list item marker if 'list-style-image' has the value 'none' or if the image pointed to by the URI cannot be displayed""",
    'margin'                : """Shorthand for setting 'margin-top', 'margin-right', 'margin-bottom', and 'margin-left' at the same place in the style sheet""",
    'margin-bottom'         : """Specifies the width of the bottom margin area of a box""",
    'margin-left'           : """Specifies the width of the left margin area of a box""",
    'margin-right'          : """Specifies the width of the right margin area of a box""",
    'margin-top'            : """Specifies the width of the top margin area of a box""",
    'marker-offset'         : """Specifies the distance between the nearest border edges of a marker box and its associated principal box""",
    'marks'                 : """Specifies whether cross marks or crop marks or both should be rendered just outside the page box edge. Crop marks indicate where the page should be cut. Cross marks (also known as register marks or registration marks) are used to align sheets""",
    'max-height'            : """Maximum height of the containing box""",
    'max-width'             : """Maximum width of the containing box""",
    'min-height'            : """Minimum height of the containing box""",
    'min-width'             : """Minimum width of the containing box""",
    'orphans'               : """Specifies the minimum number of lines of a paragraph that must be left at the bottom of a page""",
    'outline'               : """Shorthand for setting 'outline-style', 'outline-width', and 'outline-color' at the same place in the style sheet""",
    'outline-color'         : """Outline color around visual object""",
    'outline-style'         : """Specifies the line style of the outline (solid, double, dashed, etc.)""",
    'outline-width'         : """Specifies the width of the outline around the element""",
    'overflow'              : """Specifies whether the content of a block-level element is clipped when it overflows the element's box (which is acting as a containing block for the content)""",
    'padding'               : """Shorthand for setting 'padding-top', 'padding-right', 'padding-bottom', and 'padding-left' at the same place in the style sheet""",
    'padding-bottom'        : """Sets the bottom width of the containing box""",
    'padding-left'          : """Sets the left width of the containing box""",
    'padding-right'         : """Sets the right width of the containing box""",
    'padding-top'           : """Sets the top width of the containing box""",
    'page'                  : """Specifies a particular type of page where an element should be displayed""",
    'page-break-after'      : """Indicate the user agent should break the page after here""",
    'page-break-before'     : """Indicate the user agent should break the page before here""",
    'page-break-inside'     : """Indicate the user agent should break the page within here""",
    'pause'                 : """Audio: Shorthand for setting 'pause-before' and 'pause-after'. If two values are given, the first value is 'pause-before' and the second is 'pause-after'. If only one value is given, it applies to both properties""",
    'pause-after'           : """Audio: Specifies a pause to be observed after speaking an element's content""",
    'pause-before'          : """Audio: Specifies a pause to be observed before speaking an element's content""",
    'pitch'                 : """Audio: Specifies the average pitch (a frequency) of the speaking voice""",
    'pitch-range'           : """Audio: Specifies variation in average pitch""",
    'play-during'           : """Audio: Similar to the 'cue-before' and 'cue-after' properties, this property specifies a sound to be played as a background while an element's content is spoken""",
    'position'              : """Specifies which of the CSS2 positioning algorithms is used to calculate the position of a box""",
    'quotes'                : """Specifies quotation marks for any number of embedded quotations""",
    'richness'              : """Audio: Specifies the richness, or brightness, of the speaking voice. A rich voice will "carry" in a large room, a smooth voice will not""",
    'right'                 : """This property specifies how far a box's right content edge is offset to the left of the right edge of the box's containing block""",
    'size'                  : """Specifies the size and orientation of a page box""",
    'speak'                 : """Audio: Specifies whether text will be rendered aurally and if so, in what manner""",
    'speak-header'          : """Audio: Specifies whether table headers are spoken before every cell, or only before a cell when that cell is associated with a different header than the previous cell""",
    'speak-numeral'         : """Audio: Controls how numerals are spoken""",
    'speak-punctuation'     : """Audio: Specifies how punctuation is spoken""",
    'speech-rate'           : """Audio: Specifies the speaking rate. Note that both absolute and relative keyword values are allowed""",
    'stress'                : """Audio: Specifies the height of "local peaks" in the intonation contour of a voice""",
    'table-layout'          : """Specifies the algorithm used to lay out the table cells, rows, and columns""",
    'text-align'            : """Specifies how inline content of a block is aligned""",
    'text-decoration'       : """Specifies decorations that are added to the text of an element""",
    'text-indent'           : """Specifies the indentation of the first line of text in a block""",
    'text-shadow'           : """A comma-separated list of shadow effects to be applied to the text of the element""",
    'text-transform'        : """Specifies capitalization effects of an element's text""",
    'top'                   : """This property specifies how far a box's top content edge is offset below the top edge of the box's containing block""",
    'unicode-bidi'          : """Specifies the level of embedding with respect to the bidirectional algorithm""",
    'uri'                   : """An internet reference string.""",
    'vertical-align'        : """Affects the vertical positioning inside a line box of the boxes generated by an inline-level element""",
    'visibility'            : """Specifies whether the boxes generated by an element are rendered. Invisible boxes still affect layout (set the 'display' property to 'none' to suppress box generation altogether)""",
    'voice-family'          : """Audio: Value is a comma-separated, prioritized list of voice family names""",
    'volume'                : """Audio: Refers to the median volume of the audio""",
    'white-space'           : """Specifies how whitespace inside the element is handled""",
    'widows'                : """Specifies the minimum number of lines of a paragraph that must be left at the top of a page""",
    'width'                 : """Specifies the content width of boxes generated by block-level and replaced elements""",
    'word-spacing'          : """Specifies spacing behavior between words""",
    'z-index'               : """For a positioned box, specifies the stack level of the box in the current stacking context and also whether the box establishes a local stacking context.""",
}
for property, calltip in CSS_PROPERTY_ATTRIBUTE_CALLTIPS_DICT.items():
    CSS_PROPERTY_ATTRIBUTE_CALLTIPS_DICT[property] = "\n".join(textwrap.wrap(calltip, 40))

css_color_names = [ 'aqua', 'black', 'blue', 'fuchsia', 'gray', 'green', 'lime', 'maroon', 'navy', 'olive', 'purple', 'red', 'silver', 'teal', 'white', 'yellow' ]

# Note: The color descriptions are not yet used by Komodo for attribute values,
# but since I already have the info, might as well keep it for reference, we may
# be able to add it later on...
css2_system_colors = {
    'ActiveBorder'           : """Active window border""",
    'ActiveCaption'          : """Active window caption""",
    'AppWorkspace'           : """Background color of multiple document interface""",
    'Background'             : """Desktop background""",
    'ButtonFace'             : """Face color for three-dimensional display elements""",
    'ButtonHighlight'        : """Dark shadow for three-dimensional display elements (for edges facing away from the light source)""",
    'ButtonShadow'           : """Shadow color for three-dimensional display elements""",
    'ButtonText'             : """Text on push buttons""",
    'CaptionText'            : """Text in caption, size box, and scrollbar arrow box""",
    'GrayText'               : """Grayed (disabled) text. This color is set to #000 if the current display driver does not support a solid gray color""",
    'Highlight'              : """Item(s) selected in a control""",
    'HighlightText'          : """Text of item(s) selected in a control""",
    'InactiveBorder'         : """Inactive window border""",
    'InactiveCaption'        : """Inactive window caption""",
    'InactiveCaptionText'    : """Color of text in an inactive caption""",
    'InfoBackground'         : """Background color for tooltip controls""",
    'InfoText'               : """Text color for tooltip controls""",
    'Menu'                   : """Menu background""",
    'MenuText'               : """Text in menus""",
    'Scrollbar'              : """Scroll bar gray area""",
    'ThreeDDarkShadow'       : """Dark shadow for three-dimensional display elements""",
    'ThreeDFace'             : """Face color for three-dimensional display elements""",
    'ThreeDHighlight'        : """Highlight color for three-dimensional display elements""",
    'ThreeDLightShadow'      : """Light color for three-dimensional display elements (for edges facing the light source)""",
    'ThreeDShadow'           : """Dark shadow for three-dimensional display elements""",
    'Window'                 : """Window background""",
    'WindowFrame'            : """Window frame""",
    'WindowText'             : """Text in windows""",
}

# Add the css2 system colors.
# XXX - Uncomment following lines to add, disabled for now.
#for attr, values in CSS_ATTR_DICT.items():
#    if '#' in values or 'rbg(' in values:
#        CSS_ATTR_DICT[attr] = sorted(values + css_color_names + css2_system_colors.keys(),
#                                     cmp=CompareNPunctLast)
