Home | History | Annotate | Download | only in chromium
      1 /*
      2  * Copyright (c) 2008, 2009, Google Inc. All rights reserved.
      3  *
      4  * Redistribution and use in source and binary forms, with or without
      5  * modification, are permitted provided that the following conditions are
      6  * met:
      7  *
      8  *     * Redistributions of source code must retain the above copyright
      9  * notice, this list of conditions and the following disclaimer.
     10  *     * Redistributions in binary form must reproduce the above
     11  * copyright notice, this list of conditions and the following disclaimer
     12  * in the documentation and/or other materials provided with the
     13  * distribution.
     14  *     * Neither the name of Google Inc. nor the names of its
     15  * contributors may be used to endorse or promote products derived from
     16  * this software without specific prior written permission.
     17  *
     18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     29  */
     30 
     31 #include "config.h"
     32 #include "Cursor.h"
     33 
     34 #include <wtf/Assertions.h>
     35 
     36 namespace WebCore {
     37 
     38 Cursor::Cursor(const Cursor& other)
     39     : m_platformCursor(other.m_platformCursor)
     40 {
     41 }
     42 
     43 Cursor::Cursor(Image* image, const IntPoint& hotSpot)
     44     : m_platformCursor(image, hotSpot)
     45 {
     46 }
     47 
     48 Cursor::~Cursor()
     49 {
     50 }
     51 
     52 Cursor& Cursor::operator=(const Cursor& other)
     53 {
     54     m_platformCursor = other.m_platformCursor;
     55     return *this;
     56 }
     57 
     58 Cursor::Cursor(PlatformCursor c)
     59     : m_platformCursor(c)
     60 {
     61 }
     62 
     63 const Cursor& pointerCursor()
     64 {
     65     static const Cursor c(PlatformCursor::TypePointer);
     66     return c;
     67 }
     68 
     69 const Cursor& crossCursor()
     70 {
     71     static const Cursor c(PlatformCursor::TypeCross);
     72     return c;
     73 }
     74 
     75 const Cursor& handCursor()
     76 {
     77     static const Cursor c(PlatformCursor::TypeHand);
     78     return c;
     79 }
     80 
     81 const Cursor& iBeamCursor()
     82 {
     83     static const Cursor c(PlatformCursor::TypeIBeam);
     84     return c;
     85 }
     86 
     87 const Cursor& waitCursor()
     88 {
     89     static const Cursor c(PlatformCursor::TypeWait);
     90     return c;
     91 }
     92 
     93 const Cursor& helpCursor()
     94 {
     95     static const Cursor c(PlatformCursor::TypeHelp);
     96     return c;
     97 }
     98 
     99 const Cursor& eastResizeCursor()
    100 {
    101     static const Cursor c(PlatformCursor::TypeEastResize);
    102     return c;
    103 }
    104 
    105 const Cursor& northResizeCursor()
    106 {
    107     static const Cursor c(PlatformCursor::TypeNorthResize);
    108     return c;
    109 }
    110 
    111 const Cursor& northEastResizeCursor()
    112 {
    113     static const Cursor c(PlatformCursor::TypeNorthEastResize);
    114     return c;
    115 }
    116 
    117 const Cursor& northWestResizeCursor()
    118 {
    119     static const Cursor c(PlatformCursor::TypeNorthWestResize);
    120     return c;
    121 }
    122 
    123 const Cursor& southResizeCursor()
    124 {
    125     static const Cursor c(PlatformCursor::TypeSouthResize);
    126     return c;
    127 }
    128 
    129 const Cursor& southEastResizeCursor()
    130 {
    131     static const Cursor c(PlatformCursor::TypeSouthEastResize);
    132     return c;
    133 }
    134 
    135 const Cursor& southWestResizeCursor()
    136 {
    137     static const Cursor c(PlatformCursor::TypeSouthWestResize);
    138     return c;
    139 }
    140 
    141 const Cursor& westResizeCursor()
    142 {
    143     static const Cursor c(PlatformCursor::TypeWestResize);
    144     return c;
    145 }
    146 
    147 const Cursor& northSouthResizeCursor()
    148 {
    149     static const Cursor c(PlatformCursor::TypeNorthSouthResize);
    150     return c;
    151 }
    152 
    153 const Cursor& eastWestResizeCursor()
    154 {
    155     static const Cursor c(PlatformCursor::TypeEastWestResize);
    156     return c;
    157 }
    158 
    159 const Cursor& northEastSouthWestResizeCursor()
    160 {
    161     static const Cursor c(PlatformCursor::TypeNorthEastSouthWestResize);
    162     return c;
    163 }
    164 
    165 const Cursor& northWestSouthEastResizeCursor()
    166 {
    167     static const Cursor c(PlatformCursor::TypeNorthWestSouthEastResize);
    168     return c;
    169 }
    170 
    171 const Cursor& columnResizeCursor()
    172 {
    173     static const Cursor c(PlatformCursor::TypeColumnResize);
    174     return c;
    175 }
    176 
    177 const Cursor& rowResizeCursor()
    178 {
    179     static const Cursor c(PlatformCursor::TypeRowResize);
    180     return c;
    181 }
    182 
    183 const Cursor& middlePanningCursor()
    184 {
    185     static const Cursor c(PlatformCursor::TypeMiddlePanning);
    186     return c;
    187 }
    188 
    189 const Cursor& eastPanningCursor()
    190 {
    191     static const Cursor c(PlatformCursor::TypeEastPanning);
    192     return c;
    193 }
    194 
    195 const Cursor& northPanningCursor()
    196 {
    197     static const Cursor c(PlatformCursor::TypeNorthPanning);
    198     return c;
    199 }
    200 
    201 const Cursor& northEastPanningCursor()
    202 {
    203     static const Cursor c(PlatformCursor::TypeNorthEastPanning);
    204     return c;
    205 }
    206 
    207 const Cursor& northWestPanningCursor()
    208 {
    209     static const Cursor c(PlatformCursor::TypeNorthWestPanning);
    210     return c;
    211 }
    212 
    213 const Cursor& southPanningCursor()
    214 {
    215     static const Cursor c(PlatformCursor::TypeSouthPanning);
    216     return c;
    217 }
    218 
    219 const Cursor& southEastPanningCursor()
    220 {
    221     static const Cursor c(PlatformCursor::TypeSouthEastPanning);
    222     return c;
    223 }
    224 
    225 const Cursor& southWestPanningCursor()
    226 {
    227     static const Cursor c(PlatformCursor::TypeSouthWestPanning);
    228     return c;
    229 }
    230 
    231 const Cursor& westPanningCursor()
    232 {
    233     static const Cursor c(PlatformCursor::TypeWestPanning);
    234     return c;
    235 }
    236 
    237 const Cursor& moveCursor()
    238 {
    239     static const Cursor c(PlatformCursor::TypeMove);
    240     return c;
    241 }
    242 
    243 const Cursor& verticalTextCursor()
    244 {
    245     static const Cursor c(PlatformCursor::TypeVerticalText);
    246     return c;
    247 }
    248 
    249 const Cursor& cellCursor()
    250 {
    251     static const Cursor c(PlatformCursor::TypeCell);
    252     return c;
    253 }
    254 
    255 const Cursor& contextMenuCursor()
    256 {
    257     static const Cursor c(PlatformCursor::TypeContextMenu);
    258     return c;
    259 }
    260 
    261 const Cursor& aliasCursor()
    262 {
    263     static const Cursor c(PlatformCursor::TypeAlias);
    264     return c;
    265 }
    266 
    267 const Cursor& progressCursor()
    268 {
    269     static const Cursor c(PlatformCursor::TypeProgress);
    270     return c;
    271 }
    272 
    273 const Cursor& noDropCursor()
    274 {
    275     static const Cursor c(PlatformCursor::TypeNoDrop);
    276     return c;
    277 }
    278 
    279 const Cursor& copyCursor()
    280 {
    281     static const Cursor c(PlatformCursor::TypeCopy);
    282     return c;
    283 }
    284 
    285 const Cursor& noneCursor()
    286 {
    287     static const Cursor c(PlatformCursor::TypeNone);
    288     return c;
    289 }
    290 
    291 const Cursor& notAllowedCursor()
    292 {
    293     static const Cursor c(PlatformCursor::TypeNotAllowed);
    294     return c;
    295 }
    296 
    297 const Cursor& zoomInCursor()
    298 {
    299     static const Cursor c(PlatformCursor::TypeZoomIn);
    300     return c;
    301 }
    302 
    303 const Cursor& zoomOutCursor()
    304 {
    305     static const Cursor c(PlatformCursor::TypeZoomOut);
    306     return c;
    307 }
    308 
    309 const Cursor& grabCursor()
    310 {
    311     static const Cursor c(PlatformCursor::TypeGrab);
    312     return c;
    313 }
    314 
    315 const Cursor& grabbingCursor()
    316 {
    317     static const Cursor c(PlatformCursor::TypeGrabbing);
    318     return c;
    319 }
    320 
    321 } // namespace WebCore
    322 
    323 #define COMPILE_ASSERT_MATCHING_ENUM(cursor_name, platform_cursor_name) \
    324     COMPILE_ASSERT(int(WebCore::Cursor::cursor_name) == int(WebCore::PlatformCursor::platform_cursor_name), mismatching_enums)
    325 
    326 COMPILE_ASSERT_MATCHING_ENUM(Pointer, TypePointer);
    327 COMPILE_ASSERT_MATCHING_ENUM(Cross, TypeCross);
    328 COMPILE_ASSERT_MATCHING_ENUM(Hand, TypeHand);
    329 COMPILE_ASSERT_MATCHING_ENUM(IBeam, TypeIBeam);
    330 COMPILE_ASSERT_MATCHING_ENUM(Wait, TypeWait);
    331 COMPILE_ASSERT_MATCHING_ENUM(Help, TypeHelp);
    332 COMPILE_ASSERT_MATCHING_ENUM(EastResize, TypeEastResize);
    333 COMPILE_ASSERT_MATCHING_ENUM(NorthResize, TypeNorthResize);
    334 COMPILE_ASSERT_MATCHING_ENUM(NorthEastResize, TypeNorthEastResize);
    335 COMPILE_ASSERT_MATCHING_ENUM(NorthWestResize, TypeNorthWestResize);
    336 COMPILE_ASSERT_MATCHING_ENUM(SouthResize, TypeSouthResize);
    337 COMPILE_ASSERT_MATCHING_ENUM(SouthEastResize, TypeSouthEastResize);
    338 COMPILE_ASSERT_MATCHING_ENUM(SouthWestResize, TypeSouthWestResize);
    339 COMPILE_ASSERT_MATCHING_ENUM(WestResize, TypeWestResize);
    340 COMPILE_ASSERT_MATCHING_ENUM(NorthSouthResize, TypeNorthSouthResize);
    341 COMPILE_ASSERT_MATCHING_ENUM(EastWestResize, TypeEastWestResize);
    342 COMPILE_ASSERT_MATCHING_ENUM(NorthEastSouthWestResize, TypeNorthEastSouthWestResize);
    343 COMPILE_ASSERT_MATCHING_ENUM(NorthWestSouthEastResize, TypeNorthWestSouthEastResize);
    344 COMPILE_ASSERT_MATCHING_ENUM(ColumnResize, TypeColumnResize);
    345 COMPILE_ASSERT_MATCHING_ENUM(RowResize, TypeRowResize);
    346 COMPILE_ASSERT_MATCHING_ENUM(MiddlePanning, TypeMiddlePanning);
    347 COMPILE_ASSERT_MATCHING_ENUM(EastPanning, TypeEastPanning);
    348 COMPILE_ASSERT_MATCHING_ENUM(NorthPanning, TypeNorthPanning);
    349 COMPILE_ASSERT_MATCHING_ENUM(NorthEastPanning, TypeNorthEastPanning);
    350 COMPILE_ASSERT_MATCHING_ENUM(NorthWestPanning, TypeNorthWestPanning);
    351 COMPILE_ASSERT_MATCHING_ENUM(SouthPanning, TypeSouthPanning);
    352 COMPILE_ASSERT_MATCHING_ENUM(SouthEastPanning, TypeSouthEastPanning);
    353 COMPILE_ASSERT_MATCHING_ENUM(SouthWestPanning, TypeSouthWestPanning);
    354 COMPILE_ASSERT_MATCHING_ENUM(WestPanning, TypeWestPanning);
    355 COMPILE_ASSERT_MATCHING_ENUM(Move, TypeMove);
    356 COMPILE_ASSERT_MATCHING_ENUM(VerticalText, TypeVerticalText);
    357 COMPILE_ASSERT_MATCHING_ENUM(Cell, TypeCell);
    358 COMPILE_ASSERT_MATCHING_ENUM(ContextMenu, TypeContextMenu);
    359 COMPILE_ASSERT_MATCHING_ENUM(Alias, TypeAlias);
    360 COMPILE_ASSERT_MATCHING_ENUM(Progress, TypeProgress);
    361 COMPILE_ASSERT_MATCHING_ENUM(NoDrop, TypeNoDrop);
    362 COMPILE_ASSERT_MATCHING_ENUM(Copy, TypeCopy);
    363 COMPILE_ASSERT_MATCHING_ENUM(None, TypeNone);
    364 COMPILE_ASSERT_MATCHING_ENUM(NotAllowed, TypeNotAllowed);
    365 COMPILE_ASSERT_MATCHING_ENUM(ZoomIn, TypeZoomIn);
    366 COMPILE_ASSERT_MATCHING_ENUM(ZoomOut, TypeZoomOut);
    367 COMPILE_ASSERT_MATCHING_ENUM(Grab, TypeGrab);
    368 COMPILE_ASSERT_MATCHING_ENUM(Grabbing, TypeGrabbing);
    369 COMPILE_ASSERT_MATCHING_ENUM(Custom, TypeCustom);
    370