Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/nsDocShell.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#ifndef nsDocShell_h__
8
#define nsDocShell_h__
9
10
#include "mozilla/BasePrincipal.h"
11
#include "mozilla/HalScreenConfiguration.h"
12
#include "mozilla/LinkedList.h"
13
#include "mozilla/Maybe.h"
14
#include "mozilla/Move.h"
15
#include "mozilla/TimeStamp.h"
16
#include "mozilla/UniquePtr.h"
17
#include "mozilla/WeakPtr.h"
18
19
#include "mozilla/dom/BrowsingContext.h"
20
#include "mozilla/dom/ProfileTimelineMarkerBinding.h"
21
#include "mozilla/gfx/Matrix.h"
22
#include "mozilla/dom/ChildSHistory.h"
23
24
#include "nsIAuthPromptProvider.h"
25
#include "nsIBaseWindow.h"
26
#include "nsIDeprecationWarner.h"
27
#include "nsIDocShell.h"
28
#include "nsIDocShellTreeItem.h"
29
#include "nsIDOMStorageManager.h"
30
#include "nsIInterfaceRequestor.h"
31
#include "nsILinkHandler.h"
32
#include "nsILoadContext.h"
33
#include "nsILoadURIDelegate.h"
34
#include "nsINetworkInterceptController.h"
35
#include "nsIRefreshURI.h"
36
#include "nsIScrollable.h"
37
#include "nsITabParent.h"
38
#include "nsIWebNavigation.h"
39
#include "nsIWebPageDescriptor.h"
40
#include "nsIWebProgressListener.h"
41
42
#include "nsAutoPtr.h"
43
#include "nsCharsetSource.h"
44
#include "nsCOMPtr.h"
45
#include "nsContentPolicyUtils.h"
46
#include "nsContentUtils.h"
47
#include "nsCRT.h"
48
#include "nsDocLoader.h"
49
#include "nsPoint.h" // mCurrent/mDefaultScrollbarPreferences
50
#include "nsRect.h"
51
#include "nsString.h"
52
#include "nsThreadUtils.h"
53
54
#include "GeckoProfiler.h"
55
#include "jsapi.h"
56
#include "prtime.h"
57
#include "Units.h"
58
59
#include "mozilla/ObservedDocShell.h"
60
#include "mozilla/TimelineConsumers.h"
61
#include "mozilla/TimelineMarker.h"
62
63
// Interfaces Needed
64
65
namespace mozilla {
66
class Encoding;
67
class HTMLEditor;
68
enum class TaskCategory;
69
namespace dom {
70
class ClientInfo;
71
class ClientSource;
72
class EventTarget;
73
} // namespace dom
74
} // namespace mozilla
75
76
class nsICommandManager;
77
class nsIContentViewer;
78
class nsIController;
79
class nsIDocShellTreeOwner;
80
class nsIDocument;
81
class nsIHttpChannel;
82
class nsIMutableArray;
83
class nsIPrompt;
84
class nsIScrollableFrame;
85
class nsISecureBrowserUI;
86
class nsISHistory;
87
class nsIStringBundle;
88
class nsIURIFixup;
89
class nsIURILoader;
90
class nsIWebBrowserFind;
91
class nsIWidget;
92
93
class nsDocShell;
94
class nsDocShellEditorData;
95
class nsDOMNavigationTiming;
96
class nsDSURIContentListener;
97
class nsGlobalWindowInner;
98
class nsGlobalWindowOuter;
99
100
class FramingChecker;
101
class OnLinkClickEvent;
102
103
/* internally used ViewMode types */
104
enum ViewMode
105
{
106
  viewNormal = 0x0,
107
  viewSource = 0x1
108
};
109
110
enum eCharsetReloadState
111
{
112
  eCharsetReloadInit,
113
  eCharsetReloadRequested,
114
  eCharsetReloadStopOrigional
115
};
116
117
class nsDocShell final
118
  : public nsDocLoader
119
  , public nsIDocShell
120
  , public nsIWebNavigation
121
  , public nsIBaseWindow
122
  , public nsIScrollable
123
  , public nsIRefreshURI
124
  , public nsIWebProgressListener
125
  , public nsIWebPageDescriptor
126
  , public nsIAuthPromptProvider
127
  , public nsILoadContext
128
  , public nsILinkHandler
129
  , public nsIDOMStorageManager
130
  , public nsINetworkInterceptController
131
  , public nsIDeprecationWarner
132
  , public mozilla::SupportsWeakPtr<nsDocShell>
133
{
134
public:
135
  // Event type dispatched by RestorePresentation
136
  class RestorePresentationEvent : public mozilla::Runnable
137
  {
138
  public:
139
    NS_DECL_NSIRUNNABLE
140
    explicit RestorePresentationEvent(nsDocShell* aDs)
141
      : mozilla::Runnable("nsDocShell::RestorePresentationEvent")
142
      , mDocShell(aDs)
143
    {
144
    }
145
    void Revoke() { mDocShell = nullptr; }
146
  private:
147
    RefPtr<nsDocShell> mDocShell;
148
  };
149
150
  class InterfaceRequestorProxy : public nsIInterfaceRequestor
151
  {
152
  public:
153
    explicit InterfaceRequestorProxy(nsIInterfaceRequestor* aRequestor);
154
    NS_DECL_THREADSAFE_ISUPPORTS
155
    NS_DECL_NSIINTERFACEREQUESTOR
156
157
  private:
158
    virtual ~InterfaceRequestorProxy();
159
0
    InterfaceRequestorProxy() {}
160
    nsWeakPtr mWeakPtr;
161
  };
162
163
  MOZ_DECLARE_WEAKREFERENCE_TYPENAME(nsDocShell)
164
  NS_DECL_ISUPPORTS_INHERITED
165
  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDocShell, nsDocLoader)
166
  NS_DECL_NSIDOCSHELL
167
  NS_DECL_NSIDOCSHELLTREEITEM
168
  NS_DECL_NSIWEBNAVIGATION
169
  NS_DECL_NSIBASEWINDOW
170
  NS_DECL_NSISCROLLABLE
171
  NS_DECL_NSIINTERFACEREQUESTOR
172
  NS_DECL_NSIWEBPROGRESSLISTENER
173
  NS_DECL_NSIREFRESHURI
174
  NS_DECL_NSIWEBPAGEDESCRIPTOR
175
  NS_DECL_NSIAUTHPROMPTPROVIDER
176
  NS_DECL_NSINETWORKINTERCEPTCONTROLLER
177
  NS_DECL_NSIDEPRECATIONWARNER
178
179
  NS_FORWARD_SAFE_NSIDOMSTORAGEMANAGER(TopSessionStorageManager())
180
181
  // Need to implement (and forward) nsISecurityEventSink, because
182
  // nsIWebProgressListener has methods with identical names...
183
  NS_FORWARD_NSISECURITYEVENTSINK(nsDocLoader::)
