Mozilla/mozilla/layout/html/base/src/nsHTMLImageLoader.h
buster%netscape.com 685185593d bug 14280
nsTextTransformer.cpp.
  I moved where we translate the nbsp to a (ascii 32 space character) until after the i18n routines are called, so they can properly account
  for the space as non-breaking and therefore part of the first word in the block.

bug  39901 and 38396
  nsHTMLImageLoader.*, nsImageFrame.cpp
  I backed out the bad fix for 38396, and put in a new fix where I store a little state in the image loader flags for cases where the image
  gets an unconstrained reflow and has %-based width.  This does not handle %-based min-width or max-width, that would be a separate
  bug that I'll file shortly.  But this fixes the vast majority of real cases out there.

bug  18754
  nsHRFrame.cpp, quirks.css, nsCSSFrameConstructor.cpp, last part of nsLineLayout.cpp
  in quirks mode, I changed HR from a block element to a replaced inline element that acts like a block, using generated content to get
  newlines before and after the HR.  This isn't ideal, but it gets us backwards compatibility, and ian and dbaron have blessed the approach.

bug  50257
  nsLineLayout.cpp
  Did a couple of things in here:
       * The actual fix is controlled by FIX_BUG_50257 #define symbol.  This basically says that an break (BR) will always fit on a line.
         A more general solution would probably be to round up to the nearest pixel, and if the thing is less than a pixel make it fit on a
         line.  This is a wimpier, safer solution.
       * I noticed that the way we got the compatibility mode was way out of date, very wasteful.  So I fixed that.
       * I noticed that there were a bunch of redundant SetFlag calls.  Since the flag variable is initialized to 0, setting a flag to 0 on a newly
         created object is a waste.

  nsBlockFrame.cpp  --  just added a comment to some odd looking code, to make sure no one comes along later and breaks it


git-svn-id: svn://10.0.0.236/trunk@78763 18797224-902f-48f8-a5cc-f745e15eee43
2000-09-11 21:15:02 +00:00

147 lines
4.3 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsHTMLImageLoader_h___
#define nsHTMLImageLoader_h___
#include "nslayout.h"
#include "nsString.h"
#include "nsIPresContext.h"
class nsIFrame;
class nsImageMap;
class nsIImage;
class nsIURI;
class nsISizeOfHandler;
struct nsHTMLReflowState;
struct nsHTMLReflowMetrics;
struct nsSize;
class nsHTMLImageLoader;
typedef nsresult (*nsHTMLImageLoaderCB)(nsIPresContext* aPresContext,
nsHTMLImageLoader* aLoader,
nsIFrame* aFrame,
void* aClosure,
PRUint32 aStatus);
/**
* HTML image loader. This is designed to encapsulate the loading
* and sizing process of html images (basically so that the logic
* can be reused in the image button form control code and the html
* image layout code).
*/
class nsHTMLImageLoader {
public:
nsHTMLImageLoader();
~nsHTMLImageLoader();
void Init(nsIFrame* aFrame, nsHTMLImageLoaderCB aCallBack, void* aClosure,
nsIURI* aBaseURL, const nsString& aURLSpec);
nsIImage* GetImage();
void GetURLSpec(nsString& aResult) {
aResult = mURLSpec;
}
void UpdateURLSpec(nsIPresContext* aPresContext,
const nsString& aNewSpec);
// Stop the current image load request from loading
void StopLoadImage(nsIPresContext* aPresContext);
// Stop all image load requests from loading
void StopAllLoadImages(nsIPresContext* aPresContext);
// Get the desired size for the image. If aReflowState is not null
// then the image will be scaled to fit the reflow
// constraints. Otherwise, the image will be left at its intrinsic
// size.
PRBool GetDesiredSize(nsIPresContext* aPresContext,
const nsHTMLReflowState* aReflowState,
nsHTMLReflowMetrics& aDesiredSize);
PRUint32 GetLoadStatus() const;
PRBool GetLoadImageFailed() const;
PRBool IsImageSizeKnown() const {
return mFlags.mHaveComputedSize;
}
// Get the intrinsic (natural) size for the image. Returns 0,0 if
// the dimensions are not known
void GetIntrinsicSize(nsSize& aSize);
void GetNaturalImageSize(PRUint32* naturalWidth, PRUint32* naturalHeight);
#ifdef DEBUG
void SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
#endif
protected:
static nsresult ImageLoadCB(nsIPresContext* aPresContext,
nsIFrameImageLoader* aLoader,
nsIFrame* aFrame,
void* aClosure,
PRUint32 aStatus);
void Update(nsIPresContext* aPresContext,
nsIFrame* aFrame,
PRUint32 aStatus);
void SetURL(const nsString& aNewSpec);
nsresult StartLoadImage(nsIPresContext* aPresContext);
nsIURI* mBaseURL;
nsIFrame* mFrame;
nsHTMLImageLoaderCB mCallBack;
void* mClosure;
nsString mURLSpec;
nsString mURL;
nsIFrameImageLoader* mImageLoader;
public:
struct _indFlags {
PRUint32 mLoadImageFailed : 1;
PRUint32 mHaveIntrinsicImageSize : 1;
PRUint32 mNeedIntrinsicImageSize : 1;
PRUint32 mAutoImageSize : 1;
PRUint32 mHaveComputedSize : 1;
PRUint32 mSquelchCallback : 1;
PRUint32 mNeedSizeNotification : 1;
PRUint32 mInRecalcMode : 1; // a special flag used only in very rare circumstances, see nsHTMLImageLoader::GetDesiredSize
} ;
protected:
union {
PRUint32 mAllFlags;
_indFlags mFlags;
};
nsSize mIntrinsicImageSize;
nsSize mComputedImageSize;
};
#endif /* nsHTMLImageLoader_h___ */