Attachment #181828: new patch for bug #274784

View | Details | Raw Unified | Return to bug 274784
Collapse All | Expand All

(-)accessible/src/base/nsAccessNode.cpp (-1 / +3 lines)
Line     Link Here 
 Lines 498-504   nsAccessNode::GetDocShellTreeItemFor(nsI Link Here 
498
  NS_ASSERTION(doc, "No document for node passed in");
498
  NS_ASSERTION(doc, "No document for node passed in");
499
  nsCOMPtr<nsISupports> container = doc->GetContainer();
499
  nsCOMPtr<nsISupports> container = doc->GetContainer();
500
  nsIDocShellTreeItem *docShellTreeItem = nsnull;
500
  nsIDocShellTreeItem *docShellTreeItem = nsnull;
501
  CallQueryInterface(container, &docShellTreeItem);
501
  if (container) {
502
    CallQueryInterface(container, &docShellTreeItem);
503
  }
502
504
503
  return docShellTreeItem;
505
  return docShellTreeItem;
504
}
506
}
(-)browser/app/profile/firefox.js (+1 lines)
Line     Link Here 
 Lines 199-204   pref("browser.search.basic.min_ver", "0. Link Here 
199
199
200
pref("browser.history.grouping", "day");
200
pref("browser.history.grouping", "day");
201
pref("browser.sessionhistory.max_entries", 50);
201
pref("browser.sessionhistory.max_entries", 50);
202
pref("browser.sessionhistory.max_viewers", 5);
202
203
203
// handle external links
204
// handle external links
204
// 0=default window, 1=current window/tab, 2=new window, 3=new tab in most recent window
205
// 0=default window, 1=current window/tab, 2=new window, 3=new tab in most recent window
(-)content/base/public/nsIDocument.h (-3 / +23 lines)
Line     Link Here 
 Lines 52-57    Link Here 
52
#include "nsCRT.h"
52
#include "nsCRT.h"
53
#include "mozFlushType.h"
53
#include "mozFlushType.h"
54
#include "nsPropertyTable.h"
54
#include "nsPropertyTable.h"
55
#include "pldhash.h"
55
56
56
class nsIAtom;
57
class nsIAtom;
57
class nsIContent;
58
class nsIContent;
 Lines 88-97   class nsHTMLStyleSheet; Link Here 
88
class nsIHTMLCSSStyleSheet;
89
class nsIHTMLCSSStyleSheet;
89
90
90
// IID for the nsIDocument interface
91
// IID for the nsIDocument interface
91
// f01b47c6-6271-4c0d-b786-eb5eee222b45
92
#define NS_IDOCUMENT_IID      \
92
#define NS_IDOCUMENT_IID      \
93
{ 0xf01b47c6, 0x6271, 0x4c0d, \
93
{ 0x8bc6ae5f, 0xb396, 0x11d9, \
94
  { 0xb7, 0x86, 0xeb, 0x5e, 0xee, 0x22, 0x2b, 0x45 } }
94
  { 0xb1, 0x4f, 0x00, 0x11, 0x24, 0x78, 0xd6, 0x26 } }
95
95
96
// The base value for the content ID counter.
96
// The base value for the content ID counter.
97
// This counter is used by the document to 
97
// This counter is used by the document to 
 Lines 665-670   public: Link Here 
665
    return mPartID;
665
    return mPartID;
666
  }
666
  }
667
667
668
  /**
669
   * Sanitize the document by resetting all input elements and forms that have
670
   * autocomplete=off to their default values.
671
   */
672
  virtual nsresult Sanitize() = 0;
673
674
  /**
675
   * Enumerate all subdocuments.
676
   */
677
  typedef PRBool (*nsSubDocEnumFunc)(nsIDocument *aDocument, void *aData);
678
  virtual void EnumerateSubDocuments(nsSubDocEnumFunc aCallback,
679
                                     void *aData) = 0;
680
681
  /**
682
   * Check whether there are any requests in our loadgroup or the loadgroups
683
   * of any child documents, recursively.  aIgnoreRequest may be set to a
684
   * specific request to ignore (it can be null).
685
   */
686
  virtual PRBool HasRequests(nsIRequest *aIgnoreRequest) = 0;
687
668
protected:
688
protected:
669
  ~nsIDocument()
689
  ~nsIDocument()