184
185
  nsDocShell();
186
  virtual nsresult Init() override;
187
188
  NS_IMETHOD Stop() override
189
  {
190
    // Need this here because otherwise nsIWebNavigation::Stop
191
    // overrides the docloader's Stop()
192
    return nsDocLoader::Stop();
193
  }
194
195
  // nsILinkHandler
196
  NS_IMETHOD OnLinkClick(nsIContent* aContent,
197
                         nsIURI* aURI,
198
                         const char16_t* aTargetSpec,
199
                         const nsAString& aFileName,
200
                         nsIInputStream* aPostDataStream,
201
                         nsIInputStream* aHeadersDataStream,
202
                         bool aIsUserTriggered,
203
                         bool aIsTrusted,
204
                         nsIPrincipal* aTriggeringPrincipal) override;
205
  NS_IMETHOD OnLinkClickSync(nsIContent* aContent,
206
                             nsIURI* aURI,
207
                             const char16_t* aTargetSpec,
208
                             const nsAString& aFileName,
209
                             nsIInputStream* aPostDataStream = 0,
210
                             nsIInputStream* aHeadersDataStream = 0,
211
                             bool aNoOpenerImplied = false,
212
                             nsIDocShell** aDocShell = 0,
213
                             nsIRequest** aRequest = 0,
214
                             bool aIsUserTriggered = false,
215
                             nsIPrincipal* aTriggeringPrincipal = nullptr) override;
216
  NS_IMETHOD OnOverLink(nsIContent* aContent,
217
                        nsIURI* aURI,
218
                        const char16_t* aTargetSpec) override;
219
  NS_IMETHOD OnLeaveLink() override;
220
221
  // Don't use NS_DECL_NSILOADCONTEXT because some of nsILoadContext's methods
222
  // are shared with nsIDocShell (appID, etc.) and can't be declared twice.
223
  NS_IMETHOD GetAssociatedWindow(mozIDOMWindowProxy**) override;
224
  NS_IMETHOD GetTopWindow(mozIDOMWindowProxy**) override;
225
  NS_IMETHOD GetTopFrameElement(mozilla::dom::Element**) override;
226
  NS_IMETHOD GetNestedFrameId(uint64_t*) override;
227
  NS_IMETHOD GetIsContent(bool*) override;
228
  NS_IMETHOD GetUsePrivateBrowsing(bool*) override;
229
  NS_IMETHOD SetUsePrivateBrowsing(bool) override;
230
  NS_IMETHOD SetPrivateBrowsing(bool) override;
231
  NS_IMETHOD GetUseRemoteTabs(bool*) override;
232
  NS_IMETHOD SetRemoteTabs(bool) override;
233
  NS_IMETHOD GetScriptableOriginAttributes(JS::MutableHandle<JS::Value>) override;
234
  NS_IMETHOD_(void) GetOriginAttributes(mozilla::OriginAttributes& aAttrs) override;
235
236
  // Restores a cached presentation from history (mLSHE).
237
  // This method swaps out the content viewer and simulates loads for
238
  // subframes. It then simulates the completion of the toplevel load.
239
  nsresult RestoreFromHistory();
240
241
  // Perform a URI load from a refresh timer. This is just like the
242
  // ForceRefreshURI method on nsIRefreshURI, but makes sure to take
243
  // the timer involved out of mRefreshURIList if it's there.
244
  // aTimer must not be null.
245
  nsresult ForceRefreshURIFromTimer(nsIURI* aURI, nsIPrincipal* aPrincipal,
246
                                    int32_t aDelay,
247
                                    bool aMetaRefresh, nsITimer* aTimer);
248
249
  // We need dummy OnLocationChange in some cases to update the UI without
250
  // updating security info.
251
  void FireDummyOnLocationChange()
252
  {
253
    FireOnLocationChange(this, nullptr, mCurrentURI,
254
                         LOCATION_CHANGE_SAME_DOCUMENT);
255
  }
256
257
  nsresult HistoryEntryRemoved(int32_t aIndex);
258
259
  // Notify Scroll observers when an async panning/zooming transform
260
  // has started being applied
261
  MOZ_CAN_RUN_SCRIPT_BOUNDARY
262
  void NotifyAsyncPanZoomStarted();
263
264
  // Notify Scroll observers when an async panning/zooming transform
265
  // is no longer applied
266
  MOZ_CAN_RUN_SCRIPT_BOUNDARY
267
  void NotifyAsyncPanZoomStopped();
268
269
  void SetInFrameSwap(bool aInSwap)
270
  {
271
    mInFrameSwap = aInSwap;
272
  }
273
  bool InFrameSwap();
274
275
  const mozilla::Encoding* GetForcedCharset() { return mForcedCharset; }
276
277
  mozilla::HTMLEditor* GetHTMLEditorInternal();
278
  nsresult SetHTMLEditorInternal(mozilla::HTMLEditor* aHTMLEditor);
279
280
  // Handle page navigation due to charset changes
281
  nsresult CharsetChangeReloadDocument(const char* aCharset = nullptr,
282
                                               int32_t aSource = kCharsetUninitialized);
283
  nsresult CharsetChangeStopDocumentLoad();
284
285
  nsDOMNavigationTiming* GetNavigationTiming() const;
286
287
  nsresult SetOriginAttributes(const mozilla::OriginAttributes& aAttrs);
288
289
  /**
290
   * Get the list of ancestor principals for this docshell.  The list is meant
291
   * to be the list of principals of the documents this docshell is "nested
292
   * through" in the sense of
293
   * <https://html.spec.whatwg.org/multipage/browsers.html#browsing-context-nested-through>.
294
   * In practice, it is defined as follows:
295
   *
296
   * If this is an <iframe mozbrowser> or a toplevel content docshell
297
   * (i.e. toplevel document in spec terms), the list is empty.
298
   *
299
   * Otherwise the list is the list for the document we're nested through (again
300
   * in the spec sense), with the principal of that document prepended.  Note
301
   * that this matches the ordering specified for Location.ancestorOrigins.
302
   */
303
  const nsTArray<nsCOMPtr<nsIPrincipal>>& AncestorPrincipals() const
304
  {
305
    return mAncestorPrincipals;
306
  }
307
308
  /**
309
   * Set the list of ancestor principals for this docshell.  This is really only
310
   * needed for use by the frameloader.  We can't do this ourselves, inside
311
   * docshell, because there's a bunch of state setup that frameloader does
312
   * (like telling us whether we're a mozbrowser), some of which comes after the
313
   * docshell is added to the docshell tree, which can affect what the ancestor
314
   * principals should look like.
315
   *
316
   * This method steals the data from the passed-in array.
317
   */
318
  void SetAncestorPrincipals(
319
    nsTArray<nsCOMPtr<nsIPrincipal>>&& aAncestorPrincipals)
320
  {
321
    mAncestorPrincipals = std::move(aAncestorPrincipals);
322
  }
