Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/layout/generic/nsSubDocumentFrame.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 NSSUBDOCUMENTFRAME_H_
8
#define NSSUBDOCUMENTFRAME_H_
9
10
#include "mozilla/Attributes.h"
11
#include "nsAtomicContainerFrame.h"
12
#include "nsIReflowCallback.h"
13
#include "nsFrameLoader.h"
14
#include "Units.h"
15
16
namespace mozilla {
17
namespace layout {
18
class RenderFrameParent;
19
}
20
}
21
22
/******************************************************************************
23
 * nsSubDocumentFrame
24
 *****************************************************************************/
25
class nsSubDocumentFrame final
26
  : public nsAtomicContainerFrame
27
  , public nsIReflowCallback
28
{
29
public:
30
  NS_DECL_FRAMEARENA_HELPERS(nsSubDocumentFrame)
31
32
  explicit nsSubDocumentFrame(ComputedStyle* aStyle);
33
34
#ifdef DEBUG_FRAME_DUMP
35
  void List(FILE* out = stderr, const char* aPrefix = "", uint32_t aFlags = 0) const override;
36
  nsresult GetFrameName(nsAString& aResult) const override;
37
#endif
38
39
  NS_DECL_QUERYFRAME
40
41
  bool IsFrameOfType(uint32_t aFlags) const override
42
0
  {
43
0
    return nsAtomicContainerFrame::IsFrameOfType(aFlags &
44
0
      ~(nsIFrame::eReplaced |
45
0
        nsIFrame::eReplacedSizing |
46
0
        nsIFrame::eReplacedContainsBlock));
47
0
  }
48
49
  void Init(nsIContent*       aContent,
50
            nsContainerFrame* aParent,
51
            nsIFrame*         aPrevInFlow) override;
52
53
  void DestroyFrom(nsIFrame* aDestructRoot, PostDestroyData& aPostDestroyData) override;
54
55
  nscoord GetMinISize(gfxContext *aRenderingContext) override;
56
  nscoord GetPrefISize(gfxContext *aRenderingContext) override;
57
58
  mozilla::IntrinsicSize GetIntrinsicSize() override;
59
  nsSize  GetIntrinsicRatio() override;
60
61
  mozilla::LogicalSize
62
  ComputeAutoSize(gfxContext*                 aRenderingContext,
63
                  mozilla::WritingMode        aWritingMode,
64
                  const mozilla::LogicalSize& aCBSize,
65
                  nscoord                     aAvailableISize,
66
                  const mozilla::LogicalSize& aMargin,
67
                  const mozilla::LogicalSize& aBorder,
68
                  const mozilla::LogicalSize& aPadding,
69
                  ComputeSizeFlags            aFlags) override;
70
71
  mozilla::LogicalSize
72
  ComputeSize(gfxContext*                 aRenderingContext,
73
              mozilla::WritingMode        aWritingMode,
74
              const mozilla::LogicalSize& aCBSize,
75
              nscoord                     aAvailableISize,
76
              const mozilla::LogicalSize& aMargin,
77
              const mozilla::LogicalSize& aBorder,
78
              const mozilla::LogicalSize& aPadding,
79
              ComputeSizeFlags            aFlags) override;
80
81
  void Reflow(nsPresContext*     aPresContext,
82
              ReflowOutput&      aDesiredSize,
83
              const ReflowInput& aReflowInput,
84
              nsReflowStatus&    aStatus) override;
85
86
  void BuildDisplayList(nsDisplayListBuilder*   aBuilder,
87
                        const nsDisplayListSet& aLists) override;
88
89
  nsresult AttributeChanged(int32_t aNameSpaceID,
90
                            nsAtom* aAttribute,
91
                            int32_t aModType) override;
92
93
  // if the content is "visibility:hidden", then just hide the view
94
  // and all our contents. We don't extend "visibility:hidden" to
95
  // the child content ourselves, since it belongs to a different
96
  // document and CSS doesn't inherit in there.
97
0
  bool SupportsVisibilityHidden() override { return false; }
98
99
#ifdef ACCESSIBILITY
100
  mozilla::a11y::AccType AccessibleType() override;
101
#endif
102
103
  nsIDocShell* GetDocShell();
104
  nsresult BeginSwapDocShells(nsIFrame* aOther);
105
  void EndSwapDocShells(nsIFrame* aOther);
106
  nsView* EnsureInnerView();
107
  nsIFrame* GetSubdocumentRootFrame();
108
  enum {
109
    IGNORE_PAINT_SUPPRESSION = 0x1
110
  };
111
  nsIPresShell* GetSubdocumentPresShellForPainting(uint32_t aFlags);
112
  mozilla::ScreenIntSize GetSubdocumentSize();
113
114
  // nsIReflowCallback
115
  bool ReflowFinished() override;
116
  void ReflowCallbackCanceled() override;
117
118
  bool ShouldClipSubdocument()
119
0
  {
120
0
    nsFrameLoader* frameLoader = FrameLoader();
121
0
    return !frameLoader || frameLoader->ShouldClipSubdocument();
122
0
  }
123
124
  bool ShouldClampScrollPosition()
125
0
  {
126
0
    nsFrameLoader* frameLoader = FrameLoader();
127
0
    return !frameLoader || frameLoader->ShouldClampScrollPosition();
128
0
  }
129
130
  /**
131
   * Return true if pointer event hit-testing should be allowed to target
132
   * content in the subdocument.
133
   */
134
  bool PassPointerEventsToChildren();
135
136
  void MaybeShowViewer()
137
0
  {
138
0
    if (!mDidCreateDoc && !mCallingShow) {
139
0
      ShowViewer();
140
0
    }
141
0
  }
142
143
  mozilla::layout::RenderFrameParent* GetRenderFrameParent() const;
144
145
protected:
146
  friend class AsyncFrameInit;
147
148
  // Helper method to look up the HTML marginwidth & marginheight attributes.
149
  mozilla::CSSIntSize GetMarginAttributes();
150
151
  nsFrameLoader* FrameLoader() const;
152
153
0
  bool IsInline() { return mIsInline; }
154
155
  nscoord GetIntrinsicISize();
156
  nscoord GetIntrinsicBSize();
157
158
  // Show our document viewer. The document viewer is hidden via a script
159
  // runner, so that we can save and restore the presentation if we're
160
  // being reframed.
161
  void ShowViewer();
162
163
  void ClearDisplayItems();
164
165
  /* Obtains the frame we should use for intrinsic size information if we are
166
   * an HTML <object> or <embed>  (a replaced element - not <iframe>)
167
   * and our sub-document has an intrinsic size. The frame returned is the
168
   * frame for the document element of the document we're embedding.
169
   *
170
   * Called "Obtain*" and not "Get*" because of comment on GetDocShell that
171
   * says it should be called ObtainDocShell because of its side effects.
172
   */
173
  nsIFrame* ObtainIntrinsicSizeFrame();
174
175
0
  nsView* GetViewInternal() const override { return mOuterView; }
176
0
  void SetViewInternal(nsView* aView) override { mOuterView = aView; }
177
178
  mutable RefPtr<nsFrameLoader> mFrameLoader;
179
180
  nsView* mOuterView;
181
  nsView* mInnerView;
182
  bool mIsInline;
183
  bool mPostedReflowCallback;
184
  bool mDidCreateDoc;
185
  bool mCallingShow;
186
  WeakFrame mPreviousCaret;
187
};
188
189
#endif /* NSSUBDOCUMENTFRAME_H_ */