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

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

Issue 2640143005: Support subpixel layout for borders. (Closed)
Patch Set: Rebased patch set. Created 3 years, 10 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 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 2138 matching lines...) Expand 10 before | Expand all | Expand 10 after
2215 return isLeftToRightDirection() ? borderLeft() : borderRight(); 2215 return isLeftToRightDirection() ? borderLeft() : borderRight();
2216 return isLeftToRightDirection() ? borderTop() : borderBottom(); 2216 return isLeftToRightDirection() ? borderTop() : borderBottom();
2217 } 2217 }
2218 2218
2219 const BorderValue& ComputedStyle::borderEnd() const { 2219 const BorderValue& ComputedStyle::borderEnd() const {
2220 if (isHorizontalWritingMode()) 2220 if (isHorizontalWritingMode())
2221 return isLeftToRightDirection() ? borderRight() : borderLeft(); 2221 return isLeftToRightDirection() ? borderRight() : borderLeft();
2222 return isLeftToRightDirection() ? borderBottom() : borderTop(); 2222 return isLeftToRightDirection() ? borderBottom() : borderTop();
2223 } 2223 }
2224 2224
2225 int ComputedStyle::borderBeforeWidth() const { 2225 float ComputedStyle::borderBeforeWidth() const {
2226 switch (getWritingMode()) { 2226 switch (getWritingMode()) {
2227 case WritingMode::kHorizontalTb: 2227 case WritingMode::kHorizontalTb:
2228 return borderTopWidth(); 2228 return borderTopWidth();
2229 case WritingMode::kVerticalLr: 2229 case WritingMode::kVerticalLr:
2230 return borderLeftWidth(); 2230 return borderLeftWidth();
2231 case WritingMode::kVerticalRl: 2231 case WritingMode::kVerticalRl:
2232 return borderRightWidth(); 2232 return borderRightWidth();
2233 } 2233 }
2234 ASSERT_NOT_REACHED(); 2234 ASSERT_NOT_REACHED();
2235 return borderTopWidth(); 2235 return borderTopWidth();
2236 } 2236 }
2237 2237
2238 int ComputedStyle::borderAfterWidth() const { 2238 float ComputedStyle::borderAfterWidth() const {
2239 switch (getWritingMode()) { 2239 switch (getWritingMode()) {
2240 case WritingMode::kHorizontalTb: 2240 case WritingMode::kHorizontalTb:
2241 return borderBottomWidth(); 2241 return borderBottomWidth();
2242 case WritingMode::kVerticalLr: 2242 case WritingMode::kVerticalLr:
2243 return borderRightWidth(); 2243 return borderRightWidth();
2244 case WritingMode::kVerticalRl: 2244 case WritingMode::kVerticalRl:
2245 return borderLeftWidth(); 2245 return borderLeftWidth();
2246 } 2246 }
2247 ASSERT_NOT_REACHED(); 2247 ASSERT_NOT_REACHED();
2248 return borderBottomWidth(); 2248 return borderBottomWidth();
2249 } 2249 }
2250 2250
2251 int ComputedStyle::borderStartWidth() const { 2251 float ComputedStyle::borderStartWidth() const {
2252 if (isHorizontalWritingMode()) 2252 if (isHorizontalWritingMode())
2253 return isLeftToRightDirection() ? borderLeftWidth() : borderRightWidth(); 2253 return isLeftToRightDirection() ? borderLeftWidth() : borderRightWidth();
2254 return isLeftToRightDirection() ? borderTopWidth() : borderBottomWidth(); 2254 return isLeftToRightDirection() ? borderTopWidth() : borderBottomWidth();
2255 } 2255 }
2256 2256
2257 int ComputedStyle::borderEndWidth() const { 2257 float ComputedStyle::borderEndWidth() const {
2258 if (isHorizontalWritingMode()) 2258 if (isHorizontalWritingMode())
2259 return isLeftToRightDirection() ? borderRightWidth() : borderLeftWidth(); 2259 return isLeftToRightDirection() ? borderRightWidth() : borderLeftWidth();
2260 return isLeftToRightDirection() ? borderBottomWidth() : borderTopWidth(); 2260 return isLeftToRightDirection() ? borderBottomWidth() : borderTopWidth();
2261 } 2261 }
2262 2262
2263 int ComputedStyle::borderOverWidth() const { 2263 float ComputedStyle::borderOverWidth() const {
2264 return isHorizontalWritingMode() ? borderTopWidth() : borderRightWidth(); 2264 return isHorizontalWritingMode() ? borderTopWidth() : borderRightWidth();
2265 } 2265 }
2266 2266
2267 int ComputedStyle::borderUnderWidth() const { 2267 float ComputedStyle::borderUnderWidth() const {
2268 return isHorizontalWritingMode() ? borderBottomWidth() : borderLeftWidth(); 2268 return isHorizontalWritingMode() ? borderBottomWidth() : borderLeftWidth();
2269 } 2269 }
2270 2270
2271 void ComputedStyle::setMarginStart(const Length& margin) { 2271 void ComputedStyle::setMarginStart(const Length& margin) {
2272 if (isHorizontalWritingMode()) { 2272 if (isHorizontalWritingMode()) {
2273 if (isLeftToRightDirection()) 2273 if (isLeftToRightDirection())
2274 setMarginLeft(margin); 2274 setMarginLeft(margin);
2275 else 2275 else
2276 setMarginRight(margin); 2276 setMarginRight(margin);
2277 } else { 2277 } else {
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
2480 if (value < 0) 2480 if (value < 0)
2481 fvalue -= 0.5f; 2481 fvalue -= 0.5f;
2482 else 2482 else
2483 fvalue += 0.5f; 2483 fvalue += 0.5f;
2484 } 2484 }
2485 2485
2486 return roundForImpreciseConversion<int>(fvalue / zoomFactor); 2486 return roundForImpreciseConversion<int>(fvalue / zoomFactor);
2487 } 2487 }
2488 2488
2489 } // namespace blink 2489 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698