Chromium Code Reviews| Index: third_party/WebKit/Source/core/svg/SVGImageElement.cpp |
| diff --git a/third_party/WebKit/Source/core/svg/SVGImageElement.cpp b/third_party/WebKit/Source/core/svg/SVGImageElement.cpp |
| index 41784f57f801f07cb0544398f7c727e2fec8eaab..c8f1c7a37c7e2dd5d3b264f87cb2c38a1d89254c 100644 |
| --- a/third_party/WebKit/Source/core/svg/SVGImageElement.cpp |
| +++ b/third_party/WebKit/Source/core/svg/SVGImageElement.cpp |
| @@ -23,6 +23,8 @@ |
| #include "core/CSSPropertyNames.h" |
| #include "core/dom/StyleChangeReason.h" |
| +#include "core/frame/ImageBitmap.h" |
| +#include "core/frame/LocalDOMWindow.h" |
| #include "core/layout/LayoutImageResource.h" |
| #include "core/layout/svg/LayoutSVGImage.h" |
| @@ -147,6 +149,38 @@ void SVGImageElement::svgAttributeChanged(const QualifiedName& attrName) { |
| SVGGraphicsElement::svgAttributeChanged(attrName); |
| } |
| +IntSize SVGImageElement::bitmapSourceSize() const { |
| + ImageResourceContent* image = cachedImage(); |
| + if (!image) |
| + return IntSize(); |
| + LayoutSize lSize = image->imageSize( |
| + LayoutObject::shouldRespectImageOrientation(layoutObject()), 1.0f); |
| + DCHECK(lSize.fraction().isZero()); |
| + return IntSize(lSize.width().toInt(), lSize.height().toInt()); |
| +} |
| + |
| +ScriptPromise SVGImageElement::createImageBitmap( |
| + ScriptState* scriptState, |
| + EventTarget& eventTarget, |
| + Optional<IntRect> cropRect, |
| + const ImageBitmapOptions& options, |
| + ExceptionState& exceptionState) { |
| + DCHECK(eventTarget.toLocalDOMWindow()); |
| + if ((cropRect && |
| + !ImageBitmap::isSourceSizeValid(cropRect->width(), cropRect->height(), |
| + exceptionState)) || |
| + !ImageBitmap::isSourceSizeValid(bitmapSourceSize().width(), |
| + bitmapSourceSize().height(), |
| + exceptionState)) |
| + return ScriptPromise(); |
| + if (!ImageBitmap::isResizeOptionValid(options, exceptionState)) |
| + return ScriptPromise(); |
| + return ImageBitmapSource::fulfillImageBitmap( |
| + scriptState, |
| + ImageBitmap::create(this, cropRect, |
| + eventTarget.toLocalDOMWindow()->document(), options)); |
|
fs
2017/04/06 16:48:12
I was a bit puzzled by this until I saw what it wa
fserb
2017/04/06 20:06:16
For the first thing, you are right.
For the second
|
| +} |
| + |
| bool SVGImageElement::selfHasRelativeLengths() const { |
| return m_x->currentValue()->isRelative() || |
| m_y->currentValue()->isRelative() || |