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

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: Moved BorderImageLength{,Box} to core/rendering/style 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
« no previous file with comments | « Source/core/css/CSSToStyleMap.h ('k') | Source/core/rendering/RenderBoxModelObject.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 19 matching lines...) Expand all
30 30
31 #include "CSSValueKeywords.h" 31 #include "CSSValueKeywords.h"
32 #include "core/css/CSSBorderImageSliceValue.h" 32 #include "core/css/CSSBorderImageSliceValue.h"
33 #include "core/css/CSSPrimitiveValue.h" 33 #include "core/css/CSSPrimitiveValue.h"
34 #include "core/css/CSSPrimitiveValueMappings.h" 34 #include "core/css/CSSPrimitiveValueMappings.h"
35 #include "core/css/CSSTimingFunctionValue.h" 35 #include "core/css/CSSTimingFunctionValue.h"
36 #include "core/css/Pair.h" 36 #include "core/css/Pair.h"
37 #include "core/css/Rect.h" 37 #include "core/css/Rect.h"
38 #include "core/css/resolver/StyleResolverState.h" 38 #include "core/css/resolver/StyleResolverState.h"
39 #include "core/platform/animation/CSSAnimationData.h" 39 #include "core/platform/animation/CSSAnimationData.h"
40 #include "core/rendering/style/BorderImageLengthBox.h"
40 #include "core/rendering/style/FillLayer.h" 41 #include "core/rendering/style/FillLayer.h"
41 42
42 namespace WebCore { 43 namespace WebCore {
43 44
44 const RenderStyle* CSSToStyleMap::style() const 45 const RenderStyle* CSSToStyleMap::style() const
45 { 46 {
46 return m_state.style(); 47 return m_state.style();
47 } 48 }
48 49
49 const RenderStyle* CSSToStyleMap::rootElementStyle() const 50 const RenderStyle* CSSToStyleMap::rootElementStyle() const
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 } else if (current->isPrimitiveValue()) { 559 } else if (current->isPrimitiveValue()) {
559 // Set the appropriate rules for stretch/round/repeat of the slices. 560 // Set the appropriate rules for stretch/round/repeat of the slices.
560 mapNinePieceImageRepeat(current, image); 561 mapNinePieceImageRepeat(current, image);
561 } 562 }
562 } 563 }
563 564
564 if (property == CSSPropertyWebkitBorderImage) { 565 if (property == CSSPropertyWebkitBorderImage) {
565 // We have to preserve the legacy behavior of -webkit-border-image and m ake the border slices 566 // 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 567 // 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. 568 // those on real borders yet.
568 if (image.borderSlices().top().isFixed()) 569 if (image.borderSlices().top().isLength() && image.borderSlices().top(). length().isFixed())
569 mutableStyle->setBorderTopWidth(image.borderSlices().top().value()); 570 mutableStyle->setBorderTopWidth(image.borderSlices().top().length(). value());
570 if (image.borderSlices().right().isFixed()) 571 if (image.borderSlices().right().isLength() && image.borderSlices().righ t().length().isFixed())
571 mutableStyle->setBorderRightWidth(image.borderSlices().right().value ()); 572 mutableStyle->setBorderRightWidth(image.borderSlices().right().lengt h().value());
572 if (image.borderSlices().bottom().isFixed()) 573 if (image.borderSlices().bottom().isLength() && image.borderSlices().bot tom().length().isFixed())
573 mutableStyle->setBorderBottomWidth(image.borderSlices().bottom().val ue()); 574 mutableStyle->setBorderBottomWidth(image.borderSlices().bottom().len gth().value());
574 if (image.borderSlices().left().isFixed()) 575 if (image.borderSlices().left().isLength() && image.borderSlices().left( ).length().isFixed())
575 mutableStyle->setBorderLeftWidth(image.borderSlices().left().value() ); 576 mutableStyle->setBorderLeftWidth(image.borderSlices().left().length( ).value());
576 } 577 }
577 } 578 }
578 579
579 void CSSToStyleMap::mapNinePieceImageSlice(CSSValue* value, NinePieceImage& imag e) const 580 void CSSToStyleMap::mapNinePieceImageSlice(CSSValue* value, NinePieceImage& imag e) const
580 { 581 {
581 if (!value || !value->isBorderImageSliceValue()) 582 if (!value || !value->isBorderImageSliceValue())
582 return; 583 return;
583 584
584 // Retrieve the border image value. 585 // Retrieve the border image value.
585 CSSBorderImageSliceValue* borderImageSlice = toCSSBorderImageSliceValue(valu e); 586 CSSBorderImageSliceValue* borderImageSlice = toCSSBorderImageSliceValue(valu e);
(...skipping 16 matching lines...) Expand all
602 if (slices->right()->isPercentage()) 603 if (slices->right()->isPercentage())
603 box.m_right = Length(slices->right()->getDoubleValue(), Percent); 604 box.m_right = Length(slices->right()->getDoubleValue(), Percent);
604 else 605 else
605 box.m_right = Length(slices->right()->getIntValue(CSSPrimitiveValue::CSS _NUMBER), Fixed); 606 box.m_right = Length(slices->right()->getIntValue(CSSPrimitiveValue::CSS _NUMBER), Fixed);
606 image.setImageSlices(box); 607 image.setImageSlices(box);
607 608
608 // Set our fill mode. 609 // Set our fill mode.
609 image.setFill(borderImageSlice->m_fill); 610 image.setFill(borderImageSlice->m_fill);
610 } 611 }
611 612
612 LengthBox CSSToStyleMap::mapNinePieceImageQuad(CSSValue* value) const 613 BorderImageLengthBox CSSToStyleMap::mapNinePieceImageQuad(CSSValue* value) const
613 { 614 {
614 if (!value || !value->isPrimitiveValue()) 615 if (!value || !value->isPrimitiveValue())
615 return LengthBox(); 616 return BorderImageLengthBox();
616 617
617 // Get our zoom value. 618 // Get our zoom value.
618 float zoom = useSVGZoomRules() ? 1.0f : style()->effectiveZoom(); 619 float zoom = useSVGZoomRules() ? 1.0f : style()->effectiveZoom();
619 620
620 // Retrieve the primitive value. 621 // Retrieve the primitive value.
621 CSSPrimitiveValue* borderWidths = toCSSPrimitiveValue(value); 622 CSSPrimitiveValue* borderWidths = toCSSPrimitiveValue(value);
622 623
623 // Set up a length box to represent our image slices. 624 // 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. 625 BorderImageLengthBox box; // Defaults to 'auto' so we don't have to handle t hat explicitly below.
625 Quad* slices = borderWidths->getQuadValue(); 626 Quad* slices = borderWidths->getQuadValue();
626 if (slices->top()->isNumber()) 627 if (slices->top()->isNumber())
627 box.m_top = Length(slices->top()->getIntValue(), Relative); 628 box.setTop(slices->top()->getIntValue());
628 else if (slices->top()->isPercentage()) 629 else if (slices->top()->isPercentage())
629 box.m_top = Length(slices->top()->getDoubleValue(CSSPrimitiveValue::CSS_ PERCENTAGE), Percent); 630 box.setTop(Length(slices->top()->getDoubleValue(CSSPrimitiveValue::CSS_P ERCENTAGE), Percent));
630 else if (slices->top()->getValueID() != CSSValueAuto) 631 else if (slices->top()->getValueID() != CSSValueAuto)
631 box.m_top = slices->top()->computeLength<Length>(style(), rootElementSty le(), zoom); 632 box.setTop(slices->top()->computeLength<Length>(style(), rootElementStyl e(), zoom));
632 633
633 if (slices->right()->isNumber()) 634 if (slices->right()->isNumber())
634 box.m_right = Length(slices->right()->getIntValue(), Relative); 635 box.setRight(slices->right()->getIntValue());
635 else if (slices->right()->isPercentage()) 636 else if (slices->right()->isPercentage())
636 box.m_right = Length(slices->right()->getDoubleValue(CSSPrimitiveValue:: CSS_PERCENTAGE), Percent); 637 box.setRight(Length(slices->right()->getDoubleValue(CSSPrimitiveValue::C SS_PERCENTAGE), Percent));
637 else if (slices->right()->getValueID() != CSSValueAuto) 638 else if (slices->right()->getValueID() != CSSValueAuto)
638 box.m_right = slices->right()->computeLength<Length>(style(), rootElemen tStyle(), zoom); 639 box.setRight(slices->right()->computeLength<Length>(style(), rootElement Style(), zoom));
639 640
640 if (slices->bottom()->isNumber()) 641 if (slices->bottom()->isNumber())
641 box.m_bottom = Length(slices->bottom()->getIntValue(), Relative); 642 box.setBottom(slices->bottom()->getIntValue());
642 else if (slices->bottom()->isPercentage()) 643 else if (slices->bottom()->isPercentage())
643 box.m_bottom = Length(slices->bottom()->getDoubleValue(CSSPrimitiveValue ::CSS_PERCENTAGE), Percent); 644 box.setBottom(Length(slices->bottom()->getDoubleValue(CSSPrimitiveValue: :CSS_PERCENTAGE), Percent));
644 else if (slices->bottom()->getValueID() != CSSValueAuto) 645 else if (slices->bottom()->getValueID() != CSSValueAuto)
645 box.m_bottom = slices->bottom()->computeLength<Length>(style(), rootElem entStyle(), zoom); 646 box.setBottom(slices->bottom()->computeLength<Length>(style(), rootEleme ntStyle(), zoom));
646 647
647 if (slices->left()->isNumber()) 648 if (slices->left()->isNumber())
648 box.m_left = Length(slices->left()->getIntValue(), Relative); 649 box.setLeft(slices->left()->getIntValue());
649 else if (slices->left()->isPercentage()) 650 else if (slices->left()->isPercentage())
650 box.m_left = Length(slices->left()->getDoubleValue(CSSPrimitiveValue::CS S_PERCENTAGE), Percent); 651 box.setLeft(Length(slices->left()->getDoubleValue(CSSPrimitiveValue::CSS _PERCENTAGE), Percent));
651 else if (slices->left()->getValueID() != CSSValueAuto) 652 else if (slices->left()->getValueID() != CSSValueAuto)
652 box.m_left = slices->left()->computeLength<Length>(style(), rootElementS tyle(), zoom); 653 box.setLeft(slices->left()->computeLength<Length>(style(), rootElementSt yle(), zoom));
653 654
654 return box; 655 return box;
655 } 656 }
656 657
657 void CSSToStyleMap::mapNinePieceImageRepeat(CSSValue* value, NinePieceImage& ima ge) const 658 void CSSToStyleMap::mapNinePieceImageRepeat(CSSValue* value, NinePieceImage& ima ge) const
658 { 659 {
659 if (!value || !value->isPrimitiveValue()) 660 if (!value || !value->isPrimitiveValue())
660 return; 661 return;
661 662
662 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); 663 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 verticalRule = SpaceImageRule; 697 verticalRule = SpaceImageRule;
697 break; 698 break;
698 default: // CSSValueRepeat 699 default: // CSSValueRepeat
699 verticalRule = RepeatImageRule; 700 verticalRule = RepeatImageRule;
700 break; 701 break;
701 } 702 }
702 image.setVerticalRule(verticalRule); 703 image.setVerticalRule(verticalRule);
703 } 704 }
704 705
705 }; 706 };
OLDNEW
« no previous file with comments | « Source/core/css/CSSToStyleMap.h ('k') | Source/core/rendering/RenderBoxModelObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698