670
  {
690
  {
(-)content/base/src/nsDocument.cpp (-33 / +180 lines)
Line     Link Here 
 Lines 126-131   static NS_DEFINE_CID(kDOMEventGroupCID, Link Here 
126
126
127
#include "nsIScriptContext.h"
127
#include "nsIScriptContext.h"
128
#include "nsBindingManager.h"
128
#include "nsBindingManager.h"
129
#include "nsIDOMHTMLFormElement.h"
130
#include "nsIRequest.h"
129
131
130
#include "nsICharsetAlias.h"
132
#include "nsICharsetAlias.h"
131
static NS_DEFINE_CID(kCharsetAliasCID, NS_CHARSETALIAS_CID);
133
static NS_DEFINE_CID(kCharsetAliasCID, NS_CHARSETALIAS_CID);
 Lines 1616-1622   nsDocument::RemoveStyleSheet(nsIStyleShe Link Here 
1616
    return;
1618
    return;
1617
  }
1619
  }
1618
1620
1619
  if (!mIsGoingAway) {
1621
  // If there is no script global object, we assume that either:
1622
  //   1) Document teardown is in progress
1623
  //   2) The document is in session history not being shown; it should not be
1624
  //      possible for RemoveStyleSheet to be called in this case.
1625
1626
  if (mScriptGlobalObject) {
1620
    PRBool applicable = PR_TRUE;
1627
    PRBool applicable = PR_TRUE;
1621
    aSheet->GetApplicable(applicable);
1628
    aSheet->GetApplicable(applicable);
1622
    if (applicable) {
1629
    if (applicable) {
 Lines 1832-1838   nsDocument::GetScriptGlobalObject() cons Link Here 
1832
   // ScriptGlobalObject.  We can, however, try to obtain it for the
1839
   // ScriptGlobalObject.  We can, however, try to obtain it for the
1833
   // caller through our docshell.
1840
   // caller through our docshell.
1834
1841
1835
   if (mIsGoingAway) {
1842
   if (!mScriptGlobalObject) {
1836
     nsCOMPtr<nsIInterfaceRequestor> requestor =
1843
     nsCOMPtr<nsIInterfaceRequestor> requestor =
1837
       do_QueryReferent(mDocumentContainer);
1844
       do_QueryReferent(mDocumentContainer);
1838
     if (requestor) {
1845
     if (requestor) {
 Lines 1847-1883   nsDocument::GetScriptGlobalObject() cons Link Here 
1847
void
1854
void
1848
nsDocument::SetScriptGlobalObject(nsIScriptGlobalObject *aScriptGlobalObject)
1855
nsDocument::SetScriptGlobalObject(nsIScriptGlobalObject *aScriptGlobalObject)
1849
{
1856
{
1850
  // XXX HACK ALERT! If the script context owner is null, the document
1851
  // will soon be going away. So tell our content that to lose its
1852
  // reference to the document. This has to be done before we actually
1853
  // set the script context owner to null so that the content elements
1854
  // can remove references to their script objects.
1855
  if (!aScriptGlobalObject) {
1856
    PRInt32 count, indx;
1857
1858
    count = mChildren.Count();
1859
1860
    mIsGoingAway = PR_TRUE;
1861
1862
    for (indx = 0; indx < count; ++indx) {
1863
      mChildren[indx]->UnbindFromTree();
1864
    }
1865
1866
    // Propagate the out-of-band notification to each PresShell's
1867
    // anonymous content as well. This ensures that there aren't any
1868
    // accidental script references left in anonymous content keeping
1869
    // the document alive. (While not strictly necessary -- the
1870
    // PresShell owns us -- it's tidy.)
1871
    for (count = mPresShells.Count() - 1; count >= 0; --count) {
1872
      nsCOMPtr<nsIPresShell> shell =
1873
        NS_STATIC_CAST(nsIPresShell*, mPresShells[count]);
1874
      if (!shell)
1875
        continue;
1876
1877
      shell->ReleaseAnonymousContent();
1878
    }
1879
  }
1880
1881
  mScriptGlobalObject = aScriptGlobalObject;
1857
  mScriptGlobalObject = aScriptGlobalObject;
1882
}
1858
}
1883
1859
 Lines 4574-4576   nsDocument::UnsetProperty(nsIAtom *aProp Link Here 
4574
{
4550
{
4575
  return mPropertyTable.UnsetProperty(this, aPropertyName, aStatus);
4551
  return mPropertyTable.UnsetProperty(this, aPropertyName, aStatus);
4576
}
4552
}
4553
4554
nsresult
4555
nsDocument::Sanitize()
4556
{
4557
    // Sanitize the document by resetting all password fields and any form
4558
    // fields with autocomplete=off to their default values.  We do this now,
4559
    // instead of when the presentation is restored, to offer some protection
4560
    // in case there is ever an exploit that allows a cached document to be
4561
    // accessed from a different document.
4562
4563
    // First locate all input elements, regardless of whether they are
4564
    // in a form, and reset the password and autocomplete=off elements.
4565
4566
    nsCOMPtr<nsIDOMNodeList> nodes;
4567
    nsresult rv = GetElementsByTagName(NS_LITERAL_STRING("input"),
4568
                                       getter_AddRefs(nodes));
4569
    NS_ENSURE_SUCCESS(rv, rv);
4570
4571
    PRUint32 length = 0;
4572
    if (nodes)
4573
        nodes->GetLength(&length);
4574
4575
    nsCOMPtr<nsIDOMNode> item;
4576
    nsCOMPtr<nsIDOMHTMLInputElement> input;
4577
    nsAutoString value;
4578
    PRUint32 i;
4579
4580
    for (i = 0; i < length; ++i) {
4581
        nodes->Item(i, getter_AddRefs(item));
4582
        NS_ASSERTION(item, "null item in node list!");
4583
4584
        input = do_QueryInterface(item);
4585
        if (!input)
4586
            continue;
4587
4588
        PRBool resetValue = PR_FALSE;
4589
4590
        input->GetAttribute(NS_LITERAL_STRING("autocomplete"), value);
4591
        if (value.LowerCaseEqualsLiteral("off")) {
4592
            resetValue = PR_TRUE;
4593
        } else {
4594
            input->GetType(value);
4595
            if (value.LowerCaseEqualsLiteral("password"))
4596
                resetValue = PR_TRUE;
4597
        }
4598
4599
        if (resetValue) {
4600
            nsCOMPtr<nsIFormControl> fc = do_QueryInterface(input);
4601
            fc->Reset();
4602
        }
4603
    }
4604
4605
    // Now locate all _form_ elements that have autocomplete=off and reset them
4606
    rv = GetElementsByTagName(NS_LITERAL_STRING("form"),
4607
                              getter_AddRefs(nodes));
4608
    NS_ENSURE_SUCCESS(rv, rv);
4609
4610
    length = 0;
4611
    if (nodes)
4612
        nodes->GetLength(&length);
4613
4614
    nsCOMPtr<nsIDOMHTMLFormElement> form;
4615
4616
    for (i = 0; i < length; ++i) {
4617
        nodes->Item(i, getter_AddRefs(item));
4618
        NS_ASSERTION(item, "null item in nodelist");
4619
4620
        form = do_QueryInterface(item);
4621
        if (!form)
4622
            continue;
4623
4624
        form->GetAttribute(NS_LITERAL_STRING("autocomplete"), value);
4625
        if (value.LowerCaseEqualsLiteral("off"))
4626
            form->Reset();
4627
    }
4628
4629
    return NS_OK;
4630
}
4631
4632
struct SubDocEnumData
4633
{
4634
  nsIDocument::nsSubDocEnumFunc callback;
4635
  void *data;
4636
};
4637
4638
PR_STATIC_CALLBACK(PLDHashOperator)
4639
SubDocHashEnum(PLDHashTable *table, PLDHashEntryHdr *hdr,
4640
               PRUint32 number, void *arg)
4641
{
4642
  SubDocMapEntry *entry = NS_STATIC_CAST(SubDocMapEntry*, hdr);
4643
  SubDocEnumData *data = NS_STATIC_CAST(SubDocEnumData*, arg);
4644
4645
  nsIDocument *subdoc = entry->mSubDocument;
4646
  PRBool next = PR_TRUE;
4647
4648
  if (subdoc)
4649
    next = data->callback(subdoc, data->data);
4650
4651
  return next ? PL_DHASH_NEXT : PL_DHASH_STOP;
4652
}
4653
4654
void
4655
nsDocument::EnumerateSubDocuments(nsSubDocEnumFunc aCallback, void *aData)
4656
{
4657
  if (mSubDocuments) {
4658
    SubDocEnumData data = { aCallback, aData };
4659
    PL_DHashTableEnumerate(mSubDocuments, SubDocHashEnum, &data);
4660
  }
4661
}
4662
4663
PR_STATIC_CALLBACK(PLDHashOperator)
4664
SubDocHasRequests(PLDHashTable *table, PLDHashEntryHdr *hdr,
4665
                  PRUint32 number, void *arg)
4666
{
4667
  SubDocMapEntry *entry = NS_STATIC_CAST(SubDocMapEntry*, hdr);
4668
  PRBool *hasRequests = NS_STATIC_CAST(PRBool*, arg);
4669
4670
  nsIDocument *subdoc = entry->mSubDocument;
4671
4672
  // The aIgnoreRequest we were passed is only for us, so don't pass it on.
4673
  PRBool hasRequest = subdoc ? PR_FALSE : subdoc->HasRequests(nsnull);
4674
  if (hasRequest) {
4675
    *hasRequests = PR_TRUE;
4676
    return PL_DHASH_STOP;
4677
  }
4678
4679
  return PL_DHASH_NEXT;
4680
}
4681
4682
#ifdef DEBUG_bryner
4683
#define DEBUG_PAGE_CACHE
4684
#endif
4685
4686
PRBool
4687
nsDocument::HasRequests(nsIRequest *aIgnoreRequest)
4688
{
4689
  nsCOMPtr<nsILoadGroup> loadGroup = GetDocumentLoadGroup();
4690
  if (loadGroup) {
4691
    nsCOMPtr<nsISimpleEnumerator> requests;
4692
    loadGroup->GetRequests(getter_AddRefs(requests));
4693
4694
    PRBool hasMore = PR_FALSE;
4695
    nsCOMPtr<nsISupports> elem;
4696
    nsCOMPtr<nsIRequest> request;
4697
4698
    while (NS_SUCCEEDED(requests->HasMoreElements(&hasMore)) && hasMore) {
4699
      requests->GetNext(getter_AddRefs(elem));
4700
      request = do_QueryInterface(elem);
4701
      if (request && request != aIgnoreRequest) {
4702
#ifdef DEBUG_PAGE_CACHE
4703
        nsCAutoString requestName, docSpec;
4704
        request->GetName(requestName);
4705
        if (mDocumentURI)
4706
          mDocumentURI->GetSpec(docSpec);
4707
4708
        printf("document %s has request %s\n",
4709
               docSpec.get(), requestName.get());
4710
#endif
4711
        return PR_TRUE;
4712
      }
4713
    }
4714
  }
4715
4716
  PRBool subDocsHaveRequests = PR_FALSE;
4717
  if (mSubDocuments) {
4718
    PL_DHashTableEnumerate(mSubDocuments, SubDocHasRequests,
4719
                           &subDocsHaveRequests);
4720
  }
4721
4722
  return subDocsHaveRequests;
4723
}
(-)content/base/src/nsDocument.h (-3 / +7 lines)
Line     Link Here 
 Lines 524-529   public: Link Here 
524
  virtual NS_HIDDEN_(void*) UnsetProperty(nsIAtom  *aPropertyName,
524
  virtual NS_HIDDEN_(void*) UnsetProperty(nsIAtom  *aPropertyName,
525
                                          nsresult *aStatus = nsnull);
525
                                          nsresult *aStatus = nsnull);
526
526
527
  virtual NS_HIDDEN_(nsresult) Sanitize();
528
529
  virtual NS_HIDDEN_(void) EnumerateSubDocuments(nsSubDocEnumFunc aCallback,
530
                                                 void *aData);
531
532
  virtual NS_HIDDEN_(PRBool) HasRequests(nsIRequest *aIgnoreRequest);
533
527
protected:
534
protected:
528
535
529
  void RetrieveRelevantHeaders(nsIChannel *aChannel);
536
  void RetrieveRelevantHeaders(nsIChannel *aChannel);
 Lines 583-591   protected: Link Here 
583
  nsHashtable mRadioGroups;
590
  nsHashtable mRadioGroups;
584
591
585
  // True if the document is being destroyed.
592
  // True if the document is being destroyed.
586
  PRPackedBool mIsGoingAway;
587
588
  // True if the document is being destroyed.
589
  PRPackedBool mInDestructor;
593
  PRPackedBool mInDestructor;
590
594
591
  PRUint8 mXMLDeclarationBits;
595
  PRUint8 mXMLDeclarationBits;
(-)content/base/src/nsSyncLoadService.cpp (+20 lines)
Line     Link Here 
 Lines 120-125   public: Link Here 
120
    NS_IMETHOD Unload(nsIDOMEvent* aEvent);
120
    NS_IMETHOD Unload(nsIDOMEvent* aEvent);
121
    NS_IMETHOD Abort(nsIDOMEvent* aEvent);
121
    NS_IMETHOD Abort(nsIDOMEvent* aEvent);
122
    NS_IMETHOD Error(nsIDOMEvent* aEvent);
122
    NS_IMETHOD Error(nsIDOMEvent* aEvent);
123
    NS_IMETHOD PageRestore(nsIDOMEvent* aEvent);
123
124
124
    NS_DECL_NSICHANNELEVENTSINK
125
    NS_DECL_NSICHANNELEVENTSINK
125
126
 Lines 161-166   public: Link Here 
161
    NS_IMETHOD Unload(nsIDOMEvent* aEvent);
162
    NS_IMETHOD Unload(nsIDOMEvent* aEvent);
162
    NS_IMETHOD Abort(nsIDOMEvent* aEvent);
163
    NS_IMETHOD Abort(nsIDOMEvent* aEvent);
163
    NS_IMETHOD Error(nsIDOMEvent* aEvent);
164
    NS_IMETHOD Error(nsIDOMEvent* aEvent);
165
    NS_IMETHOD PageRestore(nsIDOMEvent* aEvent);
164
166
165
protected:
167
protected:
166
    nsWeakPtr  mParent;
168
    nsWeakPtr  mParent;
 Lines 249-254   txLoadListenerProxy::Error(nsIDOMEvent* Link Here 
249
    return NS_OK;
251
    return NS_OK;
250
}
252
}
251
253
254
NS_IMETHODIMP
255
txLoadListenerProxy::PageRestore(nsIDOMEvent* aEvent)
256
{
257
    nsCOMPtr<nsIDOMLoadListener> listener = do_QueryReferent(mParent);
258
259
    if (listener) {
260
        return listener->PageRestore(aEvent);
261
    }
262
263
    return NS_OK;
264
}
265
252
class nsForceXMLListener : public nsIStreamListener
266
class nsForceXMLListener : public nsIStreamListener
253
{
267
{
254
public:
268
public:
 Lines 513-518   nsSyncLoader::Error(nsIDOMEvent* aEvent) Link Here 
513
}
527
}
514
528
515
NS_IMETHODIMP
529
NS_IMETHODIMP
530
nsSyncLoader::PageRestore(nsIDOMEvent* aEvent)
531
{
532
    return NS_OK;
533
}
534
535
NS_IMETHODIMP
516
nsSyncLoader::OnChannelRedirect(nsIChannel *aOldChannel,
536
nsSyncLoader::OnChannelRedirect(nsIChannel *aOldChannel,
517
                                nsIChannel *aNewChannel,
537
                                nsIChannel *aNewChannel,
518
                                PRUint32    aFlags)
538
                                PRUint32    aFlags)
(-)content/events/public/nsIEventListenerManager.h (-3 / +8 lines)
Line     Link Here 
 Lines 53-61   class nsIAtom; Link Here 
53
 * Event listener manager interface.
53
 * Event listener manager interface.
54
 */
54
 */
55
#define NS_IEVENTLISTENERMANAGER_IID \
55
#define NS_IEVENTLISTENERMANAGER_IID \
56
{ /* cd91bcf0-ded9-11d1-bd85-00805f8ae3f4 */ \
56
{0xc23b877c, 0xb396, 0x11d9, \
57
0xcd91bcf0, 0xded9, 0x11d1, \
57
{0x86, 0xbd, 0x00, 0x11, 0x24, 0x78, 0xd6, 0x26} }
58
{0xbd, 0x85, 0x00, 0x80, 0x5f, 0x8a, 0xe3, 0xf4} }
59
58
60
class nsIEventListenerManager : public nsISupports {
59
class nsIEventListenerManager : public nsISupports {
61
60
 Lines 182-187   public: Link Here 
182
  * Loop pass for evaluation of system event listeners.
181
  * Loop pass for evaluation of system event listeners.
183
  */
182
  */
184
  NS_IMETHOD GetSystemEventGroupLM(nsIDOMEventGroup** aGroup) = 0;
183
  NS_IMETHOD GetSystemEventGroupLM(nsIDOMEventGroup** aGroup) = 0;
184
185
  /**
186
   * Allows us to quickly determine if we have unload or beforeunload
187
   * listeners registered.
188
   */
189
  virtual PRBool HasUnloadListeners() = 0;
185
};
190
};
186
191
187
nsresult
192
nsresult
(-)content/events/src/nsDOMEvent.cpp (-2 / +6 lines)
Line     Link Here 
 Lines 58-65   static const char* const sEventNames[] = Link Here 
58
  "mousedown", "mouseup", "click", "dblclick", "mouseover",
58
  "mousedown", "mouseup", "click", "dblclick", "mouseover",
59
  "mouseout", "mousemove", "contextmenu", "keydown", "keyup", "keypress",
59
  "mouseout", "mousemove", "contextmenu", "keydown", "keyup", "keypress",
60
  "focus", "blur", "load", "beforeunload", "unload", "abort", "error",
60
  "focus", "blur", "load", "beforeunload", "unload", "abort", "error",
61
  "submit", "reset", "change", "select", "input", "paint" ,"text",
61
  "DOMPageRestore", "submit", "reset", "change", "select", "input", "paint",
62
  "compositionstart", "compositionend", "popupshowing", "popupshown",
62
  "text", "compositionstart", "compositionend", "popupshowing", "popupshown",
63
  "popuphiding", "popuphidden", "close", "command", "broadcast", "commandupdate",
63
  "popuphiding", "popuphidden", "close", "command", "broadcast", "commandupdate",
64
  "dragenter", "dragover", "dragexit", "dragdrop", "draggesture", "resize",
64
  "dragenter", "dragover", "dragexit", "dragdrop", "draggesture", "resize",
65
  "scroll","overflow", "underflow", "overflowchanged",
65
  "scroll","overflow", "underflow", "overflowchanged",
 Lines 434-439   nsDOMEvent::SetEventType(const nsAString Link Here 
434
      mEvent->message = NS_IMAGE_ABORT;
434
      mEvent->message = NS_IMAGE_ABORT;
435
    else if (atom == nsLayoutAtoms::onerror)
435
    else if (atom == nsLayoutAtoms::onerror)
436
      mEvent->message = NS_IMAGE_ERROR;
436
      mEvent->message = NS_IMAGE_ERROR;
437
    else if (atom == nsLayoutAtoms::onDOMPageRestore)
438
      mEvent->message = NS_PAGE_RESTORE;
437
  } else if (mEvent->eventStructType == NS_MUTATION_EVENT) {
439
  } else if (mEvent->eventStructType == NS_MUTATION_EVENT) {
438
    if (atom == nsLayoutAtoms::onDOMAttrModified)
440
    if (atom == nsLayoutAtoms::onDOMAttrModified)
439
      mEvent->message = NS_MUTATION_ATTRMODIFIED;
441
      mEvent->message = NS_MUTATION_ATTRMODIFIED;
 Lines 794-799   const char* nsDOMEvent::GetEventName(PRU Link Here 
794
  case NS_IMAGE_ERROR:
796
  case NS_IMAGE_ERROR:
795
  case NS_SCRIPT_ERROR:
797
  case NS_SCRIPT_ERROR:
796
    return sEventNames[eDOMEvents_error];
798
    return sEventNames[eDOMEvents_error];
799
  case NS_PAGE_RESTORE:
800
    return sEventNames[eDOMEvents_DOMPageRestore];
797
  case NS_FORM_SUBMIT:
801
  case NS_FORM_SUBMIT:
798
    return sEventNames[eDOMEvents_submit];
802
    return sEventNames[eDOMEvents_submit];
799
  case NS_FORM_RESET:
803
  case NS_FORM_RESET:
(-)content/events/src/nsDOMEvent.h (+1 lines)
Line     Link Here 
 Lines 85-90   public: Link Here 
85
    eDOMEvents_unload,
85
    eDOMEvents_unload,
86
    eDOMEvents_abort,
86
    eDOMEvents_abort,
87
    eDOMEvents_error,
87
    eDOMEvents_error,
88
    eDOMEvents_DOMPageRestore,
88
    eDOMEvents_submit,
89
    eDOMEvents_submit,
89
    eDOMEvents_reset,
90
    eDOMEvents_reset,
90
    eDOMEvents_change,
91
    eDOMEvents_change,
(-)content/events/src/nsEventListenerManager.cpp (-1 / +26 lines)
Line     Link Here 
 Lines 241-247   static const EventDispatchData sLoadEven Link Here 
241
  {NS_PAGE_UNLOAD, HANDLER(&nsIDOMLoadListener::Unload),NS_EVENT_BITS_LOAD_UNLOAD},
241
  {NS_PAGE_UNLOAD, HANDLER(&nsIDOMLoadListener::Unload),NS_EVENT_BITS_LOAD_UNLOAD},
242
  {NS_IMAGE_ERROR, HANDLER(&nsIDOMLoadListener::Error), NS_EVENT_BITS_LOAD_ERROR},
242
  {NS_IMAGE_ERROR, HANDLER(&nsIDOMLoadListener::Error), NS_EVENT_BITS_LOAD_ERROR},
243
  {NS_SCRIPT_ERROR,HANDLER(&nsIDOMLoadListener::Error), NS_EVENT_BITS_LOAD_ERROR},
243
  {NS_SCRIPT_ERROR,HANDLER(&nsIDOMLoadListener::Error), NS_EVENT_BITS_LOAD_ERROR},
244
  {NS_BEFORE_PAGE_UNLOAD,HANDLER(&nsIDOMLoadListener::BeforeUnload), NS_EVENT_BITS_LOAD_BEFORE_UNLOAD}
244
  {NS_BEFORE_PAGE_UNLOAD,HANDLER(&nsIDOMLoadListener::BeforeUnload), NS_EVENT_BITS_LOAD_BEFORE_UNLOAD},
245
  {NS_PAGE_RESTORE,HANDLER(&nsIDOMLoadListener::PageRestore), NS_EVENT_BITS_LOAD_PAGE_RESTORE}
245
};
246
};
246
247
247
static const EventDispatchData sPaintEvents[] = {
248
static const EventDispatchData sPaintEvents[] = {
 Lines 885-890   nsEventListenerManager::GetIdentifiersFo Link Here 
885
    *aArrayType = eEventArrayType_Load;
886
    *aArrayType = eEventArrayType_Load;
886
    *aFlags = NS_EVENT_BITS_LOAD_ERROR;
887
    *aFlags = NS_EVENT_BITS_LOAD_ERROR;
887
  }
888
  }
889
  else if (aType == nsLayoutAtoms::onDOMPageRestore) {
890
    *aArrayType = eEventArrayType_Load;
891
    *aFlags = NS_EVENT_BITS_LOAD_PAGE_RESTORE;
892
  }
888
  else if (aType == nsLayoutAtoms::onpaint) {
893
  else if (aType == nsLayoutAtoms::onpaint) {
889
    *aArrayType = eEventArrayType_Paint;
894
    *aArrayType = eEventArrayType_Paint;
890
    *aFlags = NS_EVENT_BITS_PAINT_PAINT;
895
    *aFlags = NS_EVENT_BITS_PAINT_PAINT;
 Lines 2208-2213   void nsEventListenerManager::GetCoordina Link Here 
2208
  }
2213
  }
2209
}
2214
}
2210
2215
2216
PRBool
2217
nsEventListenerManager::HasUnloadListeners()
2218
{
2219
  nsVoidArray *listeners = GetListenersByType(eEventArrayType_Load, nsnull,
2220
                                              PR_FALSE);
2221
  if (listeners) {
2222
    PRInt32 count = listeners->Count();
2223
    for (PRInt32 i = 0; i < count; ++i) {
2224
      PRUint32 subtype = NS_STATIC_CAST(nsListenerStruct*,
2225
                                        listeners->FastElementAt(i))->mSubType;
2226
      if (subtype == NS_EVENT_BITS_NONE ||
2227
          subtype & (NS_EVENT_BITS_LOAD_UNLOAD |
2228
                     NS_EVENT_BITS_LOAD_BEFORE_UNLOAD))
2229
        return PR_TRUE;
2230
    }
2231
  }
2232
2233
  return PR_FALSE;
2234
}
2235
2211
nsresult
2236
nsresult
2212
NS_NewEventListenerManager(nsIEventListenerManager** aInstancePtrResult) 
2237
NS_NewEventListenerManager(nsIEventListenerManager** aInstancePtrResult) 
2213
{
2238
{
(-)content/events/src/nsEventListenerManager.h (+3 lines)
Line     Link Here 
 Lines 163-168   public: Link Here 
163
163
164
  NS_IMETHOD GetSystemEventGroupLM(nsIDOMEventGroup** aGroup);
164
  NS_IMETHOD GetSystemEventGroupLM(nsIDOMEventGroup** aGroup);
165
165
166
  virtual PRBool HasUnloadListeners();
167
166
  static nsresult GetIdentifiersForType(nsIAtom* aType,
168
  static nsresult GetIdentifiersForType(nsIAtom* aType,
167
                                        EventArrayType* aArrayType,
169
                                        EventArrayType* aArrayType,
168
                                        PRInt32* aSubType);
170
                                        PRInt32* aSubType);
 Lines 300-305   protected: Link Here 
300
#define NS_EVENT_BITS_LOAD_ABORT             0x04
302
#define NS_EVENT_BITS_LOAD_ABORT             0x04
301
#define NS_EVENT_BITS_LOAD_ERROR             0x08
303
#define NS_EVENT_BITS_LOAD_ERROR             0x08
302
#define NS_EVENT_BITS_LOAD_BEFORE_UNLOAD     0x10
304
#define NS_EVENT_BITS_LOAD_BEFORE_UNLOAD     0x10
305
#define NS_EVENT_BITS_LOAD_PAGE_RESTORE      0x20
303
306
304
//nsIDOMXULListener
307
//nsIDOMXULListener
305
#define NS_EVENT_BITS_XUL_NONE               0x00
308
#define NS_EVENT_BITS_XUL_NONE               0x00
(-)content/html/content/src/nsGenericHTMLElement.cpp (-9 / +11 lines)
Line     Link Here 
 Lines 1525-1539   nsGenericHTMLElement::HandleDOMEventForA Link Here 
1525
            // nothing else.
1525
            // nothing else.
1526
            nsCOMPtr<nsPIDOMWindow> win =
1526
            nsCOMPtr<nsPIDOMWindow> win =
1527
              do_QueryInterface(document->GetScriptGlobalObject());
1527
              do_QueryInterface(document->GetScriptGlobalObject());
1528
            nsIFocusController *focusController =
1528
            if (win) {
1529
              win->GetRootFocusController();
1529
              nsIFocusController *focusController =
1530
            PRBool isActive = PR_FALSE;
1530
                win->GetRootFocusController();
1531
            focusController->GetActive(&isActive);
1531
              PRBool isActive = PR_FALSE;
1532
            if (!isActive) {
1532
              focusController->GetActive(&isActive);
1533
              nsCOMPtr<nsIDOMElement> domElement = do_QueryInterface(this);
1533
              if (!isActive) {
1534
              if(domElement)
1534
                nsCOMPtr<nsIDOMElement> domElement = do_QueryInterface(this);
1535
                focusController->SetFocusedElement(domElement);
1535
                if(domElement)
1536
              break;
1536
                  focusController->SetFocusedElement(domElement);
1537
                break;
1538
              }
1537
            }
1539
            }
1538
  
1540
  
1539
            aPresContext->EventStateManager()->
1541
            aPresContext->EventStateManager()->
(-)content/html/content/src/nsHTMLInputElement.cpp (-15 / +19 lines)
Line     Link Here 
 Lines 1069-1082   nsHTMLInputElement::SetFocus(nsPresConte Link Here 
1069
  // nothing else.
1069
  // nothing else.
1070
  nsCOMPtr<nsPIDOMWindow> win =
1070
  nsCOMPtr<nsPIDOMWindow> win =
1071
    do_QueryInterface(doc->GetScriptGlobalObject());
1071
    do_QueryInterface(doc->GetScriptGlobalObject());
1072
  nsIFocusController *focusController = win->GetRootFocusController();
1072
  if (win) {
1073
  PRBool isActive = PR_FALSE;
1073
    nsIFocusController *focusController = win->GetRootFocusController();
1074
  focusController->GetActive(&isActive);
1074
    PRBool isActive = PR_FALSE;
1075
  if (!isActive) {
1075
    focusController->GetActive(&isActive);
1076
    focusController->SetFocusedWindow(win);
1076
    if (!isActive) {
1077
    focusController->SetFocusedElement(this);
1077
      focusController->SetFocusedWindow(win);
1078
      focusController->SetFocusedElement(this);
1078
1079
1079
    return;
1080
      return;
1081
    }
1080
  }
1082
  }
1081
1083
1082
  aPresContext->EventStateManager()->SetContentState(this,
1084
  aPresContext->EventStateManager()->SetContentState(this,
 Lines 1119-1132   nsHTMLInputElement::Select() Link Here 
1119
    // nothing else.
1121
    // nothing else.
1120
    nsCOMPtr<nsPIDOMWindow> win =
1122
    nsCOMPtr<nsPIDOMWindow> win =
1121
      do_QueryInterface(doc->GetScriptGlobalObject());
1123
      do_QueryInterface(doc->GetScriptGlobalObject());
1122
    nsIFocusController *focusController = win->GetRootFocusController();
1124
    if (win) {
1123
    PRBool isActive = PR_FALSE;
1125
      nsIFocusController *focusController = win->GetRootFocusController();
1124
    focusController->GetActive(&isActive);
1126
      PRBool isActive = PR_FALSE;
1125
    if (!isActive) {
1127
      focusController->GetActive(&isActive);
1126
      focusController->SetFocusedWindow(win);
1128
      if (!isActive) {
1127
      focusController->SetFocusedElement(this);
1129
        focusController->SetFocusedWindow(win);
1128
      SelectAll(presContext);
1130
        focusController->SetFocusedElement(this);
1129
      return NS_OK;
1131
        SelectAll(presContext);
1132
        return NS_OK;
1133
      }
1130
    }
1134
    }
1131
1135
1132
    // Just like SetFocus() but without the ScrollIntoView()!
1136
    // Just like SetFocus() but without the ScrollIntoView()!
(-)content/html/document/src/nsPluginDocument.cpp (+3 lines)
Line     Link Here 
 Lines 97-102   nsPluginDocument::SetScriptGlobalObject( Link Here 
97
{
97
{
98
  if (!aScriptGlobalObject) {
98
  if (!aScriptGlobalObject) {
99
    mStreamListener = nsnull;
99
    mStreamListener = nsnull;
100
  } else if (!mStreamListener) {
101
    mStreamListener = new nsMediaDocumentStreamListener(this);
102
    // XXX no way to indicate OOM
100
  }
103
  }
101
104
102
  nsMediaDocument::SetScriptGlobalObject(aScriptGlobalObject);
105
  nsMediaDocument::SetScriptGlobalObject(aScriptGlobalObject);
(-)content/xbl/src/nsXBLPrototypeHandler.cpp (-1 / +2 lines)
Line     Link Here 
 Lines 291-297   nsXBLPrototypeHandler::ExecuteHandler(ns Link Here 
291
        privateWindow = do_QueryInterface(doc->GetScriptGlobalObject());
291
        privateWindow = do_QueryInterface(doc->GetScriptGlobalObject());
292
      }
292
      }
293
293
294
      focusController = privateWindow->GetRootFocusController();
294
      if (privateWindow)
295
        focusController = privateWindow->GetRootFocusController();
295
    }
296
    }
296
297
297
    NS_LossyConvertUCS2toASCII command(mHandlerText);
298
    NS_LossyConvertUCS2toASCII command(mHandlerText);
(-)content/xbl/src/nsXBLService.cpp (-5 / +6 lines)
Line     Link Here 
 Lines 229-239   public: Link Here 
229
  NS_DECL_NSIREQUESTOBSERVER
229
  NS_DECL_NSIREQUESTOBSERVER
230
230
231
  NS_IMETHOD Load(nsIDOMEvent* aEvent);
231
  NS_IMETHOD Load(nsIDOMEvent* aEvent);
232
  NS_IMETHOD BeforeUnload(nsIDOMEvent* aEvent) { return NS_OK; };
232
  NS_IMETHOD BeforeUnload(nsIDOMEvent* aEvent) { return NS_OK; }
233
  NS_IMETHOD Unload(nsIDOMEvent* aEvent) { return NS_OK; };
233
  NS_IMETHOD Unload(nsIDOMEvent* aEvent) { return NS_OK; }
234
  NS_IMETHOD Abort(nsIDOMEvent* aEvent) { return NS_OK; };
234
  NS_IMETHOD Abort(nsIDOMEvent* aEvent) { return NS_OK; }
235
  NS_IMETHOD Error(nsIDOMEvent* aEvent) { return NS_OK; };
235
  NS_IMETHOD Error(nsIDOMEvent* aEvent) { return NS_OK; }
236
  NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; };
236
  NS_IMETHOD PageRestore(nsIDOMEvent* aEvent) { return NS_OK; }
237
  NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; }
237
238
238
#ifdef MOZ_XUL
239
#ifdef MOZ_XUL
239
  static nsIXULPrototypeCache* gXULCache;
240
  static nsIXULPrototypeCache* gXULCache;
(-)docshell/base/nsDocShell.cpp (-24 / +537 lines)
Line     Link Here 
 Lines 166-174   static NS_DEFINE_CID(kDOMScriptObjectFac Link Here 
166
166
167
#if defined(DEBUG_bryner)
167
#if defined(DEBUG_bryner)
168
//#define DEBUG_DOCSHELL_FOCUS
168
//#define DEBUG_DOCSHELL_FOCUS
169
#define DEBUG_PAGE_CACHE
169
#endif
170
#endif
170
171
171
#include "plevent.h"
172
#include "plevent.h"
173
#include "nsGUIEvent.h"
174
#include "nsIPrivateDOMEvent.h"
175
#include "nsIDOMEventReceiver.h"
176
#include "nsIEventListenerManager.h"
177
#include "nsICaret.h"
172
178
173
// Number of documents currently loading
179
// Number of documents currently loading
174
static PRInt32 gNumberOfDocumentsLoading = 0;
180
static PRInt32 gNumberOfDocumentsLoading = 0;
 Lines 199-204   static PRBool gValidateOrigin = (PRBool) Link Here 
199
static PRLogModuleInfo* gDocShellLog;
205
static PRLogModuleInfo* gDocShellLog;
200
#endif
206
#endif
201
207
208
// Used to let SetupNewViewer() know that the previous viewer can be saved.
209
static PRBool gSavingOldViewer = PR_FALSE;
210
202
//*****************************************************************************
211
//*****************************************************************************
203
//***    nsDocShellFocusController
212
//***    nsDocShellFocusController
204
//*****************************************************************************
213
//*****************************************************************************
 Lines 1355-1366   nsDocShell::SetCurrentURI(nsIURI *aURI, Link Here 
1355
        isRoot = PR_TRUE;
1364
        isRoot = PR_TRUE;
1356
    }
1365
    }
1357
    if (mLSHE) {
1366
    if (mLSHE) {
1358
      nsCOMPtr<nsIHistoryEntry> historyEntry(do_QueryInterface(mLSHE));
1367
        mLSHE->GetIsSubFrame(&isSubFrame);
1359
      
1360
      // Check if this is a subframe navigation
1361
      if (historyEntry) {
1362
        historyEntry->GetIsSubFrame(&isSubFrame);
1363
      }
1364
    }
1368
    }
1365
1369
1366
    if (!isSubFrame && !isRoot) {
1370
    if (!isSubFrame && !isRoot) {
 Lines 1681-1686   nsDocShell::TabToTreeOwner(PRBool aForwa Link Here 
1681
    return NS_OK;
1685
    return NS_OK;
1682
}
1686
}
1683
1687
1688
NS_IMETHODIMP
1689
nsDocShell::GetSecurityUI(nsISecureBrowserUI **aSecurityUI)
1690
{
1691
    NS_IF_ADDREF(*aSecurityUI = mSecurityUI);
1692
    return NS_OK;
1693
}
1694
1695
NS_IMETHODIMP
1696
nsDocShell::SetSecurityUI(nsISecureBrowserUI *aSecurityUI)
1697
{
1698
    mSecurityUI = aSecurityUI;
1699
    return NS_OK;
1700
}
1701
1684
//*****************************************************************************
1702
//*****************************************************************************
1685
// nsDocShell::nsIDocShellTreeItem
1703
// nsDocShell::nsIDocShellTreeItem
1686
//*****************************************************************************   
1704
//*****************************************************************************   
 Lines 3261-3272   nsDocShell::LoadPage(nsISupports *aPageD Link Here 
3261
    // load the page as view-source
3279
    // load the page as view-source
3262
    //
3280
    //
3263
    if (nsIWebPageDescriptor::DISPLAY_AS_SOURCE == aDisplayType) {
3281
    if (nsIWebPageDescriptor::DISPLAY_AS_SOURCE == aDisplayType) {
3264
        nsCOMPtr<nsIHistoryEntry> srcHE(do_QueryInterface(shEntry));
3265
        nsCOMPtr<nsIURI> oldUri, newUri;
3282
        nsCOMPtr<nsIURI> oldUri, newUri;
3266
        nsCString spec, newSpec;
3283
        nsCString spec, newSpec;
3267
3284
3268
        // Create a new view-source URI and replace the original.
3285
        // Create a new view-source URI and replace the original.
3269
        rv = srcHE->GetURI(getter_AddRefs(oldUri));
3286
        rv = shEntry->GetURI(getter_AddRefs(oldUri));
3270
        if (NS_FAILED(rv))
3287
        if (NS_FAILED(rv))
3271
              return rv;
3288
              return rv;
3272
3289
 Lines 3720-3726   nsDocShell::SetTitle(const PRUnichar * a Link Here 
3720
    // would suffice. 
3737
    // would suffice. 
3721
    if (mOSHE && (mLoadType != LOAD_BYPASS_HISTORY) &&
3738
    if (mOSHE && (mLoadType != LOAD_BYPASS_HISTORY) &&
3722
        (mLoadType != LOAD_HISTORY) && (mLoadType != LOAD_ERROR_PAGE)) {
3739
        (mLoadType != LOAD_HISTORY) && (mLoadType != LOAD_ERROR_PAGE)) {
3723
        mOSHE->SetTitle(mTitle.get());    
3740
        mOSHE->SetTitle(mTitle);    
3724
    }
3741
    }
3725
3742
3726
3743
 Lines 4315-4321   nsDocShell::CancelRefreshURITimers() Link Here 
4315
    return NS_OK;
4332
    return NS_OK;
4316
}
4333
}
4317
4334
4318
NS_IMETHODIMP
4335
void
4336
nsDocShell::SuspendRefreshURIs()
4337
{
4338
    if (!mRefreshURIList)
4339
        return;
4340
    PRUint32 n = 0;
4341
    mRefreshURIList->Count(&n);
4342
4343
    nsCOMPtr<nsITimer> timer;
4344
    nsCOMPtr<nsITimerCallback> callback;
4345
    nsCOMPtr<nsRefreshTimer> rt;
4346
4347
    for (PRUint32 i = 0;  i < n; ++i) {
4348
        timer = do_QueryElementAt(mRefreshURIList, --n);
4349
        if (!timer)
4350
            continue;  // this must be a nsRefreshURI already
4351
4352
        // Replace this timer object with a nsRefreshTimer object.
4353
        nsCOMPtr<nsITimerCallback> callback;
4354
        timer->GetCallback(getter_AddRefs(callback));
4355
4356
        timer->Cancel();
4357
4358
        nsCOMPtr<nsRefreshTimer> rt = do_QueryInterface(callback);
4359
        NS_ASSERTION(rt, "RefreshURIList timer callbacks should only be RefreshTimer objects");
4360
4361
        mRefreshURIList->ReplaceElementAt(rt, i);
4362
    }
4363
}
4364
4365
nsresult
4319
nsDocShell::RefreshURIFromQueue()
4366
nsDocShell::RefreshURIFromQueue()
4320
{
4367
{
4321
    if (!mRefreshURIList)
4368
    if (!mRefreshURIList)
 Lines 4701-4706   nsDocShell::CreateAboutBlankContentViewe Link Here 
4701
  return rv;
4748
  return rv;
4702
}
4749
}
4703
4750
4751
PRBool
4752
nsDocShell::CanSavePresentation(nsIRequest *aNewRequest)
4753
{
4754
    // If the document is not done loading, don't cache it.
4755
    nsCOMPtr<nsPIDOMWindow> pWin = do_QueryInterface(mScriptGlobal);
4756
    if (pWin && pWin->IsLoading())
4757
        return PR_FALSE;
4758
4759
    // If there are any active requests in the document load group, don't cache
4760
    // the document.  Ideally we would instead suspend these requests and
4761
    // resume them when restoring the presentation, but that is potentially
4762
    // difficult (i.e. XMLHttpRequest).
4763
4764
    nsCOMPtr<nsIDocument> doc = do_QueryInterface(pWin->GetExtantDocument());
4765
    if (doc->HasRequests(aNewRequest))
4766
        return PR_FALSE;
4767
4768
    // Only save presentation for "normal" loads and link loads.  Anything else
4769
    // probably wants to refetch the page, so caching the old presentation
4770
    // would be incorrect.
4771
    if (mLoadType != LOAD_NORMAL &&
4772
        mLoadType != LOAD_HISTORY &&
4773
        mLoadType != LOAD_LINK)
4774
        return PR_FALSE;
4775
4776
    // If there is an unload or beforeunload listener on the window, then we do
4777
    // not save the presentation into the session history cache.
4778
    nsCOMPtr<nsIDOMEventReceiver> er = do_QueryInterface(mScriptGlobal);
4779
    if (er) {
4780
        nsCOMPtr<nsIEventListenerManager> eventManager;
4781
        er->GetListenerManager(getter_AddRefs(eventManager));
4782
4783
        if (eventManager && eventManager->HasUnloadListeners())
4784
            return PR_FALSE;
4785
    }
4786
4787
    // If the session history entry has the saveLayoutState flag set to false,
4788
    // then we should not cache the presentation.
4789
4790
    if (!mOSHE)
4791
        return PR_FALSE; // no entry to save into
4792
4793
    PRBool canSaveState;
4794
    mOSHE->GetSaveLayoutStateFlag(&canSaveState);
4795
    return canSaveState;
4796
}
4797
4798
nsresult
4799
nsDocShell::CaptureState()
4800
{
4801
    nsCOMPtr<nsPIDOMWindow> privWin = do_QueryInterface(mScriptGlobal);
4802
    if (!privWin || !mOSHE)
4803
        return NS_ERROR_FAILURE;
4804
4805
    nsCOMPtr<nsISupports> windowState;
4806
    nsresult rv = privWin->SaveWindowState(getter_AddRefs(windowState));
4807
    NS_ENSURE_SUCCESS(rv, rv);
4808
4809
#ifdef DEBUG_PAGE_CACHE
4810
    nsCOMPtr<nsIURI> uri;
4811
    mOSHE->GetURI(getter_AddRefs(uri));
4812
    nsCAutoString spec;
4813
    if (uri)
4814
        uri->GetSpec(spec);
4815
    printf("Saving presentation into session history\n");
4816
    printf("  SH URI: %s\n", spec.get());
4817
#endif
4818
4819
    rv = mOSHE->SetWindowState(windowState);
4820
    NS_ENSURE_SUCCESS(rv, rv);
4821
4822
    // Suspend refresh URIs and save off the timer queue
4823
    SuspendRefreshURIs();
4824
    rv = mOSHE->SetRefreshURIList(mRefreshURIList);
4825
    NS_ENSURE_SUCCESS(rv, rv);
4826
4827
    mRefreshURIList = nsnull;
4828
4829
    // Capture the current content viewer bounds.
4830
    nsCOMPtr<nsIPresShell> shell;
4831
    nsDocShell::GetPresShell(getter_AddRefs(shell));
4832
    if (shell) {
4833
        nsIViewManager *vm = shell->GetViewManager();
4834
        if (vm) {
4835
            nsIView *rootView = nsnull;
4836
            vm->GetRootView(rootView);
4837
            if (rootView) {
4838
                nsIWidget *widget = rootView->GetWidget();
4839
                if (widget) {
4840
                    nsRect bounds(0, 0, 0, 0);
4841
                    widget->GetBounds(bounds);
4842
                    rv = mOSHE->SetViewerBounds(bounds);
4843
                }
4844
            }
4845
        }
4846
    }
4847
4848
    // Disable the caret for this shell and all of its children.
4849
    DisableCaret(this);
4850
4851
    // Capture the docshell hierarchy.
4852
4853
    PRInt32 childCount = mChildList.Count();
4854
    nsCOMPtr<nsIDocShellTreeItem> childShell;
4855
4856
    mOSHE->ClearChildShells();
4857
4858
    for (PRInt32 i = 0; i < childCount; ++i) {
4859
        childShell = do_QueryInterface(ChildAt(i));
4860
        NS_ASSERTION(childShell, "null child shell");
4861
4862
        mOSHE->AddChildShell(childShell);
4863
    }
4864
4865
    // Capture the security state.
4866
    nsCOMPtr<nsISecureBrowserUIState> securityState;
4867
    if (mSecurityUI)
4868
        mSecurityUI->CaptureState(getter_AddRefs(securityState));
4869
4870
    return mOSHE->SetSecurityState(securityState);
4871
}
4872
4873
nsresult
4874
nsDocShell::RestorePresentation(nsISHEntry *aSHEntry)
4875
{
4876
    nsCOMPtr<nsIURI> uri;
4877
    aSHEntry->GetURI(getter_AddRefs(uri));
4878
4879
    nsCOMPtr<nsIContentViewer> viewer;
4880
    aSHEntry->GetContentViewer(getter_AddRefs(viewer));
4881
4882
#ifdef DEBUG_PAGE_CACHE
4883
    nsCAutoString spec;
4884
    if (uri)
4885
        uri->GetSpec(spec);
4886
#endif
4887
4888
    if (!viewer) {
4889
#ifdef DEBUG_PAGE_CACHE
4890
        printf("no saved presentation for uri: %s\n", spec.get());
4891
#endif
4892
        return NS_ERROR_FAILURE;
4893
    }
4894
4895
    NS_ASSERTION(mContentViewer != viewer, "Restoring existing presentation");
4896
4897
#ifdef DEBUG_PAGE_CACHE
4898
    printf("restoring presentation from session history: %s\n", spec.get());
4899
#endif
4900
4901
    // Save off the root view's parent and sibling so that we can insert the
4902
    // new content viewer's root view at the same position.  Also save the
4903
    // bounds of the root view's widget.
4904
4905
    nsIView *rootViewSibling = nsnull, *rootViewParent = nsnull;
4906
    nsRect newBounds(0, 0, 0, 0);
4907
4908
    nsCOMPtr<nsIPresShell> oldPresShell;
4909
    nsDocShell::GetPresShell(getter_AddRefs(oldPresShell));
4910
    if (oldPresShell) {
4911
        nsIViewManager *vm = oldPresShell->GetViewManager();
4912
        if (vm) {
4913
            nsIView *oldRootView = nsnull;
4914
            vm->GetRootView(oldRootView);
4915
4916
            if (oldRootView) {
4917
                rootViewSibling = oldRootView->GetNextSibling();
4918
                rootViewParent = oldRootView->GetParent();
4919
4920
                nsIWidget *widget = oldRootView->GetWidget();
4921
                if (widget) {
4922
                    widget->GetBounds(newBounds);
4923
                }
4924
            }
4925
        }
4926
    }
4927
4928
    // Transfer ownership to mContentViewer.  By ensuring that either the
4929
    // docshell or the session history, but not both, have references to the
4930
    // content viewer, we prevent the viewer from being torn down after
4931
    // Destroy() is called.
4932
4933
    PRBool savePresentation = CanSavePresentation(nsnull);
4934
    if (!savePresentation)
4935
        FireUnloadNotification();
4936
4937
    mFiredUnloadEvent = PR_FALSE;
4938
4939
    if (mContentViewer) {
4940
        mContentViewer->Close();
4941
4942
        if (savePresentation)
4943
            mContentViewer->SetHistoryEntry(mOSHE);
4944
4945
        mContentViewer->Destroy();
4946
    }
4947
4948
    mContentViewer.swap(viewer);
4949
    viewer = nsnull; // force a release to complete ownership transfer
4950
4951
    // Pulling the viewer out of the CachedPresentation will thaw() it.
4952
    // We must first open it to prevent pending destruction.
4953
    nsresult rv = mContentViewer->Open();
4954
    NS_ENSURE_SUCCESS(rv, rv);
4955
4956
    // Now remove it from the cached presentation.
4957
    aSHEntry->SetContentViewer(nsnull);
4958
4959
    // Restore our child docshell hierarchy.
4960
    DestroyChildren();
4961
4962
    PRInt32 i = 0;
4963
    nsCOMPtr<nsIDocShellTreeItem> childShell;
4964
    while (NS_SUCCEEDED(aSHEntry->ChildShellAt(i++,
4965
                                               getter_AddRefs(childShell))) &&
4966
           childShell) {
4967
        AddChild(childShell);
4968
    }
4969
4970
    // And release the references in the history entry.
4971
    aSHEntry->ClearChildShells();
4972
4973
    // restore the sticky state of the viewer
4974
    PRBool sticky;
4975
    aSHEntry->GetSticky(&sticky);
4976
    mContentViewer->SetSticky(sticky);
4977
4978
    // save the previous content viewer size
4979
    nsRect oldBounds(0, 0, 0, 0);
4980
    aSHEntry->GetViewerBounds(oldBounds);
4981
4982
    // Insert the new root view at the correct location in the view tree.
4983
    if (rootViewParent) {
4984
        nsIViewManager *parentVM = rootViewParent->GetViewManager();
4985
4986
        nsCOMPtr<nsIPresShell> shell;
4987
        nsDocShell::GetPresShell(getter_AddRefs(shell));
4988
4989
        if (parentVM && shell) {
4990
            nsIViewManager *newVM = shell->GetViewManager();
4991
            if (newVM) {
4992
                nsIView *newRootView = nsnull;
4993
                newVM->GetRootView(newRootView);
4994
                if (newRootView) {
4995
                    parentVM->InsertChild(rootViewParent, newRootView,
4996
                                          rootViewSibling, PR_TRUE);
4997
4998
                    NS_ASSERTION(newRootView->GetNextSibling() ==
4999
                                 rootViewSibling,
5000
                                 "error in InsertChild");
5001
5002
                    if (oldPresShell)
5003
                        oldPresShell->InvalidateViewManagers();
5004
                }
5005
            }
5006
        }
5007
    }
5008
5009
    // restore the state of the window object
5010
    nsCOMPtr<nsPIDOMWindow> privWin =
5011
        do_GetInterface(NS_STATIC_CAST(nsIInterfaceRequestor*, this));
5012
    NS_ASSERTION(privWin, "could not get nsPIDOMWindow interface");
5013
5014
    nsCOMPtr<nsISupports> windowState;
5015
    aSHEntry->GetWindowState(getter_AddRefs(windowState));
5016
5017
    rv = privWin->RestoreWindowState(windowState);
5018
    NS_ENSURE_SUCCESS(rv, rv);
5019
5020
    aSHEntry->SetWindowState(nsnull);
5021
5022
    // Restore the refresh URI list.
5023
    aSHEntry->GetRefreshURIList(getter_AddRefs(mRefreshURIList));
5024
    aSHEntry->SetRefreshURIList(nsnull);
5025
5026
    RefreshURIFromQueue();
5027
5028
    mOSHE = aSHEntry;
5029
    EndPageLoad(nsnull, nsnull, NS_OK);
5030
5031
    nsCOMPtr<nsISHistory> rootSH;
5032
    GetRootSessionHistory(getter_AddRefs(rootSH));
5033
    if (rootSH && (mLoadType & LOAD_CMD_HISTORY)) {
5034
        nsCOMPtr<nsISHistoryInternal> hist = do_QueryInterface(rootSH);
5035
        hist->UpdateIndex();
5036
    }
5037
5038
    // Make sure this presentation is the same size as the previous
5039
    // presentation.  If this is not the same size we showed it at last time,
5040
    // then we need to resize the widget.
5041
5042
    // XXXbryner   This interacts poorly with Firefox's infobar.  If the old
5043
    // presentation had the infobar visible, then we will resize the new
5044
    // presentation to that smaller size.  However, firing the locationchanged
5045
    // event will hide the infobar, which will immediately resize the window
5046
    // back to the larger size.  A future optimization might be to restore
5047
    // the presentation at the "wrong" size, then fire the locationchanged
5048
    // event and check whether the docshell's new size is the same as the
5049
    // cached viewer size (skipping the resize if they are equal).
5050
5051
    nsCOMPtr<nsIPresShell> shell;
5052
    nsDocShell::GetPresShell(getter_AddRefs(shell));
5053
5054
    if (shell) {
5055
        nsIViewManager *vm = shell->GetViewManager();
5056
        if (vm) {
5057
            nsIView *rootView = nsnull;
5058
            vm->GetRootView(rootView);
5059
5060
            if (rootView) {
5061
                nsIWidget *widget = rootView->GetWidget();
5062
                if (widget && !newBounds.IsEmpty()) {
5063
#ifdef DEBUG_PAGE_CACHE
5064
                    printf("resize widget(%d, %d, %d, %d)\n", newBounds.x,
5065
                           newBounds.y, newBounds.width, newBounds.height);
5066
#endif
5067
5068
                    widget->Resize(newBounds.x, newBounds.y, newBounds.width,
5069
                                   newBounds.height, PR_FALSE);
5070
                }
5071
            }
5072
        }
5073
    }
5074
5075
    // Reset the security state
5076
    if (mSecurityUI) {
5077
        nsCOMPtr<nsISecureBrowserUIState> securityState;
5078
        aSHEntry->GetSecurityState(getter_AddRefs(securityState));
5079
        if (securityState)
5080
            mSecurityUI->TransitionToState(securityState);
5081
    }
5082
5083
    SetCurrentURI(uri);
5084
5085
    // Dispatch events.  This is a little messy.  We need to avoid firing
5086
    // onload so that it is visible from the content DOM window, but we _do_
5087
    // want the chrome to see it for chrome/extensions that look for page load.
5088
    // In addition, we need to fire DOMPageRestore on the content window.
5089
5090
    nsEvent event(NS_PAGE_LOAD);
5091
    nsEventStatus status = nsEventStatus_eIgnore;
5092
5093
    nsCOMPtr<nsIChromeEventHandler> handler = privWin->GetChromeEventHandler();
5094
5095
    nsCOMPtr<nsPresContext> presContext;
5096
    GetPresContext(getter_AddRefs(presContext));
5097
5098
    PRUint32 flags = NS_EVENT_FLAG_INIT;
5099
    event.flags |= flags;
5100
    flags &= ~(NS_EVENT_FLAG_CANT_BUBBLE | NS_EVENT_FLAG_CANT_CANCEL);
5101
    flags |= NS_EVENT_FLAG_BUBBLE | NS_EVENT_FLAG_CAPTURE;
5102
5103
    nsIDOMEvent *domEvt = nsnull;
5104
5105
    rv = handler->HandleChromeEvent(presContext, &event, &domEvt,
5106
                                    flags & NS_EVENT_CAPTURE_MASK, &status);
5107
    NS_ENSURE_SUCCESS(rv, rv);
5108
5109
    if (domEvt) {
5110
        nsrefcnt rc;
5111
        NS_RELEASE2(domEvt, rc);
5112
        if (0 != rc) {
5113
            // Okay, so someone in the DOM loop (a listener, JS object)
5114
            // still has a ref to the DOM Event but the internal data
5115
            // hasn't been malloc'd.  Force a copy of the data here so the
5116
            // DOM Event is still valid.
5117
5118
            nsCOMPtr<nsIPrivateDOMEvent> privateEvent =
5119
                do_QueryInterface(domEvt);
5120
5121
            if (privateEvent) {
5122
                privateEvent->DuplicatePrivateData();
5123
            }
5124
        }
5125
    }
5126
5127
    if (mScriptGlobal) {
5128
        nsEventStatus status = nsEventStatus_eIgnore;
5129
        nsEvent restoreEvent(NS_PAGE_RESTORE);
5130
5131
        nsCOMPtr<nsPresContext> presContext;
5132
        nsDocShell::GetPresContext(getter_AddRefs(presContext));
5133
5134
        if (presContext) {
5135
            mScriptGlobal->HandleDOMEvent(presContext, &restoreEvent, nsnull,
5136
                                          NS_EVENT_FLAG_INIT, &status);
5137
        }
5138
    }
5139
5140
    rv = mContentViewer->Show();
5141
    NS_ENSURE_SUCCESS(rv, rv);
5142
5143
    // Restart plugins
5144
    if (shell)
5145
        shell->StartPlugins();
5146
5147
    // XXXbryner  Making this invalidate synchronous causes unpainted areas
5148
    // (on Mac, at least) if the above locationchanged event hides Firefox's
5149
    // infobar.  Doing it asynchronously seems to work around the problem, but
5150
    // shouldn't the style change that hides the infobar handle all necessary
5151
    // invalidation, including the newly-exposed area?
5152
5153
    return mParentWidget->Invalidate(PR_FALSE);
5154
}
5155
5156
/* static */ void
5157
nsDocShell::DisableCaret(nsIDocShellTreeItem *aRoot)
5158
{
5159
    nsCOMPtr<nsIDocShell> ds = do_QueryInterface(aRoot);
5160
    if (ds) {
5161
        nsCOMPtr<nsIPresShell> presShell;
5162
        ds->GetPresShell(getter_AddRefs(presShell));
5163
        if (presShell) {
5164
            nsCOMPtr<nsICaret> caret;
5165
            presShell->GetCaret(getter_AddRefs(caret));
5166
5167
            if (caret) {
5168
                caret->SetCaretVisible(PR_FALSE);
5169
            }
5170
        }
5171
    }
5172
5173
    nsCOMPtr<nsIDocShellTreeNode> node = do_QueryInterface(aRoot);
5174
    if (node) {
5175
        PRInt32 childCount = 0;
5176
        node->GetChildCount(&childCount);
5177
5178
        nsCOMPtr<nsIDocShellTreeItem> child;
5179
        for (PRInt32 i = 0; i < childCount; ++i) {
5180
            node->GetChildAt(i, getter_AddRefs(child));
5181
            DisableCaret(child);
5182
        }
5183
    }
5184
}
5185
4704
NS_IMETHODIMP
5186
NS_IMETHODIMP
4705
nsDocShell::CreateContentViewer(const char *aContentType,
5187
nsDocShell::CreateContentViewer(const char *aContentType,
4706
                                nsIRequest * request,
5188
                                nsIRequest * request,
 Lines 4727-4733   nsDocShell::CreateContentViewer(const ch Link Here 
4727
    // is changed within the DocShell - otherwise, javascript will get the
5209
    // is changed within the DocShell - otherwise, javascript will get the
4728
    // wrong information :-(
5210
    // wrong information :-(
4729
    //
5211
    //
4730
    (void) FireUnloadNotification();
5212
5213
    PRBool savePresentation = CanSavePresentation(request);
5214
    if (!savePresentation)
5215
        FireUnloadNotification();
4731
5216
4732
    // Set mFiredUnloadEvent = PR_FALSE so that the unload handler for the
5217
    // Set mFiredUnloadEvent = PR_FALSE so that the unload handler for the
4733
    // *new* document will fire.
5218
    // *new* document will fire.
 Lines 4742-4747   nsDocShell::CreateContentViewer(const ch Link Here 
4742
5227
4743
    PRBool onLocationChangeNeeded = OnLoadingSite(aOpenedChannel, PR_FALSE);
5228
    PRBool onLocationChangeNeeded = OnLoadingSite(aOpenedChannel, PR_FALSE);
4744
5229
5230
    if (savePresentation) {
5231
        // The old content viewer will be saved during the call to Embed().
5232
        rv = CaptureState();
5233
        gSavingOldViewer = PR_TRUE;
5234
        // XXX this isn't really fatal, necessarily...
5235
        // should we try to fire unload if NS_FAILED(rv) ?
5236
    }
5237
4745
    // let's try resetting the load group if we need to...
5238
    // let's try resetting the load group if we need to...
4746
    nsCOMPtr<nsILoadGroup> currentLoadGroup;
5239
    nsCOMPtr<nsILoadGroup> currentLoadGroup;
4747
    NS_ENSURE_SUCCESS(aOpenedChannel->
5240
    NS_ENSURE_SUCCESS(aOpenedChannel->
 Lines 4783-4788   nsDocShell::CreateContentViewer(const ch Link Here 
4783
    NS_ENSURE_SUCCESS(Embed(viewer, "", (nsISupports *) nsnull),
5276
    NS_ENSURE_SUCCESS(Embed(viewer, "", (nsISupports *) nsnull),
4784
                      NS_ERROR_FAILURE);
5277
                      NS_ERROR_FAILURE);
4785
5278
5279
    gSavingOldViewer = PR_FALSE;
4786
    mEODForCurrentDocument = PR_FALSE;
5280
    mEODForCurrentDocument = PR_FALSE;
4787
5281
4788
    // if this document is part of a multipart document,
5282
    // if this document is part of a multipart document,
 Lines 5005-5010   nsDocShell::SetupNewViewer(nsIContentVie Link Here 
5005
5499
5006
    // Ensure that the content viewer is destroyed *after* the GC - bug 71515
5500
    // Ensure that the content viewer is destroyed *after* the GC - bug 71515
5007
    nsCOMPtr<nsIContentViewer> kungfuDeathGrip = mContentViewer;
5501
    nsCOMPtr<nsIContentViewer> kungfuDeathGrip = mContentViewer;
5502
    nsCOMPtr<nsIDOMDocument> oldDocument;
5008
    if (mContentViewer) {
5503
    if (mContentViewer) {
5009
        // Stop any activity that may be happening in the old document before
5504
        // Stop any activity that may be happening in the old document before
5010
        // releasing it...
5505
        // releasing it...
 Lines 5030-5037   nsDocShell::SetupNewViewer(nsIContentVie Link Here 
5030
            }
5525
            }
5031
        }
5526
        }
5032
5527
5528
        mContentViewer->GetDOMDocument(getter_AddRefs(oldDocument));
5529
5033
        mContentViewer->Close();
5530
        mContentViewer->Close();
5034
        aNewViewer->SetPreviousViewer(mContentViewer);
5531
        aNewViewer->SetPreviousViewer(mContentViewer);
5532
5533
        if (gSavingOldViewer) {
5534
            // Tell the old content viewer to hibernate in session history when
5535
            // it is destroyed.
5536
            mContentViewer->SetHistoryEntry(mOSHE);
5537
        }
5538
5035
        mContentViewer = nsnull;
5539
        mContentViewer = nsnull;
5036
    }
5540
    }
5037
5541
 Lines 5572-5578   nsDocShell::InternalLoad(nsIURI * aURI, Link Here 
5572
                NS_ENSURE_TRUE(hEntry, NS_ERROR_FAILURE);
6076
                NS_ENSURE_TRUE(hEntry, NS_ERROR_FAILURE);
5573
                nsCOMPtr<nsISHEntry> shEntry(do_QueryInterface(hEntry));
6077
                nsCOMPtr<nsISHEntry> shEntry(do_QueryInterface(hEntry));
5574
                if (shEntry)
6078
                if (shEntry)
5575
                    shEntry->SetTitle(mTitle.get());
6079
                    shEntry->SetTitle(mTitle);
5576
            }
6080
            }
5577
6081
5578
            return NS_OK;
6082
            return NS_OK;
 Lines 5627-5632   nsDocShell::InternalLoad(nsIURI * aURI, Link Here 
5627
    // been called.
6131
    // been called.
5628
    mLSHE = aSHEntry;
6132
    mLSHE = aSHEntry;
5629
6133
6134
    // If we have a saved content viewer in history, restore and show it now.
6135
    if (aSHEntry) {
6136
        if (!CanSavePresentation(nsnull))
6137
            FireUnloadNotification();
6138
6139
        mFiredUnloadEvent = PR_FALSE;
6140
6141
        CaptureState();
6142
6143
        rv = RestorePresentation(aSHEntry);
6144
        if (NS_SUCCEEDED(rv))
6145
            return rv;
6146
    }
6147
5630
    nsCOMPtr<nsIRequest> req;
6148
    nsCOMPtr<nsIRequest> req;
5631
    rv = DoURILoad(aURI, aReferrer,
6149
    rv = DoURILoad(aURI, aReferrer,
5632
                   !(aFlags & INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER),
6150
                   !(aFlags & INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER),
 Lines 6524-6535   nsDocShell::AddToSessionHistory(nsIURI * Link Here 
6524
    }
7042
    }
6525
7043
6526
    //Title is set in nsDocShell::SetTitle()
7044
    //Title is set in nsDocShell::SetTitle()
6527
    entry->Create(aURI,         // uri
7045
    entry->Create(aURI,              // uri
6528
                  nsnull,       // Title
7046
                  EmptyString(),     // Title
6529
                  nsnull,       // DOMDocument
7047
                  inputStream,       // Post data stream
6530
                  inputStream,  // Post data stream
7048
                  nsnull,            // LayoutHistory state
6531
                  nsnull,       // LayoutHistory state
7049
                  cacheKey,          // CacheKey
6532
                  cacheKey,     // CacheKey
6533
                  mContentTypeHint); // Content-type
7050
                  mContentTypeHint); // Content-type
6534
    entry->SetReferrerURI(referrerURI);
7051
    entry->SetReferrerURI(referrerURI);
6535
    /* If cache got a 'no-store', ask SH not to store
7052
    /* If cache got a 'no-store', ask SH not to store
 Lines 6560-6566   nsDocShell::AddToSessionHistory(nsIURI * Link Here 
6560
        if (LOAD_TYPE_HAS_FLAGS(mLoadType, LOAD_FLAGS_REPLACE_HISTORY)) {            
7077
        if (LOAD_TYPE_HAS_FLAGS(mLoadType, LOAD_FLAGS_REPLACE_HISTORY)) {            
6561
            // Replace current entry in session history.
7078
            // Replace current entry in session history.
6562
            PRInt32  index = 0;   
7079
            PRInt32  index = 0;   
6563
            nsCOMPtr<nsIHistoryEntry> hEntry;
6564
            mSessionHistory->GetIndex(&index);
7080
            mSessionHistory->GetIndex(&index);
6565
            nsCOMPtr<nsISHistoryInternal>   shPrivate(do_QueryInterface(mSessionHistory));
7081
            nsCOMPtr<nsISHistoryInternal>   shPrivate(do_QueryInterface(mSessionHistory));
6566
            // Replace the current entry with the new entry
7082
            // Replace the current entry with the new entry
 Lines 6605-6614   nsDocShell::LoadHistoryEntry(nsISHEntry Link Here 
6605
    nsCAutoString contentType;
7121
    nsCAutoString contentType;
6606
7122
6607
    NS_ENSURE_TRUE(aEntry, NS_ERROR_FAILURE);
7123
    NS_ENSURE_TRUE(aEntry, NS_ERROR_FAILURE);
6608
    nsCOMPtr<nsIHistoryEntry> hEntry(do_QueryInterface(aEntry));
6609
    NS_ENSURE_TRUE(hEntry, NS_ERROR_FAILURE);
6610
7124
6611
    NS_ENSURE_SUCCESS(hEntry->GetURI(getter_AddRefs(uri)), NS_ERROR_FAILURE);
7125
    NS_ENSURE_SUCCESS(aEntry->GetURI(getter_AddRefs(uri)), NS_ERROR_FAILURE);
6612
    NS_ENSURE_SUCCESS(aEntry->GetReferrerURI(getter_AddRefs(referrerURI)),
7126
    NS_ENSURE_SUCCESS(aEntry->GetReferrerURI(getter_AddRefs(referrerURI)),
6613
                      NS_ERROR_FAILURE);
7127
                      NS_ERROR_FAILURE);
6614
    NS_ENSURE_SUCCESS(aEntry->GetPostData(getter_AddRefs(postData)),
7128
    NS_ENSURE_SUCCESS(aEntry->GetPostData(getter_AddRefs(postData)),
 Lines 6703-6711   nsDocShell::CloneAndReplace(nsISHEntry * Link Here 
6703
    nsISHEntry *dest = (nsISHEntry *) nsnull;
7217
    nsISHEntry *dest = (nsISHEntry *) nsnull;
6704
    PRUint32 srcID;
7218
    PRUint32 srcID;
6705
    src->GetID(&srcID);
7219
    src->GetID(&srcID);
6706
    nsCOMPtr<nsIHistoryEntry> srcHE(do_QueryInterface(src));
6707
7220
6708
    if (!src || !replaceEntry || !srcHE)
7221
    if (!src || !replaceEntry)
6709
        return NS_ERROR_FAILURE;
7222
        return NS_ERROR_FAILURE;
6710
7223
6711
    if (srcID == aCloneID) {
7224
    if (srcID == aCloneID) {
(-)docshell/base/nsDocShell.h (-1 / +49 lines)
Line     Link Here 
 Lines 100-105    Link Here 
100
#include "nsIHttpChannel.h"
100
#include "nsIHttpChannel.h"
101
#include "nsDocShellTransferableHooks.h"
101
#include "nsDocShellTransferableHooks.h"
102
#include "nsIAuthPromptProvider.h"
102
#include "nsIAuthPromptProvider.h"
103
#include "nsISecureBrowserUI.h"
103
104
104
/**
105
/**
105
 * Load flag for error pages. This should be bigger than all flags on
106
 * Load flag for error pages. This should be bigger than all flags on
 Lines 340-346   protected: Link Here 
340
    NS_IMETHOD EnsureEditorData();
341
    NS_IMETHOD EnsureEditorData();
341
    nsresult   EnsureTransferableHookData();
342
    nsresult   EnsureTransferableHookData();
342
    NS_IMETHOD EnsureFind();
343
    NS_IMETHOD EnsureFind();
343
    NS_IMETHOD RefreshURIFromQueue();
344
    nsresult   RefreshURIFromQueue();
345
    void       SuspendRefreshURIs();
344
    NS_IMETHOD DisplayLoadError(nsresult aError, nsIURI *aURI,
346
    NS_IMETHOD DisplayLoadError(nsresult aError, nsIURI *aURI,
345
                                const PRUnichar *aURL,
347
                                const PRUnichar *aURL,
346
                                nsIChannel* aFailedChannel = nsnull);
348
                                nsIChannel* aFailedChannel = nsnull);
 Lines 395-400   protected: Link Here 
395
    PRBool SetCurrentURI(nsIURI *aURI, nsIRequest *aRequest,
397
    PRBool SetCurrentURI(nsIURI *aURI, nsIRequest *aRequest,
396
                         PRBool aFireOnLocationChange);
398
                         PRBool aFireOnLocationChange);
397
399
400
    // The following methods deal with saving and restoring content viewers
401
    // in session history.
402
403
    // mContentViewer points to the current content viewer associated with
404
    // this docshell.  When loading a new document, the content viewer is
405
    // either destroyed or stored into a session history entry.  To make sure
406
    // that destruction happens in a controlled fashion, a given content viewer
407
    // is always owned in exactly one of these ways:
408
    //   1) The content viewer is active and owned by a docshell's
409
    //      mContentViewer.
410
    //   2) The content viewer is still being displayed while we begin loading
411
    //      a new document.  The content viewer is owned by the _new_
412
    //      content viewer's mPreviousViewer, and has a pointer to the
413
    //      nsISHEntry where it will eventually be stored.  The content viewer
414
    //      has been close()d by the docshell, which detaches the document from
415
    //      the window object.
416
    //   3) The content viewer is cached in session history.  The nsISHEntry
417
    //      has the only owning reference to the content viewer.  The viewer
418
    //      has released its nsISHEntry pointer to prevent circular ownership.
419
    //
420
    // When restoring a content viewer from session history, open() is called
421
    // to reattach the document to the window object.  The content viewer is
422
    // then placed into mContentViewer and removed from the history entry.
423
    // (mContentViewer is put into session history as described above, if
424
    // applicable).
425
426
    // Determines whether we can safely cache the current mContentViewer in
427
    // session history.  This checks a number of factors such as cache policy,
428
    // pending requests, and unload handlers.  |aNewRequest| should be the
429
    // request for the document to be loaded in place of the current document.
430
    PRBool CanSavePresentation(nsIRequest *aNewRequest);
431
432
    // Captures the state of the supporting elements of the presentation
433
    // (the "window" object, docshell tree, meta-refresh loads, and security
434
    // state) and stores them on |mOSHE|.
435
    nsresult CaptureState();
436
437
    // Restores the presentation stored in |aSHEntry|.
438
    nsresult RestorePresentation(nsISHEntry *aSHEntry);
439
440
    // Disable the caret in |aRoot| and all children.
441
    static void DisableCaret(nsIDocShellTreeItem *aRoot);
442
398
protected:
443
protected:
399
    // Override the parent setter from nsDocLoader
444
    // Override the parent setter from nsDocLoader
400
    virtual nsresult SetDocLoaderParent(nsDocLoader * aLoader);
445
    virtual nsresult SetDocLoaderParent(nsDocLoader * aLoader);
 Lines 474-479   protected: Link Here 
474
    // Transferable hooks/callbacks
519
    // Transferable hooks/callbacks
475
    nsCOMPtr<nsIClipboardDragDropHookList>  mTransferableHookData;
520
    nsCOMPtr<nsIClipboardDragDropHookList>  mTransferableHookData;
476
521
522
    // Secure browser UI object
523
    nsCOMPtr<nsISecureBrowserUI> mSecurityUI;
524
477
    // WEAK REFERENCES BELOW HERE.
525
    // WEAK REFERENCES BELOW HERE.
478
    // Note these are intentionally not addrefd.  Doing so will create a cycle.
526
    // Note these are intentionally not addrefd.  Doing so will create a cycle.
479
    // For that reasons don't use nsCOMPtr.
527
    // For that reasons don't use nsCOMPtr.
(-)docshell/base/nsIContentViewer.idl (-1 / +19 lines)
Line     Link Here 
 Lines 1-6    Link Here 
1
#include "nsISupports.idl"
1
#include "nsISupports.idl"
2
2
3
interface nsIDOMDocument;
3
interface nsIDOMDocument;
4
interface nsISHEntry;
4
5
5
6
6
%{ C++
7
%{ C++
 Lines 13-19   struct nsRect; Link Here 
13
[ptr] native nsIDeviceContextPtr(nsIDeviceContext);
14
[ptr] native nsIDeviceContextPtr(nsIDeviceContext);
14
[ref] native nsRectRef(nsRect);
15
[ref] native nsRectRef(nsRect);
15
16
16
[scriptable, uuid(70b8f22d-135c-4c94-8044-1bd3238d0990)]
17
[scriptable, uuid(e2c68a4d-b396-11d9-a3d1-00112478d626)]
17
interface nsIContentViewer : nsISupports
18
interface nsIContentViewer : nsISupports
18
{
19
{
19
20
 Lines 68-71   interface nsIContentViewer : nsISupports Link Here 
68
   */
69
   */
69
70
70
  boolean requestWindowClose();
71
  boolean requestWindowClose();
72
73
  /**
74
   * Attach the content viewer to its DOM window and docshell.
75
   */
76
  void open();
77
78
  /**
79
   * Set the  session history entry for the content viewer.  If this is set,
80
   * then the following actions will happen when destroy() is called (*):
81
   *  - Sanitize() will be called on the viewer's document
82
   *  - The content viewer will set the contentViewer property on the
83
   *    history entry, and release its reference (ownership reversal).
84
   *  - hide() will be called, and no further destruction will happen.
85
   *
86
   *  (*) unless the document is currently being printed
87
   */
88
  void setHistoryEntry(in nsISHEntry entry);
71
};
89
};
(-)docshell/base/nsIDocShell.idl (+7 lines)
Line     Link Here 
 Lines 64-69   interface nsIInputStream; Link Here 
64
interface nsIRequest;
64
interface nsIRequest;
65
interface nsISHEntry;
65
interface nsISHEntry;
66
interface nsILayoutHistoryState;
66
interface nsILayoutHistoryState;
67
interface nsISecureBrowserUI;
67
68
68
[scriptable, uuid(BBFDF99E-D675-42FD-B3EA-EA341C2331A6)]
69
[scriptable, uuid(BBFDF99E-D675-42FD-B3EA-EA341C2331A6)]
69
interface nsIDocShell : nsISupports
70
interface nsIDocShell : nsISupports
 Lines 340-344   interface nsIDocShell : nsISupports Link Here 
340
  attribute nsILayoutHistoryState layoutHistoryState;
341
  attribute nsILayoutHistoryState layoutHistoryState;
341
342
342
  readonly attribute boolean shouldSaveLayoutState;
343
  readonly attribute boolean shouldSaveLayoutState;
344
345
  /**
346
   * The SecureBrowserUI object for this docshell.  This is set by XUL
347
   * <browser> or nsWebBrowser for their root docshell.
348
   */
349
  attribute nsISecureBrowserUI securityUI;
343
};
350
};
344
351
(-)dom/public/base/nsPIDOMWindow.h (+12 lines)
Line     Link Here 
 Lines 124-129   public: Link Here 
124
    return !mIsDocumentLoaded || mRunningTimeout;
124
    return !mIsDocumentLoaded || mRunningTimeout;
125
  }
125
  }
126
126
127
  // Check whether a document is currently loading
128
  PRBool IsLoading() const
129
  {
130
    return !mIsDocumentLoaded;
131
  }
132
127
  PRBool IsHandlingResizeEvent() const
133
  PRBool IsHandlingResizeEvent() const
128
  {
134
  {
129
    return mIsHandlingResizeEvent;
135
    return mIsHandlingResizeEvent;
 Lines 139-144   public: Link Here 
139
  // Clear all pending timeouts and intervals.
145
  // Clear all pending timeouts and intervals.
140
  virtual void ClearAllTimeouts() = 0;
146
  virtual void ClearAllTimeouts() = 0;
141
  
147
  
148
  // Returns an object containing the window's state.
149
  virtual nsresult SaveWindowState(nsISupports **aState) = 0;
150
151
  // Restore the window state from aState.
152
  virtual nsresult RestoreWindowState(nsISupports *aState) = 0;
153
142
protected:
154
protected:
143
  nsPIDOMWindow()
155
  nsPIDOMWindow()
144
    : mRunningTimeout(nsnull), mMutationBits(0), mIsDocumentLoaded(PR_FALSE),
156
    : mRunningTimeout(nsnull), mMutationBits(0), mIsDocumentLoaded(PR_FALSE),
(-)dom/public/coreEvents/nsIDOMLoadListener.h (-3 / +9 lines)
Line     Link Here 
 Lines 47-55    Link Here 
47
 *
47
 *
48
 */
48
 */
49
#define NS_IDOMLOADLISTENER_IID \
49
#define NS_IDOMLOADLISTENER_IID \
50
{ /* d1810238-14f8-4cab-9b96-96bedb9de7be */ \
50
{0x0f7fa587, 0xaac5, 0x11d9, \
51
0xd1810238, 0x14f8, 0x4cab, \
51
{0xba, 0x4e, 0x00, 0x11, 0x24, 0x78, 0xd6, 0x26} }
52
{0x9b, 0x96, 0x96, 0xbe, 0xdb, 0x9d, 0xe7, 0xbe} }
53
52
54
class nsIDOMLoadListener : public nsIDOMEventListener {
53
class nsIDOMLoadListener : public nsIDOMEventListener {
55
54
 Lines 91-96   public: Link Here 
91
   */
90
   */
92
  NS_IMETHOD Error(nsIDOMEvent* aEvent) = 0;
91
  NS_IMETHOD Error(nsIDOMEvent* aEvent) = 0;
93
92
93
  /**
94
   * Processes a DOMPageRestore event.  This is dispatched when a page's
95
   * presentation is restored from session history (onload does not fire
96
   * in this case).
97
   * @param aEvent The event object
98
   */
99
  NS_IMETHOD PageRestore(nsIDOMEvent* aEvent) = 0;
94
};
100
};
95
101
96
#endif // nsIDOMLoadListener_h__
102
#endif // nsIDOMLoadListener_h__
(-)dom/src/base/nsGlobalWindow.cpp (-4 / +335 lines)
Line     Link Here 
 Lines 153-158    Link Here 
153
153
154
#include "nsIBindingManager.h"
154
#include "nsIBindingManager.h"
155
#include "nsIXBLService.h"
155
#include "nsIXBLService.h"
156
#include "nsIDOMNSHTMLElement.h"
157
#include "nsIDOMXULElement.h"
156
158
157
// used for popup blocking, needs to be converted to something
159
// used for popup blocking, needs to be converted to something
158
// belonging to the back-end like nsIContentPolicy
160
// belonging to the back-end like nsIContentPolicy
 Lines 171-176   static PRInt32 gRunningTime Link Here 
171
PRInt32 gTimeoutCnt                                    = 0;
173
PRInt32 gTimeoutCnt                                    = 0;
172
#endif
174
#endif
173
175
176
#ifdef DEBUG_bryner
177
#define DEBUG_PAGE_CACHE
178
#endif
179
174
#define DOM_MIN_TIMEOUT_VALUE 10 // 10ms
180
#define DOM_MIN_TIMEOUT_VALUE 10 // 10ms
175
181
176
// CIDs
182
// CIDs
 Lines 4272-4281   nsGlobalWindow::GetPrivateRoot() Link Here 
4272
    nsIDocument* doc = chromeElement->GetDocument();
4278
    nsIDocument* doc = chromeElement->GetDocument();
4273
    if (doc) {
4279
    if (doc) {
4274
      parent = do_QueryInterface(doc->GetScriptGlobalObject());
4280
      parent = do_QueryInterface(doc->GetScriptGlobalObject());
4275
      nsCOMPtr<nsIDOMWindow> tempParent;
4281
      if (parent) {
4276
      parent->GetTop(getter_AddRefs(tempParent));
4282
        nsCOMPtr<nsIDOMWindow> tempParent;
4277
      return NS_STATIC_CAST(nsGlobalWindow *,
4283
        parent->GetTop(getter_AddRefs(tempParent));
4278
                            NS_STATIC_CAST(nsIDOMWindow*, tempParent));
4284
        return NS_STATIC_CAST(nsGlobalWindow *,
4285
                              NS_STATIC_CAST(nsIDOMWindow*, tempParent));
4286
      }
4279
    }
4287
    }
4280
  }
4288
  }
4281
4289
 Lines 5768-5773   nsGlobalWindow::EnsureSizeUpToDate() Link Here 
5768
  }
5776
  }
5769
}
5777
}
5770
5778
5779
#define WINDOWSTATEHOLDER_IID \
5780
{0xae1c7401, 0xcdee, 0x404a, {0xbd, 0x63, 0x05, 0xc0, 0x35, 0x0d, 0xa7, 0x72}}
5781
5782
class WindowStateHolder : public nsISupports
5783
{
5784
public:
5785
  NS_DEFINE_STATIC_IID_ACCESSOR(WINDOWSTATEHOLDER_IID)
5786
  NS_DECL_ISUPPORTS
5787
5788
  WindowStateHolder(JSContext *cx, JSObject *aObject, nsGlobalWindow *aWindow);
5789
5790
  JSObject* GetObject() { return mJSObj; }
5791
  nsIEventListenerManager* GetListenerManager() { return mListenerManager; }
5792
  nsIDOMElement* GetFocusedElement() { return mFocusedElement; }
5793
  nsIDOMWindowInternal* GetFocusedWindow() { return mFocusedWindow; }
5794
  nsTimeout* GetSavedTimeouts() { return mSavedTimeouts; }
5795
  void ClearSavedTimeouts() { mSavedTimeouts = nsnull; }
5796
5797
private:
5798
  ~WindowStateHolder();
5799
5800
  JSRuntime *mRuntime;
5801
  JSObject *mJSObj;
5802
  nsCOMPtr<nsIEventListenerManager> mListenerManager;
5803
  nsCOMPtr<nsIDOMElement> mFocusedElement;
5804
  nsCOMPtr<nsIDOMWindowInternal> mFocusedWindow;
5805
  nsTimeout *mSavedTimeouts;
5806
};
5807
5808
WindowStateHolder::WindowStateHolder(JSContext *cx, JSObject *aObject,
5809
                                     nsGlobalWindow *aWindow)
5810
  : mRuntime(::JS_GetRuntime(cx)), mJSObj(aObject), mSavedTimeouts(nsnull)
5811
{
5812
  NS_ASSERTION(aWindow, "null window");
5813
5814
  aWindow->GetListenerManager(getter_AddRefs(mListenerManager));
5815
5816
  nsIFocusController *fc = aWindow->GetRootFocusController();
5817
  NS_ASSERTION(fc, "null focus controller");
5818
5819
  // We want to save the focused element/window only if they are inside of
5820
  // this window.
5821
5822
  nsCOMPtr<nsIDOMWindowInternal> focusWinInternal;
5823
  fc->GetFocusedWindow(getter_AddRefs(focusWinInternal));
5824
5825
  nsPIDOMWindow *focusedWindow =
5826
    NS_STATIC_CAST(nsPIDOMWindow*,
5827
                   NS_STATIC_CAST(nsGlobalWindow*,
5828
                                  NS_STATIC_CAST(nsIDOMWindowInternal*,
5829
                                                 focusWinInternal)));
5830
5831
  while (focusedWindow) {
5832
    if (focusedWindow == aWindow) {
5833
      fc->GetFocusedWindow(getter_AddRefs(mFocusedWindow));
5834
      fc->GetFocusedElement(getter_AddRefs(mFocusedElement));
5835
      break;
5836
    }
5837
5838
    focusedWindow =
5839
      NS_STATIC_CAST(nsGlobalWindow*, focusedWindow)->GetPrivateParent();
5840
  }
5841
5842
  aWindow->SuspendTimeouts();
5843
5844
  // Clear the timeout list for aWindow (but we don't need to for children)
5845
  mSavedTimeouts = aWindow->mTimeouts;
5846
  aWindow->mTimeouts = nsnull;
5847
5848
  ::JS_AddNamedRoot(cx, &mJSObj, "WindowStateHolder::mJSObj");
5849
}
5850
5851
WindowStateHolder::~WindowStateHolder()
5852
{
5853
  ::JS_RemoveRootRT(mRuntime, &mJSObj);
5854
}
5855
5856
NS_IMPL_ISUPPORTS1(WindowStateHolder, WindowStateHolder)
5857
5858
static JSClass sWindowStateClass = {
5859
  "window state", 0,
5860
  JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
5861
  JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
5862
  JSCLASS_NO_OPTIONAL_MEMBERS
5863
};
5864
5865
static void
5866
CopyJSPropertyArray(JSContext *cx, JSObject *aSource, JSObject *aDest,
5867
                    JSIdArray *props)
5868
{
5869
  jsint length = props->length;
5870
  jsint i;
5871
  for (i = 0; i < length; ++i) {
5872
    jsval propname_value;
5873
5874
    if (!::JS_IdToValue(cx, props->vector[i], &propname_value) ||
5875
        !JSVAL_IS_STRING(propname_value)) {
5876
      NS_WARNING("Failed to copy non-string window property\n");
5877
      continue;
5878
    }
5879
5880
    char *propname_str = ::JS_GetStringBytes(JSVAL_TO_STRING(propname_value));
5881
5882
    uintN attrs;
5883
    JSBool found;
5884
    if (!::JS_GetPropertyAttributes(cx, aSource, propname_str, &attrs, &found))
5885
      continue;
5886
5887
    if (!found)
5888
      continue;
5889
5890
    jsval propvalue;
5891
    if (!::JS_GetProperty(cx, aSource, propname_str, &propvalue)) {
5892
      NS_WARNING("property was found, but get failed");
5893
      continue;
5894
    }
5895
5896
    PRBool res = ::JS_DefineProperty(cx, aDest, propname_str, propvalue,
5897
                                     NULL, NULL, attrs);
5898
#ifdef DEBUG_PAGE_CACHE
5899
    if (res)
5900
      printf("Copied window property: %s\n", propname_str);
5901
#endif
5902
5903
#ifdef DEBUG
5904
    if (!res)
5905
      printf("failed to copy property: %s\n", propname_str);
5906
#endif
5907
  }
5908
}
5909
5910
static void
5911
CopyJSProperties(JSContext *cx, JSObject *aSource, JSObject *aDest)
5912
{
5913
  // Enumerate all of the properties on aSource and install them on aDest.
5914
5915
  JSIdArray *props = ::JS_Enumerate(cx, aSource);
5916
  if (!props) {
5917
#ifdef DEBUG_PAGE_CACHE
5918
    printf("[no properties]\n");
5919
#endif
5920
    return;
5921
  }
5922
5923
#ifdef DEBUG_PAGE_CACHE
5924
  printf("props length = %d\n", props->length);
5925
#endif
5926
5927
  CopyJSPropertyArray(cx, aSource, aDest, props);
5928
  ::JS_DestroyIdArray(cx, props);
5929
}
5930
5931
nsresult
5932
nsGlobalWindow::SaveWindowState(nsISupports **aState)
5933
{
5934
  *aState = nsnull;
5935
5936
  if (!mContext || !mJSObject) {
5937
    // The window may be getting torn down; don't bother saving state.
5938
    return NS_OK;
5939
  }
5940
5941
  JSContext *cx = NS_STATIC_CAST(JSContext*, mContext->GetNativeContext());
5942
  NS_ENSURE_TRUE(cx, NS_ERROR_FAILURE);
5943
5944
  JSObject *stateObj = ::JS_NewObject(cx, &sWindowStateClass, NULL, NULL);
5945
  NS_ENSURE_TRUE(stateObj, NS_ERROR_OUT_OF_MEMORY);
5946
5947
#ifdef DEBUG_PAGE_CACHE
5948
  printf("saving window state, stateObj = %p\n", stateObj);
5949
#endif
5950
  CopyJSProperties(cx, mJSObject, stateObj);
5951
5952
  *aState = new WindowStateHolder(cx, stateObj, this);
5953
  NS_ENSURE_TRUE(*aState, NS_ERROR_OUT_OF_MEMORY);
5954
5955
  NS_ADDREF(*aState);
5956
  return NS_OK;
5957
}
5958
5959
nsresult
5960
nsGlobalWindow::RestoreWindowState(nsISupports *aState)
5961
{
5962
  if (!mContext || !mJSObject) {
5963
    // The window may be getting torn down; don't bother restoring state.
5964
    return NS_OK;
5965
  }
5966
5967
  JSContext *cx = NS_STATIC_CAST(JSContext*, mContext->GetNativeContext());
5968
  NS_ENSURE_TRUE(cx, NS_ERROR_FAILURE);
5969
5970
  // Note that we don't need to call JS_ClearScope here.  The scope is already
5971
  // cleared by SetNewDocument(), and calling it again here will remove the
5972
  // XPConnect properties.
5973
5974
  nsCOMPtr<WindowStateHolder> holder = do_QueryInterface(aState);
5975
  if (holder) {
5976
#ifdef DEBUG_PAGE_CACHE
5977
    printf("restoring window state, stateObj = %p\n", holder->GetObject());
5978
#endif
5979
    CopyJSProperties(cx, holder->GetObject(), mJSObject);
5980
    mListenerManager = holder->GetListenerManager();
5981
5982
    nsIDOMElement *focusedElement = holder->GetFocusedElement();
5983
    if (focusedElement) {
5984
      nsCOMPtr<nsIDOMNSHTMLElement> htmlElement =
5985
        do_QueryInterface(focusedElement);
5986
      if (htmlElement) {
5987
        htmlElement->Focus();
5988
      } else {
5989
        nsCOMPtr<nsIDOMXULElement> xulElement =
5990
          do_QueryInterface(focusedElement);
5991
        if (xulElement) {
5992
          xulElement->Focus();
5993
        }
5994
      }
5995
    } else {
5996
      nsIDOMWindowInternal *focusedWindow = holder->GetFocusedWindow();
5997
      if (focusedWindow) {
5998
        focusedWindow->Focus();
5999
      }
6000
    }
6001
  }
6002
6003
  mTimeouts = holder->GetSavedTimeouts();
6004
  holder->ClearSavedTimeouts();
6005
6006
  return ResumeTimeouts();
6007
}
6008
6009
void
6010
nsGlobalWindow::SuspendTimeouts()
6011
{
6012
  PRInt64 now = PR_IntervalNow();
6013
  for (nsTimeout *t = mTimeouts; t; t = t->mNext) {
6014
    // For each non-interval timeout, we change mWhen to be the time remaining.
6015
    if (!t->mInterval)
6016
      t->mWhen = PR_MAX(0, t->mWhen - now);
6017
6018
    // Drop the XPCOM timer; we'll reschedule when restoring the state.
6019
    if (t->mTimer) {
6020
      t->mTimer->Cancel();
6021
      t->mTimer = nsnull;
6022
    }
6023
6024
    // We don't Release() the timeout because we still need it.
6025
  }
6026
6027
  // Suspend our children as well.
6028
  nsCOMPtr<nsIDocShellTreeNode> node = do_QueryInterface(mDocShell);
6029
  if (node) {
6030
    PRInt32 childCount = 0;
6031
    node->GetChildCount(&childCount);
6032
6033
    nsCOMPtr<nsIDocShellTreeItem> childShell;
6034
    for (PRInt32 i = 0; i < childCount; ++i) {
6035
      node->GetChildAt(i, getter_AddRefs(childShell));
6036
      NS_ASSERTION(childShell, "null child shell");
6037
6038
      nsCOMPtr<nsPIDOMWindow> pWin = do_GetInterface(childShell);
6039
      if (pWin) {
6040
        nsGlobalWindow *win =
6041
          NS_STATIC_CAST(nsGlobalWindow*,
6042
                         NS_STATIC_CAST(nsPIDOMWindow*, pWin));
6043
6044
        win->SuspendTimeouts();
6045
      }
6046
    }
6047
  }
6048
}
6049
6050
nsresult
6051
nsGlobalWindow::ResumeTimeouts()
6052
{
6053
  // Restore all of the timeouts.  Interval timeouts are rescheduled as before;
6054
  // non-interval timers are scheduled using the stored time remaining.
6055
6056
  PRInt64 now = PR_IntervalNow();
6057
  nsresult rv;
6058
6059
  for (nsTimeout *t = mTimeouts; t; t = t->mNext) {
6060
    PRInt32 interval;
6061
    if (t->mInterval) {
6062
      interval = t->mInterval;
6063
    } else {
6064
      interval = t->mWhen;
6065
      t->mWhen += now;
6066
    }
6067
6068
    t->mTimer = do_CreateInstance("@mozilla.org/timer;1");
6069
    NS_ENSURE_TRUE(t->mTimer, NS_ERROR_OUT_OF_MEMORY);
6070
6071
    rv = t->mTimer->InitWithFuncCallback(TimerCallback, t, interval,
6072
                                         nsITimer::TYPE_ONE_SHOT);
6073
    NS_ENSURE_SUCCESS(rv, rv);
6074
  }
6075
6076
  // Resume our children as well.
6077
  nsCOMPtr<nsIDocShellTreeNode> node = do_QueryInterface(mDocShell);
6078
  if (node) {
6079
    PRInt32 childCount = 0;
6080
    node->GetChildCount(&childCount);
6081
6082
    nsCOMPtr<nsIDocShellTreeItem> childShell;
6083
    for (PRInt32 i = 0; i < childCount; ++i) {
6084
      node->GetChildAt(i, getter_AddRefs(childShell));
6085
      NS_ASSERTION(childShell, "null child shell");
6086
6087
      nsCOMPtr<nsPIDOMWindow> pWin = do_GetInterface(childShell);
6088
      if (pWin) {
6089
        nsGlobalWindow *win =
6090
          NS_STATIC_CAST(nsGlobalWindow*,
6091
                         NS_STATIC_CAST(nsPIDOMWindow*, pWin));
6092
6093
        rv = win->ResumeTimeouts();
6094
        NS_ENSURE_SUCCESS(rv, rv);
6095
      }
6096
    }
6097
  }
6098
6099
  return NS_OK;
6100
}
6101
5771
// QueryInterface implementation for nsGlobalChromeWindow
6102
// QueryInterface implementation for nsGlobalChromeWindow
5772
NS_INTERFACE_MAP_BEGIN(nsGlobalChromeWindow)
6103
NS_INTERFACE_MAP_BEGIN(nsGlobalChromeWindow)
5773
  NS_INTERFACE_MAP_ENTRY(nsIDOMChromeWindow)
6104
  NS_INTERFACE_MAP_ENTRY(nsIDOMChromeWindow)
(-)dom/src/base/nsGlobalWindow.h (-1 / +7 lines)
Line     Link Here 
 Lines 199-205   public: Link Here 
199
  virtual NS_HIDDEN_(OpenAllowValue) GetOpenAllow(const nsAString &aName);
199
  virtual NS_HIDDEN_(OpenAllowValue) GetOpenAllow(const nsAString &aName);
200
200
201
  virtual NS_HIDDEN_(void) ClearAllTimeouts();
201
  virtual NS_HIDDEN_(void) ClearAllTimeouts();
202
  
202
  virtual NS_HIDDEN_(nsresult) SaveWindowState(nsISupports **aState);
203
  virtual NS_HIDDEN_(nsresult) RestoreWindowState(nsISupports *aState);
204
  virtual NS_HIDDEN_(void) SuspendTimeouts();
205
  virtual NS_HIDDEN_(nsresult) ResumeTimeouts();
206
203
  // nsIDOMViewCSS
207
  // nsIDOMViewCSS
204
  NS_DECL_NSIDOMVIEWCSS
208
  NS_DECL_NSIDOMVIEWCSS
205
209
 Lines 215-220   public: Link Here 
215
  static void ShutDown();
219
  static void ShutDown();
216
  static PRBool IsCallerChrome();
220
  static PRBool IsCallerChrome();
217
221
222
  friend class WindowStateHolder;
223
218
protected:
224
protected:
219
  // Object Management
225
  // Object Management
220
  virtual ~nsGlobalWindow();
226
  virtual ~nsGlobalWindow();
(-)embedding/browser/cocoa/src/CHClickListener.mm (-16 / +18 lines)
Line     Link Here 
 Lines 203-230   CHClickListener::MouseDown(nsIDOMEvent* Link Here 
203
    nsCOMPtr<nsIScriptGlobalObject> sgo;
203
    nsCOMPtr<nsIScriptGlobalObject> sgo;
204
    doc->GetScriptGlobalObject(getter_AddRefs(sgo));
204
    doc->GetScriptGlobalObject(getter_AddRefs(sgo));
205
    nsCOMPtr<nsIDOMWindow> window = do_QueryInterface(sgo);
205
    nsCOMPtr<nsIDOMWindow> window = do_QueryInterface(sgo);
206
    PRInt32 scrollX, scrollY;
206
    if (window) {
207
    window->GetScrollX(&scrollX);
207
      PRInt32 scrollX, scrollY;
208
    window->GetScrollY(&scrollY);
208
      window->GetScrollX(&scrollX);
209
    xDelta += scrollX; // Normal direction.
209
      window->GetScrollY(&scrollY);
210
    yDelta -= scrollY; // Remember, y is flipped.
210
      xDelta += scrollX; // Normal direction.
211
      yDelta -= scrollY; // Remember, y is flipped.
211
    
212
    
212
#define XMENUOFFSET 20
213
#define XMENUOFFSET 20
213
#define MENUHEIGHT 20
214
#define MENUHEIGHT 20
214
    
215
    
215
    xDelta += XMENUOFFSET;
216
      xDelta += XMENUOFFSET;
216
    yDelta -= MENUHEIGHT*(selIndex+1);
217
      yDelta -= MENUHEIGHT*(selIndex+1);
217
    
218
    
218
    NSEvent* event = [NSApp currentEvent];
219
      NSEvent* event = [NSApp currentEvent];
219
    NSPoint point = [event locationInWindow];
220
      NSPoint point = [event locationInWindow];
220
    point.x -= xDelta;
221
      point.x -= xDelta;
221
    point.y -= yDelta;
222
      point.y -= yDelta;
222
223
223
    NSEvent* mouseEvent = [NSEvent mouseEventWithType: NSLeftMouseDown location: point
224
      NSEvent* mouseEvent = [NSEvent mouseEventWithType: NSLeftMouseDown location: point
224
                                        modifierFlags: 0 timestamp: [event timestamp]
225
                                          modifierFlags: 0 timestamp: [event timestamp]
225
                                         windowNumber: [event windowNumber] context: [event context]
226
                                           windowNumber: [event windowNumber] context: [event context]
226
                                          eventNumber: [event eventNumber] clickCount: [event clickCount] 																						 pressure: [event pressure]];
227
                                            eventNumber: [event eventNumber] clickCount: [event clickCount] 																						 pressure: [event pressure]];
227
    [NSMenu popUpContextMenu: menu withEvent: mouseEvent forView: [[event window] contentView]];
228
      [NSMenu popUpContextMenu: menu withEvent: mouseEvent forView: [[event window] contentView]];
229
    }
228
  }
230
  }
229
  return NS_OK;
231
  return NS_OK;
230
}
232
}
(-)embedding/browser/webBrowser/nsWebBrowser.cpp (-2 / +3 lines)
Line     Link Here 
 Lines 1215-1222   NS_IMETHODIMP nsWebBrowser::Create() Link Here 
1215
   rv = GetContentDOMWindow(getter_AddRefs(domWindow));
1215
   rv = GetContentDOMWindow(getter_AddRefs(domWindow));
1216
   if (NS_SUCCEEDED(rv))
1216
   if (NS_SUCCEEDED(rv))
1217
   {
1217
   {
1218
       mSecurityUI = do_CreateInstance(NS_SECURE_BROWSER_UI_CONTRACTID, &rv);
1218
       nsCOMPtr<nsISecureBrowserUI> securityUI =
1219
       if (NS_SUCCEEDED(rv))mSecurityUI->Init(domWindow);
1219
           do_CreateInstance(NS_SECURE_BROWSER_UI_CONTRACTID, &rv);
1220
       if (NS_SUCCEEDED(rv)) securityUI->Init(domWindow);
1220
   }
1221
   }
1221
1222
1222
   mDocShellTreeOwner->AddToWatcher(); // evil twin of Remove in SetDocShell(0)
1223
   mDocShellTreeOwner->AddToWatcher(); // evil twin of Remove in SetDocShell(0)
(-)embedding/browser/webBrowser/nsWebBrowser.h (-1 lines)
Line     Link Here 
 Lines 168-174   protected: Link Here 
168
   nativeWindow               mParentNativeWindow;
168
   nativeWindow               mParentNativeWindow;
169
   nsIWebProgressListener    *mProgressListener;
169
   nsIWebProgressListener    *mProgressListener;
170
   nsCOMPtr<nsIWebProgress>      mWebProgress;
170
   nsCOMPtr<nsIWebProgress>      mWebProgress;
171
   nsCOMPtr<nsISecureBrowserUI> mSecurityUI;
172
171
173
   nsCOMPtr<nsIPrintSettings> mPrintSettings;
172
   nsCOMPtr<nsIPrintSettings> mPrintSettings;
174
173
(-)embedding/tests/mfcembed/StdAfx.h (+1 lines)
Line     Link Here 
 Lines 115-120    Link Here 
115
#include "nsIEmbeddingSiteWindow2.h"
115
#include "nsIEmbeddingSiteWindow2.h"
116
#include "nsIWebBrowserFind.h"
116
#include "nsIWebBrowserFind.h"
117
#include "nsIWebBrowserFocus.h"
117
#include "nsIWebBrowserFocus.h"
118
#include "nsIURI.h"
118
119
119
// Printer Includes
120
// Printer Includes
120
#include "nsIWebBrowserPrint.h"
121
#include "nsIWebBrowserPrint.h"
(-)extensions/xmlextras/base/src/nsDOMParser.cpp (+6 lines)
Line     Link Here 
 Lines 333-338   nsDOMParser::Error(nsIDOMEvent* aEvent) Link Here 
333
  return NS_OK;
333
  return NS_OK;
334
}
334
}
335
335
336
NS_IMETHODIMP
337
nsDOMParser::PageRestore(nsIDOMEvent* aEvent)
338
{
339
  return NS_OK;
340
}
341
336
nsDOMParser::nsDOMParser()
342
nsDOMParser::nsDOMParser()
337
  : mLoopingForSyncLoad(PR_FALSE)
343
  : mLoopingForSyncLoad(PR_FALSE)
338
{
344
{
(-)extensions/xmlextras/base/src/nsDOMParser.h (+1 lines)
Line     Link Here 
 Lines 67-72   public: Link Here 
67
  NS_IMETHOD Unload(nsIDOMEvent* aEvent);
67
  NS_IMETHOD Unload(nsIDOMEvent* aEvent);
68
  NS_IMETHOD Abort(nsIDOMEvent* aEvent);
68
  NS_IMETHOD Abort(nsIDOMEvent* aEvent);
69
  NS_IMETHOD Error(nsIDOMEvent* aEvent);
69
  NS_IMETHOD Error(nsIDOMEvent* aEvent);
70
  NS_IMETHOD PageRestore(nsIDOMEvent* aEvent);
70
71
71
private:
72
private:
72
  nsCOMPtr<nsIURI> mBaseURI;
73
  nsCOMPtr<nsIURI> mBaseURI;
(-)extensions/xmlextras/base/src/nsLoadListenerProxy.cpp (+12 lines)
Line     Link Here 
 Lines 121-123   nsLoadListenerProxy::Error(nsIDOMEvent* Link Here 
121
  
121
  
122
  return NS_OK;
122
  return NS_OK;
123
}
123
}
124
125
NS_IMETHODIMP
126
nsLoadListenerProxy::PageRestore(nsIDOMEvent* aEvent)
127
{
128
  nsCOMPtr<nsIDOMLoadListener> listener(do_QueryReferent(mParent));
129
130
  if (listener) {
131
    return listener->PageRestore(aEvent);
132
  }
133
  
134
  return NS_OK;
135
}
(-)extensions/xmlextras/base/src/nsLoadListenerProxy.h (+1 lines)
Line     Link Here 
 Lines 69-74   public: Link Here 
69
  NS_IMETHOD Unload(nsIDOMEvent* aEvent);
69
  NS_IMETHOD Unload(nsIDOMEvent* aEvent);
70
  NS_IMETHOD Abort(nsIDOMEvent* aEvent);
70
  NS_IMETHOD Abort(nsIDOMEvent* aEvent);
71
  NS_IMETHOD Error(nsIDOMEvent* aEvent);
71
  NS_IMETHOD Error(nsIDOMEvent* aEvent);
72
  NS_IMETHOD PageRestore(nsIDOMEvent* aEvent);
72
73
73
protected:
74
protected:
74
  nsWeakPtr  mParent;
75
  nsWeakPtr  mParent;
(-)extensions/xmlextras/base/src/nsXMLHttpRequest.cpp (+6 lines)
Line     Link Here 
 Lines 1731-1736   nsXMLHttpRequest::Error(nsIDOMEvent* aEv Link Here 
1731
  return NS_OK;
1731
  return NS_OK;
1732
}
1732
}
1733
1733
1734
NS_IMETHODIMP
1735
nsXMLHttpRequest::PageRestore(nsIDOMEvent* aEvent)
1736
{
1737
  return NS_OK;
1738
}
1739
1734
nsresult
1740
nsresult
1735
nsXMLHttpRequest::ChangeState(PRUint32 aState, PRBool aBroadcast,
1741
nsXMLHttpRequest::ChangeState(PRUint32 aState, PRBool aBroadcast,
1736
                              PRBool aClearEventListeners)
1742
                              PRBool aClearEventListeners)
(-)extensions/xmlextras/base/src/nsXMLHttpRequest.h (+1 lines)
Line     Link Here 
 Lines 97-102   public: Link Here 
97
  NS_IMETHOD Unload(nsIDOMEvent* aEvent);
97
  NS_IMETHOD Unload(nsIDOMEvent* aEvent);
98
  NS_IMETHOD Abort(nsIDOMEvent* aEvent);
98
  NS_IMETHOD Abort(nsIDOMEvent* aEvent);
99
  NS_IMETHOD Error(nsIDOMEvent* aEvent);
99
  NS_IMETHOD Error(nsIDOMEvent* aEvent);
100
  NS_IMETHOD PageRestore(nsIDOMEvent* aEvent);
100
101
101
  // nsIStreamListener
102
  // nsIStreamListener
102
  NS_DECL_NSISTREAMLISTENER
103
  NS_DECL_NSISTREAMLISTENER
(-)extensions/xmlextras/tests/TestXMLExtras.cpp (+1 lines)
Line     Link Here 
 Lines 78-83   public: Link Here 
78
  virtual nsresult Unload(nsIDOMEvent* aEvent) {printf("Unload\n"); return NS_OK;}
78
  virtual nsresult Unload(nsIDOMEvent* aEvent) {printf("Unload\n"); return NS_OK;}
79
  virtual nsresult Abort(nsIDOMEvent* aEvent)  {printf("Abort\n"); return NS_OK;}
79
  virtual nsresult Abort(nsIDOMEvent* aEvent)  {printf("Abort\n"); return NS_OK;}
80
  virtual nsresult Error(nsIDOMEvent* aEvent)  {printf("Error\n"); return NS_OK;}
80
  virtual nsresult Error(nsIDOMEvent* aEvent)  {printf("Error\n"); return NS_OK;}
81
  NS_IMETHOD PageRestore(nsIDOMEvent* aEvent) {printf("PageRestore\n"); return NS_OK;}
81
};
82
};
82
83
83
NS_IMPL_ADDREF(nsMyListener)
84
NS_IMPL_ADDREF(nsMyListener)
(-)layout/base/Makefile.in (+1 lines)
Line     Link Here 
 Lines 73-78   REQUIRES = xpcom \ Link Here 
73
		  util \
73
		  util \
74
		  windowwatcher \
74
		  windowwatcher \
75
		  accessibility \
75
		  accessibility \
76
		  shistory \
76
		  $(NULL)
77
		  $(NULL)
77
78
78
XPIDLSRCS	= \
79
XPIDLSRCS	= \
(-)layout/base/nsDocumentViewer.cpp (-85 / +148 lines)
Line     Link Here 
 Lines 148-154    Link Here 
148
#include "nsISupportsPrimitives.h"
148
#include "nsISupportsPrimitives.h"
149
149
150
// PrintOptions is now implemented by PrintSettingsService
150
// PrintOptions is now implemented by PrintSettingsService
151
static const char sPrintSettingsServiceContractID[] = "@mozilla.org/gfx/printsettings-service;1";
152
static const char sPrintOptionsContractID[]         = "@mozilla.org/gfx/printsettings-service;1";
151
static const char sPrintOptionsContractID[]         = "@mozilla.org/gfx/printsettings-service;1";
153
152
154
// Printing Events
153
// Printing Events
 Lines 189-194   static const char sPrintOptionsContractI Link Here 
189
#include "nsISelectionController.h"
188
#include "nsISelectionController.h"
190
189
191
#include "nsBidiUtils.h"
190
#include "nsBidiUtils.h"
191
#include "nsISHEntry.h"
192
192
193
//paint forcing
193
//paint forcing
194
#include "prenv.h"
194
#include "prenv.h"
 Lines 346-352   protected: Link Here 
346
  virtual ~DocumentViewerImpl();
346
  virtual ~DocumentViewerImpl();
347
347
348
private:
348
private:
349
  void ForceRefresh(void);
350
  nsresult MakeWindow(nsIWidget* aParentWidget,
349
  nsresult MakeWindow(nsIWidget* aParentWidget,
351
                      const nsRect& aBounds);
350
                      const nsRect& aBounds);
352
  nsresult InitInternal(nsIWidget* aParentWidget,
351
  nsresult InitInternal(nsIWidget* aParentWidget,
 Lines 398-427   protected: Link Here 
398
  nsCOMPtr<nsIDOMFocusListener> mFocusListener;
397
  nsCOMPtr<nsIDOMFocusListener> mFocusListener;
399
398
400
  nsCOMPtr<nsIContentViewer> mPreviousViewer;
399
  nsCOMPtr<nsIContentViewer> mPreviousViewer;
401
400
  nsCOMPtr<nsISHEntry> mSHEntry;
402
  PRPackedBool  mEnableRendering;
403
  PRPackedBool  mStopped;
404
  PRPackedBool  mLoaded;
405
  PRPackedBool  mDeferredWindowClose;
406
  PRInt16 mNumURLStarts;
407
  PRInt16 mDestroyRefCount;     // a second "refcount" for the document viewer's "destroy"
408
401
409
  nsIWidget* mParentWidget;          // purposely won't be ref counted
402
  nsIWidget* mParentWidget;          // purposely won't be ref counted
410
403
411
  PRPackedBool         mInPermitUnload;
404
  PRInt16 mNumURLStarts;
405
  PRInt16 mDestroyRefCount;    // a second "refcount" for the document viewer's "destroy"
406
407
  unsigned      mEnableRendering : 1;
408
  unsigned      mStopped : 1;
409
  unsigned      mLoaded : 1;
410
  unsigned      mDeferredWindowClose : 1;
411
  // document management data
412
  //   these items are specific to markup documents (html and xml)
413
  //   may consider splitting these out into a subclass
414
  unsigned      mIsSticky : 1;
415
  unsigned      mInPermitUnload : 1;
412
416
413
#ifdef NS_PRINTING
417
#ifdef NS_PRINTING
414
  PRPackedBool          mClosingWhilePrinting;
418
  unsigned      mClosingWhilePrinting : 1;
415
  nsPrintEngine*        mPrintEngine;
419
416
  nsCOMPtr<nsIDOMWindowInternal> mDialogParentWin;
417
#if NS_PRINT_PREVIEW
420
#if NS_PRINT_PREVIEW
418
  // These data member support delayed printing when the document is loading
421
  // These data members support delayed printing when the document is loading
422
  unsigned                         mPrintIsPending : 1;
423
  unsigned                         mPrintDocIsFullyLoaded : 1;
419
  nsCOMPtr<nsIPrintSettings>       mCachedPrintSettings;
424
  nsCOMPtr<nsIPrintSettings>       mCachedPrintSettings;
420
  nsCOMPtr<nsIWebProgressListener> mCachedPrintWebProgressListner;
425
  nsCOMPtr<nsIWebProgressListener> mCachedPrintWebProgressListner;
421
  PRPackedBool                     mPrintIsPending;
422
  PRPackedBool                     mPrintDocIsFullyLoaded;
423
#endif // NS_PRINT_PREVIEW
426
#endif // NS_PRINT_PREVIEW
424
427
428
  nsPrintEngine*        mPrintEngine;
429
  nsCOMPtr<nsIDOMWindowInternal> mDialogParentWin;
430
425
#ifdef NS_DEBUG
431
#ifdef NS_DEBUG
426
  FILE* mDebugFile;
432
  FILE* mDebugFile;
427
#endif // NS_DEBUG
433
#endif // NS_DEBUG
 Lines 434-443   protected: Link Here 
434
  nsCString mForceCharacterSet;
440
  nsCString mForceCharacterSet;
435
  nsCString mPrevDocCharacterSet;
441
  nsCString mPrevDocCharacterSet;
436
  
442
  
437
  // document management data
438
  //   these items are specific to markup documents (html and xml)
439
  //   may consider splitting these out into a subclass
440
  PRPackedBool mIsSticky;
441
443
442
};
444
};
443
445
 Lines 494-501   void DocumentViewerImpl::PrepareToStartL Link Here 
494
// Note: operator new zeros our memory, so no need to init things to null.
496
// Note: operator new zeros our memory, so no need to init things to null.
495
DocumentViewerImpl::DocumentViewerImpl(nsPresContext* aPresContext)
497
DocumentViewerImpl::DocumentViewerImpl(nsPresContext* aPresContext)
496
  : mPresContext(aPresContext),
498
  : mPresContext(aPresContext),
497
    mHintCharsetSource(kCharsetUninitialized),
499
    mIsSticky(PR_TRUE),
498
    mIsSticky(PR_TRUE)
500
    mHintCharsetSource(kCharsetUninitialized)
499
{
501
{
500
  PrepareToStartLoad();
502
  PrepareToStartLoad();
501
}
503
}
 Lines 795-813   DocumentViewerImpl::InitInternal(nsIWidg Link Here 
795
      makeCX = PR_TRUE;
797
      makeCX = PR_TRUE;
796
#endif
798
#endif
797
    }
799
    }
798
  }
799
800
800
  if (aDoCreation && mPresContext) {
801
    if (mPresContext) {
801
    // Create the ViewManager and Root View...
802
      // Create the ViewManager and Root View...
802
803
803
    // We must do this before we tell the script global object about
804
      // We must do this before we tell the script global object about
804
    // this new document since doing that will cause us to re-enter
805
      // this new document since doing that will cause us to re-enter
805
    // into nsSubDocumentFrame code through reflows caused by
806
      // into nsSubDocumentFrame code through reflows caused by
806
    // FlushPendingNotifications() calls down the road...
807
      // FlushPendingNotifications() calls down the road...
807
808
808
    rv = MakeWindow(aParentWidget, aBounds);
809
      rv = MakeWindow(aParentWidget, aBounds);
809
    NS_ENSURE_SUCCESS(rv, rv);
810
      NS_ENSURE_SUCCESS(rv, rv);
810
    Hide();
811
      Hide();
812
    }
811
  }
813
  }