323
324
  /**
325
   * Get the list of ancestor outerWindowIDs for this docshell.  The list is meant
326
   * to be the list of outer window IDs that correspond to the ancestorPrincipals
327
   * above.   For each ancestor principal, we store the parent window ID.
328
   */
329
  const nsTArray<uint64_t>& AncestorOuterWindowIDs() const
330
  {
331
    return mAncestorOuterWindowIDs;
332
  }
333
334
  /**
335
   * Set the list of ancestor outer window IDs for this docshell.  We call this
336
   * from frameloader as well in order to keep the array matched with the
337
   * ancestor principals.
338
   *
339
   * This method steals the data from the passed-in array.
340
   */
341
  void SetAncestorOuterWindowIDs(nsTArray<uint64_t>&& aAncestorOuterWindowIDs)
342
  {
343
    mAncestorOuterWindowIDs = std::move(aAncestorOuterWindowIDs);
344
  }
345
346
  const mozilla::OriginAttributes& GetOriginAttributes()
347
  {
348
    return mOriginAttributes;
349
  }
350
351
  // Determine whether this docshell corresponds to the given history entry,
352
  // via having a pointer to it in mOSHE or mLSHE.
353
  bool HasHistoryEntry(nsISHEntry* aEntry) const
354
  {
355
    return aEntry && (aEntry == mOSHE || aEntry == mLSHE);
356
  }
357
358
  // Update any pointers (mOSHE or mLSHE) to aOldEntry to point to aNewEntry
359
  void SwapHistoryEntries(nsISHEntry* aOldEntry, nsISHEntry* aNewEntry);
360
361
  mozilla::gfx::Matrix5x4* GetColorMatrix() {
362
    return mColorMatrix.get();
363
  }
364
365
  static bool SandboxFlagsImplyCookies(const uint32_t &aSandboxFlags);
366
367
  // Tell the favicon service that aNewURI has the same favicon as aOldURI.
368
  static void CopyFavicon(nsIURI* aOldURI,
369
                          nsIURI* aNewURI,
370
                          nsIPrincipal* aLoadingPrincipal,
371
                          bool aInPrivateBrowsing);
372
373
  static nsDocShell* Cast(nsIDocShell* aDocShell)
374
  {
375
    return static_cast<nsDocShell*>(aDocShell);
376
  }
377
378
  // Returns true if the current load is a force reload (started by holding
379
  // shift while triggering reload)
380
  bool IsForceReloading();
381
382
  already_AddRefed<mozilla::dom::BrowsingContext>
383
  GetBrowsingContext() const;
384
385
private: // member functions
386
  friend class nsDSURIContentListener;
387
  friend class FramingChecker;
388
  friend class OnLinkClickEvent;
389
390
  // It is necessary to allow adding a timeline marker wherever a docshell
391
  // instance is available. This operation happens frequently and needs to
392
  // be very fast, so instead of using a Map or having to search for some
393
  // docshell-specific markers storage, a pointer to an `ObservedDocShell` is
394
  // is stored on docshells directly.
395
  friend void mozilla::TimelineConsumers::AddConsumer(nsDocShell*);
396
  friend void mozilla::TimelineConsumers::RemoveConsumer(nsDocShell*);
397
  friend void mozilla::TimelineConsumers::AddMarkerForDocShell(
398
    nsDocShell*, const char*, MarkerTracingType, MarkerStackRequest);
399
  friend void mozilla::TimelineConsumers::AddMarkerForDocShell(
400
    nsDocShell*, const char*, const TimeStamp&, MarkerTracingType,
401
    MarkerStackRequest);
402
  friend void mozilla::TimelineConsumers::AddMarkerForDocShell(
403
    nsDocShell*, UniquePtr<AbstractTimelineMarker>&&);
404
  friend void mozilla::TimelineConsumers::PopMarkers(nsDocShell*,
405
    JSContext*, nsTArray<dom::ProfileTimelineMarker>&);
406
407
  // Security checks to prevent frameset spoofing. See comments at
408
  // implementation sites.
409
  static bool CanAccessItem(nsIDocShellTreeItem* aTargetItem,
410
                            nsIDocShellTreeItem* aAccessingItem,
411
                            bool aConsiderOpener = true);
412
  static bool ValidateOrigin(nsIDocShellTreeItem* aOriginTreeItem,
413
                             nsIDocShellTreeItem* aTargetTreeItem);
414
415
  static inline uint32_t PRTimeToSeconds(PRTime aTimeUsec)
416
  {
417
    PRTime usecPerSec = PR_USEC_PER_SEC;
418
    return uint32_t(aTimeUsec /= usecPerSec);
419
  }
420
421
  static const nsCString FrameTypeToString(uint32_t aFrameType)
422
  {
423
    switch (aFrameType) {
424
      case FRAME_TYPE_BROWSER:
425
        return NS_LITERAL_CSTRING("browser");
426
      case FRAME_TYPE_REGULAR:
427
        return NS_LITERAL_CSTRING("regular");
428
      default:
429
        NS_ERROR("Unknown frame type");
430
        return EmptyCString();
431
    }
432
  }
433
434
  virtual ~nsDocShell();
435
436
  //
437
  // nsDocLoader
438
  //
439
440
  virtual void DestroyChildren() override;
441
442
  // Overridden from nsDocLoader, this provides more information than the
443
  // normal OnStateChange with flags STATE_REDIRECTING
444
  virtual void OnRedirectStateChange(nsIChannel* aOldChannel,
445
                                     nsIChannel* aNewChannel,
446
                                     uint32_t aRedirectFlags,
447
                                     uint32_t aStateFlags) override;
448
449
  // Override the parent setter from nsDocLoader
450
  virtual nsresult SetDocLoaderParent(nsDocLoader* aLoader) override;
451
452
  //
453
  // Content Viewer Management
454
  //
455
456
  nsresult EnsureContentViewer();
457
458
  // aPrincipal can be passed in if the caller wants. If null is
459
  // passed in, the about:blank principal will end up being used.
460
  nsresult CreateAboutBlankContentViewer(nsIPrincipal* aPrincipal,
461
                                         nsIURI* aBaseURI,
462
                                         bool aTryToSaveOldPresentation = true,
463
                                         bool aCheckPermitUnload = true);
464
465
  nsresult CreateContentViewer(const nsACString& aContentType,
466
                               nsIRequest* aRequest,
467
                               nsIStreamListener** aContentHandler);
468
469
  nsresult NewContentViewerObj(const nsACString& aContentType,
470
                               nsIRequest* aRequest, nsILoadGroup* aLoadGroup,
471
                               nsIStreamListener** aContentHandler,
472
                               nsIContentViewer** aViewer);
473
474
  nsresult SetupNewViewer(nsIContentViewer* aNewViewer);
475
476
  //
477
  // Session History
478
  //
