Skip to content


Browse files Browse the repository at this point in the history
Sync 'naturalWidth' and 'naturalHeight' with Spec and change from 'in…
…t' to 'unsigned'

Reviewed by Ryosuke Niwa.

This patch aligns WebKit with Web-Spec [1] by changing 'naturalWidth'
and 'naturalHeight' from 'int' to 'unsigned'.


* Source/WebCore/html/HTMLImageElement.cpp:
(HTMLImageElement::naturalWidth): Change to 'unsigned' and return to have 'toUnsigned'
(HTMLImageElement::naturalHeight): Ditto
* Source/WebCore/html/HTMLImageElement.h: Update definition to 'unsigned' from 'int' for 'naturalWidth' and 'naturalHeight'
* Source/WebCore/html/HTMLImageElement.idl: Update 'naturalWidth' and 'naturalHeight' to have 'unsigned'

Canonical link:
  • Loading branch information
Ahmad-S792 authored and Ahmad Saleem committed Jul 25, 2023
1 parent 264836a commit e7d267d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions Source/WebCore/html/HTMLImageElement.cpp
Expand Up @@ -596,20 +596,20 @@ float HTMLImageElement::effectiveImageDevicePixelRatio() const
return m_imageDevicePixelRatio;

int HTMLImageElement::naturalWidth() const
unsigned HTMLImageElement::naturalWidth() const
if (!m_imageLoader->image())
return 0;

return m_imageLoader->image()->unclampedImageSizeForRenderer(renderer(), effectiveImageDevicePixelRatio()).width();
return m_imageLoader->image()->unclampedImageSizeForRenderer(renderer(), effectiveImageDevicePixelRatio()).width().toUnsigned();

int HTMLImageElement::naturalHeight() const
unsigned HTMLImageElement::naturalHeight() const
if (!m_imageLoader->image())
return 0;

return m_imageLoader->image()->unclampedImageSizeForRenderer(renderer(), effectiveImageDevicePixelRatio()).height();
return m_imageLoader->image()->unclampedImageSizeForRenderer(renderer(), effectiveImageDevicePixelRatio()).height().toUnsigned();

bool HTMLImageElement::isURLAttribute(const Attribute& attribute) const
Expand Down
4 changes: 2 additions & 2 deletions Source/WebCore/html/HTMLImageElement.h
Expand Up @@ -64,8 +64,8 @@ class HTMLImageElement : public HTMLElement, public FormAssociatedElement, publi
WEBCORE_EXPORT unsigned width();
WEBCORE_EXPORT unsigned height();

WEBCORE_EXPORT int naturalWidth() const;
WEBCORE_EXPORT int naturalHeight() const;
WEBCORE_EXPORT unsigned naturalWidth() const;
WEBCORE_EXPORT unsigned naturalHeight() const;
const URL& currentURL() const { return m_currentURL; }
const AtomString& currentSrc() const { return m_currentSrc; }

Expand Down
4 changes: 2 additions & 2 deletions Source/WebCore/html/HTMLImageElement.idl
Expand Up @@ -36,8 +36,8 @@
[CEReactions=NotNeeded, Reflect] attribute boolean isMap;
[CEReactions=NotNeeded] attribute unsigned long width;
[CEReactions=NotNeeded] attribute unsigned long height;
readonly attribute long naturalHeight;
readonly attribute long naturalWidth;
readonly attribute unsigned long naturalHeight;
readonly attribute unsigned long naturalWidth;
readonly attribute boolean complete;
readonly attribute USVString currentSrc;
[CEReactions=NotNeeded, EnabledBySetting=ReferrerPolicyAttributeEnabled, ImplementedAs=referrerPolicyForBindings] attribute [AtomString] DOMString referrerPolicy;
Expand Down

0 comments on commit e7d267d

Please sign in to comment.