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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLImageElement.cpp

Issue 2035113002: Implement ImageBitmapOptions resize (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: spec is clear, patch is now ready Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserv ed. 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserv ed.
5 * Copyright (C) 2010 Google Inc. All rights reserved. 5 * Copyright (C) 2010 Google Inc. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 imageLoader().updateFromElement(ImageLoader::UpdateForcedReload, m_referrerP olicy); 687 imageLoader().updateFromElement(ImageLoader::UpdateForcedReload, m_referrerP olicy);
688 } 688 }
689 689
690 ScriptPromise HTMLImageElement::createImageBitmap(ScriptState* scriptState, Even tTarget& eventTarget, int sx, int sy, int sw, int sh, const ImageBitmapOptions& options, ExceptionState& exceptionState) 690 ScriptPromise HTMLImageElement::createImageBitmap(ScriptState* scriptState, Even tTarget& eventTarget, int sx, int sy, int sw, int sh, const ImageBitmapOptions& options, ExceptionState& exceptionState)
691 { 691 {
692 ASSERT(eventTarget.toLocalDOMWindow()); 692 ASSERT(eventTarget.toLocalDOMWindow());
693 if (!sw || !sh) { 693 if (!sw || !sh) {
694 exceptionState.throwDOMException(IndexSizeError, String::format("The sou rce %s provided is 0.", sw ? "height" : "width")); 694 exceptionState.throwDOMException(IndexSizeError, String::format("The sou rce %s provided is 0.", sw ? "height" : "width"));
695 return ScriptPromise(); 695 return ScriptPromise();
696 } 696 }
697 if ((options.hasResizeWidth() && options.resizeWidth() <= 0) || (options.has ResizeHeight() && options.resizeHeight() <= 0)) {
698 exceptionState.throwDOMException(InvalidStateError, "The resizeWidth or/ and resizeHeight is less than or equals to 0.");
699 return ScriptPromise();
700 }
697 return ImageBitmapSource::fulfillImageBitmap(scriptState, ImageBitmap::creat e(this, IntRect(sx, sy, sw, sh), eventTarget.toLocalDOMWindow()->document(), opt ions)); 701 return ImageBitmapSource::fulfillImageBitmap(scriptState, ImageBitmap::creat e(this, IntRect(sx, sy, sw, sh), eventTarget.toLocalDOMWindow()->document(), opt ions));
698 } 702 }
699 703
700 void HTMLImageElement::selectSourceURL(ImageLoader::UpdateFromElementBehavior be havior) 704 void HTMLImageElement::selectSourceURL(ImageLoader::UpdateFromElementBehavior be havior)
701 { 705 {
702 if (!document().isActive()) 706 if (!document().isActive())
703 return; 707 return;
704 708
705 bool foundURL = false; 709 bool foundURL = false;
706 ImageCandidate candidate = findBestFitImageFromPictureParent(); 710 ImageCandidate candidate = findBestFitImageFromPictureParent();
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 { 830 {
827 ImageResource* image = cachedImage(); 831 ImageResource* image = cachedImage();
828 if (!image) 832 if (!image)
829 return IntSize(); 833 return IntSize();
830 LayoutSize lSize = image->imageSize(LayoutObject::shouldRespectImageOrientat ion(layoutObject()), 1.0f); 834 LayoutSize lSize = image->imageSize(LayoutObject::shouldRespectImageOrientat ion(layoutObject()), 1.0f);
831 ASSERT(lSize.fraction().isZero()); 835 ASSERT(lSize.fraction().isZero());
832 return IntSize(lSize.width(), lSize.height()); 836 return IntSize(lSize.width(), lSize.height());
833 } 837 }
834 838
835 } // namespace blink 839 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698