-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
m92-f46c37ba85-2 Removed SkSVGDOM patch, added SkSVGDOM.getRoot API h…
- Loading branch information
Showing
2 changed files
with
38 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ on: | |
default: 'false' | ||
|
||
env: | ||
version: m92-f46c37ba85 | ||
version: m92-f46c37ba85-2 | ||
|
||
jobs: | ||
macos: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,39 @@ | ||
diff --git a/modules/svg/src/SkSVGDOM.cpp b/modules/svg/src/SkSVGDOM.cpp | ||
index 7915654963..509c52548d 100644 | ||
--- a/modules/svg/src/SkSVGDOM.cpp | ||
+++ b/modules/svg/src/SkSVGDOM.cpp | ||
@@ -426,6 +426,15 @@ SkSVGDOM::SkSVGDOM(sk_sp<SkSVGSVG> root, sk_sp<SkFontMgr> fmgr, | ||
, fContainerSize(fRoot->intrinsicSize(SkSVGLengthContext(SkSize::Make(0, 0)))) | ||
{ | ||
SkASSERT(fResourceProvider); | ||
+ if (!fRoot->getViewBox().isValid() | ||
+ && fRoot->getWidth().unit() != SkSVGLength::Unit::kPercentage | ||
+ && fRoot->getHeight().unit() != SkSVGLength::Unit::kPercentage) | ||
+ { | ||
+ SkSVGLengthContext lctx(SkSize::Make(0, 0)); | ||
+ SkScalar width = lctx.resolve(fRoot->getWidth(), SkSVGLengthContext::LengthType::kHorizontal); | ||
+ SkScalar height = lctx.resolve(fRoot->getHeight(), SkSVGLengthContext::LengthType::kVertical); | ||
+ fRoot->setViewBox(SkRect::MakeWH(width, height)); | ||
+ } | ||
} | ||
diff --git a/modules/svg/include/SkSVGDOM.h b/modules/svg/include/SkSVGDOM.h | ||
index c9e0b312dc..a9cc540e43 100644 | ||
--- a/modules/svg/include/SkSVGDOM.h | ||
+++ b/modules/svg/include/SkSVGDOM.h | ||
@@ -46,8 +46,33 @@ public: | ||
return Builder().make(str); | ||
} | ||
|
||
void SkSVGDOM::render(SkCanvas* canvas) const { | ||
@@ -444,6 +453,10 @@ const SkSize& SkSVGDOM::containerSize() const { | ||
void SkSVGDOM::setContainerSize(const SkSize& containerSize) { | ||
// TODO: inval | ||
fContainerSize = containerSize; | ||
+ if (fRoot) { | ||
+ fRoot->setWidth(SkSVGLength(containerSize.fWidth)); | ||
+ fRoot->setHeight(SkSVGLength(containerSize.fHeight)); | ||
+ } | ||
} | ||
- const SkSize& containerSize() const; | ||
+ /** | ||
+ * Returns the root (outermost) SVG element. | ||
+ */ | ||
+ SkSVGSVG* getRoot() const { return fRoot.get(); } | ||
+ /** | ||
+ * Specify a "container size" for the SVG dom. | ||
+ * | ||
+ * This is used to resolve the initial viewport when the root SVG width/height are specified | ||
+ * in relative units. | ||
+ * | ||
+ * If the root dimensions are in absolute units, then the container size has no effect since | ||
+ * the initial viewport is fixed. | ||
+ */ | ||
void setContainerSize(const SkSize&); | ||
+ /** | ||
+ * DEPRECATED: use getRoot()->intrinsicSize() to query the root element intrinsic size. | ||
+ * | ||
+ * Returns the SVG dom container size. | ||
+ * | ||
+ * If the client specified a container size via setContainerSize(), then the same size is | ||
+ * returned. | ||
+ * | ||
+ * When unspecified by clients, this returns the intrinsic size of the root element, as defined | ||
+ * by its width/height attributes. If either width or height is specified in relative units | ||
+ * (e.g. "100%"), then the corresponding intrinsic size dimension is zero. | ||
+ */ | ||
+ const SkSize& containerSize() const; | ||
|
||
sk_sp<SkSVGNode>* SkSVGDOM::findNodeById(const char* id) { | ||
// Returns the node with the given id, or nullptr if not found. | ||
sk_sp<SkSVGNode>* findNodeById(const char* id); |