-
Notifications
You must be signed in to change notification settings - Fork 40
Resolution for issue Fill or stroke attributes on a use element #162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
4a4bed1
3fd71c3
4fdfbaf
18ac44d
3cf6720
01c6b0a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -321,7 +321,6 @@ void SVGDocumentImpl::ParseChild(XMLNode* child) | |
| auto hrefAttr = child->GetAttribute(kHrefAttr, kXlinkNS); | ||
| if (!hrefAttr.found || !hrefAttr.value || hrefAttr.value[0] != '#') | ||
| return; | ||
|
|
||
| const float x = ParseLengthFromAttr(child, kXAttr, LengthType::kHorizontal); | ||
| const float y = ParseLengthFromAttr(child, kYAttr, LengthType::kVertical); | ||
| if (!isCloseToZero(x) || !isCloseToZero(y)) | ||
|
|
@@ -330,7 +329,6 @@ void SVGDocumentImpl::ParseChild(XMLNode* child) | |
| graphicStyle.transform = mRenderer->CreateTransform(); | ||
| graphicStyle.transform->Concat(1, 0, 0, 1, x, y); | ||
| } | ||
|
|
||
| std::string href{(hrefAttr.value + 1)}; | ||
| AddChildToCurrentGroup(std::make_shared<Reference>(graphicStyle, classNames, fillStyle, strokeStyle, std::move(href)), std::move(idString)); | ||
| } | ||
|
|
@@ -606,7 +604,6 @@ void SVGDocumentImpl::ParseFillProperties(FillStyleImpl& fillStyle, const Proper | |
| else if (result == SVGDocumentImpl::Result::kSuccess) | ||
| fillStyle.hasFill = true; | ||
| } | ||
|
|
||
| prop = propertySet.find(kFillOpacityProp); | ||
| if (prop != iterEnd) | ||
| { | ||
|
|
@@ -820,7 +817,6 @@ float SVGDocumentImpl::ParseColorStop(const XMLNode* node, std::vector<ColorStop | |
| // Value is "currentColor". Simply set value to CSS color property. | ||
| paint = fillStyle.color; | ||
| } | ||
|
|
||
| graphicStyle.stopOpacity = std::max<float>(0.0, std::min<float>(1.0, graphicStyle.stopOpacity)); | ||
|
|
||
| colorStops.push_back(std::make_tuple(offset, paint, graphicStyle.stopOpacity)); | ||
|
|
@@ -1063,13 +1059,18 @@ void SVGDocumentImpl::TraverseTree(const ColorMap& colorMap, const Element& elem | |
| if (it != mVisitedElements.end()) | ||
| break; // We found a cycle. Do not continue rendering. | ||
| auto insertResult = mVisitedElements.insert(&reference); | ||
|
|
||
| // Render referenced content. | ||
| auto refIt = mIdToElementMap.find(reference.href); | ||
| if (refIt != mIdToElementMap.end()) | ||
| { | ||
| ApplyCSSStyle(reference.classNames, graphicStyle, fillStyle, strokeStyle); | ||
| auto saveRestore = SaveRestoreHelper{mRenderer, reference.graphicStyle}; | ||
| if ((*(refIt->second)).Type() == ElementType::kGraphic) | ||
| { | ||
| Graphic& graphic = static_cast<Graphic&>(*(refIt->second)); | ||
| // it will call assignment operator and pass fillStyle from reference to graphic | ||
| graphic = reference; | ||
| } | ||
| TraverseTree(colorMap, *(refIt->second)); | ||
| } | ||
|
|
||
|
|
@@ -1115,7 +1116,7 @@ void SVGDocumentImpl::TraverseTree(const ColorMap& colorMap, const Element& elem | |
| } | ||
| } | ||
|
|
||
| #ifndef STYLE_SUPPORT | ||
| #ifndef STYLE_SUPPORTn | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this a typo?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes its typo! and i have fixed in latest one @dirkschulze |
||
| // Deprecated style support | ||
| void SVGDocumentImpl::ApplyCSSStyle( | ||
| const std::set<std::string>&, GraphicStyleImpl&, FillStyleImpl&, StrokeStyleImpl&) {} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -133,40 +133,46 @@ class SVGDocumentImpl | |
| ElementType Type() const override { return ElementType::kGroup; } | ||
| }; | ||
|
|
||
| struct Graphic : public Element | ||
| struct Reference : public Element | ||
|
dirkschulze marked this conversation as resolved.
|
||
| { | ||
| Graphic(GraphicStyleImpl& aGraphicStyle, std::set<std::string>& aClasses, FillStyleImpl& aFillStyle, StrokeStyleImpl& aStrokeStyle, | ||
| std::shared_ptr<Path> aPath) | ||
| Reference(GraphicStyleImpl& aGraphicStyle, std::set<std::string>& aClasses, FillStyleImpl& aFillStyle, StrokeStyleImpl& aStrokeStyle, | ||
| std::string aHref) | ||
| : Element(aGraphicStyle, aClasses) | ||
| , fillStyle{aFillStyle} | ||
| , strokeStyle{aStrokeStyle} | ||
| , path{std::move(aPath)} | ||
| , href{std::move(aHref)} | ||
| { | ||
| } | ||
|
|
||
| FillStyleImpl fillStyle; | ||
| StrokeStyleImpl strokeStyle; | ||
| std::shared_ptr<Path> path; | ||
| std::string href; | ||
|
|
||
| ElementType Type() const override { return ElementType::kGraphic; } | ||
| ElementType Type() const override { return ElementType::kReference; } | ||
| }; | ||
|
|
||
| struct Reference : public Element | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no trailing whitespaces. |
||
| struct Graphic : public Element | ||
| { | ||
| Reference(GraphicStyleImpl& aGraphicStyle, std::set<std::string>& aClasses, FillStyleImpl& aFillStyle, StrokeStyleImpl& aStrokeStyle, | ||
| std::string aHref) | ||
| Graphic(GraphicStyleImpl& aGraphicStyle, std::set<std::string>& aClasses, FillStyleImpl& aFillStyle, StrokeStyleImpl& aStrokeStyle, | ||
| std::shared_ptr<Path> aPath) | ||
| : Element(aGraphicStyle, aClasses) | ||
| , fillStyle{aFillStyle} | ||
| , strokeStyle{aStrokeStyle} | ||
| , href{std::move(aHref)} | ||
| , path{std::move(aPath)} | ||
| { | ||
| } | ||
|
|
||
| FillStyleImpl fillStyle; | ||
| StrokeStyleImpl strokeStyle; | ||
| std::string href; | ||
| std::shared_ptr<Path> path; | ||
|
|
||
| ElementType Type() const override { return ElementType::kReference; } | ||
| ElementType Type() const override { return ElementType::kGraphic; } | ||
| Graphic& operator= (const Reference& refObj) | ||
| { | ||
| this->fillStyle = refObj.fillStyle; //internal Paint is transferred | ||
| this->strokeStyle = refObj.strokeStyle; | ||
| return *this; | ||
| } | ||
| }; | ||
|
|
||
| SVGDocumentImpl(std::shared_ptr<SVGRenderer> renderer); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fell that those newlines are useful for readability. Can we keep them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, i have kept those newlines in latest one. Mistakenly removed last time. @dirkschulze