Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | /* representation of length values in computed style data */ |
michael@0 | 7 | |
michael@0 | 8 | #ifndef nsStyleCoord_h___ |
michael@0 | 9 | #define nsStyleCoord_h___ |
michael@0 | 10 | |
michael@0 | 11 | #include "nsCoord.h" |
michael@0 | 12 | #include "nsStyleConsts.h" |
michael@0 | 13 | |
michael@0 | 14 | enum nsStyleUnit { |
michael@0 | 15 | eStyleUnit_Null = 0, // (no value) value is not specified |
michael@0 | 16 | eStyleUnit_Normal = 1, // (no value) |
michael@0 | 17 | eStyleUnit_Auto = 2, // (no value) |
michael@0 | 18 | eStyleUnit_None = 3, // (no value) |
michael@0 | 19 | eStyleUnit_Percent = 10, // (float) 1.0 == 100% |
michael@0 | 20 | eStyleUnit_Factor = 11, // (float) a multiplier |
michael@0 | 21 | eStyleUnit_Degree = 12, // (float) angle in degrees |
michael@0 | 22 | eStyleUnit_Grad = 13, // (float) angle in grads |
michael@0 | 23 | eStyleUnit_Radian = 14, // (float) angle in radians |
michael@0 | 24 | eStyleUnit_Turn = 15, // (float) angle in turns |
michael@0 | 25 | eStyleUnit_FlexFraction = 16, // (float) <flex> in fr units |
michael@0 | 26 | eStyleUnit_Coord = 20, // (nscoord) value is twips |
michael@0 | 27 | eStyleUnit_Integer = 30, // (int) value is simple integer |
michael@0 | 28 | eStyleUnit_Enumerated = 32, // (int) value has enumerated meaning |
michael@0 | 29 | |
michael@0 | 30 | // The following are allocated types. They are weak pointers to |
michael@0 | 31 | // values allocated by nsStyleContext::Alloc. |
michael@0 | 32 | eStyleUnit_Calc = 40 // (Calc*) calc() toplevel; always present |
michael@0 | 33 | // to distinguish 50% from calc(50%), etc. |
michael@0 | 34 | }; |
michael@0 | 35 | |
michael@0 | 36 | typedef union { |
michael@0 | 37 | int32_t mInt; // nscoord is a int32_t for now |
michael@0 | 38 | float mFloat; |
michael@0 | 39 | // An mPointer is a weak pointer to a value that is guaranteed to |
michael@0 | 40 | // outlive the nsStyleCoord. In the case of nsStyleCoord::Calc*, it |
michael@0 | 41 | // is a pointer owned by the style context, allocated through |
michael@0 | 42 | // nsStyleContext::Alloc (and, therefore, is never stored in the rule |
michael@0 | 43 | // tree). |
michael@0 | 44 | void* mPointer; |
michael@0 | 45 | } nsStyleUnion; |
michael@0 | 46 | |
michael@0 | 47 | /** |
michael@0 | 48 | * Class that hold a single size specification used by the style |
michael@0 | 49 | * system. The size specification consists of two parts -- a number |
michael@0 | 50 | * and a unit. The number is an integer, a floating point value, an |
michael@0 | 51 | * nscoord, or undefined, and the unit is an nsStyleUnit. Checking |
michael@0 | 52 | * the unit is a must before asking for the value in any particular |
michael@0 | 53 | * form. |
michael@0 | 54 | */ |
michael@0 | 55 | class nsStyleCoord { |
michael@0 | 56 | public: |
michael@0 | 57 | struct Calc { |
michael@0 | 58 | // Every calc() expression evaluates to a length plus a percentage. |
michael@0 | 59 | nscoord mLength; |
michael@0 | 60 | float mPercent; |
michael@0 | 61 | bool mHasPercent; // whether there was any % syntax, even if 0 |
michael@0 | 62 | |
michael@0 | 63 | bool operator==(const Calc& aOther) const { |
michael@0 | 64 | return mLength == aOther.mLength && |
michael@0 | 65 | mPercent == aOther.mPercent && |
michael@0 | 66 | mHasPercent == aOther.mHasPercent; |
michael@0 | 67 | } |
michael@0 | 68 | bool operator!=(const Calc& aOther) const { return !(*this == aOther); } |
michael@0 | 69 | }; |
michael@0 | 70 | |
michael@0 | 71 | nsStyleCoord(nsStyleUnit aUnit = eStyleUnit_Null); |
michael@0 | 72 | enum CoordConstructorType { CoordConstructor }; |
michael@0 | 73 | inline nsStyleCoord(nscoord aValue, CoordConstructorType); |
michael@0 | 74 | nsStyleCoord(int32_t aValue, nsStyleUnit aUnit); |
michael@0 | 75 | nsStyleCoord(float aValue, nsStyleUnit aUnit); |
michael@0 | 76 | inline nsStyleCoord(const nsStyleCoord& aCopy); |
michael@0 | 77 | inline nsStyleCoord(const nsStyleUnion& aValue, nsStyleUnit aUnit); |
michael@0 | 78 | |
michael@0 | 79 | nsStyleCoord& operator=(const nsStyleCoord& aOther) |
michael@0 | 80 | { |
michael@0 | 81 | mUnit = aOther.mUnit; |
michael@0 | 82 | mValue = aOther.mValue; |
michael@0 | 83 | return *this; |
michael@0 | 84 | } |
michael@0 | 85 | bool operator==(const nsStyleCoord& aOther) const; |
michael@0 | 86 | bool operator!=(const nsStyleCoord& aOther) const; |
michael@0 | 87 | |
michael@0 | 88 | nsStyleUnit GetUnit() const { |
michael@0 | 89 | NS_ASSERTION(mUnit != eStyleUnit_Null, "reading uninitialized value"); |
michael@0 | 90 | return mUnit; |
michael@0 | 91 | } |
michael@0 | 92 | |
michael@0 | 93 | bool IsAngleValue() const { |
michael@0 | 94 | return eStyleUnit_Degree <= mUnit && mUnit <= eStyleUnit_Turn; |
michael@0 | 95 | } |
michael@0 | 96 | |
michael@0 | 97 | bool IsCalcUnit() const { |
michael@0 | 98 | return eStyleUnit_Calc == mUnit; |
michael@0 | 99 | } |
michael@0 | 100 | |
michael@0 | 101 | bool IsPointerValue() const { |
michael@0 | 102 | return IsCalcUnit(); |
michael@0 | 103 | } |
michael@0 | 104 | |
michael@0 | 105 | bool IsCoordPercentCalcUnit() const { |
michael@0 | 106 | return mUnit == eStyleUnit_Coord || |
michael@0 | 107 | mUnit == eStyleUnit_Percent || |
michael@0 | 108 | IsCalcUnit(); |
michael@0 | 109 | } |
michael@0 | 110 | |
michael@0 | 111 | // Does this calc() expression have any percentages inside it? Can be |
michael@0 | 112 | // called only when IsCalcUnit() is true. |
michael@0 | 113 | bool CalcHasPercent() const { |
michael@0 | 114 | return GetCalcValue()->mHasPercent; |
michael@0 | 115 | } |
michael@0 | 116 | |
michael@0 | 117 | bool HasPercent() const { |
michael@0 | 118 | return mUnit == eStyleUnit_Percent || |
michael@0 | 119 | (IsCalcUnit() && CalcHasPercent()); |
michael@0 | 120 | } |
michael@0 | 121 | |
michael@0 | 122 | bool ConvertsToLength() const { |
michael@0 | 123 | return mUnit == eStyleUnit_Coord || |
michael@0 | 124 | (IsCalcUnit() && !CalcHasPercent()); |
michael@0 | 125 | } |
michael@0 | 126 | |
michael@0 | 127 | nscoord GetCoordValue() const; |
michael@0 | 128 | int32_t GetIntValue() const; |
michael@0 | 129 | float GetPercentValue() const; |
michael@0 | 130 | float GetFactorValue() const; |
michael@0 | 131 | float GetAngleValue() const; |
michael@0 | 132 | double GetAngleValueInRadians() const; |
michael@0 | 133 | float GetFlexFractionValue() const; |
michael@0 | 134 | Calc* GetCalcValue() const; |
michael@0 | 135 | void GetUnionValue(nsStyleUnion& aValue) const; |
michael@0 | 136 | uint32_t HashValue(uint32_t aHash) const; |
michael@0 | 137 | |
michael@0 | 138 | void Reset(); // sets to null |
michael@0 | 139 | void SetCoordValue(nscoord aValue); |
michael@0 | 140 | void SetIntValue(int32_t aValue, nsStyleUnit aUnit); |
michael@0 | 141 | void SetPercentValue(float aValue); |
michael@0 | 142 | void SetFactorValue(float aValue); |
michael@0 | 143 | void SetAngleValue(float aValue, nsStyleUnit aUnit); |
michael@0 | 144 | void SetFlexFractionValue(float aValue); |
michael@0 | 145 | void SetNormalValue(); |
michael@0 | 146 | void SetAutoValue(); |
michael@0 | 147 | void SetNoneValue(); |
michael@0 | 148 | void SetCalcValue(Calc* aValue); |
michael@0 | 149 | |
michael@0 | 150 | private: |
michael@0 | 151 | nsStyleUnit mUnit; |
michael@0 | 152 | nsStyleUnion mValue; |
michael@0 | 153 | }; |
michael@0 | 154 | |
michael@0 | 155 | /** |
michael@0 | 156 | * Class that represents a set of top/right/bottom/left nsStyleCoords. |
michael@0 | 157 | * This is commonly used to hold the widths of the borders, margins, |
michael@0 | 158 | * or paddings of a box. |
michael@0 | 159 | */ |
michael@0 | 160 | class nsStyleSides { |
michael@0 | 161 | public: |
michael@0 | 162 | nsStyleSides(); |
michael@0 | 163 | |
michael@0 | 164 | // nsStyleSides& operator=(const nsStyleSides& aCopy); // use compiler's version |
michael@0 | 165 | bool operator==(const nsStyleSides& aOther) const; |
michael@0 | 166 | bool operator!=(const nsStyleSides& aOther) const; |
michael@0 | 167 | |
michael@0 | 168 | inline nsStyleUnit GetUnit(mozilla::css::Side aSide) const; |
michael@0 | 169 | inline nsStyleUnit GetLeftUnit() const; |
michael@0 | 170 | inline nsStyleUnit GetTopUnit() const; |
michael@0 | 171 | inline nsStyleUnit GetRightUnit() const; |
michael@0 | 172 | inline nsStyleUnit GetBottomUnit() const; |
michael@0 | 173 | |
michael@0 | 174 | inline nsStyleCoord Get(mozilla::css::Side aSide) const; |
michael@0 | 175 | inline nsStyleCoord GetLeft() const; |
michael@0 | 176 | inline nsStyleCoord GetTop() const; |
michael@0 | 177 | inline nsStyleCoord GetRight() const; |
michael@0 | 178 | inline nsStyleCoord GetBottom() const; |
michael@0 | 179 | |
michael@0 | 180 | void Reset(); |
michael@0 | 181 | |
michael@0 | 182 | inline void Set(mozilla::css::Side aSide, const nsStyleCoord& aCoord); |
michael@0 | 183 | inline void SetLeft(const nsStyleCoord& aCoord); |
michael@0 | 184 | inline void SetTop(const nsStyleCoord& aCoord); |
michael@0 | 185 | inline void SetRight(const nsStyleCoord& aCoord); |
michael@0 | 186 | inline void SetBottom(const nsStyleCoord& aCoord); |
michael@0 | 187 | |
michael@0 | 188 | protected: |
michael@0 | 189 | uint8_t mUnits[4]; |
michael@0 | 190 | nsStyleUnion mValues[4]; |
michael@0 | 191 | }; |
michael@0 | 192 | |
michael@0 | 193 | /** |
michael@0 | 194 | * Class that represents a set of top-left/top-right/bottom-left/bottom-right |
michael@0 | 195 | * nsStyleCoord pairs. This is used to hold the dimensions of the |
michael@0 | 196 | * corners of a box (for, e.g., border-radius and outline-radius). |
michael@0 | 197 | */ |
michael@0 | 198 | class nsStyleCorners { |
michael@0 | 199 | public: |
michael@0 | 200 | nsStyleCorners(); |
michael@0 | 201 | |
michael@0 | 202 | // use compiler's version |
michael@0 | 203 | //nsStyleCorners& operator=(const nsStyleCorners& aCopy); |
michael@0 | 204 | bool operator==(const nsStyleCorners& aOther) const; |
michael@0 | 205 | bool operator!=(const nsStyleCorners& aOther) const; |
michael@0 | 206 | |
michael@0 | 207 | // aCorner is always one of NS_CORNER_* defined in nsStyleConsts.h |
michael@0 | 208 | inline nsStyleUnit GetUnit(uint8_t aHalfCorner) const; |
michael@0 | 209 | |
michael@0 | 210 | inline nsStyleCoord Get(uint8_t aHalfCorner) const; |
michael@0 | 211 | |
michael@0 | 212 | void Reset(); |
michael@0 | 213 | |
michael@0 | 214 | inline void Set(uint8_t aHalfCorner, const nsStyleCoord& aCoord); |
michael@0 | 215 | |
michael@0 | 216 | protected: |
michael@0 | 217 | uint8_t mUnits[8]; |
michael@0 | 218 | nsStyleUnion mValues[8]; |
michael@0 | 219 | }; |
michael@0 | 220 | |
michael@0 | 221 | |
michael@0 | 222 | // ------------------------- |
michael@0 | 223 | // nsStyleCoord inlines |
michael@0 | 224 | // |
michael@0 | 225 | inline nsStyleCoord::nsStyleCoord(nscoord aValue, CoordConstructorType) |
michael@0 | 226 | : mUnit(eStyleUnit_Coord) |
michael@0 | 227 | { |
michael@0 | 228 | mValue.mInt = aValue; |
michael@0 | 229 | } |
michael@0 | 230 | |
michael@0 | 231 | // FIXME: In C++0x we can rely on the default copy constructor since |
michael@0 | 232 | // default copy construction is defined properly for unions. But when |
michael@0 | 233 | // can we actually use that? (It seems to work in gcc 4.4.) |
michael@0 | 234 | inline nsStyleCoord::nsStyleCoord(const nsStyleCoord& aCopy) |
michael@0 | 235 | : mUnit(aCopy.mUnit) |
michael@0 | 236 | { |
michael@0 | 237 | if ((eStyleUnit_Percent <= mUnit) && (mUnit < eStyleUnit_Coord)) { |
michael@0 | 238 | mValue.mFloat = aCopy.mValue.mFloat; |
michael@0 | 239 | } |
michael@0 | 240 | else if (IsPointerValue()) { |
michael@0 | 241 | mValue.mPointer = aCopy.mValue.mPointer; |
michael@0 | 242 | } |
michael@0 | 243 | else { |
michael@0 | 244 | mValue.mInt = aCopy.mValue.mInt; |
michael@0 | 245 | } |
michael@0 | 246 | } |
michael@0 | 247 | |
michael@0 | 248 | inline nsStyleCoord::nsStyleCoord(const nsStyleUnion& aValue, nsStyleUnit aUnit) |
michael@0 | 249 | : mUnit(aUnit), mValue(aValue) |
michael@0 | 250 | { |
michael@0 | 251 | } |
michael@0 | 252 | |
michael@0 | 253 | inline bool nsStyleCoord::operator!=(const nsStyleCoord& aOther) const |
michael@0 | 254 | { |
michael@0 | 255 | return !((*this) == aOther); |
michael@0 | 256 | } |
michael@0 | 257 | |
michael@0 | 258 | inline nscoord nsStyleCoord::GetCoordValue() const |
michael@0 | 259 | { |
michael@0 | 260 | NS_ASSERTION((mUnit == eStyleUnit_Coord), "not a coord value"); |
michael@0 | 261 | if (mUnit == eStyleUnit_Coord) { |
michael@0 | 262 | return mValue.mInt; |
michael@0 | 263 | } |
michael@0 | 264 | return 0; |
michael@0 | 265 | } |
michael@0 | 266 | |
michael@0 | 267 | inline int32_t nsStyleCoord::GetIntValue() const |
michael@0 | 268 | { |
michael@0 | 269 | NS_ASSERTION((mUnit == eStyleUnit_Enumerated) || |
michael@0 | 270 | (mUnit == eStyleUnit_Integer), "not an int value"); |
michael@0 | 271 | if ((mUnit == eStyleUnit_Enumerated) || |
michael@0 | 272 | (mUnit == eStyleUnit_Integer)) { |
michael@0 | 273 | return mValue.mInt; |
michael@0 | 274 | } |
michael@0 | 275 | return 0; |
michael@0 | 276 | } |
michael@0 | 277 | |
michael@0 | 278 | inline float nsStyleCoord::GetPercentValue() const |
michael@0 | 279 | { |
michael@0 | 280 | NS_ASSERTION(mUnit == eStyleUnit_Percent, "not a percent value"); |
michael@0 | 281 | if (mUnit == eStyleUnit_Percent) { |
michael@0 | 282 | return mValue.mFloat; |
michael@0 | 283 | } |
michael@0 | 284 | return 0.0f; |
michael@0 | 285 | } |
michael@0 | 286 | |
michael@0 | 287 | inline float nsStyleCoord::GetFactorValue() const |
michael@0 | 288 | { |
michael@0 | 289 | NS_ASSERTION(mUnit == eStyleUnit_Factor, "not a factor value"); |
michael@0 | 290 | if (mUnit == eStyleUnit_Factor) { |
michael@0 | 291 | return mValue.mFloat; |
michael@0 | 292 | } |
michael@0 | 293 | return 0.0f; |
michael@0 | 294 | } |
michael@0 | 295 | |
michael@0 | 296 | inline float nsStyleCoord::GetAngleValue() const |
michael@0 | 297 | { |
michael@0 | 298 | NS_ASSERTION(mUnit >= eStyleUnit_Degree && |
michael@0 | 299 | mUnit <= eStyleUnit_Turn, "not an angle value"); |
michael@0 | 300 | if (mUnit >= eStyleUnit_Degree && mUnit <= eStyleUnit_Turn) { |
michael@0 | 301 | return mValue.mFloat; |
michael@0 | 302 | } |
michael@0 | 303 | return 0.0f; |
michael@0 | 304 | } |
michael@0 | 305 | |
michael@0 | 306 | inline float nsStyleCoord::GetFlexFractionValue() const |
michael@0 | 307 | { |
michael@0 | 308 | NS_ASSERTION(mUnit == eStyleUnit_FlexFraction, "not a fr value"); |
michael@0 | 309 | if (mUnit == eStyleUnit_FlexFraction) { |
michael@0 | 310 | return mValue.mFloat; |
michael@0 | 311 | } |
michael@0 | 312 | return 0.0f; |
michael@0 | 313 | } |
michael@0 | 314 | |
michael@0 | 315 | inline nsStyleCoord::Calc* nsStyleCoord::GetCalcValue() const |
michael@0 | 316 | { |
michael@0 | 317 | NS_ASSERTION(IsCalcUnit(), "not a pointer value"); |
michael@0 | 318 | if (IsCalcUnit()) { |
michael@0 | 319 | return static_cast<Calc*>(mValue.mPointer); |
michael@0 | 320 | } |
michael@0 | 321 | return nullptr; |
michael@0 | 322 | } |
michael@0 | 323 | |
michael@0 | 324 | |
michael@0 | 325 | inline void nsStyleCoord::GetUnionValue(nsStyleUnion& aValue) const |
michael@0 | 326 | { |
michael@0 | 327 | aValue = mValue; |
michael@0 | 328 | } |
michael@0 | 329 | |
michael@0 | 330 | // ------------------------- |
michael@0 | 331 | // nsStyleSides inlines |
michael@0 | 332 | // |
michael@0 | 333 | inline bool nsStyleSides::operator!=(const nsStyleSides& aOther) const |
michael@0 | 334 | { |
michael@0 | 335 | return !((*this) == aOther); |
michael@0 | 336 | } |
michael@0 | 337 | |
michael@0 | 338 | inline nsStyleUnit nsStyleSides::GetUnit(mozilla::css::Side aSide) const |
michael@0 | 339 | { |
michael@0 | 340 | return (nsStyleUnit)mUnits[aSide]; |
michael@0 | 341 | } |
michael@0 | 342 | |
michael@0 | 343 | inline nsStyleUnit nsStyleSides::GetLeftUnit() const |
michael@0 | 344 | { |
michael@0 | 345 | return GetUnit(NS_SIDE_LEFT); |
michael@0 | 346 | } |
michael@0 | 347 | |
michael@0 | 348 | inline nsStyleUnit nsStyleSides::GetTopUnit() const |
michael@0 | 349 | { |
michael@0 | 350 | return GetUnit(NS_SIDE_TOP); |
michael@0 | 351 | } |
michael@0 | 352 | |
michael@0 | 353 | inline nsStyleUnit nsStyleSides::GetRightUnit() const |
michael@0 | 354 | { |
michael@0 | 355 | return GetUnit(NS_SIDE_RIGHT); |
michael@0 | 356 | } |
michael@0 | 357 | |
michael@0 | 358 | inline nsStyleUnit nsStyleSides::GetBottomUnit() const |
michael@0 | 359 | { |
michael@0 | 360 | return GetUnit(NS_SIDE_BOTTOM); |
michael@0 | 361 | } |
michael@0 | 362 | |
michael@0 | 363 | inline nsStyleCoord nsStyleSides::Get(mozilla::css::Side aSide) const |
michael@0 | 364 | { |
michael@0 | 365 | return nsStyleCoord(mValues[aSide], nsStyleUnit(mUnits[aSide])); |
michael@0 | 366 | } |
michael@0 | 367 | |
michael@0 | 368 | inline nsStyleCoord nsStyleSides::GetLeft() const |
michael@0 | 369 | { |
michael@0 | 370 | return Get(NS_SIDE_LEFT); |
michael@0 | 371 | } |
michael@0 | 372 | |
michael@0 | 373 | inline nsStyleCoord nsStyleSides::GetTop() const |
michael@0 | 374 | { |
michael@0 | 375 | return Get(NS_SIDE_TOP); |
michael@0 | 376 | } |
michael@0 | 377 | |
michael@0 | 378 | inline nsStyleCoord nsStyleSides::GetRight() const |
michael@0 | 379 | { |
michael@0 | 380 | return Get(NS_SIDE_RIGHT); |
michael@0 | 381 | } |
michael@0 | 382 | |
michael@0 | 383 | inline nsStyleCoord nsStyleSides::GetBottom() const |
michael@0 | 384 | { |
michael@0 | 385 | return Get(NS_SIDE_BOTTOM); |
michael@0 | 386 | } |
michael@0 | 387 | |
michael@0 | 388 | inline void nsStyleSides::Set(mozilla::css::Side aSide, const nsStyleCoord& aCoord) |
michael@0 | 389 | { |
michael@0 | 390 | mUnits[aSide] = aCoord.GetUnit(); |
michael@0 | 391 | aCoord.GetUnionValue(mValues[aSide]); |
michael@0 | 392 | } |
michael@0 | 393 | |
michael@0 | 394 | inline void nsStyleSides::SetLeft(const nsStyleCoord& aCoord) |
michael@0 | 395 | { |
michael@0 | 396 | Set(NS_SIDE_LEFT, aCoord); |
michael@0 | 397 | } |
michael@0 | 398 | |
michael@0 | 399 | inline void nsStyleSides::SetTop(const nsStyleCoord& aCoord) |
michael@0 | 400 | { |
michael@0 | 401 | Set(NS_SIDE_TOP, aCoord); |
michael@0 | 402 | } |
michael@0 | 403 | |
michael@0 | 404 | inline void nsStyleSides::SetRight(const nsStyleCoord& aCoord) |
michael@0 | 405 | { |
michael@0 | 406 | Set(NS_SIDE_RIGHT, aCoord); |
michael@0 | 407 | } |
michael@0 | 408 | |
michael@0 | 409 | inline void nsStyleSides::SetBottom(const nsStyleCoord& aCoord) |
michael@0 | 410 | { |
michael@0 | 411 | Set(NS_SIDE_BOTTOM, aCoord); |
michael@0 | 412 | } |
michael@0 | 413 | |
michael@0 | 414 | // ------------------------- |
michael@0 | 415 | // nsStyleCorners inlines |
michael@0 | 416 | // |
michael@0 | 417 | inline bool nsStyleCorners::operator!=(const nsStyleCorners& aOther) const |
michael@0 | 418 | { |
michael@0 | 419 | return !((*this) == aOther); |
michael@0 | 420 | } |
michael@0 | 421 | |
michael@0 | 422 | inline nsStyleUnit nsStyleCorners::GetUnit(uint8_t aCorner) const |
michael@0 | 423 | { |
michael@0 | 424 | return (nsStyleUnit)mUnits[aCorner]; |
michael@0 | 425 | } |
michael@0 | 426 | |
michael@0 | 427 | inline nsStyleCoord nsStyleCorners::Get(uint8_t aCorner) const |
michael@0 | 428 | { |
michael@0 | 429 | return nsStyleCoord(mValues[aCorner], nsStyleUnit(mUnits[aCorner])); |
michael@0 | 430 | } |
michael@0 | 431 | |
michael@0 | 432 | inline void nsStyleCorners::Set(uint8_t aCorner, const nsStyleCoord& aCoord) |
michael@0 | 433 | { |
michael@0 | 434 | mUnits[aCorner] = aCoord.GetUnit(); |
michael@0 | 435 | aCoord.GetUnionValue(mValues[aCorner]); |
michael@0 | 436 | } |
michael@0 | 437 | |
michael@0 | 438 | #endif /* nsStyleCoord_h___ */ |