[webkit-changes] cvs commit: WebCore/kwq DOM-CSS.mm DOMPrivate.h

David hyatt at opensource.apple.com
Tue Dec 6 17:12:39 PST 2005


hyatt       05/12/06 17:12:39

  Modified:    .        ChangeLog
               khtml/css css_computedstyle.h css_valueimpl.cpp
                        css_valueimpl.h cssparser.cpp cssparser.h
                        cssstyleselector.cpp cssstyleselector.h
               khtml/ecma kjs_css.cpp kjs_css.h kjs_views.cpp kjs_views.h
               khtml/xml dom2_viewsimpl.cpp dom2_viewsimpl.h
               kwq      DOM-CSS.mm DOMPrivate.h
  Log:
  	Add support for more methods for exposing more useful style information.
  
  	getMatchedCSSRules can be used to obtain the matched sheet rules for an element.  In Obj-C
  	it will also include user/user agent sheet rules.
  
  	Also add support for tracking the original shorthand in which a property was declared, as well
  	as whether the property was just implicitly set rather than explicitly mentioned (e.g., if it was
  	an omitted piece of a shorthand).  The new methods on CSSStyleDeclaration are getPropertyShorthand
  	and isPropertyImplicit.
  
          Reviewed by mjs
  
          Test: fast/inspector/style.html
  
          * khtml/css/css_computedstyle.h:
          (DOM::CSSComputedStyleDeclarationImpl::getPropertyShorthand):
          (DOM::CSSComputedStyleDeclarationImpl::isPropertyImplicit):
          * khtml/css/css_valueimpl.cpp:
          (DOM::CSSStyleDeclarationImpl::getPropertyShorthand):
          (DOM::CSSStyleDeclarationImpl::isPropertyImplicit):
          (DOM::CSSMutableStyleDeclarationImpl::getPropertyPriority):
          (DOM::CSSMutableStyleDeclarationImpl::getPropertyShorthand):
          (DOM::CSSMutableStyleDeclarationImpl::isPropertyImplicit):
          (DOM::CSSProperty::cssText):
          (DOM::operator==):
          * khtml/css/css_valueimpl.h:
          (DOM::CSSProperty::CSSProperty):
          (DOM::CSSProperty::operator=):
          (DOM::CSSProperty::~CSSProperty):
          (DOM::CSSProperty::setValue):
          (DOM::CSSProperty::shorthandID):
          (DOM::CSSProperty::isImportant):
          (DOM::CSSProperty::isImplicit):
          * khtml/css/cssparser.cpp:
          (CSSParser::CSSParser):
          (CSSParser::addProperty):
          (CSSParser::parseValue):
          (CSSParser::parseBackgroundShorthand):
          (CSSParser::parseShorthand):
          (CSSParser::parse4Values):
          (CSSParser::parseBackgroundPosition):
          (CSSParser::parseBackgroundProperty):
          * khtml/css/cssparser.h:
          (DOM::CSSParser::enterShorthand):
          (DOM::CSSParser::exitShorthand):
          (DOM::CSSParser::inShorthand):
          * khtml/css/cssstyleselector.cpp:
          (khtml::CSSStyleSelector::CSSStyleSelector):
          (khtml::CSSStyleSelector::matchRules):
          (khtml::CSSStyleSelector::matchRulesForList):
          (khtml::CSSStyleSelector::initForStyleResolve):
          (khtml::CSSStyleSelector::styleRulesForElement):
          (khtml::CSSStyleSelector::pseudoStyleRulesForElement):
          * khtml/css/cssstyleselector.h:
          * khtml/ecma/kjs_css.cpp:
          (KJS::DOMCSSStyleDeclarationProtoFunc::callAsFunction):
          * khtml/ecma/kjs_css.h:
          (KJS::DOMCSSStyleDeclaration::):
          * khtml/ecma/kjs_views.cpp:
          (KJS::DOMAbstractViewProtoFunc::callAsFunction):
          * khtml/ecma/kjs_views.h:
          (KJS::DOMAbstractView::):
          * khtml/xml/dom2_viewsimpl.cpp:
          (DOM::AbstractViewImpl::getComputedStyle):
          (DOM::AbstractViewImpl::getMatchedCSSRules):
          * khtml/xml/dom2_viewsimpl.h:
          * kwq/DOM-CSS.mm:
          (-[DOMCSSStyleDeclaration getPropertyShorthand:]):
          (-[DOMCSSStyleDeclaration isPropertyImplicit:]):
          (-[DOMDocument getMatchedCSSRules::]):
          * kwq/DOMPrivate.h:
  
  Revision  Changes    Path
  1.483     +77 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.482
  retrieving revision 1.483
  diff -u -r1.482 -r1.483
  --- ChangeLog	6 Dec 2005 09:21:09 -0000	1.482
  +++ ChangeLog	7 Dec 2005 01:12:34 -0000	1.483
  @@ -1,3 +1,79 @@
  +<<<<<<< ChangeLog
  +2005-12-05  David Hyatt  <hyatt at apple.com>
  +
  +	Add support for more methods for exposing more useful style information.
  +
  +	getMatchedCSSRules can be used to obtain the matched sheet rules for an element.  In Obj-C
  +	it will also include user/user agent sheet rules.
  +
  +	Also add support for tracking the original shorthand in which a property was declared, as well
  +	as whether the property was just implicitly set rather than explicitly mentioned (e.g., if it was
  +	an omitted piece of a shorthand).  The new methods on CSSStyleDeclaration are getPropertyShorthand
  +	and isPropertyImplicit.
  +	
  +        Reviewed by mjs
  +
  +        Test: fast/inspector/style.html
  +
  +        * khtml/css/css_computedstyle.h:
  +        (DOM::CSSComputedStyleDeclarationImpl::getPropertyShorthand):
  +        (DOM::CSSComputedStyleDeclarationImpl::isPropertyImplicit):
  +        * khtml/css/css_valueimpl.cpp:
  +        (DOM::CSSStyleDeclarationImpl::getPropertyShorthand):
  +        (DOM::CSSStyleDeclarationImpl::isPropertyImplicit):
  +        (DOM::CSSMutableStyleDeclarationImpl::getPropertyPriority):
  +        (DOM::CSSMutableStyleDeclarationImpl::getPropertyShorthand):
  +        (DOM::CSSMutableStyleDeclarationImpl::isPropertyImplicit):
  +        (DOM::CSSProperty::cssText):
  +        (DOM::operator==):
  +        * khtml/css/css_valueimpl.h:
  +        (DOM::CSSProperty::CSSProperty):
  +        (DOM::CSSProperty::operator=):
  +        (DOM::CSSProperty::~CSSProperty):
  +        (DOM::CSSProperty::setValue):
  +        (DOM::CSSProperty::shorthandID):
  +        (DOM::CSSProperty::isImportant):
  +        (DOM::CSSProperty::isImplicit):
  +        * khtml/css/cssparser.cpp:
  +        (CSSParser::CSSParser):
  +        (CSSParser::addProperty):
  +        (CSSParser::parseValue):
  +        (CSSParser::parseBackgroundShorthand):
  +        (CSSParser::parseShorthand):
  +        (CSSParser::parse4Values):
  +        (CSSParser::parseBackgroundPosition):
  +        (CSSParser::parseBackgroundProperty):
  +        * khtml/css/cssparser.h:
  +        (DOM::CSSParser::enterShorthand):
  +        (DOM::CSSParser::exitShorthand):
  +        (DOM::CSSParser::inShorthand):
  +        * khtml/css/cssstyleselector.cpp:
  +        (khtml::CSSStyleSelector::CSSStyleSelector):
  +        (khtml::CSSStyleSelector::matchRules):
  +        (khtml::CSSStyleSelector::matchRulesForList):
  +        (khtml::CSSStyleSelector::initForStyleResolve):
  +        (khtml::CSSStyleSelector::styleRulesForElement):
  +        (khtml::CSSStyleSelector::pseudoStyleRulesForElement):
  +        * khtml/css/cssstyleselector.h:
  +        * khtml/ecma/kjs_css.cpp:
  +        (KJS::DOMCSSStyleDeclarationProtoFunc::callAsFunction):
  +        * khtml/ecma/kjs_css.h:
  +        (KJS::DOMCSSStyleDeclaration::):
  +        * khtml/ecma/kjs_views.cpp:
  +        (KJS::DOMAbstractViewProtoFunc::callAsFunction):
  +        * khtml/ecma/kjs_views.h:
  +        (KJS::DOMAbstractView::):
  +        * khtml/xml/dom2_viewsimpl.cpp:
  +        (DOM::AbstractViewImpl::getComputedStyle):
  +        (DOM::AbstractViewImpl::getMatchedCSSRules):
  +        * khtml/xml/dom2_viewsimpl.h:
  +        * kwq/DOM-CSS.mm:
  +        (-[DOMCSSStyleDeclaration getPropertyShorthand:]):
  +        (-[DOMCSSStyleDeclaration isPropertyImplicit:]):
  +        (-[DOMDocument getMatchedCSSRules::]):
  +        * kwq/DOMPrivate.h:
  +
  +=======
   2005-12-04  Maciej Stachowiak  <mjs at apple.com>
   
           Reviewed by Eric.
  @@ -252,6 +328,7 @@
           * khtml/khtmlview.cpp: (KHTMLView::dispatchMouseEvent): Do the same "skip text node"
           logic for the "oldUnder" variable as for the "targetNode" variable.
   
  +>>>>>>> 1.482
   2005-12-05  John Sullivan  <sullivan at apple.com>
   
           Reviewed by Darin Adler.
  
  
  
  1.11      +2 -0      WebCore/khtml/css/css_computedstyle.h
  
  Index: css_computedstyle.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/css/css_computedstyle.h,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- css_computedstyle.h	1 Dec 2005 10:32:08 -0000	1.10
  +++ css_computedstyle.h	7 Dec 2005 01:12:35 -0000	1.11
  @@ -50,6 +50,8 @@
       virtual CSSValueImpl *getPropertyCSSValue(int propertyID) const;
       virtual DOMString getPropertyValue(int propertyID) const;
       virtual bool getPropertyPriority(int propertyID) const;
  +    virtual int getPropertyShorthand(int propertyID) const { return -1; }
  +    virtual bool isPropertyImplicit(int propertyID) const { return true; }
   
       virtual CSSMutableStyleDeclarationImpl *copy() const;
       virtual CSSMutableStyleDeclarationImpl *makeMutable();
  
  
  
  1.83      +41 -4     WebCore/khtml/css/css_valueimpl.cpp
  
  Index: css_valueimpl.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/css/css_valueimpl.cpp,v
  retrieving revision 1.82
  retrieving revision 1.83
  diff -u -r1.82 -r1.83
  --- css_valueimpl.cpp	29 Nov 2005 11:20:43 -0000	1.82
  +++ css_valueimpl.cpp	7 Dec 2005 01:12:35 -0000	1.83
  @@ -131,6 +131,25 @@
       return getPropertyPriority(propID) ? "important" : "";
   }
   
  +DOMString CSSStyleDeclarationImpl::getPropertyShorthand(const DOMString &propertyName)
  +{
  +    int propID = propertyID(propertyName);
  +    if (!propID)
  +        return DOMString();
  +    int shorthandID = getPropertyShorthand(propID);
  +    if (!shorthandID)
  +        return DOMString();
  +    return getPropertyName(shorthandID);
  +}
  +
  +bool CSSStyleDeclarationImpl::isPropertyImplicit(const DOMString &propertyName)
  +{
  +    int propID = propertyID(propertyName);
  +    if (!propID)
  +        return false;
  +    return isPropertyImplicit(propID);
  +}
  +
   void CSSStyleDeclarationImpl::setProperty(const DOMString &propertyName, const DOMString &value, const DOMString &priority, int &exception)
   {
       int propID = propertyID(propertyName);
  @@ -385,8 +404,26 @@
   {
       QValueListConstIterator<CSSProperty> end;
       for (QValueListConstIterator<CSSProperty> it = m_values.begin(); it != end; ++it)
  -        if (propertyID == (*it).m_id)
  -            return (*it).m_bImportant;
  +        if (propertyID == (*it).id())
  +            return (*it).isImportant();
  +    return false;
  +}
  +
  +int CSSMutableStyleDeclarationImpl::getPropertyShorthand(int propertyID) const
  +{
  +    QValueListConstIterator<CSSProperty> end;
  +    for (QValueListConstIterator<CSSProperty> it = m_values.begin(); it != end; ++it)
  +        if (propertyID == (*it).id())
  +            return (*it).shorthandID();
  +    return false;
  +}
  +
  +bool CSSMutableStyleDeclarationImpl::isPropertyImplicit(int propertyID) const
  +{
  +    QValueListConstIterator<CSSProperty> end;
  +    for (QValueListConstIterator<CSSProperty> it = m_values.begin(); it != end; ++it)
  +        if (propertyID == (*it).id())
  +            return (*it).isImplicit();
       return false;
   }
   
  @@ -1337,12 +1374,12 @@
   
   DOMString CSSProperty::cssText() const
   {
  -    return getPropertyName(m_id) + DOMString(": ") + m_value->cssText() + (m_bImportant ? DOMString(" !important") : DOMString()) + DOMString("; ");
  +    return getPropertyName(id()) + DOMString(": ") + m_value->cssText() + (isImportant() ? DOMString(" !important") : DOMString()) + DOMString("; ");
   }
   
   bool operator==(const CSSProperty &a, const CSSProperty &b)
   {
  -    return a.m_id == b.m_id && a.m_bImportant == b.m_bImportant && a.m_value == b.m_value;
  +    return a.m_id == b.m_id && a.m_important == b.m_important && a.m_value == b.m_value;
   }
   
   }
  
  
  
  1.54      +40 -17    WebCore/khtml/css/css_valueimpl.h
  
  Index: css_valueimpl.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/css/css_valueimpl.h,v
  retrieving revision 1.53
  retrieving revision 1.54
  diff -u -r1.53 -r1.54
  --- css_valueimpl.h	21 Nov 2005 04:01:51 -0000	1.53
  +++ css_valueimpl.h	7 Dec 2005 01:12:36 -0000	1.54
  @@ -63,9 +63,14 @@
       CSSValueImpl *getPropertyCSSValue(const DOMString &propertyName);
       DOMString getPropertyValue(const DOMString &propertyName);
       DOMString getPropertyPriority(const DOMString &propertyName);
  +    DOMString getPropertyShorthand(const DOMString& propertyName);
  +    bool isPropertyImplicit(const DOMString& propertyName);
  +    
       virtual CSSValueImpl *getPropertyCSSValue(int propertyID) const = 0;
       virtual DOMString getPropertyValue(int propertyID) const = 0;
       virtual bool getPropertyPriority(int propertyID) const = 0;
  +    virtual int getPropertyShorthand(int propertyID) const = 0;
  +    virtual bool isPropertyImplicit(int propertyID) const = 0;
   
       void setProperty(const DOMString &propertyName, const DOMString &value, const DOMString &priority, int &exception);
       DOMString removeProperty(const DOMString &propertyName, int &exception);
  @@ -406,49 +411,65 @@
   class CSSProperty
   {
   public:
  -    CSSProperty() : m_id(-1), m_bImportant(false), m_value(0)
  -    {
  -    }
  -    CSSProperty(int propID, CSSValueImpl *value, bool important = false)
  -        : m_id(propID), m_bImportant(important), m_value(value)
  +    CSSProperty(int propID, CSSValueImpl *value, bool important = false, int shorthandID = 0, bool implicit = false)
  +        : m_id(propID), m_shorthandID(shorthandID), m_important(important), m_implicit(implicit), m_value(value)
       {
  -        if (value) value->ref();
  +        if (value)
  +            value->ref();
       }
  +    
       CSSProperty(const CSSProperty& o)
       {
           m_id = o.m_id;
  -        m_bImportant = o.m_bImportant;
  +        m_shorthandID = o.m_shorthandID;
  +        m_important = o.m_important;
  +        m_implicit = o.m_implicit;
           m_value = o.m_value;
  -        if (m_value) m_value->ref();
  +        if (m_value)
  +            m_value->ref();
       }
  +    
       CSSProperty &operator=(const CSSProperty& o)
       {
  -        if (o.m_value) o.m_value->ref();
  -	if (m_value) m_value->deref();
  +        if (o.m_value)
  +            o.m_value->ref();
  +	if (m_value)
  +            m_value->deref();
           m_id = o.m_id;
  -        m_bImportant = o.m_bImportant;
  +        m_shorthandID = o.m_shorthandID;
  +        m_important = o.m_important;
           m_value = o.m_value;
           return *this;
       }
  +    
       ~CSSProperty() {
  -	if(m_value) m_value->deref();
  +	if (m_value)
  +            m_value->deref();
       }
   
       void setValue(CSSValueImpl *val) {
  -	if (val) val->ref();
  -        if (m_value) m_value->deref();
  +	if (val)
  +            val->ref();
  +        if (m_value)
  +            m_value->deref();
           m_value = val;
       }
   
       int id() const { return m_id; }
  -    bool isImportant() const { return m_bImportant; }
  +    int shorthandID() const { return m_shorthandID; }
  +    
  +    bool isImportant() const { return m_important; }
  +    bool isImplicit() const { return m_implicit; }
  +
       CSSValueImpl *value() const { return m_value; }
       
       DOMString cssText() const;
   
       // make sure the following fits in 4 bytes.
  -    int  m_id;
  -    bool m_bImportant;
  +    int m_id;
  +    int m_shorthandID;  // If this property was set as part of a shorthand, gives the shorthand.
  +    bool m_important : 1;
  +    bool m_implicit  : 1; // Whether or not the property was set implicitly as the result of a shorthand.
   
       friend bool operator==(const CSSProperty &, const CSSProperty &);
   
  @@ -478,6 +499,8 @@
       virtual CSSValueImpl *getPropertyCSSValue(int propertyID) const;
       virtual DOMString getPropertyValue(int propertyID) const;
       virtual bool getPropertyPriority(int propertyID) const;
  +    virtual int getPropertyShorthand(int propertyID) const;
  +    virtual bool isPropertyImplicit(int propertyID) const;
   
       virtual void setProperty(int propertyId, const DOMString &value, bool important, int &exceptionCode);
       virtual DOMString removeProperty(int propertyID, int &exceptionCode);
  
  
  
  1.114     +106 -105  WebCore/khtml/css/cssparser.cpp
  
  Index: cssparser.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/css/cssparser.cpp,v
  retrieving revision 1.113
  retrieving revision 1.114
  diff -u -r1.113 -r1.114
  --- cssparser.cpp	21 Nov 2005 04:01:51 -0000	1.113
  +++ cssparser.cpp	7 Dec 2005 01:12:36 -0000	1.114
  @@ -2,7 +2,8 @@
    * This file is part of the DOM implementation for KDE.
    *
    * Copyright (C) 2003 Lars Knoll (knoll at kde.org)
  - * Copyright (C) 2004 Apple Computer, Inc.
  + * Copyright (C) 2005 Allan Sandfeld Jensen (kde at carewolf.com)
  + * Copyright (C) 2004, 2005 Apple Computer, Inc.
    *
    * This library is free software; you can redistribute it and/or
    * modify it under the terms of the GNU Library General Public
  @@ -102,8 +103,10 @@
       rule = 0;
       id = 0;
       important = false;
  -    inParseShortHand = false;
  -    
  +    m_inParseShorthand = 0;
  +    m_currentShorthand = 0;
  +    m_implicitShorthand = false;
  +
       defaultNamespace = starAtom;
       
       yy_start = 1;
  @@ -312,14 +315,10 @@
   }
   
   
  -void CSSParser::addProperty( int propId, CSSValueImpl *value, bool important )
  +void CSSParser::addProperty(int propId, CSSValueImpl *value, bool important)
   {
  -    CSSProperty *prop = new CSSProperty;
  -    prop->m_id = propId;
  -    prop->setValue( value );
  -    prop->m_bImportant = important;
  -
  -    if ( numParsedProperties >= maxParsedProperties ) {
  +    CSSProperty *prop = new CSSProperty(propId, value, important, m_currentShorthand, m_implicitShorthand);
  +    if (numParsedProperties >= maxParsedProperties) {
   	maxParsedProperties += 32;
   	parsedProperties = (CSSProperty **)fastRealloc(parsedProperties,
                                                          maxParsedProperties*sizeof(CSSProperty *));
  @@ -424,8 +423,7 @@
       if ( !value )
   	return false;
   
  -    int id = 0;
  -    id = value->id;
  +    int id = value->id;
   
       if (id == CSS_VAL_INHERIT) {
   	addProperty(propId, new CSSInheritedValueImpl(), important);
  @@ -519,7 +517,7 @@
   	    return parseDashboardRegions( propId, important );
   	break;
   
  -    /* Start of supported CSS properties with validation. This is needed for parseShortHand to work
  +    /* Start of supported CSS properties with validation. This is needed for parseShorthand to work
        * correctly and allows optimization in khtml::applyRule(..)
        */
       case CSS_PROP_CAPTION_SIDE:         // top | bottom | left | right | inherit
  @@ -1043,7 +1041,7 @@
           const int properties[5] = { CSS_PROP__KHTML_MARQUEE_DIRECTION, CSS_PROP__KHTML_MARQUEE_INCREMENT,
                                       CSS_PROP__KHTML_MARQUEE_REPETITION,
                                       CSS_PROP__KHTML_MARQUEE_STYLE, CSS_PROP__KHTML_MARQUEE_SPEED };
  -        return parseShortHand(properties, 5, important);
  +        return parseShorthand(propId, properties, 5, important);
       }
       case CSS_PROP__KHTML_MARQUEE_DIRECTION:
           if (id == CSS_VAL_FORWARDS || id == CSS_VAL_BACKWARDS || id == CSS_VAL_AHEAD ||
  @@ -1158,82 +1156,82 @@
       {
   	const int properties[3] = { CSS_PROP_BORDER_WIDTH, CSS_PROP_BORDER_STYLE,
   				    CSS_PROP_BORDER_COLOR };
  -	return parseShortHand(properties, 3, important);
  +	return parseShorthand(propId, properties, 3, important);
       }
       case CSS_PROP_BORDER_TOP:
       	// [ 'border-top-width' || 'border-style' || <color> ] | inherit
       {
   	const int properties[3] = { CSS_PROP_BORDER_TOP_WIDTH, CSS_PROP_BORDER_TOP_STYLE,
   				    CSS_PROP_BORDER_TOP_COLOR};
  -	return parseShortHand(properties, 3, important);
  +	return parseShorthand(propId, properties, 3, important);
       }
       case CSS_PROP_BORDER_RIGHT:
       	// [ 'border-right-width' || 'border-style' || <color> ] | inherit
       {
   	const int properties[3] = { CSS_PROP_BORDER_RIGHT_WIDTH, CSS_PROP_BORDER_RIGHT_STYLE,
   				    CSS_PROP_BORDER_RIGHT_COLOR };
  -	return parseShortHand(properties, 3, important);
  +	return parseShorthand(propId, properties, 3, important);
       }
       case CSS_PROP_BORDER_BOTTOM:
       	// [ 'border-bottom-width' || 'border-style' || <color> ] | inherit
       {
   	const int properties[3] = { CSS_PROP_BORDER_BOTTOM_WIDTH, CSS_PROP_BORDER_BOTTOM_STYLE,
   				    CSS_PROP_BORDER_BOTTOM_COLOR };
  -	return parseShortHand(properties, 3, important);
  +	return parseShorthand(propId, properties, 3, important);
       }
       case CSS_PROP_BORDER_LEFT:
       	// [ 'border-left-width' || 'border-style' || <color> ] | inherit
       {
   	const int properties[3] = { CSS_PROP_BORDER_LEFT_WIDTH, CSS_PROP_BORDER_LEFT_STYLE,
   				    CSS_PROP_BORDER_LEFT_COLOR };
  -	return parseShortHand(properties, 3, important);
  +	return parseShorthand(propId, properties, 3, important);
       }
       case CSS_PROP_OUTLINE:
       	// [ 'outline-color' || 'outline-style' || 'outline-width' ] | inherit
       {
   	const int properties[3] = { CSS_PROP_OUTLINE_WIDTH, CSS_PROP_OUTLINE_STYLE,
   				    CSS_PROP_OUTLINE_COLOR };
  -	return parseShortHand(properties, 3, important);
  +	return parseShorthand(propId, properties, 3, important);
       }
       case CSS_PROP_BORDER_COLOR:
       	// <color>{1,4} | inherit
       {
   	const int properties[4] = { CSS_PROP_BORDER_TOP_COLOR, CSS_PROP_BORDER_RIGHT_COLOR,
   				    CSS_PROP_BORDER_BOTTOM_COLOR, CSS_PROP_BORDER_LEFT_COLOR };
  -	return parse4Values(properties, important);
  +	return parse4Values(propId, properties, important);
       }
       case CSS_PROP_BORDER_WIDTH:
       	// <border-width>{1,4} | inherit
       {
   	const int properties[4] = { CSS_PROP_BORDER_TOP_WIDTH, CSS_PROP_BORDER_RIGHT_WIDTH,
   				    CSS_PROP_BORDER_BOTTOM_WIDTH, CSS_PROP_BORDER_LEFT_WIDTH };
  -	return parse4Values(properties, important);
  +	return parse4Values(propId, properties, important);
       }
       case CSS_PROP_BORDER_STYLE:
       	// <border-style>{1,4} | inherit
       {
   	const int properties[4] = { CSS_PROP_BORDER_TOP_STYLE, CSS_PROP_BORDER_RIGHT_STYLE,
   				    CSS_PROP_BORDER_BOTTOM_STYLE, CSS_PROP_BORDER_LEFT_STYLE };
  -	return parse4Values(properties, important);
  +	return parse4Values(propId, properties, important);
       }
       case CSS_PROP_MARGIN:
       	// <margin-width>{1,4} | inherit
       {
   	const int properties[4] = { CSS_PROP_MARGIN_TOP, CSS_PROP_MARGIN_RIGHT,
   				    CSS_PROP_MARGIN_BOTTOM, CSS_PROP_MARGIN_LEFT };
  -	return parse4Values(properties, important);
  +	return parse4Values(propId, properties, important);
       }
       case CSS_PROP_PADDING:
       	// <padding-width>{1,4} | inherit
       {
   	const int properties[4] = { CSS_PROP_PADDING_TOP, CSS_PROP_PADDING_RIGHT,
   				    CSS_PROP_PADDING_BOTTOM, CSS_PROP_PADDING_LEFT };
  -	return parse4Values(properties, important);
  +	return parse4Values(propId, properties, important);
       }
       case CSS_PROP_FONT:
       	// [ [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-height' ]?
   	// 'font-family' ] | caption | icon | menu | message-box | small-caption | status-bar | inherit
  -	if ( id >= CSS_VAL_CAPTION && id <= CSS_VAL_STATUS_BAR )
  +	if (id >= CSS_VAL_CAPTION && id <= CSS_VAL_STATUS_BAR)
   	    valid_primitive = true;
   	else
   	    return parseFont(important);
  @@ -1242,7 +1240,7 @@
       {
   	const int properties[3] = { CSS_PROP_LIST_STYLE_TYPE, CSS_PROP_LIST_STYLE_POSITION,
   				    CSS_PROP_LIST_STYLE_IMAGE };
  -	return parseShortHand(properties, 3, important);
  +	return parseShorthand(propId, properties, 3, important);
       }
       default:
   // #ifdef CSS_DEBUG
  @@ -1306,8 +1304,8 @@
           CSS_PROP_BACKGROUND_ATTACHMENT, CSS_PROP_BACKGROUND_POSITION, CSS_PROP_BACKGROUND_CLIP,
           CSS_PROP_BACKGROUND_ORIGIN, CSS_PROP_BACKGROUND_COLOR };
       
  -    inParseShortHand = true;
  -    
  +    enterShorthand(CSS_PROP_BACKGROUND);
  +
       bool parsedProperty[numProperties] = { false }; // compiler will repeat false as necessary
       CSSValueImpl* values[numProperties] = { 0 }; // compiler will repeat 0 as necessary
       CSSValueImpl* positionYValue = 0;
  @@ -1374,75 +1372,59 @@
               addProperty(properties[i], values[i], important);
       }
       
  -    inParseShortHand = false;
  +    exitShorthand();
       return true;
   
   fail:
  -    inParseShortHand = false;
  +    exitShorthand();
       for (int k = 0; k < numProperties; k++)
           delete values[k];
       delete positionYValue;
       return false;
   }
   
  -bool CSSParser::parseShortHand( const int *properties, int numProperties, bool important )
  +bool CSSParser::parseShorthand(int propId, const int *properties, int numProperties, bool important)
   {
  -    /* We try to match as many properties as possible
  -     * We setup an array of booleans to mark which property has been found,
  -     * and we try to search for properties until it makes no longer any sense
  -     */
  -    inParseShortHand = true;
  +    // We try to match as many properties as possible
  +    // We set up an array of booleans to mark which property has been found,
  +    // and we try to search for properties until it makes no longer any sense.
  +    enterShorthand(propId);
   
       bool found = false;
  -    bool fnd[6]; //Trust me ;)
  -    for( int i = 0; i < numProperties; i++ )
  +    bool fnd[6]; // Trust me ;)
  +    for (int i = 0; i < numProperties; i++)
       	fnd[i] = false;
   
  -#ifdef CSS_DEBUG
  -    kdDebug(6080) << "PSH: numProperties=" << numProperties << endl;
  -#endif
  -
  -    while ( valueList->current() ) {
  +    while (valueList->current()) {
           found = false;
  -	// qDebug("outer loop" );
  -        for (int propIndex = 0; !found && propIndex < numProperties; ++propIndex) {
  +	for (int propIndex = 0; !found && propIndex < numProperties; ++propIndex) {
               if (!fnd[propIndex]) {
  -#ifdef CSS_DEBUG
  -		kdDebug(6080) << "LOOKING FOR: " << getPropertyName(properties[propIndex]).qstring() << endl;
  -#endif
  -		if ( parseValue( properties[propIndex], important ) ) {
  +		if (parseValue( properties[propIndex], important))
   		    fnd[propIndex] = found = true;
  -#ifdef CSS_DEBUG
  -		    kdDebug(6080) << "FOUND: " << getPropertyName(properties[propIndex]).qstring() << endl;
  -#endif
  -		}
   	    }
   	}
  +
           // if we didn't find at least one match, this is an
           // invalid shorthand and we have to ignore it
           if (!found) {
  -#ifdef CSS_DEBUG
  -	    qDebug("didn't find anything" );
  -#endif
  -	    inParseShortHand = false;
  +	    exitShorthand();
   	    return false;
   	}
       }
       
       // Fill in any remaining properties with the initial value.
  +    m_implicitShorthand = true;
       for (int i = 0; i < numProperties; ++i) {
           if (!fnd[i])
               addProperty(properties[i], new CSSInitialValueImpl(), important);
       }
  -    
  -    inParseShortHand = false;
  -#ifdef CSS_DEBUG
  -    kdDebug( 6080 ) << "parsed shorthand" << endl;
  -#endif
  +    m_implicitShorthand = false;
  +
  +    exitShorthand();
       return true;
   }
   
  -bool CSSParser::parse4Values( const int *properties,  bool important )
  +bool CSSParser::parse4Values(int propId, const int *properties,  bool important)
   {
       /* From the CSS 2 specs, 8.3
        * If there is only one value, it applies to all sides. If there are two values, the top and
  @@ -1451,48 +1433,67 @@
        * second, and the bottom is set to the third. If there are four values, they apply to the top,
        * right, bottom, and left, respectively.
        */
  -
  -    int num = inParseShortHand ? 1 : valueList->numValues;
  -    // qDebug("parse4Values: num=%d", num );
  +    
  +    int num = inShorthand() ? 1 : valueList->numValues;
  +    
  +    enterShorthand(propId);
   
       // the order is top, right, bottom, left
  -    switch( num ) {
  -    case 1: {
  -        if( !parseValue( properties[0], important ) ) return false;
  -	CSSValueImpl *value = parsedProperties[numParsedProperties-1]->value();
  -	addProperty( properties[1], value, important );
  -	addProperty( properties[2], value, important );
  -	addProperty( properties[3], value, important );
  -        return true;
  -    }
  -    case 2: {
  -
  -        if( !parseValue( properties[0], important ) ) return false;
  -        if( !parseValue( properties[1], important ) ) return false;
  -	CSSValueImpl *value = parsedProperties[numParsedProperties-2]->value();
  -	addProperty( properties[2], value, important );
  -	value = parsedProperties[numParsedProperties-2]->value();
  -	addProperty( properties[3], value, important );
  -        return true;
  -    }
  -    case 3: {
  -        if( !parseValue( properties[0], important ) ) return false;
  -        if( !parseValue( properties[1], important ) ) return false;
  -        if( !parseValue( properties[2], important ) ) return false;
  -	CSSValueImpl *value = parsedProperties[numParsedProperties-2]->value();
  -	addProperty( properties[3], value, important );
  -        return true;
  -    }
  -    case 4: {
  -        if( !parseValue( properties[0], important ) ) return false;
  -        if( !parseValue( properties[1], important ) ) return false;
  -        if( !parseValue( properties[2], important ) ) return false;
  -        if( !parseValue( properties[3], important ) ) return false;
  -	return true;
  -    }
  -    default:
  -        return false;
  +    switch (num) {
  +        case 1: {
  +            if (!parseValue(properties[0], important)) {
  +                exitShorthand();
  +                return false;
  +            }
  +            CSSValueImpl *value = parsedProperties[numParsedProperties-1]->value();
  +            m_implicitShorthand = true;
  +            addProperty(properties[1], value, important);
  +            addProperty(properties[2], value, important);
  +            addProperty(properties[3], value, important);
  +            m_implicitShorthand = false;
  +            break;
  +        }
  +        case 2: {
  +            if (!parseValue(properties[0], important) || !parseValue(properties[1], important)) {
  +                exitShorthand();
  +                return false;
  +            }
  +            CSSValueImpl *value = parsedProperties[numParsedProperties-2]->value();
  +            m_implicitShorthand = true;
  +            addProperty(properties[2], value, important);
  +            value = parsedProperties[numParsedProperties-2]->value();
  +            addProperty(properties[3], value, important);
  +            m_implicitShorthand = false;
  +            break;
  +        }
  +        case 3: {
  +            if (!parseValue(properties[0], important) || !parseValue(properties[1], important) ||
  +                !parseValue(properties[2], important)) {
  +                exitShorthand();
  +                return false;
  +            }
  +            CSSValueImpl *value = parsedProperties[numParsedProperties-2]->value();
  +            m_implicitShorthand = true;
  +            addProperty(properties[3], value, important);
  +            m_implicitShorthand = false;
  +            break;
  +        }
  +        case 4: {
  +            if (!parseValue(properties[0], important) || !parseValue(properties[1], important) ||
  +                !parseValue(properties[2], important) || !parseValue(properties[3], important)) {
  +                exitShorthand();
  +                return false;
  +            }
  +            break;
  +        }
  +        default: {
  +            exitShorthand();
  +            return false;
  +        }
       }
  +    
  +    exitShorthand();
  +    return true;
   }
   
   // [ <string> | <uri> | <counter> | attr(X) | open-quote | close-quote | no-open-quote | no-close-quote ]+ | inherit
  @@ -1628,7 +1629,7 @@
           if (value2)
               valueList->next();
           else {
  -            if (!inParseShortHand) {
  +            if (!inShorthand()) {
                   delete value1;
                   value1 = 0;
                   return;
  @@ -1756,7 +1757,7 @@
           
           // When parsing the 'background' shorthand property, we let it handle building up the lists for all
           // properties.
  -        if (inParseShortHand)
  +        if (inShorthand())
               break;
       }
       
  
  
  
  1.34      +21 -7     WebCore/khtml/css/cssparser.h
  
  Index: cssparser.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/css/cssparser.h,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- cssparser.h	21 Nov 2005 04:01:52 -0000	1.33
  +++ cssparser.h	7 Dec 2005 01:12:36 -0000	1.34
  @@ -119,15 +119,15 @@
   
   	DOM::DocumentImpl *document() const;
   
  -	void addProperty( int propId, CSSValueImpl *value, bool important );
  +	void addProperty(int propId, CSSValueImpl *value, bool important);
   	bool hasProperties() const { return numParsedProperties > 0; }
   	CSSMutableStyleDeclarationImpl *createStyleDeclaration( CSSStyleRuleImpl *rule );
   	void clearProperties();
   
  -	bool parseValue( int propId, bool important );
  -	bool parseShortHand( const int *properties, int numProperties, bool important );
  -	bool parse4Values( const int *properties, bool important );
  -	bool parseContent( int propId, bool important );
  +	bool parseValue(int propId, bool important);
  +	bool parseShorthand(int propId, const int *properties, int numProperties, bool important);
  +	bool parse4Values(int propId, const int *properties, bool important);
  +	bool parseContent(int propId, bool important);
   
           CSSValueImpl* parseBackgroundColor();
           CSSValueImpl* parseBackgroundImage();
  @@ -170,7 +170,10 @@
   	CSSProperty **parsedProperties;
   	int numParsedProperties;
   	int maxParsedProperties;
  -	bool inParseShortHand;
  +	
  +        int m_inParseShorthand;
  +        int m_currentShorthand;
  +        bool m_implicitShorthand;
   
           AtomicString defaultNamespace;
           
  @@ -185,7 +188,18 @@
           
       private:
           void setupParser(const char *prefix, const DOMString &string, const char *suffix);
  -        
  +        void enterShorthand(int propId)
  +        {
  +            if (!(m_inParseShorthand++))
  +                m_currentShorthand = propId;
  +        }
  +        void exitShorthand()
  +        {
  +            if (!(--m_inParseShorthand))
  +                m_currentShorthand = 0;
  +        }
  +        bool inShorthand() const { return m_inParseShorthand; }
  +
   	unsigned short *data;
   	unsigned short *yytext;
   	unsigned short *yy_c_buf_p;
  
  
  
  1.226     +61 -5     WebCore/khtml/css/cssstyleselector.cpp
  
  Index: cssstyleselector.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/css/cssstyleselector.cpp,v
  retrieving revision 1.225
  retrieving revision 1.226
  diff -u -r1.225 -r1.226
  --- cssstyleselector.cpp	29 Nov 2005 11:20:43 -0000	1.225
  +++ cssstyleselector.cpp	7 Dec 2005 01:12:36 -0000	1.226
  @@ -2,7 +2,8 @@
    * This file is part of the CSS implementation for KDE.
    *
    * Copyright (C) 1999 Lars Knoll (knoll at kde.org)
  - * Copyright (C) 2004 Apple Computer, Inc.
  + *           (C) 2004-2005 Allan Sandfeld Jensen (kde at carewolf.com)
  + * Copyright (C) 2005 Apple Computer, Inc.
    *
    * This library is free software; you can redistribute it and/or
    * modify it under the terms of the GNU Library General Public
  @@ -254,6 +255,9 @@
           if (it.current()->isCSSStyleSheet())
               m_authorStyle->addRulesFromSheet(static_cast<CSSStyleSheetImpl*>(it.current()), m_medium);
   
  +    m_ruleList = 0;
  +    m_collectRulesOnly = false;
  +
       //kdDebug( 6080 ) << "number of style sheets in document " << authorStyleSheets.count() << endl;
       //kdDebug( 6080 ) << "CSSStyleSelector: author style has " << authorStyle->count() << " elements"<< endl;
   }
  @@ -386,8 +390,16 @@
       sortMatchedRules(0, m_matchedRuleCount);
       
       // Now transfer the set of matched rules over to our list of decls.
  -    for (unsigned i = 0; i < m_matchedRuleCount; i++)
  -        addMatchedDeclaration(m_matchedRules[i]->rule()->declaration());
  +    if (!m_collectRulesOnly) {
  +        for (unsigned i = 0; i < m_matchedRuleCount; i++)
  +            addMatchedDeclaration(m_matchedRules[i]->rule()->declaration());
  +    } else {
  +        for (unsigned i = 0; i < m_matchedRuleCount; i++) {
  +            if (!m_ruleList)
  +                m_ruleList = new CSSRuleListImpl();
  +            m_ruleList->append(m_matchedRules[i]->rule());
  +        }
  +    }
   }
   
   void CSSStyleSelector::matchRulesForList(CSSRuleDataList* rules,
  @@ -405,7 +417,7 @@
               
               // If we're matching normal rules, set a pseudo bit if 
               // we really just matched a pseudo-element.
  -            if (dynamicPseudo != RenderStyle::NOPSEUDO && pseudoStyle == RenderStyle::NOPSEUDO)
  +            if (!m_collectRulesOnly && dynamicPseudo != RenderStyle::NOPSEUDO && pseudoStyle == RenderStyle::NOPSEUDO)
                   style->setHasPseudoStyle(dynamicPseudo);
               else {
                   // Update our first/last rule indices in the matched rules array.
  @@ -529,7 +541,8 @@
       m_matchedRuleCount = 0;
       m_matchedDeclCount = 0;
       m_tmpRuleCount = 0;
  -    
  +    m_ruleList = 0;
  +
       fontDirty = false;
   }
   
  @@ -1044,6 +1057,49 @@
           view->useSlowRepaints();
   }
   
  +RefPtr<CSSRuleListImpl> CSSStyleSelector::styleRulesForElement(ElementImpl* e, bool authorOnly)
  +{
  +    if (!e->getDocument()->haveStylesheetsLoaded())
  +        return 0;
  +
  +    m_collectRulesOnly = true;
  +    
  +    initElementAndPseudoState(e);
  +    initForStyleResolve(e, 0);
  +    
  +    if (!authorOnly) {
  +        // First we match rules from the user agent sheet.
  +        int firstUARule = -1, lastUARule = -1;
  +        matchRules(defaultStyle, firstUARule, lastUARule);
  +        
  +        // In quirks mode, we match rules from the quirks user agent sheet.
  +        if (!strictParsing)
  +            matchRules(defaultQuirksStyle, firstUARule, lastUARule);
  +        
  +        // If our medium is print, then we match rules from the print sheet.
  +        if (m_medium == "print")
  +            matchRules(defaultPrintStyle, firstUARule, lastUARule);
  +
  +        // Now we check user sheet rules.
  +        int firstUserRule = -1, lastUserRule = -1;
  +        matchRules(m_userStyle, firstUserRule, lastUserRule);
  +    }
  +
  +    // Check the rules in author sheets.
  +    int firstAuthorRule = -1, lastAuthorRule = -1;
  +    matchRules(m_authorStyle, firstAuthorRule, lastAuthorRule);
  +    
  +    m_collectRulesOnly = false;
  +    
  +    return m_ruleList;
  +}
  +
  +RefPtr<CSSRuleListImpl> CSSStyleSelector::pseudoStyleRulesForElement(ElementImpl* e, DOMStringImpl* pseudoStyle, bool authorOnly)
  +{
  +    // FIXME: Implement this.
  +    return 0;
  +}
  +
   static bool subject;
   
   bool CSSStyleSelector::checkSelector(CSSSelector* sel, ElementImpl *e)
  
  
  
  1.47      +7 -1      WebCore/khtml/css/cssstyleselector.h
  
  Index: cssstyleselector.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/css/cssstyleselector.h,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- cssstyleselector.h	21 Nov 2005 04:01:52 -0000	1.46
  +++ cssstyleselector.h	7 Dec 2005 01:12:36 -0000	1.47
  @@ -114,6 +114,10 @@
           DOM::NodeImpl* locateCousinList(DOM::ElementImpl* parent);
           bool canShareStyleWithElement(DOM::NodeImpl* n);
           
  +        // These methods will give back the set of rules that matched for a given element (or a pseudo-element).
  +        RefPtr<DOM::CSSRuleListImpl> styleRulesForElement(DOM::ElementImpl* e, bool authorOnly);
  +        RefPtr<DOM::CSSRuleListImpl> pseudoStyleRulesForElement(DOM::ElementImpl* e, DOM::DOMStringImpl* pseudoStyle, bool authorOnly);
  +
   	bool strictParsing;
   	
           struct Encodedurl {
  @@ -210,7 +214,9 @@
           unsigned m_matchedRuleCount;
           QMemArray<CSSRuleData*> m_tmpRules;
           unsigned m_tmpRuleCount;
  -        
  +        DOM::CSSRuleListImpl* m_ruleList;
  +        bool m_collectRulesOnly;
  +
           QString m_medium;
   
   	RenderStyle::PseudoId dynamicPseudo;
  
  
  
  1.41      +6 -0      WebCore/khtml/ecma/kjs_css.cpp
  
  Index: kjs_css.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/ecma/kjs_css.cpp,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- kjs_css.cpp	21 Nov 2005 01:19:54 -0000	1.40
  +++ kjs_css.cpp	7 Dec 2005 01:12:37 -0000	1.41
  @@ -110,6 +110,8 @@
     getPropertyCSSValue	DOMCSSStyleDeclaration::GetPropertyCSSValue	DontDelete|Function 1
     removeProperty	DOMCSSStyleDeclaration::RemoveProperty		DontDelete|Function 1
     getPropertyPriority	DOMCSSStyleDeclaration::GetPropertyPriority	DontDelete|Function 1
  +  getPropertyShorthand  DOMCSSStyleDeclaration::GetPropertyShorthand    DontDelete|Function 1
  +  isPropertyImplicit    DOMCSSStyleDeclaration::IsPropertyImplicit      DontDelete|Function 1
     setProperty		DOMCSSStyleDeclaration::SetProperty		DontDelete|Function 3
     item			DOMCSSStyleDeclaration::Item			DontDelete|Function 1
   @end
  @@ -257,6 +259,10 @@
         return getStringOrNull(styleDecl.removeProperty(s, exception));
       case DOMCSSStyleDeclaration::GetPropertyPriority:
         return getStringOrNull(styleDecl.getPropertyPriority(s));
  +    case DOMCSSStyleDeclaration::GetPropertyShorthand:
  +      return getStringOrNull(styleDecl.getPropertyShorthand(s));
  +    case DOMCSSStyleDeclaration::IsPropertyImplicit:
  +      return Boolean(styleDecl.isPropertyImplicit(s));
       case DOMCSSStyleDeclaration::SetProperty:
         styleDecl.setProperty(s, args[1]->toString(exec).domString(), args[2]->toString(exec).domString(), exception);
         return Undefined();
  
  
  
  1.22      +1 -1      WebCore/khtml/ecma/kjs_css.h
  
  Index: kjs_css.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/ecma/kjs_css.h,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- kjs_css.h	1 Dec 2005 10:32:09 -0000	1.21
  +++ kjs_css.h	7 Dec 2005 01:12:37 -0000	1.22
  @@ -57,7 +57,7 @@
       static const ClassInfo info;
       enum { CssText, Length, ParentRule };
       enum { GetPropertyValue, GetPropertyCSSValue, RemoveProperty, 
  -           GetPropertyPriority, SetProperty, Item };
  +           GetPropertyPriority, GetPropertyShorthand, IsPropertyImplicit, SetProperty, Item };
       DOM::CSSStyleDeclarationImpl *impl() const { return m_impl.get(); }
     private:
       static ValueImp *indexGetter(ExecState *, const Identifier&, const PropertySlot&);
  
  
  
  1.18      +12 -1     WebCore/khtml/ecma/kjs_views.cpp
  
  Index: kjs_views.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/ecma/kjs_views.cpp,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- kjs_views.cpp	20 Nov 2005 21:34:14 -0000	1.17
  +++ kjs_views.cpp	7 Dec 2005 01:12:37 -0000	1.18
  @@ -32,7 +32,7 @@
   using DOM::DocumentImpl;
   using DOM::ElementImpl;
   using DOM::NodeImpl;
  -
  +using DOM::CSSRuleListImpl;
   
   #include "kjs_views.lut.h"
   
  @@ -47,6 +47,7 @@
   @end
   @begin DOMAbstractViewProtoTable 1
     getComputedStyle	DOMAbstractView::GetComputedStyle	DontDelete|Function 2
  +  getMatchedCSSRules    DOMAbstractView::GetMatchedCSSRules     DontDelete|Function 2
   @end
   */
   
  @@ -92,6 +93,16 @@
             return getDOMCSSStyleDeclaration(exec, abstractView.getComputedStyle(arg0, args[1]->toString(exec).domString().impl()));
           }
         }
  +    case DOMAbstractView::GetMatchedCSSRules: {
  +        ElementImpl *arg0 = toElement(args[0]);
  +        if (!arg0)
  +            return Undefined(); // throw exception?
  +        else {
  +            // No need to update layout, since we just want the back-end rules.
  +            return getDOMCSSRuleList(exec, abstractView.getMatchedCSSRules(arg0,
  +                                     args[1]->toString(exec).domString().impl()).get());
  +        }
  +    }
     }
     return Undefined();
   }
  
  
  
  1.14      +1 -1      WebCore/khtml/ecma/kjs_views.h
  
  Index: kjs_views.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/ecma/kjs_views.h,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- kjs_views.h	1 Dec 2005 10:32:10 -0000	1.13
  +++ kjs_views.h	7 Dec 2005 01:12:37 -0000	1.14
  @@ -39,7 +39,7 @@
       virtual const ClassInfo* classInfo() const { return &info; }
       static const ClassInfo info;
       DOM::AbstractViewImpl *impl() const { return m_impl.get(); }
  -    enum { Document, GetComputedStyle };
  +    enum { Document, GetComputedStyle, GetMatchedCSSRules };
     private:
       RefPtr<DOM::AbstractViewImpl> m_impl;
     };
  
  
  
  1.9       +10 -1     WebCore/khtml/xml/dom2_viewsimpl.cpp
  
  Index: dom2_viewsimpl.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/xml/dom2_viewsimpl.cpp,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- dom2_viewsimpl.cpp	20 Nov 2005 21:34:15 -0000	1.8
  +++ dom2_viewsimpl.cpp	7 Dec 2005 01:12:38 -0000	1.9
  @@ -26,6 +26,8 @@
   
   #include "css/css_computedstyle.h"
   #include "dom_elementimpl.h"
  +#include "dom_docimpl.h"
  +#include "cssstyleselector.h"
   
   namespace DOM {
   
  @@ -41,11 +43,18 @@
   CSSStyleDeclarationImpl *AbstractViewImpl::getComputedStyle(ElementImpl *elt, DOMStringImpl *pseudoElt)
   {
       // FIXME: This should work even if we do not have a renderer.
  -    
  +    // FIXME: This needs to work with pseudo elements.
       if (!elt || !elt->renderer())
           return 0;
   
       return new CSSComputedStyleDeclarationImpl(elt);
   }
   
  +RefPtr<CSSRuleListImpl> AbstractViewImpl::getMatchedCSSRules(ElementImpl* elt, DOMStringImpl* pseudoElt, bool authorOnly)
  +{
  +    if (pseudoElt && pseudoElt->l)
  +        return m_document->styleSelector()->pseudoStyleRulesForElement(elt, pseudoElt, authorOnly);
  +    return m_document->styleSelector()->styleRulesForElement(elt, authorOnly);
  +}
  +
   }
  
  
  
  1.11      +3 -0      WebCore/khtml/xml/dom2_viewsimpl.h
  
  Index: dom2_viewsimpl.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/xml/dom2_viewsimpl.h,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- dom2_viewsimpl.h	20 Nov 2005 21:34:15 -0000	1.10
  +++ dom2_viewsimpl.h	7 Dec 2005 01:12:38 -0000	1.11
  @@ -30,6 +30,7 @@
   
   class DocumentImpl;
   class CSSStyleDeclarationImpl;
  +class CSSRuleListImpl;
   class ElementImpl;
   class DOMStringImpl;
   
  @@ -42,6 +43,8 @@
   
       DocumentImpl *document() const { return m_document; }
       CSSStyleDeclarationImpl *getComputedStyle(ElementImpl *elt, DOMStringImpl *pseudoElt);
  +    RefPtr<CSSRuleListImpl> getMatchedCSSRules(ElementImpl *elt, DOMStringImpl *pseudoElt, bool authorOnly = true);
  +
   protected:
       DocumentImpl *m_document;
   };
  
  
  
  1.34      +16 -0     WebCore/kwq/DOM-CSS.mm
  
  Index: DOM-CSS.mm
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/DOM-CSS.mm,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- DOM-CSS.mm	29 Nov 2005 17:44:02 -0000	1.33
  +++ DOM-CSS.mm	7 Dec 2005 01:12:38 -0000	1.34
  @@ -757,6 +757,16 @@
       return [self _styleDeclarationImpl]->getPropertyPriority(propertyName);
   }
   
  +- (NSString *)getPropertyShorthand:(NSString *)propertyName
  +{
  +    return [self _styleDeclarationImpl]->getPropertyShorthand(propertyName);
  +}
  +
  +- (BOOL)isPropertyImplicit:(NSString *)propertyName
  +{
  +    return [self _styleDeclarationImpl]->isPropertyImplicit(propertyName);
  +}
  +
   - (void)setProperty:(NSString *)propertyName :(NSString *)value :(NSString *)priority
   {
       int exceptionCode;
  @@ -2516,4 +2526,10 @@
       return [DOMCSSStyleDeclaration _styleDeclarationWithImpl:[self _documentImpl]->defaultView()->getComputedStyle(elementImpl, pseudoEltString.impl())];
   }
   
  +- (DOMCSSRuleList *)getMatchedCSSRules:(DOMElement *)elt :(NSString *)pseudoElt
  +{
  +    // The parameter of "false" is handy for the DOM inspector and lets us see user agent and user rules.
  +    return [DOMCSSRuleList _ruleListWithImpl: AbstractViewImpl([self _documentImpl]).getMatchedCSSRules([elt _elementImpl], DOMString(pseudoElt).impl(), false).get()];
  +}
  +
   @end
  
  
  
  1.11      +4 -0      WebCore/kwq/DOMPrivate.h
  
  Index: DOMPrivate.h
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/DOMPrivate.h,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DOMPrivate.h	23 Nov 2005 09:46:57 -0000	1.10
  +++ DOMPrivate.h	7 Dec 2005 01:12:38 -0000	1.11
  @@ -85,6 +85,10 @@
   - (DOMCSSRuleList *)getMatchedCSSRules:(DOMElement *)elt :(NSString *)pseudoElt;
   @end
   
  + at interface DOMCSSStyleDeclaration (DOMCSSStyleDeclarationExtensions)
  +- (NSString *)getPropertyShorthand:(NSString *)propertyName;
  +- (BOOL)isPropertyImplicit:(NSString *)propertyName;
  + at end
   // END
   
   // Pending DOM3 APIs
  
  
  



More information about the webkit-changes mailing list