Bug 1251088. Update the stored mImageWidth/Height on ImageDocuments when we get the document load event. r=bz
authorTimothy Nikkel <tnikkel@gmail.com>
Wed, 13 Apr 2016 00:42:15 -0500
changeset 292940 b15d2346d864cee95cf6bb56e3eaf58b1f595135
parent 292939 aa8227ba76e0477af7a9f42f9351ed65ef36ea3b
child 292941 9e62762fcc4aa6db5a13b86018d22da3bfc70256
push id75036
push usertnikkel@gmail.com
push dateWed, 13 Apr 2016 05:42:24 +0000
treeherdermozilla-inbound@b15d2346d864 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1251088
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1251088. Update the stored mImageWidth/Height on ImageDocuments when we get the document load event. r=bz We only update mImageWidth/Height when we get the load event for the img element. But the style sheet TopLevelImageDocument.css can be loaded after the img load event. TopLevelImageDocument.css specifies that the orientation of the image comes from the embedded exif data, thus when it is loaded the image can rotate and change size. So we need to be sure to re-get the size after all style sheets are loaded. This means mImageWidth/Height could be wrong during loading.
dom/html/ImageDocument.cpp
--- a/dom/html/ImageDocument.cpp
+++ b/dom/html/ImageDocument.cpp
@@ -280,16 +280,19 @@ ImageDocument::SetScriptGlobalObject(nsI
 void
 ImageDocument::OnPageShow(bool aPersisted,
                           EventTarget* aDispatchStartTarget)
 {
   if (aPersisted) {
     mOriginalZoomLevel =
       Preferences::GetBool(SITE_SPECIFIC_ZOOM, false) ? 1.0 : GetZoomLevel();
   }
+  RefPtr<ImageDocument> kungFuDeathGrip(this);
+  UpdateSizeFromLayout();
+
   MediaDocument::OnPageShow(aPersisted, aDispatchStartTarget);
 }
 
 NS_IMETHODIMP
 ImageDocument::GetImageResizingEnabled(bool* aImageResizingEnabled)
 {
   *aImageResizingEnabled = ImageResizingEnabled();
   return NS_OK;