зеркало из https://github.com/mozilla/gecko-dev.git
Move the document's bidi state to actually live on the document, and remove
dependencies on nsPresContext in form submission. Fixes bugs 100533, 180861, 293171. r+sr=jst
This commit is contained in:
Родитель
560f560f03
Коммит
06dc79df0f
|
@ -95,8 +95,8 @@ class nsIDOMUserDataHandler;
|
|||
|
||||
// IID for the nsIDocument interface
|
||||
#define NS_IDOCUMENT_IID \
|
||||
{ 0xf529a315, 0xb4ea, 0x449c, \
|
||||
{ 0x93, 0x44, 0x8a, 0xf8, 0x93, 0xfe, 0x6c, 0x4e } }
|
||||
{ 0x6120dffe, 0xf8fc, 0x47b1, \
|
||||
{ 0x98, 0xd3, 0x97, 0x68, 0x0c, 0xc9, 0xc3, 0xcd } }
|
||||
|
||||
// The base value for the content ID counter.
|
||||
// This counter is used by the document to
|
||||
|
@ -273,6 +273,26 @@ public:
|
|||
mBidiEnabled = aBidiEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the bidi options for this document.
|
||||
* @see nsBidiUtils.h
|
||||
*/
|
||||
PRUint32 GetBidiOptions() const
|
||||
{
|
||||
return mBidiOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the bidi options for this document. This just sets the bits;
|
||||
* callers are expected to take action as needed if they want this
|
||||
* change to actually change anything immediately.
|
||||
* @see nsBidiUtils.h
|
||||
*/
|
||||
void SetBidiOptions(PRUint32 aBidiOptions)
|
||||
{
|
||||
mBidiOptions = aBidiOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access HTTP header data (this may also get set from other
|
||||
* sources, like HTML META tags).
|
||||
|
@ -933,6 +953,10 @@ protected:
|
|||
// True if BIDI is enabled.
|
||||
PRBool mBidiEnabled;
|
||||
|
||||
// The bidi options for this document. What this bitfield means is
|
||||
// defined in nsBidiUtils.h
|
||||
PRUint32 mBidiOptions;
|
||||
|
||||
nsXPIDLCString mContentLanguage;
|
||||
nsCString mContentType;
|
||||
|
||||
|
|
|
@ -3300,17 +3300,11 @@ static const DirTable dirAttributes[] = {
|
|||
NS_IMETHODIMP
|
||||
nsDocument::GetDir(nsAString& aDirection)
|
||||
{
|
||||
nsCOMPtr<nsIPresShell> shell = GetShellAt(0);
|
||||
if (shell) {
|
||||
nsPresContext *context = shell->GetPresContext();
|
||||
if (context) {
|
||||
PRUint32 options = context->GetBidi();
|
||||
for (const DirTable* elt = dirAttributes; elt->mName; elt++) {
|
||||
if (GET_BIDI_OPTION_DIRECTION(options) == elt->mValue) {
|
||||
CopyASCIItoUTF16(elt->mName, aDirection);
|
||||
break;
|
||||
}
|
||||
}
|
||||
PRUint32 options = GetBidiOptions();
|
||||
for (const DirTable* elt = dirAttributes; elt->mName; elt++) {
|
||||
if (GET_BIDI_OPTION_DIRECTION(options) == elt->mValue) {
|
||||
CopyASCIItoUTF16(elt->mName, aDirection);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3325,22 +3319,21 @@ nsDocument::GetDir(nsAString& aDirection)
|
|||
NS_IMETHODIMP
|
||||
nsDocument::SetDir(const nsAString& aDirection)
|
||||
{
|
||||
nsIPresShell *shell = GetShellAt(0);
|
||||
|
||||
if (!shell) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsPresContext *context = shell->GetPresContext();
|
||||
NS_ENSURE_TRUE(context, NS_ERROR_UNEXPECTED);
|
||||
|
||||
PRUint32 options = context->GetBidi();
|
||||
PRUint32 options = GetBidiOptions();
|
||||
|
||||
for (const DirTable* elt = dirAttributes; elt->mName; elt++) {
|
||||
if (aDirection == NS_ConvertASCIItoUCS2(elt->mName)) {
|
||||
if (GET_BIDI_OPTION_DIRECTION(options) != elt->mValue) {
|
||||
SET_BIDI_OPTION_DIRECTION(options, elt->mValue);
|
||||
context->SetBidi(options, PR_TRUE);
|
||||
nsIPresShell *shell = GetShellAt(0);
|
||||
if (shell) {
|
||||
nsPresContext *context = shell->GetPresContext();
|
||||
NS_ENSURE_TRUE(context, NS_ERROR_UNEXPECTED);
|
||||
context->SetBidi(options, PR_TRUE);
|
||||
} else {
|
||||
// No presentation; just set it on ourselves
|
||||
SetBidiOptions(options);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
@ -43,7 +43,7 @@ class nsACString;
|
|||
class nsIURI;
|
||||
class nsIInputStream;
|
||||
class nsGenericHTMLElement;
|
||||
class nsPresContext;
|
||||
class nsILinkHandler;
|
||||
class nsIContent;
|
||||
class nsIFormControl;
|
||||
class nsIDOMHTMLElement;
|
||||
|
@ -77,13 +77,13 @@ public:
|
|||
* @param aActionURL the URL to submit to (may be modified with GET contents)
|
||||
* @param aTarget the target window
|
||||
* @param aSource the element responsible for the submission (for web shell)
|
||||
* @param aPresContext the presentation context
|
||||
* @param aLinkHandler the link handler to use
|
||||
* @param aDocShell (out param) the DocShell in which the submission was
|
||||
* loaded
|
||||
* @param aRequest (out param) the Request for the submission
|
||||
*/
|
||||
virtual nsresult SubmitTo(nsIURI* aActionURL, const nsAString& aTarget,
|
||||
nsIContent* aSource, nsPresContext* aPresContext,
|
||||
nsIContent* aSource, nsILinkHandler* aLinkHandler,
|
||||
nsIDocShell** aDocShell,
|
||||
nsIRequest** aRequest) = 0;
|
||||
|
||||
|
@ -126,11 +126,9 @@ public:
|
|||
* Get a submission object based on attributes in the form (ENCTYPE and METHOD)
|
||||
*
|
||||
* @param aForm the form to get a submission object based on
|
||||
* @param aPresContext the presentation context
|
||||
* @param aFormSubmission the form submission object (out param)
|
||||
*/
|
||||
nsresult GetSubmissionFromForm(nsGenericHTMLElement* aForm,
|
||||
nsPresContext* aPresContext,
|
||||
nsIFormSubmission** aFormSubmission);
|
||||
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ public:
|
|||
// nsIFormSubmission
|
||||
//
|
||||
virtual nsresult SubmitTo(nsIURI* aActionURI, const nsAString& aTarget,
|
||||
nsIContent* aSource, nsPresContext* aPresContext,
|
||||
nsIContent* aSource, nsILinkHandler* aLinkHandler,
|
||||
nsIDocShell** aDocShell, nsIRequest** aRequest);
|
||||
|
||||
/**
|
||||
|
@ -191,12 +191,10 @@ public:
|
|||
/**
|
||||
* Get the encoder for a form (suitable to pass in to the constructor).
|
||||
* @param aForm the form in question
|
||||
* @param aPresContext the pres context in which we are submitting
|
||||
* @param aCharset the charset of the form
|
||||
* @param aEncoder the returned encoder [OUT]
|
||||
*/
|
||||
static nsresult GetEncoder(nsGenericHTMLElement* aForm,
|
||||
nsPresContext* aPresContext,
|
||||
const nsACString& aCharset,
|
||||
nsISaveAsCharset** aEncoder);
|
||||
/**
|
||||
|
@ -1133,7 +1131,6 @@ SendJSWarning(nsIContent* aContent,
|
|||
|
||||
nsresult
|
||||
GetSubmissionFromForm(nsGenericHTMLElement* aForm,
|
||||
nsPresContext* aPresContext,
|
||||
nsIFormSubmission** aFormSubmission)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
@ -1141,10 +1138,12 @@ GetSubmissionFromForm(nsGenericHTMLElement* aForm,
|
|||
//
|
||||
// Get all the information necessary to encode the form data
|
||||
//
|
||||
nsIDocument* doc = aForm->GetCurrentDoc();
|
||||
NS_ASSERTION(doc, "Should have doc if we're building submission!");
|
||||
|
||||
// Get BIDI options
|
||||
PRUint8 ctrlsModAtSubmit = 0;
|
||||
PRUint32 bidiOptions = aPresContext->GetBidi();
|
||||
PRUint32 bidiOptions = doc->GetBidiOptions();
|
||||
ctrlsModAtSubmit = GET_BIDI_OPTION_CONTROLSTEXTMODE(bidiOptions);
|
||||
|
||||
// Get encoding type (default: urlencoded)
|
||||
|
@ -1161,8 +1160,7 @@ GetSubmissionFromForm(nsGenericHTMLElement* aForm,
|
|||
|
||||
// Get unicode encoder
|
||||
nsCOMPtr<nsISaveAsCharset> encoder;
|
||||
nsFormSubmission::GetEncoder(aForm, aPresContext, charset,
|
||||
getter_AddRefs(encoder));
|
||||
nsFormSubmission::GetEncoder(aForm, charset, getter_AddRefs(encoder));
|
||||
|
||||
// Get form processor
|
||||
nsCOMPtr<nsIFormProcessor> formProcessor =
|
||||
|
@ -1207,7 +1205,7 @@ GetSubmissionFromForm(nsGenericHTMLElement* aForm,
|
|||
|
||||
nsresult
|
||||
nsFormSubmission::SubmitTo(nsIURI* aActionURI, const nsAString& aTarget,
|
||||
nsIContent* aSource, nsPresContext* aPresContext,
|
||||
nsIContent* aSource, nsILinkHandler* aLinkHandler,
|
||||
nsIDocShell** aDocShell, nsIRequest** aRequest)
|
||||
{
|
||||
nsresult rv;
|
||||
|
@ -1222,14 +1220,13 @@ nsFormSubmission::SubmitTo(nsIURI* aActionURI, const nsAString& aTarget,
|
|||
//
|
||||
// Actually submit the data
|
||||
//
|
||||
nsILinkHandler *handler = aPresContext->GetLinkHandler();
|
||||
NS_ENSURE_TRUE(handler, NS_ERROR_FAILURE);
|
||||
NS_ENSURE_ARG_POINTER(aLinkHandler);
|
||||
|
||||
return handler->OnLinkClickSync(aSource, eLinkVerb_Replace,
|
||||
aActionURI,
|
||||
PromiseFlatString(aTarget).get(),
|
||||
postDataStream, nsnull,
|
||||
aDocShell, aRequest);
|
||||
return aLinkHandler->OnLinkClickSync(aSource, eLinkVerb_Replace,
|
||||
aActionURI,
|
||||
PromiseFlatString(aTarget).get(),
|
||||
postDataStream, nsnull,
|
||||
aDocShell, aRequest);
|
||||
}
|
||||
|
||||
// JBK moved from nsFormFrame - bug 34297
|
||||
|
@ -1307,7 +1304,6 @@ nsFormSubmission::GetSubmitCharset(nsGenericHTMLElement* aForm,
|
|||
// static
|
||||
nsresult
|
||||
nsFormSubmission::GetEncoder(nsGenericHTMLElement* aForm,
|
||||
nsPresContext* aPresContext,
|
||||
const nsACString& aCharset,
|
||||
nsISaveAsCharset** aEncoder)
|
||||
{
|
||||
|
|
|
@ -242,8 +242,7 @@ public:
|
|||
PRInt32* retval);
|
||||
|
||||
protected:
|
||||
nsresult DoSubmitOrReset(nsPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsresult DoSubmitOrReset(nsEvent* aEvent,
|
||||
PRInt32 aMessage);
|
||||
nsresult DoReset();
|
||||
|
||||
|
@ -258,26 +257,22 @@ protected:
|
|||
* @param aPresContext the presentation context
|
||||
* @param aEvent the DOM event that was passed to us for the submit
|
||||
*/
|
||||
nsresult DoSubmit(nsPresContext* aPresContext, nsEvent* aEvent);
|
||||
nsresult DoSubmit(nsEvent* aEvent);
|
||||
|
||||
/**
|
||||
* Prepare the submission object (called by DoSubmit)
|
||||
*
|
||||
* @param aPresContext the presentation context
|
||||
* @param aFormSubmission the submission object
|
||||
* @param aEvent the DOM event that was passed to us for the submit
|
||||
*/
|
||||
nsresult BuildSubmission(nsPresContext* aPresContext,
|
||||
nsCOMPtr<nsIFormSubmission>& aFormSubmission,
|
||||
nsresult BuildSubmission(nsCOMPtr<nsIFormSubmission>& aFormSubmission,
|
||||
nsEvent* aEvent);
|
||||
/**
|
||||
* Perform the submission (called by DoSubmit and FlushPendingSubmission)
|
||||
*
|
||||
* @param aPresContext the presentation context
|
||||
* @param aFormSubmission the submission object
|
||||
*/
|
||||
nsresult SubmitSubmission(nsPresContext* aPresContext,
|
||||
nsIFormSubmission* aFormSubmission);
|
||||
nsresult SubmitSubmission(nsIFormSubmission* aFormSubmission);
|
||||
/**
|
||||
* Walk over the form elements and call SubmitNamesValues() on them to get
|
||||
* their data pumped into the FormSubmitter.
|
||||
|
@ -608,17 +603,15 @@ nsHTMLFormElement::Submit()
|
|||
// Send the submit event
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsPresContext> presContext = GetPresContext();
|
||||
if (presContext) {
|
||||
if (mPendingSubmission) {
|
||||
// aha, we have a pending submission that was not flushed
|
||||
// (this happens when form.submit() is called twice)
|
||||
// we have to delete it and build a new one since values
|
||||
// might have changed inbetween (we emulate IE here, that's all)
|
||||
mPendingSubmission = nsnull;
|
||||
}
|
||||
|
||||
rv = DoSubmitOrReset(presContext, nsnull, NS_FORM_SUBMIT);
|
||||
if (mPendingSubmission) {
|
||||
// aha, we have a pending submission that was not flushed
|
||||
// (this happens when form.submit() is called twice)
|
||||
// we have to delete it and build a new one since values
|
||||
// might have changed inbetween (we emulate IE here, that's all)
|
||||
mPendingSubmission = nsnull;
|
||||
}
|
||||
|
||||
rv = DoSubmitOrReset(nsnull, NS_FORM_SUBMIT);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -628,6 +621,7 @@ nsHTMLFormElement::Reset()
|
|||
// Send the reset event
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsPresContext> presContext = GetPresContext();
|
||||
// XXXbz shouldn't need prescontext here! Fix events!
|
||||
if (presContext) {
|
||||
// Calling HandleDOMEvent() directly so that reset() will work even if
|
||||
// the frame does not exist. This does not have an effect right now, but
|
||||
|
@ -761,7 +755,7 @@ nsHTMLFormElement::HandleDOMEvent(nsPresContext* aPresContext,
|
|||
// to forget it and the form element will build a new one
|
||||
ForgetPendingSubmission();
|
||||
}
|
||||
DoSubmitOrReset(aPresContext, aEvent, aEvent->message);
|
||||
DoSubmitOrReset(aEvent, aEvent->message);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -787,12 +781,9 @@ nsHTMLFormElement::HandleDOMEvent(nsPresContext* aPresContext,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLFormElement::DoSubmitOrReset(nsPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsHTMLFormElement::DoSubmitOrReset(nsEvent* aEvent,
|
||||
PRInt32 aMessage)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aPresContext);
|
||||
|
||||
// Make sure the presentation is up-to-date
|
||||
nsIDocument* doc = GetCurrentDoc();
|
||||
if (doc) {
|
||||
|
@ -807,7 +798,10 @@ nsHTMLFormElement::DoSubmitOrReset(nsPresContext* aPresContext,
|
|||
rv = DoReset();
|
||||
}
|
||||
else if (NS_FORM_SUBMIT == aMessage) {
|
||||
rv = DoSubmit(aPresContext, aEvent);
|
||||
// Don't submit if we're not in a document.
|
||||
if (doc) {
|
||||
rv = DoSubmit(aEvent);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
@ -836,10 +830,11 @@ nsHTMLFormElement::DoReset()
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLFormElement::DoSubmit(nsPresContext* aPresContext, nsEvent* aEvent)
|
||||
nsHTMLFormElement::DoSubmit(nsEvent* aEvent)
|
||||
{
|
||||
NS_ASSERTION(!mIsSubmitting, "Either two people are trying to submit or the "
|
||||
"previous submit was not properly cancelled by the DocShell");
|
||||
NS_ASSERTION(GetCurrentDoc(), "Should never get here without a current doc");
|
||||
if (mIsSubmitting) {
|
||||
// XXX Should this return an error?
|
||||
return NS_OK;
|
||||
|
@ -854,7 +849,7 @@ nsHTMLFormElement::DoSubmit(nsPresContext* aPresContext, nsEvent* aEvent)
|
|||
//
|
||||
// prepare the submission object
|
||||
//
|
||||
BuildSubmission(aPresContext, submission, aEvent);
|
||||
BuildSubmission(submission, aEvent);
|
||||
|
||||
// XXXbz if the script global is that for an sXBL/XBL2 doc, it won't
|
||||
// be a window...
|
||||
|
@ -882,12 +877,11 @@ nsHTMLFormElement::DoSubmit(nsPresContext* aPresContext, nsEvent* aEvent)
|
|||
//
|
||||
// perform the submission
|
||||
//
|
||||
return SubmitSubmission(aPresContext, submission);
|
||||
return SubmitSubmission(submission);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLFormElement::BuildSubmission(nsPresContext* aPresContext,
|
||||
nsCOMPtr<nsIFormSubmission>& aFormSubmission,
|
||||
nsHTMLFormElement::BuildSubmission(nsCOMPtr<nsIFormSubmission>& aFormSubmission,
|
||||
nsEvent* aEvent)
|
||||
{
|
||||
NS_ASSERTION(!mPendingSubmission, "tried to build two submissions!");
|
||||
|
@ -905,7 +899,7 @@ nsHTMLFormElement::BuildSubmission(nsPresContext* aPresContext,
|
|||
//
|
||||
// Get the submission object
|
||||
//
|
||||
rv = GetSubmissionFromForm(this, aPresContext, getter_AddRefs(aFormSubmission));
|
||||
rv = GetSubmissionFromForm(this, getter_AddRefs(aFormSubmission));
|
||||
NS_ENSURE_SUBMIT_SUCCESS(rv);
|
||||
|
||||
//
|
||||
|
@ -918,8 +912,7 @@ nsHTMLFormElement::BuildSubmission(nsPresContext* aPresContext,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLFormElement::SubmitSubmission(nsPresContext* aPresContext,
|
||||
nsIFormSubmission* aFormSubmission)
|
||||
nsHTMLFormElement::SubmitSubmission(nsIFormSubmission* aFormSubmission)
|
||||
{
|
||||
nsresult rv;
|
||||
//
|
||||
|
@ -935,7 +928,14 @@ nsHTMLFormElement::SubmitSubmission(nsPresContext* aPresContext,
|
|||
}
|
||||
|
||||
// If there is no link handler, then we won't actually be able to submit.
|
||||
if (!aPresContext->GetLinkHandler()) {
|
||||
nsIDocument* doc = GetCurrentDoc();
|
||||
if (!doc) {
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupports> container = doc->GetContainer();
|
||||
nsCOMPtr<nsILinkHandler> linkHandler(do_QueryInterface(container));
|
||||
if (!linkHandler) {
|
||||
mIsSubmitting = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -977,7 +977,7 @@ nsHTMLFormElement::SubmitSubmission(nsPresContext* aPresContext,
|
|||
|
||||
nsAutoHandlingUserInputStatePusher userInpStatePusher(mSubmitInitiatedFromUserInput);
|
||||
|
||||
rv = aFormSubmission->SubmitTo(actionURI, target, this, aPresContext,
|
||||
rv = aFormSubmission->SubmitTo(actionURI, target, this, linkHandler,
|
||||
getter_AddRefs(docShell),
|
||||
getter_AddRefs(mSubmittingRequest));
|
||||
}
|
||||
|
@ -1329,8 +1329,7 @@ nsHTMLFormElement::FlushPendingSubmission()
|
|||
//
|
||||
// perform the submission with the stored pending submission
|
||||
//
|
||||
nsCOMPtr<nsPresContext> presContext = GetPresContext();
|
||||
SubmitSubmission(presContext, mPendingSubmission);
|
||||
SubmitSubmission(mPendingSubmission);
|
||||
|
||||
// now delete the pending submission object
|
||||
mPendingSubmission = nsnull;
|
||||
|
|
|
@ -273,8 +273,7 @@ IdAndNameHashInitEntry(PLDHashTable *table, PLDHashEntryHdr *entry,
|
|||
// bother initializing members to 0.
|
||||
|
||||
nsHTMLDocument::nsHTMLDocument()
|
||||
: mCompatMode(eCompatibility_NavQuirks),
|
||||
mTexttype(IBMBIDI_TEXTTYPE_LOGICAL)
|
||||
: mCompatMode(eCompatibility_NavQuirks)
|
||||
{
|
||||
|
||||
// NOTE! nsDocument::operator new() zeroes out all members, so don't
|
||||
|
@ -723,17 +722,12 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
NS_PRECONDITION(nsnull != aContainer, "No content viewer container");
|
||||
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aContainer));
|
||||
|
||||
nsCOMPtr<nsIDocumentCharsetInfo> dcInfo;
|
||||
docShell->GetDocumentCharsetInfo(getter_AddRefs(dcInfo));
|
||||
nsCOMPtr<nsPresContext> cx;
|
||||
docShell->GetPresContext(getter_AddRefs(cx));
|
||||
if(cx){
|
||||
mTexttype = GET_BIDI_OPTION_TEXTTYPE(cx->GetBidi());
|
||||
}
|
||||
PRInt32 textType = GET_BIDI_OPTION_TEXTTYPE(GetBidiOptions());
|
||||
|
||||
//
|
||||
// The following logic is mirrored in nsWebShell::Embed!
|
||||
//
|
||||
|
@ -835,7 +829,7 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
|
|||
|
||||
// ahmed
|
||||
// Check if 864 but in Implicit mode !
|
||||
if ((mTexttype == IBMBIDI_TEXTTYPE_LOGICAL) &&
|
||||
if ((textType == IBMBIDI_TEXTTYPE_LOGICAL) &&
|
||||
(charset.LowerCaseEqualsLiteral("ibm864"))) {
|
||||
charset.AssignLiteral("IBM864i");
|
||||
}
|
||||
|
|
|
@ -265,9 +265,6 @@ protected:
|
|||
/** # of forms in the document, synchronously set */
|
||||
PRInt32 mNumForms;
|
||||
|
||||
// ahmed 12-2
|
||||
PRInt32 mTexttype;
|
||||
|
||||
static PRUint32 gWyciwygSessionCnt;
|
||||
|
||||
static PRBool TryHintCharset(nsIMarkupDocumentViewer* aMarkupDV,
|
||||
|
|
|
@ -492,6 +492,12 @@ nsPresContext::GetDocumentColorPreferences()
|
|||
void
|
||||
nsPresContext::GetUserPreferences()
|
||||
{
|
||||
if (!GetPresShell()) {
|
||||
// No presshell means nothing to do here. We'll do this when we
|
||||
// get a presshell.
|
||||
return;
|
||||
}
|
||||
|
||||
mFontScaler =
|
||||
nsContentUtils::GetIntPref("browser.display.base_font_scaler",
|
||||
mFontScaler);
|
||||
|
@ -572,35 +578,41 @@ nsPresContext::GetUserPreferences()
|
|||
mImageAnimationModePref = imgIContainer::kLoopOnceAnimMode;
|
||||
|
||||
#ifdef IBMBIDI
|
||||
PRUint32 bidiOptions = GetBidi();
|
||||
|
||||
PRInt32 prefInt =
|
||||
nsContentUtils::GetIntPref("bidi.direction",
|
||||
GET_BIDI_OPTION_DIRECTION(mBidi));
|
||||
SET_BIDI_OPTION_DIRECTION(mBidi, prefInt);
|
||||
GET_BIDI_OPTION_DIRECTION(bidiOptions));
|
||||
SET_BIDI_OPTION_DIRECTION(bidiOptions, prefInt);
|
||||
|
||||
prefInt =
|
||||
nsContentUtils::GetIntPref("bidi.texttype",
|
||||
GET_BIDI_OPTION_TEXTTYPE(mBidi));
|
||||
SET_BIDI_OPTION_TEXTTYPE(mBidi, prefInt);
|
||||
GET_BIDI_OPTION_TEXTTYPE(bidiOptions));
|
||||
SET_BIDI_OPTION_TEXTTYPE(bidiOptions, prefInt);
|
||||
|
||||
prefInt =
|
||||
nsContentUtils::GetIntPref("bidi.controlstextmode",
|
||||
GET_BIDI_OPTION_CONTROLSTEXTMODE(mBidi));
|
||||
SET_BIDI_OPTION_CONTROLSTEXTMODE(mBidi, prefInt);
|
||||
GET_BIDI_OPTION_CONTROLSTEXTMODE(bidiOptions));
|
||||
SET_BIDI_OPTION_CONTROLSTEXTMODE(bidiOptions, prefInt);
|
||||
|
||||
prefInt =
|
||||
nsContentUtils::GetIntPref("bidi.numeral",
|
||||
GET_BIDI_OPTION_NUMERAL(mBidi));
|
||||
SET_BIDI_OPTION_NUMERAL(mBidi, prefInt);
|
||||
GET_BIDI_OPTION_NUMERAL(bidiOptions));
|
||||
SET_BIDI_OPTION_NUMERAL(bidiOptions, prefInt);
|
||||
|
||||
prefInt =
|
||||
nsContentUtils::GetIntPref("bidi.support",
|
||||
GET_BIDI_OPTION_SUPPORT(mBidi));
|
||||
SET_BIDI_OPTION_SUPPORT(mBidi, prefInt);
|
||||
GET_BIDI_OPTION_SUPPORT(bidiOptions));
|
||||
SET_BIDI_OPTION_SUPPORT(bidiOptions, prefInt);
|
||||
|
||||
prefInt =
|
||||
nsContentUtils::GetIntPref("bidi.characterset",
|
||||
GET_BIDI_OPTION_CHARACTERSET(mBidi));
|
||||
SET_BIDI_OPTION_CHARACTERSET(mBidi, prefInt);
|
||||
GET_BIDI_OPTION_CHARACTERSET(bidiOptions));
|
||||
SET_BIDI_OPTION_CHARACTERSET(bidiOptions, prefInt);
|
||||
|
||||
// Set on the document, not on ourselves so we don't do the various
|
||||
// extra SetBidi() work.
|
||||
GetDocument()->SetBidiOptions(bidiOptions);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -667,7 +679,7 @@ nsPresContext::Init(nsIDeviceContext* aDeviceContext)
|
|||
NS_ADDREF(mDeviceContext);
|
||||
|
||||
// Get the look and feel service here; default colors will be initialized
|
||||
// from calling GetUserPreferences() below.
|
||||
// from calling GetUserPreferences() when we get a presshell.
|
||||
nsresult rv = CallGetService(kLookAndFeelCID, &mLookAndFeel);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("LookAndFeel service must be implemented for this toolkit");
|
||||
|
@ -709,9 +721,6 @@ nsPresContext::Init(nsIDeviceContext* aDeviceContext)
|
|||
this);
|
||||
#endif
|
||||
|
||||
// Initialize our state from the user preferences
|
||||
GetUserPreferences();
|
||||
|
||||
rv = mEventManager->Init();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
@ -746,6 +755,10 @@ nsPresContext::SetShell(nsIPresShell* aShell)
|
|||
mShell = aShell;
|
||||
|
||||
if (mShell) {
|
||||
// Initialize our state from the user preferences, now that we
|
||||
// have a presshell, and hence a document.
|
||||
GetUserPreferences();
|
||||
|
||||
nsIDocument *doc = mShell->GetDocument();
|
||||
NS_ASSERTION(doc, "expect document here");
|
||||
if (doc) {
|
||||
|
@ -798,7 +811,7 @@ nsPresContext::UpdateCharSet(const nsAFlatCString& aCharSet)
|
|||
#ifdef IBMBIDI
|
||||
//ahmed
|
||||
|
||||
switch (GET_BIDI_OPTION_TEXTTYPE(mBidi)) {
|
||||
switch (GET_BIDI_OPTION_TEXTTYPE(GetBidi())) {
|
||||
|
||||
case IBMBIDI_TEXTTYPE_LOGICAL:
|
||||
SetVisualMode(PR_FALSE);
|
||||
|
@ -1142,15 +1155,15 @@ nsPresContext::GetBidiUtils()
|
|||
void
|
||||
nsPresContext::SetBidi(PRUint32 aSource, PRBool aForceReflow)
|
||||
{
|
||||
mBidi = aSource;
|
||||
if (IBMBIDI_TEXTDIRECTION_RTL == GET_BIDI_OPTION_DIRECTION(mBidi)
|
||||
|| IBMBIDI_NUMERAL_HINDI == GET_BIDI_OPTION_NUMERAL(mBidi)) {
|
||||
GetDocument()->SetBidiOptions(aSource);
|
||||
if (IBMBIDI_TEXTDIRECTION_RTL == GET_BIDI_OPTION_DIRECTION(aSource)
|
||||
|| IBMBIDI_NUMERAL_HINDI == GET_BIDI_OPTION_NUMERAL(aSource)) {
|
||||
SetBidiEnabled(PR_TRUE);
|
||||
}
|
||||
if (IBMBIDI_TEXTTYPE_VISUAL == GET_BIDI_OPTION_TEXTTYPE(mBidi)) {
|
||||
if (IBMBIDI_TEXTTYPE_VISUAL == GET_BIDI_OPTION_TEXTTYPE(aSource)) {
|
||||
SetVisualMode(PR_TRUE);
|
||||
}
|
||||
else if (IBMBIDI_TEXTTYPE_LOGICAL == GET_BIDI_OPTION_TEXTTYPE(mBidi)) {
|
||||
else if (IBMBIDI_TEXTTYPE_LOGICAL == GET_BIDI_OPTION_TEXTTYPE(aSource)) {
|
||||
SetVisualMode(PR_FALSE);
|
||||
}
|
||||
else {
|
||||
|
@ -1163,6 +1176,12 @@ nsPresContext::SetBidi(PRUint32 aSource, PRBool aForceReflow)
|
|||
ClearStyleDataAndReflow();
|
||||
}
|
||||
}
|
||||
|
||||
PRUint32
|
||||
nsPresContext::GetBidi() const
|
||||
{
|
||||
return GetDocument()->GetBidiOptions();
|
||||
}
|
||||
#endif //IBMBIDI
|
||||
|
||||
nsITheme*
|
||||
|
|
|
@ -86,8 +86,8 @@ class nsIRenderingContext;
|
|||
#endif
|
||||
|
||||
#define NS_IPRESCONTEXT_IID \
|
||||
{ 0x96e4bc06, 0x8e72, 0x4941, \
|
||||
{0xa6, 0x6c, 0x70, 0xee, 0x7d, 0x1b, 0x58, 0x21} }
|
||||
{ 0xa7f3a964, 0xbbea, 0x4559, \
|
||||
{ 0x9a, 0x5c, 0x4e, 0x3b, 0x90, 0x38, 0x13, 0x68 } }
|
||||
|
||||
enum nsWidgetType {
|
||||
eWidgetType_Button = 1,
|
||||
|
@ -164,7 +164,7 @@ public:
|
|||
|
||||
nsIPresShell* GetPresShell() const { return mShell; }
|
||||
|
||||
nsIDocument* GetDocument() { return GetPresShell()->GetDocument(); }
|
||||
nsIDocument* GetDocument() const { return GetPresShell()->GetDocument(); }
|
||||
nsIViewManager* GetViewManager() { return GetPresShell()->GetViewManager(); }
|
||||
#ifdef _IMPL_NS_LAYOUT
|
||||
nsStyleSet* StyleSet() { return GetPresShell()->StyleSet(); }
|
||||
|
@ -545,8 +545,10 @@ public:
|
|||
|
||||
/**
|
||||
* Get the Bidi options for the presentation context
|
||||
* Not inline so consumers of nsPresContext are not forced to
|
||||
* include nsIDocument.
|
||||
*/
|
||||
NS_HIDDEN_(PRUint32) GetBidi() const { return mBidi; }
|
||||
NS_HIDDEN_(PRUint32) GetBidi() const;
|
||||
|
||||
/**
|
||||
* Set the Bidi capabilities of the system
|
||||
|
@ -728,7 +730,6 @@ protected:
|
|||
unsigned mIsVisual : 1;
|
||||
unsigned mIsBidiSystem : 1;
|
||||
|
||||
PRUint32 mBidi;
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
PRBool mInitialized;
|
||||
|
|
Загрузка…
Ссылка в новой задаче