author Henrik Skupin <>
Fri, 30 Nov 2018 13:27:22 +0000
changeset 448968 cd370c35d88d82c719e7b3d70ae1da003c8cb7f6
parent 448947 6f3709b3878117466168c40affa7bca0b60cf75b
child 457593 525e804dc7e63855e026be9557af15340d71455a
permissions -rw-r--r--
Bug 1511311 - [marionette] GeckoInstance classes should not overwrite already set custom preferences. r=automatedtester Custom preferences as passed into both classes via the constructor are getting set in the base GeckoInstance class. But both the DesktopInstance and FennecInstance classes could override those custom preferences if they have the same preference set as required preference. As such the custom preference doesn't have any effect. This patch allows both classes to override required prefs with a different value. Differential Revision:

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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 */

#ifndef nsBox_h___
#define nsBox_h___

#include "mozilla/Attributes.h"
#include "mozilla/StaticPtr.h"
#include "nsIFrame.h"

class nsITheme;

class nsBox : public nsIFrame {
  friend class nsIFrame;

  static void Shutdown();

  virtual nsSize GetXULPrefSize(nsBoxLayoutState& aBoxLayoutState) override;
  virtual nsSize GetXULMinSize(nsBoxLayoutState& aBoxLayoutState) override;
  virtual nsSize GetXULMaxSize(nsBoxLayoutState& aBoxLayoutState) override;
  virtual nscoord GetXULFlex() override;
  virtual nscoord GetXULBoxAscent(nsBoxLayoutState& aBoxLayoutState) override;

  virtual nsSize GetXULMinSizeForScrollArea(
      nsBoxLayoutState& aBoxLayoutState) override;

  virtual bool IsXULCollapsed() override;

  virtual void SetXULBounds(nsBoxLayoutState& aBoxLayoutState,
                            const nsRect& aRect,
                            bool aRemoveOverflowAreas = false) override;

  virtual nsresult GetXULBorder(nsMargin& aBorderAndPadding) override;
  virtual nsresult GetXULPadding(nsMargin& aBorderAndPadding) override;
  virtual nsresult GetXULMargin(nsMargin& aMargin) override;

  virtual Valignment GetXULVAlign() const override { return vAlign_Top; }
  virtual Halignment GetXULHAlign() const override { return hAlign_Left; }

  virtual nsresult XULRelayoutChildAtOrdinal(nsIFrame* aChild) override;

  nsBox(ClassID aID);
  virtual ~nsBox();

   * Returns true if this box clips its children, e.g., if this box is an
   * scrollbox.
  virtual bool DoesClipChildren();
  virtual bool ComputesOwnOverflowArea() = 0;

  nsresult SyncLayout(nsBoxLayoutState& aBoxLayoutState);

  bool DoesNeedRecalc(const nsSize& aSize);
  bool DoesNeedRecalc(nscoord aCoord);
  void SizeNeedsRecalc(nsSize& aSize);
  void CoordNeedsRecalc(nscoord& aCoord);

  void AddBorderAndPadding(nsSize& aSize);

  static void AddBorderAndPadding(nsIFrame* aBox, nsSize& aSize);
  static void AddMargin(nsIFrame* aChild, nsSize& aSize);
  static void AddMargin(nsSize& aSize, const nsMargin& aMargin);

  static nsSize BoundsCheckMinMax(const nsSize& aMinSize,
                                  const nsSize& aMaxSize);
  static nsSize BoundsCheck(const nsSize& aMinSize, const nsSize& aPrefSize,
                            const nsSize& aMaxSize);
  static nscoord BoundsCheck(nscoord aMinSize, nscoord aPrefSize,
                             nscoord aMaxSize);

  static nsIFrame* GetChildXULBox(const nsIFrame* aFrame);
  static nsIFrame* GetNextXULBox(const nsIFrame* aFrame);
  static nsIFrame* GetParentXULBox(const nsIFrame* aFrame);

  nsresult BeginXULLayout(nsBoxLayoutState& aState);
  NS_IMETHOD DoXULLayout(nsBoxLayoutState& aBoxLayoutState);
  nsresult EndXULLayout(nsBoxLayoutState& aState);

  static bool gGotTheme;
  static mozilla::StaticRefPtr<nsITheme> gTheme;

  enum eMouseThrough { unset, never, always };