2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2005-08-22 20:35:47 +00:00
|
|
|
/* vim: set ts=2 sw=2 et tw=80: */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* 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/. */
|
1999-03-27 01:35:55 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Eric Vaughan
|
|
|
|
// Netscape Communications
|
|
|
|
//
|
|
|
|
// See documentation in associated header file
|
|
|
|
//
|
|
|
|
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
// How boxes layout
|
|
|
|
// ----------------
|
|
|
|
// Boxes layout a bit differently than html. html does a bottom up layout. Where boxes do a top down.
|
|
|
|
// 1) First thing a box does it goes out and askes each child for its min, max, and preferred sizes.
|
|
|
|
// 2) It then adds them up to determine its size.
|
|
|
|
// 3) If the box was asked to layout it self intrinically it will layout its children at their preferred size
|
|
|
|
// otherwise it will layout the child at the size it was told to. It will squeeze or stretch its children if
|
|
|
|
// Necessary.
|
|
|
|
//
|
|
|
|
// However there is a catch. Some html components like block frames can not determine their preferred size.
|
2005-11-20 22:05:24 +00:00
|
|
|
// this is their size if they were laid out intrinsically. So the box will flow the child to determine this can
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
// cache the value.
|
|
|
|
|
|
|
|
// Boxes and Incremental Reflow
|
|
|
|
// ----------------------------
|
2005-11-20 22:05:24 +00:00
|
|
|
// Boxes layout out top down by adding up their children's min, max, and preferred sizes. Only problem is if a incremental
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
// reflow occurs. The preferred size of a child deep in the hierarchy could change. And this could change
|
|
|
|
// any number of syblings around the box. Basically any children in the reflow chain must have their caches cleared
|
2000-03-31 07:02:06 +00:00
|
|
|
// so when asked for there current size they can relayout themselves.
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
|
1999-03-27 01:35:55 +00:00
|
|
|
#include "nsBoxFrame.h"
|
2014-10-17 14:06:34 +00:00
|
|
|
|
|
|
|
#include "gfxUtils.h"
|
|
|
|
#include "mozilla/gfx/2D.h"
|
|
|
|
#include "nsBoxLayoutState.h"
|
2013-04-05 08:49:00 +00:00
|
|
|
#include "mozilla/dom/Touch.h"
|
2014-10-20 09:55:48 +00:00
|
|
|
#include "mozilla/Move.h"
|
2003-02-22 00:32:13 +00:00
|
|
|
#include "nsStyleContext.h"
|
2013-06-01 05:14:03 +00:00
|
|
|
#include "nsPlaceholderFrame.h"
|
2004-07-31 23:15:21 +00:00
|
|
|
#include "nsPresContext.h"
|
1999-03-27 01:35:55 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2014-02-27 23:04:46 +00:00
|
|
|
#include "nsNameSpaceManager.h"
|
2007-01-30 00:06:41 +00:00
|
|
|
#include "nsGkAtoms.h"
|
1999-05-09 21:46:24 +00:00
|
|
|
#include "nsIContent.h"
|
1999-07-02 05:28:32 +00:00
|
|
|
#include "nsHTMLParts.h"
|
2013-01-05 03:12:24 +00:00
|
|
|
#include "nsViewManager.h"
|
2013-01-03 13:23:11 +00:00
|
|
|
#include "nsView.h"
|
1999-08-19 03:51:25 +00:00
|
|
|
#include "nsIPresShell.h"
|
1999-09-10 00:57:01 +00:00
|
|
|
#include "nsCSSRendering.h"
|
2000-03-02 07:13:02 +00:00
|
|
|
#include "nsIServiceManager.h"
|
2011-07-11 14:05:10 +00:00
|
|
|
#include "nsBoxLayout.h"
|
2000-03-31 07:02:06 +00:00
|
|
|
#include "nsSprocketLayout.h"
|
2000-05-22 09:15:54 +00:00
|
|
|
#include "nsIScrollableFrame.h"
|
2000-06-22 00:48:49 +00:00
|
|
|
#include "nsWidgetsCID.h"
|
2002-11-17 15:37:56 +00:00
|
|
|
#include "nsCSSAnonBoxes.h"
|
2011-12-27 20:18:48 +00:00
|
|
|
#include "nsContainerFrame.h"
|
2002-02-21 13:39:39 +00:00
|
|
|
#include "nsIDOMElement.h"
|
2002-01-08 00:43:20 +00:00
|
|
|
#include "nsITheme.h"
|
2002-06-17 23:35:15 +00:00
|
|
|
#include "nsTransform2D.h"
|
2014-04-01 04:09:23 +00:00
|
|
|
#include "mozilla/EventStateManager.h"
|
2002-07-03 16:38:15 +00:00
|
|
|
#include "nsIDOMEvent.h"
|
2006-01-26 02:29:17 +00:00
|
|
|
#include "nsDisplayList.h"
|
2011-05-25 06:31:59 +00:00
|
|
|
#include "mozilla/Preferences.h"
|
2013-08-19 22:55:18 +00:00
|
|
|
#include "nsThemeConstants.h"
|
2013-09-30 21:26:04 +00:00
|
|
|
#include "nsLayoutUtils.h"
|
2015-04-13 03:03:02 +00:00
|
|
|
#include "nsSliderFrame.h"
|
2013-01-15 12:22:03 +00:00
|
|
|
#include <algorithm>
|
2000-06-22 00:48:49 +00:00
|
|
|
|
2002-01-23 02:53:02 +00:00
|
|
|
// Needed for Print Preview
|
|
|
|
#include "nsIURI.h"
|
|
|
|
|
2013-09-25 11:21:16 +00:00
|
|
|
#include "mozilla/TouchEvents.h"
|
|
|
|
|
2011-05-25 06:31:59 +00:00
|
|
|
using namespace mozilla;
|
2013-04-05 08:49:00 +00:00
|
|
|
using namespace mozilla::dom;
|
2014-10-17 14:06:34 +00:00
|
|
|
using namespace mozilla::gfx;
|
2011-05-25 06:31:59 +00:00
|
|
|
|
2000-02-14 01:42:09 +00:00
|
|
|
//define DEBUG_REDRAW
|
2000-05-15 04:12:31 +00:00
|
|
|
|
1999-08-27 06:06:39 +00:00
|
|
|
#define DEBUG_SPRING_SIZE 8
|
|
|
|
#define DEBUG_BORDER_SIZE 2
|
|
|
|
#define COIL_SIZE 8
|
|
|
|
|
2000-02-16 23:00:52 +00:00
|
|
|
//#define TEST_SANITY
|
1999-12-02 01:07:27 +00:00
|
|
|
|
2000-08-23 11:02:19 +00:00
|
|
|
#ifdef DEBUG_rods
|
2000-08-24 13:19:57 +00:00
|
|
|
//#define DO_NOISY_REFLOW
|
2000-08-23 11:02:19 +00:00
|
|
|
#endif
|
|
|
|
|
2004-06-19 09:07:47 +00:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2011-09-29 06:19:26 +00:00
|
|
|
bool nsBoxFrame::gDebug = false;
|
2012-08-06 03:00:57 +00:00
|
|
|
nsIFrame* nsBoxFrame::mDebugChild = nullptr;
|
2004-06-19 09:07:47 +00:00
|
|
|
#endif
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2005-10-26 21:46:39 +00:00
|
|
|
nsIFrame*
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_NewBoxFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, bool aIsRoot, nsBoxLayout* aLayoutManager)
|
1999-03-27 01:35:55 +00:00
|
|
|
{
|
2015-01-06 09:27:56 +00:00
|
|
|
return new (aPresShell) nsBoxFrame(aContext, aIsRoot, aLayoutManager);
|
2009-09-12 16:49:24 +00:00
|
|
|
}
|
1999-03-27 01:35:55 +00:00
|
|
|
|
2009-01-19 18:31:33 +00:00
|
|
|
nsIFrame*
|
|
|
|
NS_NewBoxFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
|
|
|
{
|
2015-01-06 09:27:56 +00:00
|
|
|
return new (aPresShell) nsBoxFrame(aContext);
|
2009-01-19 18:31:33 +00:00
|
|
|
}
|
|
|
|
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsBoxFrame)
|
|
|
|
|
2014-01-18 07:08:22 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
NS_QUERYFRAME_HEAD(nsBoxFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsBoxFrame)
|
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
|
|
|
|
#endif
|
|
|
|
|
2015-01-06 09:27:56 +00:00
|
|
|
nsBoxFrame::nsBoxFrame(nsStyleContext* aContext,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aIsRoot,
|
2011-07-11 14:05:10 +00:00
|
|
|
nsBoxLayout* aLayoutManager) :
|
2010-11-30 14:59:46 +00:00
|
|
|
nsContainerFrame(aContext)
|
1999-03-27 01:35:55 +00:00
|
|
|
{
|
2001-03-06 02:27:50 +00:00
|
|
|
mState |= NS_STATE_IS_HORIZONTAL;
|
2000-02-14 01:42:09 +00:00
|
|
|
mState |= NS_STATE_AUTO_STRETCH;
|
2000-02-16 23:00:52 +00:00
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
if (aIsRoot)
|
2000-03-02 03:01:30 +00:00
|
|
|
mState |= NS_STATE_IS_ROOT;
|
|
|
|
|
2002-10-10 06:39:30 +00:00
|
|
|
mValign = vAlign_Top;
|
|
|
|
mHalign = hAlign_Left;
|
2001-09-25 22:17:00 +00:00
|
|
|
|
2000-04-05 00:19:00 +00:00
|
|
|
// if no layout manager specified us the static sprocket layout
|
2011-07-11 14:05:10 +00:00
|
|
|
nsCOMPtr<nsBoxLayout> layout = aLayoutManager;
|
2000-04-05 00:19:00 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
if (layout == nullptr) {
|
2015-01-06 09:27:56 +00:00
|
|
|
NS_NewSprocketLayout(PresContext()->PresShell(), layout);
|
2000-04-05 00:19:00 +00:00
|
|
|
}
|
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
SetLayoutManager(layout);
|
1999-08-27 06:06:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsBoxFrame::~nsBoxFrame()
|
|
|
|
{
|
1999-03-27 01:35:55 +00:00
|
|
|
}
|
|
|
|
|
2014-05-28 19:36:58 +00:00
|
|
|
void
|
2011-08-24 20:54:30 +00:00
|
|
|
nsBoxFrame::SetInitialChildList(ChildListID aListID,
|
2009-07-28 12:53:20 +00:00
|
|
|
nsFrameList& aChildList)
|
1999-12-02 01:07:27 +00:00
|
|
|
{
|
2014-05-28 19:36:58 +00:00
|
|
|
nsContainerFrame::SetInitialChildList(aListID, aChildList);
|
|
|
|
// initialize our list of infos.
|
|
|
|
nsBoxLayoutState state(PresContext());
|
|
|
|
CheckBoxOrder();
|
|
|
|
if (mLayoutManager)
|
|
|
|
mLayoutManager->ChildrenSet(this, state, mFrames.FirstChild());
|
1999-12-02 01:07:27 +00:00
|
|
|
}
|
|
|
|
|
2008-10-13 22:03:28 +00:00
|
|
|
/* virtual */ void
|
2008-10-26 10:11:34 +00:00
|
|
|
nsBoxFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
|
2006-04-17 23:58:17 +00:00
|
|
|
{
|
2008-10-26 10:11:34 +00:00
|
|
|
nsContainerFrame::DidSetStyleContext(aOldStyleContext);
|
2008-10-13 22:03:28 +00:00
|
|
|
|
2006-04-17 23:58:17 +00:00
|
|
|
// The values that CacheAttributes() computes depend on our style,
|
|
|
|
// so we need to recompute them here...
|
|
|
|
CacheAttributes();
|
|
|
|
}
|
|
|
|
|
1999-05-09 21:46:24 +00:00
|
|
|
/**
|
|
|
|
* Initialize us. This is a good time to get the alignment of the box
|
|
|
|
*/
|
2013-03-20 01:47:48 +00:00
|
|
|
void
|
2014-05-24 22:20:40 +00:00
|
|
|
nsBoxFrame::Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
1999-03-27 01:35:55 +00:00
|
|
|
{
|
2013-03-20 01:47:48 +00:00
|
|
|
nsContainerFrame::Init(aContent, aParent, aPrevInFlow);
|
2000-01-08 02:18:14 +00:00
|
|
|
|
2012-04-16 22:32:12 +00:00
|
|
|
if (GetStateBits() & NS_FRAME_FONT_INFLATION_CONTAINER) {
|
|
|
|
AddStateBits(NS_FRAME_FONT_INFLATION_FLOW_ROOT);
|
|
|
|
}
|
|
|
|
|
2014-07-24 17:03:26 +00:00
|
|
|
MarkIntrinsicISizesDirty();
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
2002-10-10 06:39:30 +00:00
|
|
|
CacheAttributes();
|
2000-03-02 03:01:30 +00:00
|
|
|
|
2004-06-19 09:07:47 +00:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2000-03-02 03:01:30 +00:00
|
|
|
// if we are root and this
|
|
|
|
if (mState & NS_STATE_IS_ROOT)
|
2006-04-10 00:16:29 +00:00
|
|
|
GetDebugPref(GetPresContext());
|
2004-06-19 09:07:47 +00:00
|
|
|
#endif
|
2000-02-14 01:42:09 +00:00
|
|
|
|
2007-06-18 23:22:46 +00:00
|
|
|
UpdateMouseThrough();
|
|
|
|
|
2002-02-21 13:39:39 +00:00
|
|
|
// register access key
|
2013-03-20 01:47:48 +00:00
|
|
|
RegUnregAccessKey(true);
|
2001-12-03 23:41:13 +00:00
|
|
|
}
|
|
|
|
|
2007-06-18 23:22:46 +00:00
|
|
|
void nsBoxFrame::UpdateMouseThrough()
|
|
|
|
{
|
|
|
|
if (mContent) {
|
|
|
|
static nsIContent::AttrValuesArray strings[] =
|
2012-07-30 14:20:58 +00:00
|
|
|
{&nsGkAtoms::never, &nsGkAtoms::always, nullptr};
|
2010-11-30 14:59:46 +00:00
|
|
|
switch (mContent->FindAttrValueIn(kNameSpaceID_None,
|
|
|
|
nsGkAtoms::mousethrough, strings, eCaseMatters)) {
|
|
|
|
case 0: AddStateBits(NS_FRAME_MOUSE_THROUGH_NEVER); break;
|
|
|
|
case 1: AddStateBits(NS_FRAME_MOUSE_THROUGH_ALWAYS); break;
|
|
|
|
case 2: {
|
|
|
|
RemoveStateBits(NS_FRAME_MOUSE_THROUGH_ALWAYS);
|
|
|
|
RemoveStateBits(NS_FRAME_MOUSE_THROUGH_NEVER);
|
|
|
|
break;
|
|
|
|
}
|
2007-06-18 23:22:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-06-23 05:15:04 +00:00
|
|
|
void
|
2002-10-10 06:39:30 +00:00
|
|
|
nsBoxFrame::CacheAttributes()
|
2000-06-23 05:15:04 +00:00
|
|
|
{
|
|
|
|
/*
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("Caching: ");
|
2002-10-10 06:39:30 +00:00
|
|
|
DumpBox(stdout);
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("\n");
|
2000-06-23 05:15:04 +00:00
|
|
|
*/
|
|
|
|
|
2002-10-10 06:39:30 +00:00
|
|
|
mValign = vAlign_Top;
|
|
|
|
mHalign = hAlign_Left;
|
2000-06-23 05:15:04 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool orient = false;
|
2002-10-10 06:39:30 +00:00
|
|
|
GetInitialOrientation(orient);
|
2000-06-23 05:15:04 +00:00
|
|
|
if (orient)
|
2002-10-10 06:39:30 +00:00
|
|
|
mState |= NS_STATE_IS_HORIZONTAL;
|
2001-08-02 00:09:27 +00:00
|
|
|
else
|
2002-10-10 06:39:30 +00:00
|
|
|
mState &= ~NS_STATE_IS_HORIZONTAL;
|
2000-06-23 05:15:04 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool normal = true;
|
2002-10-10 06:39:30 +00:00
|
|
|
GetInitialDirection(normal);
|
2001-08-15 04:09:41 +00:00
|
|
|
if (normal)
|
2002-10-10 06:39:30 +00:00
|
|
|
mState |= NS_STATE_IS_DIRECTION_NORMAL;
|
2001-08-15 04:09:41 +00:00
|
|
|
else
|
2002-10-10 06:39:30 +00:00
|
|
|
mState &= ~NS_STATE_IS_DIRECTION_NORMAL;
|
2001-08-15 04:09:41 +00:00
|
|
|
|
2002-10-10 06:39:30 +00:00
|
|
|
GetInitialVAlignment(mValign);
|
|
|
|
GetInitialHAlignment(mHalign);
|
2001-08-02 00:09:27 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool equalSize = false;
|
2002-10-10 06:39:30 +00:00
|
|
|
GetInitialEqualSize(equalSize);
|
2000-06-23 05:15:04 +00:00
|
|
|
if (equalSize)
|
2002-10-10 06:39:30 +00:00
|
|
|
mState |= NS_STATE_EQUAL_SIZE;
|
2000-06-23 05:15:04 +00:00
|
|
|
else
|
2002-10-10 06:39:30 +00:00
|
|
|
mState &= ~NS_STATE_EQUAL_SIZE;
|
2000-06-23 05:15:04 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool autostretch = !!(mState & NS_STATE_AUTO_STRETCH);
|
2002-10-10 06:39:30 +00:00
|
|
|
GetInitialAutoStretch(autostretch);
|
2000-06-23 05:15:04 +00:00
|
|
|
if (autostretch)
|
2002-10-10 06:39:30 +00:00
|
|
|
mState |= NS_STATE_AUTO_STRETCH;
|
2000-06-23 05:15:04 +00:00
|
|
|
else
|
2002-10-10 06:39:30 +00:00
|
|
|
mState &= ~NS_STATE_AUTO_STRETCH;
|
2000-06-23 05:15:04 +00:00
|
|
|
|
|
|
|
|
2004-06-19 09:07:47 +00:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2011-09-29 06:19:26 +00:00
|
|
|
bool debug = mState & NS_STATE_SET_TO_DEBUG;
|
|
|
|
bool debugSet = GetInitialDebug(debug);
|
2000-06-23 05:15:04 +00:00
|
|
|
if (debugSet) {
|
2002-10-10 06:39:30 +00:00
|
|
|
mState |= NS_STATE_DEBUG_WAS_SET;
|
2000-06-23 05:15:04 +00:00
|
|
|
if (debug)
|
2002-10-10 06:39:30 +00:00
|
|
|
mState |= NS_STATE_SET_TO_DEBUG;
|
2000-06-23 05:15:04 +00:00
|
|
|
else
|
2002-10-10 06:39:30 +00:00
|
|
|
mState &= ~NS_STATE_SET_TO_DEBUG;
|
2000-06-23 05:15:04 +00:00
|
|
|
} else {
|
2002-10-10 06:39:30 +00:00
|
|
|
mState &= ~NS_STATE_DEBUG_WAS_SET;
|
2000-06-23 05:15:04 +00:00
|
|
|
}
|
2004-06-19 09:07:47 +00:00
|
|
|
#endif
|
2000-06-23 05:15:04 +00:00
|
|
|
}
|
|
|
|
|
2004-06-19 09:07:47 +00:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
|
|
|
nsBoxFrame::GetInitialDebug(bool& aDebug)
|
2000-03-02 03:01:30 +00:00
|
|
|
{
|
2007-05-23 03:48:43 +00:00
|
|
|
if (!GetContent())
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2006-01-18 04:09:33 +00:00
|
|
|
static nsIContent::AttrValuesArray strings[] =
|
2012-07-30 14:20:58 +00:00
|
|
|
{&nsGkAtoms::_false, &nsGkAtoms::_true, nullptr};
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t index = GetContent()->FindAttrValueIn(kNameSpaceID_None,
|
2006-12-26 17:47:52 +00:00
|
|
|
nsGkAtoms::debug, strings, eCaseMatters);
|
2006-01-18 04:09:33 +00:00
|
|
|
if (index >= 0) {
|
|
|
|
aDebug = index == 1;
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2000-03-02 03:01:30 +00:00
|
|
|
}
|
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2000-03-02 03:01:30 +00:00
|
|
|
}
|
2004-06-19 09:07:47 +00:00
|
|
|
#endif
|
2000-03-02 03:01:30 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2000-02-14 01:42:09 +00:00
|
|
|
nsBoxFrame::GetInitialHAlignment(nsBoxFrame::Halignment& aHalign)
|
|
|
|
{
|
2007-05-23 03:48:43 +00:00
|
|
|
if (!GetContent())
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
|
2005-10-28 11:25:24 +00:00
|
|
|
// XXXdwh Everything inside this if statement is deprecated code.
|
2006-01-18 04:09:33 +00:00
|
|
|
static nsIContent::AttrValuesArray alignStrings[] =
|
2012-07-30 14:20:58 +00:00
|
|
|
{&nsGkAtoms::left, &nsGkAtoms::right, nullptr};
|
2006-01-18 04:09:33 +00:00
|
|
|
static const Halignment alignValues[] = {hAlign_Left, hAlign_Right};
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t index = GetContent()->FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::align,
|
2006-01-18 04:09:33 +00:00
|
|
|
alignStrings, eCaseMatters);
|
|
|
|
if (index >= 0) {
|
|
|
|
aHalign = alignValues[index];
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
}
|
2001-08-02 00:09:27 +00:00
|
|
|
|
|
|
|
// Now that the deprecated stuff is out of the way, we move on to check the appropriate
|
|
|
|
// attribute. For horizontal boxes, we are checking the PACK attribute. For vertical boxes
|
|
|
|
// we are checking the ALIGN attribute.
|
2006-12-26 17:47:52 +00:00
|
|
|
nsIAtom* attrName = IsHorizontal() ? nsGkAtoms::pack : nsGkAtoms::align;
|
2006-01-18 04:09:33 +00:00
|
|
|
static nsIContent::AttrValuesArray strings[] =
|
2012-07-30 14:20:58 +00:00
|
|
|
{&nsGkAtoms::_empty, &nsGkAtoms::start, &nsGkAtoms::center, &nsGkAtoms::end, nullptr};
|
2006-01-18 04:09:33 +00:00
|
|
|
static const Halignment values[] =
|
|
|
|
{hAlign_Left/*not used*/, hAlign_Left, hAlign_Center, hAlign_Right};
|
2007-05-23 03:48:43 +00:00
|
|
|
index = GetContent()->FindAttrValueIn(kNameSpaceID_None, attrName,
|
2006-01-18 04:09:33 +00:00
|
|
|
strings, eCaseMatters);
|
|
|
|
|
|
|
|
if (index == nsIContent::ATTR_VALUE_NO_MATCH) {
|
2001-08-02 00:09:27 +00:00
|
|
|
// The attr was present but had a nonsensical value. Revert to the default.
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2001-08-02 00:09:27 +00:00
|
|
|
}
|
2006-01-18 04:09:33 +00:00
|
|
|
if (index > 0) {
|
|
|
|
aHalign = values[index];
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2006-01-18 04:09:33 +00:00
|
|
|
}
|
2000-02-14 01:42:09 +00:00
|
|
|
|
2001-08-02 00:09:27 +00:00
|
|
|
// Now that we've checked for the attribute it's time to check CSS. For
|
|
|
|
// horizontal boxes we're checking PACK. For vertical boxes we are checking
|
|
|
|
// ALIGN.
|
2013-02-16 21:51:02 +00:00
|
|
|
const nsStyleXUL* boxInfo = StyleXUL();
|
2001-08-02 00:09:27 +00:00
|
|
|
if (IsHorizontal()) {
|
|
|
|
switch (boxInfo->mBoxPack) {
|
|
|
|
case NS_STYLE_BOX_PACK_START:
|
|
|
|
aHalign = nsBoxFrame::hAlign_Left;
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2001-08-02 00:09:27 +00:00
|
|
|
case NS_STYLE_BOX_PACK_CENTER:
|
|
|
|
aHalign = nsBoxFrame::hAlign_Center;
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2001-08-02 00:09:27 +00:00
|
|
|
case NS_STYLE_BOX_PACK_END:
|
|
|
|
aHalign = nsBoxFrame::hAlign_Right;
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2001-08-02 00:09:27 +00:00
|
|
|
default: // Nonsensical value. Just bail.
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2001-08-02 00:09:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
switch (boxInfo->mBoxAlign) {
|
|
|
|
case NS_STYLE_BOX_ALIGN_START:
|
|
|
|
aHalign = nsBoxFrame::hAlign_Left;
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2001-08-02 00:09:27 +00:00
|
|
|
case NS_STYLE_BOX_ALIGN_CENTER:
|
|
|
|
aHalign = nsBoxFrame::hAlign_Center;
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2001-08-02 00:09:27 +00:00
|
|
|
case NS_STYLE_BOX_ALIGN_END:
|
|
|
|
aHalign = nsBoxFrame::hAlign_Right;
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2001-08-02 00:09:27 +00:00
|
|
|
default: // Nonsensical value. Just bail.
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2001-08-02 00:09:27 +00:00
|
|
|
}
|
|
|
|
}
|
2000-02-14 01:42:09 +00:00
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2000-02-14 01:42:09 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2000-02-14 01:42:09 +00:00
|
|
|
nsBoxFrame::GetInitialVAlignment(nsBoxFrame::Valignment& aValign)
|
|
|
|
{
|
2007-05-23 03:48:43 +00:00
|
|
|
if (!GetContent())
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2000-02-14 01:42:09 +00:00
|
|
|
|
2006-01-18 04:09:33 +00:00
|
|
|
static nsIContent::AttrValuesArray valignStrings[] =
|
2012-07-30 14:20:58 +00:00
|
|
|
{&nsGkAtoms::top, &nsGkAtoms::baseline, &nsGkAtoms::middle, &nsGkAtoms::bottom, nullptr};
|
2006-01-18 04:09:33 +00:00
|
|
|
static const Valignment valignValues[] =
|
|
|
|
{vAlign_Top, vAlign_BaseLine, vAlign_Middle, vAlign_Bottom};
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t index = GetContent()->FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::valign,
|
2006-01-18 04:09:33 +00:00
|
|
|
valignStrings, eCaseMatters);
|
|
|
|
if (index >= 0) {
|
|
|
|
aValign = valignValues[index];
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
}
|
|
|
|
|
2001-08-02 00:09:27 +00:00
|
|
|
// Now that the deprecated stuff is out of the way, we move on to check the appropriate
|
|
|
|
// attribute. For horizontal boxes, we are checking the ALIGN attribute. For vertical boxes
|
|
|
|
// we are checking the PACK attribute.
|
2006-12-26 17:47:52 +00:00
|
|
|
nsIAtom* attrName = IsHorizontal() ? nsGkAtoms::align : nsGkAtoms::pack;
|
2006-01-18 04:09:33 +00:00
|
|
|
static nsIContent::AttrValuesArray strings[] =
|
2006-12-26 17:47:52 +00:00
|
|
|
{&nsGkAtoms::_empty, &nsGkAtoms::start, &nsGkAtoms::center,
|
2012-07-30 14:20:58 +00:00
|
|
|
&nsGkAtoms::baseline, &nsGkAtoms::end, nullptr};
|
2006-01-18 04:09:33 +00:00
|
|
|
static const Valignment values[] =
|
|
|
|
{vAlign_Top/*not used*/, vAlign_Top, vAlign_Middle, vAlign_BaseLine, vAlign_Bottom};
|
2007-05-23 03:48:43 +00:00
|
|
|
index = GetContent()->FindAttrValueIn(kNameSpaceID_None, attrName,
|
2006-01-18 04:09:33 +00:00
|
|
|
strings, eCaseMatters);
|
|
|
|
if (index == nsIContent::ATTR_VALUE_NO_MATCH) {
|
2001-08-02 00:09:27 +00:00
|
|
|
// The attr was present but had a nonsensical value. Revert to the default.
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2001-08-02 00:09:27 +00:00
|
|
|
}
|
2006-01-18 04:09:33 +00:00
|
|
|
if (index > 0) {
|
|
|
|
aValign = values[index];
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2006-01-18 04:09:33 +00:00
|
|
|
}
|
2001-08-02 00:09:27 +00:00
|
|
|
|
|
|
|
// Now that we've checked for the attribute it's time to check CSS. For
|
|
|
|
// horizontal boxes we're checking ALIGN. For vertical boxes we are checking
|
|
|
|
// PACK.
|
2013-02-16 21:51:02 +00:00
|
|
|
const nsStyleXUL* boxInfo = StyleXUL();
|
2001-08-02 00:09:27 +00:00
|
|
|
if (IsHorizontal()) {
|
|
|
|
switch (boxInfo->mBoxAlign) {
|
|
|
|
case NS_STYLE_BOX_ALIGN_START:
|
|
|
|
aValign = nsBoxFrame::vAlign_Top;
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2001-08-02 00:09:27 +00:00
|
|
|
case NS_STYLE_BOX_ALIGN_CENTER:
|
|
|
|
aValign = nsBoxFrame::vAlign_Middle;
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2001-08-02 00:09:27 +00:00
|
|
|
case NS_STYLE_BOX_ALIGN_BASELINE:
|
|
|
|
aValign = nsBoxFrame::vAlign_BaseLine;
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2001-08-02 00:09:27 +00:00
|
|
|
case NS_STYLE_BOX_ALIGN_END:
|
|
|
|
aValign = nsBoxFrame::vAlign_Bottom;
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2001-08-02 00:09:27 +00:00
|
|
|
default: // Nonsensical value. Just bail.
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2001-08-02 00:09:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
switch (boxInfo->mBoxPack) {
|
|
|
|
case NS_STYLE_BOX_PACK_START:
|
|
|
|
aValign = nsBoxFrame::vAlign_Top;
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2001-08-02 00:09:27 +00:00
|
|
|
case NS_STYLE_BOX_PACK_CENTER:
|
|
|
|
aValign = nsBoxFrame::vAlign_Middle;
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2001-08-02 00:09:27 +00:00
|
|
|
case NS_STYLE_BOX_PACK_END:
|
|
|
|
aValign = nsBoxFrame::vAlign_Bottom;
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2001-08-02 00:09:27 +00:00
|
|
|
default: // Nonsensical value. Just bail.
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2001-08-02 00:09:27 +00:00
|
|
|
}
|
|
|
|
}
|
2000-02-14 01:42:09 +00:00
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
1999-11-18 21:05:43 +00:00
|
|
|
}
|
|
|
|
|
2001-03-06 02:27:50 +00:00
|
|
|
void
|
2011-09-29 06:19:26 +00:00
|
|
|
nsBoxFrame::GetInitialOrientation(bool& aIsHorizontal)
|
1999-11-18 21:05:43 +00:00
|
|
|
{
|
|
|
|
// see if we are a vertical or horizontal box.
|
2007-05-23 03:48:43 +00:00
|
|
|
if (!GetContent())
|
2001-03-06 02:27:50 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// Check the style system first.
|
2013-02-16 21:51:02 +00:00
|
|
|
const nsStyleXUL* boxInfo = StyleXUL();
|
2001-03-06 02:27:50 +00:00
|
|
|
if (boxInfo->mBoxOrient == NS_STYLE_BOX_ORIENT_HORIZONTAL)
|
2011-10-17 14:59:28 +00:00
|
|
|
aIsHorizontal = true;
|
2001-03-06 02:27:50 +00:00
|
|
|
else
|
2011-10-17 14:59:28 +00:00
|
|
|
aIsHorizontal = false;
|
2001-03-06 02:27:50 +00:00
|
|
|
|
|
|
|
// Now see if we have an attribute. The attribute overrides
|
|
|
|
// the style system value.
|
2006-01-18 04:09:33 +00:00
|
|
|
static nsIContent::AttrValuesArray strings[] =
|
2012-07-30 14:20:58 +00:00
|
|
|
{&nsGkAtoms::vertical, &nsGkAtoms::horizontal, nullptr};
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t index = GetContent()->FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::orient,
|
2006-01-18 04:09:33 +00:00
|
|
|
strings, eCaseMatters);
|
|
|
|
if (index >= 0) {
|
|
|
|
aIsHorizontal = index == 1;
|
|
|
|
}
|
2000-02-14 01:42:09 +00:00
|
|
|
}
|
|
|
|
|
2001-08-15 04:09:41 +00:00
|
|
|
void
|
2011-09-29 06:19:26 +00:00
|
|
|
nsBoxFrame::GetInitialDirection(bool& aIsNormal)
|
2001-08-15 04:09:41 +00:00
|
|
|
{
|
2007-05-23 03:48:43 +00:00
|
|
|
if (!GetContent())
|
2001-08-15 04:09:41 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (IsHorizontal()) {
|
|
|
|
// For horizontal boxes only, we initialize our value based off the CSS 'direction' property.
|
|
|
|
// This means that BiDI users will end up with horizontally inverted chrome.
|
2013-02-16 21:51:02 +00:00
|
|
|
aIsNormal = (StyleVisibility()->mDirection == NS_STYLE_DIRECTION_LTR); // If text runs RTL then so do we.
|
2001-08-15 04:09:41 +00:00
|
|
|
}
|
|
|
|
else
|
2011-10-17 14:59:28 +00:00
|
|
|
aIsNormal = true; // Assume a normal direction in the vertical case.
|
2001-08-15 04:09:41 +00:00
|
|
|
|
|
|
|
// Now check the style system to see if we should invert aIsNormal.
|
2013-02-16 21:51:02 +00:00
|
|
|
const nsStyleXUL* boxInfo = StyleXUL();
|
2001-08-15 04:09:41 +00:00
|
|
|
if (boxInfo->mBoxDirection == NS_STYLE_BOX_DIRECTION_REVERSE)
|
|
|
|
aIsNormal = !aIsNormal; // Invert our direction.
|
|
|
|
|
|
|
|
// Now see if we have an attribute. The attribute overrides
|
|
|
|
// the style system value.
|
2012-05-07 19:17:41 +00:00
|
|
|
if (IsHorizontal()) {
|
|
|
|
static nsIContent::AttrValuesArray strings[] =
|
2012-07-30 14:20:58 +00:00
|
|
|
{&nsGkAtoms::reverse, &nsGkAtoms::ltr, &nsGkAtoms::rtl, nullptr};
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t index = GetContent()->FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::dir,
|
2012-05-07 19:17:41 +00:00
|
|
|
strings, eCaseMatters);
|
|
|
|
if (index >= 0) {
|
|
|
|
bool values[] = {!aIsNormal, true, false};
|
|
|
|
aIsNormal = values[index];
|
|
|
|
}
|
|
|
|
} else if (GetContent()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::dir,
|
|
|
|
nsGkAtoms::reverse, eCaseMatters)) {
|
|
|
|
aIsNormal = !aIsNormal;
|
2001-08-15 04:09:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-06-23 05:15:04 +00:00
|
|
|
/* Returns true if it was set.
|
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
|
|
|
nsBoxFrame::GetInitialEqualSize(bool& aEqualSize)
|
2000-06-23 05:15:04 +00:00
|
|
|
{
|
|
|
|
// see if we are a vertical or horizontal box.
|
2007-05-23 03:48:43 +00:00
|
|
|
if (!GetContent())
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2007-05-23 03:48:43 +00:00
|
|
|
|
|
|
|
if (GetContent()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::equalsize,
|
2006-12-26 17:47:52 +00:00
|
|
|
nsGkAtoms::always, eCaseMatters)) {
|
2011-10-17 14:59:28 +00:00
|
|
|
aEqualSize = true;
|
|
|
|
return true;
|
2007-05-23 03:48:43 +00:00
|
|
|
}
|
2000-06-23 05:15:04 +00:00
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2000-06-23 05:15:04 +00:00
|
|
|
}
|
|
|
|
|
2000-02-14 01:42:09 +00:00
|
|
|
/* Returns true if it was set.
|
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
|
|
|
nsBoxFrame::GetInitialAutoStretch(bool& aStretch)
|
2000-02-14 01:42:09 +00:00
|
|
|
{
|
2007-05-23 03:48:43 +00:00
|
|
|
if (!GetContent())
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
107642 - XUL syntax/cleanup landing. Fixes 94470, 96008, 96019, 76800, 102637, 80399, 108303, and removes over a thousand unnecessary or nonsensical attributes. Also fixes 108302, 102366, 102367, 105815. r=sspitzer,cmanske on appropriate parts sr=ben
2001-11-03 04:17:02 +00:00
|
|
|
|
|
|
|
// Check the align attribute.
|
2006-01-18 04:09:33 +00:00
|
|
|
static nsIContent::AttrValuesArray strings[] =
|
2012-07-30 14:20:58 +00:00
|
|
|
{&nsGkAtoms::_empty, &nsGkAtoms::stretch, nullptr};
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t index = GetContent()->FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::align,
|
2006-01-18 04:09:33 +00:00
|
|
|
strings, eCaseMatters);
|
|
|
|
if (index != nsIContent::ATTR_MISSING && index != 0) {
|
|
|
|
aStretch = index == 1;
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2001-08-02 00:09:27 +00:00
|
|
|
}
|
2000-02-14 01:42:09 +00:00
|
|
|
|
107642 - XUL syntax/cleanup landing. Fixes 94470, 96008, 96019, 76800, 102637, 80399, 108303, and removes over a thousand unnecessary or nonsensical attributes. Also fixes 108302, 102366, 102367, 105815. r=sspitzer,cmanske on appropriate parts sr=ben
2001-11-03 04:17:02 +00:00
|
|
|
// Check the CSS box-align property.
|
2013-02-16 21:51:02 +00:00
|
|
|
const nsStyleXUL* boxInfo = StyleXUL();
|
107642 - XUL syntax/cleanup landing. Fixes 94470, 96008, 96019, 76800, 102637, 80399, 108303, and removes over a thousand unnecessary or nonsensical attributes. Also fixes 108302, 102366, 102367, 105815. r=sspitzer,cmanske on appropriate parts sr=ben
2001-11-03 04:17:02 +00:00
|
|
|
aStretch = (boxInfo->mBoxAlign == NS_STYLE_BOX_ALIGN_STRETCH);
|
2001-08-02 00:09:27 +00:00
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
1999-11-18 21:05:43 +00:00
|
|
|
}
|
1999-07-02 05:28:32 +00:00
|
|
|
|
2014-05-13 00:47:53 +00:00
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsBoxFrame::DidReflow(nsPresContext* aPresContext,
|
2001-12-07 14:51:12 +00:00
|
|
|
const nsHTMLReflowState* aReflowState,
|
|
|
|
nsDidReflowStatus aStatus)
|
1999-09-10 00:57:01 +00:00
|
|
|
{
|
2003-06-01 20:03:13 +00:00
|
|
|
nsFrameState preserveBits =
|
|
|
|
mState & (NS_FRAME_IS_DIRTY | NS_FRAME_HAS_DIRTY_CHILDREN);
|
2014-05-13 00:47:53 +00:00
|
|
|
nsFrame::DidReflow(aPresContext, aReflowState, aStatus);
|
2003-06-01 20:03:13 +00:00
|
|
|
mState |= preserveBits;
|
1999-09-10 00:57:01 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2007-10-12 18:37:51 +00:00
|
|
|
nsBoxFrame::HonorPrintBackgroundSettings()
|
|
|
|
{
|
2008-02-26 12:40:18 +00:00
|
|
|
return (!mContent || !mContent->IsInNativeAnonymousSubtree()) &&
|
2007-10-12 18:37:51 +00:00
|
|
|
nsContainerFrame::HonorPrintBackgroundSettings();
|
|
|
|
}
|
|
|
|
|
2000-08-23 11:02:19 +00:00
|
|
|
#ifdef DO_NOISY_REFLOW
|
|
|
|
static int myCounter = 0;
|
|
|
|
static void printSize(char * aDesc, nscoord aSize)
|
|
|
|
{
|
2000-10-28 22:17:53 +00:00
|
|
|
printf(" %s: ", aDesc);
|
2000-08-23 11:02:19 +00:00
|
|
|
if (aSize == NS_UNCONSTRAINEDSIZE) {
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("UC");
|
2000-08-23 11:02:19 +00:00
|
|
|
} else {
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("%d", aSize);
|
2000-08-23 11:02:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
/* virtual */ nscoord
|
2014-07-24 17:03:25 +00:00
|
|
|
nsBoxFrame::GetMinISize(nsRenderingContext *aRenderingContext)
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
{
|
|
|
|
nscoord result;
|
|
|
|
DISPLAY_MIN_WIDTH(this, result);
|
|
|
|
|
2007-03-30 21:11:41 +00:00
|
|
|
nsBoxLayoutState state(PresContext(), aRenderingContext);
|
2007-01-08 02:57:59 +00:00
|
|
|
nsSize minSize = GetMinSize(state);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
|
|
|
// GetMinSize returns border-box width, and we want to return content
|
|
|
|
// width. Since Reflow uses the reflow state's border and padding, we
|
|
|
|
// actually just want to subtract what GetMinSize added, which is the
|
|
|
|
// result of GetBorderAndPadding.
|
|
|
|
nsMargin bp;
|
|
|
|
GetBorderAndPadding(bp);
|
|
|
|
|
|
|
|
result = minSize.width - bp.LeftRight();
|
2013-01-15 12:22:03 +00:00
|
|
|
result = std::max(result, 0);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nscoord
|
2014-07-24 17:03:25 +00:00
|
|
|
nsBoxFrame::GetPrefISize(nsRenderingContext *aRenderingContext)
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
{
|
|
|
|
nscoord result;
|
|
|
|
DISPLAY_PREF_WIDTH(this, result);
|
|
|
|
|
2007-03-30 21:11:41 +00:00
|
|
|
nsBoxLayoutState state(PresContext(), aRenderingContext);
|
2007-01-08 02:57:59 +00:00
|
|
|
nsSize prefSize = GetPrefSize(state);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
|
|
|
// GetPrefSize returns border-box width, and we want to return content
|
|
|
|
// width. Since Reflow uses the reflow state's border and padding, we
|
|
|
|
// actually just want to subtract what GetPrefSize added, which is the
|
|
|
|
// result of GetBorderAndPadding.
|
|
|
|
nsMargin bp;
|
|
|
|
GetBorderAndPadding(bp);
|
|
|
|
|
|
|
|
result = prefSize.width - bp.LeftRight();
|
2013-01-15 12:22:03 +00:00
|
|
|
result = std::max(result, 0);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
|
|
|
return result;
|
2002-01-23 02:53:02 +00:00
|
|
|
}
|
|
|
|
|
2014-05-13 00:47:52 +00:00
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsBoxFrame::Reflow(nsPresContext* aPresContext,
|
2002-05-28 22:50:43 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1999-03-27 01:35:55 +00:00
|
|
|
{
|
2015-03-29 22:38:40 +00:00
|
|
|
MarkInReflow();
|
2002-02-14 00:08:08 +00:00
|
|
|
// If you make changes to this method, please keep nsLeafBoxFrame::Reflow
|
|
|
|
// in sync, if the changes are applicable there.
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsBoxFrame");
|
2002-03-03 19:53:56 +00:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
1999-03-27 01:35:55 +00:00
|
|
|
|
2008-08-25 17:21:29 +00:00
|
|
|
NS_ASSERTION(aReflowState.ComputedWidth() >=0 &&
|
|
|
|
aReflowState.ComputedHeight() >= 0, "Computed Size < 0");
|
1999-04-12 21:48:21 +00:00
|
|
|
|
2000-08-23 11:02:19 +00:00
|
|
|
#ifdef DO_NOISY_REFLOW
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("\n-------------Starting BoxFrame Reflow ----------------------------\n");
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
printf("%p ** nsBF::Reflow %d ", this, myCounter++);
|
2000-08-23 11:02:19 +00:00
|
|
|
|
2013-12-27 17:59:21 +00:00
|
|
|
printSize("AW", aReflowState.AvailableWidth());
|
|
|
|
printSize("AH", aReflowState.AvailableHeight());
|
2007-01-26 00:05:12 +00:00
|
|
|
printSize("CW", aReflowState.ComputedWidth());
|
2007-08-02 18:08:05 +00:00
|
|
|
printSize("CH", aReflowState.ComputedHeight());
|
2000-08-23 11:02:19 +00:00
|
|
|
|
2000-10-28 22:17:53 +00:00
|
|
|
printf(" *\n");
|
2000-08-23 11:02:19 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
1999-04-12 21:48:21 +00:00
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
// create the layout state
|
2008-04-10 04:39:41 +00:00
|
|
|
nsBoxLayoutState state(aPresContext, aReflowState.rendContext,
|
2011-11-24 02:48:23 +00:00
|
|
|
&aReflowState, aReflowState.mReflowDepth);
|
1999-04-12 21:48:21 +00:00
|
|
|
|
2014-07-24 08:30:07 +00:00
|
|
|
WritingMode wm = aReflowState.GetWritingMode();
|
|
|
|
LogicalSize computedSize(wm, aReflowState.ComputedISize(),
|
|
|
|
aReflowState.ComputedBSize());
|
1999-09-13 20:24:20 +00:00
|
|
|
|
2014-07-24 08:30:07 +00:00
|
|
|
LogicalMargin m = aReflowState.ComputedLogicalBorderPadding();
|
2002-09-25 20:23:34 +00:00
|
|
|
// GetBorderAndPadding(m);
|
1999-08-30 22:32:25 +00:00
|
|
|
|
2014-07-24 08:30:07 +00:00
|
|
|
LogicalSize prefSize(wm);
|
1999-09-13 20:24:20 +00:00
|
|
|
|
2007-01-08 02:57:59 +00:00
|
|
|
// if we are told to layout intrinsic then get our preferred size.
|
2014-07-24 08:30:07 +00:00
|
|
|
NS_ASSERTION(computedSize.ISize(wm) != NS_INTRINSICSIZE,
|
|
|
|
"computed inline size should always be computed");
|
|
|
|
if (computedSize.BSize(wm) == NS_INTRINSICSIZE) {
|
|
|
|
nsSize physicalPrefSize = GetPrefSize(state);
|
2007-01-08 03:49:59 +00:00
|
|
|
nsSize minSize = GetMinSize(state);
|
|
|
|
nsSize maxSize = GetMaxSize(state);
|
2009-04-27 21:18:37 +00:00
|
|
|
// XXXbz isn't GetPrefSize supposed to bounds-check for us?
|
2014-07-24 08:30:07 +00:00
|
|
|
physicalPrefSize = BoundsCheck(minSize, physicalPrefSize, maxSize);
|
|
|
|
prefSize = LogicalSize(wm, physicalPrefSize);
|
2000-03-31 07:02:06 +00:00
|
|
|
}
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
// get our desiredSize
|
2014-07-24 08:30:07 +00:00
|
|
|
computedSize.ISize(wm) += m.IStart(wm) + m.IEnd(wm);
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
|
2014-07-24 08:30:07 +00:00
|
|
|
if (aReflowState.ComputedBSize() == NS_INTRINSICSIZE) {
|
|
|
|
computedSize.BSize(wm) = prefSize.BSize(wm);
|
2012-09-11 22:20:51 +00:00
|
|
|
// prefSize is border-box but min/max constraints are content-box.
|
2014-07-24 08:30:07 +00:00
|
|
|
nscoord blockDirBorderPadding =
|
|
|
|
aReflowState.ComputedLogicalBorderPadding().BStartEnd(wm);
|
|
|
|
nscoord contentBSize = computedSize.BSize(wm) - blockDirBorderPadding;
|
2012-09-11 22:20:51 +00:00
|
|
|
// Note: contentHeight might be negative, but that's OK because min-height
|
|
|
|
// is never negative.
|
2014-07-24 08:30:07 +00:00
|
|
|
computedSize.BSize(wm) = aReflowState.ApplyMinMaxHeight(contentBSize) +
|
|
|
|
blockDirBorderPadding;
|
2000-08-17 20:08:44 +00:00
|
|
|
} else {
|
2014-07-24 08:30:07 +00:00
|
|
|
computedSize.BSize(wm) += m.BStart(wm) + m.BEnd(wm);
|
2000-08-17 20:08:44 +00:00
|
|
|
}
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
|
2014-07-24 08:30:07 +00:00
|
|
|
nsSize physicalSize = computedSize.GetPhysicalSize(wm);
|
|
|
|
nsRect r(mRect.x, mRect.y, physicalSize.width, physicalSize.height);
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
SetBounds(state, r);
|
|
|
|
|
|
|
|
// layout our children
|
|
|
|
Layout(state);
|
|
|
|
|
|
|
|
// ok our child could have gotten bigger. So lets get its bounds
|
|
|
|
|
|
|
|
// get the ascent
|
2014-07-24 08:30:07 +00:00
|
|
|
LogicalSize boxSize = GetLogicalSize(wm);
|
|
|
|
nscoord ascent = boxSize.BSize(wm);
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
// getting the ascent could be a lot of work. Don't get it if
|
|
|
|
// we are the root. The viewport doesn't care about it.
|
2002-01-23 02:53:02 +00:00
|
|
|
if (!(mState & NS_STATE_IS_ROOT)) {
|
2007-01-31 16:02:42 +00:00
|
|
|
ascent = GetBoxAscent(state);
|
2002-01-23 02:53:02 +00:00
|
|
|
}
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
|
2014-07-24 08:30:07 +00:00
|
|
|
aDesiredSize.SetSize(wm, boxSize);
|
2014-06-11 09:45:31 +00:00
|
|
|
aDesiredSize.SetBlockStartAscent(ascent);
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
|
2010-10-07 04:25:46 +00:00
|
|
|
aDesiredSize.mOverflowAreas = GetOverflowAreas();
|
2004-07-16 16:56:21 +00:00
|
|
|
|
2000-08-23 11:02:19 +00:00
|
|
|
#ifdef DO_NOISY_REFLOW
|
|
|
|
{
|
2013-12-27 17:59:52 +00:00
|
|
|
printf("%p ** nsBF(done) W:%d H:%d ", this, aDesiredSize.Width(), aDesiredSize.Height());
|
2000-08-23 11:02:19 +00:00
|
|
|
|
|
|
|
if (maxElementSize) {
|
2003-01-09 14:26:32 +00:00
|
|
|
printf("MW:%d\n", *maxElementWidth);
|
2000-08-23 11:02:19 +00:00
|
|
|
} else {
|
2003-01-09 14:26:32 +00:00
|
|
|
printf("MW:?\n");
|
2000-08-23 11:02:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
2000-04-05 00:19:00 +00:00
|
|
|
|
2012-03-10 22:49:10 +00:00
|
|
|
ReflowAbsoluteFrames(aPresContext, aDesiredSize, aReflowState, aStatus);
|
|
|
|
|
2002-05-28 22:50:43 +00:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
1999-04-12 21:48:21 +00:00
|
|
|
}
|
|
|
|
|
2007-01-08 02:57:59 +00:00
|
|
|
nsSize
|
|
|
|
nsBoxFrame::GetPrefSize(nsBoxLayoutState& aBoxLayoutState)
|
1999-03-27 01:35:55 +00:00
|
|
|
{
|
2007-04-29 22:24:59 +00:00
|
|
|
NS_ASSERTION(aBoxLayoutState.GetRenderingContext(),
|
|
|
|
"must have rendering context");
|
|
|
|
|
2007-01-08 02:57:59 +00:00
|
|
|
nsSize size(0,0);
|
|
|
|
DISPLAY_PREF_SIZE(this, size);
|
2000-06-06 01:25:03 +00:00
|
|
|
if (!DoesNeedRecalc(mPrefSize)) {
|
2010-03-18 19:58:15 +00:00
|
|
|
return mPrefSize;
|
2000-02-25 04:18:34 +00:00
|
|
|
}
|
|
|
|
|
2004-06-19 09:07:47 +00:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2000-03-31 07:02:06 +00:00
|
|
|
PropagateDebug(aBoxLayoutState);
|
2004-06-19 09:07:47 +00:00
|
|
|
#endif
|
1999-03-27 01:35:55 +00:00
|
|
|
|
2011-06-15 21:03:49 +00:00
|
|
|
if (IsCollapsed())
|
2007-01-08 02:57:59 +00:00
|
|
|
return size;
|
2004-09-28 18:37:50 +00:00
|
|
|
|
|
|
|
// if the size was not completely redefined in CSS then ask our children
|
2011-09-29 06:19:26 +00:00
|
|
|
bool widthSet, heightSet;
|
2012-08-06 03:00:57 +00:00
|
|
|
if (!nsIFrame::AddCSSPrefSize(this, size, widthSet, heightSet))
|
2004-09-28 18:37:50 +00:00
|
|
|
{
|
|
|
|
if (mLayoutManager) {
|
2010-03-18 19:58:15 +00:00
|
|
|
nsSize layoutSize = mLayoutManager->GetPrefSize(this, aBoxLayoutState);
|
|
|
|
if (!widthSet)
|
|
|
|
size.width = layoutSize.width;
|
|
|
|
if (!heightSet)
|
|
|
|
size.height = layoutSize.height;
|
|
|
|
}
|
|
|
|
else {
|
2007-01-08 02:57:59 +00:00
|
|
|
size = nsBox::GetPrefSize(aBoxLayoutState);
|
2010-03-18 19:58:15 +00:00
|
|
|
}
|
2004-09-28 18:37:50 +00:00
|
|
|
}
|
|
|
|
|
2007-01-08 03:49:59 +00:00
|
|
|
nsSize minSize = GetMinSize(aBoxLayoutState);
|
|
|
|
nsSize maxSize = GetMaxSize(aBoxLayoutState);
|
2008-01-05 05:49:44 +00:00
|
|
|
mPrefSize = BoundsCheck(minSize, size, maxSize);
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2008-01-05 05:49:44 +00:00
|
|
|
return mPrefSize;
|
2000-03-31 07:02:06 +00:00
|
|
|
}
|
1999-10-21 20:17:51 +00:00
|
|
|
|
2007-01-31 16:02:42 +00:00
|
|
|
nscoord
|
|
|
|
nsBoxFrame::GetBoxAscent(nsBoxLayoutState& aBoxLayoutState)
|
2000-03-31 07:02:06 +00:00
|
|
|
{
|
2007-01-31 16:02:42 +00:00
|
|
|
if (!DoesNeedRecalc(mAscent))
|
|
|
|
return mAscent;
|
1999-07-23 23:30:17 +00:00
|
|
|
|
2004-06-19 09:07:47 +00:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2000-03-31 07:02:06 +00:00
|
|
|
PropagateDebug(aBoxLayoutState);
|
2004-06-19 09:07:47 +00:00
|
|
|
#endif
|
1999-07-23 23:30:17 +00:00
|
|
|
|
2011-06-15 21:03:49 +00:00
|
|
|
if (IsCollapsed())
|
2007-01-31 16:02:42 +00:00
|
|
|
return 0;
|
2004-09-28 18:37:50 +00:00
|
|
|
|
|
|
|
if (mLayoutManager)
|
2008-01-09 07:28:39 +00:00
|
|
|
mAscent = mLayoutManager->GetAscent(this, aBoxLayoutState);
|
2004-09-28 18:37:50 +00:00
|
|
|
else
|
2007-01-31 16:02:42 +00:00
|
|
|
mAscent = nsBox::GetBoxAscent(aBoxLayoutState);
|
2004-09-28 18:37:50 +00:00
|
|
|
|
2007-01-31 16:02:42 +00:00
|
|
|
return mAscent;
|
2000-03-31 07:02:06 +00:00
|
|
|
}
|
1999-07-23 23:30:17 +00:00
|
|
|
|
2007-01-08 02:57:59 +00:00
|
|
|
nsSize
|
|
|
|
nsBoxFrame::GetMinSize(nsBoxLayoutState& aBoxLayoutState)
|
2000-03-31 07:02:06 +00:00
|
|
|
{
|
2007-04-29 22:24:59 +00:00
|
|
|
NS_ASSERTION(aBoxLayoutState.GetRenderingContext(),
|
|
|
|
"must have rendering context");
|
|
|
|
|
2007-01-08 02:57:59 +00:00
|
|
|
nsSize size(0,0);
|
|
|
|
DISPLAY_MIN_SIZE(this, size);
|
2000-06-06 01:25:03 +00:00
|
|
|
if (!DoesNeedRecalc(mMinSize)) {
|
2010-03-18 19:58:15 +00:00
|
|
|
return mMinSize;
|
2000-03-31 07:02:06 +00:00
|
|
|
}
|
1999-07-23 23:30:17 +00:00
|
|
|
|
2004-06-19 09:07:47 +00:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2000-03-31 07:02:06 +00:00
|
|
|
PropagateDebug(aBoxLayoutState);
|
2004-06-19 09:07:47 +00:00
|
|
|
#endif
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
|
2011-06-15 21:03:49 +00:00
|
|
|
if (IsCollapsed())
|
2007-01-08 02:57:59 +00:00
|
|
|
return size;
|
2004-09-28 18:37:50 +00:00
|
|
|
|
|
|
|
// if the size was not completely redefined in CSS then ask our children
|
2011-09-29 06:19:26 +00:00
|
|
|
bool widthSet, heightSet;
|
2012-08-06 03:00:57 +00:00
|
|
|
if (!nsIFrame::AddCSSMinSize(aBoxLayoutState, this, size, widthSet, heightSet))
|
2004-09-28 18:37:50 +00:00
|
|
|
{
|
|
|
|
if (mLayoutManager) {
|
2010-03-18 19:58:15 +00:00
|
|
|
nsSize layoutSize = mLayoutManager->GetMinSize(this, aBoxLayoutState);
|
|
|
|
if (!widthSet)
|
|
|
|
size.width = layoutSize.width;
|
|
|
|
if (!heightSet)
|
|
|
|
size.height = layoutSize.height;
|
|
|
|
}
|
|
|
|
else {
|
2007-01-08 02:57:59 +00:00
|
|
|
size = nsBox::GetMinSize(aBoxLayoutState);
|
2004-09-28 18:37:50 +00:00
|
|
|
}
|
|
|
|
}
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2007-01-08 02:57:59 +00:00
|
|
|
mMinSize = size;
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
|
2007-01-08 02:57:59 +00:00
|
|
|
return size;
|
2000-03-31 07:02:06 +00:00
|
|
|
}
|
1999-07-23 23:30:17 +00:00
|
|
|
|
2007-01-08 02:57:59 +00:00
|
|
|
nsSize
|
|
|
|
nsBoxFrame::GetMaxSize(nsBoxLayoutState& aBoxLayoutState)
|
2000-03-31 07:02:06 +00:00
|
|
|
{
|
2007-04-29 22:24:59 +00:00
|
|
|
NS_ASSERTION(aBoxLayoutState.GetRenderingContext(),
|
|
|
|
"must have rendering context");
|
|
|
|
|
2007-01-08 02:57:59 +00:00
|
|
|
nsSize size(NS_INTRINSICSIZE, NS_INTRINSICSIZE);
|
|
|
|
DISPLAY_MAX_SIZE(this, size);
|
2000-06-06 01:25:03 +00:00
|
|
|
if (!DoesNeedRecalc(mMaxSize)) {
|
2010-03-18 19:58:15 +00:00
|
|
|
return mMaxSize;
|
2000-03-31 07:02:06 +00:00
|
|
|
}
|
1999-07-23 23:30:17 +00:00
|
|
|
|
2004-06-19 09:07:47 +00:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2000-03-31 07:02:06 +00:00
|
|
|
PropagateDebug(aBoxLayoutState);
|
2004-06-19 09:07:47 +00:00
|
|
|
#endif
|
2000-03-02 03:01:30 +00:00
|
|
|
|
2011-06-15 21:03:49 +00:00
|
|
|
if (IsCollapsed())
|
2007-01-08 02:57:59 +00:00
|
|
|
return size;
|
2004-09-28 18:37:50 +00:00
|
|
|
|
|
|
|
// if the size was not completely redefined in CSS then ask our children
|
2011-09-29 06:19:26 +00:00
|
|
|
bool widthSet, heightSet;
|
2012-08-06 03:00:57 +00:00
|
|
|
if (!nsIFrame::AddCSSMaxSize(this, size, widthSet, heightSet))
|
2004-09-28 18:37:50 +00:00
|
|
|
{
|
|
|
|
if (mLayoutManager) {
|
2010-03-18 19:58:15 +00:00
|
|
|
nsSize layoutSize = mLayoutManager->GetMaxSize(this, aBoxLayoutState);
|
|
|
|
if (!widthSet)
|
|
|
|
size.width = layoutSize.width;
|
|
|
|
if (!heightSet)
|
|
|
|
size.height = layoutSize.height;
|
|
|
|
}
|
|
|
|
else {
|
2007-01-08 02:57:59 +00:00
|
|
|
size = nsBox::GetMaxSize(aBoxLayoutState);
|
2004-09-28 18:37:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-08 02:57:59 +00:00
|
|
|
mMaxSize = size;
|
2000-03-02 03:01:30 +00:00
|
|
|
|
2007-01-08 02:57:59 +00:00
|
|
|
return size;
|
1999-03-27 01:35:55 +00:00
|
|
|
}
|
|
|
|
|
2007-01-31 16:02:42 +00:00
|
|
|
nscoord
|
|
|
|
nsBoxFrame::GetFlex(nsBoxLayoutState& aBoxLayoutState)
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
{
|
2007-01-31 16:02:42 +00:00
|
|
|
if (!DoesNeedRecalc(mFlex))
|
|
|
|
return mFlex;
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
|
2007-01-31 16:02:42 +00:00
|
|
|
mFlex = nsBox::GetFlex(aBoxLayoutState);
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
|
2007-01-31 16:02:42 +00:00
|
|
|
return mFlex;
|
2000-03-31 07:02:06 +00:00
|
|
|
}
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
|
2000-07-07 22:24:06 +00:00
|
|
|
/**
|
|
|
|
* If subclassing please subclass this method not layout.
|
|
|
|
* layout will call this method.
|
|
|
|
*/
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBoxFrame::DoLayout(nsBoxLayoutState& aState)
|
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t oldFlags = aState.LayoutFlags();
|
2004-09-28 18:37:50 +00:00
|
|
|
aState.SetLayoutFlags(0);
|
|
|
|
|
|
|
|
nsresult rv = NS_OK;
|
2009-10-22 00:11:25 +00:00
|
|
|
if (mLayoutManager) {
|
|
|
|
CoordNeedsRecalc(mAscent);
|
2004-09-28 18:37:50 +00:00
|
|
|
rv = mLayoutManager->Layout(this, aState);
|
2009-10-22 00:11:25 +00:00
|
|
|
}
|
2004-09-28 18:37:50 +00:00
|
|
|
|
|
|
|
aState.SetLayoutFlags(oldFlags);
|
|
|
|
|
2012-03-10 22:49:10 +00:00
|
|
|
if (HasAbsolutelyPositionedChildren()) {
|
|
|
|
// Set up a |reflowState| to pass into ReflowAbsoluteFrames
|
2014-07-24 08:28:46 +00:00
|
|
|
WritingMode wm = GetWritingMode();
|
2012-03-10 22:49:10 +00:00
|
|
|
nsHTMLReflowState reflowState(aState.PresContext(), this,
|
|
|
|
aState.GetRenderingContext(),
|
2014-07-24 08:28:46 +00:00
|
|
|
LogicalSize(wm, GetLogicalSize().ISize(wm),
|
|
|
|
NS_UNCONSTRAINEDSIZE));
|
2012-03-10 22:49:10 +00:00
|
|
|
|
|
|
|
// Set up a |desiredSize| to pass into ReflowAbsoluteFrames
|
2013-12-31 13:50:31 +00:00
|
|
|
nsHTMLReflowMetrics desiredSize(reflowState);
|
2013-12-27 17:59:52 +00:00
|
|
|
desiredSize.Width() = mRect.width;
|
|
|
|
desiredSize.Height() = mRect.height;
|
2012-03-10 22:49:10 +00:00
|
|
|
|
|
|
|
// get the ascent (cribbed from ::Reflow)
|
|
|
|
nscoord ascent = mRect.height;
|
|
|
|
|
|
|
|
// getting the ascent could be a lot of work. Don't get it if
|
|
|
|
// we are the root. The viewport doesn't care about it.
|
|
|
|
if (!(mState & NS_STATE_IS_ROOT)) {
|
|
|
|
ascent = GetBoxAscent(aState);
|
|
|
|
}
|
2014-06-11 09:45:31 +00:00
|
|
|
desiredSize.SetBlockStartAscent(ascent);
|
2012-03-10 22:49:10 +00:00
|
|
|
desiredSize.mOverflowAreas = GetOverflowAreas();
|
|
|
|
|
2014-01-03 21:08:50 +00:00
|
|
|
AddStateBits(NS_FRAME_IN_REFLOW);
|
2012-03-10 22:49:10 +00:00
|
|
|
// Set up a |reflowStatus| to pass into ReflowAbsoluteFrames
|
|
|
|
// (just a dummy value; hopefully that's OK)
|
|
|
|
nsReflowStatus reflowStatus = NS_FRAME_COMPLETE;
|
|
|
|
ReflowAbsoluteFrames(aState.PresContext(), desiredSize,
|
|
|
|
reflowState, reflowStatus);
|
2014-01-03 21:08:50 +00:00
|
|
|
RemoveStateBits(NS_FRAME_IN_REFLOW);
|
2012-03-10 22:49:10 +00:00
|
|
|
}
|
|
|
|
|
2004-09-28 18:37:50 +00:00
|
|
|
return rv;
|
2000-07-07 22:24:06 +00:00
|
|
|
}
|
|
|
|
|
2006-04-10 00:16:29 +00:00
|
|
|
void
|
2009-12-24 05:21:15 +00:00
|
|
|
nsBoxFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
2000-02-17 04:10:02 +00:00
|
|
|
{
|
2002-02-21 13:39:39 +00:00
|
|
|
// unregister access key
|
2011-10-17 14:59:28 +00:00
|
|
|
RegUnregAccessKey(false);
|
2002-02-21 13:39:39 +00:00
|
|
|
|
2003-03-26 06:52:20 +00:00
|
|
|
// clean up the container box's layout manager and child boxes
|
2012-07-30 14:20:58 +00:00
|
|
|
SetLayoutManager(nullptr);
|
2000-04-18 00:17:00 +00:00
|
|
|
|
2009-12-24 05:21:15 +00:00
|
|
|
nsContainerFrame::DestroyFrom(aDestructRoot);
|
2000-02-17 04:10:02 +00:00
|
|
|
}
|
|
|
|
|
2004-06-19 09:07:47 +00:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2014-02-18 07:47:48 +00:00
|
|
|
nsresult
|
2011-09-29 06:19:26 +00:00
|
|
|
nsBoxFrame::SetDebug(nsBoxLayoutState& aState, bool aDebug)
|
2000-03-02 03:01:30 +00:00
|
|
|
{
|
|
|
|
// see if our state matches the given debug state
|
2011-09-29 06:19:26 +00:00
|
|
|
bool debugSet = mState & NS_STATE_CURRENTLY_IN_DEBUG;
|
|
|
|
bool debugChanged = (!aDebug && debugSet) || (aDebug && !debugSet);
|
2000-03-02 03:01:30 +00:00
|
|
|
|
|
|
|
// if it doesn't then tell each child below us the new debug state
|
|
|
|
if (debugChanged)
|
|
|
|
{
|
|
|
|
if (aDebug) {
|
|
|
|
mState |= NS_STATE_CURRENTLY_IN_DEBUG;
|
|
|
|
} else {
|
|
|
|
mState &= ~NS_STATE_CURRENTLY_IN_DEBUG;
|
|
|
|
}
|
2000-03-31 07:02:06 +00:00
|
|
|
|
|
|
|
SetDebugOnChildList(aState, mFirstChild, aDebug);
|
2000-03-02 03:01:30 +00:00
|
|
|
|
2014-07-24 17:03:26 +00:00
|
|
|
MarkIntrinsicISizesDirty();
|
2000-03-02 03:01:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2004-06-19 09:07:47 +00:00
|
|
|
#endif
|
2000-03-02 03:01:30 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
/* virtual */ void
|
2014-07-24 17:03:26 +00:00
|
|
|
nsBoxFrame::MarkIntrinsicISizesDirty()
|
2000-03-02 03:01:30 +00:00
|
|
|
{
|
2002-10-10 06:39:30 +00:00
|
|
|
SizeNeedsRecalc(mPrefSize);
|
|
|
|
SizeNeedsRecalc(mMinSize);
|
|
|
|
SizeNeedsRecalc(mMaxSize);
|
|
|
|
CoordNeedsRecalc(mFlex);
|
|
|
|
CoordNeedsRecalc(mAscent);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
|
|
|
if (mLayoutManager) {
|
2007-03-30 21:11:41 +00:00
|
|
|
nsBoxLayoutState state(PresContext());
|
2014-07-24 17:03:26 +00:00
|
|
|
mLayoutManager->IntrinsicISizesDirty(this, state);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Don't call base class method, since everything it does is within an
|
|
|
|
// IsBoxWrapped check.
|
2000-03-31 07:02:06 +00:00
|
|
|
}
|
|
|
|
|
2014-05-28 19:36:58 +00:00
|
|
|
void
|
2011-08-24 20:54:30 +00:00
|
|
|
nsBoxFrame::RemoveFrame(ChildListID aListID,
|
2002-10-10 06:39:30 +00:00
|
|
|
nsIFrame* aOldFrame)
|
2000-03-31 07:02:06 +00:00
|
|
|
{
|
2011-08-24 20:54:30 +00:00
|
|
|
NS_PRECONDITION(aListID == kPrincipalList, "We don't support out-of-flow kids");
|
2007-03-30 21:11:41 +00:00
|
|
|
nsPresContext* presContext = PresContext();
|
2005-02-07 01:58:25 +00:00
|
|
|
nsBoxLayoutState state(presContext);
|
2000-03-31 07:02:06 +00:00
|
|
|
|
|
|
|
// remove the child frame
|
2004-09-28 18:37:50 +00:00
|
|
|
mFrames.RemoveFrame(aOldFrame);
|
|
|
|
|
|
|
|
// notify the layout manager
|
|
|
|
if (mLayoutManager)
|
|
|
|
mLayoutManager->ChildrenRemoved(this, state, aOldFrame);
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2004-09-28 18:37:50 +00:00
|
|
|
// destroy the child frame
|
2006-04-10 00:16:29 +00:00
|
|
|
aOldFrame->Destroy();
|
2000-03-31 07:02:06 +00:00
|
|
|
|
|
|
|
// mark us dirty and generate a reflow command
|
2007-03-30 21:11:41 +00:00
|
|
|
PresContext()->PresShell()->
|
2007-05-06 19:16:51 +00:00
|
|
|
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
2000-03-02 03:01:30 +00:00
|
|
|
}
|
|
|
|
|
2014-05-28 19:36:58 +00:00
|
|
|
void
|
2011-08-24 20:54:30 +00:00
|
|
|
nsBoxFrame::InsertFrames(ChildListID aListID,
|
2002-10-10 06:39:30 +00:00
|
|
|
nsIFrame* aPrevFrame,
|
2009-07-30 17:23:32 +00:00
|
|
|
nsFrameList& aFrameList)
|
1999-05-09 21:46:24 +00:00
|
|
|
{
|
2006-06-29 02:32:36 +00:00
|
|
|
NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == this,
|
|
|
|
"inserting after sibling frame with different parent");
|
2007-10-20 05:43:38 +00:00
|
|
|
NS_ASSERTION(!aPrevFrame || mFrames.ContainsFrame(aPrevFrame),
|
|
|
|
"inserting after sibling frame not in our child list");
|
2011-08-24 20:54:30 +00:00
|
|
|
NS_PRECONDITION(aListID == kPrincipalList, "We don't support out-of-flow kids");
|
2007-03-30 21:11:41 +00:00
|
|
|
nsBoxLayoutState state(PresContext());
|
2004-09-28 18:37:50 +00:00
|
|
|
|
|
|
|
// insert the child frames
|
2009-07-30 17:23:32 +00:00
|
|
|
const nsFrameList::Slice& newFrames =
|
|
|
|
mFrames.InsertFrames(this, aPrevFrame, aFrameList);
|
1999-11-18 21:05:43 +00:00
|
|
|
|
2004-09-28 18:37:50 +00:00
|
|
|
// notify the layout manager
|
|
|
|
if (mLayoutManager)
|
2009-07-30 17:23:32 +00:00
|
|
|
mLayoutManager->ChildrenInserted(this, state, aPrevFrame, newFrames);
|
2004-09-28 18:37:50 +00:00
|
|
|
|
2010-06-28 20:47:58 +00:00
|
|
|
// Make sure to check box order _after_ notifying the layout
|
|
|
|
// manager; otherwise the slice we give the layout manager will
|
|
|
|
// just be bogus. If the layout manager cares about the order, we
|
|
|
|
// just lose.
|
2012-11-30 23:25:32 +00:00
|
|
|
CheckBoxOrder();
|
2010-06-28 20:47:58 +00:00
|
|
|
|
2004-06-19 09:07:47 +00:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2000-03-02 03:01:30 +00:00
|
|
|
// if we are in debug make sure our children are in debug as well.
|
|
|
|
if (mState & NS_STATE_CURRENTLY_IN_DEBUG)
|
2011-10-17 14:59:28 +00:00
|
|
|
SetDebugOnChildList(state, mFrames.FirstChild(), true);
|
2004-06-19 09:07:47 +00:00
|
|
|
#endif
|
2000-03-02 03:01:30 +00:00
|
|
|
|
2007-03-30 21:11:41 +00:00
|
|
|
PresContext()->PresShell()->
|
2007-05-06 19:16:51 +00:00
|
|
|
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
1999-11-18 21:05:43 +00:00
|
|
|
}
|
|
|
|
|
1999-05-09 21:46:24 +00:00
|
|
|
|
2014-05-28 19:36:58 +00:00
|
|
|
void
|
2011-08-24 20:54:30 +00:00
|
|
|
nsBoxFrame::AppendFrames(ChildListID aListID,
|
2009-07-30 17:23:32 +00:00
|
|
|
nsFrameList& aFrameList)
|
1999-05-09 21:46:24 +00:00
|
|
|
{
|
2011-08-24 20:54:30 +00:00
|
|
|
NS_PRECONDITION(aListID == kPrincipalList, "We don't support out-of-flow kids");
|
2007-03-30 21:11:41 +00:00
|
|
|
nsBoxLayoutState state(PresContext());
|
1999-05-18 04:06:52 +00:00
|
|
|
|
2004-09-28 18:37:50 +00:00
|
|
|
// append the new frames
|
2009-07-30 17:23:32 +00:00
|
|
|
const nsFrameList::Slice& newFrames = mFrames.AppendFrames(this, aFrameList);
|
2004-09-28 18:37:50 +00:00
|
|
|
|
|
|
|
// notify the layout manager
|
|
|
|
if (mLayoutManager)
|
2009-07-30 17:23:32 +00:00
|
|
|
mLayoutManager->ChildrenAppended(this, state, newFrames);
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2010-06-28 20:47:58 +00:00
|
|
|
// Make sure to check box order _after_ notifying the layout
|
|
|
|
// manager; otherwise the slice we give the layout manager will
|
|
|
|
// just be bogus. If the layout manager cares about the order, we
|
|
|
|
// just lose.
|
2012-11-30 23:25:32 +00:00
|
|
|
CheckBoxOrder();
|
2010-06-28 20:47:58 +00:00
|
|
|
|
2004-06-19 09:07:47 +00:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2000-03-02 03:01:30 +00:00
|
|
|
// if we are in debug make sure our children are in debug as well.
|
|
|
|
if (mState & NS_STATE_CURRENTLY_IN_DEBUG)
|
2011-10-17 14:59:28 +00:00
|
|
|
SetDebugOnChildList(state, mFrames.FirstChild(), true);
|
2004-06-19 09:07:47 +00:00
|
|
|
#endif
|
2000-03-02 03:01:30 +00:00
|
|
|
|
2007-05-06 19:16:51 +00:00
|
|
|
// XXXbz why is this NS_FRAME_FIRST_REFLOW check here?
|
2006-01-09 04:01:09 +00:00
|
|
|
if (!(GetStateBits() & NS_FRAME_FIRST_REFLOW)) {
|
2007-03-30 21:11:41 +00:00
|
|
|
PresContext()->PresShell()->
|
2007-05-06 19:16:51 +00:00
|
|
|
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
2006-01-09 04:01:09 +00:00
|
|
|
}
|
1999-05-09 21:46:24 +00:00
|
|
|
}
|
|
|
|
|
2014-05-24 22:20:39 +00:00
|
|
|
/* virtual */ nsContainerFrame*
|
2007-10-25 23:30:49 +00:00
|
|
|
nsBoxFrame::GetContentInsertionFrame()
|
|
|
|
{
|
|
|
|
if (GetStateBits() & NS_STATE_BOX_WRAPS_KIDS_IN_BLOCK)
|
2011-08-24 20:54:30 +00:00
|
|
|
return GetFirstPrincipalChild()->GetContentInsertionFrame();
|
2007-10-25 23:30:49 +00:00
|
|
|
return nsContainerFrame::GetContentInsertionFrame();
|
|
|
|
}
|
1999-03-27 01:35:55 +00:00
|
|
|
|
2014-02-18 07:47:48 +00:00
|
|
|
nsresult
|
2012-08-22 15:56:38 +00:00
|
|
|
nsBoxFrame::AttributeChanged(int32_t aNameSpaceID,
|
2002-02-21 13:39:39 +00:00
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aModType)
|
2002-02-21 13:39:39 +00:00
|
|
|
{
|
2005-09-07 16:49:21 +00:00
|
|
|
nsresult rv = nsContainerFrame::AttributeChanged(aNameSpaceID, aAttribute,
|
|
|
|
aModType);
|
2003-07-11 21:16:12 +00:00
|
|
|
|
|
|
|
// Ignore 'width', 'height', 'screenX', 'screenY' and 'sizemode' on a
|
|
|
|
// <window>.
|
2015-03-03 11:09:00 +00:00
|
|
|
if (mContent->IsAnyOfXULElements(nsGkAtoms::window,
|
|
|
|
nsGkAtoms::page,
|
|
|
|
nsGkAtoms::dialog,
|
|
|
|
nsGkAtoms::wizard) &&
|
2006-12-26 17:47:52 +00:00
|
|
|
(nsGkAtoms::width == aAttribute ||
|
|
|
|
nsGkAtoms::height == aAttribute ||
|
|
|
|
nsGkAtoms::screenX == aAttribute ||
|
|
|
|
nsGkAtoms::screenY == aAttribute ||
|
|
|
|
nsGkAtoms::sizemode == aAttribute)) {
|
2003-07-11 21:16:12 +00:00
|
|
|
return rv;
|
|
|
|
}
|
2002-02-21 13:39:39 +00:00
|
|
|
|
2006-12-26 17:47:52 +00:00
|
|
|
if (aAttribute == nsGkAtoms::width ||
|
|
|
|
aAttribute == nsGkAtoms::height ||
|
|
|
|
aAttribute == nsGkAtoms::align ||
|
|
|
|
aAttribute == nsGkAtoms::valign ||
|
|
|
|
aAttribute == nsGkAtoms::left ||
|
|
|
|
aAttribute == nsGkAtoms::top ||
|
2009-09-13 21:13:54 +00:00
|
|
|
aAttribute == nsGkAtoms::right ||
|
|
|
|
aAttribute == nsGkAtoms::bottom ||
|
2011-02-28 18:06:29 +00:00
|
|
|
aAttribute == nsGkAtoms::start ||
|
|
|
|
aAttribute == nsGkAtoms::end ||
|
2006-12-26 17:47:52 +00:00
|
|
|
aAttribute == nsGkAtoms::minwidth ||
|
|
|
|
aAttribute == nsGkAtoms::maxwidth ||
|
|
|
|
aAttribute == nsGkAtoms::minheight ||
|
|
|
|
aAttribute == nsGkAtoms::maxheight ||
|
|
|
|
aAttribute == nsGkAtoms::flex ||
|
|
|
|
aAttribute == nsGkAtoms::orient ||
|
|
|
|
aAttribute == nsGkAtoms::pack ||
|
|
|
|
aAttribute == nsGkAtoms::dir ||
|
2007-06-18 23:22:46 +00:00
|
|
|
aAttribute == nsGkAtoms::mousethrough ||
|
2006-12-26 17:47:52 +00:00
|
|
|
aAttribute == nsGkAtoms::equalsize) {
|
|
|
|
|
|
|
|
if (aAttribute == nsGkAtoms::align ||
|
|
|
|
aAttribute == nsGkAtoms::valign ||
|
|
|
|
aAttribute == nsGkAtoms::orient ||
|
|
|
|
aAttribute == nsGkAtoms::pack ||
|
2004-06-19 09:07:47 +00:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2006-12-26 17:47:52 +00:00
|
|
|
aAttribute == nsGkAtoms::debug ||
|
2004-06-19 09:07:47 +00:00
|
|
|
#endif
|
2006-12-26 17:47:52 +00:00
|
|
|
aAttribute == nsGkAtoms::dir) {
|
2002-02-21 13:39:39 +00:00
|
|
|
|
2002-10-10 06:39:30 +00:00
|
|
|
mValign = nsBoxFrame::vAlign_Top;
|
|
|
|
mHalign = nsBoxFrame::hAlign_Left;
|
2002-02-21 13:39:39 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool orient = true;
|
2002-02-21 13:39:39 +00:00
|
|
|
GetInitialOrientation(orient);
|
|
|
|
if (orient)
|
|
|
|
mState |= NS_STATE_IS_HORIZONTAL;
|
|
|
|
else
|
|
|
|
mState &= ~NS_STATE_IS_HORIZONTAL;
|
1999-05-09 21:46:24 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool normal = true;
|
2002-02-21 13:39:39 +00:00
|
|
|
GetInitialDirection(normal);
|
|
|
|
if (normal)
|
|
|
|
mState |= NS_STATE_IS_DIRECTION_NORMAL;
|
|
|
|
else
|
|
|
|
mState &= ~NS_STATE_IS_DIRECTION_NORMAL;
|
2001-12-03 23:41:13 +00:00
|
|
|
|
2002-10-10 06:39:30 +00:00
|
|
|
GetInitialVAlignment(mValign);
|
|
|
|
GetInitialHAlignment(mHalign);
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool equalSize = false;
|
2002-02-21 13:39:39 +00:00
|
|
|
GetInitialEqualSize(equalSize);
|
|
|
|
if (equalSize)
|
|
|
|
mState |= NS_STATE_EQUAL_SIZE;
|
|
|
|
else
|
|
|
|
mState &= ~NS_STATE_EQUAL_SIZE;
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
|
2004-06-19 09:07:47 +00:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2011-09-29 06:19:26 +00:00
|
|
|
bool debug = mState & NS_STATE_SET_TO_DEBUG;
|
|
|
|
bool debugSet = GetInitialDebug(debug);
|
2002-02-21 13:39:39 +00:00
|
|
|
if (debugSet) {
|
|
|
|
mState |= NS_STATE_DEBUG_WAS_SET;
|
2001-12-03 23:41:13 +00:00
|
|
|
|
2002-02-21 13:39:39 +00:00
|
|
|
if (debug)
|
|
|
|
mState |= NS_STATE_SET_TO_DEBUG;
|
|
|
|
else
|
|
|
|
mState &= ~NS_STATE_SET_TO_DEBUG;
|
|
|
|
} else {
|
|
|
|
mState &= ~NS_STATE_DEBUG_WAS_SET;
|
|
|
|
}
|
2004-06-19 09:07:47 +00:00
|
|
|
#endif
|
2000-02-14 01:42:09 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool autostretch = !!(mState & NS_STATE_AUTO_STRETCH);
|
2002-02-21 13:39:39 +00:00
|
|
|
GetInitialAutoStretch(autostretch);
|
|
|
|
if (autostretch)
|
|
|
|
mState |= NS_STATE_AUTO_STRETCH;
|
|
|
|
else
|
|
|
|
mState &= ~NS_STATE_AUTO_STRETCH;
|
2000-03-31 07:02:06 +00:00
|
|
|
}
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (aAttribute == nsGkAtoms::left ||
|
2009-09-13 21:13:54 +00:00
|
|
|
aAttribute == nsGkAtoms::top ||
|
|
|
|
aAttribute == nsGkAtoms::right ||
|
2011-02-28 18:06:29 +00:00
|
|
|
aAttribute == nsGkAtoms::bottom ||
|
|
|
|
aAttribute == nsGkAtoms::start ||
|
|
|
|
aAttribute == nsGkAtoms::end) {
|
2002-02-21 13:39:39 +00:00
|
|
|
mState &= ~NS_STATE_STACK_NOT_POSITIONED;
|
|
|
|
}
|
2007-06-18 23:22:46 +00:00
|
|
|
else if (aAttribute == nsGkAtoms::mousethrough) {
|
|
|
|
UpdateMouseThrough();
|
|
|
|
}
|
2004-09-17 18:36:30 +00:00
|
|
|
|
2007-03-30 21:11:41 +00:00
|
|
|
PresContext()->PresShell()->
|
2007-05-06 19:16:51 +00:00
|
|
|
FrameNeedsReflow(this, nsIPresShell::eStyleChange, NS_FRAME_IS_DIRTY);
|
2002-02-21 13:39:39 +00:00
|
|
|
}
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (aAttribute == nsGkAtoms::ordinal) {
|
2007-03-30 21:11:41 +00:00
|
|
|
nsBoxLayoutState state(PresContext());
|
2014-05-24 22:20:41 +00:00
|
|
|
nsIFrame* parent = GetParentBox(this);
|
2006-02-21 00:40:54 +00:00
|
|
|
// If our parent is not a box, there's not much we can do... but in that
|
|
|
|
// case our ordinal doesn't matter anyway, so that's ok.
|
2007-08-16 15:39:22 +00:00
|
|
|
// Also don't bother with popup frames since they are kept on the
|
2011-08-24 20:54:30 +00:00
|
|
|
// kPopupList and RelayoutChildAtOrdinal() only handles
|
2007-08-16 15:39:22 +00:00
|
|
|
// principal children.
|
|
|
|
if (parent && !(GetStateBits() & NS_FRAME_OUT_OF_FLOW) &&
|
2013-02-16 21:51:02 +00:00
|
|
|
StyleDisplay()->mDisplay != NS_STYLE_DISPLAY_POPUP) {
|
2007-08-16 15:39:22 +00:00
|
|
|
parent->RelayoutChildAtOrdinal(state, this);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// XXXldb Should this instead be a tree change on the child or parent?
|
2007-03-30 21:11:41 +00:00
|
|
|
PresContext()->PresShell()->
|
2007-05-06 19:16:51 +00:00
|
|
|
FrameNeedsReflow(parent, nsIPresShell::eStyleChange,
|
|
|
|
NS_FRAME_IS_DIRTY);
|
2006-02-21 00:40:54 +00:00
|
|
|
}
|
2002-02-21 13:39:39 +00:00
|
|
|
}
|
|
|
|
// If the accesskey changed, register for the new value
|
|
|
|
// The old value has been unregistered in nsXULElement::SetAttr
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (aAttribute == nsGkAtoms::accesskey) {
|
2011-10-17 14:59:28 +00:00
|
|
|
RegUnregAccessKey(true);
|
2002-02-21 13:39:39 +00:00
|
|
|
}
|
2013-09-13 11:02:30 +00:00
|
|
|
else if (aAttribute == nsGkAtoms::rows &&
|
2015-03-03 11:09:00 +00:00
|
|
|
mContent->IsXULElement(nsGkAtoms::tree)) {
|
2013-09-13 11:02:30 +00:00
|
|
|
// Reflow ourselves and all our children if "rows" changes, since
|
|
|
|
// nsTreeBodyFrame's layout reads this from its parent (this frame).
|
|
|
|
PresContext()->PresShell()->
|
|
|
|
FrameNeedsReflow(this, nsIPresShell::eStyleChange, NS_FRAME_IS_DIRTY);
|
|
|
|
}
|
2001-12-03 23:41:13 +00:00
|
|
|
|
1999-03-27 01:35:55 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2004-06-19 09:07:47 +00:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2000-03-31 07:02:06 +00:00
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsBoxFrame::GetDebugPref(nsPresContext* aPresContext)
|
2000-03-31 07:02:06 +00:00
|
|
|
{
|
2011-05-25 06:31:59 +00:00
|
|
|
gDebug = Preferences::GetBool("xul.debug.box");
|
2000-03-31 07:02:06 +00:00
|
|
|
}
|
2000-09-01 00:59:09 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
class nsDisplayXULDebug : public nsDisplayItem {
|
|
|
|
public:
|
2010-08-13 10:01:13 +00:00
|
|
|
nsDisplayXULDebug(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame) :
|
|
|
|
nsDisplayItem(aBuilder, aFrame) {
|
2006-01-29 18:48:58 +00:00
|
|
|
MOZ_COUNT_CTOR(nsDisplayXULDebug);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayXULDebug() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayXULDebug);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-04-08 00:31:26 +00:00
|
|
|
virtual void HitTest(nsDisplayListBuilder* aBuilder, nsRect aRect,
|
|
|
|
HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames) {
|
|
|
|
nsPoint rectCenter(aRect.x + aRect.width / 2, aRect.y + aRect.height / 2);
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<nsBoxFrame*>(mFrame)->
|
2010-08-13 10:01:58 +00:00
|
|
|
DisplayDebugInfoFor(this, rectCenter - ToReferenceFrame());
|
2010-04-08 00:31:26 +00:00
|
|
|
aOutFrames->AppendElement(this);
|
2000-09-01 00:59:09 +00:00
|
|
|
}
|
2009-09-07 00:35:14 +00:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder
|
2011-04-08 01:04:40 +00:00
|
|
|
nsRenderingContext* aCtx);
|
2010-07-15 21:07:49 +00:00
|
|
|
NS_DISPLAY_DECL_NAME("XULDebug", TYPE_XUL_DEBUG)
|
2006-01-26 02:29:17 +00:00
|
|
|
};
|
2001-04-25 19:52:49 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
void
|
|
|
|
nsDisplayXULDebug::Paint(nsDisplayListBuilder* aBuilder,
|
2011-04-08 01:04:40 +00:00
|
|
|
nsRenderingContext* aCtx)
|
2006-01-26 02:29:17 +00:00
|
|
|
{
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<nsBoxFrame*>(mFrame)->
|
2014-10-20 09:55:48 +00:00
|
|
|
PaintXULDebugOverlay(*aCtx->GetDrawTarget(), ToReferenceFrame());
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
2000-09-01 00:59:09 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
static void
|
2011-04-08 01:04:40 +00:00
|
|
|
PaintXULDebugBackground(nsIFrame* aFrame, nsRenderingContext* aCtx,
|
2006-01-26 02:29:17 +00:00
|
|
|
const nsRect& aDirtyRect, nsPoint aPt)
|
|
|
|
{
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<nsBoxFrame*>(aFrame)->PaintXULDebugBackground(*aCtx, aPt);
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-02-14 11:12:27 +00:00
|
|
|
void
|
2006-01-26 02:29:17 +00:00
|
|
|
nsBoxFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
2014-06-04 12:44:26 +00:00
|
|
|
bool forceLayer = false;
|
|
|
|
uint32_t flags = 0;
|
|
|
|
mozilla::layers::FrameMetrics::ViewID scrollTargetId =
|
|
|
|
mozilla::layers::FrameMetrics::NULL_SCROLL_ID;
|
2015-04-13 03:03:02 +00:00
|
|
|
float scrollbarThumbRatio = 0.0f;
|
2010-08-27 23:15:08 +00:00
|
|
|
|
2015-03-03 11:08:59 +00:00
|
|
|
if (GetContent()->IsXULElement()) {
|
2014-06-04 12:44:26 +00:00
|
|
|
// forcelayer is only supported on XUL elements with box layout
|
|
|
|
if (GetContent()->HasAttr(kNameSpaceID_None, nsGkAtoms::layer)) {
|
|
|
|
forceLayer = true;
|
|
|
|
} else {
|
|
|
|
nsIFrame* parent = GetParentBox(this);
|
|
|
|
if (parent && parent->GetType() == nsGkAtoms::sliderFrame) {
|
|
|
|
aBuilder->GetScrollbarInfo(&scrollTargetId, &flags);
|
2014-06-04 12:44:26 +00:00
|
|
|
forceLayer = (scrollTargetId != layers::FrameMetrics::NULL_SCROLL_ID);
|
|
|
|
nsLayoutUtils::SetScrollbarThumbLayerization(this, forceLayer);
|
2015-04-13 03:03:02 +00:00
|
|
|
|
|
|
|
nsSliderFrame* slider = do_QueryFrame(parent);
|
|
|
|
scrollbarThumbRatio = slider->GetThumbRatio();
|
2011-05-13 16:40:46 +00:00
|
|
|
}
|
2014-06-04 12:44:26 +00:00
|
|
|
}
|
|
|
|
// Check for frames that are marked as a part of the region used
|
|
|
|
// in calculating glass margins on Windows.
|
|
|
|
const nsStyleDisplay* styles = StyleDisplay();
|
|
|
|
if (styles && styles->mAppearance == NS_THEME_WIN_EXCLUDE_GLASS) {
|
2014-10-28 23:33:52 +00:00
|
|
|
aBuilder->AddWindowExcludeGlassRegion(
|
2014-07-15 04:23:37 +00:00
|
|
|
nsRect(aBuilder->ToReferenceFrame(this), GetSize()));
|
2014-06-04 12:44:26 +00:00
|
|
|
}
|
2011-05-13 16:40:46 +00:00
|
|
|
}
|
|
|
|
|
2010-08-27 23:15:08 +00:00
|
|
|
nsDisplayListCollection tempLists;
|
|
|
|
const nsDisplayListSet& destination = forceLayer ? tempLists : aLists;
|
|
|
|
|
2013-02-14 11:08:08 +00:00
|
|
|
DisplayBorderBackgroundOutline(aBuilder, destination);
|
2006-01-26 02:29:17 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG_LAYOUT
|
|
|
|
if (mState & NS_STATE_CURRENTLY_IN_DEBUG) {
|
2013-02-14 11:08:08 +00:00
|
|
|
destination.BorderBackground()->AppendNewToTop(new (aBuilder)
|
|
|
|
nsDisplayGeneric(aBuilder, this, PaintXULDebugBackground,
|
|
|
|
"XULDebugBackground"));
|
|
|
|
destination.Outlines()->AppendNewToTop(new (aBuilder)
|
|
|
|
nsDisplayXULDebug(aBuilder, this));
|
2001-04-25 19:52:49 +00:00
|
|
|
}
|
2006-01-26 02:29:17 +00:00
|
|
|
#endif
|
2001-04-25 19:52:49 +00:00
|
|
|
|
2013-02-14 11:08:08 +00:00
|
|
|
BuildDisplayListForChildren(aBuilder, aDirtyRect, destination);
|
2000-09-01 00:59:09 +00:00
|
|
|
|
|
|
|
// see if we have to draw a selection frame around this container
|
2013-02-14 11:08:08 +00:00
|
|
|
DisplaySelectionOverlay(aBuilder, destination.Content());
|
2010-08-27 23:15:08 +00:00
|
|
|
|
|
|
|
if (forceLayer) {
|
|
|
|
// This is a bit of a hack. Collect up all descendant display items
|
|
|
|
// and merge them into a single Content() list. This can cause us
|
|
|
|
// to violate CSS stacking order, but forceLayer is a magic
|
|
|
|
// XUL-only extension anyway.
|
|
|
|
nsDisplayList masterList;
|
|
|
|
masterList.AppendToTop(tempLists.BorderBackground());
|
|
|
|
masterList.AppendToTop(tempLists.BlockBorderBackgrounds());
|
|
|
|
masterList.AppendToTop(tempLists.Floats());
|
|
|
|
masterList.AppendToTop(tempLists.Content());
|
|
|
|
masterList.AppendToTop(tempLists.PositionedDescendants());
|
|
|
|
masterList.AppendToTop(tempLists.Outlines());
|
2014-06-04 12:44:26 +00:00
|
|
|
|
2010-08-27 23:15:08 +00:00
|
|
|
// Wrap the list to make it its own layer
|
2013-02-14 11:08:08 +00:00
|
|
|
aLists.Content()->AppendNewToTop(new (aBuilder)
|
2015-04-13 03:03:02 +00:00
|
|
|
nsDisplayOwnLayer(aBuilder, this, &masterList, flags, scrollTargetId,
|
|
|
|
scrollbarThumbRatio));
|
2010-08-27 23:15:08 +00:00
|
|
|
}
|
2000-09-01 00:59:09 +00:00
|
|
|
}
|
|
|
|
|
2013-02-14 11:12:27 +00:00
|
|
|
void
|
2006-01-26 02:29:17 +00:00
|
|
|
nsBoxFrame::BuildDisplayListForChildren(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
|
|
|
nsIFrame* kid = mFrames.FirstChild();
|
|
|
|
// Put each child's background onto the BlockBorderBackgrounds list
|
|
|
|
// to emulate the existing two-layer XUL painting scheme.
|
|
|
|
nsDisplayListSet set(aLists, aLists.BlockBorderBackgrounds());
|
|
|
|
// The children should be in the right order
|
|
|
|
while (kid) {
|
2013-02-14 11:08:08 +00:00
|
|
|
BuildDisplayListForChild(aBuilder, kid, aDirtyRect, set);
|
2006-01-26 02:29:17 +00:00
|
|
|
kid = kid->GetNextSibling();
|
2000-09-01 00:59:09 +00:00
|
|
|
}
|
1999-09-10 00:57:01 +00:00
|
|
|
}
|
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
// REVIEW: PaintChildren did a few things none of which are a big deal
|
|
|
|
// anymore:
|
|
|
|
// * Paint some debugging rects for this frame.
|
|
|
|
// This is done by nsDisplayXULDebugBackground, which goes in the
|
|
|
|
// BorderBackground() layer so it isn't clipped by OVERFLOW_CLIP.
|
|
|
|
// * Apply OVERFLOW_CLIP to the children.
|
|
|
|
// This is now in nsFrame::BuildDisplayListForStackingContext/Child.
|
|
|
|
// * Actually paint the children.
|
|
|
|
// Moved to BuildDisplayList.
|
|
|
|
// * Paint per-kid debug information.
|
|
|
|
// This is done by nsDisplayXULDebug, which is in the Outlines()
|
|
|
|
// layer so it goes on top. This means it is not clipped by OVERFLOW_CLIP,
|
|
|
|
// whereas it did used to respect OVERFLOW_CLIP, but too bad.
|
|
|
|
#ifdef DEBUG_LAYOUT
|
2000-02-25 04:18:34 +00:00
|
|
|
void
|
2011-04-08 01:04:40 +00:00
|
|
|
nsBoxFrame::PaintXULDebugBackground(nsRenderingContext& aRenderingContext,
|
2006-01-26 02:29:17 +00:00
|
|
|
nsPoint aPt)
|
2000-02-25 04:18:34 +00:00
|
|
|
{
|
2000-03-31 07:02:06 +00:00
|
|
|
nsMargin border;
|
2000-04-25 07:10:48 +00:00
|
|
|
GetBorder(border);
|
|
|
|
|
2004-06-19 09:07:47 +00:00
|
|
|
nsMargin debugBorder;
|
|
|
|
nsMargin debugMargin;
|
|
|
|
nsMargin debugPadding;
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool isHorizontal = IsHorizontal();
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
GetDebugBorder(debugBorder);
|
|
|
|
PixelMarginToTwips(GetPresContext(), debugBorder);
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
GetDebugMargin(debugMargin);
|
|
|
|
PixelMarginToTwips(GetPresContext(), debugMargin);
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
GetDebugPadding(debugPadding);
|
|
|
|
PixelMarginToTwips(GetPresContext(), debugPadding);
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2007-01-31 16:02:42 +00:00
|
|
|
nsRect inner(mRect);
|
|
|
|
inner.MoveTo(aPt);
|
2006-01-26 02:29:17 +00:00
|
|
|
inner.Deflate(debugMargin);
|
|
|
|
inner.Deflate(border);
|
|
|
|
//nsRect borderRect(inner);
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2014-10-17 14:06:34 +00:00
|
|
|
int32_t appUnitsPerDevPixel = PresContext()->AppUnitsPerDevPixel();
|
|
|
|
|
|
|
|
ColorPattern color(ToDeviceColor(isHorizontal ? Color(0.f, 0.f, 1.f, 1.f) :
|
2015-01-22 04:54:07 +00:00
|
|
|
Color(1.f, 0.f, 0.f, 1.f)));
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2014-10-17 14:06:34 +00:00
|
|
|
DrawTarget* drawTarget = aRenderingContext.GetDrawTarget();
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
//left
|
|
|
|
nsRect r(inner);
|
|
|
|
r.width = debugBorder.left;
|
2014-10-17 14:06:34 +00:00
|
|
|
drawTarget->FillRect(NSRectToRect(r, appUnitsPerDevPixel), color);
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
// top
|
|
|
|
r = inner;
|
|
|
|
r.height = debugBorder.top;
|
2014-10-17 14:06:34 +00:00
|
|
|
drawTarget->FillRect(NSRectToRect(r, appUnitsPerDevPixel), color);
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
//right
|
|
|
|
r = inner;
|
|
|
|
r.x = r.x + r.width - debugBorder.right;
|
|
|
|
r.width = debugBorder.right;
|
2014-10-17 14:06:34 +00:00
|
|
|
drawTarget->FillRect(NSRectToRect(r, appUnitsPerDevPixel), color);
|
2000-05-15 04:12:31 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
//bottom
|
|
|
|
r = inner;
|
|
|
|
r.y = r.y + r.height - debugBorder.bottom;
|
|
|
|
r.height = debugBorder.bottom;
|
2014-10-17 14:06:34 +00:00
|
|
|
drawTarget->FillRect(NSRectToRect(r, appUnitsPerDevPixel), color);
|
2006-01-26 02:29:17 +00:00
|
|
|
|
|
|
|
// if we have dirty children or we are dirty
|
|
|
|
// place a green border around us.
|
2007-05-06 19:16:51 +00:00
|
|
|
if (NS_SUBTREE_DIRTY(this)) {
|
2014-10-17 14:06:34 +00:00
|
|
|
nsRect dirty(inner);
|
2015-01-22 04:54:07 +00:00
|
|
|
ColorPattern green(ToDeviceColor(Color(0.f, 1.f, 0.f, 1.f)));
|
2014-10-17 14:06:34 +00:00
|
|
|
drawTarget->StrokeRect(NSRectToRect(dirty, appUnitsPerDevPixel), green);
|
2000-02-25 04:18:34 +00:00
|
|
|
}
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
2000-02-25 04:18:34 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
void
|
2014-10-20 09:55:48 +00:00
|
|
|
nsBoxFrame::PaintXULDebugOverlay(DrawTarget& aDrawTarget, nsPoint aPt)
|
2015-01-22 04:54:07 +00:00
|
|
|
{
|
2006-01-26 02:29:17 +00:00
|
|
|
nsMargin border;
|
|
|
|
GetBorder(border);
|
2000-02-25 04:18:34 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
nsMargin debugMargin;
|
|
|
|
GetDebugMargin(debugMargin);
|
|
|
|
PixelMarginToTwips(GetPresContext(), debugMargin);
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2007-01-31 16:02:42 +00:00
|
|
|
nsRect inner(mRect);
|
|
|
|
inner.MoveTo(aPt);
|
2006-01-26 02:29:17 +00:00
|
|
|
inner.Deflate(debugMargin);
|
|
|
|
inner.Deflate(border);
|
2000-02-25 04:18:34 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
nscoord onePixel = GetPresContext()->IntScaledPixelsToTwips(1);
|
1999-09-14 22:17:19 +00:00
|
|
|
|
2014-05-24 22:20:41 +00:00
|
|
|
kid = nsBox::GetChildBox(this);
|
2012-07-30 14:20:58 +00:00
|
|
|
while (nullptr != kid) {
|
2011-09-29 06:19:26 +00:00
|
|
|
bool isHorizontal = IsHorizontal();
|
1999-08-27 06:06:39 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
nscoord x, y, borderSize, spacerSize;
|
|
|
|
|
|
|
|
nsRect cr(kid->mRect);
|
|
|
|
nsMargin margin;
|
|
|
|
kid->GetMargin(margin);
|
|
|
|
cr.Inflate(margin);
|
|
|
|
|
|
|
|
if (isHorizontal)
|
|
|
|
{
|
|
|
|
cr.y = inner.y;
|
|
|
|
x = cr.x;
|
|
|
|
y = cr.y + onePixel;
|
|
|
|
spacerSize = debugBorder.top - onePixel*4;
|
|
|
|
} else {
|
|
|
|
cr.x = inner.x;
|
|
|
|
x = cr.y;
|
|
|
|
y = cr.x + onePixel;
|
|
|
|
spacerSize = debugBorder.left - onePixel*4;
|
2000-03-31 07:02:06 +00:00
|
|
|
}
|
1999-09-10 00:57:01 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
nsBoxLayoutState state(GetPresContext());
|
2007-01-31 16:02:42 +00:00
|
|
|
nscoord flex = kid->GetFlex(state);
|
1999-08-27 06:06:39 +00:00
|
|
|
|
2011-06-15 21:03:49 +00:00
|
|
|
if (!kid->IsCollapsed()) {
|
2006-01-26 02:29:17 +00:00
|
|
|
if (isHorizontal)
|
|
|
|
borderSize = cr.width;
|
|
|
|
else
|
|
|
|
borderSize = cr.height;
|
2014-10-20 09:55:48 +00:00
|
|
|
|
|
|
|
DrawSpacer(GetPresContext(), aDrawTarget, isHorizontal, flex, x, y, borderSize, spacerSize);
|
2000-03-02 03:01:30 +00:00
|
|
|
}
|
|
|
|
|
2014-05-24 22:20:41 +00:00
|
|
|
kid = GetNextBox(kid);
|
2000-03-31 07:02:06 +00:00
|
|
|
}
|
1999-07-23 00:11:21 +00:00
|
|
|
}
|
2006-01-26 02:29:17 +00:00
|
|
|
#endif
|
1999-07-23 00:11:21 +00:00
|
|
|
|
2002-09-09 21:32:33 +00:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2000-05-15 04:12:31 +00:00
|
|
|
void
|
|
|
|
nsBoxFrame::GetBoxName(nsAutoString& aName)
|
|
|
|
{
|
|
|
|
GetFrameName(aName);
|
|
|
|
}
|
2002-09-09 21:32:33 +00:00
|
|
|
#endif
|
2000-05-15 04:12:31 +00:00
|
|
|
|
2014-01-05 23:31:14 +00:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-18 07:47:48 +00:00
|
|
|
nsresult
|
2001-11-14 01:33:42 +00:00
|
|
|
nsBoxFrame::GetFrameName(nsAString& aResult) const
|
2000-03-31 07:02:06 +00:00
|
|
|
{
|
2001-11-14 01:33:42 +00:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("Box"), aResult);
|
2000-03-31 07:02:06 +00:00
|
|
|
}
|
2001-09-15 00:45:54 +00:00
|
|
|
#endif
|
1999-12-02 01:07:27 +00:00
|
|
|
|
2003-10-31 20:19:18 +00:00
|
|
|
nsIAtom*
|
|
|
|
nsBoxFrame::GetType() const
|
2001-12-07 14:51:12 +00:00
|
|
|
{
|
2006-12-26 17:47:52 +00:00
|
|
|
return nsGkAtoms::boxFrame;
|
2001-12-07 14:51:12 +00:00
|
|
|
}
|
|
|
|
|
2004-06-19 09:07:47 +00:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2014-02-18 07:47:48 +00:00
|
|
|
nsresult
|
2011-09-29 06:19:26 +00:00
|
|
|
nsBoxFrame::GetDebug(bool& aDebug)
|
2000-03-31 07:02:06 +00:00
|
|
|
{
|
|
|
|
aDebug = (mState & NS_STATE_CURRENTLY_IN_DEBUG);
|
|
|
|
return NS_OK;
|
1999-11-18 21:05:43 +00:00
|
|
|
}
|
2004-06-19 09:07:47 +00:00
|
|
|
#endif
|
1999-09-10 00:57:01 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
// REVIEW: nsBoxFrame::GetFrameForPoint is a problem because of 'mousethrough'
|
|
|
|
// attribute support. Here's how it works:
|
|
|
|
// * For each child frame F, we determine the target frame T(F) by recursively
|
|
|
|
// invoking GetFrameForPoint on the child
|
|
|
|
// * Let F' be the last child frame such that T(F') doesn't have mousethrough.
|
|
|
|
// If F' exists, return T(F')
|
|
|
|
// * Otherwise let F'' be the first child frame such that T(F'') is non-null.
|
|
|
|
// If F'' exists, return T(F'')
|
|
|
|
// * Otherwise return this frame, if this frame contains the point
|
|
|
|
// * Otherwise return null
|
|
|
|
// It's not clear how this should work for more complex z-ordering situations.
|
|
|
|
// The basic principle seems to be that if a frame F has a descendant
|
|
|
|
// 'mousethrough' frame that includes the target position, then F
|
|
|
|
// will not receive events (unless it overrides GetFrameForPoint).
|
|
|
|
// A 'mousethrough' frame will only receive an event if, after applying that rule,
|
|
|
|
// all eligible frames are 'mousethrough'; the bottom-most inner-most 'mousethrough'
|
|
|
|
// frame is then chosen (the first eligible frame reached in a
|
|
|
|
// traversal of the frame tree --- pre/post is irrelevant since ancestors
|
|
|
|
// of the mousethrough frames can't be eligible).
|
|
|
|
// IMHO this is very bogus and adds a great deal of complexity for something
|
|
|
|
// that is very rarely used. So I'm redefining 'mousethrough' to the following:
|
|
|
|
// a frame with mousethrough is transparent to mouse events. This is compatible
|
|
|
|
// with the way 'mousethrough' is used in Seamonkey's navigator.xul and
|
|
|
|
// Firefox's browser.xul. The only other place it's used is in the 'expander'
|
|
|
|
// XBL binding, which in our tree is only used by Thunderbird SMIME Advanced
|
|
|
|
// Preferences, and I can't figure out what that does, so I'll have to test it.
|
|
|
|
// If it's broken I'll probably just change the binding to use it more sensibly.
|
|
|
|
// This new behaviour is implemented in nsDisplayList::HitTest.
|
|
|
|
// REVIEW: This debug-box stuff is annoying. I'm just going to put debug boxes
|
|
|
|
// in the outline layer and avoid GetDebugBoxAt.
|
2000-04-12 02:59:26 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
// REVIEW: GetCursor had debug-only event dumping code. I have replaced it
|
|
|
|
// with instrumentation in nsDisplayXULDebug.
|
1999-10-12 00:16:06 +00:00
|
|
|
|
2006-02-13 15:49:56 +00:00
|
|
|
#ifdef DEBUG_LAYOUT
|
1999-11-18 21:05:43 +00:00
|
|
|
void
|
2014-10-20 09:55:48 +00:00
|
|
|
nsBoxFrame::DrawLine(DrawTarget& aDrawTarget, bool aHorizontal, nscoord x1, nscoord y1, nscoord x2, nscoord y2)
|
1999-11-18 21:05:43 +00:00
|
|
|
{
|
2014-10-20 09:55:48 +00:00
|
|
|
nsPoint p1(x1, y1);
|
|
|
|
nsPoint p2(x2, y2);
|
|
|
|
if (!aHorizontal) {
|
|
|
|
Swap(p1.x, p1.y);
|
|
|
|
Swap(p2.x, p2.y);
|
|
|
|
}
|
|
|
|
ColorPattern white(ToDeviceColor(Color(1.f, 1.f, 1.f, 1.f)));
|
|
|
|
StrokeLineWithSnapping(p1, p2, PresContext()->AppUnitsPerDevPixel(),
|
|
|
|
aDrawTarget, color);
|
1999-11-18 21:05:43 +00:00
|
|
|
}
|
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
void
|
2014-10-20 09:55:48 +00:00
|
|
|
nsBoxFrame::FillRect(DrawTarget& aDrawTarget, bool aHorizontal, nscoord x, nscoord y, nscoord width, nscoord height)
|
1999-11-18 21:05:43 +00:00
|
|
|
{
|
2014-10-22 11:29:06 +00:00
|
|
|
Rect rect = NSRectToSnappedRect(aHorizontal ? nsRect(x, y, width, height) :
|
|
|
|
nsRect(y, x, height, width),
|
|
|
|
PresContext()->AppUnitsPerDevPixel(),
|
|
|
|
aDrawTarget);
|
2014-10-19 12:22:22 +00:00
|
|
|
ColorPattern white(ToDeviceColor(Color(1.f, 1.f, 1.f, 1.f)));
|
2014-10-20 09:55:48 +00:00
|
|
|
aDrawTarget.FillRect(rect, white);
|
1999-11-18 21:05:43 +00:00
|
|
|
}
|
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
void
|
2014-10-20 09:55:48 +00:00
|
|
|
nsBoxFrame::DrawSpacer(nsPresContext* aPresContext, DrawTarget& aDrawTarget,
|
|
|
|
bool aHorizontal, int32_t flex, nscoord x, nscoord y,
|
|
|
|
nscoord size, nscoord spacerSize)
|
2000-03-31 07:02:06 +00:00
|
|
|
{
|
2004-07-29 19:41:39 +00:00
|
|
|
nscoord onePixel = aPresContext->IntScaledPixelsToTwips(1);
|
1999-12-02 01:07:27 +00:00
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
// if we do draw the coils
|
|
|
|
int distance = 0;
|
|
|
|
int center = 0;
|
|
|
|
int offset = 0;
|
|
|
|
int coilSize = COIL_SIZE*onePixel;
|
2001-09-18 21:47:32 +00:00
|
|
|
int halfSpacer = spacerSize/2;
|
1999-12-02 01:07:27 +00:00
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
distance = size;
|
2001-09-18 21:47:32 +00:00
|
|
|
center = y + halfSpacer;
|
2000-03-31 07:02:06 +00:00
|
|
|
offset = x;
|
1999-12-02 01:07:27 +00:00
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
int coils = distance/coilSize;
|
1999-12-02 01:07:27 +00:00
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
int halfCoilSize = coilSize/2;
|
1999-12-02 01:07:27 +00:00
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
if (flex == 0) {
|
2014-10-20 09:55:48 +00:00
|
|
|
DrawLine(aDrawTarget, aHorizontal, x,y + spacerSize/2, x + size, y + spacerSize/2);
|
2000-03-31 07:02:06 +00:00
|
|
|
} else {
|
|
|
|
for (int i=0; i < coils; i++)
|
|
|
|
{
|
2014-10-20 09:55:48 +00:00
|
|
|
DrawLine(aDrawTarget, aHorizontal, offset, center+halfSpacer, offset+halfCoilSize, center-halfSpacer);
|
|
|
|
DrawLine(aDrawTarget, aHorizontal, offset+halfCoilSize, center-halfSpacer, offset+coilSize, center+halfSpacer);
|
1999-12-02 01:07:27 +00:00
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
offset += coilSize;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-20 09:55:48 +00:00
|
|
|
FillRect(aDrawTarget, aHorizontal, x + size - spacerSize/2, y, spacerSize/2, spacerSize);
|
|
|
|
FillRect(aDrawTarget, aHorizontal, x, y, spacerSize/2, spacerSize);
|
1999-12-02 01:07:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-10-10 06:39:30 +00:00
|
|
|
nsBoxFrame::GetDebugBorder(nsMargin& aInset)
|
1999-12-02 01:07:27 +00:00
|
|
|
{
|
2000-03-31 07:02:06 +00:00
|
|
|
aInset.SizeTo(2,2,2,2);
|
|
|
|
|
2002-10-10 06:39:30 +00:00
|
|
|
if (IsHorizontal())
|
2000-03-31 07:02:06 +00:00
|
|
|
aInset.top = 10;
|
|
|
|
else
|
|
|
|
aInset.left = 10;
|
1999-12-02 01:07:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-10-10 06:39:30 +00:00
|
|
|
nsBoxFrame::GetDebugMargin(nsMargin& aInset)
|
1999-12-02 01:07:27 +00:00
|
|
|
{
|
2000-03-31 07:02:06 +00:00
|
|
|
aInset.SizeTo(2,2,2,2);
|
1999-11-18 21:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-10-10 06:39:30 +00:00
|
|
|
nsBoxFrame::GetDebugPadding(nsMargin& aPadding)
|
1999-11-18 21:05:43 +00:00
|
|
|
{
|
2000-03-31 07:02:06 +00:00
|
|
|
aPadding.SizeTo(2,2,2,2);
|
1999-11-18 21:05:43 +00:00
|
|
|
}
|
2000-03-31 07:02:06 +00:00
|
|
|
|
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsBoxFrame::PixelMarginToTwips(nsPresContext* aPresContext, nsMargin& aMarginPixels)
|
1999-11-18 21:05:43 +00:00
|
|
|
{
|
2007-02-07 07:46:44 +00:00
|
|
|
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
|
2000-03-31 07:02:06 +00:00
|
|
|
aMarginPixels.left *= onePixel;
|
|
|
|
aMarginPixels.right *= onePixel;
|
|
|
|
aMarginPixels.top *= onePixel;
|
|
|
|
aMarginPixels.bottom *= onePixel;
|
1999-11-18 21:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsBoxFrame::GetValue(nsPresContext* aPresContext, const nsSize& a, const nsSize& b, char* ch)
|
1999-11-18 21:05:43 +00:00
|
|
|
{
|
2004-07-29 19:41:39 +00:00
|
|
|
float p2t = aPresContext->ScaledPixelsToTwips();
|
2000-03-31 07:02:06 +00:00
|
|
|
|
|
|
|
char width[100];
|
|
|
|
char height[100];
|
|
|
|
|
|
|
|
if (a.width == NS_INTRINSICSIZE)
|
|
|
|
sprintf(width,"%s","INF");
|
2006-01-26 02:29:17 +00:00
|
|
|
else
|
2000-03-31 07:02:06 +00:00
|
|
|
sprintf(width,"%d", nscoord(a.width/*/p2t*/));
|
|
|
|
|
|
|
|
if (a.height == NS_INTRINSICSIZE)
|
|
|
|
sprintf(height,"%s","INF");
|
1999-12-02 01:07:27 +00:00
|
|
|
else
|
2000-03-31 07:02:06 +00:00
|
|
|
sprintf(height,"%d", nscoord(a.height/*/p2t*/));
|
1999-12-02 01:07:27 +00:00
|
|
|
|
1999-11-18 21:05:43 +00:00
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
sprintf(ch, "(%s%s, %s%s)", width, (b.width != NS_INTRINSICSIZE ? "[SET]" : ""),
|
|
|
|
height, (b.height != NS_INTRINSICSIZE ? "[SET]" : ""));
|
1999-12-02 01:07:27 +00:00
|
|
|
|
1999-11-18 21:05:43 +00:00
|
|
|
}
|
|
|
|
|
1999-12-02 01:07:27 +00:00
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsBoxFrame::GetValue(nsPresContext* aPresContext, int32_t a, int32_t b, char* ch)
|
1999-12-02 01:07:27 +00:00
|
|
|
{
|
2000-03-31 07:02:06 +00:00
|
|
|
if (a == NS_INTRINSICSIZE)
|
|
|
|
sprintf(ch, "%d[SET]", b);
|
|
|
|
else
|
|
|
|
sprintf(ch, "%d", a);
|
1999-12-02 01:07:27 +00:00
|
|
|
}
|
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
nsresult
|
2012-08-06 03:00:57 +00:00
|
|
|
nsBoxFrame::DisplayDebugInfoFor(nsIFrame* aBox,
|
2006-01-26 02:29:17 +00:00
|
|
|
nsPoint& aPoint)
|
2000-03-31 07:02:06 +00:00
|
|
|
{
|
2006-01-26 02:29:17 +00:00
|
|
|
nsBoxLayoutState state(GetPresContext());
|
2000-03-31 07:02:06 +00:00
|
|
|
|
|
|
|
nscoord x = aPoint.x;
|
|
|
|
nscoord y = aPoint.y;
|
1999-12-02 01:07:27 +00:00
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
// get the area inside our border but not our debug margins.
|
2007-01-31 16:02:42 +00:00
|
|
|
nsRect insideBorder(aBox->mRect);
|
|
|
|
insideBorder.MoveTo(0,0):
|
2000-03-31 07:02:06 +00:00
|
|
|
nsMargin border(0,0,0,0);
|
|
|
|
aBox->GetBorderAndPadding(border);
|
|
|
|
insideBorder.Deflate(border);
|
1999-12-02 01:07:27 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool isHorizontal = IsHorizontal();
|
1999-12-02 01:07:27 +00:00
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
if (!insideBorder.Contains(nsPoint(x,y)))
|
|
|
|
return NS_ERROR_FAILURE;
|
1999-12-02 01:07:27 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
//printf("%%%%%% inside box %%%%%%%\n");
|
2000-02-14 01:42:09 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
int count = 0;
|
2014-05-24 22:20:41 +00:00
|
|
|
nsIFrame* child = nsBox::GetChildBox(aBox);
|
1999-12-02 01:07:27 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
nsMargin m;
|
|
|
|
nsMargin m2;
|
|
|
|
GetDebugBorder(m);
|
|
|
|
PixelMarginToTwips(aPresContext, m);
|
1999-12-02 01:07:27 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
GetDebugMargin(m2);
|
|
|
|
PixelMarginToTwips(aPresContext, m2);
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
m += m2;
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
if ((isHorizontal && y < insideBorder.y + m.top) ||
|
|
|
|
(!isHorizontal && x < insideBorder.x + m.left)) {
|
|
|
|
//printf("**** inside debug border *******\n");
|
|
|
|
while (child)
|
|
|
|
{
|
|
|
|
const nsRect& r = child->mRect;
|
|
|
|
|
|
|
|
// if we are not in the child. But in the spacer above the child.
|
|
|
|
if ((isHorizontal && x >= r.x && x < r.x + r.width) ||
|
|
|
|
(!isHorizontal && y >= r.y && y < r.y + r.height)) {
|
|
|
|
aCursor = NS_STYLE_CURSOR_POINTER;
|
|
|
|
// found it but we already showed it.
|
|
|
|
if (mDebugChild == child)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
if (aBox->GetContent()) {
|
|
|
|
printf("---------------\n");
|
|
|
|
DumpBox(stdout);
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (child->GetContent()) {
|
|
|
|
printf("child #%d: ", count);
|
|
|
|
child->DumpBox(stdout);
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
mDebugChild = child;
|
|
|
|
|
|
|
|
nsSize prefSizeCSS(NS_INTRINSICSIZE, NS_INTRINSICSIZE);
|
|
|
|
nsSize minSizeCSS (NS_INTRINSICSIZE, NS_INTRINSICSIZE);
|
|
|
|
nsSize maxSizeCSS (NS_INTRINSICSIZE, NS_INTRINSICSIZE);
|
|
|
|
nscoord flexCSS = NS_INTRINSICSIZE;
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool widthSet, heightSet;
|
2012-08-06 03:00:57 +00:00
|
|
|
nsIFrame::AddCSSPrefSize(child, prefSizeCSS, widthSet, heightSet);
|
|
|
|
nsIFrame::AddCSSMinSize (state, child, minSizeCSS, widthSet, heightSet);
|
|
|
|
nsIFrame::AddCSSMaxSize (child, maxSizeCSS, widthSet, heightSet);
|
|
|
|
nsIFrame::AddCSSFlex (state, child, flexCSS);
|
2006-01-26 02:29:17 +00:00
|
|
|
|
2007-01-08 02:57:59 +00:00
|
|
|
nsSize prefSize = child->GetPrefSize(state);
|
|
|
|
nsSize minSize = child->GetMinSize(state);
|
|
|
|
nsSize maxSize = child->GetMaxSize(state);
|
2007-01-31 16:02:42 +00:00
|
|
|
nscoord flexSize = child->GetFlex(state);
|
|
|
|
nscoord ascentSize = child->GetBoxAscent(state);
|
2006-01-26 02:29:17 +00:00
|
|
|
|
|
|
|
char min[100];
|
|
|
|
char pref[100];
|
|
|
|
char max[100];
|
|
|
|
char calc[100];
|
|
|
|
char flex[100];
|
|
|
|
char ascent[100];
|
|
|
|
|
|
|
|
nsSize actualSize;
|
|
|
|
GetFrameSizeWithMargin(child, actualSize);
|
|
|
|
nsSize actualSizeCSS (NS_INTRINSICSIZE, NS_INTRINSICSIZE);
|
|
|
|
|
|
|
|
GetValue(aPresContext, minSize, minSizeCSS, min);
|
|
|
|
GetValue(aPresContext, prefSize, prefSizeCSS, pref);
|
|
|
|
GetValue(aPresContext, maxSize, maxSizeCSS, max);
|
|
|
|
GetValue(aPresContext, actualSize, actualSizeCSS, calc);
|
|
|
|
GetValue(aPresContext, flexSize, flexCSS, flex);
|
|
|
|
GetValue(aPresContext, ascentSize, NS_INTRINSICSIZE, ascent);
|
|
|
|
|
|
|
|
|
|
|
|
printf("min%s, pref%s, max%s, actual%s, flex=%s, ascent=%s\n\n",
|
|
|
|
min,
|
|
|
|
pref,
|
|
|
|
max,
|
|
|
|
calc,
|
|
|
|
flex,
|
|
|
|
ascent
|
|
|
|
);
|
|
|
|
|
|
|
|
return NS_OK;
|
2000-03-31 07:02:06 +00:00
|
|
|
}
|
2006-01-26 02:29:17 +00:00
|
|
|
|
2014-05-24 22:20:41 +00:00
|
|
|
child = GetNextBox(child);
|
2006-01-26 02:29:17 +00:00
|
|
|
count++;
|
2000-03-31 07:02:06 +00:00
|
|
|
}
|
2006-01-26 02:29:17 +00:00
|
|
|
} else {
|
|
|
|
}
|
1999-09-10 00:57:01 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
mDebugChild = nullptr;
|
2000-03-02 03:01:30 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
return NS_OK;
|
2000-03-31 07:02:06 +00:00
|
|
|
}
|
2004-09-28 18:37:50 +00:00
|
|
|
|
|
|
|
void
|
2012-08-06 03:00:57 +00:00
|
|
|
nsBoxFrame::SetDebugOnChildList(nsBoxLayoutState& aState, nsIFrame* aChild, bool aDebug)
|
2004-09-28 18:37:50 +00:00
|
|
|
{
|
2014-05-24 22:20:41 +00:00
|
|
|
nsIFrame* child = nsBox::GetChildBox(this);
|
2004-09-28 18:37:50 +00:00
|
|
|
while (child)
|
|
|
|
{
|
|
|
|
child->SetDebug(aState, aDebug);
|
2014-05-24 22:20:41 +00:00
|
|
|
child = GetNextBox(child);
|
2004-09-28 18:37:50 +00:00
|
|
|
}
|
|
|
|
}
|
2000-03-02 03:01:30 +00:00
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
nsresult
|
2012-08-06 03:00:57 +00:00
|
|
|
nsBoxFrame::GetFrameSizeWithMargin(nsIFrame* aBox, nsSize& aSize)
|
2000-03-31 07:02:06 +00:00
|
|
|
{
|
2004-09-28 18:37:50 +00:00
|
|
|
nsRect rect(aBox->GetRect());
|
2000-03-31 07:02:06 +00:00
|
|
|
nsMargin margin(0,0,0,0);
|
|
|
|
aBox->GetMargin(margin);
|
|
|
|
rect.Inflate(margin);
|
|
|
|
aSize.width = rect.width;
|
|
|
|
aSize.height = rect.height;
|
|
|
|
return NS_OK;
|
2000-04-02 07:17:25 +00:00
|
|
|
}
|
2007-05-23 03:48:43 +00:00
|
|
|
#endif
|
2000-06-28 22:19:54 +00:00
|
|
|
|
2002-02-21 13:39:39 +00:00
|
|
|
// If you make changes to this function, check its counterparts
|
2008-12-29 15:07:38 +00:00
|
|
|
// in nsTextBoxFrame and nsXULLabelFrame
|
2013-03-20 01:47:48 +00:00
|
|
|
void
|
2011-09-29 06:19:26 +00:00
|
|
|
nsBoxFrame::RegUnregAccessKey(bool aDoReg)
|
2002-02-21 13:39:39 +00:00
|
|
|
{
|
2013-03-20 01:47:48 +00:00
|
|
|
MOZ_ASSERT(mContent);
|
2002-02-21 13:39:39 +00:00
|
|
|
|
|
|
|
// only support accesskeys for the following elements
|
2015-03-03 11:09:00 +00:00
|
|
|
if (!mContent->IsAnyOfXULElements(nsGkAtoms::button,
|
|
|
|
nsGkAtoms::toolbarbutton,
|
|
|
|
nsGkAtoms::checkbox,
|
|
|
|
nsGkAtoms::textbox,
|
|
|
|
nsGkAtoms::tab,
|
|
|
|
nsGkAtoms::radio)) {
|
2013-03-20 01:47:48 +00:00
|
|
|
return;
|
2002-02-21 13:39:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoString accessKey;
|
2006-12-26 17:47:52 +00:00
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::accesskey, accessKey);
|
2002-02-21 13:39:39 +00:00
|
|
|
|
|
|
|
if (accessKey.IsEmpty())
|
2013-03-20 01:47:48 +00:00
|
|
|
return;
|
2002-02-21 13:39:39 +00:00
|
|
|
|
|
|
|
// With a valid PresContext we can get the ESM
|
|
|
|
// and register the access key
|
2014-04-01 04:09:23 +00:00
|
|
|
EventStateManager* esm = PresContext()->EventStateManager();
|
2002-02-21 13:39:39 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t key = accessKey.First();
|
2004-02-27 17:17:37 +00:00
|
|
|
if (aDoReg)
|
2011-04-21 17:35:52 +00:00
|
|
|
esm->RegisterAccessKey(mContent, key);
|
2004-02-27 17:17:37 +00:00
|
|
|
else
|
2011-04-21 17:35:52 +00:00
|
|
|
esm->UnregisterAccessKey(mContent, key);
|
2002-02-21 13:39:39 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2009-01-09 00:11:30 +00:00
|
|
|
nsBoxFrame::SupportsOrdinalsInChildren()
|
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2009-01-09 00:11:30 +00:00
|
|
|
}
|
|
|
|
|
2012-11-30 23:25:33 +00:00
|
|
|
// Helper less-than-or-equal function, used in CheckBoxOrder() as a
|
|
|
|
// template-parameter for the sorting functions.
|
|
|
|
bool
|
|
|
|
IsBoxOrdinalLEQ(nsIFrame* aFrame1,
|
|
|
|
nsIFrame* aFrame2)
|
|
|
|
{
|
2013-06-01 05:14:03 +00:00
|
|
|
// If we've got a placeholder frame, use its out-of-flow frame's ordinal val.
|
|
|
|
nsIFrame* aRealFrame1 = nsPlaceholderFrame::GetRealFrameFor(aFrame1);
|
|
|
|
nsIFrame* aRealFrame2 = nsPlaceholderFrame::GetRealFrameFor(aFrame2);
|
|
|
|
return aRealFrame1->GetOrdinal() <= aRealFrame2->GetOrdinal();
|
2012-11-30 23:25:33 +00:00
|
|
|
}
|
|
|
|
|
2008-12-07 18:11:30 +00:00
|
|
|
void
|
2012-11-30 23:25:32 +00:00
|
|
|
nsBoxFrame::CheckBoxOrder()
|
2008-12-07 18:11:30 +00:00
|
|
|
{
|
2012-11-30 23:25:33 +00:00
|
|
|
if (SupportsOrdinalsInChildren() &&
|
2013-09-30 21:26:04 +00:00
|
|
|
!nsIFrame::IsFrameListSorted<IsBoxOrdinalLEQ>(mFrames)) {
|
|
|
|
nsIFrame::SortFrameList<IsBoxOrdinalLEQ>(mFrames);
|
2012-11-30 23:25:33 +00:00
|
|
|
}
|
|
|
|
}
|
2008-12-07 18:11:30 +00:00
|
|
|
|
2004-09-28 18:37:50 +00:00
|
|
|
nsresult
|
2012-08-06 03:00:57 +00:00
|
|
|
nsBoxFrame::LayoutChildAt(nsBoxLayoutState& aState, nsIFrame* aBox, const nsRect& aRect)
|
2004-09-28 18:37:50 +00:00
|
|
|
{
|
|
|
|
// get the current rect
|
|
|
|
nsRect oldRect(aBox->GetRect());
|
|
|
|
aBox->SetBounds(aState, aRect);
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool layout = NS_SUBTREE_DIRTY(aBox);
|
2004-09-28 18:37:50 +00:00
|
|
|
|
|
|
|
if (layout || (oldRect.width != aRect.width || oldRect.height != aRect.height)) {
|
|
|
|
return aBox->Layout(aState);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-02-18 07:47:48 +00:00
|
|
|
nsresult
|
2012-08-06 03:00:57 +00:00
|
|
|
nsBoxFrame::RelayoutChildAtOrdinal(nsBoxLayoutState& aState, nsIFrame* aChild)
|
2004-09-28 18:37:50 +00:00
|
|
|
{
|
2009-01-09 00:11:30 +00:00
|
|
|
if (!SupportsOrdinalsInChildren())
|
|
|
|
return NS_OK;
|
|
|
|
|
2012-11-30 23:25:32 +00:00
|
|
|
uint32_t ord = aChild->GetOrdinal();
|
2004-09-28 18:37:50 +00:00
|
|
|
|
2009-10-02 16:27:37 +00:00
|
|
|
nsIFrame* child = mFrames.FirstChild();
|
2012-07-30 14:20:58 +00:00
|
|
|
nsIFrame* newPrevSib = nullptr;
|
2004-09-30 00:18:49 +00:00
|
|
|
|
|
|
|
while (child) {
|
2012-11-30 23:25:32 +00:00
|
|
|
if (ord < child->GetOrdinal()) {
|
2009-10-02 16:27:37 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (child != aChild) {
|
2004-09-30 00:18:49 +00:00
|
|
|
newPrevSib = child;
|
2009-10-02 16:27:37 +00:00
|
|
|
}
|
2004-09-30 00:18:49 +00:00
|
|
|
|
2014-05-24 22:20:41 +00:00
|
|
|
child = GetNextBox(child);
|
2004-09-28 18:37:50 +00:00
|
|
|
}
|
2004-09-30 00:18:49 +00:00
|
|
|
|
2009-10-02 16:27:37 +00:00
|
|
|
if (aChild->GetPrevSibling() == newPrevSib) {
|
2004-09-30 00:18:49 +00:00
|
|
|
// This box is not moving.
|
|
|
|
return NS_OK;
|
2004-09-28 18:37:50 +00:00
|
|
|
}
|
2004-09-30 00:18:49 +00:00
|
|
|
|
2009-09-18 11:09:35 +00:00
|
|
|
// Take |aChild| out of its old position in the child list.
|
2009-10-02 16:27:37 +00:00
|
|
|
mFrames.RemoveFrame(aChild);
|
2004-09-28 18:37:50 +00:00
|
|
|
|
2009-09-18 11:09:35 +00:00
|
|
|
// Insert it after |newPrevSib| or at the start if it's null.
|
2012-07-30 14:20:58 +00:00
|
|
|
mFrames.InsertFrame(nullptr, newPrevSib, aChild);
|
2004-09-28 18:37:50 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
/**
|
|
|
|
* This wrapper class lets us redirect mouse hits from descendant frames
|
|
|
|
* of a menu to the menu itself, if they didn't specify 'allowevents'.
|
|
|
|
*
|
|
|
|
* The wrapper simply turns a hit on a descendant element
|
|
|
|
* into a hit on the menu itself, unless there is an element between the target
|
|
|
|
* and the menu with the "allowevents" attribute.
|
|
|
|
*
|
|
|
|
* This is used by nsMenuFrame and nsTreeColFrame.
|
|
|
|
*
|
2012-07-30 14:20:58 +00:00
|
|
|
* Note that turning a hit on a descendant element into nullptr, so events
|
2006-01-26 02:29:17 +00:00
|
|
|
* could fall through to the menu background, might be an appealing simplification
|
|
|
|
* but it would mean slightly strange behaviour in some cases, because grabber
|
|
|
|
* wrappers can be created for many individual lists and items, so the exact
|
|
|
|
* fallthrough behaviour would be complex. E.g. an element with "allowevents"
|
|
|
|
* on top of the Content() list could receive the event even if it was covered
|
|
|
|
* by a PositionedDescenants() element without "allowevents". It is best to
|
|
|
|
* never convert a non-null hit into null.
|
|
|
|
*/
|
|
|
|
// REVIEW: This is roughly of what nsMenuFrame::GetFrameForPoint used to do.
|
|
|
|
// I've made 'allowevents' affect child elements because that seems the only
|
|
|
|
// reasonable thing to do.
|
|
|
|
class nsDisplayXULEventRedirector : public nsDisplayWrapList {
|
|
|
|
public:
|
2010-08-13 10:01:13 +00:00
|
|
|
nsDisplayXULEventRedirector(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsIFrame* aFrame, nsDisplayItem* aItem,
|
2006-01-26 02:29:17 +00:00
|
|
|
nsIFrame* aTargetFrame)
|
2010-08-13 10:01:13 +00:00
|
|
|
: nsDisplayWrapList(aBuilder, aFrame, aItem), mTargetFrame(aTargetFrame) {}
|
|
|
|
nsDisplayXULEventRedirector(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsIFrame* aFrame, nsDisplayList* aList,
|
2006-01-26 02:29:17 +00:00
|
|
|
nsIFrame* aTargetFrame)
|
2010-08-13 10:01:13 +00:00
|
|
|
: nsDisplayWrapList(aBuilder, aFrame, aList), mTargetFrame(aTargetFrame) {}
|
2010-04-08 00:31:26 +00:00
|
|
|
virtual void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
|
2014-02-24 14:41:56 +00:00
|
|
|
HitTestState* aState,
|
2015-03-21 16:28:04 +00:00
|
|
|
nsTArray<nsIFrame*> *aOutFrames) override;
|
|
|
|
virtual bool ShouldFlattenAway(nsDisplayListBuilder* aBuilder) override {
|
2014-06-09 04:47:59 +00:00
|
|
|
return false;
|
|
|
|
}
|
2010-07-15 21:07:49 +00:00
|
|
|
NS_DISPLAY_DECL_NAME("XULEventRedirector", TYPE_XUL_EVENT_REDIRECTOR)
|
2006-01-26 02:29:17 +00:00
|
|
|
private:
|
|
|
|
nsIFrame* mTargetFrame;
|
|
|
|
};
|
|
|
|
|
2010-04-08 00:31:26 +00:00
|
|
|
void nsDisplayXULEventRedirector::HitTest(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aRect, HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames)
|
2006-01-26 02:29:17 +00:00
|
|
|
{
|
2010-04-08 00:31:26 +00:00
|
|
|
nsTArray<nsIFrame*> outFrames;
|
|
|
|
mList.HitTest(aBuilder, aRect, aState, &outFrames);
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool topMostAdded = false;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t localLength = outFrames.Length();
|
2010-04-08 00:31:26 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < localLength; i++) {
|
2006-01-26 02:29:17 +00:00
|
|
|
|
2010-04-08 00:31:26 +00:00
|
|
|
for (nsIContent* content = outFrames.ElementAt(i)->GetContent();
|
|
|
|
content && content != mTargetFrame->GetContent();
|
|
|
|
content = content->GetParent()) {
|
|
|
|
if (content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::allowevents,
|
|
|
|
nsGkAtoms::_true, eCaseMatters)) {
|
|
|
|
// Events are allowed on 'frame', so let it go.
|
|
|
|
aOutFrames->AppendElement(outFrames.ElementAt(i));
|
2011-10-17 14:59:28 +00:00
|
|
|
topMostAdded = true;
|
2010-04-08 00:31:26 +00:00
|
|
|
}
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
2010-04-08 00:31:26 +00:00
|
|
|
|
2010-05-01 16:39:00 +00:00
|
|
|
// If there was no hit on the topmost frame or its ancestors,
|
|
|
|
// add the target frame itself as the first candidate (see bug 562554).
|
|
|
|
if (!topMostAdded) {
|
2011-10-17 14:59:28 +00:00
|
|
|
topMostAdded = true;
|
2010-05-01 16:39:00 +00:00
|
|
|
aOutFrames->AppendElement(mTargetFrame);
|
|
|
|
}
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class nsXULEventRedirectorWrapper : public nsDisplayWrapper
|
|
|
|
{
|
|
|
|
public:
|
2014-09-01 03:36:37 +00:00
|
|
|
explicit nsXULEventRedirectorWrapper(nsIFrame* aTargetFrame)
|
2006-01-26 02:29:17 +00:00
|
|
|
: mTargetFrame(aTargetFrame) {}
|
|
|
|
virtual nsDisplayItem* WrapList(nsDisplayListBuilder* aBuilder,
|
2014-02-24 14:41:56 +00:00
|
|
|
nsIFrame* aFrame,
|
2015-03-21 16:28:04 +00:00
|
|
|
nsDisplayList* aList) override {
|
2006-01-26 02:29:17 +00:00
|
|
|
return new (aBuilder)
|
2010-08-13 10:01:13 +00:00
|
|
|
nsDisplayXULEventRedirector(aBuilder, aFrame, aList, mTargetFrame);
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
|
|
|
virtual nsDisplayItem* WrapItem(nsDisplayListBuilder* aBuilder,
|
2015-03-21 16:28:04 +00:00
|
|
|
nsDisplayItem* aItem) override {
|
2006-01-26 02:29:17 +00:00
|
|
|
return new (aBuilder)
|
2013-04-19 12:02:13 +00:00
|
|
|
nsDisplayXULEventRedirector(aBuilder, aItem->Frame(), aItem,
|
2006-01-26 02:29:17 +00:00
|
|
|
mTargetFrame);
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
nsIFrame* mTargetFrame;
|
|
|
|
};
|
|
|
|
|
2013-02-14 11:12:27 +00:00
|
|
|
void
|
2006-01-26 02:29:17 +00:00
|
|
|
nsBoxFrame::WrapListsInRedirector(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayListSet& aIn,
|
|
|
|
const nsDisplayListSet& aOut)
|
|
|
|
{
|
|
|
|
nsXULEventRedirectorWrapper wrapper(this);
|
2013-02-14 11:12:27 +00:00
|
|
|
wrapper.WrapLists(aBuilder, this, aIn, aOut);
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
2012-07-27 22:01:12 +00:00
|
|
|
|
|
|
|
bool
|
2013-10-02 03:46:03 +00:00
|
|
|
nsBoxFrame::GetEventPoint(WidgetGUIEvent* aEvent, nsPoint &aPoint) {
|
2015-02-01 22:27:41 +00:00
|
|
|
LayoutDeviceIntPoint refPoint;
|
2012-07-27 22:01:12 +00:00
|
|
|
bool res = GetEventPoint(aEvent, refPoint);
|
2015-02-01 22:27:31 +00:00
|
|
|
aPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(
|
2015-02-01 22:27:41 +00:00
|
|
|
aEvent, refPoint, this);
|
2012-07-27 22:01:12 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2015-02-01 22:27:41 +00:00
|
|
|
nsBoxFrame::GetEventPoint(WidgetGUIEvent* aEvent, LayoutDeviceIntPoint& aPoint) {
|
2012-07-27 22:01:12 +00:00
|
|
|
NS_ENSURE_TRUE(aEvent, false);
|
|
|
|
|
2013-10-18 06:10:23 +00:00
|
|
|
WidgetTouchEvent* touchEvent = aEvent->AsTouchEvent();
|
|
|
|
if (touchEvent) {
|
2012-07-27 22:01:12 +00:00
|
|
|
// return false if there is more than one touch on the page, or if
|
|
|
|
// we can't find a touch point
|
|
|
|
if (touchEvent->touches.Length() != 1) {
|
|
|
|
return false;
|
|
|
|
}
|
2013-04-05 08:49:00 +00:00
|
|
|
|
2013-08-02 07:06:35 +00:00
|
|
|
dom::Touch* touch = touchEvent->touches.SafeElementAt(0);
|
2012-07-27 22:01:12 +00:00
|
|
|
if (!touch) {
|
|
|
|
return false;
|
|
|
|
}
|
2015-02-01 22:27:41 +00:00
|
|
|
aPoint = touch->mRefPoint;
|
2012-07-27 22:01:12 +00:00
|
|
|
} else {
|
2015-02-01 22:27:41 +00:00
|
|
|
aPoint = aEvent->refPoint;
|
2012-07-27 22:01:12 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|