author Timothy Guan-tin Chien <timdream@gmail.com>
Mon, 28 Jan 2019 18:24:08 +0000
changeset 513567 c1032d34b5e0e525820446f713e4ad6288ebcb56
parent 505383 6f3709b3878117466168c40affa7bca0b60cf75b
child 549323 16f39b7ca09c5b152aedb88f14abc2f70fbf9b26
permissions -rw-r--r--
Bug 1518932 - Convert menulist to custom element r=paolo This custom element replaces XBL <content> usage by directly prepend the two needed child nodes when the element is connected. This is doable because - There isn't any direct access of child nodes under <menulist>. Everyone seems to access via .menupopup, which is usually the only child. - We don't need to move the children under <menulist>. If we need to and if the child is a <xbl:children> (which could happen if <menulist> is inside an XBL <content> that just get cloned to the document), the layout will get very confused and crash (see finding in bug 1514926) Differential Revision: https://phabricator.services.mozilla.com/D16149

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "CompositorWidget.h"
#include "GLConsts.h"
#include "nsBaseWidget.h"
#include "VsyncDispatcher.h"

namespace mozilla {
namespace widget {

CompositorWidget::CompositorWidget(const layers::CompositorOptions& aOptions)
    : mOptions(aOptions) {}

CompositorWidget::~CompositorWidget() {}

already_AddRefed<gfx::DrawTarget> CompositorWidget::StartRemoteDrawing() {
  return nullptr;

void CompositorWidget::CleanupRemoteDrawing() { mLastBackBuffer = nullptr; }

already_AddRefed<gfx::DrawTarget> CompositorWidget::GetBackBufferDrawTarget(
    gfx::DrawTarget* aScreenTarget, const LayoutDeviceIntRect& aRect,
    const LayoutDeviceIntRect& aClearRect) {
  gfx::SurfaceFormat format =
      aScreenTarget->GetFormat() == gfx::SurfaceFormat::B8G8R8X8
          ? gfx::SurfaceFormat::B8G8R8X8
          : gfx::SurfaceFormat::B8G8R8A8;
  gfx::IntSize size = aRect.ToUnknownRect().Size();
  gfx::IntSize clientSize(GetClientSize().ToUnknownSize());

  RefPtr<gfx::DrawTarget> target;
  // Re-use back buffer if possible
  if (mLastBackBuffer &&
      mLastBackBuffer->GetBackendType() == aScreenTarget->GetBackendType() &&
      mLastBackBuffer->GetFormat() == format &&
      size <= mLastBackBuffer->GetSize() &&
      mLastBackBuffer->GetSize() <= clientSize) {
    target = mLastBackBuffer;
    if (!aClearRect.IsEmpty()) {
      gfx::IntRect clearRect =
          aClearRect.ToUnknownRect() - aRect.ToUnknownRect().TopLeft();
      target->ClearRect(gfx::Rect(clearRect.X(), clearRect.Y(),
                                  clearRect.Width(), clearRect.Height()));
  } else {
    target = aScreenTarget->CreateSimilarDrawTarget(size, format);
    mLastBackBuffer = target;
  return target.forget();

already_AddRefed<gfx::SourceSurface> CompositorWidget::EndBackBufferDrawing() {
  RefPtr<gfx::SourceSurface> surface =
      mLastBackBuffer ? mLastBackBuffer->Snapshot() : nullptr;
  return surface.forget();

uint32_t CompositorWidget::GetGLFrameBufferFormat() { return LOCAL_GL_RGBA; }

RefPtr<VsyncObserver> CompositorWidget::GetVsyncObserver() const {
  // This should only used when the widget is in the GPU process, and should be
  // implemented by IPDL-enabled CompositorWidgets.
  // GPU process does not have a CompositorVsyncDispatcher.
  MOZ_ASSERT_UNREACHABLE("Must be implemented by derived class");
  return nullptr;

}  // namespace widget
}  // namespace mozilla