Changeset 127224 in webkit for trunk/Source/WebCore/css/CSSGradientValue.cpp
- Timestamp:
- Aug 30, 2012, 6:25:43 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/css/CSSGradientValue.cpp
r124884 r127224 39 39 #include "RenderObject.h" 40 40 #include "StyleResolver.h" 41 #include <wtf/text/StringBuilder.h> 41 42 42 43 using namespace std; … … 474 475 String CSSLinearGradientValue::customCssText() const 475 476 { 476 String result;477 StringBuilder result; 477 478 if (m_deprecatedType) { 478 result = "-webkit-gradient(linear, "; 479 result += m_firstX->cssText() + " "; 480 result += m_firstY->cssText() + ", "; 481 result += m_secondX->cssText() + " "; 482 result += m_secondY->cssText(); 479 result.appendLiteral("-webkit-gradient(linear, "); 480 result.append(m_firstX->cssText()); 481 result.append(' '); 482 result.append(m_firstY->cssText()); 483 result.appendLiteral(", "); 484 result.append(m_secondX->cssText()); 485 result.append(' '); 486 result.append(m_secondY->cssText()); 483 487 484 488 for (unsigned i = 0; i < m_stops.size(); i++) { 485 489 const CSSGradientColorStop& stop = m_stops[i]; 486 result += ", "; 487 if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 0) 488 result += "from(" + stop.m_color->cssText() + ")"; 489 else if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 1) 490 result += "to(" + stop.m_color->cssText() + ")"; 491 else 492 result += "color-stop(" + String::number(stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER)) + ", " + stop.m_color->cssText() + ")"; 490 result.appendLiteral(", "); 491 if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 0) { 492 result.appendLiteral("from("); 493 result.append(stop.m_color->cssText()); 494 result.append(')'); 495 } else if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 1) { 496 result.appendLiteral("to("); 497 result.append(stop.m_color->cssText()); 498 result.append(')'); 499 } else { 500 result.appendLiteral("color-stop("); 501 result.append(String::number(stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER))); 502 result.appendLiteral(", "); 503 result.append(stop.m_color->cssText()); 504 result.append(')'); 505 } 493 506 } 494 507 } else { 495 result = m_repeating ? "-webkit-repeating-linear-gradient(" : "-webkit-linear-gradient("; 508 if (m_repeating) 509 result.appendLiteral("-webkit-repeating-linear-gradient("); 510 else 511 result.appendLiteral("-webkit-linear-gradient("); 512 496 513 if (m_angle) 497 result += m_angle->cssText();514 result.append(m_angle->cssText()); 498 515 else { 499 if (m_firstX && m_firstY) 500 result += m_firstX->cssText() + " " + m_firstY->cssText(); 501 else if (m_firstX || m_firstY) { 516 if (m_firstX && m_firstY) { 517 result.append(m_firstX->cssText()); 518 result.append(' '); 519 result.append(m_firstY->cssText()); 520 } else if (m_firstX || m_firstY) { 502 521 if (m_firstX) 503 result += m_firstX->cssText();522 result.append(m_firstX->cssText()); 504 523 505 524 if (m_firstY) 506 result += m_firstY->cssText();525 result.append(m_firstY->cssText()); 507 526 } 508 527 } … … 510 529 for (unsigned i = 0; i < m_stops.size(); i++) { 511 530 const CSSGradientColorStop& stop = m_stops[i]; 512 result += ", "; 513 result += stop.m_color->cssText(); 514 if (stop.m_position) 515 result += " " + stop.m_position->cssText(); 516 } 517 } 518 519 result += ")"; 520 return result; 531 result.appendLiteral(", "); 532 result.append(stop.m_color->cssText()); 533 if (stop.m_position) { 534 result.append(' '); 535 result.append(stop.m_position->cssText()); 536 } 537 } 538 } 539 540 result.append(')'); 541 return result.toString(); 521 542 } 522 543 … … 623 644 String CSSRadialGradientValue::customCssText() const 624 645 { 625 String result;646 StringBuilder result; 626 647 627 648 if (m_deprecatedType) { 628 result = "-webkit-gradient(radial, "; 629 630 result += m_firstX->cssText() + " "; 631 result += m_firstY->cssText() + ", "; 632 result += m_firstRadius->cssText() + ", "; 633 result += m_secondX->cssText() + " "; 634 result += m_secondY->cssText(); 635 result += ", "; 636 result += m_secondRadius->cssText(); 649 result.appendLiteral("-webkit-gradient(radial, "); 650 result.append(m_firstX->cssText()); 651 result.append(' '); 652 result.append(m_firstY->cssText()); 653 result.appendLiteral(", "); 654 result.append(m_firstRadius->cssText()); 655 result.appendLiteral(", "); 656 result.append(m_secondX->cssText()); 657 result.append(' '); 658 result.append(m_secondY->cssText()); 659 result.appendLiteral(", "); 660 result.append(m_secondRadius->cssText()); 637 661 638 662 // FIXME: share? 639 663 for (unsigned i = 0; i < m_stops.size(); i++) { 640 664 const CSSGradientColorStop& stop = m_stops[i]; 641 result += ", "; 642 if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 0) 643 result += "from(" + stop.m_color->cssText() + ")"; 644 else if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 1) 645 result += "to(" + stop.m_color->cssText() + ")"; 665 result.appendLiteral(", "); 666 if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 0) { 667 result.appendLiteral("from("); 668 result.append(stop.m_color->cssText()); 669 result.append(')'); 670 } else if (stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER) == 1) { 671 result.appendLiteral("to("); 672 result.append(stop.m_color->cssText()); 673 result.append(')'); 674 } else { 675 result.appendLiteral("color-stop("); 676 result.append(String::number(stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER))); 677 result.appendLiteral(", "); 678 result.append(stop.m_color->cssText()); 679 result.append(')'); 680 } 681 } 682 } else { 683 if (m_repeating) 684 result.appendLiteral("-webkit-repeating-radial-gradient("); 685 else 686 result.appendLiteral("-webkit-radial-gradient("); 687 688 if (m_firstX && m_firstY) { 689 result.append(m_firstX->cssText()); 690 result.append(' '); 691 result.append(m_firstY->cssText()); 692 } else if (m_firstX) 693 result.append(m_firstX->cssText()); 694 else if (m_firstY) 695 result.append(m_firstY->cssText()); 696 else 697 result.appendLiteral("center"); 698 699 if (m_shape || m_sizingBehavior) { 700 result.appendLiteral(", "); 701 if (m_shape) { 702 result.append(m_shape->cssText()); 703 result.append(' '); 704 } else 705 result.appendLiteral("ellipse "); 706 707 if (m_sizingBehavior) 708 result.append(m_sizingBehavior->cssText()); 646 709 else 647 result += "color-stop(" + String::number(stop.m_position->getDoubleValue(CSSPrimitiveValue::CSS_NUMBER)) + ", " + stop.m_color->cssText() + ")"; 648 } 649 } else { 650 651 result = m_repeating ? "-webkit-repeating-radial-gradient(" : "-webkit-radial-gradient("; 652 if (m_firstX && m_firstY) { 653 result += m_firstX->cssText() + " " + m_firstY->cssText(); 654 } else if (m_firstX) 655 result += m_firstX->cssText(); 656 else if (m_firstY) 657 result += m_firstY->cssText(); 658 else 659 result += "center"; 660 661 662 if (m_shape || m_sizingBehavior) { 663 result += ", "; 664 if (m_shape) 665 result += m_shape->cssText() + " "; 666 else 667 result += "ellipse "; 668 669 if (m_sizingBehavior) 670 result += m_sizingBehavior->cssText(); 671 else 672 result += "cover"; 710 result.appendLiteral("cover"); 673 711 674 712 } else if (m_endHorizontalSize && m_endVerticalSize) { 675 result += ", "; 676 result += m_endHorizontalSize->cssText() + " " + m_endVerticalSize->cssText(); 713 result.appendLiteral(", "); 714 result.append(m_endHorizontalSize->cssText()); 715 result.append(' '); 716 result.append(m_endVerticalSize->cssText()); 677 717 } 678 718 679 719 for (unsigned i = 0; i < m_stops.size(); i++) { 680 720 const CSSGradientColorStop& stop = m_stops[i]; 681 result += ", "; 682 result += stop.m_color->cssText(); 683 if (stop.m_position) 684 result += " " + stop.m_position->cssText(); 685 } 686 } 687 688 result += ")"; 689 return result; 721 result.appendLiteral(", "); 722 result.append(stop.m_color->cssText()); 723 if (stop.m_position) { 724 result.append(' '); 725 result.append(stop.m_position->cssText()); 726 } 727 } 728 } 729 730 result.append(')'); 731 return result.toString(); 690 732 } 691 733
Note:
See TracChangeset
for help on using the changeset viewer.