479
480
  bool ShouldAddToSessionHistory(nsIURI* aURI, nsIChannel* aChannel);
481
482
  // Either aChannel or aOwner must be null. If aChannel is
483
  // present, the owner should be gotten from it.
484
  // If aCloneChildren is true, then our current session history's
485
  // children will be cloned onto the new entry. This should be
486
  // used when we aren't actually changing the document while adding
487
  // the new session history entry.
488
489
  nsresult AddToSessionHistory(nsIURI* aURI, nsIChannel* aChannel,
490
                               nsIPrincipal* aTriggeringPrincipal,
491
                               nsIPrincipal* aPrincipalToInherit,
492
                               bool aCloneChildren,
493
                               nsISHEntry** aNewEntry);
494
495
  nsresult AddChildSHEntryToParent(nsISHEntry* aNewEntry, int32_t aChildOffset,
496
                                   bool aCloneChildren);
497
498
  nsresult AddChildSHEntryInternal(nsISHEntry* aCloneRef, nsISHEntry* aNewEntry,
499
                                   int32_t aChildOffset, uint32_t aLoadType,
500
                                   bool aCloneChildren);
501
502
  // Call this method to swap in a new history entry to m[OL]SHE, rather than
503
  // setting it directly. This completes the navigation in all docshells
504
  // in the case of a subframe navigation.
505
  void SetHistoryEntry(nsCOMPtr<nsISHEntry>* aPtr, nsISHEntry* aEntry);
506
507
  //
508
  // URI Load
509
  //
510
511
  // Actually open a channel and perform a URI load. Callers need to pass a
512
  // non-null aTriggeringPrincipal which initiated the URI load. Please note
513
  // that aTriggeringPrincipal will be used for performing security checks.
514
  // If the argument aURI is provided by the web, then please do not pass a
515
  // SystemPrincipal as the triggeringPrincipal. If principalToInherit is
516
  // null, then no inheritance of any sort will happen and the load will
517
  // get a principal based on the URI being loaded.
518
  // If aSrcdoc is not void, the load will be considered as a srcdoc load,
519
  // and the contents of aSrcdoc will be loaded instead of aURI.
520
  // aOriginalURI will be set as the originalURI on the channel that does the
521
  // load. If aOriginalURI is null, aURI will be set as the originalURI.
522
  // If aLoadReplace is true, LOAD_REPLACE flag will be set to the nsIChannel.
523
  nsresult DoURILoad(nsIURI* aURI,
524
                     nsIURI* aOriginalURI,
525
                     mozilla::Maybe<nsCOMPtr<nsIURI>> const& aResultPrincipalURI,
526
                     bool aKeepResultPrincipalURIIfSet,
527
                     bool aLoadReplace,
528
                     bool aLoadFromExternal,
529
                     bool aForceAllowDataURI,
530
                     bool aOriginalFrameSrc,
531
                     nsIURI* aReferrer,
532
                     bool aSendReferrer,
533
                     uint32_t aReferrerPolicy,
534
                     nsIPrincipal* aTriggeringPrincipal,
535
                     nsIPrincipal* aPrincipalToInherit,
536
                     const char* aTypeHint,
537
                     const nsAString& aFileName,
538
                     nsIInputStream* aPostData,
539
                     nsIInputStream* aHeadersData,
540
                     bool aFirstParty,
541
                     nsIDocShell** aDocShell,
542
                     nsIRequest** aRequest,
543
                     bool aIsNewWindowTarget,
544
                     bool aBypassClassifier,
545
                     bool aForceAllowCookies,
546
                     const nsAString& aSrcdoc,
547
                     nsIURI* aBaseURI,
548
                     nsContentPolicyType aContentPolicyType);
549
550
  nsresult AddHeadersToChannel(nsIInputStream* aHeadersData,
551
                               nsIChannel* aChannel);
552
553
  nsresult DoChannelLoad(nsIChannel* aChannel,
554
                         nsIURILoader* aURILoader,
555
                         bool aBypassClassifier);
556
557
  nsresult ScrollToAnchor(bool aCurHasRef,
558
                          bool aNewHasRef,
559
                          nsACString& aNewHash,
560
                          uint32_t aLoadType);
561
562
  // Returns true if would have called FireOnLocationChange,
563
  // but did not because aFireOnLocationChange was false on entry.
564
  // In this case it is the caller's responsibility to ensure
565
  // FireOnLocationChange is called.
566
  // In all other cases false is returned.
567
  bool OnLoadingSite(nsIChannel* aChannel,
568
                     bool aFireOnLocationChange,
569
                     bool aAddToGlobalHistory = true);
570
571
  // Returns true if would have called FireOnLocationChange,
572
  // but did not because aFireOnLocationChange was false on entry.
573
  // In this case it is the caller's responsibility to ensure
574
  // FireOnLocationChange is called.
575
  // In all other cases false is returned.
576
  // Either aChannel or aTriggeringPrincipal must be null. If aChannel is
577
  // present, the owner should be gotten from it.
578
  // If OnNewURI calls AddToSessionHistory, it will pass its
579
  // aCloneSHChildren argument as aCloneChildren.
580
  bool OnNewURI(nsIURI* aURI, nsIChannel* aChannel,
581
                nsIPrincipal* aTriggeringPrincipal,
582
                nsIPrincipal* aPrincipalToInherit,
583
                uint32_t aLoadType,
584
                bool aFireOnLocationChange,
585
                bool aAddToGlobalHistory,
586
                bool aCloneSHChildren);
587
588
  // Helper method that is called when a new document (including any
589
  // sub-documents - ie. frames) has been completely loaded.
590
  nsresult EndPageLoad(nsIWebProgress* aProgress,
591
                       nsIChannel* aChannel,
592
                       nsresult aResult);
593
594
595
  // Builds an error page URI (e.g. about:neterror?etc) for the given aURI
596
  // and displays it via the LoadErrorPage() overload below.
597
  nsresult LoadErrorPage(nsIURI* aURI, const char16_t* aURL,
598
                         const char* aErrorPage,
599
                         const char* aErrorType,
600
                         const char16_t* aDescription,
601
                         const char* aCSSClass,
602
                         nsIChannel* aFailedChannel);
603
604
  // This method directly loads aErrorURI as an error page. aFailedURI and aFailedChannel
605
  // come from DisplayLoadError() or the LoadErrorPage() overload above.
606
  nsresult LoadErrorPage(nsIURI* aErrorURI, nsIURI* aFailedURI, nsIChannel* aFailedChannel);
607
608
  bool DisplayLoadError(nsresult aError, nsIURI* aURI, const char16_t* aURL,
609
                        nsIChannel* aFailedChannel)
610
  {
611
    bool didDisplayLoadError = false;
612
    DisplayLoadError(aError, aURI, aURL, aFailedChannel, &didDisplayLoadError);
613
    return didDisplayLoadError;
614
  }
615
616
  //
617
  // Uncategorized
618
  //
