Changeset 132966 in webkit


Ignore:
Timestamp:
Oct 30, 2012 5:03:27 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

cssText for cursor property doesn't include hotspot
https://bugs.webkit.org/show_bug.cgi?id=99530

Patch by Rick Byers <rbyers@chromium.org> on 2012-10-30
Reviewed by Darin Adler.

Source/WebCore:

Implement customCssText in CSSCursorImageValue to include the hotspot when present.
Also explicitly track whether or not a hotspot was supplied in the parser,
while still using the existing convention of (-1,-1) to denote no hotspot
in the rest of the system.

Test: fast/css/cursor-parsing.html

  • css/CSSCursorImageValue.cpp:

(WebCore::CSSCursorImageValue::customCssText):

  • css/CSSCursorImageValue.h:

(CSSCursorImageValue):

LayoutTests:

Add simple test for parsing of CSS cursor property.

  • fast/css/cursor-parsing-expected.txt: Added.
  • fast/css/cursor-parsing.html: Added.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r132964 r132966  
     12012-10-30  Rick Byers  <rbyers@chromium.org>
     2
     3        cssText for cursor property doesn't include hotspot
     4        https://bugs.webkit.org/show_bug.cgi?id=99530
     5
     6        Reviewed by Darin Adler.
     7
     8        Add simple test for parsing of CSS cursor property.
     9
     10        * fast/css/cursor-parsing-expected.txt: Added.
     11        * fast/css/cursor-parsing.html: Added.
     12
    1132012-10-30  Roger Fong  <roger_fong@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r132965 r132966  
     12012-10-30  Rick Byers  <rbyers@chromium.org>
     2
     3        cssText for cursor property doesn't include hotspot
     4        https://bugs.webkit.org/show_bug.cgi?id=99530
     5
     6        Reviewed by Darin Adler.
     7
     8        Implement customCssText in CSSCursorImageValue to include the hotspot when present.
     9        Also explicitly track whether or not a hotspot was supplied in the parser,
     10        while still using the existing convention of (-1,-1) to denote no hotspot
     11        in the rest of the system.
     12
     13        Test: fast/css/cursor-parsing.html
     14
     15        * css/CSSCursorImageValue.cpp:
     16        (WebCore::CSSCursorImageValue::customCssText):
     17        * css/CSSCursorImageValue.h:
     18        (CSSCursorImageValue):
     19
    1202012-10-30  Kenneth Russell  <kbr@google.com>
    221
  • trunk/Source/WebCore/css/CSSCursorImageValue.cpp

    r129637 r132966  
    5757#endif
    5858
    59 CSSCursorImageValue::CSSCursorImageValue(const String& url, const IntPoint& hotSpot)
     59CSSCursorImageValue::CSSCursorImageValue(const String& url, bool hasHotSpot, const IntPoint& hotSpot)
    6060    : CSSImageValue(CursorImageClass, url)
     61    , m_hasHotSpot(hasHotSpot)
    6162    , m_hotSpot(hotSpot)
    6263{
     
    8182}
    8283
     84String CSSCursorImageValue::customCssText() const
     85{
     86    StringBuilder result;
     87    result.append(CSSImageValue::customCssText());
     88    if (m_hasHotSpot) {
     89        result.append(' ');
     90        result.appendNumber(m_hotSpot.x());
     91        result.append(' ');
     92        result.appendNumber(m_hotSpot.y());
     93    }
     94    return result.toString();
     95}
     96
    8397bool CSSCursorImageValue::updateIfSVGCursorIsUsed(Element* element)
    8498{
     
    95109        // FIXME: This will override hot spot specified in CSS, which is probably incorrect.
    96110        SVGLengthContext lengthContext(0);
     111        m_hasHotSpot = true;
    97112        float x = roundf(cursorElement->x().value(lengthContext));
    98113        m_hotSpot.setX(static_cast<int>(x));
  • trunk/Source/WebCore/css/CSSCursorImageValue.h

    r124768 r132966  
    3333class CSSCursorImageValue : public CSSImageValue {
    3434public:
    35     static PassRefPtr<CSSCursorImageValue> create(const String& url, const IntPoint& hotSpot)
     35    static PassRefPtr<CSSCursorImageValue> create(const String& url, bool hasHotSpot, const IntPoint& hotSpot)
    3636    {
    37         return adoptRef(new CSSCursorImageValue(url, hotSpot));
     37        return adoptRef(new CSSCursorImageValue(url, hasHotSpot, hotSpot));
    3838    }
    3939
    4040    ~CSSCursorImageValue();
    4141
    42     IntPoint hotSpot() const { return m_hotSpot; }
     42    bool hasHotSpot() const { return m_hasHotSpot; }
     43
     44    IntPoint hotSpot() const
     45    {
     46        if (m_hasHotSpot)
     47            return m_hotSpot;
     48        return IntPoint(-1, -1);
     49    }
     50
     51    String customCssText() const;
    4352
    4453    bool updateIfSVGCursorIsUsed(Element*);
     
    5261
    5362private:
    54     CSSCursorImageValue(const String& url, const IntPoint& hotSpot);
     63    CSSCursorImageValue(const String& url, bool hasHotSpot, const IntPoint& hotSpot);
    5564
     65    bool m_hasHotSpot;
    5666    IntPoint m_hotSpot;
    5767
  • trunk/Source/WebCore/css/CSSParser.cpp

    r132942 r132966  
    18751875                value = m_valueList->next();
    18761876            }
     1877            bool hasHotSpot = false;
    18771878            IntPoint hotSpot(-1, -1);
    18781879            int nrcoords = coords.size();
    18791880            if (nrcoords > 0 && nrcoords != 2)
    18801881                return false;
    1881             if (nrcoords == 2)
     1882            if (nrcoords == 2) {
     1883                hasHotSpot = true;
    18821884                hotSpot = IntPoint(coords[0], coords[1]);
     1885            }
    18831886
    18841887            if (!uri.isNull())
    1885                 list->append(CSSCursorImageValue::create(completeURL(uri), hotSpot));
     1888                list->append(CSSCursorImageValue::create(completeURL(uri), hasHotSpot, hotSpot));
    18861889
    18871890            if ((inStrictMode() && !value) || (value && !(value->unit == CSSParserValue::Operator && value->iValue == ',')))
Note: See TracChangeset for help on using the changeset viewer.