2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2005-08-23 00:35:47 +04:00
|
|
|
/* vim: set ts=2 sw=2 et tw=80: */
|
2012-05-21 15:12:37 +04: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 04:35:55 +03: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-10 01:02:40 +03: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-21 01:05:24 +03: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-10 01:02:40 +03:00
|
|
|
// cache the value.
|
|
|
|
|
|
|
|
// Boxes and Incremental Reflow
|
|
|
|
// ----------------------------
|
2005-11-21 01:05:24 +03: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-10 01:02:40 +03: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 11:02:06 +04: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-10 01:02:40 +03:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
#include "nsBoxLayoutState.h"
|
1999-03-27 04:35:55 +03:00
|
|
|
#include "nsBoxFrame.h"
|
2013-04-05 12:49:00 +04:00
|
|
|
#include "mozilla/dom/Touch.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsStyleContext.h"
|
2013-06-01 09:14:03 +04:00
|
|
|
#include "nsPlaceholderFrame.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
1999-03-27 04:35:55 +03:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsINameSpaceManager.h"
|
2007-01-30 03:06:41 +03:00
|
|
|
#include "nsGkAtoms.h"
|
1999-05-10 01:46:24 +04:00
|
|
|
#include "nsIContent.h"
|
1999-07-02 09:28:32 +04:00
|
|
|
#include "nsHTMLParts.h"
|
2013-01-05 07:12:24 +04:00
|
|
|
#include "nsViewManager.h"
|
2013-01-03 17:23:11 +04:00
|
|
|
#include "nsView.h"
|
1999-08-19 07:51:25 +04:00
|
|
|
#include "nsIPresShell.h"
|
1999-09-10 04:57:01 +04:00
|
|
|
#include "nsCSSRendering.h"
|
2000-03-02 10:13:02 +03:00
|
|
|
#include "nsIServiceManager.h"
|
2011-07-11 18:05:10 +04:00
|
|
|
#include "nsBoxLayout.h"
|
2000-03-31 11:02:06 +04:00
|
|
|
#include "nsSprocketLayout.h"
|
2000-05-22 13:15:54 +04:00
|
|
|
#include "nsIScrollableFrame.h"
|
2000-06-22 04:48:49 +04:00
|
|
|
#include "nsWidgetsCID.h"
|
2002-11-17 18:37:56 +03:00
|
|
|
#include "nsCSSAnonBoxes.h"
|
2011-12-28 00:18:48 +04:00
|
|
|
#include "nsContainerFrame.h"
|
2002-02-21 16:39:39 +03:00
|
|
|
#include "nsIDOMElement.h"
|
2002-01-08 03:43:20 +03:00
|
|
|
#include "nsITheme.h"
|
2002-06-18 03:35:15 +04:00
|
|
|
#include "nsTransform2D.h"
|
2011-04-21 21:35:52 +04:00
|
|
|
#include "nsEventStateManager.h"
|
2006-03-07 20:08:51 +03:00
|
|
|
#include "nsEventDispatcher.h"
|
2002-07-03 20:38:15 +04:00
|
|
|
#include "nsIDOMEvent.h"
|
2006-01-26 05:29:17 +03:00
|
|
|
#include "nsDisplayList.h"
|
2011-05-25 10:31:59 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2013-08-20 02:55:18 +04:00
|
|
|
#include "nsThemeConstants.h"
|
2013-10-01 01:26:04 +04:00
|
|
|
#include "nsLayoutUtils.h"
|
2013-01-15 16:22:03 +04:00
|
|
|
#include <algorithm>
|
2000-06-22 04:48:49 +04:00
|
|
|
|
2002-01-23 05:53:02 +03:00
|
|
|
// Needed for Print Preview
|
|
|
|
#include "nsIURI.h"
|
|
|
|
|
2013-09-25 15:21:16 +04:00
|
|
|
#include "mozilla/TouchEvents.h"
|
|
|
|
|
2011-05-25 10:31:59 +04:00
|
|
|
using namespace mozilla;
|
2013-04-05 12:49:00 +04:00
|
|
|
using namespace mozilla::dom;
|
2011-05-25 10:31:59 +04:00
|
|
|
|
2000-02-14 04:42:09 +03:00
|
|
|
//define DEBUG_REDRAW
|
2000-05-15 08:12:31 +04:00
|
|
|
|
1999-08-27 10:06:39 +04:00
|
|
|
#define DEBUG_SPRING_SIZE 8
|
|
|
|
#define DEBUG_BORDER_SIZE 2
|
|
|
|
#define COIL_SIZE 8
|
|
|
|
|
2000-02-17 02:00:52 +03:00
|
|
|
//#define TEST_SANITY
|
1999-12-02 04:07:27 +03:00
|
|
|
|
2000-08-23 15:02:19 +04:00
|
|
|
#ifdef DEBUG_rods
|
2000-08-24 17:19:57 +04:00
|
|
|
//#define DO_NOISY_REFLOW
|
2000-08-23 15:02:19 +04:00
|
|
|
#endif
|
|
|
|
|
2004-06-19 13:07:47 +04:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2011-09-29 10:19:26 +04:00
|
|
|
bool nsBoxFrame::gDebug = false;
|
2012-08-06 07:00:57 +04:00
|
|
|
nsIFrame* nsBoxFrame::mDebugChild = nullptr;
|
2004-06-19 13:07:47 +04:00
|
|
|
#endif
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2005-10-27 01:46:39 +04:00
|
|
|
nsIFrame*
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_NewBoxFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, bool aIsRoot, nsBoxLayout* aLayoutManager)
|
1999-03-27 04:35:55 +03:00
|
|
|
{
|
2006-03-27 01:30:36 +04:00
|
|
|
return new (aPresShell) nsBoxFrame(aPresShell, aContext, aIsRoot, aLayoutManager);
|
2009-09-12 20:49:24 +04:00
|
|
|
}
|
1999-03-27 04:35:55 +03:00
|
|
|
|
2009-01-19 21:31:33 +03:00
|
|
|
nsIFrame*
|
|
|
|
NS_NewBoxFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
|
|
|
{
|
|
|
|
return new (aPresShell) nsBoxFrame(aPresShell, aContext);
|
|
|
|
}
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsBoxFrame)
|
|
|
|
|
2006-03-27 01:30:36 +04:00
|
|
|
nsBoxFrame::nsBoxFrame(nsIPresShell* aPresShell,
|
|
|
|
nsStyleContext* aContext,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aIsRoot,
|
2011-07-11 18:05:10 +04:00
|
|
|
nsBoxLayout* aLayoutManager) :
|
2010-11-30 17:59:46 +03:00
|
|
|
nsContainerFrame(aContext)
|
1999-03-27 04:35:55 +03:00
|
|
|
{
|
2001-03-06 05:27:50 +03:00
|
|
|
mState |= NS_STATE_IS_HORIZONTAL;
|
2000-02-14 04:42:09 +03:00
|
|
|
mState |= NS_STATE_AUTO_STRETCH;
|
2000-02-17 02:00:52 +03:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
if (aIsRoot)
|
2000-03-02 06:01:30 +03:00
|
|
|
mState |= NS_STATE_IS_ROOT;
|
|
|
|
|
2002-10-10 10:39:30 +04:00
|
|
|
mValign = vAlign_Top;
|
|
|
|
mHalign = hAlign_Left;
|
2001-09-26 02:17:00 +04:00
|
|
|
|
2000-04-05 04:19:00 +04:00
|
|
|
// if no layout manager specified us the static sprocket layout
|
2011-07-11 18:05:10 +04:00
|
|
|
nsCOMPtr<nsBoxLayout> layout = aLayoutManager;
|
2000-04-05 04:19:00 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
if (layout == nullptr) {
|
2000-04-05 04:19:00 +04:00
|
|
|
NS_NewSprocketLayout(aPresShell, layout);
|
|
|
|
}
|
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
SetLayoutManager(layout);
|
1999-08-27 10:06:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsBoxFrame::~nsBoxFrame()
|
|
|
|
{
|
1999-03-27 04:35:55 +03:00
|
|
|
}
|
|
|
|
|
1999-12-02 04:07:27 +03:00
|
|
|
NS_IMETHODIMP
|
2011-08-25 00:54:30 +04:00
|
|
|
nsBoxFrame::SetInitialChildList(ChildListID aListID,
|
2009-07-28 16:53:20 +04:00
|
|
|
nsFrameList& aChildList)
|
1999-12-02 04:07:27 +03:00
|
|
|
{
|
2011-08-25 00:54:30 +04:00
|
|
|
nsresult r = nsContainerFrame::SetInitialChildList(aListID, aChildList);
|
2000-03-31 11:02:06 +04:00
|
|
|
if (r == NS_OK) {
|
|
|
|
// initialize our list of infos.
|
2007-03-31 01:11:41 +04:00
|
|
|
nsBoxLayoutState state(PresContext());
|
2012-12-01 03:25:32 +04:00
|
|
|
CheckBoxOrder();
|
2004-09-28 22:37:50 +04:00
|
|
|
if (mLayoutManager)
|
|
|
|
mLayoutManager->ChildrenSet(this, state, mFrames.FirstChild());
|
2000-03-31 11:02:06 +04:00
|
|
|
} else {
|
2002-09-10 01:32:33 +04:00
|
|
|
NS_WARNING("Warning add child failed!!\n");
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
1999-12-02 04:07:27 +03:00
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2008-10-14 02:03:28 +04:00
|
|
|
/* virtual */ void
|
2008-10-26 13:11:34 +03:00
|
|
|
nsBoxFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
|
2006-04-18 03:58:17 +04:00
|
|
|
{
|
2008-10-26 13:11:34 +03:00
|
|
|
nsContainerFrame::DidSetStyleContext(aOldStyleContext);
|
2008-10-14 02:03:28 +04:00
|
|
|
|
2006-04-18 03:58:17 +04:00
|
|
|
// The values that CacheAttributes() computes depend on our style,
|
|
|
|
// so we need to recompute them here...
|
|
|
|
CacheAttributes();
|
|
|
|
}
|
|
|
|
|
1999-05-10 01:46:24 +04:00
|
|
|
/**
|
|
|
|
* Initialize us. This is a good time to get the alignment of the box
|
|
|
|
*/
|
2013-03-20 05:47:48 +04:00
|
|
|
void
|
2006-03-09 21:55:21 +03:00
|
|
|
nsBoxFrame::Init(nsIContent* aContent,
|
2002-10-10 10:39:30 +04:00
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
1999-03-27 04:35:55 +03:00
|
|
|
{
|
2013-03-20 05:47:48 +04:00
|
|
|
nsContainerFrame::Init(aContent, aParent, aPrevInFlow);
|
2000-01-08 05:18:14 +03:00
|
|
|
|
2012-04-17 02:32:12 +04:00
|
|
|
if (GetStateBits() & NS_FRAME_FONT_INFLATION_CONTAINER) {
|
|
|
|
AddStateBits(NS_FRAME_FONT_INFLATION_FLOW_ROOT);
|
|
|
|
}
|
|
|
|
|
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 08:38:33 +03:00
|
|
|
MarkIntrinsicWidthsDirty();
|
|
|
|
|
2002-10-10 10:39:30 +04:00
|
|
|
CacheAttributes();
|
2000-03-02 06:01:30 +03:00
|
|
|
|
2004-06-19 13:07:47 +04:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2000-03-02 06:01:30 +03:00
|
|
|
// if we are root and this
|
|
|
|
if (mState & NS_STATE_IS_ROOT)
|
2006-04-10 04:16:29 +04:00
|
|
|
GetDebugPref(GetPresContext());
|
2004-06-19 13:07:47 +04:00
|
|
|
#endif
|
2000-02-14 04:42:09 +03:00
|
|
|
|
2007-06-19 03:22:46 +04:00
|
|
|
UpdateMouseThrough();
|
|
|
|
|
2002-02-21 16:39:39 +03:00
|
|
|
// register access key
|
2013-03-20 05:47:48 +04:00
|
|
|
RegUnregAccessKey(true);
|
2001-12-04 02:41:13 +03:00
|
|
|
}
|
|
|
|
|
2007-06-19 03:22:46 +04:00
|
|
|
void nsBoxFrame::UpdateMouseThrough()
|
|
|
|
{
|
|
|
|
if (mContent) {
|
|
|
|
static nsIContent::AttrValuesArray strings[] =
|
2012-07-30 18:20:58 +04:00
|
|
|
{&nsGkAtoms::never, &nsGkAtoms::always, nullptr};
|
2010-11-30 17:59:46 +03: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-19 03:22:46 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-06-23 09:15:04 +04:00
|
|
|
void
|
2002-10-10 10:39:30 +04:00
|
|
|
nsBoxFrame::CacheAttributes()
|
2000-06-23 09:15:04 +04:00
|
|
|
{
|
|
|
|
/*
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("Caching: ");
|
2002-10-10 10:39:30 +04:00
|
|
|
DumpBox(stdout);
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("\n");
|
2000-06-23 09:15:04 +04:00
|
|
|
*/
|
|
|
|
|
2002-10-10 10:39:30 +04:00
|
|
|
mValign = vAlign_Top;
|
|
|
|
mHalign = hAlign_Left;
|
2000-06-23 09:15:04 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool orient = false;
|
2002-10-10 10:39:30 +04:00
|
|
|
GetInitialOrientation(orient);
|
2000-06-23 09:15:04 +04:00
|
|
|
if (orient)
|
2002-10-10 10:39:30 +04:00
|
|
|
mState |= NS_STATE_IS_HORIZONTAL;
|
2001-08-02 04:09:27 +04:00
|
|
|
else
|
2002-10-10 10:39:30 +04:00
|
|
|
mState &= ~NS_STATE_IS_HORIZONTAL;
|
2000-06-23 09:15:04 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool normal = true;
|
2002-10-10 10:39:30 +04:00
|
|
|
GetInitialDirection(normal);
|
2001-08-15 08:09:41 +04:00
|
|
|
if (normal)
|
2002-10-10 10:39:30 +04:00
|
|
|
mState |= NS_STATE_IS_DIRECTION_NORMAL;
|
2001-08-15 08:09:41 +04:00
|
|
|
else
|
2002-10-10 10:39:30 +04:00
|
|
|
mState &= ~NS_STATE_IS_DIRECTION_NORMAL;
|
2001-08-15 08:09:41 +04:00
|
|
|
|
2002-10-10 10:39:30 +04:00
|
|
|
GetInitialVAlignment(mValign);
|
|
|
|
GetInitialHAlignment(mHalign);
|
2001-08-02 04:09:27 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool equalSize = false;
|
2002-10-10 10:39:30 +04:00
|
|
|
GetInitialEqualSize(equalSize);
|
2000-06-23 09:15:04 +04:00
|
|
|
if (equalSize)
|
2002-10-10 10:39:30 +04:00
|
|
|
mState |= NS_STATE_EQUAL_SIZE;
|
2000-06-23 09:15:04 +04:00
|
|
|
else
|
2002-10-10 10:39:30 +04:00
|
|
|
mState &= ~NS_STATE_EQUAL_SIZE;
|
2000-06-23 09:15:04 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool autostretch = !!(mState & NS_STATE_AUTO_STRETCH);
|
2002-10-10 10:39:30 +04:00
|
|
|
GetInitialAutoStretch(autostretch);
|
2000-06-23 09:15:04 +04:00
|
|
|
if (autostretch)
|
2002-10-10 10:39:30 +04:00
|
|
|
mState |= NS_STATE_AUTO_STRETCH;
|
2000-06-23 09:15:04 +04:00
|
|
|
else
|
2002-10-10 10:39:30 +04:00
|
|
|
mState &= ~NS_STATE_AUTO_STRETCH;
|
2000-06-23 09:15:04 +04:00
|
|
|
|
|
|
|
|
2004-06-19 13:07:47 +04:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2011-09-29 10:19:26 +04:00
|
|
|
bool debug = mState & NS_STATE_SET_TO_DEBUG;
|
|
|
|
bool debugSet = GetInitialDebug(debug);
|
2000-06-23 09:15:04 +04:00
|
|
|
if (debugSet) {
|
2002-10-10 10:39:30 +04:00
|
|
|
mState |= NS_STATE_DEBUG_WAS_SET;
|
2000-06-23 09:15:04 +04:00
|
|
|
if (debug)
|
2002-10-10 10:39:30 +04:00
|
|
|
mState |= NS_STATE_SET_TO_DEBUG;
|
2000-06-23 09:15:04 +04:00
|
|
|
else
|
2002-10-10 10:39:30 +04:00
|
|
|
mState &= ~NS_STATE_SET_TO_DEBUG;
|
2000-06-23 09:15:04 +04:00
|
|
|
} else {
|
2002-10-10 10:39:30 +04:00
|
|
|
mState &= ~NS_STATE_DEBUG_WAS_SET;
|
2000-06-23 09:15:04 +04:00
|
|
|
}
|
2004-06-19 13:07:47 +04:00
|
|
|
#endif
|
2000-06-23 09:15:04 +04:00
|
|
|
}
|
|
|
|
|
2004-06-19 13:07:47 +04:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
|
|
|
nsBoxFrame::GetInitialDebug(bool& aDebug)
|
2000-03-02 06:01:30 +03:00
|
|
|
{
|
2007-05-23 07:48:43 +04:00
|
|
|
if (!GetContent())
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2006-01-18 07:09:33 +03:00
|
|
|
static nsIContent::AttrValuesArray strings[] =
|
2012-07-30 18:20:58 +04:00
|
|
|
{&nsGkAtoms::_false, &nsGkAtoms::_true, nullptr};
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t index = GetContent()->FindAttrValueIn(kNameSpaceID_None,
|
2006-12-26 20:47:52 +03:00
|
|
|
nsGkAtoms::debug, strings, eCaseMatters);
|
2006-01-18 07:09:33 +03:00
|
|
|
if (index >= 0) {
|
|
|
|
aDebug = index == 1;
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2000-03-02 06:01:30 +03:00
|
|
|
}
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2000-03-02 06:01:30 +03:00
|
|
|
}
|
2004-06-19 13:07:47 +04:00
|
|
|
#endif
|
2000-03-02 06:01:30 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2000-02-14 04:42:09 +03:00
|
|
|
nsBoxFrame::GetInitialHAlignment(nsBoxFrame::Halignment& aHalign)
|
|
|
|
{
|
2007-05-23 07:48:43 +04:00
|
|
|
if (!GetContent())
|
2011-10-17 18:59:28 +04: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-10 01:02:40 +03:00
|
|
|
|
2005-10-28 15:25:24 +04:00
|
|
|
// XXXdwh Everything inside this if statement is deprecated code.
|
2006-01-18 07:09:33 +03:00
|
|
|
static nsIContent::AttrValuesArray alignStrings[] =
|
2012-07-30 18:20:58 +04:00
|
|
|
{&nsGkAtoms::left, &nsGkAtoms::right, nullptr};
|
2006-01-18 07:09:33 +03:00
|
|
|
static const Halignment alignValues[] = {hAlign_Left, hAlign_Right};
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t index = GetContent()->FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::align,
|
2006-01-18 07:09:33 +03:00
|
|
|
alignStrings, eCaseMatters);
|
|
|
|
if (index >= 0) {
|
|
|
|
aHalign = alignValues[index];
|
2011-10-17 18:59:28 +04: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-10 01:02:40 +03:00
|
|
|
}
|
2001-08-02 04:09:27 +04: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 20:47:52 +03:00
|
|
|
nsIAtom* attrName = IsHorizontal() ? nsGkAtoms::pack : nsGkAtoms::align;
|
2006-01-18 07:09:33 +03:00
|
|
|
static nsIContent::AttrValuesArray strings[] =
|
2012-07-30 18:20:58 +04:00
|
|
|
{&nsGkAtoms::_empty, &nsGkAtoms::start, &nsGkAtoms::center, &nsGkAtoms::end, nullptr};
|
2006-01-18 07:09:33 +03:00
|
|
|
static const Halignment values[] =
|
|
|
|
{hAlign_Left/*not used*/, hAlign_Left, hAlign_Center, hAlign_Right};
|
2007-05-23 07:48:43 +04:00
|
|
|
index = GetContent()->FindAttrValueIn(kNameSpaceID_None, attrName,
|
2006-01-18 07:09:33 +03:00
|
|
|
strings, eCaseMatters);
|
|
|
|
|
|
|
|
if (index == nsIContent::ATTR_VALUE_NO_MATCH) {
|
2001-08-02 04:09:27 +04:00
|
|
|
// The attr was present but had a nonsensical value. Revert to the default.
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2001-08-02 04:09:27 +04:00
|
|
|
}
|
2006-01-18 07:09:33 +03:00
|
|
|
if (index > 0) {
|
|
|
|
aHalign = values[index];
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2006-01-18 07:09:33 +03:00
|
|
|
}
|
2000-02-14 04:42:09 +03:00
|
|
|
|
2001-08-02 04:09:27 +04: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-17 01:51:02 +04:00
|
|
|
const nsStyleXUL* boxInfo = StyleXUL();
|
2001-08-02 04:09:27 +04:00
|
|
|
if (IsHorizontal()) {
|
|
|
|
switch (boxInfo->mBoxPack) {
|
|
|
|
case NS_STYLE_BOX_PACK_START:
|
|
|
|
aHalign = nsBoxFrame::hAlign_Left;
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2001-08-02 04:09:27 +04:00
|
|
|
case NS_STYLE_BOX_PACK_CENTER:
|
|
|
|
aHalign = nsBoxFrame::hAlign_Center;
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2001-08-02 04:09:27 +04:00
|
|
|
case NS_STYLE_BOX_PACK_END:
|
|
|
|
aHalign = nsBoxFrame::hAlign_Right;
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2001-08-02 04:09:27 +04:00
|
|
|
default: // Nonsensical value. Just bail.
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2001-08-02 04:09:27 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
switch (boxInfo->mBoxAlign) {
|
|
|
|
case NS_STYLE_BOX_ALIGN_START:
|
|
|
|
aHalign = nsBoxFrame::hAlign_Left;
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2001-08-02 04:09:27 +04:00
|
|
|
case NS_STYLE_BOX_ALIGN_CENTER:
|
|
|
|
aHalign = nsBoxFrame::hAlign_Center;
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2001-08-02 04:09:27 +04:00
|
|
|
case NS_STYLE_BOX_ALIGN_END:
|
|
|
|
aHalign = nsBoxFrame::hAlign_Right;
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2001-08-02 04:09:27 +04:00
|
|
|
default: // Nonsensical value. Just bail.
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2001-08-02 04:09:27 +04:00
|
|
|
}
|
|
|
|
}
|
2000-02-14 04:42:09 +03:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2000-02-14 04:42:09 +03:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2000-02-14 04:42:09 +03:00
|
|
|
nsBoxFrame::GetInitialVAlignment(nsBoxFrame::Valignment& aValign)
|
|
|
|
{
|
2007-05-23 07:48:43 +04:00
|
|
|
if (!GetContent())
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2000-02-14 04:42:09 +03:00
|
|
|
|
2006-01-18 07:09:33 +03:00
|
|
|
static nsIContent::AttrValuesArray valignStrings[] =
|
2012-07-30 18:20:58 +04:00
|
|
|
{&nsGkAtoms::top, &nsGkAtoms::baseline, &nsGkAtoms::middle, &nsGkAtoms::bottom, nullptr};
|
2006-01-18 07:09:33 +03:00
|
|
|
static const Valignment valignValues[] =
|
|
|
|
{vAlign_Top, vAlign_BaseLine, vAlign_Middle, vAlign_Bottom};
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t index = GetContent()->FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::valign,
|
2006-01-18 07:09:33 +03:00
|
|
|
valignStrings, eCaseMatters);
|
|
|
|
if (index >= 0) {
|
|
|
|
aValign = valignValues[index];
|
2011-10-17 18:59:28 +04: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-10 01:02:40 +03:00
|
|
|
}
|
|
|
|
|
2001-08-02 04:09:27 +04: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 20:47:52 +03:00
|
|
|
nsIAtom* attrName = IsHorizontal() ? nsGkAtoms::align : nsGkAtoms::pack;
|
2006-01-18 07:09:33 +03:00
|
|
|
static nsIContent::AttrValuesArray strings[] =
|
2006-12-26 20:47:52 +03:00
|
|
|
{&nsGkAtoms::_empty, &nsGkAtoms::start, &nsGkAtoms::center,
|
2012-07-30 18:20:58 +04:00
|
|
|
&nsGkAtoms::baseline, &nsGkAtoms::end, nullptr};
|
2006-01-18 07:09:33 +03:00
|
|
|
static const Valignment values[] =
|
|
|
|
{vAlign_Top/*not used*/, vAlign_Top, vAlign_Middle, vAlign_BaseLine, vAlign_Bottom};
|
2007-05-23 07:48:43 +04:00
|
|
|
index = GetContent()->FindAttrValueIn(kNameSpaceID_None, attrName,
|
2006-01-18 07:09:33 +03:00
|
|
|
strings, eCaseMatters);
|
|
|
|
if (index == nsIContent::ATTR_VALUE_NO_MATCH) {
|
2001-08-02 04:09:27 +04:00
|
|
|
// The attr was present but had a nonsensical value. Revert to the default.
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2001-08-02 04:09:27 +04:00
|
|
|
}
|
2006-01-18 07:09:33 +03:00
|
|
|
if (index > 0) {
|
|
|
|
aValign = values[index];
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2006-01-18 07:09:33 +03:00
|
|
|
}
|
2001-08-02 04:09:27 +04: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-17 01:51:02 +04:00
|
|
|
const nsStyleXUL* boxInfo = StyleXUL();
|
2001-08-02 04:09:27 +04:00
|
|
|
if (IsHorizontal()) {
|
|
|
|
switch (boxInfo->mBoxAlign) {
|
|
|
|
case NS_STYLE_BOX_ALIGN_START:
|
|
|
|
aValign = nsBoxFrame::vAlign_Top;
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2001-08-02 04:09:27 +04:00
|
|
|
case NS_STYLE_BOX_ALIGN_CENTER:
|
|
|
|
aValign = nsBoxFrame::vAlign_Middle;
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2001-08-02 04:09:27 +04:00
|
|
|
case NS_STYLE_BOX_ALIGN_BASELINE:
|
|
|
|
aValign = nsBoxFrame::vAlign_BaseLine;
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2001-08-02 04:09:27 +04:00
|
|
|
case NS_STYLE_BOX_ALIGN_END:
|
|
|
|
aValign = nsBoxFrame::vAlign_Bottom;
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2001-08-02 04:09:27 +04:00
|
|
|
default: // Nonsensical value. Just bail.
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2001-08-02 04:09:27 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
switch (boxInfo->mBoxPack) {
|
|
|
|
case NS_STYLE_BOX_PACK_START:
|
|
|
|
aValign = nsBoxFrame::vAlign_Top;
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2001-08-02 04:09:27 +04:00
|
|
|
case NS_STYLE_BOX_PACK_CENTER:
|
|
|
|
aValign = nsBoxFrame::vAlign_Middle;
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2001-08-02 04:09:27 +04:00
|
|
|
case NS_STYLE_BOX_PACK_END:
|
|
|
|
aValign = nsBoxFrame::vAlign_Bottom;
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2001-08-02 04:09:27 +04:00
|
|
|
default: // Nonsensical value. Just bail.
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2001-08-02 04:09:27 +04:00
|
|
|
}
|
|
|
|
}
|
2000-02-14 04:42:09 +03:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
1999-11-19 00:05:43 +03:00
|
|
|
}
|
|
|
|
|
2001-03-06 05:27:50 +03:00
|
|
|
void
|
2011-09-29 10:19:26 +04:00
|
|
|
nsBoxFrame::GetInitialOrientation(bool& aIsHorizontal)
|
1999-11-19 00:05:43 +03:00
|
|
|
{
|
|
|
|
// see if we are a vertical or horizontal box.
|
2007-05-23 07:48:43 +04:00
|
|
|
if (!GetContent())
|
2001-03-06 05:27:50 +03:00
|
|
|
return;
|
|
|
|
|
|
|
|
// Check the style system first.
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleXUL* boxInfo = StyleXUL();
|
2001-03-06 05:27:50 +03:00
|
|
|
if (boxInfo->mBoxOrient == NS_STYLE_BOX_ORIENT_HORIZONTAL)
|
2011-10-17 18:59:28 +04:00
|
|
|
aIsHorizontal = true;
|
2001-03-06 05:27:50 +03:00
|
|
|
else
|
2011-10-17 18:59:28 +04:00
|
|
|
aIsHorizontal = false;
|
2001-03-06 05:27:50 +03:00
|
|
|
|
|
|
|
// Now see if we have an attribute. The attribute overrides
|
|
|
|
// the style system value.
|
2006-01-18 07:09:33 +03:00
|
|
|
static nsIContent::AttrValuesArray strings[] =
|
2012-07-30 18:20:58 +04:00
|
|
|
{&nsGkAtoms::vertical, &nsGkAtoms::horizontal, nullptr};
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t index = GetContent()->FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::orient,
|
2006-01-18 07:09:33 +03:00
|
|
|
strings, eCaseMatters);
|
|
|
|
if (index >= 0) {
|
|
|
|
aIsHorizontal = index == 1;
|
|
|
|
}
|
2000-02-14 04:42:09 +03:00
|
|
|
}
|
|
|
|
|
2001-08-15 08:09:41 +04:00
|
|
|
void
|
2011-09-29 10:19:26 +04:00
|
|
|
nsBoxFrame::GetInitialDirection(bool& aIsNormal)
|
2001-08-15 08:09:41 +04:00
|
|
|
{
|
2007-05-23 07:48:43 +04:00
|
|
|
if (!GetContent())
|
2001-08-15 08:09:41 +04: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-17 01:51:02 +04:00
|
|
|
aIsNormal = (StyleVisibility()->mDirection == NS_STYLE_DIRECTION_LTR); // If text runs RTL then so do we.
|
2001-08-15 08:09:41 +04:00
|
|
|
}
|
|
|
|
else
|
2011-10-17 18:59:28 +04:00
|
|
|
aIsNormal = true; // Assume a normal direction in the vertical case.
|
2001-08-15 08:09:41 +04:00
|
|
|
|
|
|
|
// Now check the style system to see if we should invert aIsNormal.
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleXUL* boxInfo = StyleXUL();
|
2001-08-15 08:09:41 +04: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 23:17:41 +04:00
|
|
|
if (IsHorizontal()) {
|
|
|
|
static nsIContent::AttrValuesArray strings[] =
|
2012-07-30 18:20:58 +04:00
|
|
|
{&nsGkAtoms::reverse, &nsGkAtoms::ltr, &nsGkAtoms::rtl, nullptr};
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t index = GetContent()->FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::dir,
|
2012-05-07 23:17:41 +04: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 08:09:41 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-06-23 09:15:04 +04:00
|
|
|
/* Returns true if it was set.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
|
|
|
nsBoxFrame::GetInitialEqualSize(bool& aEqualSize)
|
2000-06-23 09:15:04 +04:00
|
|
|
{
|
|
|
|
// see if we are a vertical or horizontal box.
|
2007-05-23 07:48:43 +04:00
|
|
|
if (!GetContent())
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2007-05-23 07:48:43 +04:00
|
|
|
|
|
|
|
if (GetContent()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::equalsize,
|
2006-12-26 20:47:52 +03:00
|
|
|
nsGkAtoms::always, eCaseMatters)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
aEqualSize = true;
|
|
|
|
return true;
|
2007-05-23 07:48:43 +04:00
|
|
|
}
|
2000-06-23 09:15:04 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2000-06-23 09:15:04 +04:00
|
|
|
}
|
|
|
|
|
2000-02-14 04:42:09 +03:00
|
|
|
/* Returns true if it was set.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
|
|
|
nsBoxFrame::GetInitialAutoStretch(bool& aStretch)
|
2000-02-14 04:42:09 +03:00
|
|
|
{
|
2007-05-23 07:48:43 +04:00
|
|
|
if (!GetContent())
|
2011-10-17 18:59:28 +04: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 07:17:02 +03:00
|
|
|
|
|
|
|
// Check the align attribute.
|
2006-01-18 07:09:33 +03:00
|
|
|
static nsIContent::AttrValuesArray strings[] =
|
2012-07-30 18:20:58 +04:00
|
|
|
{&nsGkAtoms::_empty, &nsGkAtoms::stretch, nullptr};
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t index = GetContent()->FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::align,
|
2006-01-18 07:09:33 +03:00
|
|
|
strings, eCaseMatters);
|
|
|
|
if (index != nsIContent::ATTR_MISSING && index != 0) {
|
|
|
|
aStretch = index == 1;
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2001-08-02 04:09:27 +04:00
|
|
|
}
|
2000-02-14 04:42:09 +03: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 07:17:02 +03:00
|
|
|
// Check the CSS box-align property.
|
2013-02-17 01:51:02 +04: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 07:17:02 +03:00
|
|
|
aStretch = (boxInfo->mBoxAlign == NS_STYLE_BOX_ALIGN_STRETCH);
|
2001-08-02 04:09:27 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
1999-11-19 00:05:43 +03:00
|
|
|
}
|
1999-07-02 09:28:32 +04:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsBoxFrame::DidReflow(nsPresContext* aPresContext,
|
2001-12-07 17:51:12 +03:00
|
|
|
const nsHTMLReflowState* aReflowState,
|
|
|
|
nsDidReflowStatus aStatus)
|
1999-09-10 04:57:01 +04:00
|
|
|
{
|
2003-06-02 00:03:13 +04:00
|
|
|
nsFrameState preserveBits =
|
|
|
|
mState & (NS_FRAME_IS_DIRTY | NS_FRAME_HAS_DIRTY_CHILDREN);
|
2001-12-07 17:51:12 +03:00
|
|
|
nsresult rv = nsFrame::DidReflow(aPresContext, aReflowState, aStatus);
|
2003-06-02 00:03:13 +04:00
|
|
|
mState |= preserveBits;
|
2000-03-31 11:02:06 +04:00
|
|
|
return rv;
|
1999-09-10 04:57:01 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2007-10-12 22:37:51 +04:00
|
|
|
nsBoxFrame::HonorPrintBackgroundSettings()
|
|
|
|
{
|
2008-02-26 15:40:18 +03:00
|
|
|
return (!mContent || !mContent->IsInNativeAnonymousSubtree()) &&
|
2007-10-12 22:37:51 +04:00
|
|
|
nsContainerFrame::HonorPrintBackgroundSettings();
|
|
|
|
}
|
|
|
|
|
2000-08-23 15:02:19 +04:00
|
|
|
#ifdef DO_NOISY_REFLOW
|
|
|
|
static int myCounter = 0;
|
|
|
|
static void printSize(char * aDesc, nscoord aSize)
|
|
|
|
{
|
2000-10-29 02:17:53 +04:00
|
|
|
printf(" %s: ", aDesc);
|
2000-08-23 15:02:19 +04:00
|
|
|
if (aSize == NS_UNCONSTRAINEDSIZE) {
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("UC");
|
2000-08-23 15:02:19 +04:00
|
|
|
} else {
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("%d", aSize);
|
2000-08-23 15:02:19 +04: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 08:38:33 +03:00
|
|
|
/* virtual */ nscoord
|
2011-04-08 05:04:40 +04:00
|
|
|
nsBoxFrame::GetMinWidth(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 08:38:33 +03:00
|
|
|
{
|
|
|
|
nscoord result;
|
|
|
|
DISPLAY_MIN_WIDTH(this, result);
|
|
|
|
|
2007-03-31 01:11:41 +04:00
|
|
|
nsBoxLayoutState state(PresContext(), aRenderingContext);
|
2007-01-08 05:57:59 +03: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 08:38:33 +03: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 16:22:03 +04: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 08:38:33 +03:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nscoord
|
2011-04-08 05:04:40 +04:00
|
|
|
nsBoxFrame::GetPrefWidth(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 08:38:33 +03:00
|
|
|
{
|
|
|
|
nscoord result;
|
|
|
|
DISPLAY_PREF_WIDTH(this, result);
|
|
|
|
|
2007-03-31 01:11:41 +04:00
|
|
|
nsBoxLayoutState state(PresContext(), aRenderingContext);
|
2007-01-08 05:57:59 +03: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 08:38:33 +03: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 16:22:03 +04: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 08:38:33 +03:00
|
|
|
|
|
|
|
return result;
|
2002-01-23 05:53:02 +03:00
|
|
|
}
|
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsBoxFrame::Reflow(nsPresContext* aPresContext,
|
2002-05-29 02:50:43 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1999-03-27 04:35:55 +03:00
|
|
|
{
|
2002-02-14 03:08:08 +03: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 08:38:33 +03:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsBoxFrame");
|
2002-03-03 22:53:56 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
1999-03-27 04:35:55 +03:00
|
|
|
|
2008-08-25 21:21:29 +04:00
|
|
|
NS_ASSERTION(aReflowState.ComputedWidth() >=0 &&
|
|
|
|
aReflowState.ComputedHeight() >= 0, "Computed Size < 0");
|
1999-04-13 01:48:21 +04:00
|
|
|
|
2000-08-23 15:02:19 +04:00
|
|
|
#ifdef DO_NOISY_REFLOW
|
2000-10-29 02:17:53 +04: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 08:38:33 +03:00
|
|
|
printf("%p ** nsBF::Reflow %d ", this, myCounter++);
|
2000-08-23 15:02:19 +04:00
|
|
|
|
2013-12-27 21:59:21 +04:00
|
|
|
printSize("AW", aReflowState.AvailableWidth());
|
|
|
|
printSize("AH", aReflowState.AvailableHeight());
|
2007-01-26 03:05:12 +03:00
|
|
|
printSize("CW", aReflowState.ComputedWidth());
|
2007-08-02 22:08:05 +04:00
|
|
|
printSize("CH", aReflowState.ComputedHeight());
|
2000-08-23 15:02:19 +04:00
|
|
|
|
2000-10-29 02:17:53 +04:00
|
|
|
printf(" *\n");
|
2000-08-23 15:02:19 +04:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
1999-04-13 01:48:21 +04:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
// create the layout state
|
2008-04-10 08:39:41 +04:00
|
|
|
nsBoxLayoutState state(aPresContext, aReflowState.rendContext,
|
2011-11-24 06:48:23 +04:00
|
|
|
&aReflowState, aReflowState.mReflowDepth);
|
1999-04-13 01:48:21 +04:00
|
|
|
|
2007-08-02 22:08:05 +04:00
|
|
|
nsSize computedSize(aReflowState.ComputedWidth(),aReflowState.ComputedHeight());
|
1999-09-14 00:24:20 +04:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
nsMargin m;
|
2013-12-27 21:59:21 +04:00
|
|
|
m = aReflowState.ComputedPhysicalBorderPadding();
|
2002-09-26 00:23:34 +04:00
|
|
|
// GetBorderAndPadding(m);
|
1999-08-31 02:32:25 +04:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
nsSize prefSize(0,0);
|
1999-09-14 00:24:20 +04:00
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
// if we are told to layout intrinsic then get our preferred size.
|
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 08:38:33 +03:00
|
|
|
NS_ASSERTION(computedSize.width != NS_INTRINSICSIZE,
|
|
|
|
"computed width should always be computed");
|
|
|
|
if (computedSize.height == NS_INTRINSICSIZE) {
|
2007-01-08 05:57:59 +03:00
|
|
|
prefSize = GetPrefSize(state);
|
2007-01-08 06:49:59 +03:00
|
|
|
nsSize minSize = GetMinSize(state);
|
|
|
|
nsSize maxSize = GetMaxSize(state);
|
2009-04-28 01:18:37 +04:00
|
|
|
// XXXbz isn't GetPrefSize supposed to bounds-check for us?
|
2008-01-05 08:49:44 +03:00
|
|
|
prefSize = BoundsCheck(minSize, prefSize, maxSize);
|
2000-03-31 11:02:06 +04: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-10 01:02:40 +03:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
// get our desiredSize
|
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 08:38:33 +03:00
|
|
|
computedSize.width += m.left + m.right;
|
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-10 01:02:40 +03:00
|
|
|
|
2007-08-02 22:08:05 +04:00
|
|
|
if (aReflowState.ComputedHeight() == NS_INTRINSICSIZE) {
|
2000-08-24 17:19:57 +04:00
|
|
|
computedSize.height = prefSize.height;
|
2012-09-12 02:20:51 +04:00
|
|
|
// prefSize is border-box but min/max constraints are content-box.
|
|
|
|
nscoord verticalBorderPadding =
|
2013-12-27 21:59:21 +04:00
|
|
|
aReflowState.ComputedPhysicalBorderPadding().TopBottom();
|
2012-09-12 02:20:51 +04:00
|
|
|
nscoord contentHeight = computedSize.height - verticalBorderPadding;
|
|
|
|
// Note: contentHeight might be negative, but that's OK because min-height
|
|
|
|
// is never negative.
|
|
|
|
computedSize.height = aReflowState.ApplyMinMaxHeight(contentHeight) +
|
|
|
|
verticalBorderPadding;
|
2000-08-18 00:08:44 +04:00
|
|
|
} else {
|
|
|
|
computedSize.height += m.top + m.bottom;
|
|
|
|
}
|
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-10 01:02:40 +03:00
|
|
|
|
2000-06-23 09:15:04 +04:00
|
|
|
nsRect r(mRect.x, mRect.y, computedSize.width, computedSize.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-10 01:02:40 +03:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
SetBounds(state, r);
|
|
|
|
|
|
|
|
// layout our children
|
|
|
|
Layout(state);
|
|
|
|
|
|
|
|
// ok our child could have gotten bigger. So lets get its bounds
|
|
|
|
|
|
|
|
// get the ascent
|
2004-09-28 22:37:50 +04:00
|
|
|
nscoord ascent = mRect.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-10 01:02:40 +03:00
|
|
|
|
2000-03-31 11:02:06 +04: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 05:53:02 +03:00
|
|
|
if (!(mState & NS_STATE_IS_ROOT)) {
|
2007-01-31 19:02:42 +03:00
|
|
|
ascent = GetBoxAscent(state);
|
2002-01-23 05:53:02 +03: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-10 01:02:40 +03:00
|
|
|
|
2013-12-27 21:59:52 +04:00
|
|
|
aDesiredSize.Width() = mRect.width;
|
|
|
|
aDesiredSize.Height() = mRect.height;
|
|
|
|
aDesiredSize.SetTopAscent(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-10 01:02:40 +03:00
|
|
|
|
2010-10-07 08:25:46 +04:00
|
|
|
aDesiredSize.mOverflowAreas = GetOverflowAreas();
|
2004-07-16 20:56:21 +04:00
|
|
|
|
2000-08-23 15:02:19 +04:00
|
|
|
#ifdef DO_NOISY_REFLOW
|
|
|
|
{
|
2013-12-27 21:59:52 +04:00
|
|
|
printf("%p ** nsBF(done) W:%d H:%d ", this, aDesiredSize.Width(), aDesiredSize.Height());
|
2000-08-23 15:02:19 +04:00
|
|
|
|
|
|
|
if (maxElementSize) {
|
2003-01-09 17:26:32 +03:00
|
|
|
printf("MW:%d\n", *maxElementWidth);
|
2000-08-23 15:02:19 +04:00
|
|
|
} else {
|
2003-01-09 17:26:32 +03:00
|
|
|
printf("MW:?\n");
|
2000-08-23 15:02:19 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
2000-04-05 04:19:00 +04:00
|
|
|
|
2012-03-11 02:49:10 +04:00
|
|
|
ReflowAbsoluteFrames(aPresContext, aDesiredSize, aReflowState, aStatus);
|
|
|
|
|
2002-05-29 02:50:43 +04:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
2000-03-31 11:02:06 +04:00
|
|
|
return NS_OK;
|
1999-04-13 01:48:21 +04:00
|
|
|
}
|
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
nsSize
|
|
|
|
nsBoxFrame::GetPrefSize(nsBoxLayoutState& aBoxLayoutState)
|
1999-03-27 04:35:55 +03:00
|
|
|
{
|
2007-04-30 02:24:59 +04:00
|
|
|
NS_ASSERTION(aBoxLayoutState.GetRenderingContext(),
|
|
|
|
"must have rendering context");
|
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
nsSize size(0,0);
|
|
|
|
DISPLAY_PREF_SIZE(this, size);
|
2000-06-06 05:25:03 +04:00
|
|
|
if (!DoesNeedRecalc(mPrefSize)) {
|
2010-03-18 22:58:15 +03:00
|
|
|
return mPrefSize;
|
2000-02-25 07:18:34 +03:00
|
|
|
}
|
|
|
|
|
2004-06-19 13:07:47 +04:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2000-03-31 11:02:06 +04:00
|
|
|
PropagateDebug(aBoxLayoutState);
|
2004-06-19 13:07:47 +04:00
|
|
|
#endif
|
1999-03-27 04:35:55 +03:00
|
|
|
|
2011-06-16 01:03:49 +04:00
|
|
|
if (IsCollapsed())
|
2007-01-08 05:57:59 +03:00
|
|
|
return size;
|
2004-09-28 22:37:50 +04:00
|
|
|
|
|
|
|
// if the size was not completely redefined in CSS then ask our children
|
2011-09-29 10:19:26 +04:00
|
|
|
bool widthSet, heightSet;
|
2012-08-06 07:00:57 +04:00
|
|
|
if (!nsIFrame::AddCSSPrefSize(this, size, widthSet, heightSet))
|
2004-09-28 22:37:50 +04:00
|
|
|
{
|
|
|
|
if (mLayoutManager) {
|
2010-03-18 22:58:15 +03:00
|
|
|
nsSize layoutSize = mLayoutManager->GetPrefSize(this, aBoxLayoutState);
|
|
|
|
if (!widthSet)
|
|
|
|
size.width = layoutSize.width;
|
|
|
|
if (!heightSet)
|
|
|
|
size.height = layoutSize.height;
|
|
|
|
}
|
|
|
|
else {
|
2007-01-08 05:57:59 +03:00
|
|
|
size = nsBox::GetPrefSize(aBoxLayoutState);
|
2010-03-18 22:58:15 +03:00
|
|
|
}
|
2004-09-28 22:37:50 +04:00
|
|
|
}
|
|
|
|
|
2007-01-08 06:49:59 +03:00
|
|
|
nsSize minSize = GetMinSize(aBoxLayoutState);
|
|
|
|
nsSize maxSize = GetMaxSize(aBoxLayoutState);
|
2008-01-05 08:49:44 +03:00
|
|
|
mPrefSize = BoundsCheck(minSize, size, maxSize);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2008-01-05 08:49:44 +03:00
|
|
|
return mPrefSize;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
1999-10-22 00:17:51 +04:00
|
|
|
|
2007-01-31 19:02:42 +03:00
|
|
|
nscoord
|
|
|
|
nsBoxFrame::GetBoxAscent(nsBoxLayoutState& aBoxLayoutState)
|
2000-03-31 11:02:06 +04:00
|
|
|
{
|
2007-01-31 19:02:42 +03:00
|
|
|
if (!DoesNeedRecalc(mAscent))
|
|
|
|
return mAscent;
|
1999-07-24 03:30:17 +04:00
|
|
|
|
2004-06-19 13:07:47 +04:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2000-03-31 11:02:06 +04:00
|
|
|
PropagateDebug(aBoxLayoutState);
|
2004-06-19 13:07:47 +04:00
|
|
|
#endif
|
1999-07-24 03:30:17 +04:00
|
|
|
|
2011-06-16 01:03:49 +04:00
|
|
|
if (IsCollapsed())
|
2007-01-31 19:02:42 +03:00
|
|
|
return 0;
|
2004-09-28 22:37:50 +04:00
|
|
|
|
|
|
|
if (mLayoutManager)
|
2008-01-09 10:28:39 +03:00
|
|
|
mAscent = mLayoutManager->GetAscent(this, aBoxLayoutState);
|
2004-09-28 22:37:50 +04:00
|
|
|
else
|
2007-01-31 19:02:42 +03:00
|
|
|
mAscent = nsBox::GetBoxAscent(aBoxLayoutState);
|
2004-09-28 22:37:50 +04:00
|
|
|
|
2007-01-31 19:02:42 +03:00
|
|
|
return mAscent;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
1999-07-24 03:30:17 +04:00
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
nsSize
|
|
|
|
nsBoxFrame::GetMinSize(nsBoxLayoutState& aBoxLayoutState)
|
2000-03-31 11:02:06 +04:00
|
|
|
{
|
2007-04-30 02:24:59 +04:00
|
|
|
NS_ASSERTION(aBoxLayoutState.GetRenderingContext(),
|
|
|
|
"must have rendering context");
|
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
nsSize size(0,0);
|
|
|
|
DISPLAY_MIN_SIZE(this, size);
|
2000-06-06 05:25:03 +04:00
|
|
|
if (!DoesNeedRecalc(mMinSize)) {
|
2010-03-18 22:58:15 +03:00
|
|
|
return mMinSize;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
1999-07-24 03:30:17 +04:00
|
|
|
|
2004-06-19 13:07:47 +04:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2000-03-31 11:02:06 +04:00
|
|
|
PropagateDebug(aBoxLayoutState);
|
2004-06-19 13:07:47 +04: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-10 01:02:40 +03:00
|
|
|
|
2011-06-16 01:03:49 +04:00
|
|
|
if (IsCollapsed())
|
2007-01-08 05:57:59 +03:00
|
|
|
return size;
|
2004-09-28 22:37:50 +04:00
|
|
|
|
|
|
|
// if the size was not completely redefined in CSS then ask our children
|
2011-09-29 10:19:26 +04:00
|
|
|
bool widthSet, heightSet;
|
2012-08-06 07:00:57 +04:00
|
|
|
if (!nsIFrame::AddCSSMinSize(aBoxLayoutState, this, size, widthSet, heightSet))
|
2004-09-28 22:37:50 +04:00
|
|
|
{
|
|
|
|
if (mLayoutManager) {
|
2010-03-18 22:58:15 +03:00
|
|
|
nsSize layoutSize = mLayoutManager->GetMinSize(this, aBoxLayoutState);
|
|
|
|
if (!widthSet)
|
|
|
|
size.width = layoutSize.width;
|
|
|
|
if (!heightSet)
|
|
|
|
size.height = layoutSize.height;
|
|
|
|
}
|
|
|
|
else {
|
2007-01-08 05:57:59 +03:00
|
|
|
size = nsBox::GetMinSize(aBoxLayoutState);
|
2004-09-28 22:37:50 +04:00
|
|
|
}
|
|
|
|
}
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2007-01-08 05:57:59 +03: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-10 01:02:40 +03:00
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
return size;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
1999-07-24 03:30:17 +04:00
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
nsSize
|
|
|
|
nsBoxFrame::GetMaxSize(nsBoxLayoutState& aBoxLayoutState)
|
2000-03-31 11:02:06 +04:00
|
|
|
{
|
2007-04-30 02:24:59 +04:00
|
|
|
NS_ASSERTION(aBoxLayoutState.GetRenderingContext(),
|
|
|
|
"must have rendering context");
|
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
nsSize size(NS_INTRINSICSIZE, NS_INTRINSICSIZE);
|
|
|
|
DISPLAY_MAX_SIZE(this, size);
|
2000-06-06 05:25:03 +04:00
|
|
|
if (!DoesNeedRecalc(mMaxSize)) {
|
2010-03-18 22:58:15 +03:00
|
|
|
return mMaxSize;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
1999-07-24 03:30:17 +04:00
|
|
|
|
2004-06-19 13:07:47 +04:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2000-03-31 11:02:06 +04:00
|
|
|
PropagateDebug(aBoxLayoutState);
|
2004-06-19 13:07:47 +04:00
|
|
|
#endif
|
2000-03-02 06:01:30 +03:00
|
|
|
|
2011-06-16 01:03:49 +04:00
|
|
|
if (IsCollapsed())
|
2007-01-08 05:57:59 +03:00
|
|
|
return size;
|
2004-09-28 22:37:50 +04:00
|
|
|
|
|
|
|
// if the size was not completely redefined in CSS then ask our children
|
2011-09-29 10:19:26 +04:00
|
|
|
bool widthSet, heightSet;
|
2012-08-06 07:00:57 +04:00
|
|
|
if (!nsIFrame::AddCSSMaxSize(this, size, widthSet, heightSet))
|
2004-09-28 22:37:50 +04:00
|
|
|
{
|
|
|
|
if (mLayoutManager) {
|
2010-03-18 22:58:15 +03:00
|
|
|
nsSize layoutSize = mLayoutManager->GetMaxSize(this, aBoxLayoutState);
|
|
|
|
if (!widthSet)
|
|
|
|
size.width = layoutSize.width;
|
|
|
|
if (!heightSet)
|
|
|
|
size.height = layoutSize.height;
|
|
|
|
}
|
|
|
|
else {
|
2007-01-08 05:57:59 +03:00
|
|
|
size = nsBox::GetMaxSize(aBoxLayoutState);
|
2004-09-28 22:37:50 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
mMaxSize = size;
|
2000-03-02 06:01:30 +03:00
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
return size;
|
1999-03-27 04:35:55 +03:00
|
|
|
}
|
|
|
|
|
2007-01-31 19:02:42 +03: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-10 01:02:40 +03:00
|
|
|
{
|
2007-01-31 19:02:42 +03: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-10 01:02:40 +03:00
|
|
|
|
2007-01-31 19:02:42 +03: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-10 01:02:40 +03:00
|
|
|
|
2007-01-31 19:02:42 +03:00
|
|
|
return mFlex;
|
2000-03-31 11:02:06 +04: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-10 01:02:40 +03:00
|
|
|
|
2000-07-08 02:24:06 +04:00
|
|
|
/**
|
|
|
|
* If subclassing please subclass this method not layout.
|
|
|
|
* layout will call this method.
|
|
|
|
*/
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBoxFrame::DoLayout(nsBoxLayoutState& aState)
|
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t oldFlags = aState.LayoutFlags();
|
2004-09-28 22:37:50 +04:00
|
|
|
aState.SetLayoutFlags(0);
|
|
|
|
|
|
|
|
nsresult rv = NS_OK;
|
2009-10-22 04:11:25 +04:00
|
|
|
if (mLayoutManager) {
|
|
|
|
CoordNeedsRecalc(mAscent);
|
2004-09-28 22:37:50 +04:00
|
|
|
rv = mLayoutManager->Layout(this, aState);
|
2009-10-22 04:11:25 +04:00
|
|
|
}
|
2004-09-28 22:37:50 +04:00
|
|
|
|
|
|
|
aState.SetLayoutFlags(oldFlags);
|
|
|
|
|
2012-03-11 02:49:10 +04:00
|
|
|
if (HasAbsolutelyPositionedChildren()) {
|
|
|
|
// Set up a |reflowState| to pass into ReflowAbsoluteFrames
|
|
|
|
nsHTMLReflowState reflowState(aState.PresContext(), this,
|
|
|
|
aState.GetRenderingContext(),
|
|
|
|
nsSize(mRect.width, NS_UNCONSTRAINEDSIZE));
|
|
|
|
|
|
|
|
// Set up a |desiredSize| to pass into ReflowAbsoluteFrames
|
2013-12-30 02:48:13 +04:00
|
|
|
nsHTMLReflowMetrics desiredSize(reflowState.GetWritingMode());
|
2013-12-27 21:59:52 +04:00
|
|
|
desiredSize.Width() = mRect.width;
|
|
|
|
desiredSize.Height() = mRect.height;
|
2012-03-11 02:49:10 +04: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);
|
|
|
|
}
|
2013-12-27 21:59:52 +04:00
|
|
|
desiredSize.SetTopAscent(ascent);
|
2012-03-11 02:49:10 +04:00
|
|
|
desiredSize.mOverflowAreas = GetOverflowAreas();
|
|
|
|
|
2014-01-04 01:08:50 +04:00
|
|
|
AddStateBits(NS_FRAME_IN_REFLOW);
|
2012-03-11 02:49:10 +04: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-04 01:08:50 +04:00
|
|
|
RemoveStateBits(NS_FRAME_IN_REFLOW);
|
2012-03-11 02:49:10 +04:00
|
|
|
}
|
|
|
|
|
2004-09-28 22:37:50 +04:00
|
|
|
return rv;
|
2000-07-08 02:24:06 +04:00
|
|
|
}
|
|
|
|
|
2006-04-10 04:16:29 +04:00
|
|
|
void
|
2009-12-24 08:21:15 +03:00
|
|
|
nsBoxFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
2000-02-17 07:10:02 +03:00
|
|
|
{
|
2002-02-21 16:39:39 +03:00
|
|
|
// unregister access key
|
2011-10-17 18:59:28 +04:00
|
|
|
RegUnregAccessKey(false);
|
2002-02-21 16:39:39 +03:00
|
|
|
|
2003-03-26 09:52:20 +03:00
|
|
|
// clean up the container box's layout manager and child boxes
|
2012-07-30 18:20:58 +04:00
|
|
|
SetLayoutManager(nullptr);
|
2000-04-18 04:17:00 +04:00
|
|
|
|
2009-12-24 08:21:15 +03:00
|
|
|
nsContainerFrame::DestroyFrom(aDestructRoot);
|
2000-02-17 07:10:02 +03:00
|
|
|
}
|
|
|
|
|
2004-06-19 13:07:47 +04:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2000-03-02 06:01:30 +03:00
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsBoxFrame::SetDebug(nsBoxLayoutState& aState, bool aDebug)
|
2000-03-02 06:01:30 +03:00
|
|
|
{
|
|
|
|
// see if our state matches the given debug state
|
2011-09-29 10:19:26 +04:00
|
|
|
bool debugSet = mState & NS_STATE_CURRENTLY_IN_DEBUG;
|
|
|
|
bool debugChanged = (!aDebug && debugSet) || (aDebug && !debugSet);
|
2000-03-02 06:01:30 +03: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 11:02:06 +04:00
|
|
|
|
|
|
|
SetDebugOnChildList(aState, mFirstChild, aDebug);
|
2000-03-02 06:01:30 +03: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 08:38:33 +03:00
|
|
|
MarkIntrinsicWidthsDirty();
|
2000-03-02 06:01:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2004-06-19 13:07:47 +04:00
|
|
|
#endif
|
2000-03-02 06:01:30 +03: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 08:38:33 +03:00
|
|
|
/* virtual */ void
|
|
|
|
nsBoxFrame::MarkIntrinsicWidthsDirty()
|
2000-03-02 06:01:30 +03:00
|
|
|
{
|
2002-10-10 10:39:30 +04: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 08:38:33 +03:00
|
|
|
|
|
|
|
if (mLayoutManager) {
|
2007-03-31 01:11:41 +04:00
|
|
|
nsBoxLayoutState state(PresContext());
|
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 08:38:33 +03:00
|
|
|
mLayoutManager->IntrinsicWidthsDirty(this, state);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Don't call base class method, since everything it does is within an
|
|
|
|
// IsBoxWrapped check.
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-08-25 00:54:30 +04:00
|
|
|
nsBoxFrame::RemoveFrame(ChildListID aListID,
|
2002-10-10 10:39:30 +04:00
|
|
|
nsIFrame* aOldFrame)
|
2000-03-31 11:02:06 +04:00
|
|
|
{
|
2011-08-25 00:54:30 +04:00
|
|
|
NS_PRECONDITION(aListID == kPrincipalList, "We don't support out-of-flow kids");
|
2007-03-31 01:11:41 +04:00
|
|
|
nsPresContext* presContext = PresContext();
|
2005-02-07 04:58:25 +03:00
|
|
|
nsBoxLayoutState state(presContext);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
|
|
|
// remove the child frame
|
2004-09-28 22:37:50 +04:00
|
|
|
mFrames.RemoveFrame(aOldFrame);
|
|
|
|
|
|
|
|
// notify the layout manager
|
|
|
|
if (mLayoutManager)
|
|
|
|
mLayoutManager->ChildrenRemoved(this, state, aOldFrame);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2004-09-28 22:37:50 +04:00
|
|
|
// destroy the child frame
|
2006-04-10 04:16:29 +04:00
|
|
|
aOldFrame->Destroy();
|
2000-03-31 11:02:06 +04:00
|
|
|
|
|
|
|
// mark us dirty and generate a reflow command
|
2007-03-31 01:11:41 +04:00
|
|
|
PresContext()->PresShell()->
|
2007-05-06 23:16:51 +04:00
|
|
|
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
2000-03-31 11:02:06 +04:00
|
|
|
return NS_OK;
|
2000-03-02 06:01:30 +03:00
|
|
|
}
|
|
|
|
|
1999-05-10 01:46:24 +04:00
|
|
|
NS_IMETHODIMP
|
2011-08-25 00:54:30 +04:00
|
|
|
nsBoxFrame::InsertFrames(ChildListID aListID,
|
2002-10-10 10:39:30 +04:00
|
|
|
nsIFrame* aPrevFrame,
|
2009-07-30 21:23:32 +04:00
|
|
|
nsFrameList& aFrameList)
|
1999-05-10 01:46:24 +04:00
|
|
|
{
|
2006-06-29 06:32:36 +04:00
|
|
|
NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == this,
|
|
|
|
"inserting after sibling frame with different parent");
|
2007-10-20 09:43:38 +04:00
|
|
|
NS_ASSERTION(!aPrevFrame || mFrames.ContainsFrame(aPrevFrame),
|
|
|
|
"inserting after sibling frame not in our child list");
|
2011-08-25 00:54:30 +04:00
|
|
|
NS_PRECONDITION(aListID == kPrincipalList, "We don't support out-of-flow kids");
|
2007-03-31 01:11:41 +04:00
|
|
|
nsBoxLayoutState state(PresContext());
|
2004-09-28 22:37:50 +04:00
|
|
|
|
|
|
|
// insert the child frames
|
2009-07-30 21:23:32 +04:00
|
|
|
const nsFrameList::Slice& newFrames =
|
|
|
|
mFrames.InsertFrames(this, aPrevFrame, aFrameList);
|
1999-11-19 00:05:43 +03:00
|
|
|
|
2004-09-28 22:37:50 +04:00
|
|
|
// notify the layout manager
|
|
|
|
if (mLayoutManager)
|
2009-07-30 21:23:32 +04:00
|
|
|
mLayoutManager->ChildrenInserted(this, state, aPrevFrame, newFrames);
|
2004-09-28 22:37:50 +04:00
|
|
|
|
2010-06-29 00:47:58 +04: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-12-01 03:25:32 +04:00
|
|
|
CheckBoxOrder();
|
2010-06-29 00:47:58 +04:00
|
|
|
|
2004-06-19 13:07:47 +04:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2000-03-02 06:01:30 +03: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 18:59:28 +04:00
|
|
|
SetDebugOnChildList(state, mFrames.FirstChild(), true);
|
2004-06-19 13:07:47 +04:00
|
|
|
#endif
|
2000-03-02 06:01:30 +03:00
|
|
|
|
2007-03-31 01:11:41 +04:00
|
|
|
PresContext()->PresShell()->
|
2007-05-06 23:16:51 +04:00
|
|
|
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
2000-03-31 11:02:06 +04:00
|
|
|
return NS_OK;
|
1999-11-19 00:05:43 +03:00
|
|
|
}
|
|
|
|
|
1999-05-10 01:46:24 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-08-25 00:54:30 +04:00
|
|
|
nsBoxFrame::AppendFrames(ChildListID aListID,
|
2009-07-30 21:23:32 +04:00
|
|
|
nsFrameList& aFrameList)
|
1999-05-10 01:46:24 +04:00
|
|
|
{
|
2011-08-25 00:54:30 +04:00
|
|
|
NS_PRECONDITION(aListID == kPrincipalList, "We don't support out-of-flow kids");
|
2007-03-31 01:11:41 +04:00
|
|
|
nsBoxLayoutState state(PresContext());
|
1999-05-18 08:06:52 +04:00
|
|
|
|
2004-09-28 22:37:50 +04:00
|
|
|
// append the new frames
|
2009-07-30 21:23:32 +04:00
|
|
|
const nsFrameList::Slice& newFrames = mFrames.AppendFrames(this, aFrameList);
|
2004-09-28 22:37:50 +04:00
|
|
|
|
|
|
|
// notify the layout manager
|
|
|
|
if (mLayoutManager)
|
2009-07-30 21:23:32 +04:00
|
|
|
mLayoutManager->ChildrenAppended(this, state, newFrames);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2010-06-29 00:47:58 +04: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-12-01 03:25:32 +04:00
|
|
|
CheckBoxOrder();
|
2010-06-29 00:47:58 +04:00
|
|
|
|
2004-06-19 13:07:47 +04:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2000-03-02 06:01:30 +03: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 18:59:28 +04:00
|
|
|
SetDebugOnChildList(state, mFrames.FirstChild(), true);
|
2004-06-19 13:07:47 +04:00
|
|
|
#endif
|
2000-03-02 06:01:30 +03:00
|
|
|
|
2007-05-06 23:16:51 +04:00
|
|
|
// XXXbz why is this NS_FRAME_FIRST_REFLOW check here?
|
2006-01-09 07:01:09 +03:00
|
|
|
if (!(GetStateBits() & NS_FRAME_FIRST_REFLOW)) {
|
2007-03-31 01:11:41 +04:00
|
|
|
PresContext()->PresShell()->
|
2007-05-06 23:16:51 +04:00
|
|
|
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
2006-01-09 07:01:09 +03:00
|
|
|
}
|
2000-03-31 11:02:06 +04:00
|
|
|
return NS_OK;
|
1999-05-10 01:46:24 +04:00
|
|
|
}
|
|
|
|
|
2007-10-26 03:30:49 +04:00
|
|
|
/* virtual */ nsIFrame*
|
|
|
|
nsBoxFrame::GetContentInsertionFrame()
|
|
|
|
{
|
|
|
|
if (GetStateBits() & NS_STATE_BOX_WRAPS_KIDS_IN_BLOCK)
|
2011-08-25 00:54:30 +04:00
|
|
|
return GetFirstPrincipalChild()->GetContentInsertionFrame();
|
2007-10-26 03:30:49 +04:00
|
|
|
return nsContainerFrame::GetContentInsertionFrame();
|
|
|
|
}
|
1999-03-27 04:35:55 +03:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsBoxFrame::AttributeChanged(int32_t aNameSpaceID,
|
2002-02-21 16:39:39 +03:00
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aModType)
|
2002-02-21 16:39:39 +03:00
|
|
|
{
|
2005-09-07 20:49:21 +04:00
|
|
|
nsresult rv = nsContainerFrame::AttributeChanged(aNameSpaceID, aAttribute,
|
|
|
|
aModType);
|
2003-07-12 01:16:12 +04:00
|
|
|
|
|
|
|
// Ignore 'width', 'height', 'screenX', 'screenY' and 'sizemode' on a
|
|
|
|
// <window>.
|
2003-11-19 04:20:56 +03:00
|
|
|
nsIAtom *tag = mContent->Tag();
|
2006-12-26 20:47:52 +03:00
|
|
|
if ((tag == nsGkAtoms::window ||
|
|
|
|
tag == nsGkAtoms::page ||
|
|
|
|
tag == nsGkAtoms::dialog ||
|
|
|
|
tag == nsGkAtoms::wizard) &&
|
|
|
|
(nsGkAtoms::width == aAttribute ||
|
|
|
|
nsGkAtoms::height == aAttribute ||
|
|
|
|
nsGkAtoms::screenX == aAttribute ||
|
|
|
|
nsGkAtoms::screenY == aAttribute ||
|
|
|
|
nsGkAtoms::sizemode == aAttribute)) {
|
2003-07-12 01:16:12 +04:00
|
|
|
return rv;
|
|
|
|
}
|
2002-02-21 16:39:39 +03:00
|
|
|
|
2006-12-26 20:47:52 +03:00
|
|
|
if (aAttribute == nsGkAtoms::width ||
|
|
|
|
aAttribute == nsGkAtoms::height ||
|
|
|
|
aAttribute == nsGkAtoms::align ||
|
|
|
|
aAttribute == nsGkAtoms::valign ||
|
|
|
|
aAttribute == nsGkAtoms::left ||
|
|
|
|
aAttribute == nsGkAtoms::top ||
|
2009-09-14 01:13:54 +04:00
|
|
|
aAttribute == nsGkAtoms::right ||
|
|
|
|
aAttribute == nsGkAtoms::bottom ||
|
2011-02-28 21:06:29 +03:00
|
|
|
aAttribute == nsGkAtoms::start ||
|
|
|
|
aAttribute == nsGkAtoms::end ||
|
2006-12-26 20:47:52 +03: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-19 03:22:46 +04:00
|
|
|
aAttribute == nsGkAtoms::mousethrough ||
|
2006-12-26 20:47:52 +03:00
|
|
|
aAttribute == nsGkAtoms::equalsize) {
|
|
|
|
|
|
|
|
if (aAttribute == nsGkAtoms::align ||
|
|
|
|
aAttribute == nsGkAtoms::valign ||
|
|
|
|
aAttribute == nsGkAtoms::orient ||
|
|
|
|
aAttribute == nsGkAtoms::pack ||
|
2004-06-19 13:07:47 +04:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2006-12-26 20:47:52 +03:00
|
|
|
aAttribute == nsGkAtoms::debug ||
|
2004-06-19 13:07:47 +04:00
|
|
|
#endif
|
2006-12-26 20:47:52 +03:00
|
|
|
aAttribute == nsGkAtoms::dir) {
|
2002-02-21 16:39:39 +03:00
|
|
|
|
2002-10-10 10:39:30 +04:00
|
|
|
mValign = nsBoxFrame::vAlign_Top;
|
|
|
|
mHalign = nsBoxFrame::hAlign_Left;
|
2002-02-21 16:39:39 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool orient = true;
|
2002-02-21 16:39:39 +03:00
|
|
|
GetInitialOrientation(orient);
|
|
|
|
if (orient)
|
|
|
|
mState |= NS_STATE_IS_HORIZONTAL;
|
|
|
|
else
|
|
|
|
mState &= ~NS_STATE_IS_HORIZONTAL;
|
1999-05-10 01:46:24 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool normal = true;
|
2002-02-21 16:39:39 +03:00
|
|
|
GetInitialDirection(normal);
|
|
|
|
if (normal)
|
|
|
|
mState |= NS_STATE_IS_DIRECTION_NORMAL;
|
|
|
|
else
|
|
|
|
mState &= ~NS_STATE_IS_DIRECTION_NORMAL;
|
2001-12-04 02:41:13 +03:00
|
|
|
|
2002-10-10 10:39:30 +04: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-10 01:02:40 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool equalSize = false;
|
2002-02-21 16:39:39 +03: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-10 01:02:40 +03:00
|
|
|
|
2004-06-19 13:07:47 +04:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2011-09-29 10:19:26 +04:00
|
|
|
bool debug = mState & NS_STATE_SET_TO_DEBUG;
|
|
|
|
bool debugSet = GetInitialDebug(debug);
|
2002-02-21 16:39:39 +03:00
|
|
|
if (debugSet) {
|
|
|
|
mState |= NS_STATE_DEBUG_WAS_SET;
|
2001-12-04 02:41:13 +03:00
|
|
|
|
2002-02-21 16:39:39 +03: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 13:07:47 +04:00
|
|
|
#endif
|
2000-02-14 04:42:09 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool autostretch = !!(mState & NS_STATE_AUTO_STRETCH);
|
2002-02-21 16:39:39 +03:00
|
|
|
GetInitialAutoStretch(autostretch);
|
|
|
|
if (autostretch)
|
|
|
|
mState |= NS_STATE_AUTO_STRETCH;
|
|
|
|
else
|
|
|
|
mState &= ~NS_STATE_AUTO_STRETCH;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
2006-12-26 20:47:52 +03:00
|
|
|
else if (aAttribute == nsGkAtoms::left ||
|
2009-09-14 01:13:54 +04:00
|
|
|
aAttribute == nsGkAtoms::top ||
|
|
|
|
aAttribute == nsGkAtoms::right ||
|
2011-02-28 21:06:29 +03:00
|
|
|
aAttribute == nsGkAtoms::bottom ||
|
|
|
|
aAttribute == nsGkAtoms::start ||
|
|
|
|
aAttribute == nsGkAtoms::end) {
|
2002-02-21 16:39:39 +03:00
|
|
|
mState &= ~NS_STATE_STACK_NOT_POSITIONED;
|
|
|
|
}
|
2007-06-19 03:22:46 +04:00
|
|
|
else if (aAttribute == nsGkAtoms::mousethrough) {
|
|
|
|
UpdateMouseThrough();
|
|
|
|
}
|
2004-09-17 22:36:30 +04:00
|
|
|
|
2007-03-31 01:11:41 +04:00
|
|
|
PresContext()->PresShell()->
|
2007-05-06 23:16:51 +04:00
|
|
|
FrameNeedsReflow(this, nsIPresShell::eStyleChange, NS_FRAME_IS_DIRTY);
|
2002-02-21 16:39:39 +03:00
|
|
|
}
|
2006-12-26 20:47:52 +03:00
|
|
|
else if (aAttribute == nsGkAtoms::ordinal) {
|
2007-03-31 01:11:41 +04:00
|
|
|
nsBoxLayoutState state(PresContext());
|
2012-08-06 07:00:57 +04:00
|
|
|
nsIFrame* parent = GetParentBox();
|
2006-02-21 03:40:54 +03: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 19:39:22 +04:00
|
|
|
// Also don't bother with popup frames since they are kept on the
|
2011-08-25 00:54:30 +04:00
|
|
|
// kPopupList and RelayoutChildAtOrdinal() only handles
|
2007-08-16 19:39:22 +04:00
|
|
|
// principal children.
|
|
|
|
if (parent && !(GetStateBits() & NS_FRAME_OUT_OF_FLOW) &&
|
2013-02-17 01:51:02 +04:00
|
|
|
StyleDisplay()->mDisplay != NS_STYLE_DISPLAY_POPUP) {
|
2007-08-16 19:39:22 +04: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 08:38:33 +03:00
|
|
|
// XXXldb Should this instead be a tree change on the child or parent?
|
2007-03-31 01:11:41 +04:00
|
|
|
PresContext()->PresShell()->
|
2007-05-06 23:16:51 +04:00
|
|
|
FrameNeedsReflow(parent, nsIPresShell::eStyleChange,
|
|
|
|
NS_FRAME_IS_DIRTY);
|
2006-02-21 03:40:54 +03:00
|
|
|
}
|
2002-02-21 16:39:39 +03:00
|
|
|
}
|
|
|
|
// If the accesskey changed, register for the new value
|
|
|
|
// The old value has been unregistered in nsXULElement::SetAttr
|
2006-12-26 20:47:52 +03:00
|
|
|
else if (aAttribute == nsGkAtoms::accesskey) {
|
2011-10-17 18:59:28 +04:00
|
|
|
RegUnregAccessKey(true);
|
2002-02-21 16:39:39 +03:00
|
|
|
}
|
2013-09-13 15:02:30 +04:00
|
|
|
else if (aAttribute == nsGkAtoms::rows &&
|
|
|
|
tag == nsGkAtoms::tree) {
|
|
|
|
// 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-04 02:41:13 +03:00
|
|
|
|
1999-03-27 04:35:55 +03:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2004-06-19 13:07:47 +04:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2000-03-31 11:02:06 +04:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsBoxFrame::GetDebugPref(nsPresContext* aPresContext)
|
2000-03-31 11:02:06 +04:00
|
|
|
{
|
2011-05-25 10:31:59 +04:00
|
|
|
gDebug = Preferences::GetBool("xul.debug.box");
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
2000-09-01 04:59:09 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
class nsDisplayXULDebug : public nsDisplayItem {
|
|
|
|
public:
|
2010-08-13 14:01:13 +04:00
|
|
|
nsDisplayXULDebug(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame) :
|
|
|
|
nsDisplayItem(aBuilder, aFrame) {
|
2006-01-29 21:48:58 +03:00
|
|
|
MOZ_COUNT_CTOR(nsDisplayXULDebug);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayXULDebug() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayXULDebug);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-04-08 04:31:26 +04: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 11:08:04 +04:00
|
|
|
static_cast<nsBoxFrame*>(mFrame)->
|
2010-08-13 14:01:58 +04:00
|
|
|
DisplayDebugInfoFor(this, rectCenter - ToReferenceFrame());
|
2010-04-08 04:31:26 +04:00
|
|
|
aOutFrames->AppendElement(this);
|
2000-09-01 04:59:09 +04:00
|
|
|
}
|
2009-09-07 04:35:14 +04:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder
|
2011-04-08 05:04:40 +04:00
|
|
|
nsRenderingContext* aCtx);
|
2010-07-16 01:07:49 +04:00
|
|
|
NS_DISPLAY_DECL_NAME("XULDebug", TYPE_XUL_DEBUG)
|
2006-01-26 05:29:17 +03:00
|
|
|
};
|
2001-04-25 23:52:49 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
void
|
|
|
|
nsDisplayXULDebug::Paint(nsDisplayListBuilder* aBuilder,
|
2011-04-08 05:04:40 +04:00
|
|
|
nsRenderingContext* aCtx)
|
2006-01-26 05:29:17 +03:00
|
|
|
{
|
2007-07-08 11:08:04 +04:00
|
|
|
static_cast<nsBoxFrame*>(mFrame)->
|
2010-08-13 14:01:58 +04:00
|
|
|
PaintXULDebugOverlay(*aCtx, ToReferenceFrame());
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
2000-09-01 04:59:09 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
static void
|
2011-04-08 05:04:40 +04:00
|
|
|
PaintXULDebugBackground(nsIFrame* aFrame, nsRenderingContext* aCtx,
|
2006-01-26 05:29:17 +03:00
|
|
|
const nsRect& aDirtyRect, nsPoint aPt)
|
|
|
|
{
|
2007-07-08 11:08:04 +04:00
|
|
|
static_cast<nsBoxFrame*>(aFrame)->PaintXULDebugBackground(*aCtx, aPt);
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
void
|
2006-01-26 05:29:17 +03:00
|
|
|
nsBoxFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
2010-08-28 03:15:08 +04:00
|
|
|
// forcelayer is only supported on XUL elements with box layout
|
2011-09-29 10:19:26 +04:00
|
|
|
bool forceLayer =
|
2010-08-28 03:15:08 +04:00
|
|
|
GetContent()->HasAttr(kNameSpaceID_None, nsGkAtoms::layer) &&
|
|
|
|
GetContent()->IsXUL();
|
|
|
|
|
2011-05-13 20:40:46 +04:00
|
|
|
// Check for frames that are marked as a part of the region used
|
|
|
|
// in calculating glass margins on Windows.
|
|
|
|
if (GetContent()->IsXUL()) {
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleDisplay* styles = StyleDisplay();
|
2011-05-13 20:40:46 +04:00
|
|
|
if (styles && styles->mAppearance == NS_THEME_WIN_EXCLUDE_GLASS) {
|
2012-04-18 09:14:14 +04:00
|
|
|
nsRect rect = nsRect(aBuilder->ToReferenceFrame(this), GetSize());
|
2011-05-13 20:40:46 +04:00
|
|
|
aBuilder->AddExcludedGlassRegion(rect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-28 03:15:08 +04:00
|
|
|
nsDisplayListCollection tempLists;
|
|
|
|
const nsDisplayListSet& destination = forceLayer ? tempLists : aLists;
|
|
|
|
|
2013-02-14 15:08:08 +04:00
|
|
|
DisplayBorderBackgroundOutline(aBuilder, destination);
|
2006-01-26 05:29:17 +03:00
|
|
|
|
|
|
|
#ifdef DEBUG_LAYOUT
|
|
|
|
if (mState & NS_STATE_CURRENTLY_IN_DEBUG) {
|
2013-02-14 15:08:08 +04:00
|
|
|
destination.BorderBackground()->AppendNewToTop(new (aBuilder)
|
|
|
|
nsDisplayGeneric(aBuilder, this, PaintXULDebugBackground,
|
|
|
|
"XULDebugBackground"));
|
|
|
|
destination.Outlines()->AppendNewToTop(new (aBuilder)
|
|
|
|
nsDisplayXULDebug(aBuilder, this));
|
2001-04-25 23:52:49 +04:00
|
|
|
}
|
2006-01-26 05:29:17 +03:00
|
|
|
#endif
|
2001-04-25 23:52:49 +04:00
|
|
|
|
2013-02-14 15:08:08 +04:00
|
|
|
BuildDisplayListForChildren(aBuilder, aDirtyRect, destination);
|
2000-09-01 04:59:09 +04:00
|
|
|
|
|
|
|
// see if we have to draw a selection frame around this container
|
2013-02-14 15:08:08 +04:00
|
|
|
DisplaySelectionOverlay(aBuilder, destination.Content());
|
2010-08-28 03:15:08 +04: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());
|
|
|
|
// Wrap the list to make it its own layer
|
2013-02-14 15:08:08 +04:00
|
|
|
aLists.Content()->AppendNewToTop(new (aBuilder)
|
|
|
|
nsDisplayOwnLayer(aBuilder, this, &masterList));
|
2010-08-28 03:15:08 +04:00
|
|
|
}
|
2000-09-01 04:59:09 +04:00
|
|
|
}
|
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
void
|
2006-01-26 05:29:17 +03: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 15:08:08 +04:00
|
|
|
BuildDisplayListForChild(aBuilder, kid, aDirtyRect, set);
|
2006-01-26 05:29:17 +03:00
|
|
|
kid = kid->GetNextSibling();
|
2000-09-01 04:59:09 +04:00
|
|
|
}
|
1999-09-10 04:57:01 +04:00
|
|
|
}
|
|
|
|
|
2006-01-26 05:29:17 +03: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 07:18:34 +03:00
|
|
|
void
|
2011-04-08 05:04:40 +04:00
|
|
|
nsBoxFrame::PaintXULDebugBackground(nsRenderingContext& aRenderingContext,
|
2006-01-26 05:29:17 +03:00
|
|
|
nsPoint aPt)
|
2000-02-25 07:18:34 +03:00
|
|
|
{
|
2000-03-31 11:02:06 +04:00
|
|
|
nsMargin border;
|
2000-04-25 11:10:48 +04:00
|
|
|
GetBorder(border);
|
|
|
|
|
2004-06-19 13:07:47 +04:00
|
|
|
nsMargin debugBorder;
|
|
|
|
nsMargin debugMargin;
|
|
|
|
nsMargin debugPadding;
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isHorizontal = IsHorizontal();
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
GetDebugBorder(debugBorder);
|
|
|
|
PixelMarginToTwips(GetPresContext(), debugBorder);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
GetDebugMargin(debugMargin);
|
|
|
|
PixelMarginToTwips(GetPresContext(), debugMargin);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
GetDebugPadding(debugPadding);
|
|
|
|
PixelMarginToTwips(GetPresContext(), debugPadding);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2007-01-31 19:02:42 +03:00
|
|
|
nsRect inner(mRect);
|
|
|
|
inner.MoveTo(aPt);
|
2006-01-26 05:29:17 +03:00
|
|
|
inner.Deflate(debugMargin);
|
|
|
|
inner.Deflate(border);
|
|
|
|
//nsRect borderRect(inner);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
nscolor color;
|
|
|
|
if (isHorizontal) {
|
|
|
|
color = NS_RGB(0,0,255);
|
|
|
|
} else {
|
|
|
|
color = NS_RGB(255,0,0);
|
|
|
|
}
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
aRenderingContext.SetColor(color);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
//left
|
|
|
|
nsRect r(inner);
|
|
|
|
r.width = debugBorder.left;
|
|
|
|
aRenderingContext.FillRect(r);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
// top
|
|
|
|
r = inner;
|
|
|
|
r.height = debugBorder.top;
|
|
|
|
aRenderingContext.FillRect(r);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
//right
|
|
|
|
r = inner;
|
|
|
|
r.x = r.x + r.width - debugBorder.right;
|
|
|
|
r.width = debugBorder.right;
|
|
|
|
aRenderingContext.FillRect(r);
|
2000-05-15 08:12:31 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
//bottom
|
|
|
|
r = inner;
|
|
|
|
r.y = r.y + r.height - debugBorder.bottom;
|
|
|
|
r.height = debugBorder.bottom;
|
|
|
|
aRenderingContext.FillRect(r);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
|
|
|
|
// if we have dirty children or we are dirty
|
|
|
|
// place a green border around us.
|
2007-05-06 23:16:51 +04:00
|
|
|
if (NS_SUBTREE_DIRTY(this)) {
|
2006-01-26 05:29:17 +03:00
|
|
|
nsRect dirtyr(inner);
|
|
|
|
aRenderingContext.SetColor(NS_RGB(0,255,0));
|
|
|
|
aRenderingContext.DrawRect(dirtyr);
|
|
|
|
aRenderingContext.SetColor(color);
|
2000-02-25 07:18:34 +03:00
|
|
|
}
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
2000-02-25 07:18:34 +03:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
void
|
2011-04-08 05:04:40 +04:00
|
|
|
nsBoxFrame::PaintXULDebugOverlay(nsRenderingContext& aRenderingContext,
|
2006-01-26 05:29:17 +03:00
|
|
|
nsPoint aPt)
|
|
|
|
nsMargin border;
|
|
|
|
GetBorder(border);
|
2000-02-25 07:18:34 +03:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
nsMargin debugMargin;
|
|
|
|
GetDebugMargin(debugMargin);
|
|
|
|
PixelMarginToTwips(GetPresContext(), debugMargin);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2007-01-31 19:02:42 +03:00
|
|
|
nsRect inner(mRect);
|
|
|
|
inner.MoveTo(aPt);
|
2006-01-26 05:29:17 +03:00
|
|
|
inner.Deflate(debugMargin);
|
|
|
|
inner.Deflate(border);
|
2000-02-25 07:18:34 +03:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
nscoord onePixel = GetPresContext()->IntScaledPixelsToTwips(1);
|
1999-09-15 02:17:19 +04:00
|
|
|
|
2007-02-22 21:05:14 +03:00
|
|
|
kid = GetChildBox();
|
2012-07-30 18:20:58 +04:00
|
|
|
while (nullptr != kid) {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isHorizontal = IsHorizontal();
|
1999-08-27 10:06:39 +04:00
|
|
|
|
2006-01-26 05:29:17 +03: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 11:02:06 +04:00
|
|
|
}
|
1999-09-10 04:57:01 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
nsBoxLayoutState state(GetPresContext());
|
2007-01-31 19:02:42 +03:00
|
|
|
nscoord flex = kid->GetFlex(state);
|
1999-08-27 10:06:39 +04:00
|
|
|
|
2011-06-16 01:03:49 +04:00
|
|
|
if (!kid->IsCollapsed()) {
|
2006-01-26 05:29:17 +03:00
|
|
|
aRenderingContext.SetColor(NS_RGB(255,255,255));
|
1999-08-27 10:06:39 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
if (isHorizontal)
|
|
|
|
borderSize = cr.width;
|
|
|
|
else
|
|
|
|
borderSize = cr.height;
|
|
|
|
|
|
|
|
DrawSpacer(GetPresContext(), aRenderingContext, isHorizontal, flex, x, y, borderSize, spacerSize);
|
2000-03-02 06:01:30 +03:00
|
|
|
}
|
|
|
|
|
2007-02-22 21:05:14 +03:00
|
|
|
kid = kid->GetNextBox();
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
1999-07-23 04:11:21 +04:00
|
|
|
}
|
2006-01-26 05:29:17 +03:00
|
|
|
#endif
|
1999-07-23 04:11:21 +04:00
|
|
|
|
2002-09-10 01:32:33 +04:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2000-05-15 08:12:31 +04:00
|
|
|
void
|
|
|
|
nsBoxFrame::GetBoxName(nsAutoString& aName)
|
|
|
|
{
|
|
|
|
GetFrameName(aName);
|
|
|
|
}
|
2002-09-10 01:32:33 +04:00
|
|
|
#endif
|
2000-05-15 08:12:31 +04:00
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2000-03-31 11:02:06 +04:00
|
|
|
NS_IMETHODIMP
|
2001-11-14 04:33:42 +03:00
|
|
|
nsBoxFrame::GetFrameName(nsAString& aResult) const
|
2000-03-31 11:02:06 +04:00
|
|
|
{
|
2001-11-14 04:33:42 +03:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("Box"), aResult);
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
2001-09-15 04:45:54 +04:00
|
|
|
#endif
|
1999-12-02 04:07:27 +03:00
|
|
|
|
2003-10-31 23:19:18 +03:00
|
|
|
nsIAtom*
|
|
|
|
nsBoxFrame::GetType() const
|
2001-12-07 17:51:12 +03:00
|
|
|
{
|
2006-12-26 20:47:52 +03:00
|
|
|
return nsGkAtoms::boxFrame;
|
2001-12-07 17:51:12 +03:00
|
|
|
}
|
|
|
|
|
2004-06-19 13:07:47 +04:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2000-03-31 11:02:06 +04:00
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsBoxFrame::GetDebug(bool& aDebug)
|
2000-03-31 11:02:06 +04:00
|
|
|
{
|
|
|
|
aDebug = (mState & NS_STATE_CURRENTLY_IN_DEBUG);
|
|
|
|
return NS_OK;
|
1999-11-19 00:05:43 +03:00
|
|
|
}
|
2004-06-19 13:07:47 +04:00
|
|
|
#endif
|
1999-09-10 04:57:01 +04:00
|
|
|
|
2006-01-26 05:29:17 +03: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 06:59:26 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
// REVIEW: GetCursor had debug-only event dumping code. I have replaced it
|
|
|
|
// with instrumentation in nsDisplayXULDebug.
|
1999-10-12 04:16:06 +04:00
|
|
|
|
2006-02-13 18:49:56 +03:00
|
|
|
#ifdef DEBUG_LAYOUT
|
1999-11-19 00:05:43 +03:00
|
|
|
void
|
2011-09-29 10:19:26 +04:00
|
|
|
nsBoxFrame::DrawLine(nsRenderingContext& aRenderingContext, bool aHorizontal, nscoord x1, nscoord y1, nscoord x2, nscoord y2)
|
1999-11-19 00:05:43 +03:00
|
|
|
{
|
2000-03-31 11:02:06 +04:00
|
|
|
if (aHorizontal)
|
|
|
|
aRenderingContext.DrawLine(x1,y1,x2,y2);
|
|
|
|
else
|
|
|
|
aRenderingContext.DrawLine(y1,x1,y2,x2);
|
1999-11-19 00:05:43 +03:00
|
|
|
}
|
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
void
|
2011-09-29 10:19:26 +04:00
|
|
|
nsBoxFrame::FillRect(nsRenderingContext& aRenderingContext, bool aHorizontal, nscoord x, nscoord y, nscoord width, nscoord height)
|
1999-11-19 00:05:43 +03:00
|
|
|
{
|
2000-03-31 11:02:06 +04:00
|
|
|
if (aHorizontal)
|
|
|
|
aRenderingContext.FillRect(x,y,width,height);
|
|
|
|
else
|
|
|
|
aRenderingContext.FillRect(y,x,height,width);
|
1999-11-19 00:05:43 +03:00
|
|
|
}
|
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsBoxFrame::DrawSpacer(nsPresContext* aPresContext, nsRenderingContext& aRenderingContext, bool aHorizontal, int32_t flex, nscoord x, nscoord y, nscoord size, nscoord spacerSize)
|
2000-03-31 11:02:06 +04:00
|
|
|
{
|
2004-07-29 23:41:39 +04:00
|
|
|
nscoord onePixel = aPresContext->IntScaledPixelsToTwips(1);
|
1999-12-02 04:07:27 +03:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
// if we do draw the coils
|
|
|
|
int distance = 0;
|
|
|
|
int center = 0;
|
|
|
|
int offset = 0;
|
|
|
|
int coilSize = COIL_SIZE*onePixel;
|
2001-09-19 01:47:32 +04:00
|
|
|
int halfSpacer = spacerSize/2;
|
1999-12-02 04:07:27 +03:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
distance = size;
|
2001-09-19 01:47:32 +04:00
|
|
|
center = y + halfSpacer;
|
2000-03-31 11:02:06 +04:00
|
|
|
offset = x;
|
1999-12-02 04:07:27 +03:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
int coils = distance/coilSize;
|
1999-12-02 04:07:27 +03:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
int halfCoilSize = coilSize/2;
|
1999-12-02 04:07:27 +03:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
if (flex == 0) {
|
2001-09-19 01:47:32 +04:00
|
|
|
DrawLine(aRenderingContext, aHorizontal, x,y + spacerSize/2, x + size, y + spacerSize/2);
|
2000-03-31 11:02:06 +04:00
|
|
|
} else {
|
|
|
|
for (int i=0; i < coils; i++)
|
|
|
|
{
|
2001-09-19 01:47:32 +04:00
|
|
|
DrawLine(aRenderingContext, aHorizontal, offset, center+halfSpacer, offset+halfCoilSize, center-halfSpacer);
|
|
|
|
DrawLine(aRenderingContext, aHorizontal, offset+halfCoilSize, center-halfSpacer, offset+coilSize, center+halfSpacer);
|
1999-12-02 04:07:27 +03:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
offset += coilSize;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-09-19 01:47:32 +04:00
|
|
|
FillRect(aRenderingContext, aHorizontal, x + size - spacerSize/2, y, spacerSize/2, spacerSize);
|
|
|
|
FillRect(aRenderingContext, aHorizontal, x, y, spacerSize/2, spacerSize);
|
1999-12-02 04:07:27 +03:00
|
|
|
|
2001-09-19 01:47:32 +04:00
|
|
|
//DrawKnob(aPresContext, aRenderingContext, x + size - spacerSize, y, spacerSize);
|
1999-12-02 04:07:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-10-10 10:39:30 +04:00
|
|
|
nsBoxFrame::GetDebugBorder(nsMargin& aInset)
|
1999-12-02 04:07:27 +03:00
|
|
|
{
|
2000-03-31 11:02:06 +04:00
|
|
|
aInset.SizeTo(2,2,2,2);
|
|
|
|
|
2002-10-10 10:39:30 +04:00
|
|
|
if (IsHorizontal())
|
2000-03-31 11:02:06 +04:00
|
|
|
aInset.top = 10;
|
|
|
|
else
|
|
|
|
aInset.left = 10;
|
1999-12-02 04:07:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-10-10 10:39:30 +04:00
|
|
|
nsBoxFrame::GetDebugMargin(nsMargin& aInset)
|
1999-12-02 04:07:27 +03:00
|
|
|
{
|
2000-03-31 11:02:06 +04:00
|
|
|
aInset.SizeTo(2,2,2,2);
|
1999-11-19 00:05:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-10-10 10:39:30 +04:00
|
|
|
nsBoxFrame::GetDebugPadding(nsMargin& aPadding)
|
1999-11-19 00:05:43 +03:00
|
|
|
{
|
2000-03-31 11:02:06 +04:00
|
|
|
aPadding.SizeTo(2,2,2,2);
|
1999-11-19 00:05:43 +03:00
|
|
|
}
|
2000-03-31 11:02:06 +04:00
|
|
|
|
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsBoxFrame::PixelMarginToTwips(nsPresContext* aPresContext, nsMargin& aMarginPixels)
|
1999-11-19 00:05:43 +03:00
|
|
|
{
|
2007-02-07 10:46:44 +03:00
|
|
|
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
|
2000-03-31 11:02:06 +04:00
|
|
|
aMarginPixels.left *= onePixel;
|
|
|
|
aMarginPixels.right *= onePixel;
|
|
|
|
aMarginPixels.top *= onePixel;
|
|
|
|
aMarginPixels.bottom *= onePixel;
|
1999-11-19 00:05:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsBoxFrame::GetValue(nsPresContext* aPresContext, const nsSize& a, const nsSize& b, char* ch)
|
1999-11-19 00:05:43 +03:00
|
|
|
{
|
2004-07-29 23:41:39 +04:00
|
|
|
float p2t = aPresContext->ScaledPixelsToTwips();
|
2000-03-31 11:02:06 +04:00
|
|
|
|
|
|
|
char width[100];
|
|
|
|
char height[100];
|
|
|
|
|
|
|
|
if (a.width == NS_INTRINSICSIZE)
|
|
|
|
sprintf(width,"%s","INF");
|
2006-01-26 05:29:17 +03:00
|
|
|
else
|
2000-03-31 11:02:06 +04:00
|
|
|
sprintf(width,"%d", nscoord(a.width/*/p2t*/));
|
|
|
|
|
|
|
|
if (a.height == NS_INTRINSICSIZE)
|
|
|
|
sprintf(height,"%s","INF");
|
1999-12-02 04:07:27 +03:00
|
|
|
else
|
2000-03-31 11:02:06 +04:00
|
|
|
sprintf(height,"%d", nscoord(a.height/*/p2t*/));
|
1999-12-02 04:07:27 +03:00
|
|
|
|
1999-11-19 00:05:43 +03:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
sprintf(ch, "(%s%s, %s%s)", width, (b.width != NS_INTRINSICSIZE ? "[SET]" : ""),
|
|
|
|
height, (b.height != NS_INTRINSICSIZE ? "[SET]" : ""));
|
1999-12-02 04:07:27 +03:00
|
|
|
|
1999-11-19 00:05:43 +03:00
|
|
|
}
|
|
|
|
|
1999-12-02 04:07:27 +03:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsBoxFrame::GetValue(nsPresContext* aPresContext, int32_t a, int32_t b, char* ch)
|
1999-12-02 04:07:27 +03:00
|
|
|
{
|
2000-03-31 11:02:06 +04:00
|
|
|
if (a == NS_INTRINSICSIZE)
|
|
|
|
sprintf(ch, "%d[SET]", b);
|
|
|
|
else
|
|
|
|
sprintf(ch, "%d", a);
|
1999-12-02 04:07:27 +03:00
|
|
|
}
|
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
nsresult
|
2012-08-06 07:00:57 +04:00
|
|
|
nsBoxFrame::DisplayDebugInfoFor(nsIFrame* aBox,
|
2006-01-26 05:29:17 +03:00
|
|
|
nsPoint& aPoint)
|
2000-03-31 11:02:06 +04:00
|
|
|
{
|
2006-01-26 05:29:17 +03:00
|
|
|
nsBoxLayoutState state(GetPresContext());
|
2000-03-31 11:02:06 +04:00
|
|
|
|
|
|
|
nscoord x = aPoint.x;
|
|
|
|
nscoord y = aPoint.y;
|
1999-12-02 04:07:27 +03:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
// get the area inside our border but not our debug margins.
|
2007-01-31 19:02:42 +03:00
|
|
|
nsRect insideBorder(aBox->mRect);
|
|
|
|
insideBorder.MoveTo(0,0):
|
2000-03-31 11:02:06 +04:00
|
|
|
nsMargin border(0,0,0,0);
|
|
|
|
aBox->GetBorderAndPadding(border);
|
|
|
|
insideBorder.Deflate(border);
|
1999-12-02 04:07:27 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isHorizontal = IsHorizontal();
|
1999-12-02 04:07:27 +03:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
if (!insideBorder.Contains(nsPoint(x,y)))
|
|
|
|
return NS_ERROR_FAILURE;
|
1999-12-02 04:07:27 +03:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
//printf("%%%%%% inside box %%%%%%%\n");
|
2000-02-14 04:42:09 +03:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
int count = 0;
|
2012-08-06 07:00:57 +04:00
|
|
|
nsIFrame* child = aBox->GetChildBox();
|
1999-12-02 04:07:27 +03:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
nsMargin m;
|
|
|
|
nsMargin m2;
|
|
|
|
GetDebugBorder(m);
|
|
|
|
PixelMarginToTwips(aPresContext, m);
|
1999-12-02 04:07:27 +03:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
GetDebugMargin(m2);
|
|
|
|
PixelMarginToTwips(aPresContext, m2);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
m += m2;
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2006-01-26 05:29:17 +03: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 10:19:26 +04:00
|
|
|
bool widthSet, heightSet;
|
2012-08-06 07:00:57 +04: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 05:29:17 +03:00
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
nsSize prefSize = child->GetPrefSize(state);
|
|
|
|
nsSize minSize = child->GetMinSize(state);
|
|
|
|
nsSize maxSize = child->GetMaxSize(state);
|
2007-01-31 19:02:42 +03:00
|
|
|
nscoord flexSize = child->GetFlex(state);
|
|
|
|
nscoord ascentSize = child->GetBoxAscent(state);
|
2006-01-26 05:29:17 +03: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 11:02:06 +04:00
|
|
|
}
|
2006-01-26 05:29:17 +03:00
|
|
|
|
2007-02-22 21:05:14 +03:00
|
|
|
child = child->GetNextBox();
|
2006-01-26 05:29:17 +03:00
|
|
|
count++;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
2006-01-26 05:29:17 +03:00
|
|
|
} else {
|
|
|
|
}
|
1999-09-10 04:57:01 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
mDebugChild = nullptr;
|
2000-03-02 06:01:30 +03:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
return NS_OK;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
2004-09-28 22:37:50 +04:00
|
|
|
|
|
|
|
void
|
2012-08-06 07:00:57 +04:00
|
|
|
nsBoxFrame::SetDebugOnChildList(nsBoxLayoutState& aState, nsIFrame* aChild, bool aDebug)
|
2004-09-28 22:37:50 +04:00
|
|
|
{
|
2012-08-06 07:00:57 +04:00
|
|
|
nsIFrame* child = GetChildBox();
|
2004-09-28 22:37:50 +04:00
|
|
|
while (child)
|
|
|
|
{
|
|
|
|
child->SetDebug(aState, aDebug);
|
2007-02-22 21:05:14 +03:00
|
|
|
child = child->GetNextBox();
|
2004-09-28 22:37:50 +04:00
|
|
|
}
|
|
|
|
}
|
2000-03-02 06:01:30 +03:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
nsresult
|
2012-08-06 07:00:57 +04:00
|
|
|
nsBoxFrame::GetFrameSizeWithMargin(nsIFrame* aBox, nsSize& aSize)
|
2000-03-31 11:02:06 +04:00
|
|
|
{
|
2004-09-28 22:37:50 +04:00
|
|
|
nsRect rect(aBox->GetRect());
|
2000-03-31 11:02:06 +04: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 11:17:25 +04:00
|
|
|
}
|
2007-05-23 07:48:43 +04:00
|
|
|
#endif
|
2000-06-29 02:19:54 +04:00
|
|
|
|
2002-02-21 16:39:39 +03:00
|
|
|
// If you make changes to this function, check its counterparts
|
2008-12-29 18:07:38 +03:00
|
|
|
// in nsTextBoxFrame and nsXULLabelFrame
|
2013-03-20 05:47:48 +04:00
|
|
|
void
|
2011-09-29 10:19:26 +04:00
|
|
|
nsBoxFrame::RegUnregAccessKey(bool aDoReg)
|
2002-02-21 16:39:39 +03:00
|
|
|
{
|
2013-03-20 05:47:48 +04:00
|
|
|
MOZ_ASSERT(mContent);
|
2002-02-21 16:39:39 +03:00
|
|
|
|
|
|
|
// find out what type of element this is
|
2003-11-19 04:20:56 +03:00
|
|
|
nsIAtom *atom = mContent->Tag();
|
2002-02-21 16:39:39 +03:00
|
|
|
|
|
|
|
// only support accesskeys for the following elements
|
2006-12-26 20:47:52 +03:00
|
|
|
if (atom != nsGkAtoms::button &&
|
|
|
|
atom != nsGkAtoms::toolbarbutton &&
|
|
|
|
atom != nsGkAtoms::checkbox &&
|
|
|
|
atom != nsGkAtoms::textbox &&
|
|
|
|
atom != nsGkAtoms::tab &&
|
|
|
|
atom != nsGkAtoms::radio) {
|
2013-03-20 05:47:48 +04:00
|
|
|
return;
|
2002-02-21 16:39:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoString accessKey;
|
2006-12-26 20:47:52 +03:00
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::accesskey, accessKey);
|
2002-02-21 16:39:39 +03:00
|
|
|
|
|
|
|
if (accessKey.IsEmpty())
|
2013-03-20 05:47:48 +04:00
|
|
|
return;
|
2002-02-21 16:39:39 +03:00
|
|
|
|
|
|
|
// With a valid PresContext we can get the ESM
|
|
|
|
// and register the access key
|
2011-04-21 21:35:52 +04:00
|
|
|
nsEventStateManager *esm = PresContext()->EventStateManager();
|
2002-02-21 16:39:39 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t key = accessKey.First();
|
2004-02-27 20:17:37 +03:00
|
|
|
if (aDoReg)
|
2011-04-21 21:35:52 +04:00
|
|
|
esm->RegisterAccessKey(mContent, key);
|
2004-02-27 20:17:37 +03:00
|
|
|
else
|
2011-04-21 21:35:52 +04:00
|
|
|
esm->UnregisterAccessKey(mContent, key);
|
2002-02-21 16:39:39 +03:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2009-01-09 03:11:30 +03:00
|
|
|
nsBoxFrame::SupportsOrdinalsInChildren()
|
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2009-01-09 03:11:30 +03:00
|
|
|
}
|
|
|
|
|
2012-12-01 03:25:33 +04: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 09:14:03 +04: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-12-01 03:25:33 +04:00
|
|
|
}
|
|
|
|
|
2008-12-07 21:11:30 +03:00
|
|
|
void
|
2012-12-01 03:25:32 +04:00
|
|
|
nsBoxFrame::CheckBoxOrder()
|
2008-12-07 21:11:30 +03:00
|
|
|
{
|
2012-12-01 03:25:33 +04:00
|
|
|
if (SupportsOrdinalsInChildren() &&
|
2013-10-01 01:26:04 +04:00
|
|
|
!nsIFrame::IsFrameListSorted<IsBoxOrdinalLEQ>(mFrames)) {
|
|
|
|
nsIFrame::SortFrameList<IsBoxOrdinalLEQ>(mFrames);
|
2012-12-01 03:25:33 +04:00
|
|
|
}
|
|
|
|
}
|
2008-12-07 21:11:30 +03:00
|
|
|
|
2004-09-28 22:37:50 +04:00
|
|
|
nsresult
|
2012-08-06 07:00:57 +04:00
|
|
|
nsBoxFrame::LayoutChildAt(nsBoxLayoutState& aState, nsIFrame* aBox, const nsRect& aRect)
|
2004-09-28 22:37:50 +04:00
|
|
|
{
|
|
|
|
// get the current rect
|
|
|
|
nsRect oldRect(aBox->GetRect());
|
|
|
|
aBox->SetBounds(aState, aRect);
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool layout = NS_SUBTREE_DIRTY(aBox);
|
2004-09-28 22:37:50 +04:00
|
|
|
|
|
|
|
if (layout || (oldRect.width != aRect.width || oldRect.height != aRect.height)) {
|
|
|
|
return aBox->Layout(aState);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-06 07:00:57 +04:00
|
|
|
nsBoxFrame::RelayoutChildAtOrdinal(nsBoxLayoutState& aState, nsIFrame* aChild)
|
2004-09-28 22:37:50 +04:00
|
|
|
{
|
2009-01-09 03:11:30 +03:00
|
|
|
if (!SupportsOrdinalsInChildren())
|
|
|
|
return NS_OK;
|
|
|
|
|
2012-12-01 03:25:32 +04:00
|
|
|
uint32_t ord = aChild->GetOrdinal();
|
2004-09-28 22:37:50 +04:00
|
|
|
|
2009-10-02 20:27:37 +04:00
|
|
|
nsIFrame* child = mFrames.FirstChild();
|
2012-07-30 18:20:58 +04:00
|
|
|
nsIFrame* newPrevSib = nullptr;
|
2004-09-30 04:18:49 +04:00
|
|
|
|
|
|
|
while (child) {
|
2012-12-01 03:25:32 +04:00
|
|
|
if (ord < child->GetOrdinal()) {
|
2009-10-02 20:27:37 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (child != aChild) {
|
2004-09-30 04:18:49 +04:00
|
|
|
newPrevSib = child;
|
2009-10-02 20:27:37 +04:00
|
|
|
}
|
2004-09-30 04:18:49 +04:00
|
|
|
|
2007-02-22 21:05:14 +03:00
|
|
|
child = child->GetNextBox();
|
2004-09-28 22:37:50 +04:00
|
|
|
}
|
2004-09-30 04:18:49 +04:00
|
|
|
|
2009-10-02 20:27:37 +04:00
|
|
|
if (aChild->GetPrevSibling() == newPrevSib) {
|
2004-09-30 04:18:49 +04:00
|
|
|
// This box is not moving.
|
|
|
|
return NS_OK;
|
2004-09-28 22:37:50 +04:00
|
|
|
}
|
2004-09-30 04:18:49 +04:00
|
|
|
|
2009-09-18 15:09:35 +04:00
|
|
|
// Take |aChild| out of its old position in the child list.
|
2009-10-02 20:27:37 +04:00
|
|
|
mFrames.RemoveFrame(aChild);
|
2004-09-28 22:37:50 +04:00
|
|
|
|
2009-09-18 15:09:35 +04:00
|
|
|
// Insert it after |newPrevSib| or at the start if it's null.
|
2012-07-30 18:20:58 +04:00
|
|
|
mFrames.InsertFrame(nullptr, newPrevSib, aChild);
|
2004-09-28 22:37:50 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2006-01-26 05:29:17 +03: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 18:20:58 +04:00
|
|
|
* Note that turning a hit on a descendant element into nullptr, so events
|
2006-01-26 05:29:17 +03: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 14:01:13 +04:00
|
|
|
nsDisplayXULEventRedirector(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsIFrame* aFrame, nsDisplayItem* aItem,
|
2006-01-26 05:29:17 +03:00
|
|
|
nsIFrame* aTargetFrame)
|
2010-08-13 14:01:13 +04:00
|
|
|
: nsDisplayWrapList(aBuilder, aFrame, aItem), mTargetFrame(aTargetFrame) {}
|
|
|
|
nsDisplayXULEventRedirector(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsIFrame* aFrame, nsDisplayList* aList,
|
2006-01-26 05:29:17 +03:00
|
|
|
nsIFrame* aTargetFrame)
|
2010-08-13 14:01:13 +04:00
|
|
|
: nsDisplayWrapList(aBuilder, aFrame, aList), mTargetFrame(aTargetFrame) {}
|
2010-04-08 04:31:26 +04:00
|
|
|
virtual void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
|
|
|
|
HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames);
|
2010-07-16 01:07:49 +04:00
|
|
|
NS_DISPLAY_DECL_NAME("XULEventRedirector", TYPE_XUL_EVENT_REDIRECTOR)
|
2006-01-26 05:29:17 +03:00
|
|
|
private:
|
|
|
|
nsIFrame* mTargetFrame;
|
|
|
|
};
|
|
|
|
|
2010-04-08 04:31:26 +04:00
|
|
|
void nsDisplayXULEventRedirector::HitTest(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aRect, HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames)
|
2006-01-26 05:29:17 +03:00
|
|
|
{
|
2010-04-08 04:31:26 +04:00
|
|
|
nsTArray<nsIFrame*> outFrames;
|
|
|
|
mList.HitTest(aBuilder, aRect, aState, &outFrames);
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool topMostAdded = false;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t localLength = outFrames.Length();
|
2010-04-08 04:31:26 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < localLength; i++) {
|
2006-01-26 05:29:17 +03:00
|
|
|
|
2010-04-08 04:31:26 +04: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 18:59:28 +04:00
|
|
|
topMostAdded = true;
|
2010-04-08 04:31:26 +04:00
|
|
|
}
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
2010-04-08 04:31:26 +04:00
|
|
|
|
2010-05-01 20:39:00 +04: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 18:59:28 +04:00
|
|
|
topMostAdded = true;
|
2010-05-01 20:39:00 +04:00
|
|
|
aOutFrames->AppendElement(mTargetFrame);
|
|
|
|
}
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class nsXULEventRedirectorWrapper : public nsDisplayWrapper
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsXULEventRedirectorWrapper(nsIFrame* aTargetFrame)
|
|
|
|
: mTargetFrame(aTargetFrame) {}
|
|
|
|
virtual nsDisplayItem* WrapList(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsIFrame* aFrame, nsDisplayList* aList) {
|
|
|
|
return new (aBuilder)
|
2010-08-13 14:01:13 +04:00
|
|
|
nsDisplayXULEventRedirector(aBuilder, aFrame, aList, mTargetFrame);
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
|
|
|
virtual nsDisplayItem* WrapItem(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsDisplayItem* aItem) {
|
|
|
|
return new (aBuilder)
|
2013-04-19 16:02:13 +04:00
|
|
|
nsDisplayXULEventRedirector(aBuilder, aItem->Frame(), aItem,
|
2006-01-26 05:29:17 +03:00
|
|
|
mTargetFrame);
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
nsIFrame* mTargetFrame;
|
|
|
|
};
|
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
void
|
2006-01-26 05:29:17 +03:00
|
|
|
nsBoxFrame::WrapListsInRedirector(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayListSet& aIn,
|
|
|
|
const nsDisplayListSet& aOut)
|
|
|
|
{
|
|
|
|
nsXULEventRedirectorWrapper wrapper(this);
|
2013-02-14 15:12:27 +04:00
|
|
|
wrapper.WrapLists(aBuilder, this, aIn, aOut);
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
2012-07-28 02:01:12 +04:00
|
|
|
|
|
|
|
bool
|
2013-10-02 07:46:03 +04:00
|
|
|
nsBoxFrame::GetEventPoint(WidgetGUIEvent* aEvent, nsPoint &aPoint) {
|
2012-07-28 02:01:12 +04:00
|
|
|
nsIntPoint refPoint;
|
|
|
|
bool res = GetEventPoint(aEvent, refPoint);
|
|
|
|
aPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, refPoint, this);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-10-02 07:46:03 +04:00
|
|
|
nsBoxFrame::GetEventPoint(WidgetGUIEvent* aEvent, nsIntPoint &aPoint) {
|
2012-07-28 02:01:12 +04:00
|
|
|
NS_ENSURE_TRUE(aEvent, false);
|
|
|
|
|
2013-10-18 10:10:23 +04:00
|
|
|
WidgetTouchEvent* touchEvent = aEvent->AsTouchEvent();
|
|
|
|
if (touchEvent) {
|
2012-07-28 02:01:12 +04: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 12:49:00 +04:00
|
|
|
|
2013-08-02 11:06:35 +04:00
|
|
|
dom::Touch* touch = touchEvent->touches.SafeElementAt(0);
|
2012-07-28 02:01:12 +04:00
|
|
|
if (!touch) {
|
|
|
|
return false;
|
|
|
|
}
|
2013-08-02 11:06:35 +04:00
|
|
|
aPoint = touch->mRefPoint;
|
2012-07-28 02:01:12 +04:00
|
|
|
} else {
|
2013-08-02 11:05:16 +04:00
|
|
|
aPoint = LayoutDeviceIntPoint::ToUntyped(aEvent->refPoint);
|
2012-07-28 02:01:12 +04:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|