Index: third_party/WebKit/Source/core/html/HTMLImageElement.cpp |
diff --git a/third_party/WebKit/Source/core/html/HTMLImageElement.cpp b/third_party/WebKit/Source/core/html/HTMLImageElement.cpp |
index 9a72937da00d435442915c4403fd56db049846bc..54cb6398f39bbe0b44d7e9ec637f1c15d4378e72 100644 |
--- a/third_party/WebKit/Source/core/html/HTMLImageElement.cpp |
+++ b/third_party/WebKit/Source/core/html/HTMLImageElement.cpp |
@@ -688,6 +688,28 @@ |
referrer_policy_); |
} |
+ScriptPromise HTMLImageElement::CreateImageBitmap( |
+ ScriptState* script_state, |
+ EventTarget& event_target, |
+ Optional<IntRect> crop_rect, |
+ const ImageBitmapOptions& options, |
+ ExceptionState& exception_state) { |
+ DCHECK(event_target.ToLocalDOMWindow()); |
+ if ((crop_rect && |
+ !ImageBitmap::IsSourceSizeValid(crop_rect->Width(), crop_rect->Height(), |
+ exception_state)) || |
+ !ImageBitmap::IsSourceSizeValid(BitmapSourceSize().Width(), |
+ BitmapSourceSize().Height(), |
+ exception_state)) |
+ return ScriptPromise(); |
+ if (!ImageBitmap::IsResizeOptionValid(options, exception_state)) |
+ return ScriptPromise(); |
+ return ImageBitmapSource::FulfillImageBitmap( |
+ script_state, ImageBitmap::Create( |
+ this, crop_rect, |
+ event_target.ToLocalDOMWindow()->document(), options)); |
+} |
+ |
void HTMLImageElement::SelectSourceURL( |
ImageLoader::UpdateFromElementBehavior behavior) { |
if (!GetDocument().IsActive()) |
@@ -811,6 +833,16 @@ |
} |
} |
+IntSize HTMLImageElement::BitmapSourceSize() const { |
+ ImageResourceContent* image = CachedImage(); |
+ if (!image) |
+ return IntSize(); |
+ LayoutSize l_size = image->ImageSize( |
+ LayoutObject::ShouldRespectImageOrientation(GetLayoutObject()), 1.0f); |
+ DCHECK(l_size.Fraction().IsZero()); |
+ return IntSize(l_size.Width().ToInt(), l_size.Height().ToInt()); |
+} |
+ |
void HTMLImageElement::AssociateWith(HTMLFormElement* form) { |
if (form && form->isConnected()) { |
form_ = form; |