OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2007, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2007, 2009 Apple Inc. All rights reserved. |
3 * (C) 2005 Rob Buis <buis@kde.org> | 3 * (C) 2005 Rob Buis <buis@kde.org> |
4 * (C) 2006 Alexander Kellett <lypanov@kde.org> | 4 * (C) 2006 Alexander Kellett <lypanov@kde.org> |
5 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 5 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
6 * | 6 * |
7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
9 * are met: | 9 * are met: |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 #include "core/svg/graphics/filters/SVGFilterBuilder.h" | 64 #include "core/svg/graphics/filters/SVGFilterBuilder.h" |
65 #include "platform/graphics/DashArray.h" | 65 #include "platform/graphics/DashArray.h" |
66 #include "platform/graphics/GraphicsTypes.h" | 66 #include "platform/graphics/GraphicsTypes.h" |
67 #include "platform/graphics/filters/SourceGraphic.h" | 67 #include "platform/graphics/filters/SourceGraphic.h" |
68 | 68 |
69 #include <math.h> | 69 #include <math.h> |
70 #include <memory> | 70 #include <memory> |
71 | 71 |
72 namespace blink { | 72 namespace blink { |
73 | 73 |
74 /** class + iomanip to help streaming list separators, i.e. ", " in string "a, b
, c, d" | 74 /** class + iomanip to help streaming list separators, i.e. ", " in string "a, |
| 75 * b, c, d" |
75 * Can be used in cases where you don't know which item in the list is the first | 76 * Can be used in cases where you don't know which item in the list is the first |
76 * one to be printed, but still want to avoid strings like ", b, c". | 77 * one to be printed, but still want to avoid strings like ", b, c". |
77 */ | 78 */ |
78 class TextStreamSeparator { | 79 class TextStreamSeparator { |
79 public: | 80 public: |
80 TextStreamSeparator(const String& s) | 81 TextStreamSeparator(const String& s) |
81 : m_separator(s), m_needToSeparate(false) {} | 82 : m_separator(s), m_needToSeparate(false) {} |
82 | 83 |
83 private: | 84 private: |
84 friend TextStream& operator<<(TextStream&, TextStreamSeparator&); | 85 friend TextStream& operator<<(TextStream&, TextStreamSeparator&); |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 | 398 |
398 static void writeLayoutSVGTextBox(TextStream& ts, const LayoutSVGText& text) { | 399 static void writeLayoutSVGTextBox(TextStream& ts, const LayoutSVGText& text) { |
399 SVGRootInlineBox* box = toSVGRootInlineBox(text.firstRootBox()); | 400 SVGRootInlineBox* box = toSVGRootInlineBox(text.firstRootBox()); |
400 if (!box) | 401 if (!box) |
401 return; | 402 return; |
402 | 403 |
403 ts << " " << enclosingIntRect(LayoutRect( | 404 ts << " " << enclosingIntRect(LayoutRect( |
404 LayoutPoint(text.location()), | 405 LayoutPoint(text.location()), |
405 LayoutSize(box->logicalWidth(), box->logicalHeight()))); | 406 LayoutSize(box->logicalWidth(), box->logicalHeight()))); |
406 | 407 |
407 // FIXME: Remove this hack, once the new text layout engine is completly lande
d. We want to preserve the old layout test results for now. | 408 // FIXME: Remove this hack, once the new text layout engine is completly |
| 409 // landed. We want to preserve the old layout test results for now. |
408 ts << " contains 1 chunk(s)"; | 410 ts << " contains 1 chunk(s)"; |
409 | 411 |
410 if (text.parent() && (text.parent()->resolveColor(CSSPropertyColor) != | 412 if (text.parent() && (text.parent()->resolveColor(CSSPropertyColor) != |
411 text.resolveColor(CSSPropertyColor))) | 413 text.resolveColor(CSSPropertyColor))) |
412 writeNameValuePair( | 414 writeNameValuePair( |
413 ts, "color", | 415 ts, "color", |
414 text.resolveColor(CSSPropertyColor).nameForLayoutTreeAsText()); | 416 text.resolveColor(CSSPropertyColor).nameForLayoutTreeAsText()); |
415 } | 417 } |
416 | 418 |
417 static inline void writeSVGInlineTextBox(TextStream& ts, | 419 static inline void writeSVGInlineTextBox(TextStream& ts, |
(...skipping 10 matching lines...) Expand all Loading... |
428 String text = textBox->getLineLayoutItem().text(); | 430 String text = textBox->getLineLayoutItem().text(); |
429 | 431 |
430 unsigned fragmentsSize = fragments.size(); | 432 unsigned fragmentsSize = fragments.size(); |
431 for (unsigned i = 0; i < fragmentsSize; ++i) { | 433 for (unsigned i = 0; i < fragmentsSize; ++i) { |
432 SVGTextFragment& fragment = fragments.at(i); | 434 SVGTextFragment& fragment = fragments.at(i); |
433 writeIndent(ts, indent + 1); | 435 writeIndent(ts, indent + 1); |
434 | 436 |
435 unsigned startOffset = fragment.characterOffset; | 437 unsigned startOffset = fragment.characterOffset; |
436 unsigned endOffset = fragment.characterOffset + fragment.length; | 438 unsigned endOffset = fragment.characterOffset + fragment.length; |
437 | 439 |
438 // FIXME: Remove this hack, once the new text layout engine is completly lan
ded. We want to preserve the old layout test results for now. | 440 // FIXME: Remove this hack, once the new text layout engine is completly |
| 441 // landed. We want to preserve the old layout test results for now. |
439 ts << "chunk 1 "; | 442 ts << "chunk 1 "; |
440 ETextAnchor anchor = svgStyle.textAnchor(); | 443 ETextAnchor anchor = svgStyle.textAnchor(); |
441 bool isVerticalText = !textLineLayout.style()->isHorizontalWritingMode(); | 444 bool isVerticalText = !textLineLayout.style()->isHorizontalWritingMode(); |
442 if (anchor == TA_MIDDLE) { | 445 if (anchor == TA_MIDDLE) { |
443 ts << "(middle anchor"; | 446 ts << "(middle anchor"; |
444 if (isVerticalText) | 447 if (isVerticalText) |
445 ts << ", vertical"; | 448 ts << ", vertical"; |
446 ts << ") "; | 449 ts << ") "; |
447 } else if (anchor == TA_END) { | 450 } else if (anchor == TA_END) { |
448 ts << "(end anchor"; | 451 ts << "(end anchor"; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 ts << " [ref at " << marker->referencePoint() << "]"; | 565 ts << " [ref at " << marker->referencePoint() << "]"; |
563 ts << " [angle="; | 566 ts << " [angle="; |
564 if (marker->orientType() != SVGMarkerOrientAngle) | 567 if (marker->orientType() != SVGMarkerOrientAngle) |
565 ts << marker->orientType() << "]\n"; | 568 ts << marker->orientType() << "]\n"; |
566 else | 569 else |
567 ts << marker->angle() << "]\n"; | 570 ts << marker->angle() << "]\n"; |
568 } else if (resource->resourceType() == PatternResourceType) { | 571 } else if (resource->resourceType() == PatternResourceType) { |
569 LayoutSVGResourcePattern* pattern = | 572 LayoutSVGResourcePattern* pattern = |
570 static_cast<LayoutSVGResourcePattern*>(resource); | 573 static_cast<LayoutSVGResourcePattern*>(resource); |
571 | 574 |
572 // Dump final results that are used for layout. No use in asking SVGPatternE
lement for its patternUnits(), as it may | 575 // Dump final results that are used for layout. No use in asking |
573 // link to other patterns using xlink:href, we need to build the full inheri
tance chain, aka. collectPatternProperties() | 576 // SVGPatternElement for its patternUnits(), as it may link to other |
| 577 // patterns using xlink:href, we need to build the full inheritance chain, |
| 578 // aka. collectPatternProperties() |
574 PatternAttributes attributes; | 579 PatternAttributes attributes; |
575 toSVGPatternElement(pattern->element()) | 580 toSVGPatternElement(pattern->element()) |
576 ->collectPatternAttributes(attributes); | 581 ->collectPatternAttributes(attributes); |
577 | 582 |
578 writeNameValuePair(ts, "patternUnits", attributes.patternUnits()); | 583 writeNameValuePair(ts, "patternUnits", attributes.patternUnits()); |
579 writeNameValuePair(ts, "patternContentUnits", | 584 writeNameValuePair(ts, "patternContentUnits", |
580 attributes.patternContentUnits()); | 585 attributes.patternContentUnits()); |
581 | 586 |
582 AffineTransform transform = attributes.patternTransform(); | 587 AffineTransform transform = attributes.patternTransform(); |
583 if (!transform.isIdentity()) | 588 if (!transform.isIdentity()) |
584 ts << " [patternTransform=" << transform << "]"; | 589 ts << " [patternTransform=" << transform << "]"; |
585 ts << "\n"; | 590 ts << "\n"; |
586 } else if (resource->resourceType() == LinearGradientResourceType) { | 591 } else if (resource->resourceType() == LinearGradientResourceType) { |
587 LayoutSVGResourceLinearGradient* gradient = | 592 LayoutSVGResourceLinearGradient* gradient = |
588 static_cast<LayoutSVGResourceLinearGradient*>(resource); | 593 static_cast<LayoutSVGResourceLinearGradient*>(resource); |
589 | 594 |
590 // Dump final results that are used for layout. No use in asking SVGGradient
Element for its gradientUnits(), as it may | 595 // Dump final results that are used for layout. No use in asking |
591 // link to other gradients using xlink:href, we need to build the full inher
itance chain, aka. collectGradientProperties() | 596 // SVGGradientElement for its gradientUnits(), as it may link to other |
| 597 // gradients using xlink:href, we need to build the full inheritance chain, |
| 598 // aka. collectGradientProperties() |
592 LinearGradientAttributes attributes; | 599 LinearGradientAttributes attributes; |
593 toSVGLinearGradientElement(gradient->element()) | 600 toSVGLinearGradientElement(gradient->element()) |
594 ->collectGradientAttributes(attributes); | 601 ->collectGradientAttributes(attributes); |
595 writeCommonGradientProperties(ts, attributes.spreadMethod(), | 602 writeCommonGradientProperties(ts, attributes.spreadMethod(), |
596 attributes.gradientTransform(), | 603 attributes.gradientTransform(), |
597 attributes.gradientUnits()); | 604 attributes.gradientUnits()); |
598 | 605 |
599 ts << " [start=" << gradient->startPoint(attributes) | 606 ts << " [start=" << gradient->startPoint(attributes) |
600 << "] [end=" << gradient->endPoint(attributes) << "]\n"; | 607 << "] [end=" << gradient->endPoint(attributes) << "]\n"; |
601 } else if (resource->resourceType() == RadialGradientResourceType) { | 608 } else if (resource->resourceType() == RadialGradientResourceType) { |
602 LayoutSVGResourceRadialGradient* gradient = | 609 LayoutSVGResourceRadialGradient* gradient = |
603 toLayoutSVGResourceRadialGradient(resource); | 610 toLayoutSVGResourceRadialGradient(resource); |
604 | 611 |
605 // Dump final results that are used for layout. No use in asking SVGGradient
Element for its gradientUnits(), as it may | 612 // Dump final results that are used for layout. No use in asking |
606 // link to other gradients using xlink:href, we need to build the full inher
itance chain, aka. collectGradientProperties() | 613 // SVGGradientElement for its gradientUnits(), as it may link to other |
| 614 // gradients using xlink:href, we need to build the full inheritance chain, |
| 615 // aka. collectGradientProperties() |
607 RadialGradientAttributes attributes; | 616 RadialGradientAttributes attributes; |
608 toSVGRadialGradientElement(gradient->element()) | 617 toSVGRadialGradientElement(gradient->element()) |
609 ->collectGradientAttributes(attributes); | 618 ->collectGradientAttributes(attributes); |
610 writeCommonGradientProperties(ts, attributes.spreadMethod(), | 619 writeCommonGradientProperties(ts, attributes.spreadMethod(), |
611 attributes.gradientTransform(), | 620 attributes.gradientTransform(), |
612 attributes.gradientUnits()); | 621 attributes.gradientUnits()); |
613 | 622 |
614 FloatPoint focalPoint = gradient->focalPoint(attributes); | 623 FloatPoint focalPoint = gradient->focalPoint(attributes); |
615 FloatPoint centerPoint = gradient->centerPoint(attributes); | 624 FloatPoint centerPoint = gradient->centerPoint(attributes); |
616 float radius = gradient->radius(attributes); | 625 float radius = gradient->radius(attributes); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 ASSERT(stop.style()); | 694 ASSERT(stop.style()); |
686 | 695 |
687 ts << " [offset=" << stopElement->offset()->currentValue()->value() | 696 ts << " [offset=" << stopElement->offset()->currentValue()->value() |
688 << "] [color=" << stopElement->stopColorIncludingOpacity() << "]\n"; | 697 << "] [color=" << stopElement->stopColorIncludingOpacity() << "]\n"; |
689 } | 698 } |
690 | 699 |
691 void writeResources(TextStream& ts, const LayoutObject& object, int indent) { | 700 void writeResources(TextStream& ts, const LayoutObject& object, int indent) { |
692 const ComputedStyle& style = object.styleRef(); | 701 const ComputedStyle& style = object.styleRef(); |
693 const SVGComputedStyle& svgStyle = style.svgStyle(); | 702 const SVGComputedStyle& svgStyle = style.svgStyle(); |
694 | 703 |
695 // FIXME: We want to use SVGResourcesCache to determine which resources are pr
esent, instead of quering the resource <-> id cache. | 704 // FIXME: We want to use SVGResourcesCache to determine which resources are |
696 // For now leave the DRT output as is, but later on we should change this so c
ycles are properly ignored in the DRT output. | 705 // present, instead of quering the resource <-> id cache. |
| 706 // For now leave the DRT output as is, but later on we should change this so |
| 707 // cycles are properly ignored in the DRT output. |
697 if (!svgStyle.maskerResource().isEmpty()) { | 708 if (!svgStyle.maskerResource().isEmpty()) { |
698 if (LayoutSVGResourceMasker* masker = | 709 if (LayoutSVGResourceMasker* masker = |
699 getLayoutSVGResourceById<LayoutSVGResourceMasker>( | 710 getLayoutSVGResourceById<LayoutSVGResourceMasker>( |
700 object.document(), svgStyle.maskerResource())) { | 711 object.document(), svgStyle.maskerResource())) { |
701 writeIndent(ts, indent); | 712 writeIndent(ts, indent); |
702 ts << " "; | 713 ts << " "; |
703 writeNameAndQuotedValue(ts, "masker", svgStyle.maskerResource()); | 714 writeNameAndQuotedValue(ts, "masker", svgStyle.maskerResource()); |
704 ts << " "; | 715 ts << " "; |
705 writeStandardPrefix(ts, *masker, 0); | 716 writeStandardPrefix(ts, *masker, 0); |
706 ts << " " << masker->resourceBoundingBox(&object) << "\n"; | 717 ts << " " << masker->resourceBoundingBox(&object) << "\n"; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 ts << " "; | 754 ts << " "; |
744 writeStandardPrefix(ts, *filter, 0); | 755 writeStandardPrefix(ts, *filter, 0); |
745 ts << " " << filter->resourceBoundingBox(&object) << "\n"; | 756 ts << " " << filter->resourceBoundingBox(&object) << "\n"; |
746 } | 757 } |
747 } | 758 } |
748 } | 759 } |
749 } | 760 } |
750 } | 761 } |
751 | 762 |
752 } // namespace blink | 763 } // namespace blink |
OLD | NEW |