Bug 1760439 [wpt PR 33220] - Implement FedCM permission delegates in content_shell...
[gecko.git] / layout / generic / nsHTMLCanvasFrame.cpp
blob15d62246592d734531c803f7f3013522e40d8212
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/. */
7 /* rendering object for the HTML <canvas> element */
9 #include "nsHTMLCanvasFrame.h"
11 #include "nsGkAtoms.h"
12 #include "mozilla/Assertions.h"
13 #include "mozilla/PresShell.h"
14 #include "mozilla/dom/HTMLCanvasElement.h"
15 #include "mozilla/layers/ImageDataSerializer.h"
16 #include "mozilla/layers/WebRenderBridgeChild.h"
17 #include "mozilla/layers/WebRenderCanvasRenderer.h"
18 #include "mozilla/layers/RenderRootStateManager.h"
19 #include "mozilla/webgpu/CanvasContext.h"
20 #include "nsDisplayList.h"
21 #include "nsLayoutUtils.h"
22 #include "nsStyleUtil.h"
23 #include "Layers.h"
24 #include "ActiveLayerTracker.h"
26 #include <algorithm>
28 using namespace mozilla;
29 using namespace mozilla::dom;
30 using namespace mozilla::layers;
31 using namespace mozilla::gfx;
33 /* Helper for our nsIFrame::GetIntrinsicSize() impl. Takes the result of
34 * "GetCanvasSize()" as a parameter, which may help avoid redundant
35 * indirect calls to GetCanvasSize().
37 * @param aCanvasSizeInPx The canvas's size in CSS pixels, as returned
38 * by GetCanvasSize().
39 * @return The canvas's intrinsic size, as an IntrinsicSize object.
41 static IntrinsicSize IntrinsicSizeFromCanvasSize(
42 const nsIntSize& aCanvasSizeInPx) {
43 return IntrinsicSize(
44 nsPresContext::CSSPixelsToAppUnits(aCanvasSizeInPx.width),
45 nsPresContext::CSSPixelsToAppUnits(aCanvasSizeInPx.height));
48 /* Helper for our nsIFrame::GetIntrinsicRatio() impl. Takes the result of
49 * "GetCanvasSize()" as a parameter, which may help avoid redundant
50 * indirect calls to GetCanvasSize().
52 * @return The canvas's intrinsic ratio.
54 static AspectRatio IntrinsicRatioFromCanvasSize(
55 const nsIntSize& aCanvasSizeInPx) {
56 return AspectRatio::FromSize(aCanvasSizeInPx.width, aCanvasSizeInPx.height);
59 class nsDisplayCanvas final : public nsPaintedDisplayItem {
60 public:
61 nsDisplayCanvas(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame)
62 : nsPaintedDisplayItem(aBuilder, aFrame) {
63 MOZ_COUNT_CTOR(nsDisplayCanvas);
65 MOZ_COUNTED_DTOR_OVERRIDE(nsDisplayCanvas)
67 NS_DISPLAY_DECL_NAME("nsDisplayCanvas", TYPE_CANVAS)
69 virtual nsRegion GetOpaqueRegion(nsDisplayListBuilder* aBuilder,
70 bool* aSnap) const override {
71 *aSnap = false;
72 nsHTMLCanvasFrame* f = static_cast<nsHTMLCanvasFrame*>(Frame());
73 HTMLCanvasElement* canvas = HTMLCanvasElement::FromNode(f->GetContent());
74 nsRegion result;
75 if (canvas->GetIsOpaque()) {
76 // OK, the entire region painted by the canvas is opaque. But what is
77 // that region? It's the canvas's "dest rect" (controlled by the
78 // object-fit/object-position CSS properties), clipped to the container's
79 // content box (which is what GetBounds() returns). So, we grab those
80 // rects and intersect them.
81 nsRect constraintRect = GetBounds(aBuilder, aSnap);
83 // Need intrinsic size & ratio, for ComputeObjectDestRect:
84 nsIntSize canvasSize = f->GetCanvasSize();
85 IntrinsicSize intrinsicSize = IntrinsicSizeFromCanvasSize(canvasSize);
86 AspectRatio intrinsicRatio = IntrinsicRatioFromCanvasSize(canvasSize);
88 const nsRect destRect = nsLayoutUtils::ComputeObjectDestRect(
89 constraintRect, intrinsicSize, intrinsicRatio, f->StylePosition());
90 return nsRegion(destRect.Intersect(constraintRect));
92 return result;
95 virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder,
96 bool* aSnap) const override {
97 *aSnap = true;
98 return Frame()->GetContentRectRelativeToSelf() + ToReferenceFrame();
101 virtual bool CreateWebRenderCommands(
102 mozilla::wr::DisplayListBuilder& aBuilder,
103 wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc,
104 mozilla::layers::RenderRootStateManager* aManager,
105 nsDisplayListBuilder* aDisplayListBuilder) override {
106 HTMLCanvasElement* element =
107 static_cast<HTMLCanvasElement*>(mFrame->GetContent());
108 element->HandlePrintCallback(mFrame->PresContext());
110 if (element->IsOffscreen()) {
111 // If we are offscreen, then we display via an ImageContainer which is
112 // updated asynchronously, likely from a worker thread. There is nothing
113 // to paint until the owner attaches it.
114 RefPtr<ImageContainer> container = element->GetImageContainer();
115 if (container) {
116 nsHTMLCanvasFrame* canvasFrame =
117 static_cast<nsHTMLCanvasFrame*>(mFrame);
118 nsIntSize canvasSizeInPx = canvasFrame->GetCanvasSize();
119 IntrinsicSize intrinsicSize =
120 IntrinsicSizeFromCanvasSize(canvasSizeInPx);
121 AspectRatio intrinsicRatio =
122 IntrinsicRatioFromCanvasSize(canvasSizeInPx);
123 nsRect area =
124 mFrame->GetContentRectRelativeToSelf() + ToReferenceFrame();
125 nsRect dest = nsLayoutUtils::ComputeObjectDestRect(
126 area, intrinsicSize, intrinsicRatio, mFrame->StylePosition());
127 LayoutDeviceRect bounds = LayoutDeviceRect::FromAppUnits(
128 dest, mFrame->PresContext()->AppUnitsPerDevPixel());
129 aManager->CommandBuilder().PushImage(this, container, aBuilder,
130 aResources, aSc, bounds, bounds);
132 return true;
135 switch (element->GetCurrentContextType()) {
136 case CanvasContextType::Canvas2D:
137 case CanvasContextType::WebGL1:
138 case CanvasContextType::WebGL2: {
139 bool isRecycled;
140 RefPtr<WebRenderCanvasData> canvasData =
141 aManager->CommandBuilder()
142 .CreateOrRecycleWebRenderUserData<WebRenderCanvasData>(
143 this, &isRecycled);
144 nsHTMLCanvasFrame* canvasFrame =
145 static_cast<nsHTMLCanvasFrame*>(mFrame);
146 if (!canvasFrame->UpdateWebRenderCanvasData(aDisplayListBuilder,
147 canvasData)) {
148 return true;
150 WebRenderCanvasRendererAsync* data = canvasData->GetCanvasRenderer();
151 MOZ_ASSERT(data);
152 data->UpdateCompositableClient();
154 // Push IFrame for async image pipeline.
155 // XXX Remove this once partial display list update is supported.
157 nsIntSize canvasSizeInPx = data->GetSize();
158 IntrinsicSize intrinsicSize =
159 IntrinsicSizeFromCanvasSize(canvasSizeInPx);
160 AspectRatio intrinsicRatio =
161 IntrinsicRatioFromCanvasSize(canvasSizeInPx);
163 nsRect area =
164 mFrame->GetContentRectRelativeToSelf() + ToReferenceFrame();
165 nsRect dest = nsLayoutUtils::ComputeObjectDestRect(
166 area, intrinsicSize, intrinsicRatio, mFrame->StylePosition());
168 LayoutDeviceRect bounds = LayoutDeviceRect::FromAppUnits(
169 dest, mFrame->PresContext()->AppUnitsPerDevPixel());
171 // We don't push a stacking context for this async image pipeline here.
172 // Instead, we do it inside the iframe that hosts the image. As a
173 // result, a bunch of the calculations normally done as part of that
174 // stacking context need to be done manually and pushed over to the
175 // parent side, where it will be done when we build the display list for
176 // the iframe. That happens in WebRenderCompositableHolder.
178 wr::LayoutRect r = wr::ToLayoutRect(bounds);
179 aBuilder.PushIFrame(r, !BackfaceIsHidden(), data->GetPipelineId().ref(),
180 /*ignoreMissingPipelines*/ false);
182 LayoutDeviceRect scBounds(LayoutDevicePoint(0, 0), bounds.Size());
183 auto filter = wr::ToImageRendering(mFrame->UsedImageRendering());
184 auto mixBlendMode = wr::MixBlendMode::Normal;
185 aManager->WrBridge()->AddWebRenderParentCommand(
186 OpUpdateAsyncImagePipeline(data->GetPipelineId().value(), scBounds,
187 VideoInfo::Rotation::kDegree_0, filter,
188 mixBlendMode));
189 break;
191 case CanvasContextType::WebGPU: {
192 nsHTMLCanvasFrame* canvasFrame =
193 static_cast<nsHTMLCanvasFrame*>(mFrame);
194 HTMLCanvasElement* canvasElement =
195 static_cast<HTMLCanvasElement*>(canvasFrame->GetContent());
196 webgpu::CanvasContext* canvasContext =
197 canvasElement->GetWebGPUContext();
199 if (!canvasContext || !canvasContext->mHandle) {
200 return true;
203 nsIntSize canvasSizeInPx = canvasFrame->GetCanvasSize();
204 IntrinsicSize intrinsicSize =
205 IntrinsicSizeFromCanvasSize(canvasSizeInPx);
206 AspectRatio intrinsicRatio =
207 IntrinsicRatioFromCanvasSize(canvasSizeInPx);
208 nsRect area =
209 mFrame->GetContentRectRelativeToSelf() + ToReferenceFrame();
210 nsRect dest = nsLayoutUtils::ComputeObjectDestRect(
211 area, intrinsicSize, intrinsicRatio, mFrame->StylePosition());
212 LayoutDeviceRect bounds = LayoutDeviceRect::FromAppUnits(
213 dest, mFrame->PresContext()->AppUnitsPerDevPixel());
214 aManager->CommandBuilder().PushInProcessImage(
215 this, canvasContext->mHandle, aBuilder, aResources, aSc, bounds);
216 break;
218 case CanvasContextType::ImageBitmap: {
219 nsHTMLCanvasFrame* canvasFrame =
220 static_cast<nsHTMLCanvasFrame*>(mFrame);
221 nsIntSize canvasSizeInPx = canvasFrame->GetCanvasSize();
222 if (canvasSizeInPx.width <= 0 || canvasSizeInPx.height <= 0) {
223 return true;
225 bool isRecycled;
226 RefPtr<WebRenderCanvasData> canvasData =
227 aManager->CommandBuilder()
228 .CreateOrRecycleWebRenderUserData<WebRenderCanvasData>(
229 this, &isRecycled);
230 if (!canvasFrame->UpdateWebRenderCanvasData(aDisplayListBuilder,
231 canvasData)) {
232 canvasData->ClearImageContainer();
233 return true;
236 IntrinsicSize intrinsicSize =
237 IntrinsicSizeFromCanvasSize(canvasSizeInPx);
238 AspectRatio intrinsicRatio =
239 IntrinsicRatioFromCanvasSize(canvasSizeInPx);
241 nsRect area =
242 mFrame->GetContentRectRelativeToSelf() + ToReferenceFrame();
243 nsRect dest = nsLayoutUtils::ComputeObjectDestRect(
244 area, intrinsicSize, intrinsicRatio, mFrame->StylePosition());
246 LayoutDeviceRect bounds = LayoutDeviceRect::FromAppUnits(
247 dest, mFrame->PresContext()->AppUnitsPerDevPixel());
249 aManager->CommandBuilder().PushImage(
250 this, canvasData->GetImageContainer(), aBuilder, aResources, aSc,
251 bounds, bounds);
252 break;
254 case CanvasContextType::NoContext:
255 break;
256 default:
257 MOZ_ASSERT_UNREACHABLE("unknown canvas context type");
259 return true;
262 // FirstContentfulPaint is supposed to ignore "white" canvases. We use
263 // MaybeModified (if GetContext() was called on the canvas) as a standin for
264 // "white"
265 virtual bool IsContentful() const override {
266 nsHTMLCanvasFrame* f = static_cast<nsHTMLCanvasFrame*>(Frame());
267 HTMLCanvasElement* canvas = HTMLCanvasElement::FromNode(f->GetContent());
268 return canvas->MaybeModified();
271 virtual void Paint(nsDisplayListBuilder* aBuilder,
272 gfxContext* aCtx) override {
273 nsHTMLCanvasFrame* f = static_cast<nsHTMLCanvasFrame*>(Frame());
274 HTMLCanvasElement* canvas = HTMLCanvasElement::FromNode(f->GetContent());
276 nsRect area = f->GetContentRectRelativeToSelf() + ToReferenceFrame();
277 nsIntSize canvasSizeInPx = f->GetCanvasSize();
279 nsPresContext* presContext = f->PresContext();
280 canvas->HandlePrintCallback(presContext);
282 if (canvasSizeInPx.width <= 0 || canvasSizeInPx.height <= 0 ||
283 area.IsEmpty()) {
284 return;
287 IntrinsicSize intrinsicSize = IntrinsicSizeFromCanvasSize(canvasSizeInPx);
288 AspectRatio intrinsicRatio = IntrinsicRatioFromCanvasSize(canvasSizeInPx);
290 nsRect dest = nsLayoutUtils::ComputeObjectDestRect(
291 area, intrinsicSize, intrinsicRatio, f->StylePosition());
293 gfxRect destGFXRect = presContext->AppUnitsToGfxUnits(dest);
295 // Transform the canvas into the right place
296 gfxPoint p = destGFXRect.TopLeft();
297 Matrix transform = Matrix::Translation(p.x, p.y);
298 transform.PreScale(destGFXRect.Width() / canvasSizeInPx.width,
299 destGFXRect.Height() / canvasSizeInPx.height);
300 gfxContextMatrixAutoSaveRestore saveMatrix(aCtx);
302 aCtx->SetMatrix(
303 gfxUtils::SnapTransformTranslation(aCtx->CurrentMatrix(), nullptr));
305 if (RefPtr<layers::Image> image = canvas->GetAsImage()) {
306 RefPtr<gfx::SourceSurface> surface = image->GetAsSourceSurface();
307 if (!surface || !surface->IsValid()) {
308 return;
310 gfx::IntSize size = surface->GetSize();
312 transform = gfxUtils::SnapTransform(
313 transform, gfxRect(0, 0, size.width, size.height), nullptr);
314 aCtx->Multiply(transform);
316 aCtx->GetDrawTarget()->FillRect(
317 Rect(0, 0, size.width, size.height),
318 SurfacePattern(surface, ExtendMode::CLAMP, Matrix(),
319 nsLayoutUtils::GetSamplingFilterForFrame(f)));
320 return;
323 if (canvas->IsOffscreen()) {
324 return;
327 RefPtr<CanvasRenderer> renderer = new CanvasRenderer();
328 if (!canvas->InitializeCanvasRenderer(aBuilder, renderer)) {
329 return;
331 renderer->FirePreTransactionCallback();
332 const auto snapshot = renderer->BorrowSnapshot();
333 if (!snapshot) return;
334 const auto& surface = snapshot->mSurf;
336 transform = gfxUtils::SnapTransform(
337 transform, gfxRect(0, 0, canvasSizeInPx.width, canvasSizeInPx.height),
338 nullptr);
340 if (!renderer->YIsDown()) {
341 // y-flip
342 transform.PreTranslate(0.0f, canvasSizeInPx.height).PreScale(1.0f, -1.0f);
344 aCtx->Multiply(transform);
346 aCtx->GetDrawTarget()->FillRect(
347 Rect(0, 0, canvasSizeInPx.width, canvasSizeInPx.height),
348 SurfacePattern(surface, ExtendMode::CLAMP, Matrix(),
349 nsLayoutUtils::GetSamplingFilterForFrame(f)));
351 renderer->FireDidTransactionCallback();
352 renderer->ResetDirty();
356 nsIFrame* NS_NewHTMLCanvasFrame(PresShell* aPresShell, ComputedStyle* aStyle) {
357 return new (aPresShell)
358 nsHTMLCanvasFrame(aStyle, aPresShell->GetPresContext());
361 NS_QUERYFRAME_HEAD(nsHTMLCanvasFrame)
362 NS_QUERYFRAME_ENTRY(nsHTMLCanvasFrame)
363 NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
365 NS_IMPL_FRAMEARENA_HELPERS(nsHTMLCanvasFrame)
367 void nsHTMLCanvasFrame::DestroyFrom(nsIFrame* aDestroyRoot,
368 PostDestroyData& aPostDestroyData) {
369 if (IsPrimaryFrame()) {
370 HTMLCanvasElement::FromNode(*mContent)->ResetPrintCallback();
372 nsContainerFrame::DestroyFrom(aDestroyRoot, aPostDestroyData);
375 nsHTMLCanvasFrame::~nsHTMLCanvasFrame() = default;
377 nsIntSize nsHTMLCanvasFrame::GetCanvasSize() const {
378 nsIntSize size(0, 0);
379 HTMLCanvasElement* canvas = HTMLCanvasElement::FromNodeOrNull(GetContent());
380 if (canvas) {
381 size = canvas->GetSize();
382 MOZ_ASSERT(size.width >= 0 && size.height >= 0,
383 "we should've required <canvas> width/height attrs to be "
384 "unsigned (non-negative) values");
385 } else {
386 MOZ_ASSERT_UNREACHABLE("couldn't get canvas size");
389 return size;
392 /* virtual */
393 nscoord nsHTMLCanvasFrame::GetMinISize(gfxContext* aRenderingContext) {
394 // XXX The caller doesn't account for constraints of the height,
395 // min-height, and max-height properties.
396 bool vertical = GetWritingMode().IsVertical();
397 nscoord result;
398 if (StyleDisplay()->IsContainSize()) {
399 result = 0;
400 } else {
401 result = nsPresContext::CSSPixelsToAppUnits(
402 vertical ? GetCanvasSize().height : GetCanvasSize().width);
404 DISPLAY_MIN_INLINE_SIZE(this, result);
405 return result;
408 /* virtual */
409 nscoord nsHTMLCanvasFrame::GetPrefISize(gfxContext* aRenderingContext) {
410 // XXX The caller doesn't account for constraints of the height,
411 // min-height, and max-height properties.
412 bool vertical = GetWritingMode().IsVertical();
413 nscoord result;
414 if (StyleDisplay()->IsContainSize()) {
415 result = 0;
416 } else {
417 result = nsPresContext::CSSPixelsToAppUnits(
418 vertical ? GetCanvasSize().height : GetCanvasSize().width);
420 DISPLAY_PREF_INLINE_SIZE(this, result);
421 return result;
424 /* virtual */
425 IntrinsicSize nsHTMLCanvasFrame::GetIntrinsicSize() {
426 if (StyleDisplay()->IsContainSize()) {
427 return IntrinsicSize(0, 0);
429 return IntrinsicSizeFromCanvasSize(GetCanvasSize());
432 /* virtual */
433 AspectRatio nsHTMLCanvasFrame::GetIntrinsicRatio() const {
434 if (StyleDisplay()->IsContainSize()) {
435 return AspectRatio();
438 return IntrinsicRatioFromCanvasSize(GetCanvasSize());
441 /* virtual */
442 nsIFrame::SizeComputationResult nsHTMLCanvasFrame::ComputeSize(
443 gfxContext* aRenderingContext, WritingMode aWM, const LogicalSize& aCBSize,
444 nscoord aAvailableISize, const LogicalSize& aMargin,
445 const LogicalSize& aBorderPadding, const StyleSizeOverrides& aSizeOverrides,
446 ComputeSizeFlags aFlags) {
447 return {ComputeSizeWithIntrinsicDimensions(
448 aRenderingContext, aWM, GetIntrinsicSize(), GetAspectRatio(),
449 aCBSize, aMargin, aBorderPadding, aSizeOverrides, aFlags),
450 AspectRatioUsage::None};
453 void nsHTMLCanvasFrame::Reflow(nsPresContext* aPresContext,
454 ReflowOutput& aMetrics,
455 const ReflowInput& aReflowInput,
456 nsReflowStatus& aStatus) {
457 MarkInReflow();
458 DO_GLOBAL_REFLOW_COUNT("nsHTMLCanvasFrame");
459 DISPLAY_REFLOW(aPresContext, this, aReflowInput, aMetrics, aStatus);
460 MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!");
461 NS_FRAME_TRACE(
462 NS_FRAME_TRACE_CALLS,
463 ("enter nsHTMLCanvasFrame::Reflow: availSize=%d,%d",
464 aReflowInput.AvailableWidth(), aReflowInput.AvailableHeight()));
466 MOZ_ASSERT(mState & NS_FRAME_IN_REFLOW, "frame is not in reflow");
468 WritingMode wm = aReflowInput.GetWritingMode();
469 const LogicalSize finalSize = aReflowInput.ComputedSizeWithBorderPadding(wm);
471 aMetrics.SetSize(wm, finalSize);
472 aMetrics.SetOverflowAreasToDesiredBounds();
473 FinishAndStoreOverflow(&aMetrics);
475 // Reflow the single anon block child.
476 nsReflowStatus childStatus;
477 nsIFrame* childFrame = mFrames.FirstChild();
478 WritingMode childWM = childFrame->GetWritingMode();
479 LogicalSize availSize = aReflowInput.ComputedSize(childWM);
480 availSize.BSize(childWM) = NS_UNCONSTRAINEDSIZE;
481 NS_ASSERTION(!childFrame->GetNextSibling(), "HTML canvas should have 1 kid");
482 ReflowOutput childDesiredSize(aReflowInput.GetWritingMode());
483 ReflowInput childReflowInput(aPresContext, aReflowInput, childFrame,
484 availSize);
485 ReflowChild(childFrame, aPresContext, childDesiredSize, childReflowInput, 0,
486 0, ReflowChildFlags::Default, childStatus, nullptr);
487 FinishReflowChild(childFrame, aPresContext, childDesiredSize,
488 &childReflowInput, 0, 0, ReflowChildFlags::Default);
490 NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
491 ("exit nsHTMLCanvasFrame::Reflow: size=%d,%d",
492 aMetrics.ISize(wm), aMetrics.BSize(wm)));
493 NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aMetrics);
496 bool nsHTMLCanvasFrame::UpdateWebRenderCanvasData(
497 nsDisplayListBuilder* aBuilder, WebRenderCanvasData* aCanvasData) {
498 HTMLCanvasElement* element = static_cast<HTMLCanvasElement*>(GetContent());
499 return element->UpdateWebRenderCanvasData(aBuilder, aCanvasData);
502 void nsHTMLCanvasFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
503 const nsDisplayListSet& aLists) {
504 if (!IsVisibleForPainting()) return;
506 DisplayBorderBackgroundOutline(aBuilder, aLists);
508 uint32_t clipFlags =
509 nsStyleUtil::ObjectPropsMightCauseOverflow(StylePosition())
511 : DisplayListClipState::ASSUME_DRAWING_RESTRICTED_TO_CONTENT_RECT;
513 DisplayListClipState::AutoClipContainingBlockDescendantsToContentBox clip(
514 aBuilder, this, clipFlags);
516 aLists.Content()->AppendNewToTop<nsDisplayCanvas>(aBuilder, this);
518 DisplaySelectionOverlay(aBuilder, aLists.Content(),
519 nsISelectionDisplay::DISPLAY_IMAGES);
522 void nsHTMLCanvasFrame::AppendDirectlyOwnedAnonBoxes(
523 nsTArray<OwnedAnonBox>& aResult) {
524 MOZ_ASSERT(mFrames.FirstChild(), "Must have our canvas content anon box");
525 MOZ_ASSERT(!mFrames.FirstChild()->GetNextSibling(),
526 "Must only have our canvas content anon box");
527 aResult.AppendElement(OwnedAnonBox(mFrames.FirstChild()));
530 #ifdef ACCESSIBILITY
531 a11y::AccType nsHTMLCanvasFrame::AccessibleType() {
532 return a11y::eHTMLCanvasType;
534 #endif
536 #ifdef DEBUG_FRAME_DUMP
537 nsresult nsHTMLCanvasFrame::GetFrameName(nsAString& aResult) const {
538 return MakeFrameName(u"HTMLCanvas"_ns, aResult);
540 #endif