2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 14:30:37 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-09-08 22:34:40 +00:00
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The contents of this file are subject to the Mozilla 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/MPL/
|
1998-09-08 22:34:40 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* 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.
|
1998-09-08 22:34:40 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-28 20:14:13 +00:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 03:40:37 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 14:30:37 +00:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-28 20:14:13 +00:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 14:30:37 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-28 20:14:13 +00:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 14:30:37 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-28 20:14:13 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1998-09-08 22:34:40 +00:00
|
|
|
#include "nsHTMLParts.h"
|
1999-07-08 19:38:08 +00:00
|
|
|
#include "nsCOMPtr.h"
|
1999-04-13 21:51:20 +00:00
|
|
|
#include "nsImageFrame.h"
|
2003-03-19 03:47:09 +00:00
|
|
|
#include "nsIImageLoadingContent.h"
|
1998-09-08 22:34:40 +00:00
|
|
|
#include "nsString.h"
|
2002-11-20 00:44:26 +00:00
|
|
|
#include "nsPrintfCString.h"
|
1998-09-08 22:34:40 +00:00
|
|
|
#include "nsIPresContext.h"
|
|
|
|
#include "nsIRenderingContext.h"
|
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsIImage.h"
|
|
|
|
#include "nsIWidget.h"
|
|
|
|
#include "nsHTMLAtoms.h"
|
|
|
|
#include "nsIDocument.h"
|
2002-11-20 00:44:26 +00:00
|
|
|
#include "nsINodeInfo.h"
|
2004-04-29 23:34:19 +00:00
|
|
|
#include "nsContentUtils.h"
|
2003-02-22 00:32:13 +00:00
|
|
|
#include "nsStyleContext.h"
|
1998-09-08 22:34:40 +00:00
|
|
|
#include "nsStyleConsts.h"
|
1999-01-09 00:13:19 +00:00
|
|
|
#include "nsImageMap.h"
|
1998-09-08 22:34:40 +00:00
|
|
|
#include "nsILinkHandler.h"
|
|
|
|
#include "nsIURL.h"
|
1999-06-18 17:34:08 +00:00
|
|
|
#include "nsIIOService.h"
|
1999-06-23 03:29:44 +00:00
|
|
|
#include "nsIURL.h"
|
2001-03-22 01:38:35 +00:00
|
|
|
#include "nsILoadGroup.h"
|
1999-06-18 17:34:08 +00:00
|
|
|
#include "nsIServiceManager.h"
|
1999-11-30 04:50:42 +00:00
|
|
|
#include "nsNetUtil.h"
|
1998-09-08 22:34:40 +00:00
|
|
|
#include "nsIView.h"
|
|
|
|
#include "nsIViewManager.h"
|
1998-09-23 02:30:21 +00:00
|
|
|
#include "nsHTMLContainerFrame.h"
|
1998-09-08 22:34:40 +00:00
|
|
|
#include "prprf.h"
|
|
|
|
#include "nsIFontMetrics.h"
|
|
|
|
#include "nsCSSRendering.h"
|
2004-02-10 16:57:00 +00:00
|
|
|
#include "nsILink.h"
|
1999-07-08 19:38:08 +00:00
|
|
|
#include "nsIDOMHTMLAnchorElement.h"
|
1998-09-08 22:34:40 +00:00
|
|
|
#include "nsIDOMHTMLImageElement.h"
|
1998-09-20 00:08:24 +00:00
|
|
|
#include "nsIDeviceContext.h"
|
1998-12-20 01:21:23 +00:00
|
|
|
#include "nsINameSpaceManager.h"
|
1999-01-05 23:02:27 +00:00
|
|
|
#include "nsTextFragment.h"
|
1999-01-30 01:04:35 +00:00
|
|
|
#include "nsIDOMHTMLMapElement.h"
|
1999-08-31 03:09:40 +00:00
|
|
|
#include "nsLayoutAtoms.h"
|
2001-04-18 00:14:34 +00:00
|
|
|
#include "nsImageMapUtils.h"
|
2000-08-08 20:35:12 +00:00
|
|
|
#include "nsIScriptSecurityManager.h"
|
2001-08-17 03:13:07 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2001-04-01 01:01:33 +00:00
|
|
|
#include "nsIAccessibilityService.h"
|
2001-08-17 03:13:07 +00:00
|
|
|
#endif
|
2001-04-01 01:01:33 +00:00
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsIDOMNode.h"
|
2001-07-16 02:40:48 +00:00
|
|
|
#include "nsGUIEvent.h"
|
2001-04-01 01:01:33 +00:00
|
|
|
|
2001-05-04 06:29:59 +00:00
|
|
|
#include "imgIContainer.h"
|
|
|
|
#include "imgILoader.h"
|
|
|
|
|
2001-07-11 05:44:12 +00:00
|
|
|
#include "nsIEventQueueService.h"
|
|
|
|
#include "plevent.h"
|
1998-09-08 22:34:40 +00:00
|
|
|
|
2001-04-15 02:13:49 +00:00
|
|
|
#include "nsContentPolicyUtils.h"
|
2001-05-21 22:40:10 +00:00
|
|
|
#include "nsIScriptGlobalObject.h"
|
|
|
|
#include "nsIDOMWindow.h"
|
2001-07-11 05:44:12 +00:00
|
|
|
#include "nsIDOMDocument.h"
|
2001-11-07 05:02:42 +00:00
|
|
|
#include "nsCSSFrameConstructor.h"
|
2004-02-03 20:30:02 +00:00
|
|
|
#include "nsIPrefBranchInternal.h"
|
2002-12-11 14:05:41 +00:00
|
|
|
#include "nsIPrefService.h"
|
2003-03-05 23:55:53 +00:00
|
|
|
#include "gfxIImageFrame.h"
|
2003-04-22 23:18:34 +00:00
|
|
|
#include "nsIDOMRange.h"
|
massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-08 21:31:05 +00:00
|
|
|
|
2003-04-21 23:57:47 +00:00
|
|
|
#include "nsLayoutErrors.h"
|
|
|
|
|
1999-04-13 21:51:20 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
#undef NOISY_IMAGE_LOADING
|
2001-11-07 05:02:42 +00:00
|
|
|
#undef NOISY_ICON_LOADING
|
1999-04-13 21:51:20 +00:00
|
|
|
#else
|
|
|
|
#undef NOISY_IMAGE_LOADING
|
2001-11-07 05:02:42 +00:00
|
|
|
#undef NOISY_ICON_LOADING
|
1998-11-13 21:31:50 +00:00
|
|
|
#endif
|
1998-09-08 22:34:40 +00:00
|
|
|
|
2002-03-26 20:14:05 +00:00
|
|
|
// sizes (pixels) for image icon, padding and border frame
|
|
|
|
#define ICON_SIZE (16)
|
|
|
|
#define ICON_PADDING (3)
|
|
|
|
#define ALT_BORDER_WIDTH (1)
|
|
|
|
|
|
|
|
|
2003-04-22 23:18:34 +00:00
|
|
|
//we must add hooks soon
|
|
|
|
#define IMAGE_EDITOR_CHECK 1
|
|
|
|
|
1998-09-08 22:34:40 +00:00
|
|
|
// Default alignment value (so we can tell an unset value from a set value)
|
|
|
|
#define ALIGN_UNSET PRUint8(-1)
|
|
|
|
|
2004-02-03 20:30:02 +00:00
|
|
|
// static icon information
|
|
|
|
nsImageFrame::IconLoad* nsImageFrame::gIconLoad = nsnull;
|
2001-11-07 05:02:42 +00:00
|
|
|
|
2004-01-21 09:35:59 +00:00
|
|
|
// cached IO service for loading icons
|
|
|
|
nsIIOService* nsImageFrame::sIOService;
|
|
|
|
|
2001-11-07 05:02:42 +00:00
|
|
|
// test if the width and height are fixed, looking at the style data
|
2003-05-15 03:42:21 +00:00
|
|
|
static PRBool HaveFixedSize(const nsStylePosition* aStylePosition)
|
2001-11-07 05:02:42 +00:00
|
|
|
{
|
|
|
|
// check the width and height values in the reflow state's style struct
|
|
|
|
// - if width and height are specified as either coord or percentage, then
|
|
|
|
// the size of the image frame is constrained
|
2003-05-15 03:42:21 +00:00
|
|
|
nsStyleUnit widthUnit = aStylePosition->mWidth.GetUnit();
|
|
|
|
nsStyleUnit heightUnit = aStylePosition->mHeight.GetUnit();
|
2001-11-07 05:02:42 +00:00
|
|
|
|
|
|
|
return ((widthUnit == eStyleUnit_Coord ||
|
|
|
|
widthUnit == eStyleUnit_Percent) &&
|
|
|
|
(heightUnit == eStyleUnit_Coord ||
|
|
|
|
heightUnit == eStyleUnit_Percent));
|
|
|
|
}
|
2001-03-06 00:47:46 +00:00
|
|
|
// use the data in the reflow state to decide if the image has a constrained size
|
|
|
|
// (i.e. width and height that are based on the containing block size and not the image size)
|
|
|
|
// so we can avoid animated GIF related reflows
|
2001-11-07 05:02:42 +00:00
|
|
|
inline PRBool HaveFixedSize(const nsHTMLReflowState& aReflowState)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aReflowState.mStylePosition, "crappy reflowState - null stylePosition");
|
2002-11-07 02:50:39 +00:00
|
|
|
// when an image has percent css style height or width, but mComputedHeight
|
|
|
|
// or mComputedWidth of reflow state is NS_UNCONSTRAINEDSIZE
|
|
|
|
// it needs to return PR_FALSE to cause an incremental reflow later
|
|
|
|
// if an image is inside table like bug 156731 simple testcase III,
|
|
|
|
// during pass 1 reflow, mComputedWidth is NS_UNCONSTRAINEDSIZE
|
|
|
|
// in pass 2 reflow, mComputedWidth is 0, it also needs to return PR_FALSE
|
|
|
|
// see bug 156731
|
|
|
|
nsStyleUnit heightUnit = (*(aReflowState.mStylePosition)).mHeight.GetUnit();
|
|
|
|
nsStyleUnit widthUnit = (*(aReflowState.mStylePosition)).mWidth.GetUnit();
|
|
|
|
return ((eStyleUnit_Percent == heightUnit && NS_UNCONSTRAINEDSIZE == aReflowState.mComputedHeight) ||
|
|
|
|
(eStyleUnit_Percent == widthUnit && (NS_UNCONSTRAINEDSIZE == aReflowState.mComputedWidth ||
|
|
|
|
0 == aReflowState.mComputedWidth)))
|
|
|
|
? PR_FALSE
|
2003-05-15 03:42:21 +00:00
|
|
|
: HaveFixedSize(aReflowState.mStylePosition);
|
2001-11-07 05:02:42 +00:00
|
|
|
}
|
2001-03-06 00:47:46 +00:00
|
|
|
|
1998-09-08 22:34:40 +00:00
|
|
|
nsresult
|
1999-12-04 23:49:50 +00:00
|
|
|
NS_NewImageFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
|
1998-09-08 22:34:40 +00:00
|
|
|
{
|
1999-05-11 22:03:29 +00:00
|
|
|
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
|
|
|
if (nsnull == aNewFrame) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1999-12-04 23:49:50 +00:00
|
|
|
nsImageFrame* it = new (aPresShell) nsImageFrame;
|
1999-05-11 22:03:29 +00:00
|
|
|
if (nsnull == it) {
|
1998-09-08 22:34:40 +00:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1999-05-11 22:03:29 +00:00
|
|
|
*aNewFrame = it;
|
1998-09-08 22:34:40 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-10-06 05:08:16 +00:00
|
|
|
|
2000-04-19 14:00:11 +00:00
|
|
|
nsImageFrame::nsImageFrame() :
|
2003-03-19 03:47:09 +00:00
|
|
|
mComputedSize(0, 0),
|
2004-02-03 20:30:02 +00:00
|
|
|
mIntrinsicSize(0, 0)
|
2000-04-19 14:00:11 +00:00
|
|
|
{
|
2003-03-19 03:47:09 +00:00
|
|
|
// We assume our size is not constrained and we haven't gotten an
|
|
|
|
// initial reflow yet, so don't touch those flags.
|
2000-04-19 14:00:11 +00:00
|
|
|
}
|
|
|
|
|
1998-11-20 17:21:02 +00:00
|
|
|
nsImageFrame::~nsImageFrame()
|
1998-09-08 22:34:40 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-02-19 21:50:04 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsImageFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aInstancePtr);
|
|
|
|
*aInstancePtr = nsnull;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (aIID.Equals(NS_GET_IID(nsIFrameDebug))) {
|
|
|
|
*aInstancePtr = NS_STATIC_CAST(nsIFrameDebug*,this);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (aIID.Equals(NS_GET_IID(nsIImageFrame))) {
|
|
|
|
*aInstancePtr = NS_STATIC_CAST(nsIImageFrame*,this);
|
|
|
|
return NS_OK;
|
|
|
|
} else if (aIID.Equals(NS_GET_IID(nsIFrame))) {
|
|
|
|
*aInstancePtr = NS_STATIC_CAST(nsIFrame*,this);
|
|
|
|
return NS_OK;
|
|
|
|
} else if (aIID.Equals(NS_GET_IID(nsISupports))) {
|
|
|
|
*aInstancePtr = NS_STATIC_CAST(nsIImageFrame*,this);
|
|
|
|
return NS_OK;
|
2001-05-17 23:52:32 +00:00
|
|
|
}
|
2001-04-01 01:01:33 +00:00
|
|
|
|
2001-02-19 21:50:04 +00:00
|
|
|
return NS_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2001-08-17 03:13:07 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2001-05-17 23:52:32 +00:00
|
|
|
NS_IMETHODIMP nsImageFrame::GetAccessible(nsIAccessible** aAccessible)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAccessibilityService> accService = do_GetService("@mozilla.org/accessibilityService;1");
|
|
|
|
|
|
|
|
if (accService) {
|
|
|
|
return accService->CreateHTMLImageAccessible(NS_STATIC_CAST(nsIFrame*, this), aAccessible);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2001-08-17 03:13:07 +00:00
|
|
|
#endif
|
2001-05-17 23:52:32 +00:00
|
|
|
|
2001-02-19 21:50:04 +00:00
|
|
|
NS_IMETHODIMP_(nsrefcnt) nsImageFrame::AddRef(void)
|
|
|
|
{
|
|
|
|
NS_WARNING("not supported for frames");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP_(nsrefcnt) nsImageFrame::Release(void)
|
|
|
|
{
|
|
|
|
NS_WARNING("not supported for frames");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 06:03:41 +00:00
|
|
|
nsImageFrame::Destroy(nsIPresContext* aPresContext)
|
1998-09-08 22:34:40 +00:00
|
|
|
{
|
2000-08-12 00:38:22 +00:00
|
|
|
// Tell our image map, if there is one, to clean up
|
|
|
|
// This causes the nsImageMap to unregister itself as
|
|
|
|
// a DOM listener.
|
2003-03-19 03:47:09 +00:00
|
|
|
if (mImageMap) {
|
2001-05-04 06:29:59 +00:00
|
|
|
mImageMap->Destroy();
|
|
|
|
NS_RELEASE(mImageMap);
|
|
|
|
}
|
1998-09-08 22:34:40 +00:00
|
|
|
|
2001-04-15 02:13:49 +00:00
|
|
|
// set the frame to null so we don't send messages to a dead object.
|
2003-03-19 03:47:09 +00:00
|
|
|
if (mListener) {
|
|
|
|
nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(mContent);
|
|
|
|
if (imageLoader) {
|
|
|
|
imageLoader->RemoveObserver(mListener);
|
|
|
|
}
|
|
|
|
|
2001-04-15 02:13:49 +00:00
|
|
|
NS_REINTERPRET_CAST(nsImageListener*, mListener.get())->SetFrame(nsnull);
|
2003-03-19 03:47:09 +00:00
|
|
|
}
|
|
|
|
|
2001-04-15 02:13:49 +00:00
|
|
|
mListener = nsnull;
|
2001-03-22 01:38:35 +00:00
|
|
|
|
2001-11-01 15:31:13 +00:00
|
|
|
return nsSplittableFrame::Destroy(aPresContext);
|
1998-09-08 22:34:40 +00:00
|
|
|
}
|
|
|
|
|
2001-03-22 01:38:35 +00:00
|
|
|
|
|
|
|
|
1998-12-29 03:38:16 +00:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 06:03:41 +00:00
|
|
|
nsImageFrame::Init(nsIPresContext* aPresContext,
|
1998-12-29 03:38:16 +00:00
|
|
|
nsIContent* aContent,
|
1999-01-14 05:16:23 +00:00
|
|
|
nsIFrame* aParent,
|
2003-02-22 00:32:13 +00:00
|
|
|
nsStyleContext* aContext,
|
1999-02-25 03:27:57 +00:00
|
|
|
nsIFrame* aPrevInFlow)
|
1998-12-29 03:38:16 +00:00
|
|
|
{
|
2001-11-01 15:31:13 +00:00
|
|
|
nsresult rv = nsSplittableFrame::Init(aPresContext, aContent, aParent,
|
|
|
|
aContext, aPrevInFlow);
|
2003-03-19 03:47:09 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2003-02-26 05:51:32 +00:00
|
|
|
|
2003-03-19 03:47:09 +00:00
|
|
|
mListener = new nsImageListener(this);
|
|
|
|
if (!mListener) return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(aContent);
|
|
|
|
NS_ENSURE_TRUE(imageLoader, NS_ERROR_UNEXPECTED);
|
2003-11-16 07:34:25 +00:00
|
|
|
// XXXbz this call _has_ to happen before we decide we won't be rendering the
|
|
|
|
// image, just in case -- this lets the image loading content know someone
|
|
|
|
// cares.
|
2003-03-19 03:47:09 +00:00
|
|
|
imageLoader->AddObserver(mListener);
|
|
|
|
|
2004-02-03 20:30:02 +00:00
|
|
|
if (!gIconLoad)
|
|
|
|
LoadIcons(aPresContext);
|
2003-03-19 03:47:09 +00:00
|
|
|
|
|
|
|
nsCOMPtr<imgIRequest> currentRequest;
|
|
|
|
imageLoader->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST,
|
|
|
|
getter_AddRefs(currentRequest));
|
|
|
|
PRUint32 currentLoadStatus = imgIRequest::STATUS_ERROR;
|
|
|
|
if (currentRequest) {
|
|
|
|
currentRequest->GetImageStatus(¤tLoadStatus);
|
|
|
|
}
|
1999-05-05 23:40:21 +00:00
|
|
|
|
2003-03-19 03:47:09 +00:00
|
|
|
if (currentLoadStatus & imgIRequest::STATUS_ERROR) {
|
|
|
|
PRBool loadBlocked = PR_FALSE;
|
|
|
|
imageLoader->GetImageBlocked(&loadBlocked);
|
2003-04-21 23:57:47 +00:00
|
|
|
rv = HandleLoadError(loadBlocked ? NS_ERROR_IMAGE_BLOCKED : NS_ERROR_FAILURE,
|
2004-02-03 20:30:02 +00:00
|
|
|
aPresContext->PresShell());
|
2003-03-19 03:47:09 +00:00
|
|
|
}
|
2003-05-04 18:06:10 +00:00
|
|
|
// If we already have an image container, OnStartContainer won't be called
|
|
|
|
// Set the animation mode here
|
2003-12-26 04:24:11 +00:00
|
|
|
if (currentRequest) {
|
2004-01-08 18:29:28 +00:00
|
|
|
nsCOMPtr<imgIContainer> image;
|
2003-05-04 18:06:10 +00:00
|
|
|
currentRequest->GetImage(getter_AddRefs(image));
|
2004-01-08 18:29:28 +00:00
|
|
|
if (image) {
|
2004-02-03 20:30:02 +00:00
|
|
|
image->SetAnimationMode(aPresContext->ImageAnimationMode());
|
2004-01-08 18:29:28 +00:00
|
|
|
// Ensure the animation (if any) is started.
|
|
|
|
image->StartAnimation();
|
|
|
|
}
|
2003-05-04 18:06:10 +00:00
|
|
|
}
|
2003-12-26 04:24:11 +00:00
|
|
|
|
2003-03-19 03:47:09 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsImageFrame::RecalculateTransform(imgIContainer* aImage)
|
|
|
|
{
|
|
|
|
PRBool intrinsicSizeChanged = PR_FALSE;
|
|
|
|
|
|
|
|
if (aImage) {
|
|
|
|
float p2t;
|
2004-02-11 04:57:07 +00:00
|
|
|
p2t = GetPresContext()->PixelsToTwips();
|
2003-03-19 03:47:09 +00:00
|
|
|
|
|
|
|
nsSize imageSizeInPx;
|
|
|
|
aImage->GetWidth(&imageSizeInPx.width);
|
|
|
|
aImage->GetHeight(&imageSizeInPx.height);
|
|
|
|
nsSize newSize(NSIntPixelsToTwips(imageSizeInPx.width, p2t),
|
|
|
|
NSIntPixelsToTwips(imageSizeInPx.height, p2t));
|
|
|
|
if (mIntrinsicSize != newSize) {
|
|
|
|
intrinsicSizeChanged = PR_TRUE;
|
|
|
|
mIntrinsicSize = newSize;
|
|
|
|
}
|
1999-02-27 00:57:04 +00:00
|
|
|
}
|
|
|
|
|
2003-03-19 03:47:09 +00:00
|
|
|
// In any case, we need to translate this over appropriately. Set
|
|
|
|
// translation _before_ setting scaling so that it does not get
|
|
|
|
// scaled!
|
2001-03-22 01:38:35 +00:00
|
|
|
|
2003-03-19 03:47:09 +00:00
|
|
|
// XXXbz does this introduce rounding errors because of the cast to
|
|
|
|
// float? Should we just manually add that stuff in every time
|
|
|
|
// instead?
|
|
|
|
mTransform.SetToTranslate(float(mBorderPadding.left),
|
|
|
|
float(mBorderPadding.top - GetContinuationOffset()));
|
|
|
|
|
|
|
|
// Set the scale factors
|
|
|
|
if (mIntrinsicSize.width != 0 && mIntrinsicSize.height != 0 &&
|
|
|
|
mIntrinsicSize != mComputedSize) {
|
|
|
|
mTransform.AddScale(float(mComputedSize.width) / float(mIntrinsicSize.width),
|
|
|
|
float(mComputedSize.height) / float(mIntrinsicSize.height));
|
|
|
|
}
|
2001-11-07 05:02:42 +00:00
|
|
|
|
2003-03-19 03:47:09 +00:00
|
|
|
return intrinsicSizeChanged;
|
|
|
|
}
|
2001-03-22 01:38:35 +00:00
|
|
|
|
2003-03-19 03:47:09 +00:00
|
|
|
/*
|
|
|
|
* These two functions basically do the same check. The first one
|
|
|
|
* checks that the given request is the current request for our
|
|
|
|
* mContent. The second checks that the given image container the
|
|
|
|
* same as the image container on the current request for our
|
|
|
|
* mContent.
|
|
|
|
*/
|
|
|
|
PRBool
|
|
|
|
nsImageFrame::IsPendingLoad(imgIRequest* aRequest) const
|
|
|
|
{
|
|
|
|
// Default to pending load in case of errors
|
|
|
|
nsCOMPtr<nsIImageLoadingContent> imageLoader(do_QueryInterface(mContent));
|
|
|
|
NS_ASSERTION(imageLoader, "No image loading content?");
|
|
|
|
|
|
|
|
PRInt32 requestType = nsIImageLoadingContent::UNKNOWN_REQUEST;
|
|
|
|
imageLoader->GetRequestType(aRequest, &requestType);
|
|
|
|
|
|
|
|
return requestType != nsIImageLoadingContent::CURRENT_REQUEST;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsImageFrame::IsPendingLoad(imgIContainer* aContainer) const
|
|
|
|
{
|
|
|
|
// default to pending load in case of errors
|
|
|
|
if (!aContainer) {
|
|
|
|
NS_ERROR("No image container!");
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIImageLoadingContent> imageLoader(do_QueryInterface(mContent));
|
|
|
|
NS_ASSERTION(imageLoader, "No image loading content?");
|
|
|
|
|
|
|
|
nsCOMPtr<imgIRequest> currentRequest;
|
|
|
|
imageLoader->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST,
|
|
|
|
getter_AddRefs(currentRequest));
|
|
|
|
if (!currentRequest) {
|
|
|
|
NS_ERROR("No current request");
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<imgIContainer> currentContainer;
|
|
|
|
currentRequest->GetImage(getter_AddRefs(currentContainer));
|
|
|
|
|
|
|
|
return currentContainer != aContainer;
|
|
|
|
|
1998-12-29 03:38:16 +00:00
|
|
|
}
|
|
|
|
|
2003-03-19 03:47:09 +00:00
|
|
|
nsRect
|
|
|
|
nsImageFrame::ConvertPxRectToTwips(const nsRect& aRect) const
|
|
|
|
{
|
|
|
|
float p2t;
|
2004-02-11 04:57:07 +00:00
|
|
|
p2t = GetPresContext()->PixelsToTwips();
|
2003-03-19 03:47:09 +00:00
|
|
|
return nsRect(NSIntPixelsToTwips(aRect.x, p2t), // x
|
|
|
|
NSIntPixelsToTwips(aRect.y, p2t), // y
|
|
|
|
NSIntPixelsToTwips(aRect.width, p2t), // width
|
|
|
|
NSIntPixelsToTwips(aRect.height, p2t)); // height
|
|
|
|
}
|
2001-03-22 01:38:35 +00:00
|
|
|
|
2003-04-21 23:57:47 +00:00
|
|
|
nsresult
|
2003-03-19 03:47:09 +00:00
|
|
|
nsImageFrame::HandleLoadError(nsresult aStatus, nsIPresShell* aPresShell)
|
2001-03-22 01:38:35 +00:00
|
|
|
{
|
2003-03-19 03:47:09 +00:00
|
|
|
if (aStatus == NS_ERROR_IMAGE_BLOCKED &&
|
2004-02-03 20:30:02 +00:00
|
|
|
!(gIconLoad && gIconLoad->mPrefAllImagesBlocked)) {
|
2003-03-19 03:47:09 +00:00
|
|
|
// don't display any alt feedback in this case; we're blocking images
|
|
|
|
// from that site and don't care to see anything from them
|
2003-04-21 23:57:47 +00:00
|
|
|
return NS_OK;
|
2003-03-19 03:47:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// If we have an image map, don't do anything here
|
|
|
|
// XXXbz Why? This is what the code used to do, but there's no good
|
|
|
|
// reason for it....
|
|
|
|
|
|
|
|
nsAutoString usemap;
|
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::usemap, usemap);
|
|
|
|
if (!usemap.IsEmpty()) {
|
2003-04-21 23:57:47 +00:00
|
|
|
return NS_OK;
|
2003-03-19 03:47:09 +00:00
|
|
|
}
|
|
|
|
|
2003-04-29 18:49:42 +00:00
|
|
|
// Check if we want to use a placeholder box with an icon or just
|
|
|
|
// let the the presShell make us into inline text. Decide as follows:
|
|
|
|
//
|
|
|
|
// - if our special "force icons" style is set, show an icon
|
|
|
|
// - else if our "do not show placeholders" pref is set, skip the icon
|
|
|
|
// - else:
|
|
|
|
// - if QuirksMode, and there is no alt attribute, and this is not an
|
|
|
|
// <object> (which could not possibly have such an attribute), show an
|
|
|
|
// icon.
|
|
|
|
// - if QuirksMode, and the IMG has a size, and the image is
|
|
|
|
// broken, not blocked, show an icon.
|
|
|
|
// - otherwise, skip the icon
|
|
|
|
|
|
|
|
PRBool useSizedBox;
|
|
|
|
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleUIReset* uiResetData = GetStyleUIReset();
|
2003-04-29 18:49:42 +00:00
|
|
|
if (uiResetData->mForceBrokenImageIcon) {
|
|
|
|
useSizedBox = PR_TRUE;
|
2003-03-19 03:47:09 +00:00
|
|
|
}
|
2004-02-03 20:30:02 +00:00
|
|
|
else if (gIconLoad && gIconLoad->mPrefForceInlineAltText) {
|
2003-04-29 18:49:42 +00:00
|
|
|
useSizedBox = PR_FALSE;
|
|
|
|
}
|
|
|
|
else {
|
2004-02-03 20:30:02 +00:00
|
|
|
if (GetPresContext()->CompatibilityMode() != eCompatibility_NavQuirks) {
|
2003-04-29 18:49:42 +00:00
|
|
|
useSizedBox = PR_FALSE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// We are in quirks mode, so we can just check the tag name; no need to
|
|
|
|
// check the namespace.
|
2003-09-27 04:18:26 +00:00
|
|
|
nsINodeInfo *nodeInfo = mContent->GetNodeInfo();
|
|
|
|
|
2003-04-29 18:49:42 +00:00
|
|
|
if (!mContent->HasAttr(kNameSpaceID_None, nsHTMLAtoms::alt) &&
|
|
|
|
nodeInfo &&
|
|
|
|
!nodeInfo->Equals(nsHTMLAtoms::object)) {
|
|
|
|
useSizedBox = PR_TRUE;
|
|
|
|
}
|
|
|
|
else if (aStatus == NS_ERROR_IMAGE_BLOCKED) {
|
|
|
|
useSizedBox = PR_FALSE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// check whether we have fixed size
|
2003-05-15 03:42:21 +00:00
|
|
|
useSizedBox = HaveFixedSize(GetStylePosition());
|
2003-04-29 18:49:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-19 03:47:09 +00:00
|
|
|
if (!useSizedBox) {
|
|
|
|
// let the presShell handle converting this into the inline alt
|
|
|
|
// text frame
|
|
|
|
nsIFrame* primaryFrame = nsnull;
|
2004-04-02 03:07:39 +00:00
|
|
|
if (mContent->IsContentOfType(nsIContent::eHTML) &&
|
|
|
|
(mContent->Tag() == nsHTMLAtoms::object ||
|
|
|
|
mContent->Tag() == nsHTMLAtoms::embed)) {
|
|
|
|
// We have to try to get the primary frame for mContent, since for
|
|
|
|
// <object> the frame CantRenderReplacedElement wants is the
|
|
|
|
// ObjectFrame, not us (we're an anonymous frame then)....
|
|
|
|
aPresShell->GetPrimaryFrameFor(mContent, &primaryFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!primaryFrame) {
|
|
|
|
primaryFrame = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
aPresShell->CantRenderReplacedElement(primaryFrame);
|
2003-04-21 23:57:47 +00:00
|
|
|
return NS_ERROR_FRAME_REPLACED;
|
2003-03-19 03:47:09 +00:00
|
|
|
}
|
2003-04-21 23:57:47 +00:00
|
|
|
|
|
|
|
// we are handling it
|
|
|
|
// invalidate the icon area (it may change states)
|
2004-02-03 20:30:02 +00:00
|
|
|
InvalidateIcon();
|
2003-04-21 23:57:47 +00:00
|
|
|
return NS_OK;
|
2001-03-22 01:38:35 +00:00
|
|
|
}
|
|
|
|
|
2003-03-19 03:47:09 +00:00
|
|
|
nsresult
|
|
|
|
nsImageFrame::OnStartContainer(imgIRequest *aRequest, imgIContainer *aImage)
|
2001-03-22 01:38:35 +00:00
|
|
|
{
|
2001-10-06 05:08:16 +00:00
|
|
|
if (!aImage) return NS_ERROR_INVALID_ARG;
|
|
|
|
|
2001-11-07 05:02:42 +00:00
|
|
|
// handle iconLoads first...
|
|
|
|
if (HandleIconLoads(aRequest, PR_FALSE)) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2003-12-26 04:24:11 +00:00
|
|
|
/* Get requested animation policy from the pres context:
|
|
|
|
* normal = 0
|
|
|
|
* one frame = 1
|
|
|
|
* one loop = 2
|
|
|
|
*/
|
2004-02-03 20:30:02 +00:00
|
|
|
nsIPresContext *presContext = GetPresContext();
|
|
|
|
aImage->SetAnimationMode(presContext->ImageAnimationMode());
|
2004-01-08 18:29:28 +00:00
|
|
|
// Ensure the animation (if any) is started.
|
|
|
|
aImage->StartAnimation();
|
2001-04-16 22:02:39 +00:00
|
|
|
|
2003-03-19 03:47:09 +00:00
|
|
|
if (IsPendingLoad(aRequest)) {
|
|
|
|
// We don't care
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
RecalculateTransform(aImage);
|
2001-03-22 01:38:35 +00:00
|
|
|
|
2003-03-19 03:47:09 +00:00
|
|
|
// Now we need to reflow if we have an unconstrained size and have
|
|
|
|
// already gotten the initial reflow
|
|
|
|
if (!(mState & IMAGE_SIZECONSTRAINED) && (mState & IMAGE_GOTINITIALREFLOW)) {
|
2004-02-03 20:30:02 +00:00
|
|
|
nsIPresShell *presShell = presContext->GetPresShell();
|
2003-03-19 03:47:09 +00:00
|
|
|
NS_ASSERTION(mParent, "No parent to pass the reflow request up to.");
|
|
|
|
NS_ASSERTION(presShell, "No PresShell.");
|
|
|
|
if (mParent && presShell) {
|
|
|
|
mState |= NS_FRAME_IS_DIRTY;
|
|
|
|
mParent->ReflowDirtyChild(presShell, NS_STATIC_CAST(nsIFrame*, this));
|
2001-03-22 01:38:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2003-03-19 03:47:09 +00:00
|
|
|
nsresult
|
|
|
|
nsImageFrame::OnDataAvailable(imgIRequest *aRequest,
|
|
|
|
gfxIImageFrame *aFrame,
|
|
|
|
const nsRect *aRect)
|
2001-03-22 01:38:35 +00:00
|
|
|
{
|
2003-03-19 03:47:09 +00:00
|
|
|
// XXX do we need to make sure that the reflow from the
|
|
|
|
// OnStartContainer has been processed before we start calling
|
|
|
|
// invalidate?
|
2001-04-04 08:23:14 +00:00
|
|
|
|
2003-03-19 03:47:09 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aRect);
|
2003-03-19 06:51:46 +00:00
|
|
|
|
|
|
|
if (!(mState & IMAGE_GOTINITIALREFLOW)) {
|
|
|
|
// Don't bother to do anything; we have a reflow coming up!
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-11-07 05:02:42 +00:00
|
|
|
// handle iconLoads first...
|
|
|
|
if (HandleIconLoads(aRequest, PR_FALSE)) {
|
2004-03-10 03:09:05 +00:00
|
|
|
// Image changed, invalidate
|
|
|
|
Invalidate(*aRect, PR_FALSE);
|
2001-11-07 05:02:42 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2003-03-19 03:47:09 +00:00
|
|
|
if (IsPendingLoad(aRequest)) {
|
|
|
|
// We don't care
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-10-06 05:08:16 +00:00
|
|
|
|
2003-03-05 23:55:53 +00:00
|
|
|
// Don't invalidate if the current visible frame isn't the one the data is
|
|
|
|
// from
|
2003-03-19 03:47:09 +00:00
|
|
|
nsCOMPtr<imgIContainer> container;
|
|
|
|
aRequest->GetImage(getter_AddRefs(container));
|
|
|
|
if (container) {
|
|
|
|
nsCOMPtr<gfxIImageFrame> currentFrame;
|
|
|
|
container->GetCurrentFrame(getter_AddRefs(currentFrame));
|
|
|
|
if (aFrame != currentFrame) {
|
|
|
|
// just bail
|
|
|
|
return NS_OK;
|
2003-03-05 23:55:53 +00:00
|
|
|
}
|
|
|
|
}
|
2001-10-06 05:08:16 +00:00
|
|
|
|
2003-03-19 03:47:09 +00:00
|
|
|
nsRect r = ConvertPxRectToTwips(*aRect);
|
|
|
|
mTransform.TransformCoord(&r.x, &r.y, &r.width, &r.height);
|
2004-03-10 03:09:05 +00:00
|
|
|
// Invalidate updated image
|
|
|
|
Invalidate(r, PR_FALSE);
|
2003-03-19 03:47:09 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
2001-07-11 05:44:12 +00:00
|
|
|
}
|
|
|
|
|
2003-03-19 03:47:09 +00:00
|
|
|
nsresult
|
|
|
|
nsImageFrame::OnStopDecode(imgIRequest *aRequest,
|
|
|
|
nsresult aStatus,
|
|
|
|
const PRUnichar *aStatusArg)
|
2001-03-22 01:38:35 +00:00
|
|
|
{
|
2004-02-03 20:30:02 +00:00
|
|
|
nsIPresContext *presContext = GetPresContext();
|
|
|
|
nsIPresShell *presShell = presContext->GetPresShell();
|
2003-02-26 05:51:32 +00:00
|
|
|
NS_ASSERTION(presShell, "No PresShell.");
|
2001-04-15 02:13:49 +00:00
|
|
|
|
2001-11-07 05:02:42 +00:00
|
|
|
// handle iconLoads first...
|
|
|
|
if (HandleIconLoads(aRequest, NS_SUCCEEDED(aStatus))) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2003-03-19 03:47:09 +00:00
|
|
|
// Check what request type we're dealing with
|
|
|
|
nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(mContent);
|
|
|
|
NS_ASSERTION(imageLoader, "Who's notifying us??");
|
|
|
|
PRInt32 loadType = nsIImageLoadingContent::UNKNOWN_REQUEST;
|
|
|
|
imageLoader->GetRequestType(aRequest, &loadType);
|
|
|
|
if (loadType != nsIImageLoadingContent::CURRENT_REQUEST &&
|
|
|
|
loadType != nsIImageLoadingContent::PENDING_REQUEST) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2001-10-06 05:08:16 +00:00
|
|
|
|
2003-03-19 03:47:09 +00:00
|
|
|
if (loadType == nsIImageLoadingContent::PENDING_REQUEST) {
|
|
|
|
// May have to switch sizes here!
|
2003-05-25 20:43:08 +00:00
|
|
|
PRBool intrinsicSizeChanged = PR_TRUE;
|
2001-10-06 05:08:16 +00:00
|
|
|
if (NS_SUCCEEDED(aStatus)) {
|
2003-03-19 03:47:09 +00:00
|
|
|
nsCOMPtr<imgIContainer> imageContainer;
|
|
|
|
aRequest->GetImage(getter_AddRefs(imageContainer));
|
|
|
|
NS_ASSERTION(imageContainer, "Successful load with no container?");
|
|
|
|
intrinsicSizeChanged = RecalculateTransform(imageContainer);
|
2002-06-18 21:28:53 +00:00
|
|
|
}
|
2003-05-30 19:47:08 +00:00
|
|
|
else {
|
|
|
|
// Have to size to 0,0 so that GetDesiredSize recalculates the size
|
2003-05-25 20:43:08 +00:00
|
|
|
mIntrinsicSize.SizeTo(0, 0);
|
2003-05-30 19:47:08 +00:00
|
|
|
}
|
2002-06-18 21:28:53 +00:00
|
|
|
|
2003-03-19 06:51:46 +00:00
|
|
|
if (mState & IMAGE_GOTINITIALREFLOW) { // do nothing if we havn't gotten the inital reflow yet
|
|
|
|
if (!(mState & IMAGE_SIZECONSTRAINED) && intrinsicSizeChanged) {
|
|
|
|
NS_ASSERTION(mParent, "No parent to pass the reflow request up to.");
|
|
|
|
if (mParent && presShell) {
|
|
|
|
mState |= NS_FRAME_IS_DIRTY;
|
|
|
|
mParent->ReflowDirtyChild(presShell, NS_STATIC_CAST(nsIFrame*, this));
|
|
|
|
}
|
|
|
|
} else {
|
2003-06-29 03:43:05 +00:00
|
|
|
nsSize s = GetSize();
|
2003-03-19 06:51:46 +00:00
|
|
|
nsRect r(0, 0, s.width, s.height);
|
2004-03-10 03:09:05 +00:00
|
|
|
// Update border+content to account for image change
|
|
|
|
Invalidate(r, PR_FALSE);
|
2002-06-18 21:28:53 +00:00
|
|
|
}
|
2001-10-06 05:08:16 +00:00
|
|
|
}
|
2001-04-15 02:13:49 +00:00
|
|
|
}
|
|
|
|
|
2001-11-07 05:02:42 +00:00
|
|
|
// if src failed to load, determine how to handle it:
|
2003-03-19 03:47:09 +00:00
|
|
|
// - either render the ALT text in this frame, or let the presShell
|
|
|
|
// handle it
|
|
|
|
if (NS_FAILED(aStatus) && aStatus != NS_ERROR_IMAGE_SRC_CHANGED &&
|
|
|
|
presShell) {
|
|
|
|
HandleLoadError(aStatus, presShell);
|
2001-04-15 02:13:49 +00:00
|
|
|
}
|
|
|
|
|
2001-03-22 01:38:35 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2003-03-19 03:47:09 +00:00
|
|
|
nsresult
|
|
|
|
nsImageFrame::FrameChanged(imgIContainer *aContainer,
|
|
|
|
gfxIImageFrame *aNewFrame,
|
|
|
|
nsRect *aDirtyRect)
|
2001-03-22 01:38:35 +00:00
|
|
|
{
|
2003-05-15 03:42:21 +00:00
|
|
|
if (!GetStyleVisibility()->IsVisible()) {
|
2002-07-01 18:17:35 +00:00
|
|
|
return NS_OK;
|
2003-03-19 03:47:09 +00:00
|
|
|
}
|
2002-07-01 18:17:35 +00:00
|
|
|
|
2003-03-19 03:47:09 +00:00
|
|
|
if (IsPendingLoad(aContainer)) {
|
|
|
|
// We don't care about it
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRect r = ConvertPxRectToTwips(*aDirtyRect);
|
|
|
|
mTransform.TransformCoord(&r.x, &r.y, &r.width, &r.height);
|
2001-03-22 01:38:35 +00:00
|
|
|
|
2004-03-10 03:09:05 +00:00
|
|
|
// Update border+content to account for image change
|
|
|
|
Invalidate(r, PR_FALSE);
|
2001-03-22 01:38:35 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-03-13 11:32:43 +00:00
|
|
|
|
2001-03-22 01:38:35 +00:00
|
|
|
|
|
|
|
#define MINMAX(_value,_min,_max) \
|
|
|
|
((_value) < (_min) \
|
|
|
|
? (_min) \
|
|
|
|
: ((_value) > (_max) \
|
|
|
|
? (_max) \
|
|
|
|
: (_value)))
|
|
|
|
|
1998-09-08 22:34:40 +00:00
|
|
|
void
|
1998-11-20 17:21:02 +00:00
|
|
|
nsImageFrame::GetDesiredSize(nsIPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize)
|
1998-09-08 22:34:40 +00:00
|
|
|
{
|
2003-03-19 03:47:09 +00:00
|
|
|
// if mIntrinsicSize.width and height are 0, then we should
|
2001-12-11 03:21:13 +00:00
|
|
|
// check to see if the size is already known by the image container.
|
2003-03-19 03:47:09 +00:00
|
|
|
if (mIntrinsicSize.width == 0 && mIntrinsicSize.height == 0) {
|
|
|
|
nsCOMPtr<imgIRequest> currentRequest;
|
|
|
|
nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(mContent);
|
|
|
|
if (imageLoader) {
|
|
|
|
imageLoader->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST,
|
|
|
|
getter_AddRefs(currentRequest));
|
|
|
|
}
|
|
|
|
nsCOMPtr<imgIContainer> currentContainer;
|
|
|
|
if (currentRequest) {
|
|
|
|
currentRequest->GetImage(getter_AddRefs(currentContainer));
|
|
|
|
}
|
|
|
|
|
2002-03-26 20:14:05 +00:00
|
|
|
float p2t;
|
2004-02-11 04:57:07 +00:00
|
|
|
p2t = aPresContext->PixelsToTwips();
|
2002-03-26 20:14:05 +00:00
|
|
|
|
2003-03-19 03:47:09 +00:00
|
|
|
if (currentContainer) {
|
|
|
|
RecalculateTransform(currentContainer);
|
|
|
|
} else {
|
|
|
|
// image request is null or image size not known, probably an
|
|
|
|
// invalid image specified
|
|
|
|
// - make the image big enough for the icon (it may not be
|
|
|
|
// used if inline alt expansion is used instead)
|
|
|
|
// XXX: we need this in composer, but it is also good for
|
|
|
|
// XXX: general quirks mode to always have room for the icon
|
2003-12-24 21:51:50 +00:00
|
|
|
if (aPresContext->CompatibilityMode() == eCompatibility_NavQuirks) {
|
2003-03-19 03:47:09 +00:00
|
|
|
mIntrinsicSize.SizeTo(NSIntPixelsToTwips(ICON_SIZE+(2*(ICON_PADDING+ALT_BORDER_WIDTH)), p2t),
|
|
|
|
NSIntPixelsToTwips(ICON_SIZE+(2*(ICON_PADDING+ALT_BORDER_WIDTH)), p2t));
|
2001-10-06 08:19:44 +00:00
|
|
|
}
|
2003-03-19 03:47:09 +00:00
|
|
|
RecalculateTransform(nsnull);
|
2001-10-06 05:08:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-04-17 09:03:20 +00:00
|
|
|
float t2p, sp2t;
|
2004-02-11 04:57:07 +00:00
|
|
|
t2p = aPresContext->TwipsToPixels();
|
2001-04-17 09:03:20 +00:00
|
|
|
aPresContext->GetScaledPixelsToTwips(&sp2t);
|
|
|
|
|
|
|
|
// convert from normal twips to scaled twips (printing...)
|
2001-12-11 03:21:13 +00:00
|
|
|
float t2st = t2p * sp2t; // twips to scaled twips
|
|
|
|
nscoord intrinsicWidth =
|
|
|
|
NSToCoordRound(float(mIntrinsicSize.width) * t2st);
|
|
|
|
nscoord intrinsicHeight =
|
|
|
|
NSToCoordRound(float(mIntrinsicSize.height) * t2st);
|
|
|
|
|
|
|
|
// Determine whether the image has fixed content width
|
|
|
|
nscoord widthConstraint = aReflowState.mComputedWidth;
|
|
|
|
nscoord minWidth = aReflowState.mComputedMinWidth;
|
|
|
|
nscoord maxWidth = aReflowState.mComputedMaxWidth;
|
|
|
|
|
|
|
|
// Determine whether the image has fixed content height
|
|
|
|
nscoord heightConstraint = aReflowState.mComputedHeight;
|
|
|
|
nscoord minHeight = aReflowState.mComputedMinHeight;
|
|
|
|
nscoord maxHeight = aReflowState.mComputedMaxHeight;
|
|
|
|
|
|
|
|
PRBool isAutoWidth = widthConstraint == NS_INTRINSICSIZE;
|
2003-03-19 03:47:09 +00:00
|
|
|
if (isAutoWidth) {
|
2001-12-11 03:21:13 +00:00
|
|
|
widthConstraint = intrinsicWidth;
|
2003-03-19 03:47:09 +00:00
|
|
|
}
|
2001-12-11 03:21:13 +00:00
|
|
|
PRBool isAutoHeight = heightConstraint == NS_UNCONSTRAINEDSIZE;
|
2003-03-19 03:47:09 +00:00
|
|
|
if (isAutoHeight) {
|
2001-12-11 03:21:13 +00:00
|
|
|
heightConstraint = intrinsicHeight;
|
2003-03-19 03:47:09 +00:00
|
|
|
}
|
2001-12-11 03:21:13 +00:00
|
|
|
|
|
|
|
nscoord newWidth = MINMAX(widthConstraint, minWidth, maxWidth);
|
|
|
|
nscoord newHeight = MINMAX(heightConstraint, minHeight, maxHeight);
|
|
|
|
|
2003-03-19 03:47:09 +00:00
|
|
|
if (isAutoWidth && newWidth != intrinsicWidth) {
|
2001-12-11 03:21:13 +00:00
|
|
|
isAutoWidth = PR_FALSE;
|
2003-03-19 03:47:09 +00:00
|
|
|
}
|
|
|
|
if (isAutoHeight && newHeight != intrinsicHeight) {
|
2001-12-11 03:21:13 +00:00
|
|
|
isAutoHeight = PR_FALSE;
|
2003-03-19 03:47:09 +00:00
|
|
|
}
|
2001-12-11 03:21:13 +00:00
|
|
|
|
2004-02-03 20:30:02 +00:00
|
|
|
// XXXldb This isn't quite right -- if an image has both 'max-width'
|
|
|
|
// and 'max-height', both smaller than the intrinsic dimensions but with
|
|
|
|
// different ratios to the intrinsic dimensions, then the image should
|
|
|
|
// stay in proportion, but this leaves the image misproportioned.
|
2001-12-11 03:21:13 +00:00
|
|
|
if (isAutoWidth) {
|
|
|
|
if (!isAutoHeight && intrinsicHeight != 0) {
|
|
|
|
newWidth = (intrinsicWidth * newHeight) / intrinsicHeight;
|
2001-03-22 01:38:35 +00:00
|
|
|
}
|
|
|
|
} else {
|
2001-12-11 03:21:13 +00:00
|
|
|
if (isAutoHeight && intrinsicWidth != 0) {
|
|
|
|
newHeight = (intrinsicHeight * newWidth) / intrinsicWidth;
|
|
|
|
}
|
2001-03-22 01:38:35 +00:00
|
|
|
}
|
|
|
|
|
2003-03-19 03:47:09 +00:00
|
|
|
if (mComputedSize.width != newWidth || mComputedSize.height != newHeight) {
|
|
|
|
mComputedSize.SizeTo(newWidth, newHeight);
|
|
|
|
RecalculateTransform(nsnull);
|
2001-04-15 02:13:49 +00:00
|
|
|
}
|
2001-03-22 01:38:35 +00:00
|
|
|
|
|
|
|
aDesiredSize.width = mComputedSize.width;
|
|
|
|
aDesiredSize.height = mComputedSize.height;
|
1998-09-08 22:34:40 +00:00
|
|
|
}
|
|
|
|
|
1998-11-20 17:21:02 +00:00
|
|
|
void
|
|
|
|
nsImageFrame::GetInnerArea(nsIPresContext* aPresContext,
|
|
|
|
nsRect& aInnerArea) const
|
|
|
|
{
|
|
|
|
aInnerArea.x = mBorderPadding.left;
|
2003-03-19 03:47:09 +00:00
|
|
|
aInnerArea.y = mPrevInFlow ? 0 : mBorderPadding.top;
|
|
|
|
aInnerArea.width = mRect.width - mBorderPadding.left - mBorderPadding.right;
|
|
|
|
aInnerArea.height = mRect.height -
|
|
|
|
(mPrevInFlow ? 0 : mBorderPadding.top) -
|
|
|
|
(mNextInFlow ? 0 : mBorderPadding.bottom);
|
2001-11-01 15:31:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// get the offset into the content area of the image where aImg starts if it is a continuation.
|
|
|
|
nscoord
|
|
|
|
nsImageFrame::GetContinuationOffset(nscoord* aWidth) const
|
|
|
|
{
|
|
|
|
nscoord offset = 0;
|
|
|
|
if (aWidth) {
|
|
|
|
*aWidth = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mPrevInFlow) {
|
|
|
|
for (nsIFrame* prevInFlow = mPrevInFlow ; prevInFlow; prevInFlow->GetPrevInFlow(&prevInFlow)) {
|
2003-06-29 03:43:05 +00:00
|
|
|
nsRect rect = prevInFlow->GetRect();
|
2001-11-01 15:31:13 +00:00
|
|
|
if (aWidth) {
|
|
|
|
*aWidth = rect.width;
|
|
|
|
}
|
|
|
|
offset += rect.height;
|
|
|
|
}
|
|
|
|
offset -= mBorderPadding.top;
|
|
|
|
offset = PR_MAX(0, offset);
|
|
|
|
}
|
|
|
|
return offset;
|
1998-11-20 17:21:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 06:03:41 +00:00
|
|
|
nsImageFrame::Reflow(nsIPresContext* aPresContext,
|
1998-11-20 17:21:02 +00:00
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
2000-04-21 14:59:47 +00:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsImageFrame", aReflowState.reason);
|
2001-11-14 13:40:03 +00:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aStatus);
|
1998-11-20 17:21:02 +00:00
|
|
|
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
|
2000-05-14 04:43:52 +00:00
|
|
|
("enter nsImageFrame::Reflow: availSize=%d,%d",
|
1999-01-05 23:31:18 +00:00
|
|
|
aReflowState.availableWidth, aReflowState.availableHeight));
|
1998-11-20 17:21:02 +00:00
|
|
|
|
|
|
|
NS_PRECONDITION(mState & NS_FRAME_IN_REFLOW, "frame is not in reflow");
|
|
|
|
|
2001-11-01 15:31:13 +00:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
|
2001-03-06 00:47:46 +00:00
|
|
|
// see if we have a frozen size (i.e. a fixed width and height)
|
2003-02-24 22:20:26 +00:00
|
|
|
if (HaveFixedSize(aReflowState)) {
|
|
|
|
mState |= IMAGE_SIZECONSTRAINED;
|
|
|
|
} else {
|
2003-03-19 03:47:09 +00:00
|
|
|
mState &= ~IMAGE_SIZECONSTRAINED;
|
2003-02-24 22:20:26 +00:00
|
|
|
}
|
2001-03-06 00:47:46 +00:00
|
|
|
|
2003-03-19 03:47:09 +00:00
|
|
|
if (aReflowState.reason == eReflowReason_Initial) {
|
2003-02-24 22:20:26 +00:00
|
|
|
mState |= IMAGE_GOTINITIALREFLOW;
|
2003-03-19 03:47:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set our borderpadding so that if GetDesiredSize has to recalc the
|
|
|
|
// transform it can.
|
|
|
|
mBorderPadding = aReflowState.mComputedBorderPadding;
|
2001-03-22 01:38:35 +00:00
|
|
|
|
2001-11-01 15:31:13 +00:00
|
|
|
// get the desired size of the complete image
|
1999-11-24 06:03:41 +00:00
|
|
|
GetDesiredSize(aPresContext, aReflowState, aMetrics);
|
2001-11-01 15:31:13 +00:00
|
|
|
|
|
|
|
// add borders and padding
|
|
|
|
aMetrics.width += mBorderPadding.left + mBorderPadding.right;
|
|
|
|
aMetrics.height += mBorderPadding.top + mBorderPadding.bottom;
|
|
|
|
|
|
|
|
if (mPrevInFlow) {
|
|
|
|
nscoord y = GetContinuationOffset(&aMetrics.width);
|
|
|
|
aMetrics.height -= y + mBorderPadding.top;
|
|
|
|
aMetrics.height = PR_MAX(0, aMetrics.height);
|
|
|
|
}
|
|
|
|
|
2002-01-11 19:32:55 +00:00
|
|
|
|
|
|
|
// we have to split images if we are:
|
|
|
|
// in Paginated mode, we need to have a constrained height, and have a height larger than our available height
|
2002-08-29 01:44:15 +00:00
|
|
|
PRUint32 loadStatus = imgIRequest::STATUS_NONE;
|
2003-03-19 03:47:09 +00:00
|
|
|
nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(mContent);
|
|
|
|
NS_ASSERTION(imageLoader, "No content node??");
|
|
|
|
if (imageLoader) {
|
|
|
|
nsCOMPtr<imgIRequest> currentRequest;
|
|
|
|
imageLoader->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST,
|
|
|
|
getter_AddRefs(currentRequest));
|
|
|
|
if (currentRequest) {
|
|
|
|
currentRequest->GetImageStatus(&loadStatus);
|
|
|
|
}
|
2002-08-29 01:44:15 +00:00
|
|
|
}
|
2004-03-03 18:24:20 +00:00
|
|
|
if (aPresContext->IsPaginated() &&
|
2003-02-24 22:20:26 +00:00
|
|
|
((loadStatus & imgIRequest::STATUS_SIZE_AVAILABLE) || (mState & IMAGE_SIZECONSTRAINED)) &&
|
2003-03-19 03:47:09 +00:00
|
|
|
NS_UNCONSTRAINEDSIZE != aReflowState.availableHeight &&
|
|
|
|
aMetrics.height > aReflowState.availableHeight) {
|
2001-11-01 15:31:13 +00:00
|
|
|
// split an image frame but not an image control frame
|
2003-10-31 20:19:18 +00:00
|
|
|
if (nsLayoutAtoms::imageFrame == GetType()) {
|
2002-02-25 14:42:12 +00:00
|
|
|
float p2t;
|
|
|
|
aPresContext->GetScaledPixelsToTwips(&p2t);
|
|
|
|
// our desired height was greater than 0, so to avoid infinite splitting, use 1 pixel as the min
|
|
|
|
aMetrics.height = PR_MAX(NSToCoordRound(p2t), aReflowState.availableHeight);
|
2001-11-01 15:31:13 +00:00
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aMetrics.ascent = aMetrics.height;
|
|
|
|
aMetrics.descent = 0;
|
|
|
|
|
2003-01-09 14:26:32 +00:00
|
|
|
if (aMetrics.mComputeMEW) {
|
2003-03-19 03:47:09 +00:00
|
|
|
// If we have a percentage based width, then our MEW is 0
|
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
2000-09-11 21:15:02 +00:00
|
|
|
if (eStyleUnit_Percent == aReflowState.mStylePosition->mWidth.GetUnit()) {
|
2003-01-09 14:26:32 +00:00
|
|
|
aMetrics.mMaxElementWidth = 0;
|
2000-01-30 18:28:38 +00:00
|
|
|
} else {
|
2003-01-09 14:26:32 +00:00
|
|
|
aMetrics.mMaxElementWidth = aMetrics.width;
|
2000-01-30 18:28:38 +00:00
|
|
|
}
|
1998-11-20 17:21:02 +00:00
|
|
|
}
|
2003-03-19 03:47:09 +00:00
|
|
|
|
2000-05-14 04:43:52 +00:00
|
|
|
if (aMetrics.mFlags & NS_REFLOW_CALC_MAX_WIDTH) {
|
|
|
|
aMetrics.mMaximumWidth = aMetrics.width;
|
|
|
|
}
|
1998-11-20 17:21:02 +00:00
|
|
|
|
|
|
|
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
|
2000-05-14 04:43:52 +00:00
|
|
|
("exit nsImageFrame::Reflow: size=%d,%d",
|
1998-11-20 17:21:02 +00:00
|
|
|
aMetrics.width, aMetrics.height));
|
2002-05-28 22:50:43 +00:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aMetrics);
|
1998-11-20 17:21:02 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-09-08 22:34:40 +00:00
|
|
|
// Computes the width of the specified string. aMaxWidth specifies the maximum
|
|
|
|
// width available. Once this limit is reached no more characters are measured.
|
|
|
|
// The number of characters that fit within the maximum width are returned in
|
1998-10-02 01:12:39 +00:00
|
|
|
// aMaxFit. NOTE: it is assumed that the fontmetrics have already been selected
|
|
|
|
// into the rendering context before this is called (for performance). MMP
|
1999-02-12 17:45:58 +00:00
|
|
|
void
|
1998-11-20 17:21:02 +00:00
|
|
|
nsImageFrame::MeasureString(const PRUnichar* aString,
|
|
|
|
PRInt32 aLength,
|
|
|
|
nscoord aMaxWidth,
|
|
|
|
PRUint32& aMaxFit,
|
|
|
|
nsIRenderingContext& aContext)
|
1998-09-08 22:34:40 +00:00
|
|
|
{
|
|
|
|
nscoord totalWidth = 0;
|
|
|
|
nscoord spaceWidth;
|
1998-10-02 01:12:39 +00:00
|
|
|
aContext.GetWidth(' ', spaceWidth);
|
1998-09-08 22:34:40 +00:00
|
|
|
|
|
|
|
aMaxFit = 0;
|
|
|
|
while (aLength > 0) {
|
|
|
|
// Find the next place we can line break
|
|
|
|
PRUint32 len = aLength;
|
|
|
|
PRBool trailingSpace = PR_FALSE;
|
|
|
|
for (PRInt32 i = 0; i < aLength; i++) {
|
|
|
|
if (XP_IS_SPACE(aString[i]) && (i > 0)) {
|
|
|
|
len = i; // don't include the space when measuring
|
|
|
|
trailingSpace = PR_TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Measure this chunk of text, and see if it fits
|
|
|
|
nscoord width;
|
1998-10-02 01:12:39 +00:00
|
|
|
aContext.GetWidth(aString, len, width);
|
1998-09-08 22:34:40 +00:00
|
|
|
PRBool fits = (totalWidth + width) <= aMaxWidth;
|
|
|
|
|
|
|
|
// If it fits on the line, or it's the first word we've processed then
|
|
|
|
// include it
|
|
|
|
if (fits || (0 == totalWidth)) {
|
|
|
|
// New piece fits
|
|
|
|
totalWidth += width;
|
|
|
|
|
|
|
|
// If there's a trailing space then see if it fits as well
|
|
|
|
if (trailingSpace) {
|
|
|
|
if ((totalWidth + spaceWidth) <= aMaxWidth) {
|
|
|
|
totalWidth += spaceWidth;
|
|
|
|
} else {
|
|
|
|
// Space won't fit. Leave it at the end but don't include it in
|
|
|
|
// the width
|
|
|
|
fits = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
len++;
|
|
|
|
}
|
|
|
|
|
|
|
|
aMaxFit += len;
|
|
|
|
aString += len;
|
|
|
|
aLength -= len;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!fits) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Formats the alt-text to fit within the specified rectangle. Breaks lines
|
|
|
|
// between words if a word would extend past the edge of the rectangle
|
|
|
|
void
|
1999-11-24 06:03:41 +00:00
|
|
|
nsImageFrame::DisplayAltText(nsIPresContext* aPresContext,
|
1998-11-20 17:21:02 +00:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsString& aAltText,
|
|
|
|
const nsRect& aRect)
|
1998-09-08 22:34:40 +00:00
|
|
|
{
|
|
|
|
// Set font and color
|
2003-05-15 03:42:21 +00:00
|
|
|
aRenderingContext.SetColor(GetStyleColor()->mColor);
|
2002-05-24 20:11:14 +00:00
|
|
|
SetFontFromStyle(&aRenderingContext, mStyleContext);
|
1998-09-08 22:34:40 +00:00
|
|
|
|
|
|
|
// Format the text to display within the formatting rect
|
1998-10-30 02:08:25 +00:00
|
|
|
nsIFontMetrics* fm;
|
|
|
|
aRenderingContext.GetFontMetrics(fm);
|
1998-09-08 22:34:40 +00:00
|
|
|
|
2001-10-30 22:58:00 +00:00
|
|
|
nscoord maxAscent, maxDescent, height;
|
|
|
|
fm->GetMaxAscent(maxAscent);
|
1998-09-08 22:34:40 +00:00
|
|
|
fm->GetMaxDescent(maxDescent);
|
|
|
|
fm->GetHeight(height);
|
|
|
|
|
|
|
|
// XXX It would be nice if there was a way to have the font metrics tell
|
|
|
|
// use where to break the text given a maximum width. At a minimum we need
|
|
|
|
// to be able to get the break character...
|
2001-06-30 11:02:25 +00:00
|
|
|
const PRUnichar* str = aAltText.get();
|
1998-09-08 22:34:40 +00:00
|
|
|
PRInt32 strLen = aAltText.Length();
|
|
|
|
nscoord y = aRect.y;
|
|
|
|
while ((strLen > 0) && ((y + maxDescent) < aRect.YMost())) {
|
|
|
|
// Determine how much of the text to display on this line
|
|
|
|
PRUint32 maxFit; // number of characters that fit
|
1999-02-12 17:45:58 +00:00
|
|
|
MeasureString(str, strLen, aRect.width, maxFit, aRenderingContext);
|
1998-09-08 22:34:40 +00:00
|
|
|
|
|
|
|
// Display the text
|
2001-10-30 22:58:00 +00:00
|
|
|
aRenderingContext.DrawString(str, maxFit, aRect.x, y + maxAscent);
|
1998-09-08 22:34:40 +00:00
|
|
|
|
|
|
|
// Move to the next line
|
|
|
|
str += maxFit;
|
|
|
|
strLen -= maxFit;
|
|
|
|
y += height;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_RELEASE(fm);
|
|
|
|
}
|
|
|
|
|
2001-02-07 09:57:26 +00:00
|
|
|
struct nsRecessedBorder : public nsStyleBorder {
|
1998-09-08 22:34:40 +00:00
|
|
|
nsRecessedBorder(nscoord aBorderWidth)
|
2001-02-07 09:57:26 +00:00
|
|
|
: nsStyleBorder()
|
1998-09-08 22:34:40 +00:00
|
|
|
{
|
|
|
|
nsStyleCoord styleCoord(aBorderWidth);
|
|
|
|
|
|
|
|
mBorder.SetLeft(styleCoord);
|
|
|
|
mBorder.SetTop(styleCoord);
|
|
|
|
mBorder.SetRight(styleCoord);
|
|
|
|
mBorder.SetBottom(styleCoord);
|
1998-12-07 18:53:07 +00:00
|
|
|
|
|
|
|
mBorderStyle[0] = NS_STYLE_BORDER_STYLE_INSET;
|
|
|
|
mBorderStyle[1] = NS_STYLE_BORDER_STYLE_INSET;
|
|
|
|
mBorderStyle[2] = NS_STYLE_BORDER_STYLE_INSET;
|
|
|
|
mBorderStyle[3] = NS_STYLE_BORDER_STYLE_INSET;
|
|
|
|
|
|
|
|
mBorderColor[0] = 0;
|
|
|
|
mBorderColor[1] = 0;
|
|
|
|
mBorderColor[2] = 0;
|
|
|
|
mBorderColor[3] = 0;
|
|
|
|
|
2001-02-07 09:57:26 +00:00
|
|
|
mHasCachedBorder = PR_FALSE;
|
1998-09-08 22:34:40 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
1998-09-22 03:34:44 +00:00
|
|
|
void
|
1999-11-24 06:03:41 +00:00
|
|
|
nsImageFrame::DisplayAltFeedback(nsIPresContext* aPresContext,
|
1998-11-20 17:21:02 +00:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
2004-02-03 20:30:02 +00:00
|
|
|
imgIRequest* aRequest)
|
1998-09-22 03:34:44 +00:00
|
|
|
{
|
1999-09-16 21:37:37 +00:00
|
|
|
// Calculate the inner area
|
1998-09-22 03:34:44 +00:00
|
|
|
nsRect inner;
|
1999-11-24 06:03:41 +00:00
|
|
|
GetInnerArea(aPresContext, inner);
|
1998-09-22 03:34:44 +00:00
|
|
|
|
1999-09-16 21:37:37 +00:00
|
|
|
// Display a recessed one pixel border
|
|
|
|
float p2t;
|
|
|
|
nscoord borderEdgeWidth;
|
1999-11-24 06:03:41 +00:00
|
|
|
aPresContext->GetScaledPixelsToTwips(&p2t);
|
2001-11-07 05:02:42 +00:00
|
|
|
borderEdgeWidth = NSIntPixelsToTwips(ALT_BORDER_WIDTH, p2t);
|
1999-09-16 21:37:37 +00:00
|
|
|
|
2002-03-26 20:14:05 +00:00
|
|
|
// if inner area is empty, then make it big enough for at least the icon
|
|
|
|
if (inner.IsEmpty()){
|
2003-03-19 03:47:09 +00:00
|
|
|
inner.SizeTo(2*(NSIntPixelsToTwips(ICON_SIZE+ICON_PADDING+ALT_BORDER_WIDTH,p2t)),
|
2002-03-26 20:14:05 +00:00
|
|
|
2*(NSIntPixelsToTwips(ICON_SIZE+ICON_PADDING+ALT_BORDER_WIDTH,p2t)));
|
|
|
|
}
|
|
|
|
|
1999-09-16 21:37:37 +00:00
|
|
|
// Make sure we have enough room to actually render the border within
|
|
|
|
// our frame bounds
|
|
|
|
if ((inner.width < 2 * borderEdgeWidth) || (inner.height < 2 * borderEdgeWidth)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Paint the border
|
|
|
|
nsRecessedBorder recessedBorder(borderEdgeWidth);
|
1998-09-22 03:34:44 +00:00
|
|
|
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this, inner,
|
1999-01-22 22:26:29 +00:00
|
|
|
inner, recessedBorder, mStyleContext, 0);
|
1998-09-22 03:34:44 +00:00
|
|
|
|
|
|
|
// Adjust the inner rect to account for the one pixel recessed border,
|
|
|
|
// and a six pixel padding on each edge
|
2001-11-07 05:02:42 +00:00
|
|
|
inner.Deflate(NSIntPixelsToTwips(ICON_PADDING+ALT_BORDER_WIDTH, p2t),
|
|
|
|
NSIntPixelsToTwips(ICON_PADDING+ALT_BORDER_WIDTH, p2t));
|
1998-09-22 03:34:44 +00:00
|
|
|
if (inner.IsEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-01-18 22:17:12 +00:00
|
|
|
// check if the size of the (deflated) rect is big enough to show the icon
|
|
|
|
// - if not, then just bail, leaving the border rect by itself
|
|
|
|
// NOTE: setting the clip (below) should be enough, but there is a bug in the Linux
|
|
|
|
// rendering context that images are not clipped when a clip rect is set (bugzilla bug 78497)
|
|
|
|
// and also this will be slightly more efficient since we will not try to render any icons
|
|
|
|
// or ALT text into the rect.
|
|
|
|
if (inner.width < NSIntPixelsToTwips(ICON_SIZE, p2t) ||
|
|
|
|
inner.height < NSIntPixelsToTwips(ICON_SIZE, p2t)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1998-09-22 03:34:44 +00:00
|
|
|
// Clip so we don't render outside the inner rect
|
|
|
|
aRenderingContext.PushState();
|
2004-04-23 15:21:24 +00:00
|
|
|
aRenderingContext.SetClipRect(inner, nsClipCombine_kIntersect);
|
1998-09-22 03:34:44 +00:00
|
|
|
|
2004-02-03 20:30:02 +00:00
|
|
|
PRBool dispIcon = gIconLoad ? gIconLoad->mPrefShowPlaceholders : PR_TRUE;
|
1998-09-22 03:34:44 +00:00
|
|
|
|
2002-04-10 14:45:05 +00:00
|
|
|
// Check if we should display image placeholders
|
|
|
|
if (dispIcon) {
|
|
|
|
PRInt32 size = NSIntPixelsToTwips(ICON_SIZE, p2t);
|
1998-09-22 03:34:44 +00:00
|
|
|
|
2002-04-10 14:45:05 +00:00
|
|
|
PRBool iconUsed = PR_FALSE;
|
1998-09-22 03:34:44 +00:00
|
|
|
|
2002-04-10 14:45:05 +00:00
|
|
|
// see if the icon images are present...
|
2004-02-03 20:30:02 +00:00
|
|
|
if (gIconLoad && gIconLoad->mIconsLoaded) {
|
2002-04-10 14:45:05 +00:00
|
|
|
// pick the correct image
|
|
|
|
nsCOMPtr<imgIContainer> imgCon;
|
2004-02-03 20:30:02 +00:00
|
|
|
if (aRequest) {
|
|
|
|
aRequest->GetImage(getter_AddRefs(imgCon));
|
2002-04-10 14:45:05 +00:00
|
|
|
}
|
2003-03-19 03:47:09 +00:00
|
|
|
if (imgCon) {
|
2002-04-10 14:45:05 +00:00
|
|
|
// draw it
|
|
|
|
nsPoint p(inner.x, inner.y);
|
|
|
|
nsRect r(0,0,size,size);
|
|
|
|
aRenderingContext.DrawImage(imgCon, &r, &p);
|
|
|
|
iconUsed = PR_TRUE;
|
|
|
|
}
|
2001-11-07 05:02:42 +00:00
|
|
|
}
|
1998-09-22 03:34:44 +00:00
|
|
|
|
2002-04-10 14:45:05 +00:00
|
|
|
// if we could not draw the image, then just draw some grafitti
|
|
|
|
if (!iconUsed) {
|
|
|
|
nscolor oldColor;
|
|
|
|
aRenderingContext.DrawRect(0,0,size,size);
|
|
|
|
aRenderingContext.GetColor(oldColor);
|
2004-02-03 20:30:02 +00:00
|
|
|
aRenderingContext.SetColor(NS_RGB(0xFF,0,0));
|
2002-04-10 14:45:05 +00:00
|
|
|
aRenderingContext.FillEllipse(NS_STATIC_CAST(int,size/2),NS_STATIC_CAST(int,size/2),
|
|
|
|
NS_STATIC_CAST(int,(size/2)-(2*p2t)),NS_STATIC_CAST(int,(size/2)-(2*p2t)));
|
|
|
|
aRenderingContext.SetColor(oldColor);
|
|
|
|
}
|
2001-11-07 05:02:42 +00:00
|
|
|
|
2002-04-10 14:45:05 +00:00
|
|
|
// Reduce the inner rect by the width of the icon, and leave an
|
|
|
|
// additional ICON_PADDING pixels for padding
|
|
|
|
PRInt32 iconWidth = NSIntPixelsToTwips(ICON_SIZE + ICON_PADDING, p2t);
|
|
|
|
inner.x += iconWidth;
|
|
|
|
inner.width -= iconWidth;
|
|
|
|
}
|
1998-09-22 03:34:44 +00:00
|
|
|
|
|
|
|
// If there's still room, display the alt-text
|
|
|
|
if (!inner.IsEmpty()) {
|
2003-06-29 03:43:05 +00:00
|
|
|
nsIContent* content = GetContent();
|
2001-11-07 05:02:42 +00:00
|
|
|
if (content) {
|
2003-11-19 01:20:56 +00:00
|
|
|
nsAutoString altText;
|
|
|
|
nsCSSFrameConstructor::GetAlternateTextFor(content, content->Tag(),
|
|
|
|
altText);
|
|
|
|
DisplayAltText(aPresContext, aRenderingContext, altText, inner);
|
1998-09-22 03:34:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-04-18 13:13:35 +00:00
|
|
|
aRenderingContext.PopState();
|
1998-09-22 03:34:44 +00:00
|
|
|
}
|
|
|
|
|
1998-09-08 22:34:40 +00:00
|
|
|
NS_METHOD
|
2001-09-19 12:35:19 +00:00
|
|
|
nsImageFrame::Paint(nsIPresContext* aPresContext,
|
1998-11-20 17:21:02 +00:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
2001-09-19 12:35:19 +00:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
PRUint32 aFlags)
|
1998-09-08 22:34:40 +00:00
|
|
|
{
|
2001-01-27 14:09:34 +00:00
|
|
|
PRBool isVisible;
|
|
|
|
if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_TRUE, &isVisible)) &&
|
|
|
|
isVisible && mRect.width && mRect.height) {
|
2001-04-25 19:52:49 +00:00
|
|
|
// If painting is suppressed, we need to stop image painting. We
|
|
|
|
// have to cover <img> here because of input image controls.
|
|
|
|
PRBool paintingSuppressed = PR_FALSE;
|
2003-12-21 05:36:36 +00:00
|
|
|
aPresContext->PresShell()->IsPaintingSuppressed(&paintingSuppressed);
|
2003-03-19 03:47:09 +00:00
|
|
|
if (paintingSuppressed) {
|
2001-04-25 19:52:49 +00:00
|
|
|
return NS_OK;
|
2003-03-19 03:47:09 +00:00
|
|
|
}
|
2001-04-25 19:52:49 +00:00
|
|
|
|
2002-04-09 01:16:48 +00:00
|
|
|
// First paint background and borders, which should be in the
|
|
|
|
// FOREGROUND or BACKGROUND paint layer if the element is
|
2003-05-03 02:34:42 +00:00
|
|
|
// inline-level or block-level, respectively (bug 36710). (See
|
|
|
|
// CSS2 9.5, which is the rationale for paint layers.)
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleDisplay* display = GetStyleDisplay();
|
2002-04-09 01:16:48 +00:00
|
|
|
nsFramePaintLayer backgroundLayer = display->IsBlockLevel()
|
|
|
|
? NS_FRAME_PAINT_LAYER_BACKGROUND
|
|
|
|
: NS_FRAME_PAINT_LAYER_FOREGROUND;
|
|
|
|
if (aWhichLayer == backgroundLayer) {
|
2002-12-23 22:05:47 +00:00
|
|
|
PaintSelf(aPresContext, aRenderingContext, aDirtyRect);
|
2001-11-01 15:31:13 +00:00
|
|
|
}
|
1998-09-08 22:34:40 +00:00
|
|
|
|
2003-11-06 16:03:34 +00:00
|
|
|
if (mComputedSize.width != 0 && mComputedSize.height != 0) {
|
|
|
|
nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(mContent);
|
|
|
|
NS_ASSERTION(mContent, "Not an image loading content?");
|
2003-03-19 03:47:09 +00:00
|
|
|
|
2003-11-06 16:03:34 +00:00
|
|
|
nsCOMPtr<imgIRequest> currentRequest;
|
|
|
|
if (imageLoader) {
|
|
|
|
imageLoader->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST,
|
|
|
|
getter_AddRefs(currentRequest));
|
|
|
|
}
|
2003-03-19 03:47:09 +00:00
|
|
|
|
2003-11-06 16:03:34 +00:00
|
|
|
nsCOMPtr<imgIContainer> imgCon;
|
2001-03-22 01:38:35 +00:00
|
|
|
|
2003-11-06 16:03:34 +00:00
|
|
|
PRUint32 loadStatus = imgIRequest::STATUS_ERROR;
|
2001-10-06 05:08:16 +00:00
|
|
|
|
2003-11-06 16:03:34 +00:00
|
|
|
if (currentRequest) {
|
|
|
|
currentRequest->GetImage(getter_AddRefs(imgCon));
|
|
|
|
currentRequest->GetImageStatus(&loadStatus);
|
|
|
|
}
|
2001-04-17 09:03:20 +00:00
|
|
|
|
2003-11-06 16:03:34 +00:00
|
|
|
if (loadStatus & imgIRequest::STATUS_ERROR || !imgCon) {
|
|
|
|
// No image yet, or image load failed. Draw the alt-text and an icon
|
|
|
|
// indicating the status (unless image is blocked, in which case we show nothing)
|
2002-03-26 20:14:05 +00:00
|
|
|
|
2003-11-06 16:03:34 +00:00
|
|
|
PRBool imageBlocked = PR_FALSE;
|
|
|
|
if (imageLoader) {
|
|
|
|
imageLoader->GetImageBlocked(&imageBlocked);
|
|
|
|
}
|
2003-03-19 03:47:09 +00:00
|
|
|
|
2003-11-06 16:03:34 +00:00
|
|
|
if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer &&
|
2004-02-03 20:30:02 +00:00
|
|
|
(!imageBlocked || gIconLoad->mPrefAllImagesBlocked)) {
|
2003-11-06 16:03:34 +00:00
|
|
|
DisplayAltFeedback(aPresContext, aRenderingContext,
|
|
|
|
(loadStatus & imgIRequest::STATUS_ERROR)
|
2004-02-03 20:30:02 +00:00
|
|
|
? gIconLoad->mBrokenImage
|
|
|
|
: gIconLoad->mLoadingImage);
|
2003-03-19 03:47:09 +00:00
|
|
|
}
|
2003-11-06 16:03:34 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
PRBool paintOutline = PR_FALSE;
|
|
|
|
if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer && imgCon) {
|
|
|
|
// Render the image into our content area (the area inside
|
|
|
|
// the borders and padding)
|
|
|
|
nsRect inner;
|
|
|
|
GetInnerArea(aPresContext, inner);
|
|
|
|
nsRect paintArea(inner);
|
|
|
|
|
|
|
|
nscoord offsetY = 0;
|
|
|
|
|
|
|
|
// if the image is split account for y-offset
|
|
|
|
if (mPrevInFlow) {
|
|
|
|
offsetY = GetContinuationOffset();
|
|
|
|
}
|
2001-03-22 01:38:35 +00:00
|
|
|
|
2003-11-06 16:03:34 +00:00
|
|
|
if (mIntrinsicSize == mComputedSize) {
|
|
|
|
// Find the actual rect to be painted to in the rendering context
|
|
|
|
paintArea.IntersectRect(paintArea, aDirtyRect);
|
2001-11-01 15:31:13 +00:00
|
|
|
|
2003-11-06 16:03:34 +00:00
|
|
|
// Point to paint to
|
|
|
|
nsPoint p(paintArea.x, paintArea.y);
|
2003-03-19 03:47:09 +00:00
|
|
|
|
2003-11-06 16:03:34 +00:00
|
|
|
// Rect in the image to paint
|
|
|
|
nsRect r(paintArea.x - inner.x,
|
|
|
|
paintArea.y - inner.y + offsetY,
|
|
|
|
paintArea.width,
|
|
|
|
paintArea.height);
|
2003-03-19 03:47:09 +00:00
|
|
|
|
2003-11-06 16:03:34 +00:00
|
|
|
aRenderingContext.DrawImage(imgCon, &r, &p);
|
|
|
|
} else {
|
|
|
|
// The computed size is the total size of all the continuations,
|
|
|
|
// including ourselves. Note that we're basically inverting
|
|
|
|
// mTransform here (would it too much to ask for
|
|
|
|
// nsTransform2D::Invert?), since we need to convert from
|
|
|
|
// rendering context coords to image coords...
|
|
|
|
nsTransform2D trans;
|
|
|
|
trans.SetToScale((float(mIntrinsicSize.width) / float(mComputedSize.width)),
|
|
|
|
(float(mIntrinsicSize.height) / float(mComputedSize.height)));
|
2003-03-19 03:47:09 +00:00
|
|
|
|
2003-11-06 16:03:34 +00:00
|
|
|
// XXXbz it looks like we should take
|
|
|
|
// IntersectRect(paintArea, aDirtyRect) here too, but things
|
|
|
|
// get very weird if I do that ....
|
|
|
|
// paintArea.IntersectRect(paintArea, aDirtyRect);
|
2003-03-19 03:47:09 +00:00
|
|
|
|
2003-11-06 16:03:34 +00:00
|
|
|
// dirty rect in image our coord size...
|
|
|
|
nsRect r(paintArea.x - inner.x,
|
|
|
|
paintArea.y - inner.y + offsetY,
|
|
|
|
paintArea.width,
|
|
|
|
paintArea.height);
|
|
|
|
|
|
|
|
// Transform that to image coords
|
|
|
|
trans.TransformCoord(&r.x, &r.y, &r.width, &r.height);
|
2003-03-19 03:47:09 +00:00
|
|
|
|
2003-11-06 16:03:34 +00:00
|
|
|
// dest rect in our coords
|
|
|
|
nsRect d(paintArea.x, paintArea.y,
|
|
|
|
paintArea.width, paintArea.height);
|
2003-03-19 03:47:09 +00:00
|
|
|
|
2003-11-06 16:03:34 +00:00
|
|
|
aRenderingContext.DrawScaledImage(imgCon, &r, &d);
|
|
|
|
}
|
|
|
|
paintOutline = PR_TRUE;
|
2001-03-22 01:38:35 +00:00
|
|
|
}
|
massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-08 21:31:05 +00:00
|
|
|
|
2000-08-18 06:27:42 +00:00
|
|
|
nsImageMap* map = GetImageMap(aPresContext);
|
1999-04-10 17:32:33 +00:00
|
|
|
if (nsnull != map) {
|
|
|
|
nsRect inner;
|
1999-11-24 06:03:41 +00:00
|
|
|
GetInnerArea(aPresContext, inner);
|
1999-04-10 17:32:33 +00:00
|
|
|
aRenderingContext.SetColor(NS_RGB(0, 0, 0));
|
2003-11-06 16:03:34 +00:00
|
|
|
aRenderingContext.SetLineStyle(nsLineStyle_kDotted);
|
1999-04-10 17:32:33 +00:00
|
|
|
aRenderingContext.PushState();
|
|
|
|
aRenderingContext.Translate(inner.x, inner.y);
|
|
|
|
map->Draw(aPresContext, aRenderingContext);
|
2004-04-18 13:13:35 +00:00
|
|
|
aRenderingContext.PopState();
|
2003-11-06 16:03:34 +00:00
|
|
|
paintOutline = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// paint the outline in the overlay layer (or if there is an image map) until the
|
|
|
|
// general problem of painting it outside the border box is solved.
|
|
|
|
if (paintOutline) {
|
|
|
|
const nsStyleBorder* myBorder = GetStyleBorder();
|
|
|
|
const nsStyleOutline* myOutline = GetStyleOutline();
|
|
|
|
nsRect rect(0, 0, mRect.width, mRect.height);
|
|
|
|
nsCSSRendering::PaintOutline(aPresContext, aRenderingContext, this,
|
|
|
|
aDirtyRect, rect, *myBorder,
|
|
|
|
*myOutline, mStyleContext, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if ((NS_FRAME_PAINT_LAYER_DEBUG == aWhichLayer) &&
|
|
|
|
GetShowFrameBorders()) {
|
|
|
|
nsImageMap* map = GetImageMap(aPresContext);
|
|
|
|
if (nsnull != map) {
|
|
|
|
nsRect inner;
|
|
|
|
GetInnerArea(aPresContext, inner);
|
|
|
|
aRenderingContext.SetColor(NS_RGB(0, 0, 0));
|
|
|
|
aRenderingContext.PushState();
|
|
|
|
aRenderingContext.Translate(inner.x, inner.y);
|
|
|
|
map->Draw(aPresContext, aRenderingContext);
|
2004-04-18 13:13:35 +00:00
|
|
|
aRenderingContext.PopState();
|
2003-11-06 16:03:34 +00:00
|
|
|
}
|
1999-04-10 17:32:33 +00:00
|
|
|
}
|
1999-11-01 22:12:45 +00:00
|
|
|
#endif
|
2003-11-06 16:03:34 +00:00
|
|
|
}
|
1999-04-10 17:32:33 +00:00
|
|
|
}
|
1998-09-08 22:34:40 +00:00
|
|
|
}
|
2001-12-18 01:29:49 +00:00
|
|
|
PRInt16 displaySelection = 0;
|
|
|
|
|
|
|
|
nsresult result;
|
2003-12-21 05:36:36 +00:00
|
|
|
result = aPresContext->PresShell()->GetSelectionFlags(&displaySelection);
|
2001-12-18 01:29:49 +00:00
|
|
|
if (NS_FAILED(result))
|
|
|
|
return result;
|
|
|
|
if (!(displaySelection & nsISelectionDisplay::DISPLAY_IMAGES))
|
|
|
|
return NS_OK;//no need to check the blue border, we cannot be drawn selected
|
2003-04-22 23:18:34 +00:00
|
|
|
//insert hook here for image selection drawing
|
|
|
|
#if IMAGE_EDITOR_CHECK
|
|
|
|
//check to see if this frame is in an editor context
|
|
|
|
//isEditor check. this needs to be changed to have better way to check
|
|
|
|
if (displaySelection == nsISelectionDisplay::DISPLAY_ALL)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsISelectionController> selCon;
|
|
|
|
result = GetSelectionController(aPresContext, getter_AddRefs(selCon));
|
|
|
|
if (NS_SUCCEEDED(result) && selCon)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsISelection> selection;
|
|
|
|
result = selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection));
|
|
|
|
if (NS_SUCCEEDED(result) && selection)
|
|
|
|
{
|
|
|
|
PRInt32 rangeCount;
|
|
|
|
selection->GetRangeCount(&rangeCount);
|
|
|
|
if (rangeCount == 1) //if not one then let code drop to nsFrame::Paint
|
|
|
|
{
|
2003-07-28 21:25:13 +00:00
|
|
|
nsCOMPtr<nsIContent> parentContent = mContent->GetParent();
|
2003-04-22 23:18:34 +00:00
|
|
|
if (parentContent)
|
|
|
|
{
|
2003-09-27 04:18:26 +00:00
|
|
|
PRInt32 thisOffset = parentContent->IndexOf(mContent);
|
2003-04-22 23:18:34 +00:00
|
|
|
nsCOMPtr<nsIDOMNode> parentNode = do_QueryInterface(parentContent);
|
|
|
|
nsCOMPtr<nsIDOMNode> rangeNode;
|
|
|
|
PRInt32 rangeOffset;
|
|
|
|
nsCOMPtr<nsIDOMRange> range;
|
|
|
|
selection->GetRangeAt(0,getter_AddRefs(range));
|
|
|
|
if (range)
|
|
|
|
{
|
|
|
|
range->GetStartContainer(getter_AddRefs(rangeNode));
|
|
|
|
range->GetStartOffset(&rangeOffset);
|
|
|
|
|
|
|
|
if (parentNode && rangeNode && (rangeNode == parentNode) && rangeOffset == thisOffset)
|
|
|
|
{
|
|
|
|
range->GetEndContainer(getter_AddRefs(rangeNode));
|
|
|
|
range->GetEndOffset(&rangeOffset);
|
|
|
|
if ((rangeNode == parentNode) && (rangeOffset == (thisOffset +1))) //+1 since that would mean this whole content is selected only
|
|
|
|
return NS_OK; //do not allow nsFrame do draw any further selection
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
1999-05-17 00:21:18 +00:00
|
|
|
|
2002-04-11 01:11:23 +00:00
|
|
|
return nsFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, nsISelectionDisplay::DISPLAY_IMAGES);
|
2002-08-17 01:46:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsImageFrame::GetImageMap(nsIPresContext *aPresContext, nsIImageMap **aImageMap)
|
|
|
|
{
|
|
|
|
nsImageMap *map = GetImageMap(aPresContext);
|
2003-03-19 03:47:09 +00:00
|
|
|
return CallQueryInterface(map, aImageMap);
|
1998-09-08 22:34:40 +00:00
|
|
|
}
|
|
|
|
|
1999-01-09 00:13:19 +00:00
|
|
|
nsImageMap*
|
2000-08-18 06:27:42 +00:00
|
|
|
nsImageFrame::GetImageMap(nsIPresContext* aPresContext)
|
1998-09-08 22:34:40 +00:00
|
|
|
{
|
2001-04-18 00:14:34 +00:00
|
|
|
if (!mImageMap) {
|
2003-07-28 21:25:13 +00:00
|
|
|
nsIDocument* doc = mContent->GetDocument();
|
2001-04-18 00:14:34 +00:00
|
|
|
if (!doc) {
|
1998-09-08 22:34:40 +00:00
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
2001-04-18 00:14:34 +00:00
|
|
|
nsAutoString usemap;
|
2002-05-20 22:47:02 +00:00
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::usemap, usemap);
|
1999-08-19 22:22:02 +00:00
|
|
|
|
2004-02-19 18:56:13 +00:00
|
|
|
nsCOMPtr<nsIDOMHTMLMapElement> map = nsImageMapUtils::FindImageMap(doc,usemap);
|
|
|
|
if (map) {
|
2001-04-18 00:14:34 +00:00
|
|
|
mImageMap = new nsImageMap();
|
|
|
|
if (mImageMap) {
|
|
|
|
NS_ADDREF(mImageMap);
|
2003-12-21 05:36:36 +00:00
|
|
|
mImageMap->Init(aPresContext->PresShell(), this, map);
|
1998-09-08 22:34:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-01-09 00:13:19 +00:00
|
|
|
|
1998-09-08 22:34:40 +00:00
|
|
|
return mImageMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-11-24 06:03:41 +00:00
|
|
|
nsImageFrame::TriggerLink(nsIPresContext* aPresContext,
|
2002-11-20 00:44:26 +00:00
|
|
|
nsIURI* aURI,
|
1998-11-20 17:21:02 +00:00
|
|
|
const nsString& aTargetSpec,
|
|
|
|
PRBool aClick)
|
1998-09-08 22:34:40 +00:00
|
|
|
{
|
2000-08-08 20:35:12 +00:00
|
|
|
// We get here with server side image map
|
2004-02-01 10:09:07 +00:00
|
|
|
nsILinkHandler *handler = aPresContext->GetLinkHandler();
|
|
|
|
if (handler) {
|
1998-09-08 22:34:40 +00:00
|
|
|
if (aClick) {
|
2000-08-08 20:35:12 +00:00
|
|
|
// Check that this page is allowed to load this URI.
|
|
|
|
// Almost a copy of the similarly named method in nsGenericElement
|
|
|
|
nsresult rv;
|
2001-07-25 07:54:28 +00:00
|
|
|
nsCOMPtr<nsIScriptSecurityManager> securityManager =
|
|
|
|
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
|
2000-08-08 20:35:12 +00:00
|
|
|
|
2003-12-21 05:36:36 +00:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return;
|
|
|
|
|
|
|
|
nsIPresShell *ps = aPresContext->GetPresShell();
|
|
|
|
if (!ps)
|
|
|
|
return;
|
|
|
|
|
2000-08-08 20:35:12 +00:00
|
|
|
nsCOMPtr<nsIDocument> doc;
|
2003-12-21 05:36:36 +00:00
|
|
|
rv = ps->GetDocument(getter_AddRefs(doc));
|
2000-08-08 20:35:12 +00:00
|
|
|
|
2004-04-25 16:55:27 +00:00
|
|
|
if (doc) {
|
|
|
|
rv = securityManager->
|
|
|
|
CheckLoadURIWithPrincipal(doc->GetPrincipal(), aURI,
|
|
|
|
nsIScriptSecurityManager::STANDARD);
|
2003-10-22 06:09:48 +00:00
|
|
|
|
|
|
|
// Only pass off the click event if the script security manager
|
|
|
|
// says it's ok.
|
|
|
|
if (NS_SUCCEEDED(rv))
|
|
|
|
handler->OnLinkClick(mContent, eLinkVerb_Replace, aURI,
|
|
|
|
aTargetSpec.get());
|
|
|
|
}
|
1998-09-08 22:34:40 +00:00
|
|
|
}
|
|
|
|
else {
|
2002-11-20 00:44:26 +00:00
|
|
|
handler->OnOverLink(mContent, aURI, aTargetSpec.get());
|
1998-09-08 22:34:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
1998-11-20 17:21:02 +00:00
|
|
|
nsImageFrame::IsServerImageMap()
|
1998-09-08 22:34:40 +00:00
|
|
|
{
|
|
|
|
nsAutoString ismap;
|
1999-07-08 19:38:08 +00:00
|
|
|
return NS_CONTENT_ATTR_HAS_VALUE ==
|
2002-05-20 22:47:02 +00:00
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::ismap, ismap);
|
1998-09-08 22:34:40 +00:00
|
|
|
}
|
|
|
|
|
1999-07-08 19:38:08 +00:00
|
|
|
//XXX the event come's in in view relative coords, but really should
|
|
|
|
//be in frame relative coords by the time it hits our frame.
|
|
|
|
|
|
|
|
// Translate an point that is relative to our view (or a containing
|
|
|
|
// view) into a localized pixel coordinate that is relative to the
|
|
|
|
// content area of this frame (inside the border+padding).
|
|
|
|
void
|
1999-11-24 06:03:41 +00:00
|
|
|
nsImageFrame::TranslateEventCoords(nsIPresContext* aPresContext,
|
1999-07-08 19:38:08 +00:00
|
|
|
const nsPoint& aPoint,
|
|
|
|
nsPoint& aResult)
|
|
|
|
{
|
|
|
|
nscoord x = aPoint.x;
|
|
|
|
nscoord y = aPoint.y;
|
|
|
|
|
|
|
|
// If we have a view then the event coordinates are already relative
|
|
|
|
// to this frame; otherwise we have to adjust the coordinates
|
|
|
|
// appropriately.
|
2003-06-19 23:44:01 +00:00
|
|
|
if (!HasView()) {
|
1999-07-08 19:38:08 +00:00
|
|
|
nsPoint offset;
|
2003-06-19 23:44:01 +00:00
|
|
|
nsIView *view;
|
1999-11-24 06:03:41 +00:00
|
|
|
GetOffsetFromView(aPresContext, offset, &view);
|
1999-07-08 19:38:08 +00:00
|
|
|
if (nsnull != view) {
|
|
|
|
x -= offset.x;
|
|
|
|
y -= offset.y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Subtract out border and padding here so that the coordinates are
|
|
|
|
// now relative to the content area of this frame.
|
|
|
|
nsRect inner;
|
1999-11-24 06:03:41 +00:00
|
|
|
GetInnerArea(aPresContext, inner);
|
1999-07-08 19:38:08 +00:00
|
|
|
x -= inner.x;
|
|
|
|
y -= inner.y;
|
|
|
|
|
|
|
|
// Translate the coordinates from twips to pixels
|
|
|
|
float t2p;
|
2004-02-11 04:57:07 +00:00
|
|
|
t2p = aPresContext->TwipsToPixels();
|
1999-07-08 19:38:08 +00:00
|
|
|
aResult.x = NSTwipsToIntPixels(x, t2p);
|
|
|
|
aResult.y = NSTwipsToIntPixels(y, t2p);
|
|
|
|
}
|
|
|
|
|
1999-07-08 19:44:42 +00:00
|
|
|
PRBool
|
2004-02-10 16:57:00 +00:00
|
|
|
nsImageFrame::GetAnchorHREFAndTarget(nsIURI** aHref, nsString& aTarget)
|
1999-07-08 19:38:08 +00:00
|
|
|
{
|
1999-07-08 19:44:42 +00:00
|
|
|
PRBool status = PR_FALSE;
|
2001-04-11 08:12:10 +00:00
|
|
|
aTarget.Truncate();
|
1999-07-08 19:38:08 +00:00
|
|
|
|
|
|
|
// Walk up the content tree, looking for an nsIDOMAnchorElement
|
2003-07-28 21:25:13 +00:00
|
|
|
for (nsIContent* content = mContent->GetParent();
|
|
|
|
content; content = content->GetParent()) {
|
2004-02-10 16:57:00 +00:00
|
|
|
nsCOMPtr<nsILink> link(do_QueryInterface(content));
|
|
|
|
if (link) {
|
|
|
|
link->GetHrefURI(aHref);
|
|
|
|
status = (*aHref != nsnull);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMHTMLAnchorElement> anchor(do_QueryInterface(content));
|
|
|
|
if (anchor) {
|
|
|
|
anchor->GetTarget(aTarget);
|
1999-07-08 19:44:42 +00:00
|
|
|
}
|
1999-07-08 19:38:08 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1999-07-08 19:44:42 +00:00
|
|
|
return status;
|
1999-07-08 19:38:08 +00:00
|
|
|
}
|
|
|
|
|
2001-08-29 22:59:09 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsImageFrame::CanContinueTextRun(PRBool& aContinueTextRun) const
|
|
|
|
{
|
2001-09-08 19:26:34 +00:00
|
|
|
// images really CAN continue text runs, but the textFrame needs to be
|
|
|
|
// educated before we can indicate that it can. For now, we handle the fixing up
|
|
|
|
// of max element widths in nsLineLayout::VerticalAlignFrames, but hopefully
|
|
|
|
// this can be eliminated and the textFrame can be convinced to handle inlines
|
|
|
|
// that take up space in text runs.
|
2001-08-29 22:59:09 +00:00
|
|
|
|
2001-09-08 19:26:34 +00:00
|
|
|
aContinueTextRun = PR_FALSE;
|
2001-08-29 22:59:09 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-11 01:24:59 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsImageFrame::GetContentForEvent(nsIPresContext* aPresContext,
|
|
|
|
nsEvent* aEvent,
|
|
|
|
nsIContent** aContent)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aContent);
|
|
|
|
nsImageMap* map;
|
2000-08-18 06:27:42 +00:00
|
|
|
map = GetImageMap(aPresContext);
|
2000-02-11 01:24:59 +00:00
|
|
|
|
|
|
|
if (nsnull != map) {
|
|
|
|
nsPoint p;
|
|
|
|
TranslateEventCoords(aPresContext, aEvent->point, p);
|
|
|
|
PRBool inside = PR_FALSE;
|
|
|
|
nsCOMPtr<nsIContent> area;
|
2004-02-20 19:00:43 +00:00
|
|
|
inside = map->IsInside(p.x, p.y, getter_AddRefs(area));
|
2000-02-11 01:24:59 +00:00
|
|
|
if (inside && area) {
|
|
|
|
*aContent = area;
|
|
|
|
NS_ADDREF(*aContent);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-29 03:43:05 +00:00
|
|
|
*aContent = GetContent();
|
|
|
|
NS_IF_ADDREF(*aContent);
|
|
|
|
return NS_OK;
|
2000-02-11 01:24:59 +00:00
|
|
|
}
|
|
|
|
|
1998-09-08 22:34:40 +00:00
|
|
|
// XXX what should clicks on transparent pixels do?
|
|
|
|
NS_METHOD
|
1999-11-24 06:03:41 +00:00
|
|
|
nsImageFrame::HandleEvent(nsIPresContext* aPresContext,
|
1998-11-20 17:21:02 +00:00
|
|
|
nsGUIEvent* aEvent,
|
1999-11-24 06:03:41 +00:00
|
|
|
nsEventStatus* aEventStatus)
|
1998-09-08 22:34:40 +00:00
|
|
|
{
|
1999-11-24 06:03:41 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aEventStatus);
|
1999-01-09 00:13:19 +00:00
|
|
|
nsImageMap* map;
|
1998-09-08 22:34:40 +00:00
|
|
|
|
|
|
|
switch (aEvent->message) {
|
|
|
|
case NS_MOUSE_LEFT_BUTTON_UP:
|
|
|
|
case NS_MOUSE_MOVE:
|
1999-08-19 22:22:02 +00:00
|
|
|
{
|
2000-08-18 06:27:42 +00:00
|
|
|
map = GetImageMap(aPresContext);
|
1999-08-19 22:22:02 +00:00
|
|
|
PRBool isServerMap = IsServerImageMap();
|
|
|
|
if ((nsnull != map) || isServerMap) {
|
|
|
|
nsPoint p;
|
|
|
|
TranslateEventCoords(aPresContext, aEvent->point, p);
|
1999-02-06 02:07:49 +00:00
|
|
|
PRBool inside = PR_FALSE;
|
2000-02-11 01:24:59 +00:00
|
|
|
// Even though client-side image map triggering happens
|
|
|
|
// through content, we need to make sure we're not inside
|
|
|
|
// (in case we deal with a case of both client-side and
|
|
|
|
// sever-side on the same image - it happens!)
|
1999-08-19 22:22:02 +00:00
|
|
|
if (nsnull != map) {
|
2000-02-11 01:24:59 +00:00
|
|
|
nsCOMPtr<nsIContent> area;
|
2004-02-20 19:00:43 +00:00
|
|
|
inside = map->IsInside(p.x, p.y, getter_AddRefs(area));
|
1999-01-15 01:57:58 +00:00
|
|
|
}
|
2001-05-23 07:00:37 +00:00
|
|
|
|
1999-08-19 22:22:02 +00:00
|
|
|
if (!inside && isServerMap) {
|
2004-02-10 16:57:00 +00:00
|
|
|
|
|
|
|
// Server side image maps use the href in a containing anchor
|
|
|
|
// element to provide the basis for the destination url.
|
|
|
|
nsCOMPtr<nsIURI> uri;
|
2004-02-20 19:00:43 +00:00
|
|
|
nsAutoString target;
|
2004-02-10 16:57:00 +00:00
|
|
|
if (GetAnchorHREFAndTarget(getter_AddRefs(uri), target)) {
|
|
|
|
// XXX if the mouse is over/clicked in the border/padding area
|
|
|
|
// we should probably just pretend nothing happened. Nav4
|
|
|
|
// keeps the x,y coordinates positive as we do; IE doesn't
|
|
|
|
// bother. Both of them send the click through even when the
|
|
|
|
// mouse is over the border.
|
|
|
|
if (p.x < 0) p.x = 0;
|
|
|
|
if (p.y < 0) p.y = 0;
|
|
|
|
nsCAutoString spec;
|
|
|
|
uri->GetSpec(spec);
|
|
|
|
spec += nsPrintfCString("?%d,%d", p.x, p.y);
|
|
|
|
uri->SetSpec(spec);
|
1999-08-19 22:22:02 +00:00
|
|
|
|
2004-02-10 16:57:00 +00:00
|
|
|
PRBool clicked = PR_FALSE;
|
|
|
|
if (aEvent->message == NS_MOUSE_LEFT_BUTTON_UP) {
|
|
|
|
*aEventStatus = nsEventStatus_eConsumeDoDefault;
|
|
|
|
clicked = PR_TRUE;
|
1999-08-19 22:22:02 +00:00
|
|
|
}
|
2004-02-10 16:57:00 +00:00
|
|
|
TriggerLink(aPresContext, uri, target, clicked);
|
1999-07-08 19:44:42 +00:00
|
|
|
}
|
1998-09-08 22:34:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
1999-04-12 21:24:07 +00:00
|
|
|
default:
|
|
|
|
break;
|
1998-09-08 22:34:40 +00:00
|
|
|
}
|
1999-04-12 21:24:07 +00:00
|
|
|
|
2001-11-01 15:31:13 +00:00
|
|
|
return nsSplittableFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
1998-09-08 22:34:40 +00:00
|
|
|
}
|
|
|
|
|
1999-07-08 19:38:08 +00:00
|
|
|
//XXX This will need to be rewritten once we have content for areas
|
2003-03-19 03:47:09 +00:00
|
|
|
//XXXbz We have content for areas now....
|
1998-09-08 22:34:40 +00:00
|
|
|
NS_METHOD
|
1999-11-24 06:03:41 +00:00
|
|
|
nsImageFrame::GetCursor(nsIPresContext* aPresContext,
|
1998-11-20 17:21:02 +00:00
|
|
|
nsPoint& aPoint,
|
|
|
|
PRInt32& aCursor)
|
1998-09-08 22:34:40 +00:00
|
|
|
{
|
2000-08-18 06:27:42 +00:00
|
|
|
nsImageMap* map = GetImageMap(aPresContext);
|
1998-11-18 05:25:26 +00:00
|
|
|
if (nsnull != map) {
|
1999-07-08 19:38:08 +00:00
|
|
|
nsPoint p;
|
|
|
|
TranslateEventCoords(aPresContext, aPoint, p);
|
1998-11-18 05:25:26 +00:00
|
|
|
aCursor = NS_STYLE_CURSOR_DEFAULT;
|
1999-07-08 19:38:08 +00:00
|
|
|
if (map->IsInside(p.x, p.y)) {
|
1998-11-23 22:21:13 +00:00
|
|
|
// Use style defined cursor if one is provided, otherwise when
|
|
|
|
// the cursor style is "auto" we use the pointer cursor.
|
2003-05-15 03:42:21 +00:00
|
|
|
aCursor = GetStyleUserInterface()->mCursor;
|
1998-11-23 22:21:13 +00:00
|
|
|
if (NS_STYLE_CURSOR_AUTO == aCursor) {
|
|
|
|
aCursor = NS_STYLE_CURSOR_POINTER;
|
|
|
|
}
|
1998-09-08 22:34:40 +00:00
|
|
|
}
|
1998-11-18 05:25:26 +00:00
|
|
|
return NS_OK;
|
1998-09-08 22:34:40 +00:00
|
|
|
}
|
1998-11-18 05:25:26 +00:00
|
|
|
return nsFrame::GetCursor(aPresContext, aPoint, aCursor);
|
1998-09-08 22:34:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-11-20 17:21:02 +00:00
|
|
|
nsImageFrame::AttributeChanged(nsIPresContext* aPresContext,
|
|
|
|
nsIContent* aChild,
|
1999-10-15 23:16:45 +00:00
|
|
|
PRInt32 aNameSpaceID,
|
1998-11-20 17:21:02 +00:00
|
|
|
nsIAtom* aAttribute,
|
2003-07-11 21:16:12 +00:00
|
|
|
PRInt32 aModType)
|
1998-09-08 22:34:40 +00:00
|
|
|
{
|
2001-11-01 15:31:13 +00:00
|
|
|
nsresult rv = nsSplittableFrame::AttributeChanged(aPresContext, aChild,
|
2003-07-11 21:16:12 +00:00
|
|
|
aNameSpaceID, aAttribute,
|
|
|
|
aModType);
|
1998-09-28 21:22:31 +00:00
|
|
|
if (NS_OK != rv) {
|
|
|
|
return rv;
|
|
|
|
}
|
2003-07-11 21:16:12 +00:00
|
|
|
// XXXldb Shouldn't width and height be handled by attribute mapping?
|
2003-04-18 21:02:49 +00:00
|
|
|
if (nsHTMLAtoms::width == aAttribute || nsHTMLAtoms::height == aAttribute || nsHTMLAtoms::alt == aAttribute)
|
2000-04-17 14:40:46 +00:00
|
|
|
{ // XXX: could check for new width == old width, and make that a no-op
|
|
|
|
mState |= NS_FRAME_IS_DIRTY;
|
2003-12-21 05:36:36 +00:00
|
|
|
mParent->ReflowDirtyChild(aPresContext->PresShell(), (nsIFrame*) this);
|
2000-04-17 14:40:46 +00:00
|
|
|
}
|
1998-09-08 22:34:40 +00:00
|
|
|
|
1998-09-25 16:35:01 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-08-31 03:09:40 +00:00
|
|
|
|
2003-10-31 20:19:18 +00:00
|
|
|
nsIAtom*
|
|
|
|
nsImageFrame::GetType() const
|
1999-08-31 03:09:40 +00:00
|
|
|
{
|
2003-10-31 20:19:18 +00:00
|
|
|
return nsLayoutAtoms::imageFrame;
|
1999-08-31 03:09:40 +00:00
|
|
|
}
|
|
|
|
|
2001-10-31 04:43:48 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsImageFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) const
|
|
|
|
{
|
|
|
|
IndentBy(out, aIndent);
|
|
|
|
ListTag(out);
|
|
|
|
#ifdef DEBUG_waterson
|
|
|
|
fprintf(out, " [parent=%p]", mParent);
|
|
|
|
#endif
|
2003-06-19 23:44:01 +00:00
|
|
|
if (HasView()) {
|
2003-06-29 03:43:05 +00:00
|
|
|
fprintf(out, " [view=%p]", GetView());
|
2001-10-31 04:43:48 +00:00
|
|
|
}
|
|
|
|
fprintf(out, " {%d,%d,%d,%d}", mRect.x, mRect.y, mRect.width,
|
|
|
|
mRect.height);
|
|
|
|
if (0 != mState) {
|
|
|
|
fprintf(out, " [state=%08x]", mState);
|
|
|
|
}
|
|
|
|
fprintf(out, " [content=%p]", mContent);
|
|
|
|
|
|
|
|
// output the img src url
|
2003-03-19 03:47:09 +00:00
|
|
|
nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(mContent);
|
|
|
|
if (imageLoader) {
|
|
|
|
nsCOMPtr<imgIRequest> currentRequest;
|
|
|
|
imageLoader->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST,
|
|
|
|
getter_AddRefs(currentRequest));
|
|
|
|
if (currentRequest) {
|
|
|
|
nsCOMPtr<nsIURI> uri;
|
|
|
|
currentRequest->GetURI(getter_AddRefs(uri));
|
|
|
|
nsCAutoString uristr;
|
|
|
|
uri->GetAsciiSpec(uristr);
|
|
|
|
fprintf(out, " [src=%s]", uristr.get());
|
|
|
|
}
|
2002-03-20 22:14:27 +00:00
|
|
|
}
|
2001-10-31 04:43:48 +00:00
|
|
|
fputs("\n", out);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2000-01-04 03:06:13 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsImageFrame::GetIntrinsicImageSize(nsSize& aSize)
|
|
|
|
{
|
2003-03-19 03:47:09 +00:00
|
|
|
aSize = mIntrinsicSize;
|
2000-01-04 03:06:13 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-10-07 18:02:13 +00:00
|
|
|
nsresult
|
2003-03-19 03:47:09 +00:00
|
|
|
nsImageFrame::LoadIcon(const nsAString& aSpec,
|
|
|
|
nsIPresContext *aPresContext,
|
|
|
|
imgIRequest** aRequest)
|
2001-05-04 06:29:59 +00:00
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
2003-03-19 03:47:09 +00:00
|
|
|
NS_PRECONDITION(!aSpec.IsEmpty(), "What happened??");
|
2001-05-04 06:29:59 +00:00
|
|
|
|
2004-01-21 09:35:59 +00:00
|
|
|
if (!sIOService) {
|
|
|
|
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
|
|
|
rv = CallGetService(kIOServiceCID, &sIOService);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
|
2001-06-05 20:22:52 +00:00
|
|
|
nsCOMPtr<nsIURI> realURI;
|
2004-01-21 09:35:59 +00:00
|
|
|
SpecToURI(aSpec, sIOService, getter_AddRefs(realURI));
|
2003-03-19 03:47:09 +00:00
|
|
|
|
2001-05-04 06:29:59 +00:00
|
|
|
nsCOMPtr<imgILoader> il(do_GetService("@mozilla.org/image/loader;1", &rv));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
nsCOMPtr<nsILoadGroup> loadGroup;
|
|
|
|
GetLoadGroup(aPresContext, getter_AddRefs(loadGroup));
|
|
|
|
|
2003-03-19 03:47:09 +00:00
|
|
|
// For icon loads, we don't need to merge with the loadgroup flags
|
2001-09-29 17:50:15 +00:00
|
|
|
nsLoadFlags loadFlags = nsIRequest::LOAD_NORMAL;
|
|
|
|
|
2003-03-19 03:47:09 +00:00
|
|
|
return il->LoadImage(realURI, /* icon URI */
|
|
|
|
nsnull, /* initial document URI; this is only
|
|
|
|
relevant for cookies, so does not
|
|
|
|
apply to icons. */
|
|
|
|
nsnull, /* referrer (not relevant for icons) */
|
|
|
|
loadGroup,
|
|
|
|
mListener,
|
|
|
|
nsnull, /* Not associated with any particular document */
|
|
|
|
loadFlags,
|
|
|
|
nsnull,
|
|
|
|
nsnull,
|
|
|
|
aRequest);
|
2001-05-04 06:29:59 +00:00
|
|
|
}
|
|
|
|
|
2002-03-12 22:26:11 +00:00
|
|
|
void
|
2003-06-17 16:40:34 +00:00
|
|
|
nsImageFrame::GetDocumentCharacterSet(nsACString& aCharset) const
|
2002-03-12 22:26:11 +00:00
|
|
|
{
|
2003-07-28 21:25:13 +00:00
|
|
|
if (mContent) {
|
|
|
|
NS_ASSERTION(mContent->GetDocument(),
|
|
|
|
"Frame still alive after content removed from document!");
|
2003-10-22 06:09:48 +00:00
|
|
|
aCharset = mContent->GetDocument()->GetDocumentCharacterSet();
|
2002-03-12 22:26:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-04-15 02:13:49 +00:00
|
|
|
void
|
2003-03-19 03:47:09 +00:00
|
|
|
nsImageFrame::SpecToURI(const nsAString& aSpec, nsIIOService *aIOService,
|
2002-11-06 12:58:05 +00:00
|
|
|
nsIURI **aURI)
|
2001-05-04 06:29:59 +00:00
|
|
|
{
|
2001-04-15 02:13:49 +00:00
|
|
|
nsCOMPtr<nsIURI> baseURI;
|
2003-07-03 02:45:34 +00:00
|
|
|
if (mContent) {
|
2004-01-09 23:54:21 +00:00
|
|
|
baseURI = mContent->GetBaseURI();
|
2003-07-03 02:45:34 +00:00
|
|
|
}
|
2003-06-17 16:40:34 +00:00
|
|
|
nsCAutoString charset;
|
2002-03-12 22:26:11 +00:00
|
|
|
GetDocumentCharacterSet(charset);
|
|
|
|
NS_NewURI(aURI, aSpec,
|
2003-06-17 16:40:34 +00:00
|
|
|
charset.IsEmpty() ? nsnull : charset.get(),
|
2002-11-06 12:58:05 +00:00
|
|
|
baseURI, aIOService);
|
2001-04-15 02:13:49 +00:00
|
|
|
}
|
|
|
|
|
2001-03-22 01:38:35 +00:00
|
|
|
void
|
|
|
|
nsImageFrame::GetLoadGroup(nsIPresContext *aPresContext, nsILoadGroup **aLoadGroup)
|
|
|
|
{
|
|
|
|
if (!aPresContext)
|
|
|
|
return;
|
|
|
|
|
|
|
|
NS_PRECONDITION(nsnull != aLoadGroup, "null OUT parameter pointer");
|
|
|
|
|
2003-12-21 05:36:36 +00:00
|
|
|
nsIPresShell *shell = aPresContext->GetPresShell();
|
2001-03-22 01:38:35 +00:00
|
|
|
|
|
|
|
if (!shell)
|
|
|
|
return;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocument> doc;
|
|
|
|
shell->GetDocument(getter_AddRefs(doc));
|
|
|
|
if (!doc)
|
|
|
|
return;
|
|
|
|
|
2003-10-22 06:09:48 +00:00
|
|
|
*aLoadGroup = doc->GetDocumentLoadGroup().get(); // already_AddRefed
|
2001-03-22 01:38:35 +00:00
|
|
|
}
|
|
|
|
|
2001-11-07 05:02:42 +00:00
|
|
|
nsresult nsImageFrame::LoadIcons(nsIPresContext *aPresContext)
|
|
|
|
{
|
2004-02-03 20:30:02 +00:00
|
|
|
NS_ASSERTION(!gIconLoad, "called LoadIcons twice");
|
|
|
|
|
2003-09-13 17:55:56 +00:00
|
|
|
NS_NAMED_LITERAL_STRING(loadingSrc,"resource://gre/res/loading-image.gif");
|
|
|
|
NS_NAMED_LITERAL_STRING(brokenSrc,"resource://gre/res/broken-image.gif");
|
2001-11-07 05:02:42 +00:00
|
|
|
|
2004-02-03 20:30:02 +00:00
|
|
|
gIconLoad = new IconLoad(mListener);
|
|
|
|
if (!gIconLoad)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
NS_ADDREF(gIconLoad);
|
2001-11-07 05:02:42 +00:00
|
|
|
|
2003-03-19 03:47:09 +00:00
|
|
|
nsresult rv;
|
|
|
|
// create a loader and load the images
|
|
|
|
rv = LoadIcon(loadingSrc,
|
|
|
|
aPresContext,
|
2004-02-03 20:30:02 +00:00
|
|
|
getter_AddRefs(gIconLoad->mLoadingImage));
|
2001-11-07 05:02:42 +00:00
|
|
|
#ifdef NOISY_ICON_LOADING
|
2003-03-19 03:47:09 +00:00
|
|
|
printf("Loading request %p, rv=%u\n",
|
2004-02-03 20:30:02 +00:00
|
|
|
gIconLoad->mLoadingImage.get(), rv);
|
2001-11-07 05:02:42 +00:00
|
|
|
#endif
|
2003-03-19 03:47:09 +00:00
|
|
|
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = LoadIcon(brokenSrc,
|
|
|
|
aPresContext,
|
2004-02-03 20:30:02 +00:00
|
|
|
getter_AddRefs(gIconLoad->mBrokenImage));
|
2001-11-07 05:02:42 +00:00
|
|
|
#ifdef NOISY_ICON_LOADING
|
2003-03-19 03:47:09 +00:00
|
|
|
printf("Loading request %p, rv=%u\n",
|
2004-02-03 20:30:02 +00:00
|
|
|
gIconLoad->mBrokenImage.get(), rv);
|
2001-11-07 05:02:42 +00:00
|
|
|
#endif
|
2003-03-19 03:47:09 +00:00
|
|
|
|
|
|
|
// ImageLoader will callback into OnStartContainer, which will
|
|
|
|
// handle the mIconsLoaded flag
|
|
|
|
|
2001-11-07 05:02:42 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool nsImageFrame::HandleIconLoads(imgIRequest* aRequest, PRBool aLoaded)
|
|
|
|
{
|
|
|
|
PRBool result = PR_FALSE;
|
|
|
|
|
2004-02-03 20:30:02 +00:00
|
|
|
if (gIconLoad) {
|
2001-11-07 05:02:42 +00:00
|
|
|
// check which image it is
|
2004-02-03 20:30:02 +00:00
|
|
|
if (aRequest == gIconLoad->mLoadingImage ||
|
|
|
|
aRequest == gIconLoad->mBrokenImage) {
|
2001-11-07 05:02:42 +00:00
|
|
|
result = PR_TRUE;
|
2004-02-03 20:30:02 +00:00
|
|
|
if (aLoaded && (++gIconLoad->mIconsLoaded == 2))
|
|
|
|
gIconLoad->mLoadObserver = nsnull;
|
2001-11-07 05:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef NOISY_ICON_LOADING
|
2004-02-03 20:30:02 +00:00
|
|
|
if (gIconLoad->mIconsLoaded && result) {
|
2003-03-19 03:47:09 +00:00
|
|
|
printf( "Icons Loaded: request for %s\n",
|
2004-02-03 20:30:02 +00:00
|
|
|
aRequest == gIconLoad->mLoadingImage
|
|
|
|
? "mLoadingImage" : "mBrokenImage" );
|
2001-11-07 05:02:42 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2003-03-19 03:47:09 +00:00
|
|
|
|
2001-11-07 05:02:42 +00:00
|
|
|
#ifdef NOISY_ICON_LOADING
|
|
|
|
printf( "HandleIconLoads returned %s (%p)\n", result ? "TRUE" : "FALSE", this);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
2001-04-15 02:13:49 +00:00
|
|
|
|
2004-02-03 20:30:02 +00:00
|
|
|
void nsImageFrame::InvalidateIcon()
|
2001-11-07 05:02:42 +00:00
|
|
|
{
|
2002-01-18 22:17:12 +00:00
|
|
|
// invalidate the inner area, where the icon lives
|
|
|
|
|
2004-02-03 20:30:02 +00:00
|
|
|
nsIPresContext *presContext = GetPresContext();
|
2001-11-07 05:02:42 +00:00
|
|
|
float p2t;
|
2004-02-03 20:30:02 +00:00
|
|
|
presContext->GetScaledPixelsToTwips(&p2t);
|
2001-11-07 05:02:42 +00:00
|
|
|
nsRect inner;
|
2004-02-03 20:30:02 +00:00
|
|
|
GetInnerArea(presContext, inner);
|
2001-11-07 05:02:42 +00:00
|
|
|
|
|
|
|
nsRect rect(inner.x,
|
|
|
|
inner.y,
|
|
|
|
NSIntPixelsToTwips(ICON_SIZE+ICON_PADDING, p2t),
|
|
|
|
NSIntPixelsToTwips(ICON_SIZE+ICON_PADDING, p2t));
|
2002-01-18 22:17:12 +00:00
|
|
|
NS_ASSERTION(!rect.IsEmpty(), "icon rect cannot be empty!");
|
2004-03-10 03:09:05 +00:00
|
|
|
// update image area
|
|
|
|
Invalidate(rect, PR_FALSE);
|
2004-02-03 20:30:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS1(nsImageFrame::IconLoad, nsIObserver)
|
|
|
|
|
|
|
|
static const char kIconLoadPrefs[][40] = {
|
|
|
|
"browser.display.force_inline_alttext",
|
|
|
|
"network.image.imageBehavior",
|
|
|
|
"browser.display.show_image_placeholders"
|
|
|
|
};
|
|
|
|
|
|
|
|
nsImageFrame::IconLoad::IconLoad(imgIDecoderObserver *aObserver)
|
|
|
|
: mLoadObserver(aObserver),
|
|
|
|
mIconsLoaded(0)
|
|
|
|
{
|
2004-04-29 23:34:19 +00:00
|
|
|
nsCOMPtr<nsIPrefBranchInternal> prefBranch =
|
|
|
|
do_QueryInterface(nsContentUtils::GetPrefBranch());
|
2004-02-03 20:30:02 +00:00
|
|
|
|
|
|
|
// register observers
|
|
|
|
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(kIconLoadPrefs); ++i)
|
2004-04-29 23:34:19 +00:00
|
|
|
prefBranch->AddObserver(kIconLoadPrefs[i], this, PR_FALSE);
|
2004-02-03 20:30:02 +00:00
|
|
|
|
2004-04-29 23:34:19 +00:00
|
|
|
GetPrefs();
|
2001-11-07 05:02:42 +00:00
|
|
|
}
|
|
|
|
|
2004-02-03 20:30:02 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsImageFrame::IconLoad::Observe(nsISupports *aSubject, const char* aTopic,
|
|
|
|
const PRUnichar* aData)
|
2001-11-07 05:02:42 +00:00
|
|
|
{
|
2004-02-03 20:30:02 +00:00
|
|
|
NS_ASSERTION(!nsCRT::strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID),
|
|
|
|
"wrong topic");
|
|
|
|
#ifdef DEBUG
|
|
|
|
// assert |aData| is one of our prefs.
|
|
|
|
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(kIconLoadPrefs) ||
|
|
|
|
(NS_NOTREACHED("wrong pref"), PR_FALSE); ++i)
|
|
|
|
if (NS_ConvertASCIItoUTF16(kIconLoadPrefs[i]) == nsDependentString(aData))
|
|
|
|
break;
|
|
|
|
#endif
|
2001-11-07 05:02:42 +00:00
|
|
|
|
2004-04-29 23:34:19 +00:00
|
|
|
GetPrefs();
|
2004-02-03 20:30:02 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2004-04-29 23:34:19 +00:00
|
|
|
void nsImageFrame::IconLoad::GetPrefs()
|
2004-02-03 20:30:02 +00:00
|
|
|
{
|
2004-04-29 23:34:19 +00:00
|
|
|
mPrefForceInlineAltText =
|
|
|
|
nsContentUtils::GetBoolPref("browser.display.force_inline_alttext");
|
|
|
|
|
|
|
|
mPrefAllImagesBlocked =
|
|
|
|
nsContentUtils::GetIntPref("network.image.imageBehavior") == 2;
|
|
|
|
|
|
|
|
mPrefShowPlaceholders =
|
|
|
|
nsContentUtils::GetBoolPref("browser.display.show_image_placeholders",
|
|
|
|
PR_TRUE);
|
2001-11-07 05:02:42 +00:00
|
|
|
}
|
2001-04-15 02:13:49 +00:00
|
|
|
|
2001-03-22 01:38:35 +00:00
|
|
|
NS_IMPL_ISUPPORTS2(nsImageListener, imgIDecoderObserver, imgIContainerObserver)
|
|
|
|
|
2001-04-15 02:13:49 +00:00
|
|
|
nsImageListener::nsImageListener(nsImageFrame *aFrame) :
|
|
|
|
mFrame(aFrame)
|
2001-03-22 01:38:35 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsImageListener::~nsImageListener()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2003-02-26 05:51:32 +00:00
|
|
|
NS_IMETHODIMP nsImageListener::OnStartDecode(imgIRequest *aRequest)
|
2001-03-22 01:38:35 +00:00
|
|
|
{
|
2003-03-19 03:47:09 +00:00
|
|
|
// Not useful to us yet.
|
|
|
|
return NS_OK;
|
2001-03-22 01:38:35 +00:00
|
|
|
}
|
|
|
|
|
2003-02-26 05:51:32 +00:00
|
|
|
NS_IMETHODIMP nsImageListener::OnStartContainer(imgIRequest *aRequest,
|
|
|
|
imgIContainer *aImage)
|
2001-03-22 01:38:35 +00:00
|
|
|
{
|
|
|
|
if (!mFrame)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2003-02-26 05:51:32 +00:00
|
|
|
return mFrame->OnStartContainer(aRequest, aImage);
|
2001-03-22 01:38:35 +00:00
|
|
|
}
|
|
|
|
|
2003-02-26 05:51:32 +00:00
|
|
|
NS_IMETHODIMP nsImageListener::OnStartFrame(imgIRequest *aRequest,
|
|
|
|
gfxIImageFrame *aFrame)
|
2001-03-22 01:38:35 +00:00
|
|
|
{
|
2003-03-19 03:47:09 +00:00
|
|
|
// Not useful to us yet.
|
|
|
|
return NS_OK;
|
2001-03-22 01:38:35 +00:00
|
|
|
}
|
|
|
|
|
2003-02-26 05:51:32 +00:00
|
|
|
NS_IMETHODIMP nsImageListener::OnDataAvailable(imgIRequest *aRequest,
|
|
|
|
gfxIImageFrame *aFrame,
|
|
|
|
const nsRect *aRect)
|
2001-03-22 01:38:35 +00:00
|
|
|
{
|
|
|
|
if (!mFrame)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2003-02-26 05:51:32 +00:00
|
|
|
return mFrame->OnDataAvailable(aRequest, aFrame, aRect);
|
2001-03-22 01:38:35 +00:00
|
|
|
}
|
|
|
|
|
2003-02-26 05:51:32 +00:00
|
|
|
NS_IMETHODIMP nsImageListener::OnStopFrame(imgIRequest *aRequest,
|
|
|
|
gfxIImageFrame *aFrame)
|
2001-03-22 01:38:35 +00:00
|
|
|
{
|
2003-03-19 03:47:09 +00:00
|
|
|
// Not useful to us yet.
|
|
|
|
return NS_OK;
|
2001-03-22 01:38:35 +00:00
|
|
|
}
|
|
|
|
|
2003-02-26 05:51:32 +00:00
|
|
|
NS_IMETHODIMP nsImageListener::OnStopContainer(imgIRequest *aRequest,
|
|
|
|
imgIContainer *aImage)
|
2001-03-22 01:38:35 +00:00
|
|
|
{
|
2003-03-19 03:47:09 +00:00
|
|
|
// Not useful to us yet.
|
|
|
|
return NS_OK;
|
2001-03-22 01:38:35 +00:00
|
|
|
}
|
|
|
|
|
2003-02-26 05:51:32 +00:00
|
|
|
NS_IMETHODIMP nsImageListener::OnStopDecode(imgIRequest *aRequest,
|
|
|
|
nsresult status,
|
|
|
|
const PRUnichar *statusArg)
|
2001-03-22 01:38:35 +00:00
|
|
|
{
|
|
|
|
if (!mFrame)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2003-02-26 05:51:32 +00:00
|
|
|
return mFrame->OnStopDecode(aRequest, status, statusArg);
|
2001-03-22 01:38:35 +00:00
|
|
|
}
|
|
|
|
|
2003-02-26 05:51:32 +00:00
|
|
|
NS_IMETHODIMP nsImageListener::FrameChanged(imgIContainer *aContainer,
|
|
|
|
gfxIImageFrame *newframe,
|
|
|
|
nsRect * dirtyRect)
|
2001-03-22 01:38:35 +00:00
|
|
|
{
|
|
|
|
if (!mFrame)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2003-02-26 05:51:32 +00:00
|
|
|
return mFrame->FrameChanged(aContainer, newframe, dirtyRect);
|
2001-03-22 01:38:35 +00:00
|
|
|
}
|
|
|
|
|