812
814
813
  nsCOMPtr<nsIInterfaceRequestor> requestor(do_QueryInterface(mContainer));
815
  nsCOMPtr<nsIInterfaceRequestor> requestor(do_QueryInterface(mContainer));
 Lines 1171-1176   DocumentViewerImpl::Unload() Link Here 
1171
}
1173
}
1172
1174
1173
NS_IMETHODIMP
1175
NS_IMETHODIMP
1176
DocumentViewerImpl::Open()
1177
{
1178
  NS_ENSURE_TRUE(mPresShell, NS_ERROR_NOT_INITIALIZED);
1179
1180
  nsRect bounds;
1181
  mWindow->GetBounds(bounds);
1182
1183
  nsresult rv = InitInternal(mParentWidget, mDeviceContext, bounds,
1184
                             PR_FALSE, PR_FALSE);
1185
  NS_ENSURE_SUCCESS(rv, rv);
1186
1187
  SyncParentSubDocMap();
1188
1189
  // XXX re-enable image animations once that works correctly
1190
1191
  return NS_OK;
1192
}
1193
1194
NS_IMETHODIMP
1174
DocumentViewerImpl::Close()
1195
DocumentViewerImpl::Close()
1175
{
1196
{
1176
  // All callers are supposed to call close to break circular
1197
  // All callers are supposed to call close to break circular
 Lines 1184-1249   DocumentViewerImpl::Close() Link Here 
1184
  // for an object that can be switched in and out so that we don't need
1205
  // for an object that can be switched in and out so that we don't need
1185
  // to disable scripts during paint suppression.
1206
  // to disable scripts during paint suppression.
1186
1207
1187
  if (mDocument) {
1208
  if (!mDocument)
1209
    return NS_OK;
1210
1188
#if defined(NS_PRINTING) && defined(NS_PRINT_PREVIEW)
1211
#if defined(NS_PRINTING) && defined(NS_PRINT_PREVIEW)
1189
    // Turn scripting back on
1212
  // Turn scripting back on
1190
    // after PrintPreview had turned it off
1213
  // after PrintPreview had turned it off
1191
    if (GetIsPrintPreview() && mPrintEngine) {
1214
  if (GetIsPrintPreview() && mPrintEngine) {
1192
      mPrintEngine->TurnScriptingOn(PR_TRUE);
1215
    mPrintEngine->TurnScriptingOn(PR_TRUE);
1193
    }
1216
  }
1194
#endif
1217
#endif
1195
1218
1196
    // Break global object circular reference on the document created
1219
  // Break global object circular reference on the document created
1197
    // in the DocViewer Init
1220
  // in the DocViewer Init
1198
    nsIScriptGlobalObject* globalObject = mDocument->GetScriptGlobalObject();
1221
  nsIScriptGlobalObject* globalObject = mDocument->GetScriptGlobalObject();
1199
1222
1200
    if (globalObject) {
1223
  if (globalObject) {
1201
      globalObject->SetNewDocument(nsnull, PR_TRUE, PR_TRUE);
1224
    globalObject->SetNewDocument(nsnull, PR_TRUE, PR_TRUE);
1202
    }
1225
  }
1203
1226
1204
#ifdef NS_PRINTING
1227
#ifdef NS_PRINTING
1205
    // A Close was called while we were printing
1228
  // A Close was called while we were printing
1206
    // so don't clear the ScriptGlobalObject
1229
  // so don't clear the ScriptGlobalObject
1207
    // or clear the mDocument below
1230
  // or clear the mDocument below
1208
    // Also, do an extra addref to keep the viewer from going away.
1231
  // Also, do an extra addref to keep the viewer from going away.
1209
    if (mPrintEngine && !mClosingWhilePrinting) {
1232
  if (mPrintEngine && !mClosingWhilePrinting) {
1210
      mClosingWhilePrinting = PR_TRUE;
1233
    mClosingWhilePrinting = PR_TRUE;
1211
      NS_ADDREF_THIS();
1234
    NS_ADDREF_THIS();
1212
    } else {
1235
  } else {
1213
      // out of band cleanup of webshell
1236
    // out of band cleanup of webshell
1214
      mDocument->SetScriptGlobalObject(nsnull);
1215
    }
1216
#else
1217
    mDocument->SetScriptGlobalObject(nsnull);
1237
    mDocument->SetScriptGlobalObject(nsnull);
1238
  }
1239
#else
1240
  mDocument->SetScriptGlobalObject(nsnull);
1218
#endif
1241
#endif
1219
1242
1220
    if (mFocusListener) {
1243
  if (mFocusListener) {
1221
      // get the DOM event receiver
1244
    // get the DOM event receiver
1222
      nsCOMPtr<nsIDOMEventReceiver> erP(do_QueryInterface(mDocument));
1245
    nsCOMPtr<nsIDOMEventReceiver> erP(do_QueryInterface(mDocument));
1223
      NS_WARN_IF_FALSE(erP, "No event receiver in document!");
1246
    NS_WARN_IF_FALSE(erP, "No event receiver in document!");
1224
1247
1225
      if (erP) {
1248
    if (erP) {
1226
        erP->RemoveEventListenerByIID(mFocusListener,
1249
      erP->RemoveEventListenerByIID(mFocusListener,
1227
                                      NS_GET_IID(nsIDOMFocusListener));
1250
                                    NS_GET_IID(nsIDOMFocusListener));
1228
      }
1229
    }
1251
    }
1230
  }
1252
  }
1231
1253
1232
#ifdef NS_PRINTING
1233
  // Don't clear the document if we are printing.
1234
  if (!mClosingWhilePrinting) {
1235
    mDocument = nsnull;
1236
  }
1237
#else
1238
    mDocument = nsnull;
1239
#endif
1240
1241
  return NS_OK;
1254
  return NS_OK;
1242
}
1255
}
1243
1256
1244
NS_IMETHODIMP
1257
NS_IMETHODIMP
1245
DocumentViewerImpl::Destroy()
1258
DocumentViewerImpl::Destroy()
1246
{
1259
{
1260
  NS_ASSERTION(mDocument, "No document in Destroy()!");
1261
1247
#ifdef NS_PRINTING
1262
#ifdef NS_PRINTING
1248
  // Here is where we check to see if the docment was still being prepared 
1263
  // Here is where we check to see if the docment was still being prepared 
1249
  // for printing when it was asked to be destroy from someone externally
1264
  // for printing when it was asked to be destroy from someone externally
 Lines 1258-1270   DocumentViewerImpl::Destroy() Link Here 
1258
  }
1273
  }