619
620
  // Get the principal that we'll set on the channel if we're inheriting. If
621
  // aConsiderCurrentDocument is true, we try to use the current document if
622
  // at all possible. If that fails, we fall back on the parent document.
623
  // If that fails too, we force creation of a content viewer and use the
624
  // resulting principal. If aConsiderCurrentDocument is false, we just look
625
  // at the parent.
626
  nsIPrincipal* GetInheritedPrincipal(bool aConsiderCurrentDocument);
627
628
  nsresult CreatePrincipalFromReferrer(nsIURI* aReferrer,
629
                                       nsIPrincipal** aResult);
630
631
  /**
632
   * Helper function that determines if channel is an HTTP POST.
633
   *
634
   * @param aChannel
635
   *        The channel to test
636
   *
637
   * @return True iff channel is an HTTP post.
638
   */
639
  bool ChannelIsPost(nsIChannel* aChannel);
640
641
  /**
642
   * Helper function that finds the last URI and its transition flags for a
643
   * channel.
644
   *
645
   * This method first checks the channel's property bag to see if previous
646
   * info has been saved. If not, it gives back the referrer of the channel.
647
   *
648
   * @param aChannel
649
   *        The channel we are transitioning to
650
   * @param aURI
651
   *        Output parameter with the previous URI, not addref'd
652
   * @param aChannelRedirectFlags
653
   *        If a redirect, output parameter with the previous redirect flags
654
   *        from nsIChannelEventSink
655
   */
656
  void ExtractLastVisit(nsIChannel* aChannel,
657
                        nsIURI** aURI,
658
                        uint32_t* aChannelRedirectFlags);
659
660
  /**
661
   * Helper function that caches a URI and a transition for saving later.
662
   *
663
   * @param aChannel
664
   *        Channel that will have these properties saved
665
   * @param aURI
666
   *        The URI to save for later
667
   * @param aChannelRedirectFlags
668
   *        The nsIChannelEventSink redirect flags to save for later
669
   */
670
  void SaveLastVisit(nsIChannel* aChannel,
671
                     nsIURI* aURI,
672
                     uint32_t aChannelRedirectFlags);
673
674
  /**
675
   * Helper function for adding a URI visit using IHistory.
676
   *
677
   * The IHistory API maintains chains of visits, tracking both HTTP referrers
678
   * and redirects for a user session. VisitURI requires the current URI and
679
   * the previous URI in the chain.
680
   *
681
   * Visits can be saved either during a redirect or when the request has
682
   * reached its final destination. The previous URI in the visit may be
683
   * from another redirect or it may be the referrer.
684
   *
685
   * @pre aURI is not null.
686
   *
687
   * @param aURI
688
   *        The URI that was just visited
689
   * @param aReferrerURI
690
   *        The referrer URI of this request
691
   * @param aPreviousURI
692
   *        The previous URI of this visit (may be the same as aReferrerURI)
693
   * @param aChannelRedirectFlags
694
   *        For redirects, the redirect flags from nsIChannelEventSink
695
   *        (0 otherwise)
696
   * @param aResponseStatus
697
   *        For HTTP channels, the response code (0 otherwise).
698
   */
699
  void AddURIVisit(nsIURI* aURI,
700
                   nsIURI* aReferrerURI,
701
                   nsIURI* aPreviousURI,
702
                   uint32_t aChannelRedirectFlags,
703
                   uint32_t aResponseStatus = 0);
704
705
  // Sets the current document's current state object to the given SHEntry's
706
  // state object. The current state object is eventually given to the page
707
  // in the PopState event.
708
  nsresult SetDocCurrentStateObj(nsISHEntry* aShEntry);
709
710
  // Returns true if would have called FireOnLocationChange,
711
  // but did not because aFireOnLocationChange was false on entry.
712
  // In this case it is the caller's responsibility to ensure
713
  // FireOnLocationChange is called.
714
  // In all other cases false is returned.
715
  bool SetCurrentURI(nsIURI* aURI, nsIRequest* aRequest,
716
                     bool aFireOnLocationChange,
717
                     uint32_t aLocationFlags);
718
719
  // The following methods deal with saving and restoring content viewers
720
  // in session history.
721
722
  // mContentViewer points to the current content viewer associated with
723
  // this docshell. When loading a new document, the content viewer is
724
  // either destroyed or stored into a session history entry. To make sure
725
  // that destruction happens in a controlled fashion, a given content viewer
726
  // is always owned in exactly one of these ways:
727
  //   1) The content viewer is active and owned by a docshell's
728
  //      mContentViewer.
729
  //   2) The content viewer is still being displayed while we begin loading
730
  //      a new document. The content viewer is owned by the _new_
731
  //      content viewer's mPreviousViewer, and has a pointer to the
732
  //      nsISHEntry where it will eventually be stored. The content viewer
733
  //      has been close()d by the docshell, which detaches the document from
734
  //      the window object.
735
  //   3) The content viewer is cached in session history. The nsISHEntry
736
  //      has the only owning reference to the content viewer. The viewer
737
  //      has released its nsISHEntry pointer to prevent circular ownership.
738
  //
739
  // When restoring a content viewer from session history, open() is called
740
  // to reattach the document to the window object. The content viewer is
741
  // then placed into mContentViewer and removed from the history entry.
742
  // (mContentViewer is put into session history as described above, if
743
  // applicable).
744
745
  // Determines whether we can safely cache the current mContentViewer in
746
  // session history. This checks a number of factors such as cache policy,
747
  // pending requests, and unload handlers.
748
  // |aLoadType| should be the load type that will replace the current
749
  // presentation. |aNewRequest| should be the request for the document to
750
  // be loaded in place of the current document, or null if such a request
751
  // has not been created yet. |aNewDocument| should be the document that will
752
  // replace the current document.
753
  bool CanSavePresentation(uint32_t aLoadType,
754
                           nsIRequest* aNewRequest,
755
                           nsIDocument* aNewDocument);
756
757
  // Captures the state of the supporting elements of the presentation
758
  // (the "window" object, docshell tree, meta-refresh loads, and security
759
  // state) and stores them on |mOSHE|.
760
  nsresult CaptureState();
761
762
  // Begin the toplevel restore process for |aSHEntry|.
763
  // This simulates a channel open, and defers the real work until
764
  // RestoreFromHistory is called from a PLEvent.
765
  nsresult RestorePresentation(nsISHEntry* aSHEntry, bool* aRestoring);
766
767
  // Call BeginRestore(nullptr, false) for each child of this shell.
768
  nsresult BeginRestoreChildren();
769
770
  // Method to get our current position and size without flushing
771
  void DoGetPositionAndSize(int32_t* aX, int32_t* aY, int32_t* aWidth,
772
                            int32_t* aHeight);
773
774
  // Call this when a URI load is handed to us (via OnLinkClick or
775
  // InternalLoad). This makes sure that we're not inside unload, or that if
