Changeset 91170 in webkit


Ignore:
Timestamp:
Jul 17, 2011 6:59:55 PM (13 years ago)
Author:
macpherson@chromium.org
Message:

Implement CSSPropertyCursor in CSSStyleApplyProperty
https://bugs.webkit.org/show_bug.cgi?id=64432

Reviewed by Dimitri Glazkov.

No new tests / refectoring only.

  • css/CSSStyleApplyProperty.cpp:

Add handler for CSSPropertyCursor.

  • css/CSSStyleSelector.cpp:

Remove current handler of CSSPropertyCursor.

  • css/CSSStyleSelector.h:

Make styleImage and cachedOrPendingFromValue public.

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r91161 r91170  
     12011-07-17  Luke Macpherson   <macpherson@chromium.org>
     2
     3        Implement CSSPropertyCursor in CSSStyleApplyProperty
     4        https://bugs.webkit.org/show_bug.cgi?id=64432
     5
     6        Reviewed by Dimitri Glazkov.
     7
     8        No new tests / refectoring only.
     9
     10        * css/CSSStyleApplyProperty.cpp:
     11        Add handler for CSSPropertyCursor.
     12        * css/CSSStyleSelector.cpp:
     13        Remove current handler of CSSPropertyCursor.
     14        * css/CSSStyleSelector.h:
     15        Make styleImage and cachedOrPendingFromValue public.
     16
    1172011-07-16  Simon Fraser  <simon.fraser@apple.com>
    218
  • trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp

    r91043 r91170  
    2626#include "CSSStyleApplyProperty.h"
    2727
     28#include "CSSCursorImageValue.h"
    2829#include "CSSPrimitiveValueMappings.h"
    2930#include "CSSStyleSelector.h"
    3031#include "CSSValueList.h"
     32#include "CursorList.h"
    3133#include "Document.h"
    3234#include "Element.h"
     
    505507};
    506508
     509class ApplyPropertyCursor : public ApplyPropertyBase {
     510private:
     511    virtual void applyInheritValue(CSSStyleSelector* selector) const
     512    {
     513        selector->style()->setCursor(selector->parentStyle()->cursor());
     514        selector->style()->setCursorList(selector->parentStyle()->cursors());
     515    }
     516
     517    virtual void applyInitialValue(CSSStyleSelector* selector) const
     518    {
     519        selector->style()->clearCursorList();
     520        selector->style()->setCursor(RenderStyle::initialCursor());
     521    }
     522
     523    virtual void applyValue(CSSStyleSelector* selector, CSSValue* value) const
     524    {
     525        selector->style()->clearCursorList();
     526        if (value->isValueList()) {
     527            CSSValueList* list = static_cast<CSSValueList*>(value);
     528            int len = list->length();
     529            selector->style()->setCursor(CURSOR_AUTO);
     530            for (int i = 0; i < len; i++) {
     531                CSSValue* item = list->itemWithoutBoundsCheck(i);
     532                if (!item->isPrimitiveValue())
     533                    continue;
     534                CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(item);
     535                int type = primitiveValue->primitiveType();
     536                if (type == CSSPrimitiveValue::CSS_URI) {
     537                    if (primitiveValue->isCursorImageValue()) {
     538                        CSSCursorImageValue* image = static_cast<CSSCursorImageValue*>(primitiveValue);
     539                        if (image->updateIfSVGCursorIsUsed(selector->element())) // Elements with SVG cursors are not allowed to share style.
     540                            selector->style()->setUnique();
     541                        selector->style()->addCursor(selector->cachedOrPendingFromValue(CSSPropertyCursor, image), image->hotSpot());
     542                    }
     543                } else if (type == CSSPrimitiveValue::CSS_IDENT)
     544                    selector->style()->setCursor(*primitiveValue);
     545            }
     546        } else if (value->isPrimitiveValue()) {
     547            CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
     548            int type = primitiveValue->primitiveType();
     549            if (type == CSSPrimitiveValue::CSS_IDENT && selector->style()->cursor() != ECursor(*primitiveValue))
     550                selector->style()->setCursor(*primitiveValue);
     551        }
     552    }
     553};
     554
    507555const CSSStyleApplyProperty& CSSStyleApplyProperty::sharedCSSStyleApplyProperty()
    508556{
     
    619667    setPropertyHandler(CSSPropertyWordSpacing, new ApplyPropertyComputeLength<int, NormalEnabled, ThicknessDisabled, SVGZoomEnabled>(&RenderStyle::wordSpacing, &RenderStyle::setWordSpacing, &RenderStyle::initialLetterWordSpacing));
    620668
     669    setPropertyHandler(CSSPropertyCursor, new ApplyPropertyCursor());
     670
    621671    setPropertyHandler(CSSPropertyFontStyle, new ApplyPropertyFont<FontItalic>(&FontDescription::italic, &FontDescription::setItalic, FontItalicOff));
    622672    setPropertyHandler(CSSPropertyFontVariant, new ApplyPropertyFont<FontSmallCaps>(&FontDescription::smallCaps, &FontDescription::setSmallCaps, FontSmallCapsOff));
  • trunk/Source/WebCore/css/CSSStyleSelector.cpp

    r91151 r91170  
    38143814        HANDLE_INHERIT_AND_INITIAL_AND_PRIMITIVE(whiteSpace, WhiteSpace)
    38153815        return;
    3816     case CSSPropertyCursor:
    3817         if (isInherit) {
    3818             m_style->setCursor(m_parentStyle->cursor());
    3819             m_style->setCursorList(m_parentStyle->cursors());
    3820             return;
    3821         }
    3822         m_style->clearCursorList();
    3823         if (isInitial) {
    3824             m_style->setCursor(RenderStyle::initialCursor());
    3825             return;
    3826         }
    3827         if (value->isValueList()) {
    3828             CSSValueList* list = static_cast<CSSValueList*>(value);
    3829             int len = list->length();
    3830             m_style->setCursor(CURSOR_AUTO);
    3831             for (int i = 0; i < len; i++) {
    3832                 CSSValue* item = list->itemWithoutBoundsCheck(i);
    3833                 if (!item->isPrimitiveValue())
    3834                     continue;
    3835                 primitiveValue = static_cast<CSSPrimitiveValue*>(item);
    3836                 int type = primitiveValue->primitiveType();
    3837                 if (type == CSSPrimitiveValue::CSS_URI) {
    3838                     if (primitiveValue->isCursorImageValue()) {
    3839                         CSSCursorImageValue* image = static_cast<CSSCursorImageValue*>(primitiveValue);
    3840                         if (image->updateIfSVGCursorIsUsed(m_element)) // Elements with SVG cursors are not allowed to share style.
    3841                             m_style->setUnique();
    3842                         m_style->addCursor(cachedOrPendingFromValue(CSSPropertyCursor, image), image->hotSpot());
    3843                     }
    3844                 } else if (type == CSSPrimitiveValue::CSS_IDENT)
    3845                     m_style->setCursor(*primitiveValue);
    3846             }
    3847         } else if (primitiveValue) {
    3848             int type = primitiveValue->primitiveType();
    3849             if (type == CSSPrimitiveValue::CSS_IDENT && m_style->cursor() != ECursor(*primitiveValue))
    3850                 m_style->setCursor(*primitiveValue);
    3851         }
    3852         return;
    3853    
    38543816// uri || inherit
    38553817    case CSSPropertyListStyleImage:
     
    54295391    case CSSPropertyWebkitPerspectiveOriginX:
    54305392    case CSSPropertyWebkitPerspectiveOriginY:
     5393    case CSSPropertyCursor:
    54315394        ASSERT_NOT_REACHED();
    54325395        return;
  • trunk/Source/WebCore/css/CSSStyleSelector.h

    r91038 r91170  
    305305        };
    306306
     307        StyleImage* styleImage(CSSPropertyID, CSSValue*);
     308        StyleImage* cachedOrPendingFromValue(CSSPropertyID, CSSImageValue*);
     309
    307310    private:
    308311        static RenderStyle* s_styleNotYetAvailable;
     
    347350
    348351        void loadPendingImages();
    349        
    350         StyleImage* styleImage(CSSPropertyID, CSSValue* value);
    351         StyleImage* cachedOrPendingFromValue(CSSPropertyID property, CSSImageValue* value);
    352352
    353353        // We collect the set of decls that match in |m_matchedDecls|.  We then walk the
Note: See TracChangeset for help on using the changeset viewer.