1 /* 2 * Copyright (C) 2006 Apple Computer, 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 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26 #ifndef ScrollTypes_h 27 #define ScrollTypes_h 28 29 #include "wtf/Assertions.h" 30 31 namespace WebCore { 32 33 enum ScrollDirection { 34 ScrollUp, 35 ScrollDown, 36 ScrollLeft, 37 ScrollRight, 38 39 ScrollBlockDirectionBackward, 40 ScrollBlockDirectionForward, 41 ScrollInlineDirectionBackward, 42 ScrollInlineDirectionForward 43 }; 44 45 inline bool isLogical(ScrollDirection direction) 46 { 47 return direction >= ScrollBlockDirectionBackward; 48 } 49 50 // Convert logical scroll direction to physical. Physical scroll directions are unaffected. 51 inline ScrollDirection toPhysicalDirection(ScrollDirection direction, bool isVertical, bool isFlipped) 52 { 53 switch (direction) { 54 case ScrollBlockDirectionBackward: { 55 if (isVertical) { 56 if (!isFlipped) 57 return ScrollUp; 58 return ScrollDown; 59 } 60 if (!isFlipped) 61 return ScrollLeft; 62 return ScrollRight; 63 } 64 case ScrollBlockDirectionForward: { 65 if (isVertical) { 66 if (!isFlipped) 67 return ScrollDown; 68 return ScrollUp; 69 } 70 if (!isFlipped) 71 return ScrollRight; 72 return ScrollLeft; 73 } 74 case ScrollInlineDirectionBackward: { 75 if (isVertical) { 76 if (!isFlipped) 77 return ScrollLeft; 78 return ScrollRight; 79 } 80 if (!isFlipped) 81 return ScrollUp; 82 return ScrollDown; 83 } 84 case ScrollInlineDirectionForward: { 85 if (isVertical) { 86 if (!isFlipped) 87 return ScrollRight; 88 return ScrollLeft; 89 } 90 if (!isFlipped) 91 return ScrollDown; 92 return ScrollUp; 93 } 94 // Direction is already physical 95 case ScrollUp: 96 case ScrollDown: 97 case ScrollLeft: 98 case ScrollRight: 99 return direction; 100 default: 101 ASSERT_NOT_REACHED(); 102 break; 103 } 104 return direction; 105 } 106 107 enum ScrollGranularity { 108 ScrollByLine, 109 ScrollByPage, 110 ScrollByDocument, 111 ScrollByPixel, 112 ScrollByPrecisePixel 113 }; 114 115 enum ScrollElasticity { 116 ScrollElasticityAutomatic, 117 ScrollElasticityNone, 118 ScrollElasticityAllowed 119 }; 120 121 enum ScrollbarOrientation { HorizontalScrollbar, VerticalScrollbar }; 122 123 enum ScrollbarMode { ScrollbarAuto, ScrollbarAlwaysOff, ScrollbarAlwaysOn }; 124 125 enum ScrollbarControlSize { RegularScrollbar, SmallScrollbar }; 126 127 typedef unsigned ScrollbarControlState; 128 129 enum ScrollbarControlStateMask { 130 ActiveScrollbarState = 1, 131 EnabledScrollbarState = 1 << 1, 132 PressedScrollbarState = 1 << 2 133 }; 134 135 enum ScrollbarPart { 136 NoPart = 0, 137 BackButtonStartPart = 1, 138 ForwardButtonStartPart = 1 << 1, 139 BackTrackPart = 1 << 2, 140 ThumbPart = 1 << 3, 141 ForwardTrackPart = 1 << 4, 142 BackButtonEndPart = 1 << 5, 143 ForwardButtonEndPart = 1 << 6, 144 ScrollbarBGPart = 1 << 7, 145 TrackBGPart = 1 << 8, 146 AllParts = 0xffffffff 147 }; 148 149 enum ScrollbarButtonsPlacement { 150 ScrollbarButtonsNone, 151 ScrollbarButtonsSingle, 152 ScrollbarButtonsDoubleStart, 153 ScrollbarButtonsDoubleEnd, 154 ScrollbarButtonsDoubleBoth 155 }; 156 157 enum ScrollbarOverlayStyle { 158 ScrollbarOverlayStyleDefault, 159 ScrollbarOverlayStyleDark, 160 ScrollbarOverlayStyleLight 161 }; 162 163 typedef unsigned ScrollbarControlPartMask; 164 165 } 166 167 #endif 168