Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(779)

Unified Diff: third_party/WebKit/Source/core/html/HTMLImageElement.cpp

Issue 2817093002: Revert of Adds SVGImageElement as a ImageBitmapSource (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;

Powered by Google App Engine
This is Rietveld 408576698