776
  // we are it's still OK to load this URI.
777
  bool IsOKToLoadURI(nsIURI* aURI);
778
779
  // helpers for executing commands
780
  nsresult GetControllerForCommand(const char* aCommand,
781
                                   nsIController** aResult);
782
783
  // Possibly create a ClientSource object to represent an initial about:blank
784
  // window that has not been allocated yet.  Normally we try not to create
785
  // this about:blank window until something calls GetDocument().  We still need
786
  // the ClientSource to exist for this conceptual window, though.
787
  //
788
  // The ClientSource is created with the given principal if specified.  If
789
  // the principal is not provided we will attempt to inherit it when we
790
  // are sure it will match what the real about:blank window principal
791
  // would have been.  There are some corner cases where we cannot easily
792
  // determine the correct principal and will not create the ClientSource.
793
  // In these cases the initial about:blank will appear to not exist until
794
  // its real document and window are created.
795
  void MaybeCreateInitialClientSource(nsIPrincipal* aPrincipal = nullptr);
796
797
  // Determine if a service worker is allowed to control a window in this
798
  // docshell with the given URL.  If there are any reasons it should not,
799
  // this will return false.  If true is returned then the window *may* be
800
  // controlled.  The caller must still consult either the parent controller
801
  // or the ServiceWorkerManager to determine if a service worker should
802
  // actually control the window.
803
  bool ServiceWorkerAllowedToControlWindow(nsIPrincipal* aPrincipal,
804
                                           nsIURI* aURI);
805
806
  // Return the ClientInfo for the initial about:blank window, if it exists
807
  // or we have speculatively created a ClientSource in
808
  // MaybeCreateInitialClientSource().  This can return a ClientInfo object
809
  // even if GetExtantDoc() returns nullptr.
810
  mozilla::Maybe<mozilla::dom::ClientInfo> GetInitialClientInfo() const;
811
812
  /**
813
   * Initializes mTiming if it isn't yet.
814
   * After calling this, mTiming is non-null. This method returns true if the
815
   * initialization of the Timing can be reset (basically this is true if a new
816
   * Timing object is created).
817
   * In case the loading is aborted, MaybeResetInitTiming() can be called
818
   * passing the return value of MaybeInitTiming(): if it's possible to reset
819
   * the Timing, this method will do it.
820
   */
821
  MOZ_MUST_USE bool MaybeInitTiming();
822
  void MaybeResetInitTiming(bool aReset);
823
824
  // Separate function to do the actual name (i.e. not _top, _self etc.)
825
  // searching for FindItemWithName.
826
  nsresult DoFindItemWithName(const nsAString& aName,
827
                              nsIDocShellTreeItem* aRequestor,
828
                              nsIDocShellTreeItem* aOriginalRequestor,
829
                              bool aSkipTabGroup,
830
                              nsIDocShellTreeItem** aResult);
831
832
  // Convenience method for getting our parent docshell. Can return null
833
  already_AddRefed<nsDocShell> GetParentDocshell();
834
835
  // Helper assertion to enforce that mInPrivateBrowsing is in sync with
836
  // OriginAttributes.mPrivateBrowsingId
837
  void AssertOriginAttributesMatchPrivateBrowsing();
838
839
  // Notify consumers of a search being loaded through the observer service:
840
  void MaybeNotifyKeywordSearchLoading(const nsString& aProvider,
841
                                       const nsString& aKeyword);
842
843
  // Internal implementation of nsIDocShell::FirePageHideNotification.
844
  // If aSkipCheckingDynEntries is true, it will not try to remove dynamic
845
  // subframe entries. This is to avoid redundant RemoveDynEntries calls in all
846
  // children docshells.
847
  void FirePageHideNotificationInternal(bool aIsUnload,
848
                                        bool aSkipCheckingDynEntries);
849
850
  // Dispatch a runnable to the TabGroup associated to this docshell.
851
  nsresult DispatchToTabGroup(mozilla::TaskCategory aCategory,
852
                              already_AddRefed<nsIRunnable>&& aRunnable);
853
854
  void SetupReferrerFromChannel(nsIChannel* aChannel);
855
  void SetReferrerURI(nsIURI* aURI);
856
  void SetReferrerPolicy(uint32_t aReferrerPolicy);
857
  void ReattachEditorToWindow(nsISHEntry* aSHEntry);
858
  void RecomputeCanExecuteScripts();
859
  void ClearFrameHistory(nsISHEntry* aEntry);
860
  void UpdateGlobalHistoryTitle(nsIURI* aURI);
861
  bool IsFrame();
862
  bool CanSetOriginAttributes();
863
  bool ShouldBlockLoadingForBackButton();
864
  bool ShouldDiscardLayoutState(nsIHttpChannel* aChannel);
865
  bool HasUnloadedParent();
866
  bool JustStartedNetworkLoad();
867
  bool IsPrintingOrPP(bool aDisplayErrorDialog = true);
868
  bool IsNavigationAllowed(bool aDisplayPrintErrorDialog = true,
869
                           bool aCheckIfUnloadFired = true);
870
  uint32_t GetInheritedFrameType();
871
  nsIScrollableFrame* GetRootScrollFrame();
872
  nsIDOMStorageManager* TopSessionStorageManager();
873
  nsIChannel* GetCurrentDocChannel();
874
  nsresult EnsureScriptEnvironment();
875
  nsresult EnsureEditorData();
876
  nsresult EnsureTransferableHookData();
877
  nsresult EnsureFind();
878
  nsresult EnsureCommandHandler();
879
  nsresult RefreshURIFromQueue();
880
  nsresult Embed(nsIContentViewer* aContentViewer,
881
                 const char* aCommand, nsISupports* aExtraInfo);
882
  nsresult GetEldestPresContext(nsPresContext** aPresContext);
883
  nsresult CheckLoadingPermissions();
884
  nsresult PersistLayoutHistoryState();
885
  nsresult LoadHistoryEntry(nsISHEntry* aEntry, uint32_t aLoadType);
886
  nsresult SetBaseUrlForWyciwyg(nsIContentViewer* aContentViewer);
887
  nsresult GetHttpChannel(nsIChannel* aChannel, nsIHttpChannel** aReturn);
888
  nsresult ConfirmRepost(bool* aRepost);
889
  nsresult GetPromptAndStringBundle(nsIPrompt** aPrompt,
890
                                    nsIStringBundle** aStringBundle);
891
  nsresult GetCurScrollPos(int32_t aScrollOrientation, int32_t* aCurPos);
892
  nsresult SetCurScrollPosEx(int32_t aCurHorizontalPos,
893
                             int32_t aCurVerticalPos);
894
895
  already_AddRefed<mozilla::dom::ChildSHistory> GetRootSessionHistory();
896
897
  inline bool UseErrorPages()
898
  {
899
    return (mObserveErrorPages ? sUseErrorPages : mUseErrorPages);
900
  }
