2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 18:30:37 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
2004-04-18 18:30:37 +04: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-04-14 00:24:54 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04: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-04-14 00:24:54 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-29 00:14:13 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 18:30:37 +04: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-29 00:14:13 +04: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 18:30:37 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-29 00:14:13 +04: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 18:30:37 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
2002-10-16 03:40:38 +04:00
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2006-03-30 09:56:38 +04:00
|
|
|
|
|
|
|
/* a presentation of a document, part 1 */
|
|
|
|
|
2002-10-16 03:40:38 +04:00
|
|
|
#include "nsCOMPtr.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsILinkHandler.h"
|
2001-07-25 10:33:06 +04:00
|
|
|
#include "nsIDocShellTreeItem.h"
|
2005-01-20 06:39:09 +03:00
|
|
|
#include "nsIDocShell.h"
|
|
|
|
#include "nsIContentViewer.h"
|
|
|
|
#include "nsIDocumentViewer.h"
|
|
|
|
#include "nsPIDOMWindow.h"
|
|
|
|
#include "nsIFocusController.h"
|
2004-01-08 01:30:53 +03:00
|
|
|
#include "nsStyleSet.h"
|
2001-08-10 00:22:39 +04:00
|
|
|
#include "nsImageLoader.h"
|
2000-12-30 22:22:22 +03:00
|
|
|
#include "nsIContent.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsIFrame.h"
|
|
|
|
#include "nsIRenderingContext.h"
|
1998-09-05 07:52:40 +04:00
|
|
|
#include "nsIURL.h"
|
|
|
|
#include "nsIDocument.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsStyleContext.h"
|
1999-09-10 09:51:08 +04:00
|
|
|
#include "nsILookAndFeel.h"
|
|
|
|
#include "nsWidgetsCID.h"
|
|
|
|
#include "nsIComponentManager.h"
|
2000-02-15 07:49:32 +03:00
|
|
|
#include "nsIURIContentListener.h"
|
|
|
|
#include "nsIInterfaceRequestor.h"
|
2001-09-06 01:28:38 +04:00
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
2000-03-02 10:13:02 +03:00
|
|
|
#include "nsIServiceManager.h"
|
2000-05-16 02:05:45 +04:00
|
|
|
#include "nsIDOMElement.h"
|
|
|
|
#include "nsContentPolicyUtils.h"
|
2001-05-22 02:40:10 +04:00
|
|
|
#include "nsIDOMWindow.h"
|
2001-05-08 05:40:09 +04:00
|
|
|
#include "nsXPIDLString.h"
|
2002-11-07 03:59:25 +03:00
|
|
|
#include "nsIWeakReferenceUtils.h"
|
2003-01-09 09:49:07 +03:00
|
|
|
#include "nsCSSRendering.h"
|
2001-05-08 05:40:09 +04:00
|
|
|
#include "prprf.h"
|
2002-02-15 02:31:54 +03:00
|
|
|
#include "nsContentPolicyUtils.h"
|
|
|
|
#include "nsIDOMDocument.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsAutoPtr.h"
|
2004-02-27 20:17:37 +03:00
|
|
|
#include "nsEventStateManager.h"
|
2006-09-12 08:36:03 +04:00
|
|
|
#include "nsThreadUtils.h"
|
2006-11-30 02:09:13 +03:00
|
|
|
#include "nsFrameManager.h"
|
|
|
|
#include "nsLayoutUtils.h"
|
2007-02-15 12:04:25 +03:00
|
|
|
#include "nsIViewManager.h"
|
2006-09-12 08:36:03 +04:00
|
|
|
|
2001-03-09 06:13:03 +03:00
|
|
|
#ifdef IBMBIDI
|
|
|
|
#include "nsBidiPresUtils.h"
|
|
|
|
#endif // IBMBIDI
|
2000-02-15 07:49:32 +03:00
|
|
|
|
2004-04-30 08:06:30 +04:00
|
|
|
#include "nsContentUtils.h"
|
|
|
|
|
2001-11-14 14:21:54 +03:00
|
|
|
// Needed for Start/Stop of Image Animation
|
|
|
|
#include "imgIContainer.h"
|
2003-03-19 06:47:09 +03:00
|
|
|
#include "nsIImageLoadingContent.h"
|
2001-11-14 14:21:54 +03:00
|
|
|
|
2002-09-11 07:03:49 +04:00
|
|
|
//needed for resetting of image service color
|
|
|
|
#include "nsLayoutCID.h"
|
2006-03-17 00:42:50 +03:00
|
|
|
#ifndef MOZ_CAIRO_GFX
|
2002-09-11 07:03:49 +04:00
|
|
|
#include "nsISelectionImageService.h"
|
2006-03-17 00:42:50 +03:00
|
|
|
#endif
|
2001-05-08 05:40:09 +04:00
|
|
|
static nscolor
|
|
|
|
MakeColorPref(const char *colstr)
|
|
|
|
{
|
|
|
|
PRUint32 red, green, blue;
|
|
|
|
nscolor colorref;
|
|
|
|
|
|
|
|
// 4.x stored RGB color values as a string rather than as an int,
|
|
|
|
// thus we need to do this conversion
|
|
|
|
PR_sscanf(colstr, "#%02x%02x%02x", &red, &green, &blue);
|
|
|
|
colorref = NS_RGB(red, green, blue);
|
|
|
|
return colorref;
|
|
|
|
}
|
|
|
|
|
2002-12-11 08:11:02 +03:00
|
|
|
int PR_CALLBACK
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::PrefChangedCallback(const char* aPrefName, void* instance_data)
|
2002-12-11 08:11:02 +03:00
|
|
|
{
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext* presContext = (nsPresContext*)instance_data;
|
2002-12-11 08:11:02 +03:00
|
|
|
|
|
|
|
NS_ASSERTION(nsnull != presContext, "bad instance data");
|
|
|
|
if (nsnull != presContext) {
|
|
|
|
presContext->PreferenceChanged(aPrefName);
|
|
|
|
}
|
|
|
|
return 0; // PREF_OK
|
|
|
|
}
|
|
|
|
|
2005-08-24 03:52:16 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
nsPresContext::PrefChangedUpdateTimerCallback(nsITimer *aTimer, void *aClosure)
|
|
|
|
{
|
|
|
|
nsPresContext* presContext = (nsPresContext*)aClosure;
|
|
|
|
NS_ASSERTION(presContext != nsnull, "bad instance data");
|
|
|
|
if (presContext)
|
|
|
|
presContext->UpdateAfterPreferencesChanged();
|
|
|
|
}
|
|
|
|
|
2001-03-09 06:13:03 +03:00
|
|
|
#ifdef IBMBIDI
|
2004-04-13 04:28:44 +04:00
|
|
|
static PRBool
|
2004-07-29 23:41:39 +04:00
|
|
|
IsVisualCharset(const nsCString& aCharset)
|
2001-03-09 06:13:03 +03:00
|
|
|
{
|
2004-06-17 04:13:25 +04:00
|
|
|
if (aCharset.LowerCaseEqualsLiteral("ibm864") // Arabic//ahmed
|
|
|
|
|| aCharset.LowerCaseEqualsLiteral("ibm862") // Hebrew
|
|
|
|
|| aCharset.LowerCaseEqualsLiteral("iso-8859-8") ) { // Hebrew
|
2001-03-09 06:13:03 +03:00
|
|
|
return PR_TRUE; // visual text type
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return PR_FALSE; // logical text type
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // IBMBIDI
|
|
|
|
|
2001-08-10 00:22:39 +04:00
|
|
|
|
2007-02-07 10:46:44 +03:00
|
|
|
PR_STATIC_CALLBACK(PLDHashOperator)
|
2007-02-09 23:44:10 +03:00
|
|
|
destroy_loads(const void * aKey, nsCOMPtr<nsImageLoader>& aData, void* closure)
|
2001-08-10 00:22:39 +04:00
|
|
|
{
|
2007-02-07 10:46:44 +03:00
|
|
|
aData->Destroy();
|
|
|
|
return PL_DHASH_NEXT;
|
2001-08-10 00:22:39 +04:00
|
|
|
}
|
|
|
|
|
2000-07-29 02:12:45 +04:00
|
|
|
static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
2001-02-20 00:50:04 +03:00
|
|
|
#include "nsContentCID.h"
|
2002-09-11 07:03:49 +04:00
|
|
|
static NS_DEFINE_CID(kSelectionImageService, NS_SELECTIONIMAGESERVICE_CID);
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
// NOTE! nsPresContext::operator new() zeroes out all members, so don't
|
2004-04-30 08:06:30 +04:00
|
|
|
// bother initializing members to 0.
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2006-05-19 14:26:44 +04:00
|
|
|
nsPresContext::nsPresContext(nsIDocument* aDocument, nsPresContextType aType)
|
|
|
|
: mType(aType), mDocument(aDocument), mTextZoom(1.0),
|
2006-09-12 08:36:03 +04:00
|
|
|
mPageSize(-1, -1),
|
2004-09-05 04:04:04 +04:00
|
|
|
mViewportStyleOverflow(NS_STYLE_OVERFLOW_AUTO, NS_STYLE_OVERFLOW_AUTO),
|
2004-07-29 23:41:39 +04:00
|
|
|
mImageAnimationModePref(imgIContainer::kNormalAnimMode),
|
2007-02-07 10:46:44 +03:00
|
|
|
// Font sizes default to zero; they will be set in GetFontPreferences
|
2004-07-29 23:41:39 +04:00
|
|
|
mDefaultVariableFont("serif", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
|
2007-02-07 10:46:44 +03:00
|
|
|
NS_FONT_WEIGHT_NORMAL, 0, 0),
|
2001-09-27 22:34:30 +04:00
|
|
|
mDefaultFixedFont("monospace", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
|
2007-02-07 10:46:44 +03:00
|
|
|
NS_FONT_WEIGHT_NORMAL, 0, 0),
|
2001-09-27 22:34:30 +04:00
|
|
|
mDefaultSerifFont("serif", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
|
2007-02-07 10:46:44 +03:00
|
|
|
NS_FONT_WEIGHT_NORMAL, 0, 0),
|
2001-09-27 22:34:30 +04:00
|
|
|
mDefaultSansSerifFont("sans-serif", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
|
2007-02-07 10:46:44 +03:00
|
|
|
NS_FONT_WEIGHT_NORMAL, 0, 0),
|
2001-09-27 22:34:30 +04:00
|
|
|
mDefaultMonospaceFont("monospace", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
|
2007-02-07 10:46:44 +03:00
|
|
|
NS_FONT_WEIGHT_NORMAL, 0, 0),
|
2004-07-29 23:41:39 +04:00
|
|
|
mDefaultCursiveFont("cursive", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
|
2007-02-07 10:46:44 +03:00
|
|
|
NS_FONT_WEIGHT_NORMAL, 0, 0),
|
2004-07-29 23:41:39 +04:00
|
|
|
mDefaultFantasyFont("fantasy", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
|
2007-02-07 10:46:44 +03:00
|
|
|
NS_FONT_WEIGHT_NORMAL, 0, 0),
|
2006-09-12 08:36:03 +04:00
|
|
|
mCanPaginatedScroll(PR_FALSE),
|
2007-02-14 01:36:59 +03:00
|
|
|
mIsRootPaginatedDocument(PR_FALSE),
|
|
|
|
mPPScale(1.0f)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2004-08-01 03:15:21 +04:00
|
|
|
// NOTE! nsPresContext::operator new() zeroes out all members, so don't
|
2004-04-30 08:06:30 +04:00
|
|
|
// bother initializing members to 0.
|
|
|
|
|
2004-07-29 23:41:39 +04:00
|
|
|
mDoScaledTwips = PR_TRUE;
|
2000-09-21 05:20:00 +04:00
|
|
|
|
2002-02-15 17:48:12 +03:00
|
|
|
SetBackgroundImageDraw(PR_TRUE); // always draw the background
|
|
|
|
SetBackgroundColorDraw(PR_TRUE);
|
2001-12-11 08:57:37 +03:00
|
|
|
|
2004-02-01 01:41:40 +03:00
|
|
|
mBackgroundColor = NS_RGB(0xFF, 0xFF, 0xFF);
|
2000-10-11 12:33:01 +04:00
|
|
|
|
|
|
|
mUseDocumentColors = PR_TRUE;
|
|
|
|
mUseDocumentFonts = PR_TRUE;
|
|
|
|
|
2001-09-27 22:34:30 +04:00
|
|
|
// the minimum font-size is unconstrained by default
|
|
|
|
|
2003-10-15 05:56:12 +04:00
|
|
|
mLinkColor = NS_RGB(0x00, 0x00, 0xEE);
|
|
|
|
mActiveLinkColor = NS_RGB(0xEE, 0x00, 0x00);
|
|
|
|
mVisitedLinkColor = NS_RGB(0x55, 0x1A, 0x8B);
|
2000-10-11 12:33:01 +04:00
|
|
|
mUnderlineLinks = PR_TRUE;
|
|
|
|
|
2001-04-10 02:17:11 +04:00
|
|
|
mFocusTextColor = mDefaultColor;
|
2004-02-01 01:41:40 +03:00
|
|
|
mFocusBackgroundColor = mBackgroundColor;
|
2001-04-10 02:17:11 +04:00
|
|
|
mFocusRingWidth = 1;
|
|
|
|
|
2000-09-21 02:59:20 +04:00
|
|
|
mLanguageSpecificTransformType = eLanguageSpecificTransformType_Unknown;
|
2004-07-29 23:41:39 +04:00
|
|
|
if (aType == eContext_Galley) {
|
2006-12-26 20:47:52 +03:00
|
|
|
mMedium = nsGkAtoms::screen;
|
2004-07-29 23:41:39 +04:00
|
|
|
} else {
|
|
|
|
SetBackgroundImageDraw(PR_FALSE);
|
|
|
|
SetBackgroundColorDraw(PR_FALSE);
|
2006-12-26 20:47:52 +03:00
|
|
|
mMedium = nsGkAtoms::print;
|
2004-07-29 23:41:39 +04:00
|
|
|
mPaginated = PR_TRUE;
|
|
|
|
}
|
2006-04-01 05:19:28 +04:00
|
|
|
|
|
|
|
if (!IsDynamic()) {
|
|
|
|
mImageAnimationMode = imgIContainer::kDontAnimMode;
|
|
|
|
mNeverAnimate = PR_TRUE;
|
|
|
|
} else {
|
|
|
|
mImageAnimationMode = imgIContainer::kNormalAnimMode;
|
|
|
|
mNeverAnimate = PR_FALSE;
|
|
|
|
}
|
2006-05-19 14:26:44 +04:00
|
|
|
NS_ASSERTION(mDocument, "Null document");
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::~nsPresContext()
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2007-02-07 10:46:44 +03:00
|
|
|
mImageLoaders.Enumerate(destroy_loads, nsnull);
|
2001-08-10 00:22:39 +04:00
|
|
|
|
2003-04-25 02:44:48 +04:00
|
|
|
NS_PRECONDITION(!mShell, "Presshell forgot to clear our mShell pointer");
|
|
|
|
SetShell(nsnull);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2003-06-19 22:16:53 +04:00
|
|
|
if (mEventManager) {
|
2006-04-11 20:37:58 +04:00
|
|
|
// unclear if these are needed, but can't hurt
|
|
|
|
mEventManager->NotifyDestroyPresContext(this);
|
|
|
|
mEventManager->SetPresContext(nsnull);
|
|
|
|
|
2003-06-19 22:16:53 +04:00
|
|
|
NS_RELEASE(mEventManager);
|
|
|
|
}
|
1998-11-18 08:25:26 +03:00
|
|
|
|
2005-08-24 03:52:16 +04:00
|
|
|
if (mPrefChangedTimer)
|
|
|
|
{
|
|
|
|
mPrefChangedTimer->Cancel();
|
|
|
|
mPrefChangedTimer = nsnull;
|
|
|
|
}
|
|
|
|
|
2002-12-11 08:11:02 +03:00
|
|
|
// Unregister preference callbacks
|
2004-04-30 08:06:30 +04:00
|
|
|
nsContentUtils::UnregisterPrefCallback("font.",
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::PrefChangedCallback,
|
2004-04-30 08:06:30 +04:00
|
|
|
this);
|
|
|
|
nsContentUtils::UnregisterPrefCallback("browser.display.",
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::PrefChangedCallback,
|
2004-04-30 08:06:30 +04:00
|
|
|
this);
|
|
|
|
nsContentUtils::UnregisterPrefCallback("browser.underline_anchors",
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::PrefChangedCallback,
|
2004-04-30 08:06:30 +04:00
|
|
|
this);
|
|
|
|
nsContentUtils::UnregisterPrefCallback("browser.anchor_color",
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::PrefChangedCallback,
|
2004-04-30 08:06:30 +04:00
|
|
|
this);
|
|
|
|
nsContentUtils::UnregisterPrefCallback("browser.active_color",
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::PrefChangedCallback,
|
2004-04-30 08:06:30 +04:00
|
|
|
this);
|
|
|
|
nsContentUtils::UnregisterPrefCallback("browser.visited_color",
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::PrefChangedCallback,
|
2004-04-30 08:06:30 +04:00
|
|
|
this);
|
|
|
|
nsContentUtils::UnregisterPrefCallback("image.animation_mode",
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::PrefChangedCallback,
|
2004-04-30 08:06:30 +04:00
|
|
|
this);
|
2004-04-30 07:10:29 +04:00
|
|
|
#ifdef IBMBIDI
|
2004-04-30 08:06:30 +04:00
|
|
|
nsContentUtils::UnregisterPrefCallback("bidi.", PrefChangedCallback, this);
|
|
|
|
|
|
|
|
delete mBidiUtils;
|
2001-03-09 06:13:03 +03:00
|
|
|
#endif // IBMBIDI
|
2007-02-15 12:04:25 +03:00
|
|
|
nsContentUtils::UnregisterPrefCallback("layout.css.dpi",
|
|
|
|
nsPresContext::PrefChangedCallback,
|
|
|
|
this);
|
2003-06-19 22:16:53 +04:00
|
|
|
|
|
|
|
NS_IF_RELEASE(mDeviceContext);
|
2004-01-21 12:35:59 +03:00
|
|
|
NS_IF_RELEASE(mLookAndFeel);
|
2004-06-09 03:53:59 +04:00
|
|
|
NS_IF_RELEASE(mLangGroup);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2005-12-02 15:02:44 +03:00
|
|
|
NS_IMPL_ISUPPORTS1(nsPresContext, nsIObserver)
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2001-09-27 22:34:30 +04:00
|
|
|
#define MAKE_FONT_PREF_KEY(_pref, _s0, _s1) \
|
|
|
|
_pref.Assign(_s0); \
|
|
|
|
_pref.Append(_s1);
|
|
|
|
|
|
|
|
static const char* const kGenericFont[] = {
|
|
|
|
".variable.",
|
|
|
|
".fixed.",
|
|
|
|
".serif.",
|
|
|
|
".sans-serif.",
|
|
|
|
".monospace.",
|
|
|
|
".cursive.",
|
|
|
|
".fantasy."
|
|
|
|
};
|
|
|
|
|
2006-09-12 08:36:03 +04:00
|
|
|
// Set to true when LookAndFeelChanged needs to be called. This is used
|
|
|
|
// because the look and feel is a service, so there's no need to notify it from
|
|
|
|
// more than one prescontext.
|
|
|
|
static PRBool sLookAndFeelChanged;
|
|
|
|
|
|
|
|
// Set to true when ThemeChanged needs to be called on mTheme. This is used
|
|
|
|
// because mTheme is a service, so there's no need to notify it from more than
|
|
|
|
// one prescontext.
|
|
|
|
static PRBool sThemeChanged;
|
|
|
|
|
2000-01-12 19:10:48 +03:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::GetFontPreferences()
|
2000-01-12 19:10:48 +03:00
|
|
|
{
|
2004-06-09 03:53:59 +04:00
|
|
|
if (!mLangGroup)
|
2001-09-27 22:34:30 +04:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* Fetch the font prefs to be used -- see bug 61883 for details.
|
|
|
|
Not all prefs are needed upfront. Some are fallback prefs intended
|
|
|
|
for the GFX font sub-system...
|
|
|
|
|
|
|
|
1) unit : assumed to be the same for all language groups -------------
|
|
|
|
font.size.unit = px | pt XXX could be folded in the size... bug 90440
|
|
|
|
|
|
|
|
2) attributes for generic fonts --------------------------------------
|
|
|
|
font.default = serif | sans-serif - fallback generic font
|
|
|
|
font.name.[generic].[langGroup] = current user' selected font on the pref dialog
|
|
|
|
font.name-list.[generic].[langGroup] = fontname1, fontname2, ... [factory pre-built list]
|
|
|
|
font.size.[generic].[langGroup] = integer - settable by the user
|
|
|
|
font.size-adjust.[generic].[langGroup] = "float" - settable by the user
|
|
|
|
font.minimum-size.[langGroup] = integer - settable by the user
|
|
|
|
*/
|
|
|
|
|
2007-02-07 10:46:44 +03:00
|
|
|
mDefaultVariableFont.size = CSSPixelsToAppUnits(16);
|
|
|
|
mDefaultFixedFont.size = CSSPixelsToAppUnits(13);
|
2001-09-27 22:34:30 +04:00
|
|
|
|
2004-06-09 03:53:59 +04:00
|
|
|
const char *langGroup;
|
|
|
|
mLangGroup->GetUTF8String(&langGroup);
|
2001-09-27 22:34:30 +04:00
|
|
|
|
|
|
|
nsCAutoString pref;
|
|
|
|
|
|
|
|
// get the current applicable font-size unit
|
|
|
|
enum {eUnit_unknown = -1, eUnit_px, eUnit_pt};
|
|
|
|
PRInt32 unit = eUnit_px;
|
2004-04-30 08:06:30 +04:00
|
|
|
|
|
|
|
nsAdoptingCString cvalue =
|
|
|
|
nsContentUtils::GetCharPref("font.size.unit");
|
|
|
|
|
|
|
|
if (!cvalue.IsEmpty()) {
|
|
|
|
if (cvalue.Equals("px")) {
|
2001-09-27 22:34:30 +04:00
|
|
|
unit = eUnit_px;
|
2000-01-12 19:10:48 +03:00
|
|
|
}
|
2004-04-30 08:06:30 +04:00
|
|
|
else if (cvalue.Equals("pt")) {
|
2001-09-27 22:34:30 +04:00
|
|
|
unit = eUnit_pt;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
NS_WARNING("unexpected font-size unit -- expected: 'px' or 'pt'");
|
|
|
|
unit = eUnit_unknown;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// get font.minimum-size.[langGroup]
|
2003-06-24 05:46:50 +04:00
|
|
|
|
|
|
|
pref.Assign("font.minimum-size.");
|
2004-06-09 03:53:59 +04:00
|
|
|
pref.Append(langGroup);
|
2003-06-24 05:46:50 +04:00
|
|
|
|
2004-04-30 08:06:30 +04:00
|
|
|
PRInt32 size = nsContentUtils::GetIntPref(pref.get());
|
2006-08-08 20:43:20 +04:00
|
|
|
if (unit == eUnit_px) {
|
2007-02-07 10:46:44 +03:00
|
|
|
mMinimumFontSize = CSSPixelsToAppUnits(size);
|
2006-08-08 20:43:20 +04:00
|
|
|
}
|
|
|
|
else if (unit == eUnit_pt) {
|
2007-02-07 10:46:44 +03:00
|
|
|
mMinimumFontSize = this->PointsToAppUnits(size);
|
2001-09-27 22:34:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// get attributes specific to each generic font
|
|
|
|
nsCAutoString generic_dot_langGroup;
|
|
|
|
for (PRInt32 eType = eDefaultFont_Variable; eType < eDefaultFont_COUNT; ++eType) {
|
|
|
|
generic_dot_langGroup.Assign(kGenericFont[eType]);
|
2004-06-09 03:53:59 +04:00
|
|
|
generic_dot_langGroup.Append(langGroup);
|
2001-09-27 22:34:30 +04:00
|
|
|
|
2002-12-11 08:11:02 +03:00
|
|
|
nsFont* font;
|
2001-09-27 22:34:30 +04:00
|
|
|
switch (eType) {
|
|
|
|
case eDefaultFont_Variable: font = &mDefaultVariableFont; break;
|
|
|
|
case eDefaultFont_Fixed: font = &mDefaultFixedFont; break;
|
|
|
|
case eDefaultFont_Serif: font = &mDefaultSerifFont; break;
|
|
|
|
case eDefaultFont_SansSerif: font = &mDefaultSansSerifFont; break;
|
|
|
|
case eDefaultFont_Monospace: font = &mDefaultMonospaceFont; break;
|
|
|
|
case eDefaultFont_Cursive: font = &mDefaultCursiveFont; break;
|
|
|
|
case eDefaultFont_Fantasy: font = &mDefaultFantasyFont; break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// set the default variable font (the other fonts are seen as 'generic' fonts
|
|
|
|
// in GFX and will be queried there when hunting for alternative fonts)
|
|
|
|
if (eType == eDefaultFont_Variable) {
|
|
|
|
MAKE_FONT_PREF_KEY(pref, "font.name", generic_dot_langGroup);
|
2004-04-30 08:06:30 +04:00
|
|
|
|
|
|
|
nsAdoptingString value =
|
|
|
|
nsContentUtils::GetStringPref(pref.get());
|
|
|
|
if (!value.IsEmpty()) {
|
2002-12-11 08:11:02 +03:00
|
|
|
font->name.Assign(value);
|
2000-01-15 19:30:13 +03:00
|
|
|
}
|
2001-09-27 22:34:30 +04:00
|
|
|
else {
|
2005-01-24 02:58:32 +03:00
|
|
|
MAKE_FONT_PREF_KEY(pref, "font.default.", langGroup);
|
|
|
|
value = nsContentUtils::GetStringPref(pref.get());
|
2004-04-30 08:06:30 +04:00
|
|
|
if (!value.IsEmpty()) {
|
2002-12-11 08:11:02 +03:00
|
|
|
mDefaultVariableFont.name.Assign(value);
|
2001-09-27 22:34:30 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (eType == eDefaultFont_Monospace) {
|
|
|
|
// This takes care of the confusion whereby people often expect "monospace"
|
|
|
|
// to have the same default font-size as "-moz-fixed" (this tentative
|
|
|
|
// size may be overwritten with the specific value for "monospace" when
|
|
|
|
// "font.size.monospace.[langGroup]" is read -- see below)
|
|
|
|
font->size = mDefaultFixedFont.size;
|
2000-01-15 19:30:13 +03:00
|
|
|
}
|
2001-09-27 22:34:30 +04:00
|
|
|
else if (eType != eDefaultFont_Fixed) {
|
|
|
|
// all the other generic fonts are initialized with the size of the
|
|
|
|
// variable font, but their specific size can supersede later -- see below
|
|
|
|
font->size = mDefaultVariableFont.size;
|
2000-01-15 19:30:13 +03:00
|
|
|
}
|
2001-09-27 22:34:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Bug 84398: for spec purists, a different font-size only applies to the
|
|
|
|
// .variable. and .fixed. fonts and the other fonts should get |font-size-adjust|.
|
|
|
|
// The problem is that only GfxWin has the support for |font-size-adjust|. So for
|
|
|
|
// parity, we enable the ability to set a different font-size on all platforms.
|
|
|
|
|
|
|
|
// get font.size.[generic].[langGroup]
|
|
|
|
// size=0 means 'Auto', i.e., generic fonts retain the size of the variable font
|
|
|
|
MAKE_FONT_PREF_KEY(pref, "font.size", generic_dot_langGroup);
|
2004-04-30 08:06:30 +04:00
|
|
|
size = nsContentUtils::GetIntPref(pref.get());
|
|
|
|
if (size > 0) {
|
2001-09-27 22:34:30 +04:00
|
|
|
if (unit == eUnit_px) {
|
2007-02-07 10:46:44 +03:00
|
|
|
font->size = nsPresContext::CSSPixelsToAppUnits(size);
|
2000-01-15 19:30:13 +03:00
|
|
|
}
|
2001-09-27 22:34:30 +04:00
|
|
|
else if (unit == eUnit_pt) {
|
2007-02-07 10:46:44 +03:00
|
|
|
font->size = this->PointsToAppUnits(size);
|
2000-01-15 19:30:13 +03:00
|
|
|
}
|
2000-01-12 19:10:48 +03:00
|
|
|
}
|
2001-09-27 22:34:30 +04:00
|
|
|
|
|
|
|
// get font.size-adjust.[generic].[langGroup]
|
|
|
|
// XXX only applicable on GFX ports that handle |font-size-adjust|
|
|
|
|
MAKE_FONT_PREF_KEY(pref, "font.size-adjust", generic_dot_langGroup);
|
2004-04-30 08:06:30 +04:00
|
|
|
cvalue = nsContentUtils::GetCharPref(pref.get());
|
|
|
|
if (!cvalue.IsEmpty()) {
|
2001-09-27 22:34:30 +04:00
|
|
|
font->sizeAdjust = (float)atof(cvalue.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG_rbs
|
|
|
|
printf("%s Family-list:%s size:%d sizeAdjust:%.2f\n",
|
2004-04-30 08:06:30 +04:00
|
|
|
generic_dot_langGroup.get(),
|
2006-02-03 17:18:39 +03:00
|
|
|
NS_ConvertUTF16toUTF8(font->name).get(), font->size,
|
2003-06-24 05:46:50 +04:00
|
|
|
font->sizeAdjust);
|
2001-09-27 22:34:30 +04:00
|
|
|
#endif
|
2000-01-12 19:10:48 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-10-17 03:59:25 +04:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::GetDocumentColorPreferences()
|
2001-10-17 03:59:25 +04:00
|
|
|
{
|
2004-06-08 23:34:55 +04:00
|
|
|
PRInt32 useAccessibilityTheme = 0;
|
2001-10-17 03:59:25 +04:00
|
|
|
PRBool usePrefColors = PR_TRUE;
|
2002-11-07 03:59:25 +03:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> docShell(do_QueryReferent(mContainer));
|
2001-10-17 03:59:25 +04:00
|
|
|
if (docShell) {
|
|
|
|
PRInt32 docShellType;
|
|
|
|
docShell->GetItemType(&docShellType);
|
2004-06-08 23:34:55 +04:00
|
|
|
if (nsIDocShellTreeItem::typeChrome == docShellType) {
|
2001-10-17 03:59:25 +04:00
|
|
|
usePrefColors = PR_FALSE;
|
2004-06-08 23:34:55 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
mLookAndFeel->GetMetric(nsILookAndFeel::eMetric_UseAccessibilityTheme, useAccessibilityTheme);
|
|
|
|
usePrefColors = !useAccessibilityTheme;
|
|
|
|
}
|
|
|
|
|
2001-10-17 03:59:25 +04:00
|
|
|
}
|
|
|
|
if (usePrefColors) {
|
2004-04-30 08:06:30 +04:00
|
|
|
usePrefColors =
|
|
|
|
!nsContentUtils::GetBoolPref("browser.display.use_system_colors",
|
|
|
|
PR_FALSE);
|
2001-10-17 03:59:25 +04:00
|
|
|
}
|
2004-04-30 08:06:30 +04:00
|
|
|
|
2001-10-17 03:59:25 +04:00
|
|
|
if (usePrefColors) {
|
2004-04-30 08:06:30 +04:00
|
|
|
nsAdoptingCString colorStr =
|
|
|
|
nsContentUtils::GetCharPref("browser.display.foreground_color");
|
|
|
|
|
|
|
|
if (!colorStr.IsEmpty()) {
|
2001-10-17 03:59:25 +04:00
|
|
|
mDefaultColor = MakeColorPref(colorStr);
|
|
|
|
}
|
2004-04-30 08:06:30 +04:00
|
|
|
|
|
|
|
colorStr =
|
|
|
|
nsContentUtils::GetCharPref("browser.display.background_color");
|
|
|
|
|
|
|
|
if (!colorStr.IsEmpty()) {
|
2004-02-01 01:41:40 +03:00
|
|
|
mBackgroundColor = MakeColorPref(colorStr);
|
2001-10-17 03:59:25 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mDefaultColor = NS_RGB(0x00, 0x00, 0x00);
|
2004-02-01 01:41:40 +03:00
|
|
|
mBackgroundColor = NS_RGB(0xFF, 0xFF, 0xFF);
|
2004-01-21 12:35:59 +03:00
|
|
|
mLookAndFeel->GetColor(nsILookAndFeel::eColor_WindowForeground,
|
|
|
|
mDefaultColor);
|
|
|
|
mLookAndFeel->GetColor(nsILookAndFeel::eColor_WindowBackground,
|
2004-02-01 01:41:40 +03:00
|
|
|
mBackgroundColor);
|
2001-10-17 03:59:25 +04:00
|
|
|
}
|
|
|
|
|
2004-06-08 23:34:55 +04:00
|
|
|
mUseDocumentColors = !useAccessibilityTheme &&
|
2004-04-30 08:06:30 +04:00
|
|
|
nsContentUtils::GetBoolPref("browser.display.use_document_colors",
|
|
|
|
mUseDocumentColors);
|
2001-10-17 03:59:25 +04:00
|
|
|
}
|
|
|
|
|
1998-11-06 19:16:01 +03:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::GetUserPreferences()
|
1998-11-06 19:16:01 +03:00
|
|
|
{
|
2005-11-09 01:45:49 +03:00
|
|
|
if (!GetPresShell()) {
|
|
|
|
// No presshell means nothing to do here. We'll do this when we
|
|
|
|
// get a presshell.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-04-30 08:06:30 +04:00
|
|
|
mFontScaler =
|
|
|
|
nsContentUtils::GetIntPref("browser.display.base_font_scaler",
|
|
|
|
mFontScaler);
|
1998-11-06 19:16:01 +03:00
|
|
|
|
2000-10-11 12:33:01 +04:00
|
|
|
// * document colors
|
2001-10-17 03:59:25 +04:00
|
|
|
GetDocumentColorPreferences();
|
2001-03-29 11:16:06 +04:00
|
|
|
|
2000-10-11 12:33:01 +04:00
|
|
|
// * link colors
|
2004-04-30 08:06:30 +04:00
|
|
|
mUnderlineLinks =
|
|
|
|
nsContentUtils::GetBoolPref("browser.underline_anchors", mUnderlineLinks);
|
|
|
|
|
|
|
|
nsAdoptingCString colorStr =
|
|
|
|
nsContentUtils::GetCharPref("browser.anchor_color");
|
|
|
|
|
|
|
|
if (!colorStr.IsEmpty()) {
|
2002-12-11 08:11:02 +03:00
|
|
|
mLinkColor = MakeColorPref(colorStr);
|
2000-10-11 12:33:01 +04:00
|
|
|
}
|
2004-04-30 08:06:30 +04:00
|
|
|
|
|
|
|
colorStr =
|
|
|
|
nsContentUtils::GetCharPref("browser.active_color");
|
|
|
|
|
|
|
|
if (!colorStr.IsEmpty()) {
|
2003-10-15 05:56:12 +04:00
|
|
|
mActiveLinkColor = MakeColorPref(colorStr);
|
|
|
|
}
|
2004-04-30 08:06:30 +04:00
|
|
|
|
|
|
|
colorStr = nsContentUtils::GetCharPref("browser.visited_color");
|
|
|
|
|
|
|
|
if (!colorStr.IsEmpty()) {
|
2002-12-11 08:11:02 +03:00
|
|
|
mVisitedLinkColor = MakeColorPref(colorStr);
|
2000-10-11 12:33:01 +04:00
|
|
|
}
|
|
|
|
|
2004-04-30 08:06:30 +04:00
|
|
|
mUseFocusColors =
|
|
|
|
nsContentUtils::GetBoolPref("browser.display.use_focus_colors",
|
|
|
|
mUseFocusColors);
|
2001-04-10 02:17:11 +04:00
|
|
|
|
2004-04-30 08:06:30 +04:00
|
|
|
mFocusTextColor = mDefaultColor;
|
|
|
|
mFocusBackgroundColor = mBackgroundColor;
|
|
|
|
|
|
|
|
colorStr = nsContentUtils::GetCharPref("browser.display.focus_text_color");
|
2001-04-10 02:17:11 +04:00
|
|
|
|
2004-04-30 08:06:30 +04:00
|
|
|
if (!colorStr.IsEmpty()) {
|
|
|
|
mFocusTextColor = MakeColorPref(colorStr);
|
2001-04-10 02:17:11 +04:00
|
|
|
}
|
|
|
|
|
2004-04-30 08:06:30 +04:00
|
|
|
colorStr =
|
|
|
|
nsContentUtils::GetCharPref("browser.display.focus_background_color");
|
|
|
|
|
|
|
|
if (!colorStr.IsEmpty()) {
|
|
|
|
mFocusBackgroundColor = MakeColorPref(colorStr);
|
2004-04-30 07:10:29 +04:00
|
|
|
}
|
2004-04-30 03:34:19 +04:00
|
|
|
|
2004-04-30 08:06:30 +04:00
|
|
|
mFocusRingWidth =
|
|
|
|
nsContentUtils::GetIntPref("browser.display.focus_ring_width",
|
|
|
|
mFocusRingWidth);
|
|
|
|
|
|
|
|
mFocusRingOnAnything =
|
|
|
|
nsContentUtils::GetBoolPref("browser.display.focus_ring_on_anything",
|
|
|
|
mFocusRingOnAnything);
|
|
|
|
|
2000-10-11 12:33:01 +04:00
|
|
|
// * use fonts?
|
2004-04-30 08:06:30 +04:00
|
|
|
mUseDocumentFonts =
|
|
|
|
nsContentUtils::GetIntPref("browser.display.use_document_fonts") != 0;
|
|
|
|
|
2004-06-21 14:32:27 +04:00
|
|
|
// * replace backslashes with Yen signs? (bug 245770)
|
|
|
|
mEnableJapaneseTransform =
|
|
|
|
nsContentUtils::GetBoolPref("layout.enable_japanese_specific_transform");
|
|
|
|
|
2006-03-26 04:48:03 +04:00
|
|
|
mPrefScrollbarSide =
|
|
|
|
nsContentUtils::GetIntPref("layout.scrollbar.side");
|
|
|
|
|
2000-01-12 19:10:48 +03:00
|
|
|
GetFontPreferences();
|
2001-01-10 02:55:27 +03:00
|
|
|
|
|
|
|
// * image animation
|
2004-04-30 08:06:30 +04:00
|
|
|
const nsAdoptingCString& animatePref =
|
|
|
|
nsContentUtils::GetCharPref("image.animation_mode");
|
|
|
|
if (animatePref.Equals("normal"))
|
|
|
|
mImageAnimationModePref = imgIContainer::kNormalAnimMode;
|
|
|
|
else if (animatePref.Equals("none"))
|
|
|
|
mImageAnimationModePref = imgIContainer::kDontAnimMode;
|
|
|
|
else if (animatePref.Equals("once"))
|
|
|
|
mImageAnimationModePref = imgIContainer::kLoopOnceAnimMode;
|
2001-11-01 08:49:45 +03:00
|
|
|
|
2005-11-09 01:45:49 +03:00
|
|
|
PRUint32 bidiOptions = GetBidi();
|
|
|
|
|
2004-04-30 08:06:30 +04:00
|
|
|
PRInt32 prefInt =
|
2006-03-26 04:48:03 +04:00
|
|
|
nsContentUtils::GetIntPref(IBMBIDI_TEXTDIRECTION_STR,
|
2005-11-09 01:45:49 +03:00
|
|
|
GET_BIDI_OPTION_DIRECTION(bidiOptions));
|
|
|
|
SET_BIDI_OPTION_DIRECTION(bidiOptions, prefInt);
|
2006-03-26 04:48:03 +04:00
|
|
|
mPrefBidiDirection = prefInt;
|
2004-04-30 08:06:30 +04:00
|
|
|
|
|
|
|
prefInt =
|
2006-03-26 04:48:03 +04:00
|
|
|
nsContentUtils::GetIntPref(IBMBIDI_TEXTTYPE_STR,
|
2005-11-09 01:45:49 +03:00
|
|
|
GET_BIDI_OPTION_TEXTTYPE(bidiOptions));
|
|
|
|
SET_BIDI_OPTION_TEXTTYPE(bidiOptions, prefInt);
|
2004-04-30 08:06:30 +04:00
|
|
|
|
|
|
|
prefInt =
|
2006-03-26 04:48:03 +04:00
|
|
|
nsContentUtils::GetIntPref(IBMBIDI_CONTROLSTEXTMODE_STR,
|
2005-11-09 01:45:49 +03:00
|
|
|
GET_BIDI_OPTION_CONTROLSTEXTMODE(bidiOptions));
|
|
|
|
SET_BIDI_OPTION_CONTROLSTEXTMODE(bidiOptions, prefInt);
|
2004-04-30 08:06:30 +04:00
|
|
|
|
|
|
|
prefInt =
|
2006-03-26 04:48:03 +04:00
|
|
|
nsContentUtils::GetIntPref(IBMBIDI_NUMERAL_STR,
|
2005-11-09 01:45:49 +03:00
|
|
|
GET_BIDI_OPTION_NUMERAL(bidiOptions));
|
|
|
|
SET_BIDI_OPTION_NUMERAL(bidiOptions, prefInt);
|
2004-04-30 08:06:30 +04:00
|
|
|
|
|
|
|
prefInt =
|
2006-03-26 04:48:03 +04:00
|
|
|
nsContentUtils::GetIntPref(IBMBIDI_SUPPORTMODE_STR,
|
2005-11-09 01:45:49 +03:00
|
|
|
GET_BIDI_OPTION_SUPPORT(bidiOptions));
|
|
|
|
SET_BIDI_OPTION_SUPPORT(bidiOptions, prefInt);
|
2004-04-30 08:06:30 +04:00
|
|
|
|
|
|
|
prefInt =
|
2006-03-26 04:48:03 +04:00
|
|
|
nsContentUtils::GetIntPref(IBMBIDI_CHARSET_STR,
|
2005-11-09 01:45:49 +03:00
|
|
|
GET_BIDI_OPTION_CHARACTERSET(bidiOptions));
|
|
|
|
SET_BIDI_OPTION_CHARACTERSET(bidiOptions, prefInt);
|
|
|
|
|
2005-11-13 12:55:09 +03:00
|
|
|
// We don't need to force reflow: either we are initializing a new
|
|
|
|
// prescontext or we are being called from UpdateAfterPreferencesChanged()
|
|
|
|
// which triggers a reflow anyway.
|
|
|
|
SetBidi(bidiOptions, PR_FALSE);
|
1998-11-06 19:16:01 +03:00
|
|
|
}
|
|
|
|
|
2004-01-28 03:18:22 +03:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::ClearStyleDataAndReflow()
|
1998-11-06 19:16:01 +03:00
|
|
|
{
|
1999-09-15 02:16:42 +04:00
|
|
|
if (mShell) {
|
2001-07-25 10:33:06 +04:00
|
|
|
// Clear out all our style data.
|
2004-01-08 01:30:53 +03:00
|
|
|
mShell->StyleSet()->ClearStyleData(this);
|
2001-07-25 10:33:06 +04:00
|
|
|
|
2002-04-29 17:46:29 +04:00
|
|
|
// Force a reflow of the root frame
|
|
|
|
// XXX We really should only do a reflow if a preference that affects
|
|
|
|
// formatting changed, e.g., a font change. If it's just a color change
|
|
|
|
// then we only need to repaint...
|
|
|
|
mShell->StyleChangeReflow();
|
1998-11-06 19:16:01 +03:00
|
|
|
}
|
2000-04-03 01:52:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::PreferenceChanged(const char* aPrefName)
|
2000-04-03 01:52:17 +04:00
|
|
|
{
|
2007-02-15 12:04:25 +03:00
|
|
|
if (!nsCRT::strcmp(aPrefName, "layout.css.dpi")) {
|
|
|
|
nsRect bounds(mVisibleArea);
|
|
|
|
bounds *= 1.0f / AppUnitsPerDevPixel();
|
|
|
|
if (mDeviceContext->CheckDPIChange() && mShell) {
|
|
|
|
mDeviceContext->FlushFontCache();
|
|
|
|
|
|
|
|
nsIViewManager* vm = GetViewManager();
|
|
|
|
nscoord width = DevPixelsToAppUnits(bounds.width);
|
|
|
|
nscoord height = DevPixelsToAppUnits(bounds.height);
|
|
|
|
vm->SetWindowDimensions(width, height);
|
|
|
|
|
|
|
|
ClearStyleDataAndReflow();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2005-08-24 03:52:16 +04:00
|
|
|
// we use a zero-delay timer to coalesce multiple pref updates
|
|
|
|
if (!mPrefChangedTimer)
|
|
|
|
{
|
|
|
|
mPrefChangedTimer = do_CreateInstance("@mozilla.org/timer;1");
|
|
|
|
if (!mPrefChangedTimer)
|
|
|
|
return;
|
|
|
|
mPrefChangedTimer->InitWithFuncCallback(nsPresContext::PrefChangedUpdateTimerCallback, (void*)this, 0, nsITimer::TYPE_ONE_SHOT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsPresContext::UpdateAfterPreferencesChanged()
|
|
|
|
{
|
|
|
|
mPrefChangedTimer = nsnull;
|
|
|
|
|
2002-11-07 03:59:25 +03:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> docShell(do_QueryReferent(mContainer));
|
2001-07-25 10:33:06 +04:00
|
|
|
if (docShell) {
|
|
|
|
PRInt32 docShellType;
|
|
|
|
docShell->GetItemType(&docShellType);
|
|
|
|
if (nsIDocShellTreeItem::typeChrome == docShellType)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-04-03 01:52:17 +04:00
|
|
|
// Initialize our state from the user preferences
|
|
|
|
GetUserPreferences();
|
2000-10-11 12:33:01 +04:00
|
|
|
|
|
|
|
// update the presShell: tell it to set the preference style rules up
|
|
|
|
if (mShell) {
|
|
|
|
mShell->SetPreferenceStyleRules(PR_TRUE);
|
|
|
|
}
|
|
|
|
|
2004-02-03 01:17:21 +03:00
|
|
|
mDeviceContext->FlushFontCache();
|
2004-07-29 23:41:39 +04:00
|
|
|
ClearStyleDataAndReflow();
|
1998-11-06 19:16:01 +03:00
|
|
|
}
|
|
|
|
|
2004-07-29 23:41:39 +04:00
|
|
|
nsresult
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::Init(nsIDeviceContext* aDeviceContext)
|
1998-06-25 08:24:45 +04:00
|
|
|
{
|
|
|
|
NS_ASSERTION(!(mInitialized == PR_TRUE), "attempt to reinit pres context");
|
2004-02-03 01:17:21 +03:00
|
|
|
NS_ENSURE_ARG(aDeviceContext);
|
1998-06-25 08:24:45 +04:00
|
|
|
|
2003-06-19 22:16:53 +04:00
|
|
|
mDeviceContext = aDeviceContext;
|
2004-02-03 01:17:21 +03:00
|
|
|
NS_ADDREF(mDeviceContext);
|
1998-07-31 09:54:59 +04:00
|
|
|
|
2007-02-07 10:46:44 +03:00
|
|
|
if (!mImageLoaders.Init())
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
2004-01-21 12:35:59 +03:00
|
|
|
// Get the look and feel service here; default colors will be initialized
|
2005-11-09 01:45:49 +03:00
|
|
|
// from calling GetUserPreferences() when we get a presshell.
|
2004-01-21 12:35:59 +03:00
|
|
|
nsresult rv = CallGetService(kLookAndFeelCID, &mLookAndFeel);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_ERROR("LookAndFeel service must be implemented for this toolkit");
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2004-02-27 20:17:37 +03:00
|
|
|
mEventManager = new nsEventStateManager();
|
|
|
|
if (!mEventManager)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
2004-02-27 21:24:36 +03:00
|
|
|
NS_ADDREF(mEventManager);
|
|
|
|
|
2004-04-30 08:06:30 +04:00
|
|
|
mLangService = do_GetService(NS_LANGUAGEATOMSERVICE_CONTRACTID);
|
|
|
|
|
|
|
|
// Register callbacks so we're notified when the preferences change
|
|
|
|
nsContentUtils::RegisterPrefCallback("font.",
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::PrefChangedCallback,
|
2004-04-30 08:06:30 +04:00
|
|
|
this);
|
|
|
|
nsContentUtils::RegisterPrefCallback("browser.display.",
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::PrefChangedCallback,
|
2004-04-30 08:06:30 +04:00
|
|
|
this);
|
|
|
|
nsContentUtils::RegisterPrefCallback("browser.underline_anchors",
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::PrefChangedCallback,
|
2004-04-30 08:06:30 +04:00
|
|
|
this);
|
|
|
|
nsContentUtils::RegisterPrefCallback("browser.anchor_color",
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::PrefChangedCallback,
|
2004-04-30 08:06:30 +04:00
|
|
|
this);
|
|
|
|
nsContentUtils::RegisterPrefCallback("browser.active_color",
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::PrefChangedCallback,
|
2004-04-30 08:06:30 +04:00
|
|
|
this);
|
|
|
|
nsContentUtils::RegisterPrefCallback("browser.visited_color",
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::PrefChangedCallback,
|
2004-04-30 08:06:30 +04:00
|
|
|
this);
|
|
|
|
nsContentUtils::RegisterPrefCallback("image.animation_mode",
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::PrefChangedCallback,
|
2004-04-30 08:06:30 +04:00
|
|
|
this);
|
|
|
|
#ifdef IBMBIDI
|
|
|
|
nsContentUtils::RegisterPrefCallback("bidi.", PrefChangedCallback,
|
|
|
|
this);
|
|
|
|
#endif
|
2007-02-15 12:04:25 +03:00
|
|
|
nsContentUtils::RegisterPrefCallback("layout.css.dpi",
|
|
|
|
nsPresContext::PrefChangedCallback,
|
|
|
|
this);
|
2004-04-30 08:06:30 +04:00
|
|
|
|
2004-02-27 20:17:37 +03:00
|
|
|
rv = mEventManager->Init();
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
mEventManager->SetPresContext(this);
|
|
|
|
|
1998-06-25 08:24:45 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
mInitialized = PR_TRUE;
|
|
|
|
#endif
|
|
|
|
|
2007-02-07 10:46:44 +03:00
|
|
|
mBorderWidthTable[NS_STYLE_BORDER_WIDTH_THIN] = CSSPixelsToAppUnits(1);
|
|
|
|
mBorderWidthTable[NS_STYLE_BORDER_WIDTH_MEDIUM] = CSSPixelsToAppUnits(3);
|
|
|
|
mBorderWidthTable[NS_STYLE_BORDER_WIDTH_THICK] = CSSPixelsToAppUnits(5);
|
2004-11-26 21:40:58 +03:00
|
|
|
|
1998-06-25 08:24:45 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// Note: We don't hold a reference on the shell; it has a reference to
|
|
|
|
// us
|
2004-07-29 23:41:39 +04:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::SetShell(nsIPresShell* aShell)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2003-04-25 02:44:48 +04:00
|
|
|
if (mShell) {
|
|
|
|
// Remove ourselves as the charset observer from the shell's doc, because
|
|
|
|
// this shell may be going away for good.
|
2004-08-02 08:52:55 +04:00
|
|
|
nsIDocument *doc = mShell->GetDocument();
|
2003-04-25 02:44:48 +04:00
|
|
|
if (doc) {
|
|
|
|
doc->RemoveCharSetObserver(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
mShell = aShell;
|
2003-04-25 02:44:48 +04:00
|
|
|
|
|
|
|
if (mShell) {
|
2006-07-28 10:22:19 +04:00
|
|
|
nsIDocument *doc = mShell->GetDocument();
|
|
|
|
NS_ASSERTION(doc, "expect document here");
|
|
|
|
if (doc) {
|
|
|
|
// Have to update PresContext's mDocument before calling any other methods.
|
|
|
|
mDocument = doc;
|
|
|
|
}
|
2005-11-09 01:45:49 +03:00
|
|
|
// Initialize our state from the user preferences, now that we
|
|
|
|
// have a presshell, and hence a document.
|
|
|
|
GetUserPreferences();
|
|
|
|
|
2004-08-02 08:52:55 +04:00
|
|
|
if (doc) {
|
2006-03-24 03:09:50 +03:00
|
|
|
nsIURI *docURI = doc->GetDocumentURI();
|
2004-08-02 08:52:55 +04:00
|
|
|
|
2006-04-01 05:19:28 +04:00
|
|
|
if (IsDynamic() && docURI) {
|
2004-08-02 08:52:55 +04:00
|
|
|
PRBool isChrome = PR_FALSE;
|
|
|
|
PRBool isRes = PR_FALSE;
|
2006-03-24 03:09:50 +03:00
|
|
|
docURI->SchemeIs("chrome", &isChrome);
|
|
|
|
docURI->SchemeIs("resource", &isRes);
|
2004-08-02 08:52:55 +04:00
|
|
|
|
|
|
|
if (!isChrome && !isRes)
|
|
|
|
mImageAnimationMode = mImageAnimationModePref;
|
|
|
|
else
|
|
|
|
mImageAnimationMode = imgIContainer::kNormalAnimMode;
|
|
|
|
}
|
2001-01-10 02:55:27 +03:00
|
|
|
|
2004-08-02 08:52:55 +04:00
|
|
|
if (mLangService) {
|
|
|
|
doc->AddCharSetObserver(this);
|
2004-08-10 01:19:15 +04:00
|
|
|
UpdateCharSet(doc->GetDocumentCharacterSet());
|
1999-02-12 20:45:58 +03:00
|
|
|
}
|
1998-09-05 07:52:40 +04:00
|
|
|
}
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2000-09-21 02:59:20 +04:00
|
|
|
void
|
2004-08-10 01:19:15 +04:00
|
|
|
nsPresContext::UpdateCharSet(const nsAFlatCString& aCharSet)
|
2000-09-21 02:59:20 +04:00
|
|
|
{
|
|
|
|
if (mLangService) {
|
2004-06-09 03:53:59 +04:00
|
|
|
NS_IF_RELEASE(mLangGroup);
|
2004-08-10 01:19:15 +04:00
|
|
|
mLangGroup = mLangService->LookupCharSet(aCharSet.get()).get(); // addrefs
|
2004-06-21 14:32:27 +04:00
|
|
|
|
2006-12-26 20:47:52 +03:00
|
|
|
if (mLangGroup == nsGkAtoms::Japanese && mEnableJapaneseTransform) {
|
2004-06-09 03:53:59 +04:00
|
|
|
mLanguageSpecificTransformType =
|
2000-09-21 02:59:20 +04:00
|
|
|
eLanguageSpecificTransformType_Japanese;
|
2004-06-09 03:53:59 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
mLanguageSpecificTransformType =
|
2000-09-21 02:59:20 +04:00
|
|
|
eLanguageSpecificTransformType_None;
|
|
|
|
}
|
2004-06-21 14:32:27 +04:00
|
|
|
// bug 39570: moved from nsLanguageAtomService::LookupCharSet()
|
|
|
|
#if !defined(XP_BEOS)
|
2006-12-26 20:47:52 +03:00
|
|
|
if (mLangGroup == nsGkAtoms::Unicode) {
|
2004-06-21 14:32:27 +04:00
|
|
|
NS_RELEASE(mLangGroup);
|
|
|
|
NS_IF_ADDREF(mLangGroup = mLangService->GetLocaleLanguageGroup());
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
GetFontPreferences();
|
2000-09-21 02:59:20 +04:00
|
|
|
}
|
2001-03-09 06:13:03 +03:00
|
|
|
#ifdef IBMBIDI
|
|
|
|
//ahmed
|
|
|
|
|
2005-11-09 01:45:49 +03:00
|
|
|
switch (GET_BIDI_OPTION_TEXTTYPE(GetBidi())) {
|
2004-08-06 01:38:08 +04:00
|
|
|
|
|
|
|
case IBMBIDI_TEXTTYPE_LOGICAL:
|
|
|
|
SetVisualMode(PR_FALSE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IBMBIDI_TEXTTYPE_VISUAL:
|
|
|
|
SetVisualMode(PR_TRUE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IBMBIDI_TEXTTYPE_CHARSET:
|
|
|
|
default:
|
2004-08-10 01:19:15 +04:00
|
|
|
SetVisualMode(IsVisualCharset(aCharSet));
|
2004-08-06 01:38:08 +04:00
|
|
|
}
|
2001-03-09 06:13:03 +03:00
|
|
|
#endif // IBMBIDI
|
2000-09-21 02:59:20 +04:00
|
|
|
}
|
|
|
|
|
2000-06-02 03:12:26 +04:00
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::Observe(nsISupports* aSubject,
|
2004-07-29 23:41:39 +04:00
|
|
|
const char* aTopic,
|
|
|
|
const PRUnichar* aData)
|
2000-06-02 03:12:26 +04:00
|
|
|
{
|
2001-10-20 00:52:59 +04:00
|
|
|
if (!nsCRT::strcmp(aTopic, "charset")) {
|
2006-02-03 17:18:39 +03:00
|
|
|
UpdateCharSet(NS_LossyConvertUTF16toASCII(aData));
|
2004-02-03 01:17:21 +03:00
|
|
|
mDeviceContext->FlushFontCache();
|
2004-07-29 23:41:39 +04:00
|
|
|
ClearStyleDataAndReflow();
|
2004-02-03 01:17:21 +03:00
|
|
|
|
2001-10-20 00:52:59 +04:00
|
|
|
return NS_OK;
|
2000-09-21 02:59:20 +04:00
|
|
|
}
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
NS_WARNING("unrecognized topic in nsPresContext::Observe");
|
2001-10-20 00:52:59 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
2000-06-02 03:12:26 +04:00
|
|
|
}
|
|
|
|
|
2006-11-30 02:09:13 +03:00
|
|
|
// We may want to replace this with something faster, maybe caching the root prescontext
|
|
|
|
nsPresContext*
|
|
|
|
nsPresContext::RootPresContext()
|
|
|
|
{
|
|
|
|
nsPresContext* pc = this;
|
|
|
|
for (;;) {
|
|
|
|
if (pc->mShell) {
|
|
|
|
nsIFrame* rootFrame = pc->mShell->FrameManager()->GetRootFrame();
|
|
|
|
if (rootFrame) {
|
|
|
|
nsIFrame* f = nsLayoutUtils::GetCrossDocParentFrame(rootFrame);
|
|
|
|
if (f) {
|
2007-03-31 01:11:41 +04:00
|
|
|
pc = f->PresContext();
|
2006-11-30 02:09:13 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return pc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-12-25 00:51:50 +03:00
|
|
|
void
|
2006-12-05 18:46:18 +03:00
|
|
|
nsPresContext::CompatibilityModeChanged()
|
1998-07-31 09:54:59 +04:00
|
|
|
{
|
2003-12-25 00:51:50 +03:00
|
|
|
if (!mShell)
|
|
|
|
return;
|
2000-06-03 01:45:06 +04:00
|
|
|
|
2000-06-22 00:44:59 +04:00
|
|
|
// enable/disable the QuirkSheet
|
2004-01-08 01:30:53 +03:00
|
|
|
mShell->StyleSet()->
|
2006-12-05 18:46:18 +03:00
|
|
|
EnableQuirkStyleSheet(CompatibilityMode() == eCompatibility_NavQuirks);
|
1998-07-31 09:54:59 +04:00
|
|
|
}
|
|
|
|
|
2001-11-14 14:21:54 +03:00
|
|
|
// Helper function for setting Anim Mode on image
|
|
|
|
static void SetImgAnimModeOnImgReq(imgIRequest* aImgReq, PRUint16 aMode)
|
|
|
|
{
|
2003-03-19 06:47:09 +03:00
|
|
|
if (aImgReq) {
|
2001-11-14 14:21:54 +03:00
|
|
|
nsCOMPtr<imgIContainer> imgCon;
|
|
|
|
aImgReq->GetImage(getter_AddRefs(imgCon));
|
|
|
|
if (imgCon) {
|
|
|
|
imgCon->SetAnimationMode(aMode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Enumeration call back for HashTable
|
2007-02-07 10:46:44 +03:00
|
|
|
PR_STATIC_CALLBACK(PLDHashOperator)
|
2007-02-09 23:44:10 +03:00
|
|
|
set_animation_mode(const void * aKey, nsCOMPtr<nsImageLoader>& aData, void* closure)
|
2001-11-14 14:21:54 +03:00
|
|
|
{
|
2007-02-07 10:46:44 +03:00
|
|
|
imgIRequest* imgReq = aData->GetRequest();
|
2001-11-14 17:44:34 +03:00
|
|
|
SetImgAnimModeOnImgReq(imgReq, (PRUint16)NS_PTR_TO_INT32(closure));
|
2007-02-07 10:46:44 +03:00
|
|
|
return PL_DHASH_NEXT;
|
2001-11-14 14:21:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// IMPORTANT: Assumption is that all images for a Presentation
|
|
|
|
// have the same Animation Mode (pavlov said this was OK)
|
|
|
|
//
|
|
|
|
// Walks content and set the animation mode
|
|
|
|
// this is a way to turn on/off image animations
|
2004-08-01 03:15:21 +04:00
|
|
|
void nsPresContext::SetImgAnimations(nsIContent *aParent, PRUint16 aMode)
|
2001-11-14 14:21:54 +03:00
|
|
|
{
|
2003-03-19 06:47:09 +03:00
|
|
|
nsCOMPtr<nsIImageLoadingContent> imgContent(do_QueryInterface(aParent));
|
2001-11-14 14:21:54 +03:00
|
|
|
if (imgContent) {
|
2003-03-19 06:47:09 +03:00
|
|
|
nsCOMPtr<imgIRequest> imgReq;
|
|
|
|
imgContent->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST,
|
|
|
|
getter_AddRefs(imgReq));
|
|
|
|
SetImgAnimModeOnImgReq(imgReq, aMode);
|
2001-11-14 14:21:54 +03:00
|
|
|
}
|
2003-03-19 06:47:09 +03:00
|
|
|
|
2003-09-27 08:18:26 +04:00
|
|
|
PRUint32 count = aParent->GetChildCount();
|
|
|
|
for (PRUint32 i = 0; i < count; ++i) {
|
|
|
|
SetImgAnimations(aParent->GetChildAt(i), aMode);
|
2001-11-14 14:21:54 +03:00
|
|
|
}
|
|
|
|
}
|
2000-05-13 05:39:20 +04:00
|
|
|
|
2003-12-26 07:24:11 +03:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::SetImageAnimationModeInternal(PRUint16 aMode)
|
2000-05-13 05:39:20 +04:00
|
|
|
{
|
2001-11-14 17:03:09 +03:00
|
|
|
NS_ASSERTION(aMode == imgIContainer::kNormalAnimMode ||
|
|
|
|
aMode == imgIContainer::kDontAnimMode ||
|
|
|
|
aMode == imgIContainer::kLoopOnceAnimMode, "Wrong Animation Mode is being set!");
|
|
|
|
|
2004-07-29 23:41:39 +04:00
|
|
|
// Image animation mode cannot be changed when rendering to a printer.
|
2006-04-01 05:19:28 +04:00
|
|
|
if (!IsDynamic())
|
2004-07-29 23:41:39 +04:00
|
|
|
return;
|
|
|
|
|
2001-11-14 14:21:54 +03:00
|
|
|
// This hash table contains a list of background images
|
|
|
|
// so iterate over it and set the mode
|
2004-04-30 08:11:02 +04:00
|
|
|
mImageLoaders.Enumerate(set_animation_mode, NS_INT32_TO_PTR(aMode));
|
2001-11-14 14:21:54 +03:00
|
|
|
|
|
|
|
// Now walk the content tree and set the animation mode
|
|
|
|
// on all the images
|
|
|
|
if (mShell != nsnull) {
|
2004-08-02 08:52:55 +04:00
|
|
|
nsIDocument *doc = mShell->GetDocument();
|
2001-11-14 14:21:54 +03:00
|
|
|
if (doc) {
|
2003-10-22 10:09:48 +04:00
|
|
|
nsIContent *rootContent = doc->GetRootContent();
|
2001-11-14 14:21:54 +03:00
|
|
|
if (rootContent) {
|
|
|
|
SetImgAnimations(rootContent, aMode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-05-13 05:39:20 +04:00
|
|
|
mImageAnimationMode = aMode;
|
|
|
|
}
|
|
|
|
|
2004-07-29 23:41:39 +04:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::SetImageAnimationModeExternal(PRUint16 aMode)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2004-07-29 23:41:39 +04:00
|
|
|
SetImageAnimationModeInternal(aMode);
|
|
|
|
}
|
1998-08-28 00:43:04 +04:00
|
|
|
|
2004-07-29 23:41:39 +04:00
|
|
|
already_AddRefed<nsIFontMetrics>
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::GetMetricsForInternal(const nsFont& aFont)
|
2004-07-29 23:41:39 +04:00
|
|
|
{
|
1999-02-12 20:45:58 +03:00
|
|
|
nsIFontMetrics* metrics = nsnull;
|
2004-06-09 03:53:59 +04:00
|
|
|
mDeviceContext->GetMetricsFor(aFont, mLangGroup, metrics);
|
2004-07-29 23:41:39 +04:00
|
|
|
return metrics;
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<nsIFontMetrics>
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::GetMetricsForExternal(const nsFont& aFont)
|
2004-07-29 23:41:39 +04:00
|
|
|
{
|
|
|
|
return GetMetricsForInternal(aFont);
|
1999-02-12 20:45:58 +03:00
|
|
|
}
|
|
|
|
|
2004-02-01 01:41:40 +03:00
|
|
|
const nsFont*
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::GetDefaultFontInternal(PRUint8 aFontID) const
|
1999-02-12 20:45:58 +03:00
|
|
|
{
|
2004-02-01 01:41:40 +03:00
|
|
|
const nsFont *font;
|
2001-09-27 22:34:30 +04:00
|
|
|
switch (aFontID) {
|
|
|
|
// Special (our default variable width font and fixed width font)
|
|
|
|
case kPresContext_DefaultVariableFont_ID:
|
2004-02-01 01:41:40 +03:00
|
|
|
font = &mDefaultVariableFont;
|
2001-09-27 22:34:30 +04:00
|
|
|
break;
|
|
|
|
case kPresContext_DefaultFixedFont_ID:
|
2004-02-01 01:41:40 +03:00
|
|
|
font = &mDefaultFixedFont;
|
2001-09-27 22:34:30 +04:00
|
|
|
break;
|
|
|
|
// CSS
|
|
|
|
case kGenericFont_serif:
|
2004-02-01 01:41:40 +03:00
|
|
|
font = &mDefaultSerifFont;
|
2001-09-27 22:34:30 +04:00
|
|
|
break;
|
|
|
|
case kGenericFont_sans_serif:
|
2004-02-01 01:41:40 +03:00
|
|
|
font = &mDefaultSansSerifFont;
|
2001-09-27 22:34:30 +04:00
|
|
|
break;
|
|
|
|
case kGenericFont_monospace:
|
2004-02-01 01:41:40 +03:00
|
|
|
font = &mDefaultMonospaceFont;
|
2001-09-27 22:34:30 +04:00
|
|
|
break;
|
|
|
|
case kGenericFont_cursive:
|
2004-02-01 01:41:40 +03:00
|
|
|
font = &mDefaultCursiveFont;
|
2001-09-27 22:34:30 +04:00
|
|
|
break;
|
|
|
|
case kGenericFont_fantasy:
|
2004-02-01 01:41:40 +03:00
|
|
|
font = &mDefaultFantasyFont;
|
2001-09-27 22:34:30 +04:00
|
|
|
break;
|
|
|
|
default:
|
2004-02-01 01:41:40 +03:00
|
|
|
font = nsnull;
|
2001-09-27 22:34:30 +04:00
|
|
|
NS_ERROR("invalid arg");
|
|
|
|
break;
|
|
|
|
}
|
2004-02-01 01:41:40 +03:00
|
|
|
return font;
|
1998-07-17 09:41:41 +04:00
|
|
|
}
|
|
|
|
|
2004-07-29 23:41:39 +04:00
|
|
|
const nsFont*
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::GetDefaultFontExternal(PRUint8 aFontID) const
|
2001-11-03 17:59:39 +03:00
|
|
|
{
|
2004-07-29 23:41:39 +04:00
|
|
|
return GetDefaultFontInternal(aFontID);
|
|
|
|
}
|
2001-11-03 17:59:39 +03:00
|
|
|
|
2005-08-13 15:54:22 +04:00
|
|
|
void
|
|
|
|
nsPresContext::SetTextZoomExternal(float aZoom)
|
|
|
|
{
|
|
|
|
SetTextZoomInternal(aZoom);
|
|
|
|
}
|
|
|
|
|
2004-07-29 23:41:39 +04:00
|
|
|
imgIRequest*
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::LoadImage(imgIRequest* aImage, nsIFrame* aTargetFrame)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2001-08-10 00:22:39 +04:00
|
|
|
// look and see if we have a loader for the target frame.
|
2007-02-07 10:46:44 +03:00
|
|
|
nsCOMPtr<nsImageLoader> loader;
|
2007-02-09 23:44:10 +03:00
|
|
|
mImageLoaders.Get(aTargetFrame, getter_AddRefs(loader));
|
1998-05-09 07:22:01 +04:00
|
|
|
|
2001-08-10 00:22:39 +04:00
|
|
|
if (!loader) {
|
2004-02-19 21:56:13 +03:00
|
|
|
loader = new nsImageLoader();
|
|
|
|
if (!loader)
|
2004-07-29 23:41:39 +04:00
|
|
|
return nsnull;
|
2000-02-15 07:49:32 +03:00
|
|
|
|
2001-08-10 00:22:39 +04:00
|
|
|
loader->Init(aTargetFrame, this);
|
2007-02-09 23:44:10 +03:00
|
|
|
mImageLoaders.Put(aTargetFrame, loader);
|
1998-11-26 21:10:10 +03:00
|
|
|
}
|
1998-11-23 20:18:34 +03:00
|
|
|
|
2004-03-09 06:57:51 +03:00
|
|
|
loader->Load(aImage);
|
1999-04-14 01:49:28 +04:00
|
|
|
|
2004-07-29 23:41:39 +04:00
|
|
|
imgIRequest *request = loader->GetRequest();
|
2001-05-22 02:40:10 +04:00
|
|
|
|
2004-07-29 23:41:39 +04:00
|
|
|
return request;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2001-08-10 00:22:39 +04:00
|
|
|
|
2004-02-01 13:09:07 +03:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::StopImagesFor(nsIFrame* aTargetFrame)
|
1998-11-26 21:10:10 +03:00
|
|
|
{
|
2007-02-07 10:46:44 +03:00
|
|
|
nsCOMPtr<nsImageLoader> loader;
|
2007-02-09 23:44:10 +03:00
|
|
|
mImageLoaders.Get(aTargetFrame, getter_AddRefs(loader));
|
2000-09-22 00:17:04 +04:00
|
|
|
|
2001-08-10 00:22:39 +04:00
|
|
|
if (loader) {
|
|
|
|
loader->Destroy();
|
1998-11-26 21:10:10 +03:00
|
|
|
|
2007-02-09 23:44:10 +03:00
|
|
|
mImageLoaders.Remove(aTargetFrame);
|
1999-04-14 01:49:28 +04:00
|
|
|
}
|
1998-05-09 07:22:01 +04:00
|
|
|
}
|
|
|
|
|
2001-08-10 00:22:39 +04:00
|
|
|
|
2004-02-01 13:09:07 +03:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::SetContainer(nsISupports* aHandler)
|
1999-04-30 13:04:36 +04:00
|
|
|
{
|
2002-11-07 03:59:25 +03:00
|
|
|
mContainer = do_GetWeakReference(aHandler);
|
2001-10-17 03:59:25 +04:00
|
|
|
if (mContainer) {
|
|
|
|
GetDocumentColorPreferences();
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2004-02-01 13:09:07 +03:00
|
|
|
already_AddRefed<nsISupports>
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::GetContainerInternal()
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2007-02-23 01:09:14 +03:00
|
|
|
nsISupports *result = nsnull;
|
2004-02-01 13:09:07 +03:00
|
|
|
if (mContainer)
|
|
|
|
CallQueryReferent(mContainer.get(), &result);
|
2002-11-07 03:59:25 +03:00
|
|
|
|
2004-02-01 13:09:07 +03:00
|
|
|
return result;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1998-06-24 01:53:02 +04:00
|
|
|
|
2004-07-29 23:41:39 +04:00
|
|
|
already_AddRefed<nsISupports>
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::GetContainerExternal()
|
2004-07-29 23:41:39 +04:00
|
|
|
{
|
|
|
|
return GetContainerInternal();
|
|
|
|
}
|
|
|
|
|
2001-03-09 06:13:03 +03:00
|
|
|
#ifdef IBMBIDI
|
2004-04-13 04:28:44 +04:00
|
|
|
PRBool
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::BidiEnabledInternal() const
|
2001-03-09 06:13:03 +03:00
|
|
|
{
|
2004-04-13 04:28:44 +04:00
|
|
|
PRBool bidiEnabled = PR_FALSE;
|
2004-08-01 03:15:21 +04:00
|
|
|
NS_ASSERTION(mShell, "PresShell must be set on PresContext before calling nsPresContext::GetBidiEnabled");
|
2001-03-09 06:13:03 +03:00
|
|
|
if (mShell) {
|
2004-08-02 08:52:55 +04:00
|
|
|
nsIDocument *doc = mShell->GetDocument();
|
2004-08-01 03:15:21 +04:00
|
|
|
NS_ASSERTION(doc, "PresShell has no document in nsPresContext::GetBidiEnabled");
|
2001-03-09 06:13:03 +03:00
|
|
|
if (doc) {
|
2004-04-13 04:28:44 +04:00
|
|
|
bidiEnabled = doc->GetBidiEnabled();
|
2001-03-09 06:13:03 +03:00
|
|
|
}
|
|
|
|
}
|
2004-04-13 04:28:44 +04:00
|
|
|
return bidiEnabled;
|
2001-03-09 06:13:03 +03:00
|
|
|
}
|
|
|
|
|
2004-07-29 23:41:39 +04:00
|
|
|
PRBool
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::BidiEnabledExternal() const
|
2004-07-29 23:41:39 +04:00
|
|
|
{
|
|
|
|
return BidiEnabledInternal();
|
|
|
|
}
|
|
|
|
|
2004-04-13 04:28:44 +04:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::SetBidiEnabled(PRBool aBidiEnabled) const
|
2001-03-09 06:13:03 +03:00
|
|
|
{
|
|
|
|
if (mShell) {
|
2004-08-02 08:52:55 +04:00
|
|
|
nsIDocument *doc = mShell->GetDocument();
|
2001-03-09 06:13:03 +03:00
|
|
|
if (doc) {
|
2001-05-16 17:40:08 +04:00
|
|
|
doc->SetBidiEnabled(aBidiEnabled);
|
2001-03-09 06:13:03 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-07-29 23:41:39 +04:00
|
|
|
nsBidiPresUtils*
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::GetBidiUtils()
|
2001-03-09 06:13:03 +03:00
|
|
|
{
|
2004-07-29 23:41:39 +04:00
|
|
|
if (!mBidiUtils)
|
2001-03-09 06:13:03 +03:00
|
|
|
mBidiUtils = new nsBidiPresUtils;
|
2004-07-29 23:41:39 +04:00
|
|
|
|
|
|
|
return mBidiUtils;
|
2001-03-09 06:13:03 +03:00
|
|
|
}
|
|
|
|
|
2004-07-29 23:41:39 +04:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::SetBidi(PRUint32 aSource, PRBool aForceReflow)
|
2001-03-09 06:13:03 +03:00
|
|
|
{
|
2005-11-13 12:55:09 +03:00
|
|
|
// Don't do all this stuff unless the options have changed.
|
|
|
|
if (aSource == GetBidi()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_ASSERTION(!(aForceReflow && (GetBidi() == 0)),
|
|
|
|
"ForceReflow on new prescontext");
|
|
|
|
|
2006-05-19 14:26:44 +04:00
|
|
|
Document()->SetBidiOptions(aSource);
|
2005-11-09 01:45:49 +03:00
|
|
|
if (IBMBIDI_TEXTDIRECTION_RTL == GET_BIDI_OPTION_DIRECTION(aSource)
|
|
|
|
|| IBMBIDI_NUMERAL_HINDI == GET_BIDI_OPTION_NUMERAL(aSource)) {
|
2001-05-16 17:40:08 +04:00
|
|
|
SetBidiEnabled(PR_TRUE);
|
2001-03-09 06:13:03 +03:00
|
|
|
}
|
2005-11-09 01:45:49 +03:00
|
|
|
if (IBMBIDI_TEXTTYPE_VISUAL == GET_BIDI_OPTION_TEXTTYPE(aSource)) {
|
2001-03-09 06:13:03 +03:00
|
|
|
SetVisualMode(PR_TRUE);
|
|
|
|
}
|
2005-11-09 01:45:49 +03:00
|
|
|
else if (IBMBIDI_TEXTTYPE_LOGICAL == GET_BIDI_OPTION_TEXTTYPE(aSource)) {
|
2001-03-09 06:13:03 +03:00
|
|
|
SetVisualMode(PR_FALSE);
|
|
|
|
}
|
|
|
|
else {
|
2004-08-10 01:19:15 +04:00
|
|
|
nsIDocument* doc = mShell->GetDocument();
|
|
|
|
if (doc) {
|
|
|
|
SetVisualMode(IsVisualCharset(doc->GetDocumentCharacterSet()));
|
|
|
|
}
|
2001-03-09 06:13:03 +03:00
|
|
|
}
|
2005-11-13 12:55:09 +03:00
|
|
|
if (aForceReflow) {
|
2004-07-29 23:41:39 +04:00
|
|
|
ClearStyleDataAndReflow();
|
2001-03-09 06:13:03 +03:00
|
|
|
}
|
|
|
|
}
|
2005-11-09 01:45:49 +03:00
|
|
|
|
|
|
|
PRUint32
|
|
|
|
nsPresContext::GetBidi() const
|
|
|
|
{
|
2006-05-19 14:26:44 +04:00
|
|
|
return Document()->GetBidiOptions();
|
2005-11-09 01:45:49 +03:00
|
|
|
}
|
2001-03-09 06:13:03 +03:00
|
|
|
#endif //IBMBIDI
|
2000-03-21 18:51:59 +03:00
|
|
|
|
2004-07-29 23:41:39 +04:00
|
|
|
nsITheme*
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::GetTheme()
|
2001-12-18 01:51:39 +03:00
|
|
|
{
|
|
|
|
if (!mNoTheme && !mTheme) {
|
|
|
|
mTheme = do_GetService("@mozilla.org/chrome/chrome-native-theme;1");
|
|
|
|
if (!mTheme)
|
|
|
|
mNoTheme = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
2004-07-29 23:41:39 +04:00
|
|
|
return mTheme;
|
2001-12-18 01:51:39 +03:00
|
|
|
}
|
|
|
|
|
2004-07-29 23:41:39 +04:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::ThemeChanged()
|
2001-12-18 01:51:39 +03:00
|
|
|
{
|
2006-09-12 08:36:03 +04:00
|
|
|
if (!mPendingThemeChanged) {
|
|
|
|
sLookAndFeelChanged = PR_TRUE;
|
|
|
|
sThemeChanged = PR_TRUE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIRunnable> ev =
|
|
|
|
new nsRunnableMethod<nsPresContext>(this,
|
|
|
|
&nsPresContext::ThemeChangedInternal);
|
|
|
|
if (NS_SUCCEEDED(NS_DispatchToCurrentThread(ev))) {
|
|
|
|
mPendingThemeChanged = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsPresContext::ThemeChangedInternal()
|
|
|
|
{
|
|
|
|
mPendingThemeChanged = PR_FALSE;
|
|
|
|
|
2001-12-18 01:51:39 +03:00
|
|
|
// Tell the theme that it changed, so it can flush any handles to stale theme
|
|
|
|
// data.
|
2006-09-12 08:36:03 +04:00
|
|
|
if (mTheme && sThemeChanged) {
|
2001-12-18 01:51:39 +03:00
|
|
|
mTheme->ThemeChanged();
|
2006-09-12 08:36:03 +04:00
|
|
|
sThemeChanged = PR_FALSE;
|
|
|
|
}
|
2001-12-18 01:51:39 +03:00
|
|
|
|
|
|
|
// Clear all cached nsILookAndFeel colors.
|
2006-09-12 08:36:03 +04:00
|
|
|
if (mLookAndFeel && sLookAndFeelChanged) {
|
2001-12-18 01:51:39 +03:00
|
|
|
mLookAndFeel->LookAndFeelChanged();
|
2006-09-12 08:36:03 +04:00
|
|
|
sLookAndFeelChanged = PR_FALSE;
|
|
|
|
}
|
2004-09-17 10:27:01 +04:00
|
|
|
|
|
|
|
// We have to clear style data because the assumption of style rule
|
|
|
|
// immutability has been violated since any style rule that uses
|
|
|
|
// system colors or fonts (and probably -moz-appearance as well) has
|
|
|
|
// changed.
|
|
|
|
nsPresContext::ClearStyleDataAndReflow();
|
2001-12-18 01:51:39 +03:00
|
|
|
}
|
|
|
|
|
2004-07-29 23:41:39 +04:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::SysColorChanged()
|
2002-06-04 21:47:54 +04:00
|
|
|
{
|
2006-09-12 08:36:03 +04:00
|
|
|
if (!mPendingSysColorChanged) {
|
|
|
|
sLookAndFeelChanged = PR_TRUE;
|
|
|
|
nsCOMPtr<nsIRunnable> ev =
|
|
|
|
new nsRunnableMethod<nsPresContext>(this,
|
|
|
|
&nsPresContext::SysColorChangedInternal);
|
|
|
|
if (NS_SUCCEEDED(NS_DispatchToCurrentThread(ev))) {
|
|
|
|
mPendingSysColorChanged = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsPresContext::SysColorChangedInternal()
|
|
|
|
{
|
|
|
|
mPendingSysColorChanged = PR_FALSE;
|
|
|
|
|
|
|
|
if (mLookAndFeel && sLookAndFeelChanged) {
|
2002-06-04 21:47:54 +04:00
|
|
|
// Don't use the cached values for the system colors
|
|
|
|
mLookAndFeel->LookAndFeelChanged();
|
2006-09-12 08:36:03 +04:00
|
|
|
sLookAndFeelChanged = PR_FALSE;
|
2002-06-04 21:47:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Reset default background and foreground colors for the document since
|
|
|
|
// they may be using system colors
|
|
|
|
GetDocumentColorPreferences();
|
|
|
|
|
2006-03-17 00:42:50 +03:00
|
|
|
#ifndef MOZ_CAIRO_GFX
|
2002-06-04 21:47:54 +04:00
|
|
|
// Clear out all of the style data since it may contain RGB values
|
|
|
|
// which originated from system colors.
|
2002-09-11 07:03:49 +04:00
|
|
|
nsCOMPtr<nsISelectionImageService> imageService;
|
|
|
|
nsresult result;
|
|
|
|
imageService = do_GetService(kSelectionImageService, &result);
|
|
|
|
if (NS_SUCCEEDED(result) && imageService)
|
|
|
|
{
|
|
|
|
imageService->Reset();
|
|
|
|
}
|
2006-03-17 00:42:50 +03:00
|
|
|
#endif
|
2002-12-14 19:18:57 +03:00
|
|
|
|
|
|
|
// We need to do a full reflow (and view update) here. Clearing the style
|
|
|
|
// data without reflowing/updating views will lead to incorrect change hints
|
|
|
|
// later, because when generating change hints, any style structs which have
|
|
|
|
// been cleared and not reread are assumed to not be used at all.
|
2004-07-29 23:41:39 +04:00
|
|
|
ClearStyleDataAndReflow();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::SetPaginatedScrolling(PRBool aPaginated)
|
2004-07-29 23:41:39 +04:00
|
|
|
{
|
2006-04-01 05:19:28 +04:00
|
|
|
if (mType == eContext_PrintPreview || mType == eContext_PageLayout)
|
2004-07-29 23:41:39 +04:00
|
|
|
mCanPaginatedScroll = aPaginated;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext::SetPrintSettings(nsIPrintSettings *aPrintSettings)
|
2004-07-29 23:41:39 +04:00
|
|
|
{
|
2006-12-26 20:47:52 +03:00
|
|
|
if (mMedium == nsGkAtoms::print)
|
2004-07-29 23:41:39 +04:00
|
|
|
mPrintSettings = aPrintSettings;
|
|
|
|
}
|
|
|
|
|
2005-01-20 06:39:09 +03:00
|
|
|
PRBool
|
|
|
|
nsPresContext::EnsureVisible(PRBool aUnsuppressFocus)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mContainer));
|
|
|
|
if (docShell) {
|
|
|
|
nsCOMPtr<nsIContentViewer> cv;
|
|
|
|
docShell->GetContentViewer(getter_AddRefs(cv));
|
|
|
|
// Make sure this is the content viewer we belong with
|
|
|
|
nsCOMPtr<nsIDocumentViewer> docV(do_QueryInterface(cv));
|
|
|
|
if (docV) {
|
|
|
|
nsCOMPtr<nsPresContext> currentPresContext;
|
|
|
|
docV->GetPresContext(getter_AddRefs(currentPresContext));
|
|
|
|
if (currentPresContext == this) {
|
|
|
|
// OK, this is us. We want to call Show() on the content viewer. But
|
|
|
|
// first, we need to suppress focus changes; otherwise the focus will
|
|
|
|
// get sent to the wrong place (toplevel window).
|
|
|
|
nsCOMPtr<nsPIDOMWindow> privWindow = do_GetInterface(docShell);
|
|
|
|
// XXXbz privWindow should never really be null!
|
|
|
|
nsIFocusController* fc =
|
|
|
|
privWindow ? privWindow->GetRootFocusController() : nsnull;
|
|
|
|
if (fc) {
|
|
|
|
fc->SetSuppressFocus(PR_TRUE,
|
|
|
|
"nsPresContext::EnsureVisible Suppression");
|
|
|
|
}
|
|
|
|
cv->Show();
|
|
|
|
if (fc && aUnsuppressFocus) {
|
|
|
|
fc->SetSuppressFocus(PR_FALSE,
|
|
|
|
"nsPresContext::EnsureVisible Suppression");
|
|
|
|
}
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
2000-04-21 18:59:47 +04:00
|
|
|
#ifdef MOZ_REFLOW_PERF
|
2004-07-29 23:41:39 +04:00
|
|
|
void
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
nsPresContext::CountReflows(const char * aName, nsIFrame * aFrame)
|
2000-04-21 18:59:47 +04:00
|
|
|
{
|
|
|
|
if (mShell) {
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
mShell->CountReflows(aName, aFrame);
|
2000-04-21 18:59:47 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|