OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) | 2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) |
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights |
4 * reserved. | 4 * reserved. |
5 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. | 5 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 #include "wtf/PtrUtil.h" | 56 #include "wtf/PtrUtil.h" |
57 #include "wtf/SaturatedArithmetic.h" | 57 #include "wtf/SaturatedArithmetic.h" |
58 #include "wtf/SizeAssertions.h" | 58 #include "wtf/SizeAssertions.h" |
59 #include <algorithm> | 59 #include <algorithm> |
60 #include <memory> | 60 #include <memory> |
61 | 61 |
62 namespace blink { | 62 namespace blink { |
63 | 63 |
64 struct SameSizeAsBorderValue { | 64 struct SameSizeAsBorderValue { |
65 RGBA32 m_color; | 65 RGBA32 m_color; |
66 unsigned m_width; | 66 unsigned m_bitfield; |
67 }; | 67 }; |
68 | 68 |
69 ASSERT_SIZE(BorderValue, SameSizeAsBorderValue); | 69 ASSERT_SIZE(BorderValue, SameSizeAsBorderValue); |
70 | 70 |
71 // Since different compilers/architectures pack ComputedStyle differently, | 71 // Since different compilers/architectures pack ComputedStyle differently, |
72 // re-create the same structure for an accurate size comparison. | 72 // re-create the same structure for an accurate size comparison. |
73 struct SameSizeAsComputedStyle : public ComputedStyleBase, | 73 struct SameSizeAsComputedStyle : public ComputedStyleBase, |
74 public RefCounted<ComputedStyle> { | 74 public RefCounted<ComputedStyle> { |
75 void* dataRefs[7]; | 75 void* dataRefs[7]; |
76 void* ownPtrs[1]; | 76 void* ownPtrs[1]; |
(...skipping 1412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1489 return roundedRect; | 1489 return roundedRect; |
1490 } | 1490 } |
1491 | 1491 |
1492 FloatRoundedRect ComputedStyle::getRoundedInnerBorderFor( | 1492 FloatRoundedRect ComputedStyle::getRoundedInnerBorderFor( |
1493 const LayoutRect& borderRect, | 1493 const LayoutRect& borderRect, |
1494 bool includeLogicalLeftEdge, | 1494 bool includeLogicalLeftEdge, |
1495 bool includeLogicalRightEdge) const { | 1495 bool includeLogicalRightEdge) const { |
1496 bool horizontal = isHorizontalWritingMode(); | 1496 bool horizontal = isHorizontalWritingMode(); |
1497 | 1497 |
1498 int leftWidth = | 1498 int leftWidth = |
1499 (!horizontal || includeLogicalLeftEdge) ? borderLeftWidth() : 0; | 1499 (!horizontal || includeLogicalLeftEdge) ? roundf(borderLeftWidth()) : 0; |
1500 int rightWidth = | 1500 int rightWidth = |
1501 (!horizontal || includeLogicalRightEdge) ? borderRightWidth() : 0; | 1501 (!horizontal || includeLogicalRightEdge) ? roundf(borderRightWidth()) : 0; |
1502 int topWidth = (horizontal || includeLogicalLeftEdge) ? borderTopWidth() : 0; | 1502 int topWidth = |
| 1503 (horizontal || includeLogicalLeftEdge) ? roundf(borderTopWidth()) : 0; |
1503 int bottomWidth = | 1504 int bottomWidth = |
1504 (horizontal || includeLogicalRightEdge) ? borderBottomWidth() : 0; | 1505 (horizontal || includeLogicalRightEdge) ? roundf(borderBottomWidth()) : 0; |
1505 | 1506 |
1506 return getRoundedInnerBorderFor( | 1507 return getRoundedInnerBorderFor( |
1507 borderRect, | 1508 borderRect, |
1508 LayoutRectOutsets(-topWidth, -rightWidth, -bottomWidth, -leftWidth), | 1509 LayoutRectOutsets(-topWidth, -rightWidth, -bottomWidth, -leftWidth), |
1509 includeLogicalLeftEdge, includeLogicalRightEdge); | 1510 includeLogicalLeftEdge, includeLogicalRightEdge); |
1510 } | 1511 } |
1511 | 1512 |
1512 FloatRoundedRect ComputedStyle::getRoundedInnerBorderFor( | 1513 FloatRoundedRect ComputedStyle::getRoundedInnerBorderFor( |
1513 const LayoutRect& borderRect, | 1514 const LayoutRect& borderRect, |
1514 const LayoutRectOutsets& insets, | 1515 const LayoutRectOutsets& insets, |
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2211 return isLeftToRightDirection() ? borderLeft() : borderRight(); | 2212 return isLeftToRightDirection() ? borderLeft() : borderRight(); |
2212 return isLeftToRightDirection() ? borderTop() : borderBottom(); | 2213 return isLeftToRightDirection() ? borderTop() : borderBottom(); |
2213 } | 2214 } |
2214 | 2215 |
2215 const BorderValue& ComputedStyle::borderEnd() const { | 2216 const BorderValue& ComputedStyle::borderEnd() const { |
2216 if (isHorizontalWritingMode()) | 2217 if (isHorizontalWritingMode()) |
2217 return isLeftToRightDirection() ? borderRight() : borderLeft(); | 2218 return isLeftToRightDirection() ? borderRight() : borderLeft(); |
2218 return isLeftToRightDirection() ? borderBottom() : borderTop(); | 2219 return isLeftToRightDirection() ? borderBottom() : borderTop(); |
2219 } | 2220 } |
2220 | 2221 |
2221 int ComputedStyle::borderBeforeWidth() const { | 2222 float ComputedStyle::borderBeforeWidth() const { |
2222 switch (getWritingMode()) { | 2223 switch (getWritingMode()) { |
2223 case WritingMode::kHorizontalTb: | 2224 case WritingMode::kHorizontalTb: |
2224 return borderTopWidth(); | 2225 return borderTopWidth(); |
2225 case WritingMode::kVerticalLr: | 2226 case WritingMode::kVerticalLr: |
2226 return borderLeftWidth(); | 2227 return borderLeftWidth(); |
2227 case WritingMode::kVerticalRl: | 2228 case WritingMode::kVerticalRl: |
2228 return borderRightWidth(); | 2229 return borderRightWidth(); |
2229 } | 2230 } |
2230 ASSERT_NOT_REACHED(); | 2231 ASSERT_NOT_REACHED(); |
2231 return borderTopWidth(); | 2232 return borderTopWidth(); |
2232 } | 2233 } |
2233 | 2234 |
2234 int ComputedStyle::borderAfterWidth() const { | 2235 float ComputedStyle::borderAfterWidth() const { |
2235 switch (getWritingMode()) { | 2236 switch (getWritingMode()) { |
2236 case WritingMode::kHorizontalTb: | 2237 case WritingMode::kHorizontalTb: |
2237 return borderBottomWidth(); | 2238 return borderBottomWidth(); |
2238 case WritingMode::kVerticalLr: | 2239 case WritingMode::kVerticalLr: |
2239 return borderRightWidth(); | 2240 return borderRightWidth(); |
2240 case WritingMode::kVerticalRl: | 2241 case WritingMode::kVerticalRl: |
2241 return borderLeftWidth(); | 2242 return borderLeftWidth(); |
2242 } | 2243 } |
2243 ASSERT_NOT_REACHED(); | 2244 ASSERT_NOT_REACHED(); |
2244 return borderBottomWidth(); | 2245 return borderBottomWidth(); |
2245 } | 2246 } |
2246 | 2247 |
2247 int ComputedStyle::borderStartWidth() const { | 2248 float ComputedStyle::borderStartWidth() const { |
2248 if (isHorizontalWritingMode()) | 2249 if (isHorizontalWritingMode()) |
2249 return isLeftToRightDirection() ? borderLeftWidth() : borderRightWidth(); | 2250 return isLeftToRightDirection() ? borderLeftWidth() : borderRightWidth(); |
2250 return isLeftToRightDirection() ? borderTopWidth() : borderBottomWidth(); | 2251 return isLeftToRightDirection() ? borderTopWidth() : borderBottomWidth(); |
2251 } | 2252 } |
2252 | 2253 |
2253 int ComputedStyle::borderEndWidth() const { | 2254 float ComputedStyle::borderEndWidth() const { |
2254 if (isHorizontalWritingMode()) | 2255 if (isHorizontalWritingMode()) |
2255 return isLeftToRightDirection() ? borderRightWidth() : borderLeftWidth(); | 2256 return isLeftToRightDirection() ? borderRightWidth() : borderLeftWidth(); |
2256 return isLeftToRightDirection() ? borderBottomWidth() : borderTopWidth(); | 2257 return isLeftToRightDirection() ? borderBottomWidth() : borderTopWidth(); |
2257 } | 2258 } |
2258 | 2259 |
2259 int ComputedStyle::borderOverWidth() const { | 2260 float ComputedStyle::borderOverWidth() const { |
2260 return isHorizontalWritingMode() ? borderTopWidth() : borderRightWidth(); | 2261 return isHorizontalWritingMode() ? borderTopWidth() : borderRightWidth(); |
2261 } | 2262 } |
2262 | 2263 |
2263 int ComputedStyle::borderUnderWidth() const { | 2264 float ComputedStyle::borderUnderWidth() const { |
2264 return isHorizontalWritingMode() ? borderBottomWidth() : borderLeftWidth(); | 2265 return isHorizontalWritingMode() ? borderBottomWidth() : borderLeftWidth(); |
2265 } | 2266 } |
2266 | 2267 |
2267 void ComputedStyle::setMarginStart(const Length& margin) { | 2268 void ComputedStyle::setMarginStart(const Length& margin) { |
2268 if (isHorizontalWritingMode()) { | 2269 if (isHorizontalWritingMode()) { |
2269 if (isLeftToRightDirection()) | 2270 if (isLeftToRightDirection()) |
2270 setMarginLeft(margin); | 2271 setMarginLeft(margin); |
2271 else | 2272 else |
2272 setMarginRight(margin); | 2273 setMarginRight(margin); |
2273 } else { | 2274 } else { |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2476 if (value < 0) | 2477 if (value < 0) |
2477 fvalue -= 0.5f; | 2478 fvalue -= 0.5f; |
2478 else | 2479 else |
2479 fvalue += 0.5f; | 2480 fvalue += 0.5f; |
2480 } | 2481 } |
2481 | 2482 |
2482 return roundForImpreciseConversion<int>(fvalue / zoomFactor); | 2483 return roundForImpreciseConversion<int>(fvalue / zoomFactor); |
2483 } | 2484 } |
2484 | 2485 |
2485 } // namespace blink | 2486 } // namespace blink |
OLD | NEW |