901
902
  bool CSSErrorReportingEnabled() const
903
0
  {
904
0
    return mCSSErrorReportingEnabled;
905
0
  }
906
907
private: // data members
908
  static nsIURIFixup* sURIFixup;
909
910
  // Cached value of the "browser.xul.error_pages.enabled" preference.
911
  static bool sUseErrorPages;
912
913
#ifdef DEBUG
914
  // We're counting the number of |nsDocShells| to help find leaks
915
  static unsigned long gNumberOfDocShells;
916
#endif /* DEBUG */
917
918
  nsID mHistoryID;
919
  nsString mTitle;
920
  nsString mCustomUserAgent;
921
  nsCString mOriginalUriString;
922
  nsWeakPtr mOnePermittedSandboxedNavigator;
923
  nsWeakPtr mOpener;
924
  nsTObserverArray<nsWeakPtr> mPrivacyObservers;
925
  nsTObserverArray<nsWeakPtr> mReflowObservers;
926
  nsTObserverArray<nsWeakPtr> mScrollObservers;
927
  mozilla::OriginAttributes mOriginAttributes;
928
  mozilla::UniquePtr<mozilla::dom::ClientSource> mInitialClientSource;
929
  nsCOMPtr<nsINetworkInterceptController> mInterceptController;
930
  RefPtr<nsDOMNavigationTiming> mTiming;
931
  RefPtr<nsDSURIContentListener> mContentListener;
932
  RefPtr<nsGlobalWindowOuter> mScriptGlobal;
933
  nsCOMPtr<nsIPrincipal> mParentCharsetPrincipal;
934
  nsCOMPtr<nsILoadURIDelegate> mLoadURIDelegate;
935
  nsCOMPtr<nsIMutableArray> mRefreshURIList;
936
  nsCOMPtr<nsIMutableArray> mSavedRefreshURIList;
937
  nsCOMPtr<nsIDOMStorageManager> mSessionStorageManager;
938
  nsCOMPtr<nsIContentViewer> mContentViewer;
939
  nsCOMPtr<nsIWidget> mParentWidget;
940
  RefPtr<mozilla::dom::ChildSHistory> mSessionHistory;
941
  nsCOMPtr<nsIWebBrowserFind> mFind;
942
  nsCOMPtr<nsICommandManager> mCommandManager;
943
  RefPtr<mozilla::dom::BrowsingContext> mBrowsingContext;
944
945
  // Dimensions of the docshell
946
  nsIntRect mBounds;
947
948
  /**
949
   * Content-Type Hint of the most-recently initiated load. Used for
950
   * session history entries.
951
   */
952
  nsCString mContentTypeHint;
953
954
  // An observed docshell wrapper is created when recording markers is enabled.
955
  mozilla::UniquePtr<mozilla::ObservedDocShell> mObserved;
956
957
  // mCurrentURI should be marked immutable on set if possible.
958
  nsCOMPtr<nsIURI> mCurrentURI;
959
  nsCOMPtr<nsIURI> mReferrerURI;
960
961
  // Reference to the SHEntry for this docshell until the page is destroyed.
962
  // Somebody give me better name
963
  nsCOMPtr<nsISHEntry> mOSHE;
964
965
  // Reference to the SHEntry for this docshell until the page is loaded
966
  // Somebody give me better name.
967
  // If mLSHE is non-null, non-pushState subframe loads don't create separate
968
  // root history entries. That is, frames loaded during the parent page
969
  // load don't generate history entries the way frame navigation after the
970
  // parent has loaded does. (This isn't the only purpose of mLSHE.)
971
  nsCOMPtr<nsISHEntry> mLSHE;
972
973
  // Holds a weak pointer to a RestorePresentationEvent object if any that
974
  // holds a weak pointer back to us. We use this pointer to possibly revoke
975
  // the event whenever necessary.
976
  nsRevocableEventPtr<RestorePresentationEvent> mRestorePresentationEvent;
977
978
  // Editor data, if this document is designMode or contentEditable.
979
  nsAutoPtr<nsDocShellEditorData> mEditorData;
980
981
  // Secure browser UI object
982
  nsCOMPtr<nsISecureBrowserUI> mSecurityUI;
983
984
  // The URI we're currently loading. This is only relevant during the
985
  // firing of a pagehide/unload. The caller of FirePageHideNotification()
986
  // is responsible for setting it and unsetting it. It may be null if the
987
  // pagehide/unload is happening for some reason other than just loading a
988
  // new URI.
989
  nsCOMPtr<nsIURI> mLoadingURI;
990
991
  // Our list of ancestor principals.
992
  nsTArray<nsCOMPtr<nsIPrincipal>> mAncestorPrincipals;
993
994
  // Our list of ancestor outerWindowIDs.
995
  nsTArray<uint64_t> mAncestorOuterWindowIDs;
996
997
  // Set in LoadErrorPage from the method argument and used later
998
  // in CreateContentViewer. We have to delay an shistory entry creation
999
  // for which these objects are needed.
1000
  nsCOMPtr<nsIURI> mFailedURI;
1001
  nsCOMPtr<nsIChannel> mFailedChannel;
1002
1003
  // Set in DoURILoad when either the LOAD_RELOAD_ALLOW_MIXED_CONTENT flag or
1004
  // the LOAD_NORMAL_ALLOW_MIXED_CONTENT flag is set.
1005
  // Checked in nsMixedContentBlocker, to see if the channels match.
1006
  nsCOMPtr<nsIChannel> mMixedContentChannel;
1007
1008
  mozilla::UniquePtr<mozilla::gfx::Matrix5x4> mColorMatrix;
1009
1010
  const mozilla::Encoding* mForcedCharset;
1011
  const mozilla::Encoding* mParentCharset;
1012
1013
  // WEAK REFERENCES BELOW HERE.
1014
  // Note these are intentionally not addrefd. Doing so will create a cycle.
1015
  // For that reasons don't use nsCOMPtr.
1016
1017
  nsIDocShellTreeOwner* mTreeOwner; // Weak Reference
1018
  mozilla::dom::EventTarget* mChromeEventHandler; // Weak Reference
1019
1020
  nsIntPoint mDefaultScrollbarPref; // persistent across doc loads
1021
1022
  eCharsetReloadState mCharsetReloadState;
1023
1024
  mozilla::hal::ScreenOrientation mOrientationLock;
1025
1026
  int32_t mParentCharsetSource;
1027
  int32_t mMarginWidth;
1028
  int32_t mMarginHeight;
1029
1030
  // This can either be a content docshell or a chrome docshell. After
1031
  // Create() is called, the type is not expected to change.
1032
  int32_t mItemType;
1033
1034
  // Index into the nsISHEntry array, indicating the previous and current
1035
  // entry at the time that this DocShell begins to load. Consequently
1036
  // root docshell's indices can differ from child docshells'.
1037
  int32_t mPreviousEntryIndex;
