Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(329)

Side by Side Diff: third_party/WebKit/Source/core/style/ComputedStyle.cpp

Issue 2640143005: Support subpixel layout for borders. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 float m_width;
67 unsigned m_bitfield;
67 }; 68 };
68 69
69 ASSERT_SIZE(BorderValue, SameSizeAsBorderValue); 70 ASSERT_SIZE(BorderValue, SameSizeAsBorderValue);
70 71
71 // Since different compilers/architectures pack ComputedStyle differently, 72 // Since different compilers/architectures pack ComputedStyle differently,
72 // re-create the same structure for an accurate size comparison. 73 // re-create the same structure for an accurate size comparison.
73 struct SameSizeAsComputedStyle : public ComputedStyleBase, 74 struct SameSizeAsComputedStyle : public ComputedStyleBase,
74 public RefCounted<ComputedStyle> { 75 public RefCounted<ComputedStyle> {
75 void* dataRefs[7]; 76 void* dataRefs[7];
76 void* ownPtrs[1]; 77 void* ownPtrs[1];
(...skipping 2138 matching lines...) Expand 10 before | Expand all | Expand 10 after
2215 return isLeftToRightDirection() ? borderLeft() : borderRight(); 2216 return isLeftToRightDirection() ? borderLeft() : borderRight();
2216 return isLeftToRightDirection() ? borderTop() : borderBottom(); 2217 return isLeftToRightDirection() ? borderTop() : borderBottom();
2217 } 2218 }
2218 2219
2219 const BorderValue& ComputedStyle::borderEnd() const { 2220 const BorderValue& ComputedStyle::borderEnd() const {
2220 if (isHorizontalWritingMode()) 2221 if (isHorizontalWritingMode())
2221 return isLeftToRightDirection() ? borderRight() : borderLeft(); 2222 return isLeftToRightDirection() ? borderRight() : borderLeft();
2222 return isLeftToRightDirection() ? borderBottom() : borderTop(); 2223 return isLeftToRightDirection() ? borderBottom() : borderTop();
2223 } 2224 }
2224 2225
2225 int ComputedStyle::borderBeforeWidth() const { 2226 float ComputedStyle::borderBeforeWidth() const {
2226 switch (getWritingMode()) { 2227 switch (getWritingMode()) {
2227 case WritingMode::kHorizontalTb: 2228 case WritingMode::kHorizontalTb:
2228 return borderTopWidth(); 2229 return borderTopWidth();
2229 case WritingMode::kVerticalLr: 2230 case WritingMode::kVerticalLr:
2230 return borderLeftWidth(); 2231 return borderLeftWidth();
2231 case WritingMode::kVerticalRl: 2232 case WritingMode::kVerticalRl:
2232 return borderRightWidth(); 2233 return borderRightWidth();
2233 } 2234 }
2234 ASSERT_NOT_REACHED(); 2235 ASSERT_NOT_REACHED();
2235 return borderTopWidth(); 2236 return borderTopWidth();
2236 } 2237 }
2237 2238
2238 int ComputedStyle::borderAfterWidth() const { 2239 float ComputedStyle::borderAfterWidth() const {
2239 switch (getWritingMode()) { 2240 switch (getWritingMode()) {
2240 case WritingMode::kHorizontalTb: 2241 case WritingMode::kHorizontalTb:
2241 return borderBottomWidth(); 2242 return borderBottomWidth();
2242 case WritingMode::kVerticalLr: 2243 case WritingMode::kVerticalLr:
2243 return borderRightWidth(); 2244 return borderRightWidth();
2244 case WritingMode::kVerticalRl: 2245 case WritingMode::kVerticalRl:
2245 return borderLeftWidth(); 2246 return borderLeftWidth();
2246 } 2247 }
2247 ASSERT_NOT_REACHED(); 2248 ASSERT_NOT_REACHED();
2248 return borderBottomWidth(); 2249 return borderBottomWidth();
2249 } 2250 }
2250 2251
2251 int ComputedStyle::borderStartWidth() const { 2252 float ComputedStyle::borderStartWidth() const {
2252 if (isHorizontalWritingMode()) 2253 if (isHorizontalWritingMode())
2253 return isLeftToRightDirection() ? borderLeftWidth() : borderRightWidth(); 2254 return isLeftToRightDirection() ? borderLeftWidth() : borderRightWidth();
2254 return isLeftToRightDirection() ? borderTopWidth() : borderBottomWidth(); 2255 return isLeftToRightDirection() ? borderTopWidth() : borderBottomWidth();
2255 } 2256 }
2256 2257
2257 int ComputedStyle::borderEndWidth() const { 2258 float ComputedStyle::borderEndWidth() const {
2258 if (isHorizontalWritingMode()) 2259 if (isHorizontalWritingMode())
2259 return isLeftToRightDirection() ? borderRightWidth() : borderLeftWidth(); 2260 return isLeftToRightDirection() ? borderRightWidth() : borderLeftWidth();
2260 return isLeftToRightDirection() ? borderBottomWidth() : borderTopWidth(); 2261 return isLeftToRightDirection() ? borderBottomWidth() : borderTopWidth();
2261 } 2262 }
2262 2263
2263 int ComputedStyle::borderOverWidth() const { 2264 float ComputedStyle::borderOverWidth() const {
2264 return isHorizontalWritingMode() ? borderTopWidth() : borderRightWidth(); 2265 return isHorizontalWritingMode() ? borderTopWidth() : borderRightWidth();
2265 } 2266 }
2266 2267
2267 int ComputedStyle::borderUnderWidth() const { 2268 float ComputedStyle::borderUnderWidth() const {
2268 return isHorizontalWritingMode() ? borderBottomWidth() : borderLeftWidth(); 2269 return isHorizontalWritingMode() ? borderBottomWidth() : borderLeftWidth();
2269 } 2270 }
2270 2271
2271 void ComputedStyle::setMarginStart(const Length& margin) { 2272 void ComputedStyle::setMarginStart(const Length& margin) {
2272 if (isHorizontalWritingMode()) { 2273 if (isHorizontalWritingMode()) {
2273 if (isLeftToRightDirection()) 2274 if (isLeftToRightDirection())
2274 setMarginLeft(margin); 2275 setMarginLeft(margin);
2275 else 2276 else
2276 setMarginRight(margin); 2277 setMarginRight(margin);
2277 } else { 2278 } else {
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
2480 if (value < 0) 2481 if (value < 0)
2481 fvalue -= 0.5f; 2482 fvalue -= 0.5f;
2482 else 2483 else
2483 fvalue += 0.5f; 2484 fvalue += 0.5f;
2484 } 2485 }
2485 2486
2486 return roundForImpreciseConversion<int>(fvalue / zoomFactor); 2487 return roundForImpreciseConversion<int>(fvalue / zoomFactor);
2487 } 2488 }
2488 2489
2489 } // namespace blink 2490 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698