1259
#endif
1274
#endif
1260
1275
1261
  // Don't let the document get unloaded while we are printing
1276
  // Don't let the document get unloaded while we are printing.
1262
  // this could happen if we hit the back button during printing
1277
  // this could happen if we hit the back button during printing.
1278
  // We also keep the viewer from being cached in session history, since
1279
  // we require all documents there to be sanitized.
1263
  if (mDestroyRefCount != 0) {
1280
  if (mDestroyRefCount != 0) {
1264
    --mDestroyRefCount;
1281
    --mDestroyRefCount;
1265
    return NS_OK;
1282
    return NS_OK;
1266
  }
1283
  }
1267
1284
1285
  // If we were told to put ourselves into session history instead of destroy
1286
  // the presentation, do that now.
1287
  if (mSHEntry) {
1288
    if (mPresShell)
1289
      mPresShell->StopPlugins();
1290
1291
    // Make sure the presentation isn't torn down by Hide().
1292
    mSHEntry->SetSticky(mIsSticky);
1293
    mIsSticky = PR_TRUE;
1294
1295
    mSHEntry->SetContentViewer(this);
1296
1297
    // Remove our root view from the view hierarchy.
1298
    if (mPresShell) {
1299
      nsIViewManager *vm = mPresShell->GetViewManager();
1300
      if (vm) {
1301
        nsIView *rootView = nsnull;
1302
        vm->GetRootView(rootView);
1303
1304
        if (rootView) {
1305
          nsIView *rootViewParent = rootView->GetParent();
1306
          if (rootViewParent) {
1307
            nsIViewManager *parentVM = rootViewParent->GetViewManager();
1308
            if (parentVM) {
1309
              parentVM->RemoveChild(rootView);
1310
            }
1311
          }
1312
        }
1313
      }
1314
1315
      mPresShell->InvalidateViewManagers();
1316
    }
1317
1318
    mSHEntry = nsnull;
1319
1320
    Hide();
1321
1322
    // This is after Hide() so that the user doesn't see the inputs clear.
1323
    if (mDocument)
1324
      mDocument->Sanitize();
1325
1326
    return NS_OK;
1327
  }