1038
  int32_t mLoadedEntryIndex;
1039
1040
  // Offset in the parent's child list.
1041
  // -1 if the docshell is added dynamically to the parent shell.
1042
  int32_t mChildOffset;
1043
1044
  uint32_t mSandboxFlags;
1045
  uint32_t mBusyFlags;
1046
  uint32_t mAppType;
1047
  uint32_t mLoadType;
1048
  uint32_t mDefaultLoadFlags;
1049
  uint32_t mReferrerPolicy;
1050
  uint32_t mFailedLoadType;
1051
1052
  // Are we a regular frame, a browser frame, or an app frame?
1053
  uint32_t mFrameType;
1054
1055
  // This represents the state of private browsing in the docshell.
1056
  // Currently treated as a binary value: 1 - in private mode, 0 - not private mode
1057
  // On content docshells mPrivateBrowsingId == mOriginAttributes.mPrivateBrowsingId
1058
  // On chrome docshells this value will be set, but not have the corresponding
1059
  // origin attribute set.
1060
  uint32_t mPrivateBrowsingId;
1061
1062
  // This represents the CSS display-mode we are currently using.
1063
  // It can be any of the following values from nsIDocShell.idl:
1064
  //
1065
  // DISPLAY_MODE_BROWSER = 0
1066
  // DISPLAY_MODE_MINIMAL_UI = 1
1067
  // DISPLAY_MODE_STANDALONE = 2
1068
  // DISPLAY_MODE_FULLSCREEN = 3
1069
  //
1070
  // This is mostly used for media queries. The integer values above
1071
  // match those used in nsStyleConsts.h
1072
  uint32_t mDisplayMode;
1073
1074
  // A depth count of how many times NotifyRunToCompletionStart
1075
  // has been called without a matching NotifyRunToCompletionStop.
1076
  uint32_t mJSRunToCompletionDepth;
1077
1078
  // Whether or not touch events are overridden. Possible values are defined
1079
  // as constants in the nsIDocShell.idl file.
1080
  uint32_t mTouchEventsOverride;
1081
1082
  // mFullscreenAllowed stores how we determine whether fullscreen is allowed
1083
  // when GetFullscreenAllowed() is called. Fullscreen is allowed in a
1084
  // docshell when all containing iframes have the allowfullscreen
1085
  // attribute set to true. When mFullscreenAllowed is CHECK_ATTRIBUTES
1086
  // we check this docshell's containing frame for the allowfullscreen
1087
  // attribute, and recurse onto the parent docshell to ensure all containing
1088
  // frames also have the allowfullscreen attribute. If we find an ancestor
1089
  // docshell with mFullscreenAllowed not equal to CHECK_ATTRIBUTES, we've
1090
  // reached a content boundary, and mFullscreenAllowed denotes whether the
1091
  // parent across the content boundary has allowfullscreen=true in all its
1092
  // containing iframes. mFullscreenAllowed defaults to CHECK_ATTRIBUTES and
1093
  // is set otherwise when docshells which are content boundaries are created.
1094
  enum FullscreenAllowedState : uint8_t
1095
  {
1096
    CHECK_ATTRIBUTES,
1097
    PARENT_ALLOWS,
1098
    PARENT_PROHIBITS
1099
  };
1100
  FullscreenAllowedState mFullscreenAllowed;
1101
1102
  // The following two fields cannot be declared as bit fields
1103
  // because of uses with AutoRestore.
1104
  bool mCreatingDocument; // (should be) debugging only
1105
#ifdef DEBUG
1106
  bool mInEnsureScriptEnv;
1107
#endif
1108
1109
  bool mCreated : 1;
1110
  bool mAllowSubframes : 1;
1111
  bool mAllowPlugins : 1;
1112
  bool mAllowJavascript : 1;
1113
  bool mAllowMetaRedirects : 1;
1114
  bool mAllowImages : 1;
1115
  bool mAllowMedia : 1;
1116
  bool mAllowDNSPrefetch : 1;
1117
  bool mAllowWindowControl : 1;
1118
  bool mAllowContentRetargeting : 1;
1119
  bool mAllowContentRetargetingOnChildren : 1;
1120
  bool mUseErrorPages : 1;
1121
  bool mObserveErrorPages : 1;
1122
  bool mCSSErrorReportingEnabled : 1;
1123
  bool mAllowAuth : 1;
1124
  bool mAllowKeywordFixup : 1;
1125
  bool mIsOffScreenBrowser : 1;
1126
  bool mIsActive : 1;
1127
  bool mDisableMetaRefreshWhenInactive : 1;
1128
  bool mIsAppTab : 1;
1129
  bool mUseGlobalHistory : 1;
1130
  bool mUseRemoteTabs : 1;
1131
  bool mUseTrackingProtection : 1;
1132
  bool mDeviceSizeIsPageSize : 1;
1133
  bool mWindowDraggingAllowed : 1;
1134
  bool mInFrameSwap : 1;
1135
  bool mInheritPrivateBrowsingId : 1;
1136
1137
  // Because scriptability depends on the mAllowJavascript values of our
1138
  // ancestors, we cache the effective scriptability and recompute it when
1139
  // it might have changed;
1140
  bool mCanExecuteScripts : 1;
1141
1142
  // This boolean is set to true right before we fire pagehide and generally
1143
  // unset when we embed a new content viewer. While it's true no navigation
1144
  // is allowed in this docshell.
1145
  bool mFiredUnloadEvent : 1;
1146
1147
  // this flag is for bug #21358. a docshell may load many urls
1148
  // which don't result in new documents being created (i.e. a new
1149
  // content viewer) we want to make sure we don't call a on load
1150
  // event more than once for a given content viewer.
1151
  bool mEODForCurrentDocument : 1;
1152
  bool mURIResultedInDocument : 1;
1153
1154
  bool mIsBeingDestroyed : 1;
1155
1156
  bool mIsExecutingOnLoadHandler : 1;
1157
1158
  // Indicates that a DocShell in this "docshell tree" is printing
1159
  bool mIsPrintingOrPP : 1;
1160
1161
  // Indicates to CreateContentViewer() that it is safe to cache the old
1162
  // presentation of the page, and to SetupNewViewer() that the old viewer
1163
  // should be passed a SHEntry to save itself into.
1164
  bool mSavingOldViewer : 1;
1165
1166
  // @see nsIDocShellHistory::createdDynamically
1167
  bool mDynamicallyCreated : 1;
1168
  bool mAffectPrivateSessionLifetime : 1;
1169
  bool mInvisible : 1;
1170
  bool mHasLoadedNonBlankURI : 1;
1171
1172
  // This flag means that mTiming has been initialized but nulled out.
1173
  // We will check the innerWin's timing before creating a new one
1174
  // in MaybeInitTiming()
1175
  bool mBlankTiming : 1;
1176
};
1177
1178
#endif /* nsDocShell_h__ */