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

Side by Side Diff: Source/core/css/CSSPrimitiveValue.cpp

Issue 1304993002: Change Rect and Quad to be CSSValues (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@split_counter_out_attempt_3
Patch Set: Created 5 years, 4 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 * (C) 1999-2003 Lars Knoll (knoll@kde.org) 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2012 Apple Inc. All rights reserv ed. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2012 Apple Inc. All rights reserv ed.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details. 13 * Library General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU Library General Public License 15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to 16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA. 18 * Boston, MA 02110-1301, USA.
19 */ 19 */
20 20
21 #include "config.h" 21 #include "config.h"
22 #include "core/css/CSSPrimitiveValue.h" 22 #include "core/css/CSSPrimitiveValue.h"
23 23
24 #include "core/css/CSSBasicShapes.h" 24 #include "core/css/CSSBasicShapes.h"
25 #include "core/css/CSSCalculationValue.h" 25 #include "core/css/CSSCalculationValue.h"
26 #include "core/css/CSSHelper.h" 26 #include "core/css/CSSHelper.h"
27 #include "core/css/CSSMarkup.h" 27 #include "core/css/CSSMarkup.h"
28 #include "core/css/CSSToLengthConversionData.h" 28 #include "core/css/CSSToLengthConversionData.h"
29 #include "core/css/Pair.h" 29 #include "core/css/Pair.h"
30 #include "core/css/Rect.h"
31 #include "core/css/StyleSheetContents.h" 30 #include "core/css/StyleSheetContents.h"
32 #include "core/dom/Node.h" 31 #include "core/dom/Node.h"
33 #include "core/style/ComputedStyle.h" 32 #include "core/style/ComputedStyle.h"
34 #include "platform/LayoutUnit.h" 33 #include "platform/LayoutUnit.h"
35 #include "platform/fonts/FontMetrics.h" 34 #include "platform/fonts/FontMetrics.h"
36 #include "wtf/StdLibExtras.h" 35 #include "wtf/StdLibExtras.h"
37 #include "wtf/ThreadSpecific.h" 36 #include "wtf/ThreadSpecific.h"
38 #include "wtf/Threading.h" 37 #include "wtf/Threading.h"
39 #include "wtf/text/StringBuffer.h" 38 #include "wtf/text/StringBuffer.h"
40 #include "wtf/text/StringBuilder.h" 39 #include "wtf/text/StringBuilder.h"
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 m_primitiveUnitType = static_cast<unsigned>(type); 326 m_primitiveUnitType = static_cast<unsigned>(type);
328 } 327 }
329 328
330 void CSSPrimitiveValue::init(const LengthSize& lengthSize, const ComputedStyle& style) 329 void CSSPrimitiveValue::init(const LengthSize& lengthSize, const ComputedStyle& style)
331 { 330 {
332 init(UnitType::Pair); 331 init(UnitType::Pair);
333 m_hasCachedCSSText = false; 332 m_hasCachedCSSText = false;
334 m_value.pair = Pair::create(create(lengthSize.width(), style.effectiveZoom() ), create(lengthSize.height(), style.effectiveZoom()), Pair::KeepIdenticalValues ).leakRef(); 333 m_value.pair = Pair::create(create(lengthSize.width(), style.effectiveZoom() ), create(lengthSize.height(), style.effectiveZoom()), Pair::KeepIdenticalValues ).leakRef();
335 } 334 }
336 335
337 void CSSPrimitiveValue::init(PassRefPtrWillBeRawPtr<Rect> r)
338 {
339 init(UnitType::Rect);
340 m_hasCachedCSSText = false;
341 m_value.rect = r.leakRef();
342 }
343
344 void CSSPrimitiveValue::init(PassRefPtrWillBeRawPtr<Quad> quad)
345 {
346 init(UnitType::Quad);
347 m_hasCachedCSSText = false;
348 m_value.quad = quad.leakRef();
349 }
350
351 void CSSPrimitiveValue::init(PassRefPtrWillBeRawPtr<Pair> p) 336 void CSSPrimitiveValue::init(PassRefPtrWillBeRawPtr<Pair> p)
352 { 337 {
353 init(UnitType::Pair); 338 init(UnitType::Pair);
354 m_hasCachedCSSText = false; 339 m_hasCachedCSSText = false;
355 m_value.pair = p.leakRef(); 340 m_value.pair = p.leakRef();
356 } 341 }
357 342
358 void CSSPrimitiveValue::init(PassRefPtrWillBeRawPtr<CSSCalcValue> c) 343 void CSSPrimitiveValue::init(PassRefPtrWillBeRawPtr<CSSCalcValue> c)
359 { 344 {
360 init(UnitType::Calc); 345 init(UnitType::Calc);
(...skipping 16 matching lines...) Expand all
377 void CSSPrimitiveValue::cleanup() 362 void CSSPrimitiveValue::cleanup()
378 { 363 {
379 switch (type()) { 364 switch (type()) {
380 case UnitType::CustomIdentifier: 365 case UnitType::CustomIdentifier:
381 case UnitType::String: 366 case UnitType::String:
382 case UnitType::URI: 367 case UnitType::URI:
383 case UnitType::Attribute: 368 case UnitType::Attribute:
384 if (m_value.string) 369 if (m_value.string)
385 m_value.string->deref(); 370 m_value.string->deref();
386 break; 371 break;
387 case UnitType::Rect:
388 // We must not call deref() when oilpan is enabled because m_value.rect is traced.
389 #if !ENABLE(OILPAN)
390 m_value.rect->deref();
391 #endif
392 break;
393 case UnitType::Quad:
394 // We must not call deref() when oilpan is enabled because m_value.quad is traced.
395 #if !ENABLE(OILPAN)
396 m_value.quad->deref();
397 #endif
398 break;
399 case UnitType::Pair: 372 case UnitType::Pair:
400 // We must not call deref() when oilpan is enabled because m_value.pair is traced. 373 // We must not call deref() when oilpan is enabled because m_value.pair is traced.
401 #if !ENABLE(OILPAN) 374 #if !ENABLE(OILPAN)
402 m_value.pair->deref(); 375 m_value.pair->deref();
403 #endif 376 #endif
404 break; 377 break;
405 case UnitType::Calc: 378 case UnitType::Calc:
406 // We must not call deref() when oilpan is enabled because m_value.calc is traced. 379 // We must not call deref() when oilpan is enabled because m_value.calc is traced.
407 #if !ENABLE(OILPAN) 380 #if !ENABLE(OILPAN)
408 m_value.calc->deref(); 381 m_value.calc->deref();
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 return "vmin"; 859 return "vmin";
887 case UnitType::ViewportMax: 860 case UnitType::ViewportMax:
888 return "vmax"; 861 return "vmax";
889 case UnitType::Unknown: 862 case UnitType::Unknown:
890 case UnitType::CustomIdentifier: 863 case UnitType::CustomIdentifier:
891 case UnitType::String: 864 case UnitType::String:
892 case UnitType::URI: 865 case UnitType::URI:
893 case UnitType::ValueID: 866 case UnitType::ValueID:
894 case UnitType::PropertyID: 867 case UnitType::PropertyID:
895 case UnitType::Attribute: 868 case UnitType::Attribute:
896 case UnitType::Rect:
897 case UnitType::Quad:
898 case UnitType::RGBColor: 869 case UnitType::RGBColor:
899 case UnitType::Pair: 870 case UnitType::Pair:
900 case UnitType::Calc: 871 case UnitType::Calc:
901 case UnitType::Shape: 872 case UnitType::Shape:
902 case UnitType::CalcPercentageWithNumber: 873 case UnitType::CalcPercentageWithNumber:
903 case UnitType::CalcPercentageWithLength: 874 case UnitType::CalcPercentageWithLength:
904 case UnitType::QuirkyEms: 875 case UnitType::QuirkyEms:
905 break; 876 break;
906 }; 877 };
907 ASSERT_NOT_REACHED(); 878 ASSERT_NOT_REACHED();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 return propertyName(m_value.propertyID); 929 return propertyName(m_value.propertyID);
959 case UnitType::Attribute: { 930 case UnitType::Attribute: {
960 StringBuilder result; 931 StringBuilder result;
961 result.reserveCapacity(6 + m_value.string->length()); 932 result.reserveCapacity(6 + m_value.string->length());
962 result.appendLiteral("attr("); 933 result.appendLiteral("attr(");
963 result.append(m_value.string); 934 result.append(m_value.string);
964 result.append(')'); 935 result.append(')');
965 936
966 return result.toString(); 937 return result.toString();
967 } 938 }
968 case UnitType::Rect:
969 return getRectValue()->cssText();
970 case UnitType::Quad:
971 return getQuadValue()->cssText();
972 case UnitType::RGBColor: { 939 case UnitType::RGBColor: {
973 return Color(m_value.rgbcolor).serializedAsCSSComponentValue(); 940 return Color(m_value.rgbcolor).serializedAsCSSComponentValue();
974 } 941 }
975 case UnitType::Pair: 942 case UnitType::Pair:
976 return getPairValue()->cssText(); 943 return getPairValue()->cssText();
977 case UnitType::Calc: 944 case UnitType::Calc:
978 return m_value.calc->customCSSText(); 945 return m_value.calc->customCSSText();
979 case UnitType::Shape: 946 case UnitType::Shape:
980 return m_value.shape->cssText(); 947 return m_value.shape->cssText();
981 case UnitType::CalcPercentageWithNumber: 948 case UnitType::CalcPercentageWithNumber:
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 return m_value.num == other.m_value.num; 991 return m_value.num == other.m_value.num;
1025 case UnitType::PropertyID: 992 case UnitType::PropertyID:
1026 return m_value.propertyID == other.m_value.propertyID; 993 return m_value.propertyID == other.m_value.propertyID;
1027 case UnitType::ValueID: 994 case UnitType::ValueID:
1028 return m_value.valueID == other.m_value.valueID; 995 return m_value.valueID == other.m_value.valueID;
1029 case UnitType::CustomIdentifier: 996 case UnitType::CustomIdentifier:
1030 case UnitType::String: 997 case UnitType::String:
1031 case UnitType::URI: 998 case UnitType::URI:
1032 case UnitType::Attribute: 999 case UnitType::Attribute:
1033 return equal(m_value.string, other.m_value.string); 1000 return equal(m_value.string, other.m_value.string);
1034 case UnitType::Rect:
1035 return m_value.rect && other.m_value.rect && m_value.rect->equals(*other .m_value.rect);
1036 case UnitType::Quad:
1037 return m_value.quad && other.m_value.quad && m_value.quad->equals(*other .m_value.quad);
1038 case UnitType::RGBColor: 1001 case UnitType::RGBColor:
1039 return m_value.rgbcolor == other.m_value.rgbcolor; 1002 return m_value.rgbcolor == other.m_value.rgbcolor;
1040 case UnitType::Pair: 1003 case UnitType::Pair:
1041 return m_value.pair && other.m_value.pair && m_value.pair->equals(*other .m_value.pair); 1004 return m_value.pair && other.m_value.pair && m_value.pair->equals(*other .m_value.pair);
1042 case UnitType::Calc: 1005 case UnitType::Calc:
1043 return m_value.calc && other.m_value.calc && m_value.calc->equals(*other .m_value.calc); 1006 return m_value.calc && other.m_value.calc && m_value.calc->equals(*other .m_value.calc);
1044 case UnitType::Shape: 1007 case UnitType::Shape:
1045 return m_value.shape && other.m_value.shape && m_value.shape->equals(*ot her.m_value.shape); 1008 return m_value.shape && other.m_value.shape && m_value.shape->equals(*ot her.m_value.shape);
1046 case UnitType::Integer: 1009 case UnitType::Integer:
1047 case UnitType::Chs: 1010 case UnitType::Chs:
1048 case UnitType::CalcPercentageWithNumber: 1011 case UnitType::CalcPercentageWithNumber:
1049 case UnitType::CalcPercentageWithLength: 1012 case UnitType::CalcPercentageWithLength:
1050 case UnitType::QuirkyEms: 1013 case UnitType::QuirkyEms:
1051 return false; 1014 return false;
1052 } 1015 }
1053 return false; 1016 return false;
1054 } 1017 }
1055 1018
1056 DEFINE_TRACE_AFTER_DISPATCH(CSSPrimitiveValue) 1019 DEFINE_TRACE_AFTER_DISPATCH(CSSPrimitiveValue)
1057 { 1020 {
1058 #if ENABLE(OILPAN) 1021 #if ENABLE(OILPAN)
1059 switch (type()) { 1022 switch (type()) {
1060 case UnitType::Rect:
1061 visitor->trace(m_value.rect);
1062 break;
1063 case UnitType::Quad:
1064 visitor->trace(m_value.quad);
1065 break;
1066 case UnitType::Pair: 1023 case UnitType::Pair:
1067 visitor->trace(m_value.pair); 1024 visitor->trace(m_value.pair);
1068 break; 1025 break;
1069 case UnitType::Calc: 1026 case UnitType::Calc:
1070 visitor->trace(m_value.calc); 1027 visitor->trace(m_value.calc);
1071 break; 1028 break;
1072 case UnitType::Shape: 1029 case UnitType::Shape:
1073 visitor->trace(m_value.shape); 1030 visitor->trace(m_value.shape);
1074 break; 1031 break;
1075 default: 1032 default:
1076 break; 1033 break;
1077 } 1034 }
1078 #endif 1035 #endif
1079 CSSValue::traceAfterDispatch(visitor); 1036 CSSValue::traceAfterDispatch(visitor);
1080 } 1037 }
1081 1038
1082 } // namespace blink 1039 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698