1328
1329
  mDocument = nsnull;
1330
1268
  // All callers are supposed to call destroy to break circular
1331
  // All callers are supposed to call destroy to break circular
1269
  // references.  If we do this stuff in the destructor, the
1332
  // references.  If we do this stuff in the destructor, the
1270
  // destructor might never be called (especially if we're being
1333
  // destructor might never be called (especially if we're being
 Lines 1323-1330   DocumentViewerImpl::Stop(void) Link Here 
1323
    mDocument->StopDocumentLoad();
1386
    mDocument->StopDocumentLoad();
1324
  }
1387
  }
1325
1388
1326
  if (mEnableRendering && (mLoaded || mStopped) && mPresContext)
1389
  if (mEnableRendering && (mLoaded || mStopped) && mPresContext) {
1327
    mPresContext->SetImageAnimationMode(imgIContainer::kDontAnimMode);
1390
    mPresContext->SetImageAnimationMode(imgIContainer::kDontAnimMode);
1391
  }
1328
1392
1329
  mStopped = PR_TRUE;
1393
  mStopped = PR_TRUE;
1330
1394
 Lines 1669-1675   DocumentViewerImpl::Hide(void) Link Here 
1669
    return NS_OK;
1733
    return NS_OK;
1670
  }
1734
  }
