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

Side by Side Diff: Source/core/css/resolver/StyleBuilderConverter.cpp

Issue 643893002: Store [-webkit-]perspective-origin as a LengthPoint. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * * Redistributions of source code must retain the above copyright 4 * * Redistributions of source code must retain the above copyright
5 * notice, this list of conditions and the following disclaimer. 5 * notice, this list of conditions and the following disclaimer.
6 * * Redistributions in binary form must reproduce the above 6 * * Redistributions in binary form must reproduce the above
7 * copyright notice, this list of conditions and the following disclaimer 7 * copyright notice, this list of conditions and the following disclaimer
8 * in the documentation and/or other materials provided with the 8 * in the documentation and/or other materials provided with the
9 * distribution. 9 * distribution.
10 * * Neither the name of Google Inc. nor the names of its 10 * * Neither the name of Google Inc. nor the names of its
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 599
600 // CSSPropertyWebkitPerspective accepts unitless numbers. 600 // CSSPropertyWebkitPerspective accepts unitless numbers.
601 if (primitiveValue->isNumber()) { 601 if (primitiveValue->isNumber()) {
602 RefPtr<CSSPrimitiveValue> px = CSSPrimitiveValue::create(primitiveValue- >getDoubleValue(), CSSPrimitiveValue::CSS_PX); 602 RefPtr<CSSPrimitiveValue> px = CSSPrimitiveValue::create(primitiveValue- >getDoubleValue(), CSSPrimitiveValue::CSS_PX);
603 return convertPerspectiveLength(state, px.get()); 603 return convertPerspectiveLength(state, px.get());
604 } 604 }
605 605
606 return convertPerspectiveLength(state, primitiveValue); 606 return convertPerspectiveLength(state, primitiveValue);
607 } 607 }
608 608
609 template <CSSValueID cssValueFor0, CSSValueID cssValueFor100>
610 static Length convertOriginLength(StyleResolverState& state, CSSPrimitiveValue* primitiveValue)
611 {
612 if (primitiveValue->isValueID()) {
613 switch (primitiveValue->getValueID()) {
614 case cssValueFor0:
615 return Length(0, Percent);
616 case cssValueFor100:
617 return Length(100, Percent);
618 case CSSValueCenter:
619 return Length(50, Percent);
620 default:
621 ASSERT_NOT_REACHED();
622 return Length(0, Percent);
Timothy Loh 2014/10/10 15:04:20 Since we never get here, do we need to bother with
623 }
624 }
625
626 return StyleBuilderConverter::convertLength(state, primitiveValue);
627 }
628
629 LengthPoint StyleBuilderConverter::convertPerspectiveOrigin(StyleResolverState& state, CSSValue* value)
630 {
631 CSSValueList* list = toCSSValueList(value);
632 ASSERT(list->length() == 2);
633
634 CSSPrimitiveValue* primitiveValueX = toCSSPrimitiveValue(list->item(0));
635 CSSPrimitiveValue* primitiveValueY = toCSSPrimitiveValue(list->item(1));
636
637 return LengthPoint(
638 convertOriginLength<CSSValueLeft, CSSValueRight>(state, primitiveValueX) ,
639 convertOriginLength<CSSValueTop, CSSValueBottom>(state, primitiveValueY)
640 );
641 }
642
609 EPaintOrder StyleBuilderConverter::convertPaintOrder(StyleResolverState&, CSSVal ue* cssPaintOrder) 643 EPaintOrder StyleBuilderConverter::convertPaintOrder(StyleResolverState&, CSSVal ue* cssPaintOrder)
610 { 644 {
611 if (cssPaintOrder->isValueList()) { 645 if (cssPaintOrder->isValueList()) {
612 int paintOrder = 0; 646 int paintOrder = 0;
613 const CSSValueList& list = *toCSSValueList(cssPaintOrder); 647 const CSSValueList& list = *toCSSValueList(cssPaintOrder);
614 for (size_t i = 0; i < list.length(); ++i) { 648 for (size_t i = 0; i < list.length(); ++i) {
615 EPaintOrderType paintOrderType = PT_NONE; 649 EPaintOrderType paintOrderType = PT_NONE;
616 switch (toCSSPrimitiveValue(list.item(i))->getValueID()) { 650 switch (toCSSPrimitiveValue(list.item(i))->getValueID()) {
617 case CSSValueFill: 651 case CSSValueFill:
618 paintOrderType = PT_FILL; 652 paintOrderType = PT_FILL;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 { 785 {
752 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 786 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
753 if (primitiveValue->getValueID()) { 787 if (primitiveValue->getValueID()) {
754 float multiplier = convertLineWidth<float>(state, value); 788 float multiplier = convertLineWidth<float>(state, value);
755 return CSSPrimitiveValue::create(multiplier / 48, CSSPrimitiveValue::CSS _EMS)->computeLength<float>(state.cssToLengthConversionData()); 789 return CSSPrimitiveValue::create(multiplier / 48, CSSPrimitiveValue::CSS _EMS)->computeLength<float>(state.cssToLengthConversionData());
756 } 790 }
757 return primitiveValue->computeLength<float>(state.cssToLengthConversionData( )); 791 return primitiveValue->computeLength<float>(state.cssToLengthConversionData( ));
758 } 792 }
759 793
760 } // namespace blink 794 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/resolver/StyleBuilderConverter.h ('k') | Source/core/css/resolver/StyleBuilderCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698