Skip to content

Commit

Permalink
Merge pull request #1165 from openkraken/fix/object-fit
Browse files Browse the repository at this point in the history
fix: object-fit not work due to image resize optimization
  • Loading branch information
answershuto committed Feb 23, 2022
2 parents 3bffedd + 0349988 commit 161edcf
Show file tree
Hide file tree
Showing 32 changed files with 715 additions and 46 deletions.
13 changes: 13 additions & 0 deletions bridge/bindings/qjs/dom/elements/image_element.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,19 @@ IMPL_PROPERTY_SETTER(ImageElement, loading)(JSContext* ctx, JSValue this_val, in
element->m_context->uiCommandBuffer()->addCommand(element->m_eventTargetId, UICommand::setProperty, *args_01, *args_02, nullptr);
return JS_NULL;
}
IMPL_PROPERTY_GETTER(ImageElement, scaling)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) {
getDartMethod()->flushUICommand();
auto* element = static_cast<ImageElementInstance*>(JS_GetOpaque(this_val, Element::classId()));
return element->getNativeProperty("scaling");
}
IMPL_PROPERTY_SETTER(ImageElement, scaling)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) {
auto* element = static_cast<ImageElementInstance*>(JS_GetOpaque(this_val, Element::classId()));
std::string key = "scaling";
std::unique_ptr<NativeString> args_01 = stringToNativeString(key);
std::unique_ptr<NativeString> args_02 = jsValueToNativeString(ctx, argv[0]);
element->m_context->uiCommandBuffer()->addCommand(element->m_eventTargetId, UICommand::setProperty, *args_01, *args_02, nullptr);
return JS_NULL;
}

ImageElementInstance::ImageElementInstance(ImageElement* element) : ElementInstance(element, "img", true) {
// Protect image instance util load or error event triggered.
Expand Down
1 change: 1 addition & 0 deletions bridge/bindings/qjs/dom/elements/image_element.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class ImageElement : public Element {
DEFINE_PROTOTYPE_PROPERTY(height);
DEFINE_PROTOTYPE_PROPERTY(src);
DEFINE_PROTOTYPE_PROPERTY(loading);
DEFINE_PROTOTYPE_PROPERTY(scaling);
friend ImageElementInstance;
};

Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 161edcf

Please sign in to comment.