1671
1735
1672
  NS_ENSURE_TRUE(mDocument, NS_ERROR_NOT_AVAILABLE);
1673
  NS_PRECONDITION(mWindow, "null window");
1736
  NS_PRECONDITION(mWindow, "null window");
1674
  if (mWindow) {
1737
  if (mWindow) {
1675
    mWindow->Show(PR_FALSE);
1738
    mWindow->Show(PR_FALSE);
 Lines 1787-1792   DocumentViewerImpl::SetSticky(PRBool aSt Link Here 
1787
}
1850
}
1788
1851
1789
NS_IMETHODIMP
1852
NS_IMETHODIMP
1853
DocumentViewerImpl::SetHistoryEntry(nsISHEntry *aEntry)
1854
{
1855
  mSHEntry = aEntry;
1856
  return NS_OK;
1857
}
1858
1859
NS_IMETHODIMP
1790
DocumentViewerImpl::GetEnableRendering(PRBool* aResult)
1860
DocumentViewerImpl::GetEnableRendering(PRBool* aResult)
1791
{
1861
{
1792
  NS_ENSURE_TRUE(mDocument, NS_ERROR_NOT_AVAILABLE);
1862
  NS_ENSURE_TRUE(mDocument, NS_ERROR_NOT_AVAILABLE);
 Lines 1811-1823   DocumentViewerImpl::RequestWindowClose(P Link Here 
1811
  return NS_OK;
1881
  return NS_OK;
1812
}
1882
}
1813
1883
1814
1815
void
1816
DocumentViewerImpl::ForceRefresh()
1817
{
1818
  mWindow->Invalidate(PR_TRUE);
1819
}
1820
1821
NS_DEFINE_CID(kCSSLoaderCID, NS_CSS_LOADER_CID);
1884
NS_DEFINE_CID(kCSSLoaderCID, NS_CSS_LOADER_CID);
1822
1885
1823
PR_STATIC_CALLBACK(PRBool)
1886
PR_STATIC_CALLBACK(PRBool)
(-)layout/base/nsIDocumentViewer.h (-1 / +1 lines)
Line     Link Here 
 Lines 45-51   class nsIPresShell; Link Here 
45
class nsIStyleSheet;
45
class nsIStyleSheet;
46
46
47
#define NS_IDOCUMENT_VIEWER_IID \
47
#define NS_IDOCUMENT_VIEWER_IID \
48
 { 0xa6cf9057, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
48
 { 0x09ad1126, 0xb397, 0x11d9,{0xa5, 0x2c, 0x00, 0x11, 0x24, 0x78, 0xd6, 0x26}}
49
49
50
/**
50
/**
51
 * A document viewer is a kind of content viewer that uses NGLayout
51
 * A document viewer is a kind of content viewer that uses NGLayout
(-)layout/base/nsIPresShell.h (-2 / +18 lines)
Line     Link Here 
 Lines 89-96   class nsIStyleSheet; Link Here 
89
class nsCSSFrameConstructor;
89
class nsCSSFrameConstructor;
90
90
91
#define NS_IPRESSHELL_IID     \
91
#define NS_IPRESSHELL_IID     \
92
{ 0x3b864134, 0x4e25, 0x4cd0, \
92
{ 0x3861ee48, 0xb397, 0x11d9, \
93
  {0xa6, 0x9e, 0x34, 0x14, 0x13, 0x18, 0x39, 0x58} }
93
  {0x86, 0x9e, 0x00, 0x11, 0x24, 0x78, 0xd6, 0x26} }
94
94
95
// Constants uses for ScrollFrameIntoView() function
95
// Constants uses for ScrollFrameIntoView() function
96
#define NS_PRESSHELL_SCROLL_TOP      0
96
#define NS_PRESSHELL_SCROLL_TOP      0
 Lines 677-682   public: Link Here 
677
  virtual void ListStyleSheets(FILE *out, PRInt32 aIndent = 0) = 0;
677
  virtual void ListStyleSheets(FILE *out, PRInt32 aIndent = 0) = 0;
678
#endif
678
#endif
679
679
680
  /**
681
   * Start all plugins in this shell.
682
   */
683
  virtual void StartPlugins() = 0;
684
685
  /**
686
   * Stop all plugins in this shell.
687
   */
688
  virtual void StopPlugins() = 0;
689
690
  /**
691
   * Call InvalidateHierarchy() on our view manager and the view manager
692
   * of any child documents, recursively.
693
   */
694
  virtual void InvalidateViewManagers() = 0;
695
680
protected:
696
protected:
681
  // IMPORTANT: The ownership implicit in the following member variables
697
  // IMPORTANT: The ownership implicit in the following member variables
682
  // has been explicitly checked.  If you add any members to this class,
698
  // has been explicitly checked.  If you add any members to this class,
(-)layout/base/nsLayoutAtomList.h (+1 lines)
Line     Link Here 
 Lines 164-169   LAYOUT_ATOM(oncontextmenu, "oncontextmen Link Here 
164
LAYOUT_ATOM(onDOMActivate, "onDOMActivate")
164
LAYOUT_ATOM(onDOMActivate, "onDOMActivate")
165
LAYOUT_ATOM(onDOMFocusIn, "onDOMFocusIn")
165
LAYOUT_ATOM(onDOMFocusIn, "onDOMFocusIn")
166
LAYOUT_ATOM(onDOMFocusOut, "onDOMFocusOut")
166
LAYOUT_ATOM(onDOMFocusOut, "onDOMFocusOut")
167
LAYOUT_ATOM(onDOMPageRestore, "onDOMPageRestore")
167
LAYOUT_ATOM(ondblclick, "ondblclick")
168
LAYOUT_ATOM(ondblclick, "ondblclick")
168
LAYOUT_ATOM(ondragdrop, "ondragdrop")
169
LAYOUT_ATOM(ondragdrop, "ondragdrop")
169
LAYOUT_ATOM(ondragenter, "ondragenter")
170
LAYOUT_ATOM(ondragenter, "ondragenter")
(-)layout/base/nsPresShell.cpp (+129 lines)
Line     Link Here 
 Lines 151-156    Link Here 
151
#include "nsIDOMWindowInternal.h"
151
#include "nsIDOMWindowInternal.h"
152
#include "nsPIDOMWindow.h"
152
#include "nsPIDOMWindow.h"
153
#include "nsIFocusController.h"
153
#include "nsIFocusController.h"
154
#include "nsIPluginInstance.h"
155
#include "nsIObjectFrame.h"
156
#include "nsIPluginHost.h"
154
157
155
// Drag & Drop, Clipboard
158
// Drag & Drop, Clipboard
156
#include "nsWidgetsCID.h"
159
#include "nsWidgetsCID.h"
 Lines 1204-1209   public: Link Here 
1204
  NS_IMETHOD IsReflowLocked(PRBool* aIsLocked);  
1207
  NS_IMETHOD IsReflowLocked(PRBool* aIsLocked);  
1205
1208
1206
  virtual nsresult ReconstructFrames(void);
1209
  virtual nsresult ReconstructFrames(void);
1210
  virtual void StartPlugins();
1211
  virtual void StopPlugins();
1212
1213
  virtual void InvalidateViewManagers();
1207
1214
1208
#ifdef IBMBIDI
1215
#ifdef IBMBIDI
1209
  NS_IMETHOD SetCaretBidiLevel(PRUint8 aLevel);
1216
  NS_IMETHOD SetCaretBidiLevel(PRUint8 aLevel);
 Lines 1513-1518   private: Link Here 
1513
  void FireResizeEvent();
1520
  void FireResizeEvent();
1514
  static void sResizeEventCallback(nsITimer* aTimer, void* aPresShell) ;
1521
  static void sResizeEventCallback(nsITimer* aTimer, void* aPresShell) ;
1515
  nsCOMPtr<nsITimer> mResizeEventTimer;
1522
  nsCOMPtr<nsITimer> mResizeEventTimer;
1523
1524
  typedef void (*nsPluginEnumCallback)(PresShell*, nsIContent*);
1525
  void EnumeratePlugins(nsIDOMDocument *aDocument,
1526
                        const nsString &aPluginTag,
1527
                        nsPluginEnumCallback aCallback);
1516
};
1528
};
1517
1529
1518
#ifdef PR_LOGGING
1530
#ifdef PR_LOGGING
 Lines 6470-6475   PresShell::RemoveOverrideStyleSheet(nsIS Link Here 
6470
  return mStyleSet->RemoveStyleSheet(nsStyleSet::eOverrideSheet, aSheet);
6482
  return mStyleSet->RemoveStyleSheet(nsStyleSet::eOverrideSheet, aSheet);
6471
}
6483
}
6472
6484
6485
static void
6486
StartPluginInstance(PresShell *aShell, nsIContent *aContent)
6487
{
6488
  // For now we just reconstruct the frame.
6489
  aShell->RecreateFramesFor(aContent);
6490
}
6491
6492
void
6493
PresShell::StartPlugins()
6494
{
6495
  nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(mDocument);
6496
  if (domDoc) {
6497
    EnumeratePlugins(domDoc, NS_LITERAL_STRING("object"), StartPluginInstance);
6498
    EnumeratePlugins(domDoc, NS_LITERAL_STRING("applet"), StartPluginInstance);
6499
    EnumeratePlugins(domDoc, NS_LITERAL_STRING("embed"), StartPluginInstance);
6500
  }
6501
}
6502
6503
static void
6504
StopPluginInstance(PresShell *aShell, nsIContent *aContent)
6505
{
6506
  nsIFrame *frame = aShell->FrameManager()->GetPrimaryFrameFor(aContent);
6507
6508
  nsIObjectFrame *objectFrame = nsnull;
6509
  if (frame)
6510
    CallQueryInterface(frame, &objectFrame);
6511
  if (!objectFrame)
6512
    return;
6513
6514
  nsCOMPtr<nsIPluginInstance> instance;
6515
  objectFrame->GetPluginInstance(*getter_AddRefs(instance));
6516
  if (!instance)
6517
    return;
6518
6519
  // Check whether the plugin wants SetWindow to be called before or after
6520
  // Stop/Destroy.  This is similar to nsObjectFrame::Destroy(), but we
6521
  // don't want to destroy the frame just yet.
6522
6523
  PRBool callSetWindowLast = PR_FALSE;
6524
  instance->GetValue(nsPluginInstanceVariable_CallSetWindowAfterDestroyBool,
6525
                     (void *) &callSetWindowLast);
6526
  if (callSetWindowLast) {
6527
    instance->Stop();
6528
    instance->Destroy();
6529
    instance->SetWindow(nsnull);
6530
  } else {
6531
    instance->SetWindow(nsnull);
6532
    instance->Stop();
6533
    instance->Destroy();
6534
  }
6535
6536
  nsCOMPtr<nsIPluginHost> pluginHost =
6537
    do_GetService("@mozilla.org/plugin/host;1");
6538
  if (pluginHost)
6539
    pluginHost->StopPluginInstance(instance);
6540
}
6541
6542
void
6543
PresShell::StopPlugins()
6544
{
6545
  nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(mDocument);
6546
  if (domDoc) {
6547
    EnumeratePlugins(domDoc, NS_LITERAL_STRING("object"), StopPluginInstance);
6548
    EnumeratePlugins(domDoc, NS_LITERAL_STRING("applet"), StopPluginInstance);
6549
    EnumeratePlugins(domDoc, NS_LITERAL_STRING("embed"), StopPluginInstance);
6550
  }
6551
}
6552
6553
static PRBool
6554
InvalidateVMCallback(nsIDocument *aDocument, void *aData)
6555
{
6556
  NS_ASSERTION(aDocument, "null document passed to callback");
6557
6558
  nsIPresShell *shell = aDocument->GetShellAt(0);
6559
  if (shell)
6560
    shell->InvalidateViewManagers();
6561
6562
  return PR_TRUE;
6563
}
6564
6565
void
6566
PresShell::InvalidateViewManagers()
6567
{
6568
  if (mViewManager)
6569
    mViewManager->InvalidateHierarchy();
6570
6571
  // Get the list of child documents.
6572
  if (mDocument)
6573
    mDocument->EnumerateSubDocuments(InvalidateVMCallback, nsnull);
6574
}
6575
6473
//--------------------------------------------------------
6576
//--------------------------------------------------------
6474
// Start of protected and private methods on the PresShell
6577
// Start of protected and private methods on the PresShell
6475
//--------------------------------------------------------
6578
//--------------------------------------------------------
 Lines 7038-7043   PresShell::Observe(nsISupports* aSubject Link Here 
7038
  return NS_ERROR_FAILURE;
7141
  return NS_ERROR_FAILURE;
7039
}
7142
}
7040
7143
7144
void
7145
PresShell::EnumeratePlugins(nsIDOMDocument *aDocument,
7146
                            const nsString &aPluginTag,
7147
                            nsPluginEnumCallback aCallback)
7148
{
7149
  nsCOMPtr<nsIDOMNodeList> nodes;
7150
  aDocument->GetElementsByTagName(aPluginTag, getter_AddRefs(nodes));
7151
  if (!nodes)
7152
    return;
7153
7154
  PRUint32 length;
7155
  nodes->GetLength(&length);
7156
7157
  nsCOMPtr<nsIDOMNode> node;
7158
  nsCOMPtr<nsIContent> content;
7159
7160
  //  nsFrameManager *fm = FrameManager();
7161
7162
  for (PRUint32 i = 0; i < length; ++i) {
7163
    nodes->Item(i, getter_AddRefs(node));
7164
    content = do_QueryInterface(node);
7165
    if (content)
7166
      aCallback(this, content);
7167
  }
7168
}
7169
7041
//------------------------------------------------------
7170
//------------------------------------------------------
7042
// End of protected and private methods on the PresShell
7171
// End of protected and private methods on the PresShell
7043
//------------------------------------------------------
7172
//------------------------------------------------------
(-)layout/printing/nsPrintEngine.cpp (-4 / +5 lines)
Line     Link Here 
 Lines 4438-4447   nsPrintEngine::TurnScriptingOn(PRBool aD Link Here 
4438
4438
4439
  // get the script global object
4439
  // get the script global object
4440
  nsIScriptGlobalObject *scriptGlobalObj = mDocument->GetScriptGlobalObject();
4440
  nsIScriptGlobalObject *scriptGlobalObj = mDocument->GetScriptGlobalObject();
4441
  NS_ASSERTION(scriptGlobalObj, "Can't get nsIScriptGlobalObject");
4441
  if (scriptGlobalObj) {
4442
  nsIScriptContext *scx = scriptGlobalObj->GetContext();
4442
    nsIScriptContext *scx = scriptGlobalObj->GetContext();
4443
  NS_ASSERTION(scx, "Can't get nsIScriptContext");
4443
    NS_ASSERTION(scx, "Can't get nsIScriptContext");
4444
  scx->SetScriptsEnabled(aDoTurnOn, PR_TRUE);
4444
    scx->SetScriptsEnabled(aDoTurnOn, PR_TRUE);
4445
  }
4445
}
4446
}
4446
4447
4447
//-----------------------------------------------------------------
4448
//-----------------------------------------------------------------
(-)layout/xul/base/src/nsMenuPopupFrame.cpp (+3 lines)
Line     Link Here 
 Lines 941-946   nsMenuPopupFrame::SyncViewWithFrame(nsPr Link Here 
941
  // the left or top sides of the screen may be in negative space (main monitor is on the
941
  // the left or top sides of the screen may be in negative space (main monitor is on the
942
  // right, etc). We need to be sure to do the right thing.
942
  // right, etc). We need to be sure to do the right thing.
943
  nsCOMPtr<nsIDOMWindowInternal> window(do_QueryInterface(document->GetScriptGlobalObject()));
943
  nsCOMPtr<nsIDOMWindowInternal> window(do_QueryInterface(document->GetScriptGlobalObject()));
944
  if (!window)
945
    return NS_OK;
946
944
  nsCOMPtr<nsIDOMScreen> screen;
947
  nsCOMPtr<nsIDOMScreen> screen;
945
  window->GetScreen(getter_AddRefs(screen));
948
  window->GetScreen(getter_AddRefs(screen));
946
  PRInt32 screenWidth = 0, screenHeight = 0;
949
  PRInt32 screenWidth = 0, screenHeight = 0;
(-)layout/xul/base/src/nsTitleBarFrame.cpp (-9 / +4 lines)
Line     Link Here 
 Lines 169-183   nsTitleBarFrame::HandleEvent(nsPresConte Link Here 
169
			   nsCOMPtr<nsIDOMWindowInternal>
169
			   nsCOMPtr<nsIDOMWindowInternal>
170
           window(do_QueryInterface(aPresContext->PresShell()->GetDocument()->GetScriptGlobalObject()));
170
           window(do_QueryInterface(aPresContext->PresShell()->GetDocument()->GetScriptGlobalObject()));
171
171
172
172
         if (window) {
173
173
           nsPoint nsMoveBy = aEvent->refPoint - mLastPoint;
174
				 nsPoint nsMoveBy;
174
           window->MoveBy(nsMoveBy.x,nsMoveBy.y);
175
				 nsMoveBy = aEvent->refPoint - mLastPoint;
175
         }
176
				 
177
				 
178
				 window->MoveBy(nsMoveBy.x,nsMoveBy.y);
179
				 
180
				 
181
				 
176
				 
182
				 *aEventStatus = nsEventStatus_eConsumeNoDefault;				
177
				 *aEventStatus = nsEventStatus_eConsumeNoDefault;				
183
				 
178
				 
(-)netwerk/base/public/nsISecureBrowserUI.idl (-2 / +18 lines)
Line     Link Here 
 Lines 41-55    Link Here 
41
#include "nsISupports.idl"
41
#include "nsISupports.idl"
42
42
43
interface nsIDOMWindow;
43
interface nsIDOMWindow;
44
interface nsIDOMElement;
44
interface nsIWebProgress;
45
interface nsIURI;
45
46
46
[scriptable, uuid(081e31e0-a144-11d3-8c7c-00609792278c)]
47
[uuid(625481c5-b2dc-11d9-bc8f-00112478d626)]
48
interface nsISecureBrowserUIState : nsISupports
49
{
50
};
51
52
[scriptable, uuid(c5ca429c-b5c2-11d9-8547-00112478d626)]
47
interface nsISecureBrowserUI : nsISupports
53
interface nsISecureBrowserUI : nsISupports
48
{
54
{
49
    void init(in nsIDOMWindow window);
55
    void init(in nsIDOMWindow window);
50
56
51
    readonly attribute unsigned long state;
57
    readonly attribute unsigned long state;
52
    readonly attribute AString tooltipText;
58
    readonly attribute AString tooltipText;
59
60
    /* Returns an object that encapsulates the current security state. */
61
    nsISecureBrowserUIState captureState();
62
63
    /**
64
     * Restore the state captured by captureState(), firing transition
65
     * notifications as necessary.
66
     */
67
    void transitionToState(in nsISecureBrowserUIState state);
68
                           
53
};
69
};
54
70
55
%{C++
71
%{C++
(-)security/manager/boot/src/nsSecureBrowserUIImpl.cpp (-11 / +71 lines)
Line     Link Here 
 Lines 206-217   nsSecureBrowserUIImpl::Init(nsIDOMWindow Link Here 
206
    rv = svc->AddObserver(this, NS_FORMSUBMIT_SUBJECT, PR_TRUE);
206
    rv = svc->AddObserver(this, NS_FORMSUBMIT_SUBJECT, PR_TRUE);
207
  }
207
  }
208
  
208
  
209
  /* GetWebProgress(mWindow) */
210
  // hook up to the webprogress notifications.
211
  nsCOMPtr<nsIScriptGlobalObject> sgo(do_QueryInterface(mWindow));
209
  nsCOMPtr<nsIScriptGlobalObject> sgo(do_QueryInterface(mWindow));
212
  if (!sgo) return NS_ERROR_FAILURE;
210
  if (!sgo) return NS_ERROR_FAILURE;
213
  
211
214
  nsCOMPtr<nsIWebProgress> wp(do_GetInterface(sgo->GetDocShell()));
212
  nsIDocShell *docShell = sgo->GetDocShell();
213
214
  // The Docshell will own the SecureBrowserUI object
215
  if (!docShell)
216
    return NS_ERROR_FAILURE;
217
218
  docShell->SetSecurityUI(this);
219
220
  /* GetWebProgress(mWindow) */
221
  // hook up to the webprogress notifications.
222
  nsCOMPtr<nsIWebProgress> wp(do_GetInterface(docShell));
215
  if (!wp) return NS_ERROR_FAILURE;
223
  if (!wp) return NS_ERROR_FAILURE;
216
  /* end GetWebProgress */
224
  /* end GetWebProgress */
217
  
225
  
 Lines 982-993   nsresult nsSecureBrowserUIImpl::UpdateSe Link Here 
982
    newSecurityState = lis_no_security;
990
    newSecurityState = lis_no_security;
983
  }
991
  }
984
992
993
  return UpdateSecurityState(newSecurityState, aRequest);
994
}
995
996
nsresult
997
nsSecureBrowserUIImpl::UpdateSecurityState(lockIconState aNewState,
998
                                           nsIRequest *aRequest)
