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

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

Issue 1306823004: Split out String, URI and CustomIdent from CSSPrimitiveValue (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@split_out_attr_values
Patch Set: Fixing tests Created 5 years, 3 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 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
4 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) 4 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
5 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) 5 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
10 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 10 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 } 564 }
565 565
566 void StyleBuilderFunctions::applyValueCSSPropertyWebkitClipPath(StyleResolverSta te& state, CSSValue* value) 566 void StyleBuilderFunctions::applyValueCSSPropertyWebkitClipPath(StyleResolverSta te& state, CSSValue* value)
567 { 567 {
568 if (value->isPrimitiveValue()) { 568 if (value->isPrimitiveValue()) {
569 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 569 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
570 if (primitiveValue->getValueID() == CSSValueNone) { 570 if (primitiveValue->getValueID() == CSSValueNone) {
571 state.style()->setClipPath(nullptr); 571 state.style()->setClipPath(nullptr);
572 } else if (primitiveValue->isShape()) { 572 } else if (primitiveValue->isShape()) {
573 state.style()->setClipPath(ShapeClipPathOperation::create(basicShape ForValue(state, primitiveValue->getShapeValue()))); 573 state.style()->setClipPath(ShapeClipPathOperation::create(basicShape ForValue(state, primitiveValue->getShapeValue())));
574 } else if (primitiveValue->isURI()) {
575 String cssURLValue = primitiveValue->getStringValue();
576 KURL url = state.document().completeURL(cssURLValue);
577 // FIXME: It doesn't work with forward or external SVG references (s ee https://bugs.webkit.org/show_bug.cgi?id=90405)
578 state.style()->setClipPath(ReferenceClipPathOperation::create(cssURL Value, AtomicString(url.fragmentIdentifier())));
579 } 574 }
575 } else if (value->isURIValue()) {
576 String cssURLValue = toCSSURIValue(value)->value();
577 KURL url = state.document().completeURL(cssURLValue);
578 // FIXME: It doesn't work with forward or external SVG references (see h ttps://bugs.webkit.org/show_bug.cgi?id=90405)
579 state.style()->setClipPath(ReferenceClipPathOperation::create(cssURLValu e, AtomicString(url.fragmentIdentifier())));
580 } 580 }
581 } 581 }
582 582
583 void StyleBuilderFunctions::applyValueCSSPropertyWebkitFilter(StyleResolverState & state, CSSValue* value) 583 void StyleBuilderFunctions::applyValueCSSPropertyWebkitFilter(StyleResolverState & state, CSSValue* value)
584 { 584 {
585 // FIXME: We should just make this a converter 585 // FIXME: We should just make this a converter
586 FilterOperations operations; 586 FilterOperations operations;
587 FilterOperationResolver::createFilterOperations(*value, state.cssToLengthCon versionData(), operations, state); 587 FilterOperationResolver::createFilterOperations(*value, state.cssToLengthCon versionData(), operations, state);
588 state.style()->setFilter(operations); 588 state.style()->setFilter(operations);
589 } 589 }
(...skipping 29 matching lines...) Expand all
619 CSSPrimitiveValue* value = toCSSPrimitiveValue(list->item(i)); 619 CSSPrimitiveValue* value = toCSSPrimitiveValue(list->item(i));
620 if (value->getValueID() == CSSValueFilled || value->getValueID() == CSSValueOpen) 620 if (value->getValueID() == CSSValueFilled || value->getValueID() == CSSValueOpen)
621 state.style()->setTextEmphasisFill(*value); 621 state.style()->setTextEmphasisFill(*value);
622 else 622 else
623 state.style()->setTextEmphasisMark(*value); 623 state.style()->setTextEmphasisMark(*value);
624 } 624 }
625 state.style()->setTextEmphasisCustomMark(nullAtom); 625 state.style()->setTextEmphasisCustomMark(nullAtom);
626 return; 626 return;
627 } 627 }
628 628
629 if (value->isStringValue()) {
630 state.style()->setTextEmphasisFill(TextEmphasisFillFilled);
631 state.style()->setTextEmphasisMark(TextEmphasisMarkCustom);
632 state.style()->setTextEmphasisCustomMark(AtomicString(toCSSStringValue(v alue)->value()));
633 return;
634 }
635
629 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 636 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
630
631 if (primitiveValue->isString()) {
632 state.style()->setTextEmphasisFill(TextEmphasisFillFilled);
633 state.style()->setTextEmphasisMark(TextEmphasisMarkCustom);
634 state.style()->setTextEmphasisCustomMark(AtomicString(primitiveValue->ge tStringValue()));
635 return;
636 }
637
638 state.style()->setTextEmphasisCustomMark(nullAtom); 637 state.style()->setTextEmphasisCustomMark(nullAtom);
639 638
640 if (primitiveValue->getValueID() == CSSValueFilled || primitiveValue->getVal ueID() == CSSValueOpen) { 639 if (primitiveValue->getValueID() == CSSValueFilled || primitiveValue->getVal ueID() == CSSValueOpen) {
641 state.style()->setTextEmphasisFill(*primitiveValue); 640 state.style()->setTextEmphasisFill(*primitiveValue);
642 state.style()->setTextEmphasisMark(TextEmphasisMarkAuto); 641 state.style()->setTextEmphasisMark(TextEmphasisMarkAuto);
643 } else { 642 } else {
644 state.style()->setTextEmphasisFill(TextEmphasisFillFilled); 643 state.style()->setTextEmphasisFill(TextEmphasisFillFilled);
645 state.style()->setTextEmphasisMark(*primitiveValue); 644 state.style()->setTextEmphasisMark(*primitiveValue);
646 } 645 }
647 } 646 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 } 728 }
730 729
731 if (item->isFunctionValue()) { 730 if (item->isFunctionValue()) {
732 CSSFunctionValue* functionValue = toCSSFunctionValue(item.get()); 731 CSSFunctionValue* functionValue = toCSSFunctionValue(item.get());
733 ASSERT(functionValue->functionType() == CSSValueAttr); 732 ASSERT(functionValue->functionType() == CSSValueAttr);
734 // FIXME: Can a namespace be specified for an attr(foo)? 733 // FIXME: Can a namespace be specified for an attr(foo)?
735 if (state.style()->styleType() == NOPSEUDO) 734 if (state.style()->styleType() == NOPSEUDO)
736 state.style()->setUnique(); 735 state.style()->setUnique();
737 else 736 else
738 state.parentStyle()->setUnique(); 737 state.parentStyle()->setUnique();
739 QualifiedName attr(nullAtom, AtomicString(toCSSPrimitiveValue(functi onValue->item(0))->getStringValue()), nullAtom); 738 QualifiedName attr(nullAtom, AtomicString(toCSSCustomIdentValue(func tionValue->item(0))->value()), nullAtom);
740 const AtomicString& value = state.element()->getAttribute(attr); 739 const AtomicString& value = state.element()->getAttribute(attr);
741 state.style()->setContent(value.isNull() ? emptyString() : value.str ing(), didSet); 740 state.style()->setContent(value.isNull() ? emptyString() : value.str ing(), didSet);
742 didSet = true; 741 didSet = true;
743 } 742 }
744 743
745 if (!item->isPrimitiveValue()) 744 if (!item->isPrimitiveValue() && !item->isStringValue())
alancutter (OOO until 2018) 2015/09/17 02:59:29 Shouldn't this be ||?
sashab 2015/09/17 04:19:49 It's a bit confusing, but it should be &&. "If the
746 continue; 745 continue;
747 746
748 CSSPrimitiveValue* contentValue = toCSSPrimitiveValue(item.get()); 747 if (item->isStringValue()) {
749 748 CSSStringValue* contentValue = toCSSStringValue(item.get());
750 if (contentValue->isString()) { 749 state.style()->setContent(contentValue->value().impl(), didSet);
751 state.style()->setContent(contentValue->getStringValue().impl(), did Set);
752 didSet = true; 750 didSet = true;
753 } else { 751 } else {
752 CSSPrimitiveValue* contentValue = toCSSPrimitiveValue(item.get());
754 switch (contentValue->getValueID()) { 753 switch (contentValue->getValueID()) {
755 case CSSValueOpenQuote: 754 case CSSValueOpenQuote:
756 state.style()->setContent(OPEN_QUOTE, didSet); 755 state.style()->setContent(OPEN_QUOTE, didSet);
757 didSet = true; 756 didSet = true;
758 break; 757 break;
759 case CSSValueCloseQuote: 758 case CSSValueCloseQuote:
760 state.style()->setContent(CLOSE_QUOTE, didSet); 759 state.style()->setContent(CLOSE_QUOTE, didSet);
761 didSet = true; 760 didSet = true;
762 break; 761 break;
763 case CSSValueNoOpenQuote: 762 case CSSValueNoOpenQuote:
764 state.style()->setContent(NO_OPEN_QUOTE, didSet); 763 state.style()->setContent(NO_OPEN_QUOTE, didSet);
765 didSet = true; 764 didSet = true;
766 break; 765 break;
767 case CSSValueNoCloseQuote: 766 case CSSValueNoCloseQuote:
768 state.style()->setContent(NO_CLOSE_QUOTE, didSet); 767 state.style()->setContent(NO_CLOSE_QUOTE, didSet);
769 didSet = true; 768 didSet = true;
770 break; 769 break;
771 default: 770 default:
772 // normal and none do not have any effect. 771 // normal and none do not have any effect.
773 { } 772 { }
774 } 773 }
775 } 774 }
776 } 775 }
777 if (!didSet) 776 if (!didSet)
778 state.style()->clearContent(); 777 state.style()->clearContent();
779 } 778 }
780 779
781 void StyleBuilderFunctions::applyValueCSSPropertyWebkitLocale(StyleResolverState & state, CSSValue* value) 780 void StyleBuilderFunctions::applyValueCSSPropertyWebkitLocale(StyleResolverState & state, CSSValue* value)
782 { 781 {
783 const CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 782 if (value->isPrimitiveValue() && toCSSPrimitiveValue(value)->getValueID() == CSSValueAuto) {
784 if (primitiveValue->getValueID() == CSSValueAuto) {
785 state.style()->setLocale(nullAtom); 783 state.style()->setLocale(nullAtom);
786 } else { 784 } else {
787 ASSERT(primitiveValue->isString()); 785 state.style()->setLocale(AtomicString(toCSSStringValue(value)->value())) ;
788 state.style()->setLocale(AtomicString(primitiveValue->getStringValue())) ;
789 } 786 }
790 state.fontBuilder().setScript(state.style()->locale()); 787 state.fontBuilder().setScript(state.style()->locale());
791 } 788 }
792 789
793 void StyleBuilderFunctions::applyInitialCSSPropertyWebkitAppRegion(StyleResolver State&) 790 void StyleBuilderFunctions::applyInitialCSSPropertyWebkitAppRegion(StyleResolver State&)
794 { 791 {
795 } 792 }
796 793
797 void StyleBuilderFunctions::applyInheritCSSPropertyWebkitAppRegion(StyleResolver State&) 794 void StyleBuilderFunctions::applyInheritCSSPropertyWebkitAppRegion(StyleResolver State&)
798 { 795 {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 return; 841 return;
845 case CSSValueSuper: 842 case CSSValueSuper:
846 svgStyle.setBaselineShift(BS_SUPER); 843 svgStyle.setBaselineShift(BS_SUPER);
847 return; 844 return;
848 default: 845 default:
849 ASSERT_NOT_REACHED(); 846 ASSERT_NOT_REACHED();
850 } 847 }
851 } 848 }
852 849
853 } // namespace blink 850 } // namespace blink
OLDNEW
« Source/core/css/CSSStringValueBase.h ('K') | « Source/core/css/resolver/StyleBuilderConverter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698