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

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

Issue 55783002: Introduce BorderImageLength and BorderImageLengthBox (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 1 month 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 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All r ights reserved. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All r ights reserved.
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 } else if (current->isPrimitiveValue()) { 558 } else if (current->isPrimitiveValue()) {
559 // Set the appropriate rules for stretch/round/repeat of the slices. 559 // Set the appropriate rules for stretch/round/repeat of the slices.
560 mapNinePieceImageRepeat(current, image); 560 mapNinePieceImageRepeat(current, image);
561 } 561 }
562 } 562 }
563 563
564 if (property == CSSPropertyWebkitBorderImage) { 564 if (property == CSSPropertyWebkitBorderImage) {
565 // We have to preserve the legacy behavior of -webkit-border-image and m ake the border slices 565 // We have to preserve the legacy behavior of -webkit-border-image and m ake the border slices
566 // also set the border widths. We don't need to worry about percentages, since we don't even support 566 // also set the border widths. We don't need to worry about percentages, since we don't even support
567 // those on real borders yet. 567 // those on real borders yet.
568 if (image.borderSlices().top().isFixed()) 568 if (image.borderSlices().top().isLength() && image.borderSlices().top(). length().isFixed())
569 mutableStyle->setBorderTopWidth(image.borderSlices().top().value()); 569 mutableStyle->setBorderTopWidth(image.borderSlices().top().length(). value());
570 if (image.borderSlices().right().isFixed()) 570 if (image.borderSlices().right().isLength() && image.borderSlices().righ t().length().isFixed())
571 mutableStyle->setBorderRightWidth(image.borderSlices().right().value ()); 571 mutableStyle->setBorderRightWidth(image.borderSlices().right().lengt h().value());
572 if (image.borderSlices().bottom().isFixed()) 572 if (image.borderSlices().bottom().isLength() && image.borderSlices().bot tom().length().isFixed())
573 mutableStyle->setBorderBottomWidth(image.borderSlices().bottom().val ue()); 573 mutableStyle->setBorderBottomWidth(image.borderSlices().bottom().len gth().value());
574 if (image.borderSlices().left().isFixed()) 574 if (image.borderSlices().left().isLength() && image.borderSlices().left( ).length().isFixed())
575 mutableStyle->setBorderLeftWidth(image.borderSlices().left().value() ); 575 mutableStyle->setBorderLeftWidth(image.borderSlices().left().length( ).value());
576 } 576 }
577 } 577 }
578 578
579 void CSSToStyleMap::mapNinePieceImageSlice(CSSValue* value, NinePieceImage& imag e) const 579 void CSSToStyleMap::mapNinePieceImageSlice(CSSValue* value, NinePieceImage& imag e) const
580 { 580 {
581 if (!value || !value->isBorderImageSliceValue()) 581 if (!value || !value->isBorderImageSliceValue())
582 return; 582 return;
583 583
584 // Retrieve the border image value. 584 // Retrieve the border image value.
585 CSSBorderImageSliceValue* borderImageSlice = toCSSBorderImageSliceValue(valu e); 585 CSSBorderImageSliceValue* borderImageSlice = toCSSBorderImageSliceValue(valu e);
(...skipping 16 matching lines...) Expand all
602 if (slices->right()->isPercentage()) 602 if (slices->right()->isPercentage())
603 box.m_right = Length(slices->right()->getDoubleValue(), Percent); 603 box.m_right = Length(slices->right()->getDoubleValue(), Percent);
604 else 604 else
605 box.m_right = Length(slices->right()->getIntValue(CSSPrimitiveValue::CSS _NUMBER), Fixed); 605 box.m_right = Length(slices->right()->getIntValue(CSSPrimitiveValue::CSS _NUMBER), Fixed);
606 image.setImageSlices(box); 606 image.setImageSlices(box);
607 607
608 // Set our fill mode. 608 // Set our fill mode.
609 image.setFill(borderImageSlice->m_fill); 609 image.setFill(borderImageSlice->m_fill);
610 } 610 }
611 611
612 LengthBox CSSToStyleMap::mapNinePieceImageQuad(CSSValue* value) const 612 LengthOrNumberBox CSSToStyleMap::mapNinePieceImageQuad(CSSValue* value) const
613 { 613 {
614 if (!value || !value->isPrimitiveValue()) 614 if (!value || !value->isPrimitiveValue())
615 return LengthBox(); 615 return LengthOrNumberBox();
616 616
617 // Get our zoom value. 617 // Get our zoom value.
618 float zoom = useSVGZoomRules() ? 1.0f : style()->effectiveZoom(); 618 float zoom = useSVGZoomRules() ? 1.0f : style()->effectiveZoom();
619 619
620 // Retrieve the primitive value. 620 // Retrieve the primitive value.
621 CSSPrimitiveValue* borderWidths = toCSSPrimitiveValue(value); 621 CSSPrimitiveValue* borderWidths = toCSSPrimitiveValue(value);
622 622
623 // Set up a length box to represent our image slices. 623 // Set up a length box to represent our image slices.
624 LengthBox box; // Defaults to 'auto' so we don't have to handle that explici tly below. 624 LengthOrNumberBox box; // Defaults to 'auto' so we don't have to handle that explicitly below.
625 Quad* slices = borderWidths->getQuadValue(); 625 Quad* slices = borderWidths->getQuadValue();
626 if (slices->top()->isNumber()) 626 if (slices->top()->isNumber())
627 box.m_top = Length(slices->top()->getIntValue(), Relative); 627 box.setTop(LengthOrNumber(slices->top()->getIntValue()));
Julien - ping for review 2013/11/01 18:27:11 Nit: There is no explicit around LengthOrNumber(do
davve 2013/11/04 12:42:54 Thanks. I use an implicit constructor for both Len
628 else if (slices->top()->isPercentage()) 628 else if (slices->top()->isPercentage())
629 box.m_top = Length(slices->top()->getDoubleValue(CSSPrimitiveValue::CSS_ PERCENTAGE), Percent); 629 box.setTop(LengthOrNumber(Length(slices->top()->getDoubleValue(CSSPrimit iveValue::CSS_PERCENTAGE), Percent)));
630 else if (slices->top()->getValueID() != CSSValueAuto) 630 else if (slices->top()->getValueID() != CSSValueAuto)
631 box.m_top = slices->top()->computeLength<Length>(style(), rootElementSty le(), zoom); 631 box.setTop(LengthOrNumber(slices->top()->computeLength<Length>(style(), rootElementStyle(), zoom)));
632 632
633 if (slices->right()->isNumber()) 633 if (slices->right()->isNumber())
634 box.m_right = Length(slices->right()->getIntValue(), Relative); 634 box.setRight(LengthOrNumber(slices->right()->getIntValue()));
635 else if (slices->right()->isPercentage()) 635 else if (slices->right()->isPercentage())
636 box.m_right = Length(slices->right()->getDoubleValue(CSSPrimitiveValue:: CSS_PERCENTAGE), Percent); 636 box.setRight(LengthOrNumber(Length(slices->right()->getDoubleValue(CSSPr imitiveValue::CSS_PERCENTAGE), Percent)));
637 else if (slices->right()->getValueID() != CSSValueAuto) 637 else if (slices->right()->getValueID() != CSSValueAuto)
638 box.m_right = slices->right()->computeLength<Length>(style(), rootElemen tStyle(), zoom); 638 box.setRight(LengthOrNumber(slices->right()->computeLength<Length>(style (), rootElementStyle(), zoom)));
639 639
640 if (slices->bottom()->isNumber()) 640 if (slices->bottom()->isNumber())
641 box.m_bottom = Length(slices->bottom()->getIntValue(), Relative); 641 box.setBottom(LengthOrNumber(slices->bottom()->getIntValue()));
642 else if (slices->bottom()->isPercentage()) 642 else if (slices->bottom()->isPercentage())
643 box.m_bottom = Length(slices->bottom()->getDoubleValue(CSSPrimitiveValue ::CSS_PERCENTAGE), Percent); 643 box.setBottom(LengthOrNumber(Length(slices->bottom()->getDoubleValue(CSS PrimitiveValue::CSS_PERCENTAGE), Percent)));
644 else if (slices->bottom()->getValueID() != CSSValueAuto) 644 else if (slices->bottom()->getValueID() != CSSValueAuto)
645 box.m_bottom = slices->bottom()->computeLength<Length>(style(), rootElem entStyle(), zoom); 645 box.setBottom(LengthOrNumber(slices->bottom()->computeLength<Length>(sty le(), rootElementStyle(), zoom)));
646 646
647 if (slices->left()->isNumber()) 647 if (slices->left()->isNumber())
648 box.m_left = Length(slices->left()->getIntValue(), Relative); 648 box.setLeft(LengthOrNumber(slices->left()->getIntValue()));
649 else if (slices->left()->isPercentage()) 649 else if (slices->left()->isPercentage())
650 box.m_left = Length(slices->left()->getDoubleValue(CSSPrimitiveValue::CS S_PERCENTAGE), Percent); 650 box.setLeft(LengthOrNumber(Length(slices->left()->getDoubleValue(CSSPrim itiveValue::CSS_PERCENTAGE), Percent)));
651 else if (slices->left()->getValueID() != CSSValueAuto) 651 else if (slices->left()->getValueID() != CSSValueAuto)
652 box.m_left = slices->left()->computeLength<Length>(style(), rootElementS tyle(), zoom); 652 box.setLeft(LengthOrNumber(slices->left()->computeLength<Length>(style() , rootElementStyle(), zoom)));
653 653
654 return box; 654 return box;
655 } 655 }
656 656
657 void CSSToStyleMap::mapNinePieceImageRepeat(CSSValue* value, NinePieceImage& ima ge) const 657 void CSSToStyleMap::mapNinePieceImageRepeat(CSSValue* value, NinePieceImage& ima ge) const
658 { 658 {
659 if (!value || !value->isPrimitiveValue()) 659 if (!value || !value->isPrimitiveValue())
660 return; 660 return;
661 661
662 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 662 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 verticalRule = SpaceImageRule; 696 verticalRule = SpaceImageRule;
697 break; 697 break;
698 default: // CSSValueRepeat 698 default: // CSSValueRepeat
699 verticalRule = RepeatImageRule; 699 verticalRule = RepeatImageRule;
700 break; 700 break;
701 } 701 }
702 image.setVerticalRule(verticalRule); 702 image.setVerticalRule(verticalRule);
703 } 703 }
704 704
705 }; 705 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698