999
{
985
  PR_LOG(gSecureDocLog, PR_LOG_DEBUG,
1000
  PR_LOG(gSecureDocLog, PR_LOG_DEBUG,
986
         ("SecureUI:%p: UpdateSecurityState:  old-new  %d - %d\n", this,
1001
         ("SecureUI:%p: UpdateSecurityState:  old-new  %d - %d\n", this,
987
         mPreviousSecurityState, newSecurityState
1002
         mPreviousSecurityState, aNewState
988
          ));
1003
          ));
989
1004
990
  if (mPreviousSecurityState != newSecurityState)
1005
  if (mPreviousSecurityState != aNewState)
991
  {
1006
  {
992
    // must show alert
1007
    // must show alert
993
    
1008
    
 Lines 1032-1038   nsresult nsSecureBrowserUIImpl::UpdateSe Link Here 
1032
    {
1047
    {
1033
      case lis_no_security:
1048
      case lis_no_security:
1034
      case lis_broken_security:
1049
      case lis_broken_security:
1035
        switch (newSecurityState)
1050
        switch (aNewState)
1036
        {
1051
        {
1037
          case lis_no_security:
1052
          case lis_no_security:
1038
          case lis_broken_security:
1053
          case lis_broken_security:
 Lines 1049-1055   nsresult nsSecureBrowserUIImpl::UpdateSe Link Here 
1049
    
1064
    
1050
    if (showWarning)
1065
    if (showWarning)
1051
    {
1066
    {
1052
      switch (newSecurityState)
1067
      switch (aNewState)
1053
      {
1068
      {
1054
        case lis_no_security:
1069
        case lis_no_security:
1055
        case lis_broken_security:
1070
        case lis_broken_security:
 Lines 1070-1078   nsresult nsSecureBrowserUIImpl::UpdateSe Link Here 
1070
      }
1085
      }
1071
    }
1086
    }
1072
1087
1073
    mPreviousSecurityState = newSecurityState;
1088
    mPreviousSecurityState = aNewState;
1074
1089
1075
    if (lis_no_security == newSecurityState)
1090
    if (lis_no_security == aNewState)
1076
    {
1091
    {
1077
      mSSLStatus = nsnull;
1092
      mSSLStatus = nsnull;
1078
      mInfoTooltip.Truncate();
1093
      mInfoTooltip.Truncate();
 Lines 1083-1089   nsresult nsSecureBrowserUIImpl::UpdateSe Link Here 
1083
  {
1098
  {
1084
    PRUint32 newState = STATE_IS_INSECURE;
1099
    PRUint32 newState = STATE_IS_INSECURE;
1085
1100
1086
    switch (newSecurityState)
1101
    switch (aNewState)
1087
    {
1102
    {
1088
      case lis_broken_security:
1103
      case lis_broken_security:
1089
        newState = STATE_IS_BROKEN;
1104
        newState = STATE_IS_BROKEN;
 Lines 1483-1485   ConfirmPostToInsecureFromSecure() Link Here 
1483
1498
1484
  return result;
1499
  return result;
1485
}
1500
}
1501
1502
class nsSecureBrowserUIImpl::State : public nsISecureBrowserUIState
1503
{
1504
public:
1505
  State(lockIconState aState, nsISupports *aSSLStatus);
1506
1507
  lockIconState GetState() const { return mState; }
1508
  nsISupports* GetSSLStatus() { return mSSLStatus; }
1509
1510
  NS_DECL_ISUPPORTS
1511
  NS_DECL_NSISECUREBROWSERUISTATE
1512
1513
private:
1514
  lockIconState mState;
1515
  nsCOMPtr<nsISupports> mSSLStatus;
1516
};
1517
1518
NS_IMPL_ISUPPORTS1(nsSecureBrowserUIImpl::State, nsISecureBrowserUIState)
1519
1520
nsSecureBrowserUIImpl::State::State(lockIconState aState,
1521
                                    nsISupports *aSSLStatus)
1522
  : mState(aState), mSSLStatus(aSSLStatus)
1523
{
1524
}
1525
1526
NS_IMETHODIMP
1527
nsSecureBrowserUIImpl::CaptureState(nsISecureBrowserUIState **aState)
1528
{
1529
  *aState = new State(mPreviousSecurityState, mSSLStatus);
1530
  NS_ENSURE_TRUE(aState, NS_ERROR_OUT_OF_MEMORY);
1531
1532
  NS_ADDREF(*aState);
1533
  return NS_OK;
1534
}
1535
1536
NS_IMETHODIMP
1537
nsSecureBrowserUIImpl::TransitionToState(nsISecureBrowserUIState *aState)
1538
{
1539
  NS_ENSURE_TRUE(aState, NS_ERROR_NULL_POINTER);
1540
1541
  State *state = NS_STATIC_CAST(State*, aState);
1542
1543
  mSSLStatus = state->GetSSLStatus();
1544
  return UpdateSecurityState(state->GetState(), nsnull);
1545
}
(-)security/manager/boot/src/nsSecureBrowserUIImpl.h (+5 lines)
Line     Link Here 
 Lines 121-126   protected: Link Here 
121
  PRInt32 mSubRequestsNoSecurity;
121
  PRInt32 mSubRequestsNoSecurity;
122
122
123
  nsresult UpdateSecurityState(nsIRequest* aRequest);
123
  nsresult UpdateSecurityState(nsIRequest* aRequest);
124
  nsresult UpdateSecurityState(lockIconState aNewState, nsIRequest *aRequest);
124
  nsresult EvaluateAndUpdateSecurityState(nsIRequest *aRequest);
125
  nsresult EvaluateAndUpdateSecurityState(nsIRequest *aRequest);
125
  void UpdateSubrequestMembers(nsIRequest *aRequest);
126
  void UpdateSubrequestMembers(nsIRequest *aRequest);
126
127
 Lines 143-148   protected: Link Here 
143
  // Support functions
144
  // Support functions
144
  nsresult GetNSSDialogs(nsISecurityWarningDialogs **);
145
  nsresult GetNSSDialogs(nsISecurityWarningDialogs **);
145
146
147
  class State;
148
  nsresult HandleStateChange(PRBool aIsToplevel, nsIURI *aURI,
149
                             PRUint32 aLoadFlags, PRUint32 aProgressStateFlgs);
150
146
  PLDHashTable mTransferringRequests;
151
  PLDHashTable mTransferringRequests;
147
};
152
};
148
153
(-)toolkit/components/passwordmgr/base/nsPasswordManager.cpp (-5 / +76 lines)
Line     Link Here 
 Lines 71-76    Link Here 
71
#include "nsIAutoCompleteResult.h"
71
#include "nsIAutoCompleteResult.h"
72
#include "nsIPK11TokenDB.h"
72
#include "nsIPK11TokenDB.h"
73
#include "nsIPK11Token.h"
73
#include "nsIPK11Token.h"
74
#include "nsIScriptGlobalObject.h"
75
#include "nsIWindowWatcher.h"
74
76
75
static const char kPMPropertiesURL[] = "chrome://passwordmgr/locale/passwordmgr.properties";
77
static const char kPMPropertiesURL[] = "chrome://passwordmgr/locale/passwordmgr.properties";
76
static PRBool sRememberPasswords = PR_FALSE;
78
static PRBool sRememberPasswords = PR_FALSE;
 Lines 263-268   nsPasswordManager::Init() Link Here 
263
265
264
  progress->AddProgressListener(this, nsIWebProgress::NOTIFY_STATE_DOCUMENT);
266
  progress->AddProgressListener(this, nsIWebProgress::NOTIFY_STATE_DOCUMENT);
265
267
268
  // Listen for "domwindowopened", this will let us attach our DOMPageRestore
269
  // event listener.
270
271
  obsService->AddObserver(this, "domwindowopened", PR_FALSE);
272
  obsService->AddObserver(this, "domwindowclosed", PR_FALSE);
273
274
  // Also register on any open windows that already exist, since we don't
275
  // get notifications for those.
276
277
  nsCOMPtr<nsIWindowWatcher> watcher =
278
    do_GetService(NS_WINDOWWATCHER_CONTRACTID);
279
  if (watcher) {
280
    nsCOMPtr<nsISimpleEnumerator> enumerator;
281
    watcher->GetWindowEnumerator(getter_AddRefs(enumerator));
282
    if (enumerator) {
283
      PRBool hasMore;
284
      nsCOMPtr<nsISupports> item;
285
      nsCOMPtr<nsIDOMEventTarget> targ;
286
287
      while (NS_SUCCEEDED(enumerator->HasMoreElements(&hasMore)) && hasMore) {
288
        enumerator->GetNext(getter_AddRefs(item));
289
        targ = do_QueryInterface(item);
290
        if (targ) {
291
          targ->AddEventListener(NS_LITERAL_STRING("DOMPageRestore"),
292
                                 NS_STATIC_CAST(nsIDOMLoadListener*, this),
293
                                 PR_FALSE);
294
        }
295
      }
296
    }
297
  }
298
266
  // Now read in the signon file
299
  // Now read in the signon file
267
  nsXPIDLCString signonFile;
300
  nsXPIDLCString signonFile;
268
  mPrefBranch->GetCharPref("SignonFileName", getter_Copies(signonFile));
301
  mPrefBranch->GetCharPref("SignonFileName", getter_Copies(signonFile));
 Lines 747-752   nsPasswordManager::Observe(nsISupports* Link Here 
747
    NS_ASSERTION(branch == mPrefBranch, "unexpected pref change notification");
780
    NS_ASSERTION(branch == mPrefBranch, "unexpected pref change notification");
748
781
749
    branch->GetBoolPref("rememberSignons", &sRememberPasswords);
782
    branch->GetBoolPref("rememberSignons", &sRememberPasswords);
783
  } else if (!strcmp(aTopic, "domwindowopened")) {
784
    nsCOMPtr<nsIDOMEventTarget> targ = do_QueryInterface(aSubject);
785
    if (targ) {
786
      targ->AddEventListener(NS_LITERAL_STRING("DOMPageRestore"),
787
                             NS_STATIC_CAST(nsIDOMLoadListener*, this),
788
                             PR_FALSE);
789
    }
790
  } else if (!strcmp(aTopic, "domwindowclosed")) {
791
    nsCOMPtr<nsIDOMEventTarget> targ = do_QueryInterface(aSubject);
792
    if (targ) {
793
      targ->RemoveEventListener(NS_LITERAL_STRING("DOMPageRestore"),
794
                                NS_STATIC_CAST(nsIDOMLoadListener*, this),
795
                                PR_FALSE);
796
    }
750
  }
797
  }
751
798
752
  return NS_OK;
799
  return NS_OK;
 Lines 765-780   nsPasswordManager::OnStateChange(nsIWebP Link Here 
765
      !(aStateFlags & nsIWebProgressListener::STATE_STOP))
812
      !(aStateFlags & nsIWebProgressListener::STATE_STOP))
766
    return NS_OK;
813
    return NS_OK;
767
814
768
  // Don't do anything if the global signon pref is disabled
769
  if (!SingleSignonEnabled())
770
    return NS_OK;
771
772
  nsCOMPtr<nsIDOMWindow> domWin;
815
  nsCOMPtr<nsIDOMWindow> domWin;
773
  nsresult rv = aWebProgress->GetDOMWindow(getter_AddRefs(domWin));
816
  nsresult rv = aWebProgress->GetDOMWindow(getter_AddRefs(domWin));
774
  NS_ENSURE_SUCCESS(rv, rv);
817
  NS_ENSURE_SUCCESS(rv, rv);
775
818
819
  return DoPrefill(domWin);
820
}
821
822
nsresult
823
nsPasswordManager::DoPrefill(nsIDOMWindow *aDOMWindow)
824
{
825
  // Don't do anything if the global signon pref is disabled
826
  if (!SingleSignonEnabled())
827
    return NS_OK;
828
776
  nsCOMPtr<nsIDOMDocument> domDoc;
829
  nsCOMPtr<nsIDOMDocument> domDoc;
777
  domWin->GetDocument(getter_AddRefs(domDoc));
830
  aDOMWindow->GetDocument(getter_AddRefs(domDoc));
778
  NS_ASSERTION(domDoc, "DOM window should always have a document!");
831
  NS_ASSERTION(domDoc, "DOM window should always have a document!");
779
832
780
  // For now, only prefill forms in HTML documents.
833
  // For now, only prefill forms in HTML documents.
 Lines 1568-1573   nsPasswordManager::Error(nsIDOMEvent* aE Link Here 
1568
  return NS_OK;
1621
  return NS_OK;
1569
}
1622
}
1570
1623
1624
NS_IMETHODIMP
1625
nsPasswordManager::PageRestore(nsIDOMEvent* aEvent)
1626
{
1627
  nsCOMPtr<nsIDOMEventTarget> target;
1628
  aEvent->GetTarget(getter_AddRefs(target));
1629
1630
  nsCOMPtr<nsIDocument> doc = do_QueryInterface(target);
1631
  if (doc) {
1632
    nsCOMPtr<nsIDOMWindow> win =
1633
      do_QueryInterface(doc->GetScriptGlobalObject());
1634
    if (win) {
1635
      return DoPrefill(win);
1636
    }
1637
  }
1638
1639
  return NS_OK;
1640
}
1641
1571
1642
1572
// internal methods
1643
// internal methods
1573
1644
(-)toolkit/components/passwordmgr/base/nsPasswordManager.h (+2 lines)
Line     Link Here 
 Lines 136-141   public: Link Here 
136
  NS_IMETHOD BeforeUnload(nsIDOMEvent* aEvent);
136
  NS_IMETHOD BeforeUnload(nsIDOMEvent* aEvent);
137
  NS_IMETHOD Abort(nsIDOMEvent* aEvent);
137
  NS_IMETHOD Abort(nsIDOMEvent* aEvent);
138
  NS_IMETHOD Error(nsIDOMEvent* aEvent);
138
  NS_IMETHOD Error(nsIDOMEvent* aEvent);
139
  NS_IMETHOD PageRestore(nsIDOMEvent* aEvent);
139
140
140
  // Autocomplete
141
  // Autocomplete
141
  PRBool AutoCompleteSearch(const nsAString& aSearchString,
142
  PRBool AutoCompleteSearch(const nsAString& aSearchString,
 Lines 157-162   protected: Link Here 
157
  nsresult FillPassword(nsIDOMEvent* aEvent);
158
  nsresult FillPassword(nsIDOMEvent* aEvent);
158
  void AttachToInput(nsIDOMHTMLInputElement* aElement);
159
  void AttachToInput(nsIDOMHTMLInputElement* aElement);
159
  PRBool GetPasswordRealm(nsIURI* aURI, nsACString& aRealm);
160
  PRBool GetPasswordRealm(nsIURI* aURI, nsACString& aRealm);
161
  nsresult DoPrefill(nsIDOMWindow *aDOMWindw);
160
162
161
  static PLDHashOperator PR_CALLBACK FindEntryEnumerator(const nsACString& aKey,
163
  static PLDHashOperator PR_CALLBACK FindEntryEnumerator(const nsACString& aKey,
162
                                                         SignonHashEntry* aEntry,
164
                                                         SignonHashEntry* aEntry,
(-)toolkit/components/satchel/src/nsFormFillController.cpp (+6 lines)
Line     Link Here 
 Lines 870-875   nsFormFillController::Error(nsIDOMEvent Link Here 
870
  return NS_OK;
870
  return NS_OK;
871
}
871
}
872
872
873
NS_IMETHODIMP
874
nsFormFillController::PageRestore(nsIDOMEvent *aLoadEvent)
875
{
876
  return NS_OK;
877
}
878
873
////////////////////////////////////////////////////////////////////////
879
////////////////////////////////////////////////////////////////////////
874
//// nsFormFillController
880
//// nsFormFillController
875
881
(-)toolkit/components/satchel/src/nsFormFillController.h (+1 lines)
Line     Link Here 
 Lines 112-117   public: Link Here 
112
  NS_IMETHOD Unload(nsIDOMEvent *aLoadEvent);
112
  NS_IMETHOD Unload(nsIDOMEvent *aLoadEvent);
113
  NS_IMETHOD Abort(nsIDOMEvent *aLoadEvent);
113
  NS_IMETHOD Abort(nsIDOMEvent *aLoadEvent);
114
  NS_IMETHOD Error(nsIDOMEvent *aLoadEvent);
114
  NS_IMETHOD Error(nsIDOMEvent *aLoadEvent);
115
  NS_IMETHOD PageRestore(nsIDOMEvent* aLoadEvent);
115
116
116
  nsFormFillController();
117
  nsFormFillController();
117
  virtual ~nsFormFillController();
118
  virtual ~nsFormFillController();
(-)toolkit/content/widgets/browser.xml (-5 / +5 lines)
Line     Link Here 
 Lines 484-492    Link Here 
484
        null
484
        null
485
      </field>
485
      </field>
486
486
487
      <field name="securityUI">
487
      <property name="securityUI"
488
        null
488
                onget="return this.docShell.securityUI;"
489
      </field>
489
                onset="this.docShell.securityUI = val;"/>
490
490
491
      <field name="userTypedClear">
491
      <field name="userTypedClear">
492
        true
492
        true
 Lines 544-551    Link Here 
544
            const SECUREBROWSERUI_CONTRACTID = "@mozilla.org/secure_browser_ui;1";
544
            const SECUREBROWSERUI_CONTRACTID = "@mozilla.org/secure_browser_ui;1";
545
            if (!this.hasAttribute("disablesecurity") &&
545
            if (!this.hasAttribute("disablesecurity") &&
546
                SECUREBROWSERUI_CONTRACTID in Components.classes) {
546
                SECUREBROWSERUI_CONTRACTID in Components.classes) {
547
              this.securityUI = Components.classes[SECUREBROWSERUI_CONTRACTID].createInstance(Components.interfaces.nsISecureBrowserUI);
547
              var securityUI = Components.classes[SECUREBROWSERUI_CONTRACTID].createInstance(Components.interfaces.nsISecureBrowserUI);
548
              this.securityUI.init(this.contentWindow);
548
	      securityUI.init(this.contentWindow);
549
            }
549
            }
550
          }
550
          }
551
          catch (e) {
551
          catch (e) {
(-)view/public/nsIViewManager.h (-2 / +8 lines)
Line     Link Here 
 Lines 62-69   enum nsRectVisibility { Link Here 
62
62
63
63
64
#define NS_IVIEWMANAGER_IID   \
64
#define NS_IVIEWMANAGER_IID   \
65
{ 0xd9af8f22, 0xc64d, 0x4036, \
65
{ 0x5a381922, 0xb397, 0x11d9, \
66
  { 0x9e, 0x8b, 0x69, 0x5a, 0x63, 0x69, 0x3f, 0xd3 } }
66
  { 0x8f, 0x7c, 0x00, 0x11, 0x24, 0x78, 0xd6, 0x26 } }
67
67
68
class nsIViewManager : public nsISupports
68
class nsIViewManager : public nsISupports
69
{
69
{
 Lines 566-571   public: Link Here 
566
   * (aFromScroll is false) or scrolled (aFromScroll is true).
566
   * (aFromScroll is false) or scrolled (aFromScroll is true).
567
   */
567
   */
568
  NS_IMETHOD SynthesizeMouseMove(PRBool aFromScroll)=0;
568
  NS_IMETHOD SynthesizeMouseMove(PRBool aFromScroll)=0;
569
570
  /**
571
   * Force any cached information about the view hierarchy (such as the root
572
   * view manager) to be recomputed.  Note that this is non-recursive.
573
   */
574
  NS_IMETHOD InvalidateHierarchy()=0;
569
};
575
};
570
576
571
// Paint timing mode flags
577
// Paint timing mode flags
(-)view/src/nsViewManager.cpp (+19 lines)
Line     Link Here 
 Lines 4439-4441   nsViewManager::ProcessSynthMouseMoveEven Link Here 
4439
  if (!aFromScroll)
4439
  if (!aFromScroll)
4440
    mSynthMouseMoveEventQueue = nsnull;
4440
    mSynthMouseMoveEventQueue = nsnull;
4441
}
4441
}
4442
4443
NS_IMETHODIMP
4444
nsViewManager::InvalidateHierarchy()
4445
{
4446
  if (mRootView) {
4447
    if (mRootViewManager != this) {
4448
      NS_IF_RELEASE(mRootViewManager);
4449
    }
4450
    nsView *parent = mRootView->GetParent();
4451
    if (parent) {
4452
      mRootViewManager = parent->GetViewManager()->RootViewManager();
4453
      NS_ADDREF(mRootViewManager);
4454
    } else {
4455
      mRootViewManager = this;
4456
    }
4457
  }
4458
4459
  return NS_OK;
4460
}
(-)view/src/nsViewManager.h (+2 lines)
Line     Link Here 
 Lines 269-274   public: Link Here 
269
  NS_IMETHOD SynthesizeMouseMove(PRBool aFromScroll);
269
  NS_IMETHOD SynthesizeMouseMove(PRBool aFromScroll);
270
  void ProcessSynthMouseMoveEvent(PRBool aFromScroll);
270
  void ProcessSynthMouseMoveEvent(PRBool aFromScroll);
271
271
272
  NS_IMETHOD InvalidateHierarchy();
273
272
protected:
274
protected:
273
  virtual ~nsViewManager();
275
  virtual ~nsViewManager();
274
276
(-)widget/public/nsGUIEvent.h (+1 lines)
Line     Link Here 
 Lines 234-239   class nsIURI; Link Here 
234
#define NS_IMAGE_ERROR                  (NS_STREAM_EVENT_START + 4)
234
#define NS_IMAGE_ERROR                  (NS_STREAM_EVENT_START + 4)
235
#define NS_SCRIPT_LOAD                  (NS_STREAM_EVENT_START + 5)
235
#define NS_SCRIPT_LOAD                  (NS_STREAM_EVENT_START + 5)
236
#define NS_BEFORE_PAGE_UNLOAD           (NS_STREAM_EVENT_START + 6)
236
#define NS_BEFORE_PAGE_UNLOAD           (NS_STREAM_EVENT_START + 6)
237
#define NS_PAGE_RESTORE                 (NS_STREAM_EVENT_START + 7)
237
 
238
 
238
#define NS_FORM_EVENT_START             1200
239
#define NS_FORM_EVENT_START             1200
239
#define NS_FORM_SUBMIT                  (NS_FORM_EVENT_START)
240
#define NS_FORM_SUBMIT                  (NS_FORM_EVENT_START)
(-)xpcom/threads/nsITimer.idl (-6 / +11 lines)
Line     Link Here 
 Lines 43-54   interface nsIObserver; Link Here 
43
43
44
%{C++
44
%{C++
45
/**
45
/**
46
 * The signature of the timer callback function passed to initWithCallback. This
46
 * The signature of the timer callback function passed to initWithFuncCallback.
47
 * is the function that will get called when the timer expires if the timer is 
47
 * This is the function that will get called when the timer expires if the
48
 * initialized via initWithCallback.
48
 * timer is initialized via initWithFuncCallback.
49
 *
49
 *
50
 * @param aTimer the timer which has expired
50
 * @param aTimer the timer which has expired
51
 * @param aClosure opaque parameter passed to initWithCallback
51
 * @param aClosure opaque parameter passed to initWithFuncCallback
52
 *
52
 *
53
 * Implementers should return the following:
53
 * Implementers should return the following:
54
 *
54
 *
 Lines 82-88   interface nsITimerCallback : nsISupports Link Here 
82
 * delay to avoid the overhead of destroying and creating a timer.  It is not
82
 * delay to avoid the overhead of destroying and creating a timer.  It is not
83
 * necessary to cancel the timer in that case.
83
 * necessary to cancel the timer in that case.
84
 */
84
 */
85
[scriptable, uuid(29ee628e-a3ea-471f-965d-dc9f11d1c183)]
85
[scriptable, uuid(436a83fa-b396-11d9-bcfa-00112478d626)]
86
interface nsITimer : nsISupports
86
interface nsITimer : nsISupports
87
{
87
{
88
  /* Timer types */
88
  /* Timer types */
 Lines 179-187   interface nsITimer : nsISupports Link Here 
179
  attribute unsigned long type;
179
  attribute unsigned long type;
180
180
181
  /**
181
  /**
182
   * The opaque pointer pass to initWithCallback.
182
   * The opaque pointer pass to initWithFuncCallback.
183
   */  
183
   */  
184
  [noscript] readonly attribute voidPtr closure;
184
  [noscript] readonly attribute voidPtr closure;
185
186
  /**
187
   * The nsITimerCallback object passed to initWithCallback.
188
   */
189
  readonly attribute nsITimerCallback callback;
185
};
190
};
186
191
187
%{C++
192
%{C++
(-)xpcom/threads/nsTimerImpl.cpp (+11 lines)
Line     Link Here 
 Lines 331-336   NS_IMETHODIMP nsTimerImpl::GetClosure(vo Link Here 
331
}
331
}
332
332
333
333
334
NS_IMETHODIMP nsTimerImpl::GetCallback(nsITimerCallback **aCallback)
335
{
336
  if (mCallbackType == CALLBACK_TYPE_INTERFACE)
337
    NS_IF_ADDREF(*aCallback = mCallback.i);
338
  else
339
    *aCallback = nsnull;
340
341
  return NS_OK;
342
}
343
344
334
NS_IMETHODIMP nsTimerImpl::GetIdle(PRBool *aIdle)
345
NS_IMETHODIMP nsTimerImpl::GetIdle(PRBool *aIdle)
335
{
346
{
336
  *aIdle = mIdle;
347
  *aIdle = mIdle;
(-)xpfe/components/shistory/public/nsIHistoryEntry.idl (-24 / +24 lines)
Line     Link Here 
 Lines 53-82   interface nsIURI; Link Here 
53
interface nsIHistoryEntry : nsISupports 
53
interface nsIHistoryEntry : nsISupports 
54
{
54
{
55
55
56
/** 
56
    /** 
57
 * A readonly property that returns the URI
57
     * A readonly property that returns the URI
58
 * of the current entry. The object returned is
58
     * of the current entry. The object returned is
59
 * of type nsIURI
59
     * of type nsIURI
60
 */
60
     */
61
readonly attribute nsIURI URI;
61
    readonly attribute nsIURI URI;
62
62
63
/** 
63
    /** 
64
 * A readonly property that returns the title
64
     * A readonly property that returns the title
65
 * of the current entry.  The object returned
65
     * of the current entry.  The object returned
66
 * is a encoded string
66
     * is a encoded string
67
 */
67
     */
68
readonly attribute wstring title;
68
    readonly attribute wstring title;
69
69
70
/** 
70
    /** 
71
 * A readonly property that returns a boolean
71
     * A readonly property that returns a boolean
72
 * flag which indicates if the entry was created as a 
72
     * flag which indicates if the entry was created as a 
73
 * result of a subframe navigation. This flag will be
73
     * result of a subframe navigation. This flag will be
74
 * 'false' when a frameset page is visited for
74
     * 'false' when a frameset page is visited for
75
 * the first time. This flag will be 'true' for all
75
     * the first time. This flag will be 'true' for all
76
 * history entries created as a result of a subframe
76
     * history entries created as a result of a subframe
77
 * navigation.
77
     * navigation.
78
 */
78
     */
79
readonly attribute boolean isSubFrame;
79
    readonly attribute boolean isSubFrame;
80
80
81
};
81
};
82
82
(-)xpfe/components/shistory/public/nsISHEntry.idl (-72 / +110 lines)
Line     Link Here 
 Lines 42-129    Link Here 
42
 * hold all information required to recreate the document from history
42
 * hold all information required to recreate the document from history
43
 * 
43
 * 
44
 */
44
 */
45
#include "nsISupports.idl"
45
#include "nsIHistoryEntry.idl"
46
#include "nsIURI.idl"
47
#include "nsIInputStream.idl"
48
46
49
interface nsILayoutHistoryState;
47
interface nsILayoutHistoryState;
50
interface nsIDOMDocument;
48
interface nsIContentViewer;
49
interface nsIURI;
50
interface nsIInputStream;
51
interface nsIDocShellTreeItem;
52
interface nsISecureBrowserUIState;
53
interface nsISupportsArray;
54
%{C++
55
struct nsRect;
56
%}
57
[ref] native nsRect(nsRect);
51
58
52
[scriptable, uuid(6b596e1f-a3bd-40f9-a7ee-ab3edc7f9960)]
59
[scriptable, uuid(e47bf412-3bc2-4306-a82f-ea2bdf950432)]
53
interface nsISHEntry : nsISupports 
60
interface nsISHEntry : nsIHistoryEntry
54
{
61
{
62
    /** URI for the document */
63
    void setURI(in nsIURI aURI);
55
64
56
/** URI for the document */
65
    /** Referrer URI */
57
void SetURI(in nsIURI aURI);
66
    attribute nsIURI referrerURI;
58
59
/** Referrer URI */
60
attribute nsIURI referrerURI;
61
67
62
/**  DOM Document */
68
    /** Content viewer, for fast restoration of presentation */
63
attribute nsIDOMDocument document;
69
    attribute nsIContentViewer contentViewer;
64
70
65
/** Title for the document */
71
    /** Whether the content viewer is marked "sticky" */
66
void SetTitle(in wstring aTitle);
72
    attribute boolean sticky;
67
73
68
/** Post Data for the document */
74
    /** Saved state of the global window object */
69
attribute nsIInputStream postData;
75
    attribute nsISupports windowState;
70
76
71
/** LayoutHistoryState for scroll position and form values */
77
    /**
72
attribute nsILayoutHistoryState layoutHistoryState;
78
     * Saved position and dimensions of the content viewer; we must adjust the
73
79
     * root view's widget accordingly if this has changed when the presentation
74
/** parent of this entry */
80
     * is restored.
75
attribute nsISHEntry parent;
81
     */
76
82
    [noscript] void getViewerBounds(in nsRect bounds);
77
/**
83
    [noscript] void setViewerBounds([const] in nsRect bounds);
78
 * The loadType for this entry. This is typically loadHistory except
84
79
 * when reload is pressed, it has the appropriate reload flag
85
    /**
80
 */
86
     * Saved child docshells corresponding to contentViewer.  There are weak
81
attribute  unsigned long loadType;
87
     * references since it's assumed that the content viewer's document has
82
88
     * an owning reference to the subdocument for each shell.  The child shells
83
/**
89
     * are restored as children of the parent docshell, in this order, when the
84
 * An ID to help identify this entry from others during
90
     * parent docshell restores a saved presentation.
85
 * subframe navigation
91
     */
86
 */
92
    void addChildShell(in nsIDocShellTreeItem shell);
87
attribute unsigned long ID;
93
    nsIDocShellTreeItem childShellAt(in long index);
88
94
    void clearChildShells();
89
/**
95
90
 * pageIdentifier is an integer that should be the same for two entries
96
    /** Saved security state for the content viewer */
91
 * attached to the same docshell only if the two entries are entries for the
97
    attribute nsISecureBrowserUIState securityState;
92
 * same page in the sense that one could go from the state represented by one
98
93
 * to the state represented by the other simply by scrolling (so the entries
99
    /** Saved refresh URI list for the content viewer */
94
 * are separated by an anchor traversal or a subframe navigation in some other
100
    attribute nsISupportsArray refreshURIList;
95
 * frame).
101
96
 */
102
    /** Title for the document */
97
attribute unsigned long pageIdentifier;
103
    void setTitle(in AString aTitle);
98
104
99
/** attribute to set and get the cache key for the entry */
105
    /** Post Data for the document */
100
attribute nsISupports cacheKey;
106
    attribute nsIInputStream postData;
101
107
102
/** attribute to indicate whether layoutHistoryState should be saved */
108
    /** LayoutHistoryState for scroll position and form values */
103
attribute boolean saveLayoutStateFlag;
109
    attribute nsILayoutHistoryState layoutHistoryState;
104
110
105
/** attribute to indicate whether the page is already expired in cache */
111
    /** parent of this entry */
106
attribute boolean expirationStatus;
112
    attribute nsISHEntry parent;
107
113
108
/** attribute to indicate the content-type of the document that this
114
    /**
109
    is a session history entry for */
115
     * The loadType for this entry. This is typically loadHistory except
110
attribute ACString contentType; 
116
     * when reload is pressed, it has the appropriate reload flag
117
     */
118
    attribute unsigned long loadType;
119
120
    /**
121
     * An ID to help identify this entry from others during
122
     * subframe navigation
123
     */
124
    attribute unsigned long ID;
125
126
    /**
127
     * pageIdentifier is an integer that should be the same for two entries
128
     * attached to the same docshell only if the two entries are entries for
129
     * the same page in the sense that one could go from the state represented
130
     * by one to the state represented by the other simply by scrolling (so the
131
     * entries are separated by an anchor traversal or a subframe navigation in
132
     * some other frame).
133
     */
134
    attribute unsigned long pageIdentifier;
135
136
    /** attribute to set and get the cache key for the entry */
137
    attribute nsISupports cacheKey;
138
139
    /** attribute to indicate whether layoutHistoryState should be saved */
140
    attribute boolean saveLayoutStateFlag;
141
142
    /** attribute to indicate whether the page is already expired in cache */
143
    attribute boolean expirationStatus;
144
145
    /**
146
     * attribute to indicate the content-type of the document that this
147
     * is a session history entry for
148
     */
149
    attribute ACString contentType; 
111
 
150
 
112
/** Set/Get scrollers' positon in anchored pages */
151
    /** Set/Get scrollers' positon in anchored pages */
113
void setScrollPosition(in PRInt32 x, in PRInt32 y);
152
    void setScrollPosition(in long x, in long y);
114
void getScrollPosition(out PRInt32 x, out PRInt32 y);
153
    void getScrollPosition(out long x, out long y);
115
154
116
/** Additional ways to create an entry */
155
    /** Additional ways to create an entry */
117
void create(in nsIURI aURI, in wstring aTitle, in nsIDOMDocument aDocument,
156
    void create(in nsIURI URI, in AString title,
118
            in nsIInputStream aInputStream, in nsILayoutHistoryState aHistoryLayoutState,
157
                in nsIInputStream inputStream,
119
            in nsISupports aCacheKey, in ACString aContentType);
158
                in nsILayoutHistoryState layoutHistoryState,
120
159
                in nsISupports cacheKey, in ACString contentType);
121
nsISHEntry clone();
122
123
/** Attribute that indicates if this entry is for a subframe navigation */
124
void SetIsSubFrame(in boolean aFlag);
125
160
161
    nsISHEntry clone();
126
162
163
    /** Attribute that indicates if this entry is for a subframe navigation */
164
    void setIsSubFrame(in boolean aFlag);
127
};
165
};
128
166
129
167
(-)xpfe/components/shistory/src/Makefile.in (+1 lines)
Line     Link Here 
 Lines 55-60   REQUIRES = xpcom \ Link Here 
55
		  layout \
55
		  layout \
56
		  docshell \
56
		  docshell \
57
		  pref \
57
		  pref \
58
		  gfx \
58
		  $(NULL)
59
		  $(NULL)
59
60
60
CPPSRCS		= nsSHEntry.cpp        \
61
CPPSRCS		= nsSHEntry.cpp        \
(-)xpfe/components/shistory/src/nsSHEntry.cpp (-11 / +122 lines)
Line     Link Here 
 Lines 37-47    Link Here 
37
 *
37
 *
38
 * ***** END LICENSE BLOCK ***** */
38
 * ***** END LICENSE BLOCK ***** */
39
39
40
#ifdef DEBUG_brymer
41
#define DEBUG_PAGE_CACHE
42
#endif
43
40
// Local Includes
44
// Local Includes
41
#include "nsSHEntry.h"
45
#include "nsSHEntry.h"
42
#include "nsXPIDLString.h"
46
#include "nsXPIDLString.h"
43
#include "nsReadableUtils.h"
47
#include "nsReadableUtils.h"
44
#include "nsIDocShellLoadInfo.h"
48
#include "nsIDocShellLoadInfo.h"
49
#include "nsIDocShellTreeItem.h"
45
50
46
static PRUint32 gEntryID = 0;
51
static PRUint32 gEntryID = 0;
47
52
 Lines 58-64   nsSHEntry::nsSHEntry() Link Here 
58
  , mIsFrameNavigation(PR_FALSE)
63
  , mIsFrameNavigation(PR_FALSE)
59
  , mSaveLayoutState(PR_TRUE)
64
  , mSaveLayoutState(PR_TRUE)
60
  , mExpired(PR_FALSE)
65
  , mExpired(PR_FALSE)
66
  , mSticky(PR_TRUE)
61
  , mParent(nsnull)
67
  , mParent(nsnull)
68
  , mViewerBounds(0, 0, 0, 0)
62
{
69
{
63
}
70
}
64
71
 Lines 77-88   nsSHEntry::nsSHEntry(const nsSHEntry &ot Link Here 
77
  , mIsFrameNavigation(other.mIsFrameNavigation)
84
  , mIsFrameNavigation(other.mIsFrameNavigation)
78
  , mSaveLayoutState(other.mSaveLayoutState)
85
  , mSaveLayoutState(other.mSaveLayoutState)
79
  , mExpired(other.mExpired)
86
  , mExpired(other.mExpired)
87
  , mSticky(other.mSticky)
80
  // XXX why not copy mContentType?
88
  // XXX why not copy mContentType?
81
  , mCacheKey(other.mCacheKey)
89
  , mCacheKey(other.mCacheKey)
82
  , mParent(other.mParent)
90
  , mParent(other.mParent)
91
  , mViewerBounds(other.mViewerBounds)
83
{
92
{
84
}
93
}
85
94
95
nsSHEntry::~nsSHEntry()
96
{
97
  mChildren.Clear();
98
  if (mContentViewer)
99
    mContentViewer->Destroy();
100
}
101
86
//*****************************************************************************
102
//*****************************************************************************
87
//    nsSHEntry: nsISupports
103
//    nsSHEntry: nsISupports
88
//*****************************************************************************
104
//*****************************************************************************
 Lines 133-151   NS_IMETHODIMP nsSHEntry::SetReferrerURI( Link Here 
133
  return NS_OK;
149
  return NS_OK;
134
}
150
}
135
151
136
NS_IMETHODIMP nsSHEntry::SetDocument(nsIDOMDocument* aDocument)
152
NS_IMETHODIMP
153
nsSHEntry::SetContentViewer(nsIContentViewer *aViewer)
137
{
154
{
138
  mDocument = aDocument;
155
  mContentViewer = aViewer;
139
  return NS_OK;
156
  return NS_OK;
140
}
157
}
141
158
142
NS_IMETHODIMP nsSHEntry::GetDocument(nsIDOMDocument** aResult)
159
NS_IMETHODIMP
160
nsSHEntry::GetContentViewer(nsIContentViewer **aResult)
143
{
161
{
144
  *aResult = mDocument;
162
  *aResult = mContentViewer;
145
  NS_IF_ADDREF(*aResult);
163
  NS_IF_ADDREF(*aResult);
146
  return NS_OK;
164
  return NS_OK;
147
}
165
}
148
166
167
NS_IMETHODIMP
168
nsSHEntry::SetSticky(PRBool aSticky)
169
{
170
  mSticky = aSticky;
171
  return NS_OK;
172
}
173
174
NS_IMETHODIMP
175
nsSHEntry::GetSticky(PRBool *aSticky)
176
{
177
  *aSticky = mSticky;
178
  return NS_OK;
179
}
180
149
NS_IMETHODIMP nsSHEntry::GetTitle(PRUnichar** aTitle)
181
NS_IMETHODIMP nsSHEntry::GetTitle(PRUnichar** aTitle)
150
{
182
{
151
  // Check for empty title...
183
  // Check for empty title...
 Lines 160-166   NS_IMETHODIMP nsSHEntry::GetTitle(PRUnic Link Here 
160
  return NS_OK;
192
  return NS_OK;
161
}
193
}
162
194
163
NS_IMETHODIMP nsSHEntry::SetTitle(const PRUnichar* aTitle)
195
NS_IMETHODIMP nsSHEntry::SetTitle(const nsAString &aTitle)
164
{
196
{
165
  mTitle = aTitle;
197
  mTitle = aTitle;
166
  return NS_OK;
198
  return NS_OK;
 Lines 297-310   NS_IMETHODIMP nsSHEntry::SetContentType( Link Here 
297
}
329
}
298
330
299
NS_IMETHODIMP
331
NS_IMETHODIMP
300
nsSHEntry::Create(nsIURI * aURI, const PRUnichar * aTitle,
332
nsSHEntry::Create(nsIURI * aURI, const nsAString &aTitle,
301
                  nsIDOMDocument * aDOMDocument, nsIInputStream * aInputStream,
333
                  nsIInputStream * aInputStream,
302
                  nsILayoutHistoryState * aHistoryLayoutState,
334
                  nsILayoutHistoryState * aLayoutHistoryState,
303
                  nsISupports * aCacheKey, const nsACString& aContentType)
335
                  nsISupports * aCacheKey, const nsACString& aContentType)
304
{
336
{
305
  mURI = aURI;
337
  mURI = aURI;
306
  mTitle = aTitle;
338
  mTitle = aTitle;
307
  mDocument = aDOMDocument;
308
  mPostData = aInputStream;
339
  mPostData = aInputStream;
309
  mCacheKey = aCacheKey;
340
  mCacheKey = aCacheKey;
310
  mContentType = aContentType;
341
  mContentType = aContentType;
 Lines 317-325   nsSHEntry::Create(nsIURI * aURI, const P Link Here 
317
  // all subframe navigations, sets the flag to true.
348
  // all subframe navigations, sets the flag to true.
318
  mIsFrameNavigation = PR_FALSE;
349
  mIsFrameNavigation = PR_FALSE;
319
350
320
  // By default we save HistoryLayoutState
351
  // By default we save LayoutHistoryState
321
  mSaveLayoutState = PR_TRUE;
352
  mSaveLayoutState = PR_TRUE;
322
  mLayoutHistoryState = aHistoryLayoutState;
353
  mLayoutHistoryState = aLayoutHistoryState;
323
354
324
  //By default the page is not expired
355
  //By default the page is not expired
325
  mExpired = PR_FALSE;
356
  mExpired = PR_FALSE;
 Lines 358-363   nsSHEntry::SetParent(nsISHEntry * aParen Link Here 
358
  return NS_OK;
389
  return NS_OK;
359
}
390
}
360
391
392
NS_IMETHODIMP
393
nsSHEntry::SetWindowState(nsISupports *aState)
394
{
395
  mWindowState = aState;
396
  return NS_OK;
397
}
398
399
NS_IMETHODIMP
400
nsSHEntry::GetWindowState(nsISupports **aState)
401
{
402
  NS_IF_ADDREF(*aState = mWindowState);
403
  return NS_OK;
404
}
405
406
NS_IMETHODIMP
407
nsSHEntry::SetViewerBounds(const nsRect &aBounds)
408
{
409
  mViewerBounds = aBounds;
410
  return NS_OK;
411
}
412
413
NS_IMETHODIMP
414
nsSHEntry::GetViewerBounds(nsRect &aBounds)
415
{
416
  aBounds = mViewerBounds;
417
  return NS_OK;
418
}
419
361
//*****************************************************************************
420
//*****************************************************************************
362
//    nsSHEntry: nsISHContainer
421
//    nsSHEntry: nsISHContainer
363
//*****************************************************************************
422
//*****************************************************************************
 Lines 416-418   nsSHEntry::GetChildAt(PRInt32 aIndex, ns Link Here 
416
  }
475
  }
417
  return NS_OK;
476
  return NS_OK;
418
}
477
}
478
479
NS_IMETHODIMP
480
nsSHEntry::AddChildShell(nsIDocShellTreeItem *aShell)
481
{
482
  NS_ASSERTION(aShell, "Null child shell added to history entry");
483
  mChildShells.AppendElement(aShell);
484
  return NS_OK;
485
}
486
487
NS_IMETHODIMP
488
nsSHEntry::ChildShellAt(PRInt32 aIndex, nsIDocShellTreeItem **aShell)
489
{
490
  NS_IF_ADDREF(*aShell =
491
               NS_STATIC_CAST(nsIDocShellTreeItem*,
492
                              mChildShells.SafeElementAt(aIndex)));
493
  return NS_OK;
494
}
495
496
NS_IMETHODIMP
497
nsSHEntry::ClearChildShells()
498
{
499
  mChildShells.Clear();
500
  return NS_OK;
501
}
502
503
NS_IMETHODIMP
504
nsSHEntry::GetSecurityState(nsISecureBrowserUIState **aState)
505
{
506
  NS_IF_ADDREF(*aState = mSecurityState);
507
  return NS_OK;
508
}
509
510
NS_IMETHODIMP
511
nsSHEntry::SetSecurityState(nsISecureBrowserUIState *aState)
512
{
513
  mSecurityState = aState;
514
  return NS_OK;
515
}
516
517
NS_IMETHODIMP
518
nsSHEntry::GetRefreshURIList(nsISupportsArray **aList)
519
{
520
  NS_IF_ADDREF(*aList = mRefreshURIList);
521
  return NS_OK;
522
}
523
524
NS_IMETHODIMP
525
nsSHEntry::SetRefreshURIList(nsISupportsArray *aList)
526
{
527
  mRefreshURIList = aList;
528
  return NS_OK;
529
}
(-)xpfe/components/shistory/src/nsSHEntry.h (-5 / +14 lines)
Line     Link Here 
 Lines 44-52    Link Here 
44
#include "nsCOMPtr.h"
44
#include "nsCOMPtr.h"
45
#include "nsCOMArray.h"
45
#include "nsCOMArray.h"
46
#include "nsString.h"
46
#include "nsString.h"
47
#include "nsVoidArray.h"
47
48
48
// Interfaces needed
49
// Interfaces needed
49
#include "nsIDOMDocument.h"
50
#include "nsIContentViewer.h"
50
#include "nsIInputStream.h"
51
#include "nsIInputStream.h"
51
#include "nsILayoutHistoryState.h"
52
#include "nsILayoutHistoryState.h"
52
#include "nsISHEntry.h"
53
#include "nsISHEntry.h"
 Lines 54-62    Link Here 
54
#include "nsIURI.h"
55
#include "nsIURI.h"
55
#include "nsIEnumerator.h"
56
#include "nsIEnumerator.h"
56
#include "nsIHistoryEntry.h"
57
#include "nsIHistoryEntry.h"
58
#include "nsRect.h"
59
#include "nsISecureBrowserUI.h"
60
#include "nsSupportsArray.h"
57
61
58
class nsSHEntry : public nsIHistoryEntry,
62
class nsSHEntry : public nsISHEntry,
59
                  public nsISHEntry,
60
                  public nsISHContainer
63
                  public nsISHContainer
61
{
64
{
62
public: 
65
public: 
 Lines 69-79   public: Link Here 
69
  NS_DECL_NSISHCONTAINER
72
  NS_DECL_NSISHCONTAINER
70
73
71
private:
74
private:
72
  ~nsSHEntry() { mChildren.Clear(); }
75
  ~nsSHEntry();
73
76
74
  nsCOMPtr<nsIURI>                mURI;
77
  nsCOMPtr<nsIURI>                mURI;
75
  nsCOMPtr<nsIURI>                mReferrerURI;
78
  nsCOMPtr<nsIURI>                mReferrerURI;
76
  nsCOMPtr<nsIDOMDocument>        mDocument;
79
  nsCOMPtr<nsIContentViewer>      mContentViewer;
77
  nsString                        mTitle;
80
  nsString                        mTitle;
78
  nsCOMPtr<nsIInputStream>        mPostData;
81
  nsCOMPtr<nsIInputStream>        mPostData;
79
  nsCOMPtr<nsILayoutHistoryState> mLayoutHistoryState;
82
  nsCOMPtr<nsILayoutHistoryState> mLayoutHistoryState;
 Lines 86-94   private: Link Here 
86
  PRPackedBool                    mIsFrameNavigation;
89
  PRPackedBool                    mIsFrameNavigation;
87
  PRPackedBool                    mSaveLayoutState;
90
  PRPackedBool                    mSaveLayoutState;
88
  PRPackedBool                    mExpired;
91
  PRPackedBool                    mExpired;
92
  PRPackedBool                    mSticky;
89
  nsCString                       mContentType;
93
  nsCString                       mContentType;
90
  nsCOMPtr<nsISupports>           mCacheKey;
94
  nsCOMPtr<nsISupports>           mCacheKey;
91
  nsISHEntry *                    mParent;  // weak reference
95
  nsISHEntry *                    mParent;  // weak reference
96
  nsCOMPtr<nsISupports>           mWindowState;
97
  nsRect                          mViewerBounds;
98
  nsVoidArray                     mChildShells;
99
  nsCOMPtr<nsISecureBrowserUIState> mSecurityState;
100
  nsCOMPtr<nsISupportsArray>      mRefreshURIList;
92
};
101
};
93
102
94
#endif /* nsSHEntry_h */
103
#endif /* nsSHEntry_h */
(-)xpfe/components/shistory/src/nsSHistory.cpp (-7 / +58 lines)
Line     Link Here 
 Lines 54-62    Link Here 
54
#include "nsIDocShellLoadInfo.h"
54
#include "nsIDocShellLoadInfo.h"
55
#include "nsIServiceManager.h"
55
#include "nsIServiceManager.h"
56
#include "nsIPrefService.h"
56
#include "nsIPrefService.h"
57
#include "nsIURI.h"
58
#include "nsIContentViewer.h"
57
59
58
#define PREF_SHISTORY_SIZE "browser.sessionhistory.max_entries"
60
#define PREF_SHISTORY_SIZE "browser.sessionhistory.max_entries"
61
#define PREF_SHISTORY_VIEWERS "browser.sessionhistory.max_viewers"
62
59
static PRInt32  gHistoryMaxSize = 50;
63
static PRInt32  gHistoryMaxSize = 50;
64
static PRInt32  gHistoryMaxViewers = 0;
60
65
61
enum HistCmd{
66
enum HistCmd{
62
  HIST_CMD_BACK,
67
  HIST_CMD_BACK,
 Lines 69-75   enum HistCmd{ Link Here 
69
//***    nsSHistory: Object Management
74
//***    nsSHistory: Object Management
70
//*****************************************************************************
75
//*****************************************************************************
71
76
72
nsSHistory::nsSHistory() : mListRoot(nsnull), mIndex(-1), mLength(0), mRequestedIndex(-1)
77
nsSHistory::nsSHistory() : mListRoot(nsnull), mIndex(-1), mLength(0), mRequestedIndex(-1), mNumViewers(0)
73
{
78
{
74
}
79
}
75
80
 Lines 104-113   nsSHistory::Init() Link Here 
104
{
109
{
105
  nsCOMPtr<nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
110
  nsCOMPtr<nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
106
  if (prefs) {
111
  if (prefs) {
107
    nsCOMPtr<nsIPrefBranch> defaultBranch;
112
    nsCOMPtr<nsIPrefBranch> branch = do_QueryInterface(prefs);
108
    prefs->GetDefaultBranch(nsnull, getter_AddRefs(defaultBranch));
113
    if (branch) {
109
    if (defaultBranch) {
114
      branch->GetIntPref(PREF_SHISTORY_SIZE, &gHistoryMaxSize);
110
      defaultBranch->GetIntPref(PREF_SHISTORY_SIZE, &gHistoryMaxSize);
115
      branch->GetIntPref(PREF_SHISTORY_VIEWERS, &gHistoryMaxViewers);
111
    }
116
    }
112
  }
117
  }
113
  return NS_OK;
118
  return NS_OK;
 Lines 171-177   nsSHistory::AddEntry(nsISHEntry * aSHEnt Link Here 
171
  //Purge History list if it is too long
176
  //Purge History list if it is too long
172
  if ((gHistoryMaxSize >= 0) && (mLength > gHistoryMaxSize))
177
  if ((gHistoryMaxSize >= 0) && (mLength > gHistoryMaxSize))
173
    PurgeHistory(mLength-gHistoryMaxSize);
178
    PurgeHistory(mLength-gHistoryMaxSize);
174
  
179
180
  // Evict content viewers if there are too many.
181
  EvictContentViewers(mIndex - 1, mIndex);
182
175
  return NS_OK;
183
  return NS_OK;
176
}
184
}
177
185
 Lines 207-212   nsSHistory::GetEntryAtIndex(PRInt32 aInd Link Here 
207
    if (NS_SUCCEEDED(rv) && (*aResult)) {
215
    if (NS_SUCCEEDED(rv) && (*aResult)) {
208
      // Set mIndex to the requested index, if asked to do so..
216
      // Set mIndex to the requested index, if asked to do so..
209
      if (aModifyIndex) {
217
      if (aModifyIndex) {
218
        EvictContentViewers(mIndex, aIndex);
210
        mIndex = aIndex;
219
        mIndex = aIndex;
211
      }
220
      }
212
    } //entry
221
    } //entry
 Lines 583-594   nsSHistory::Reload(PRUint32 aReloadFlags Link Here 
583
	return LoadEntry(mIndex, loadType, HIST_CMD_RELOAD);
592
	return LoadEntry(mIndex, loadType, HIST_CMD_RELOAD);
584
}
593
}
585
594
595
void
596
nsSHistory::EvictContentViewers(PRInt32 aFromIndex, PRInt32 aToIndex)
597
{
598
  // To enforce the limit on cached content viewers, we need to release all
599
  // of the content viewers that are no longer in the "window" that now
600
  // ends/begins at aToIndex.
601
602
  PRInt32 startIndex, endIndex;
603
  if (aToIndex > aFromIndex) { // going forward
604
    startIndex = PR_MAX(0, aFromIndex - gHistoryMaxViewers);
605
    endIndex = aToIndex - gHistoryMaxViewers;
606
  } else { // going backward
607
    startIndex = aToIndex + gHistoryMaxViewers;
608
    endIndex = PR_MIN(mLength - 1, aFromIndex + gHistoryMaxViewers);
609
  }
610
611
  nsCOMPtr<nsISHEntry> entry;
612
  nsCOMPtr<nsIContentViewer> viewer;
613
  nsISHTransaction *temp;
614
  nsCOMPtr<nsISHTransaction> trans;
615
  GetTransactionAtIndex(startIndex, getter_AddRefs(trans));
616
617
  for (PRInt32 i = startIndex; trans && i < endIndex; ++i) {
618
    trans->GetSHEntry(getter_AddRefs(entry));
619
    entry->GetContentViewer(getter_AddRefs(viewer));
620
    if (viewer) {
621
      viewer->Destroy();
622
      entry->SetContentViewer(nsnull);
623
    }
624
625
    entry->SetWindowState(nsnull);
626
    temp = trans;
627
    temp->GetNext(getter_AddRefs(trans));
628
  }
629
}
630
586
NS_IMETHODIMP
631
NS_IMETHODIMP
587
nsSHistory::UpdateIndex()
632
nsSHistory::UpdateIndex()
588
{
633
{
589
  // Update the actual index with the right value. 
634
  // Update the actual index with the right value. 
590
  if (mIndex != mRequestedIndex && mRequestedIndex != -1)
635
  if (mIndex != mRequestedIndex && mRequestedIndex != -1) {
636
    // We've just finished a history navigation (back or forward), so enforce
637
    // the max number of content viewers.
638
639
    EvictContentViewers(mIndex, mRequestedIndex);
591
    mIndex = mRequestedIndex;
640
    mIndex = mRequestedIndex;
641
  }
642
592
  return NS_OK;
643
  return NS_OK;
593
}
644
}
594
645
(-)xpfe/components/shistory/src/nsSHistory.h (+3 lines)
Line     Link Here 
 Lines 85-95   protected: Link Here 
85
   nsresult PrintHistory();
85
   nsresult PrintHistory();
86
#endif
86
#endif
87
87
88
  void EvictContentViewers(PRInt32 aFromIndex, PRInt32 aToIndex);
89
88
protected:
90
protected:
89
  nsCOMPtr<nsISHTransaction> mListRoot;
91
  nsCOMPtr<nsISHTransaction> mListRoot;
90
  PRInt32 mIndex;
92
  PRInt32 mIndex;
91
  PRInt32 mLength;
93
  PRInt32 mLength;
92
  PRInt32 mRequestedIndex;
94
  PRInt32 mRequestedIndex;
95
  PRInt32 mNumViewers;
93
  // Session History listener
96
  // Session History listener
94
  nsWeakPtr mListener;
97
  nsWeakPtr mListener;
95
  // Weak reference. Do not refcount this.
98
  // Weak reference. Do not refcount this.

Return to bug 274784