2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2001-10-25 01:08:40 +00:00
|
|
|
// vim:cindent:ts=2:et:sw=2:
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2006-03-29 18:29:03 +00:00
|
|
|
|
|
|
|
/* base class of all rendering objects */
|
|
|
|
|
2011-12-16 19:42:07 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2011-10-11 05:50:08 +00:00
|
|
|
#include "mozilla/Util.h"
|
|
|
|
|
1999-02-12 17:45:58 +00:00
|
|
|
#include "nsCOMPtr.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsFrame.h"
|
1999-02-01 17:31:10 +00:00
|
|
|
#include "nsFrameList.h"
|
2009-08-31 18:25:35 +00:00
|
|
|
#include "nsPlaceholderFrame.h"
|
1998-10-09 23:46:02 +00:00
|
|
|
#include "nsLineLayout.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsIContent.h"
|
2004-04-29 23:34:19 +00:00
|
|
|
#include "nsContentUtils.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsIAtom.h"
|
|
|
|
#include "nsString.h"
|
2003-11-01 10:57:41 +00:00
|
|
|
#include "nsReadableUtils.h"
|
2003-02-22 00:32:13 +00:00
|
|
|
#include "nsStyleContext.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsIView.h"
|
|
|
|
#include "nsIViewManager.h"
|
2004-09-01 14:58:34 +00:00
|
|
|
#include "nsIScrollableFrame.h"
|
2004-07-31 23:15:21 +00:00
|
|
|
#include "nsPresContext.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsCRT.h"
|
|
|
|
#include "nsGUIEvent.h"
|
2000-12-30 19:22:22 +00:00
|
|
|
#include "nsIDOMEvent.h"
|
2011-12-17 06:02:05 +00:00
|
|
|
#include "nsAsyncDOMEvent.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsStyleConsts.h"
|
1998-05-08 16:33:07 +00:00
|
|
|
#include "nsIPresShell.h"
|
1998-05-20 16:24:13 +00:00
|
|
|
#include "prlog.h"
|
|
|
|
#include "prprf.h"
|
|
|
|
#include <stdarg.h>
|
2004-02-23 21:29:06 +00:00
|
|
|
#include "nsFrameManager.h"
|
2002-12-23 22:05:47 +00:00
|
|
|
#include "nsCSSRendering.h"
|
2005-03-07 00:34:44 +00:00
|
|
|
#include "nsLayoutUtils.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2011-05-28 07:43:44 +00:00
|
|
|
#include "nsIDOMNode.h"
|
2004-09-28 18:40:50 +00:00
|
|
|
#include "nsIEditorDocShell.h"
|
2011-04-21 17:35:52 +00:00
|
|
|
#include "nsEventStateManager.h"
|
2000-09-14 11:45:01 +00:00
|
|
|
#include "nsISelection.h"
|
2000-12-20 22:13:54 +00:00
|
|
|
#include "nsISelectionPrivate.h"
|
2006-04-26 02:01:07 +00:00
|
|
|
#include "nsFrameSelection.h"
|
1999-01-15 01:29:15 +00:00
|
|
|
#include "nsHTMLParts.h"
|
2007-01-30 00:06:41 +00:00
|
|
|
#include "nsGkAtoms.h"
|
2003-06-15 00:55:00 +00:00
|
|
|
#include "nsCSSAnonBoxes.h"
|
|
|
|
#include "nsCSSPseudoElements.h"
|
2004-04-12 21:53:22 +00:00
|
|
|
#include "nsCSSFrameConstructor.h"
|
1998-05-08 18:33:42 +00:00
|
|
|
|
2012-10-15 18:35:50 +00:00
|
|
|
#include "nsFrameTraversal.h"
|
1999-03-25 06:43:38 +00:00
|
|
|
#include "nsStyleChangeList.h"
|
1999-09-20 21:47:37 +00:00
|
|
|
#include "nsIDOMRange.h"
|
2011-12-20 09:15:41 +00:00
|
|
|
#include "nsRange.h"
|
2009-01-11 08:46:35 +00:00
|
|
|
#include "nsITableLayout.h" //selection necessity
|
2000-03-16 23:45:39 +00:00
|
|
|
#include "nsITableCellLayout.h"// "
|
2002-07-26 20:57:24 +00:00
|
|
|
#include "nsITextControlFrame.h"
|
2000-10-04 13:38:17 +00:00
|
|
|
#include "nsINameSpaceManager.h"
|
2001-12-07 14:51:12 +00:00
|
|
|
#include "nsIPercentHeightObserver.h"
|
2008-12-23 14:06:56 +00:00
|
|
|
#include "nsStyleStructInlines.h"
|
2000-05-11 04:25:43 +00:00
|
|
|
|
2006-07-12 11:22:18 +00:00
|
|
|
#ifdef IBMBIDI
|
|
|
|
#include "nsBidiPresUtils.h"
|
|
|
|
#endif
|
|
|
|
|
2000-05-16 22:48:28 +00:00
|
|
|
// For triple-click pref
|
|
|
|
#include "nsIServiceManager.h"
|
2002-09-11 03:03:49 +00:00
|
|
|
#include "imgIContainer.h"
|
2004-12-30 21:56:11 +00:00
|
|
|
#include "imgIRequest.h"
|
2002-09-11 03:03:49 +00:00
|
|
|
#include "nsLayoutCID.h"
|
2004-06-02 02:25:18 +00:00
|
|
|
#include "nsUnicharUtils.h"
|
2012-07-27 14:03:27 +00:00
|
|
|
#include "nsError.h"
|
2011-12-27 20:18:48 +00:00
|
|
|
#include "nsContainerFrame.h"
|
2004-09-28 18:37:50 +00:00
|
|
|
#include "nsBoxLayoutState.h"
|
2005-08-18 17:09:16 +00:00
|
|
|
#include "nsBlockFrame.h"
|
2006-01-26 02:29:17 +00:00
|
|
|
#include "nsDisplayList.h"
|
2009-12-11 04:02:13 +00:00
|
|
|
#include "nsIObjectLoadingContent.h"
|
2010-07-15 21:08:06 +00:00
|
|
|
#include "nsExpirationTracker.h"
|
2008-09-11 00:24:16 +00:00
|
|
|
#include "nsSVGIntegrationUtils.h"
|
2008-10-01 00:51:05 +00:00
|
|
|
#include "nsSVGEffects.h"
|
2011-06-22 12:11:28 +00:00
|
|
|
#include "nsChangeHint.h"
|
2011-10-26 23:57:55 +00:00
|
|
|
#include "nsDeckFrame.h"
|
2012-04-16 22:32:12 +00:00
|
|
|
#include "nsTableFrame.h"
|
2012-08-29 05:39:01 +00:00
|
|
|
#include "nsSubDocumentFrame.h"
|
2008-09-11 00:24:16 +00:00
|
|
|
|
2006-03-16 21:42:50 +00:00
|
|
|
#include "gfxContext.h"
|
2012-03-20 12:15:55 +00:00
|
|
|
#include "nsRenderingContext.h"
|
2010-08-31 16:05:12 +00:00
|
|
|
#include "CSSCalc.h"
|
2011-04-27 23:41:43 +00:00
|
|
|
#include "nsAbsoluteContainingBlock.h"
|
2012-04-16 22:32:12 +00:00
|
|
|
#include "nsFontInflationData.h"
|
2012-07-31 17:28:21 +00:00
|
|
|
#include "nsAnimationManager.h"
|
2012-07-31 17:28:22 +00:00
|
|
|
#include "nsTransitionManager.h"
|
2006-03-16 21:42:50 +00:00
|
|
|
|
2011-05-25 06:31:59 +00:00
|
|
|
#include "mozilla/Preferences.h"
|
2011-09-09 02:27:13 +00:00
|
|
|
#include "mozilla/LookAndFeel.h"
|
2012-08-13 22:04:19 +00:00
|
|
|
#include "mozilla/css/ImageLoader.h"
|
2012-10-03 05:55:52 +00:00
|
|
|
#include "mozilla/gfx/Tools.h"
|
2011-05-25 06:31:59 +00:00
|
|
|
|
2010-03-29 01:46:55 +00:00
|
|
|
using namespace mozilla;
|
2011-03-27 23:59:47 +00:00
|
|
|
using namespace mozilla::layers;
|
2012-01-25 01:21:29 +00:00
|
|
|
using namespace mozilla::layout;
|
2012-08-13 22:04:19 +00:00
|
|
|
using namespace mozilla::css;
|
2010-03-29 01:46:55 +00:00
|
|
|
|
2004-09-28 18:37:50 +00:00
|
|
|
// Struct containing cached metrics for box-wrapped frames.
|
|
|
|
struct nsBoxLayoutMetrics
|
|
|
|
{
|
|
|
|
nsSize mPrefSize;
|
|
|
|
nsSize mMinSize;
|
|
|
|
nsSize mMaxSize;
|
|
|
|
|
|
|
|
nsSize mBlockMinSize;
|
|
|
|
nsSize mBlockPrefSize;
|
|
|
|
nscoord mBlockAscent;
|
|
|
|
|
|
|
|
nscoord mFlex;
|
|
|
|
nscoord mAscent;
|
|
|
|
|
|
|
|
nsSize mLastSize;
|
|
|
|
};
|
1999-02-10 18:55:25 +00:00
|
|
|
|
2005-09-18 12:41:40 +00:00
|
|
|
struct nsContentAndOffset
|
|
|
|
{
|
|
|
|
nsIContent* mContent;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t mOffset;
|
2005-09-18 12:41:40 +00:00
|
|
|
};
|
|
|
|
|
1998-07-18 18:18:20 +00:00
|
|
|
// Some Misc #defines
|
1998-07-22 22:01:46 +00:00
|
|
|
#define SELECTION_DEBUG 0
|
1998-07-18 18:18:20 +00:00
|
|
|
#define FORCE_SELECTION_UPDATE 1
|
|
|
|
#define CALC_DEBUG 0
|
|
|
|
|
1998-07-17 23:00:54 +00:00
|
|
|
|
1999-06-19 20:36:44 +00:00
|
|
|
#include "nsILineIterator.h"
|
2000-04-12 03:04:11 +00:00
|
|
|
|
1999-07-15 18:19:03 +00:00
|
|
|
//non Hack prototypes
|
1999-02-08 17:56:00 +00:00
|
|
|
#if 0
|
2004-07-31 23:15:21 +00:00
|
|
|
static void RefreshContentFrames(nsPresContext* aPresContext, nsIContent * aStartContent, nsIContent * aEndContent);
|
1999-02-08 17:56:00 +00:00
|
|
|
#endif
|
1998-05-08 18:33:42 +00:00
|
|
|
|
2001-10-29 01:43:59 +00:00
|
|
|
#include "prenv.h"
|
1998-05-08 18:33:42 +00:00
|
|
|
|
2009-08-20 21:52:48 +00:00
|
|
|
// Formerly the nsIFrameDebug interface
|
1998-05-20 16:24:13 +00:00
|
|
|
|
2012-06-25 19:59:42 +00:00
|
|
|
#ifdef DEBUG
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool gShowFrameBorders = false;
|
1998-05-08 18:33:42 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
void nsFrame::ShowFrameBorders(bool aEnable)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
gShowFrameBorders = aEnable;
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool nsFrame::GetShowFrameBorders()
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
return gShowFrameBorders;
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool gShowEventTargetFrameBorder = false;
|
2000-02-03 02:49:58 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
void nsFrame::ShowEventTargetFrameBorder(bool aEnable)
|
2000-02-03 02:49:58 +00:00
|
|
|
{
|
|
|
|
gShowEventTargetFrameBorder = aEnable;
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool nsFrame::GetShowEventTargetFrameBorder()
|
2000-02-03 02:49:58 +00:00
|
|
|
{
|
|
|
|
return gShowEventTargetFrameBorder;
|
|
|
|
}
|
|
|
|
|
1998-05-20 16:24:13 +00:00
|
|
|
/**
|
|
|
|
* Note: the log module is created during library initialization which
|
|
|
|
* means that you cannot perform logging before then.
|
|
|
|
*/
|
1999-02-26 17:05:20 +00:00
|
|
|
static PRLogModuleInfo* gLogModule;
|
1998-05-20 16:24:13 +00:00
|
|
|
|
1999-09-21 07:51:52 +00:00
|
|
|
static PRLogModuleInfo* gStyleVerifyTreeLogModuleInfo;
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
static uint32_t gStyleVerifyTreeEnable = 0x55;
|
1999-09-21 07:51:52 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2009-08-20 21:52:48 +00:00
|
|
|
nsFrame::GetVerifyStyleTreeEnable()
|
1999-09-21 07:51:52 +00:00
|
|
|
{
|
2011-08-02 01:20:52 +00:00
|
|
|
if (gStyleVerifyTreeEnable == 0x55) {
|
2012-07-30 14:20:58 +00:00
|
|
|
if (nullptr == gStyleVerifyTreeLogModuleInfo) {
|
1999-09-21 07:51:52 +00:00
|
|
|
gStyleVerifyTreeLogModuleInfo = PR_NewLogModule("styleverifytree");
|
|
|
|
gStyleVerifyTreeEnable = 0 != gStyleVerifyTreeLogModuleInfo->level;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return gStyleVerifyTreeEnable;
|
|
|
|
}
|
|
|
|
|
2001-10-23 01:37:21 +00:00
|
|
|
void
|
2011-09-29 06:19:26 +00:00
|
|
|
nsFrame::SetVerifyStyleTreeEnable(bool aEnabled)
|
1999-09-21 07:51:52 +00:00
|
|
|
{
|
|
|
|
gStyleVerifyTreeEnable = aEnabled;
|
|
|
|
}
|
|
|
|
|
2001-10-23 01:37:21 +00:00
|
|
|
PRLogModuleInfo*
|
2009-08-20 21:52:48 +00:00
|
|
|
nsFrame::GetLogModuleInfo()
|
1998-05-20 16:24:13 +00:00
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
if (nullptr == gLogModule) {
|
1999-02-26 17:05:20 +00:00
|
|
|
gLogModule = PR_NewLogModule("frame");
|
|
|
|
}
|
1998-05-20 16:24:13 +00:00
|
|
|
return gLogModule;
|
|
|
|
}
|
|
|
|
|
2007-03-08 01:48:25 +00:00
|
|
|
void
|
2009-08-20 21:52:48 +00:00
|
|
|
nsFrame::DumpFrameTree(nsIFrame* aFrame)
|
2007-03-08 01:48:25 +00:00
|
|
|
{
|
2007-03-30 21:11:41 +00:00
|
|
|
RootFrameList(aFrame->PresContext(), stdout, 0);
|
2007-03-08 01:48:25 +00:00
|
|
|
}
|
|
|
|
|
2001-10-23 01:37:21 +00:00
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsFrame::RootFrameList(nsPresContext* aPresContext, FILE* out, int32_t aIndent)
|
2001-07-17 21:30:17 +00:00
|
|
|
{
|
2009-08-20 21:52:48 +00:00
|
|
|
if (!aPresContext || !out)
|
2001-07-17 21:30:17 +00:00
|
|
|
return;
|
|
|
|
|
2003-12-21 05:36:36 +00:00
|
|
|
nsIPresShell *shell = aPresContext->GetPresShell();
|
2009-08-20 21:52:48 +00:00
|
|
|
if (shell) {
|
2004-09-02 03:08:51 +00:00
|
|
|
nsIFrame* frame = shell->FrameManager()->GetRootFrame();
|
2009-08-20 21:52:48 +00:00
|
|
|
if(frame) {
|
|
|
|
frame->List(out, aIndent);
|
2001-07-17 21:30:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-07-17 22:02:11 +00:00
|
|
|
#endif
|
1998-05-20 16:24:13 +00:00
|
|
|
|
2011-04-27 23:41:43 +00:00
|
|
|
static void
|
|
|
|
DestroyAbsoluteContainingBlock(void* aPropertyValue)
|
|
|
|
{
|
|
|
|
delete static_cast<nsAbsoluteContainingBlock*>(aPropertyValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_DECLARE_FRAME_PROPERTY(AbsoluteContainingBlockProperty, DestroyAbsoluteContainingBlock)
|
|
|
|
|
|
|
|
bool
|
|
|
|
nsIFrame::HasAbsolutelyPositionedChildren() const {
|
|
|
|
return IsAbsoluteContainer() && GetAbsoluteContainingBlock()->HasAbsoluteFrames();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAbsoluteContainingBlock*
|
|
|
|
nsIFrame::GetAbsoluteContainingBlock() const {
|
|
|
|
NS_ASSERTION(IsAbsoluteContainer(), "The frame is not marked as an abspos container correctly");
|
|
|
|
nsAbsoluteContainingBlock* absCB = static_cast<nsAbsoluteContainingBlock*>
|
|
|
|
(Properties().Get(AbsoluteContainingBlockProperty()));
|
|
|
|
NS_ASSERTION(absCB, "The frame is marked as an abspos container but doesn't have the property");
|
|
|
|
return absCB;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-10-26 09:11:24 +00:00
|
|
|
nsIFrame::MarkAsAbsoluteContainingBlock()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(!Properties().Get(AbsoluteContainingBlockProperty()),
|
|
|
|
"Already has an abs-pos containing block property?");
|
|
|
|
NS_ASSERTION(!HasAnyStateBits(NS_FRAME_HAS_ABSPOS_CHILDREN),
|
|
|
|
"Already has NS_FRAME_HAS_ABSPOS_CHILDREN state bit?");
|
2011-04-27 23:41:43 +00:00
|
|
|
AddStateBits(NS_FRAME_HAS_ABSPOS_CHILDREN);
|
|
|
|
Properties().Set(AbsoluteContainingBlockProperty(), new nsAbsoluteContainingBlock(GetAbsoluteListID()));
|
|
|
|
}
|
|
|
|
|
2012-10-26 09:11:24 +00:00
|
|
|
void
|
|
|
|
nsIFrame::MarkAsNotAbsoluteContainingBlock()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(!HasAbsolutelyPositionedChildren(), "Think of the children!");
|
|
|
|
NS_ASSERTION(Properties().Get(AbsoluteContainingBlockProperty()),
|
|
|
|
"Should have an abs-pos containing block property");
|
|
|
|
NS_ASSERTION(HasAnyStateBits(NS_FRAME_HAS_ABSPOS_CHILDREN),
|
|
|
|
"Should have NS_FRAME_HAS_ABSPOS_CHILDREN state bit");
|
|
|
|
RemoveStateBits(NS_FRAME_HAS_ABSPOS_CHILDREN);
|
|
|
|
Properties().Delete(AbsoluteContainingBlockProperty());
|
|
|
|
}
|
|
|
|
|
2012-07-23 03:00:36 +00:00
|
|
|
void
|
|
|
|
nsIFrame::ClearDisplayItemCache()
|
|
|
|
{
|
|
|
|
if (GetStateBits() & NS_FRAME_HAS_CACHED_BACKGROUND) {
|
|
|
|
Properties().Delete(CachedBackgroundImage());
|
|
|
|
RemoveStateBits(NS_FRAME_HAS_CACHED_BACKGROUND);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-26 03:23:26 +00:00
|
|
|
bool
|
|
|
|
nsIFrame::CheckAndClearPaintedState()
|
|
|
|
{
|
|
|
|
bool result = (GetStateBits() & NS_FRAME_PAINTED_THEBES);
|
|
|
|
RemoveStateBits(NS_FRAME_PAINTED_THEBES);
|
|
|
|
|
|
|
|
nsIFrame::ChildListIterator lists(this);
|
|
|
|
for (; !lists.IsDone(); lists.Next()) {
|
|
|
|
nsFrameList::Enumerator childFrames(lists.CurrentList());
|
|
|
|
for (; !childFrames.AtEnd(); childFrames.Next()) {
|
|
|
|
nsIFrame* child = childFrames.get();
|
|
|
|
if (child->CheckAndClearPaintedState()) {
|
|
|
|
result = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2011-10-26 23:57:55 +00:00
|
|
|
bool
|
2012-08-22 15:56:38 +00:00
|
|
|
nsIFrame::IsVisibleConsideringAncestors(uint32_t aFlags) const
|
2011-10-26 23:57:55 +00:00
|
|
|
{
|
|
|
|
if (!GetStyleVisibility()->IsVisible()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const nsIFrame* frame = this;
|
|
|
|
while (frame) {
|
|
|
|
nsIView* view = frame->GetView();
|
|
|
|
if (view && view->GetVisibility() == nsViewVisibility_kHide)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
nsIFrame* parent = frame->GetParent();
|
|
|
|
nsDeckFrame* deck = do_QueryFrame(parent);
|
|
|
|
if (deck) {
|
|
|
|
if (deck->GetSelectedBox() != frame)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (parent) {
|
|
|
|
frame = parent;
|
|
|
|
} else {
|
|
|
|
parent = nsLayoutUtils::GetCrossDocParentFrame(frame);
|
|
|
|
if (!parent)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if ((aFlags & nsIFrame::VISIBILITY_CROSS_CHROME_CONTENT_BOUNDARY) == 0 &&
|
|
|
|
parent->PresContext()->IsChrome() && !frame->PresContext()->IsChrome()) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!parent->GetStyleVisibility()->IsVisible())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
frame = parent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool ApplyOverflowClipping(nsDisplayListBuilder* aBuilder,
|
2011-08-27 00:01:46 +00:00
|
|
|
const nsIFrame* aFrame,
|
|
|
|
const nsStyleDisplay* aDisp,
|
|
|
|
nsRect* aRect);
|
|
|
|
|
2012-03-02 08:28:56 +00:00
|
|
|
static bool ApplyClipPropClipping(nsDisplayListBuilder* aBuilder,
|
2011-08-27 00:01:46 +00:00
|
|
|
const nsStyleDisplay* aDisp,
|
|
|
|
const nsIFrame* aFrame,
|
|
|
|
nsRect* aRect);
|
|
|
|
|
2008-05-28 13:39:41 +00:00
|
|
|
void
|
|
|
|
NS_MergeReflowStatusInto(nsReflowStatus* aPrimary, nsReflowStatus aSecondary)
|
|
|
|
{
|
|
|
|
*aPrimary |= aSecondary &
|
|
|
|
(NS_FRAME_NOT_COMPLETE | NS_FRAME_OVERFLOW_INCOMPLETE |
|
|
|
|
NS_FRAME_TRUNCATED | NS_FRAME_REFLOW_NEXTINFLOW);
|
|
|
|
if (*aPrimary & NS_FRAME_NOT_COMPLETE) {
|
|
|
|
*aPrimary &= ~NS_FRAME_OVERFLOW_INCOMPLETE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-11-18 06:38:15 +00:00
|
|
|
void
|
2009-11-16 14:03:53 +00:00
|
|
|
nsWeakFrame::InitInternal(nsIFrame* aFrame)
|
2006-11-18 06:38:15 +00:00
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
Clear(mFrame ? mFrame->PresContext()->GetPresShell() : nullptr);
|
2006-11-18 06:38:15 +00:00
|
|
|
mFrame = aFrame;
|
|
|
|
if (mFrame) {
|
2007-03-30 21:11:41 +00:00
|
|
|
nsIPresShell* shell = mFrame->PresContext()->GetPresShell();
|
2006-11-18 06:38:15 +00:00
|
|
|
NS_WARN_IF_FALSE(shell, "Null PresShell in nsWeakFrame!");
|
|
|
|
if (shell) {
|
|
|
|
shell->AddWeakFrame(this);
|
|
|
|
} else {
|
2012-07-30 14:20:58 +00:00
|
|
|
mFrame = nullptr;
|
2006-11-18 06:38:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-01 20:40:54 +00:00
|
|
|
nsIFrame*
|
2006-03-26 21:30:36 +00:00
|
|
|
NS_NewEmptyFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2006-03-26 21:30:36 +00:00
|
|
|
return new (aPresShell) nsFrame(aContext);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2006-03-26 21:30:36 +00:00
|
|
|
nsFrame::nsFrame(nsStyleContext* aContext)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-10-05 14:51:12 +00:00
|
|
|
MOZ_COUNT_CTOR(nsFrame);
|
|
|
|
|
2005-03-28 21:08:22 +00:00
|
|
|
mState = NS_FRAME_FIRST_REFLOW | NS_FRAME_IS_DIRTY;
|
2006-03-26 21:30:36 +00:00
|
|
|
mStyleContext = aContext;
|
|
|
|
mStyleContext->AddRef();
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsFrame::~nsFrame()
|
|
|
|
{
|
1999-10-05 14:51:12 +00:00
|
|
|
MOZ_COUNT_DTOR(nsFrame);
|
|
|
|
|
1998-08-04 18:19:51 +00:00
|
|
|
NS_IF_RELEASE(mContent);
|
2003-02-22 00:32:13 +00:00
|
|
|
if (mStyleContext)
|
|
|
|
mStyleContext->Release();
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsFrame)
|
|
|
|
|
|
|
|
// Dummy operator delete. Will never be called, but must be defined
|
|
|
|
// to satisfy some C++ ABIs.
|
|
|
|
void
|
|
|
|
nsFrame::operator delete(void *, size_t)
|
|
|
|
{
|
|
|
|
NS_RUNTIMEABORT("nsFrame::operator delete should never be called");
|
|
|
|
}
|
|
|
|
|
2009-01-12 19:20:59 +00:00
|
|
|
NS_QUERYFRAME_HEAD(nsFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsIFrame)
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_QUERYFRAME_TAIL_INHERITANCE_ROOT
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIFrame
|
|
|
|
|
2012-01-25 01:21:28 +00:00
|
|
|
static bool
|
|
|
|
IsFontSizeInflationContainer(nsIFrame* aFrame,
|
|
|
|
const nsStyleDisplay* aStyleDisplay)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Font size inflation is built around the idea that we're inflating
|
|
|
|
* the fonts for a pan-and-zoom UI so that when the user scales up a
|
|
|
|
* block or other container to fill the width of the device, the fonts
|
|
|
|
* will be readable. To do this, we need to pick what counts as a
|
|
|
|
* container.
|
|
|
|
*
|
|
|
|
* From a code perspective, the only hard requirement is that frames
|
|
|
|
* that are line participants
|
|
|
|
* (nsIFrame::IsFrameOfType(nsIFrame::eLineParticipant)) are never
|
|
|
|
* containers, since line layout assumes that the inflation is
|
|
|
|
* consistent within a line.
|
|
|
|
*
|
|
|
|
* This is not an imposition, since we obviously want a bunch of text
|
|
|
|
* (possibly with inline elements) flowing within a block to count the
|
|
|
|
* block (or higher) as its container.
|
|
|
|
*
|
|
|
|
* We also want form controls, including the text in the anonymous
|
|
|
|
* content inside of them, to match each other and the text next to
|
|
|
|
* them, so they and their anonymous content should also not be a
|
|
|
|
* container.
|
|
|
|
*
|
|
|
|
* However, because we can't reliably compute sizes across XUL during
|
|
|
|
* reflow, any XUL frame with a XUL parent is always a container.
|
|
|
|
*
|
|
|
|
* There are contexts where it would be nice if some blocks didn't
|
|
|
|
* count as a container, so that, for example, an indented quotation
|
|
|
|
* didn't end up with a smaller font size. However, it's hard to
|
|
|
|
* distinguish these situations where we really do want the indented
|
|
|
|
* thing to count as a container, so we don't try, and blocks are
|
|
|
|
* always containers.
|
|
|
|
*/
|
2012-05-04 17:08:23 +00:00
|
|
|
|
|
|
|
// The root frame should always be an inflation container.
|
|
|
|
if (!aFrame->GetParent()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-01-25 01:21:29 +00:00
|
|
|
nsIContent *content = aFrame->GetContent();
|
2012-08-02 11:38:51 +00:00
|
|
|
bool isInline = (aFrame->GetDisplay() == NS_STYLE_DISPLAY_INLINE ||
|
2012-08-02 11:38:49 +00:00
|
|
|
(aFrame->IsFloating() &&
|
2012-01-25 01:21:28 +00:00
|
|
|
aFrame->GetType() == nsGkAtoms::letterFrame) ||
|
2012-01-25 01:21:29 +00:00
|
|
|
// Given multiple frames for the same node, only the
|
|
|
|
// outer one should be considered a container.
|
|
|
|
// (Important, e.g., for nsSelectsAreaFrame.)
|
2012-05-04 17:08:23 +00:00
|
|
|
(aFrame->GetParent()->GetContent() == content) ||
|
2012-01-25 01:21:29 +00:00
|
|
|
(content && (content->IsHTML(nsGkAtoms::option) ||
|
|
|
|
content->IsHTML(nsGkAtoms::optgroup) ||
|
2012-09-07 14:51:34 +00:00
|
|
|
content->IsHTML(nsGkAtoms::select) ||
|
2012-01-25 01:21:29 +00:00
|
|
|
content->IsInNativeAnonymousSubtree()))) &&
|
2012-05-04 17:08:23 +00:00
|
|
|
!(aFrame->IsBoxFrame() && aFrame->GetParent()->IsBoxFrame());
|
2012-01-25 01:21:28 +00:00
|
|
|
NS_ASSERTION(!aFrame->IsFrameOfType(nsIFrame::eLineParticipant) ||
|
|
|
|
isInline ||
|
|
|
|
// br frames and mathml frames report being line
|
|
|
|
// participants even when their position or display is
|
|
|
|
// set
|
|
|
|
aFrame->GetType() == nsGkAtoms::brFrame ||
|
|
|
|
aFrame->IsFrameOfType(nsIFrame::eMathML),
|
|
|
|
"line participants must not be containers");
|
|
|
|
NS_ASSERTION(aFrame->GetType() != nsGkAtoms::bulletFrame || isInline,
|
|
|
|
"bullets should not be containers");
|
|
|
|
return !isInline;
|
|
|
|
}
|
|
|
|
|
1998-12-03 06:31:43 +00:00
|
|
|
NS_IMETHODIMP
|
2006-03-09 18:55:21 +00:00
|
|
|
nsFrame::Init(nsIContent* aContent,
|
1999-01-14 05:16:23 +00:00
|
|
|
nsIFrame* aParent,
|
1999-02-25 03:27:57 +00:00
|
|
|
nsIFrame* aPrevInFlow)
|
1998-12-03 06:31:43 +00:00
|
|
|
{
|
2007-09-22 01:24:40 +00:00
|
|
|
NS_PRECONDITION(!mContent, "Double-initing a frame?");
|
2007-02-24 18:33:33 +00:00
|
|
|
NS_ASSERTION(IsFrameOfType(eDEBUGAllFrames) &&
|
|
|
|
!IsFrameOfType(eDEBUGNoFrames),
|
|
|
|
"IsFrameOfType implementation that doesn't call base class");
|
|
|
|
|
1998-12-03 06:31:43 +00:00
|
|
|
mContent = aContent;
|
1999-01-14 05:16:23 +00:00
|
|
|
mParent = aParent;
|
1999-10-23 23:19:14 +00:00
|
|
|
|
2005-03-23 03:21:04 +00:00
|
|
|
if (aContent) {
|
|
|
|
NS_ADDREF(aContent);
|
2005-03-23 03:07:10 +00:00
|
|
|
}
|
|
|
|
|
1999-10-23 23:19:14 +00:00
|
|
|
if (aPrevInFlow) {
|
|
|
|
// Make sure the general flags bits are the same
|
2003-06-27 18:13:48 +00:00
|
|
|
nsFrameState state = aPrevInFlow->GetStateBits();
|
2002-03-27 02:38:13 +00:00
|
|
|
|
|
|
|
// Make bits that are currently off (see constructor) the same:
|
2011-12-20 09:15:41 +00:00
|
|
|
mState |= state & (NS_FRAME_INDEPENDENT_SELECTION |
|
2008-10-01 00:51:05 +00:00
|
|
|
NS_FRAME_IS_SPECIAL |
|
2012-05-30 03:45:17 +00:00
|
|
|
NS_FRAME_MAY_BE_TRANSFORMED |
|
|
|
|
NS_FRAME_MAY_HAVE_GENERATED_CONTENT);
|
1999-10-23 23:19:14 +00:00
|
|
|
}
|
2002-03-27 02:38:13 +00:00
|
|
|
if (mParent) {
|
2003-06-27 18:13:48 +00:00
|
|
|
nsFrameState state = mParent->GetStateBits();
|
2002-03-27 02:38:13 +00:00
|
|
|
|
|
|
|
// Make bits that are currently off (see constructor) the same:
|
|
|
|
mState |= state & (NS_FRAME_INDEPENDENT_SELECTION |
|
2012-08-02 11:38:46 +00:00
|
|
|
NS_FRAME_GENERATED_CONTENT |
|
2012-08-29 05:39:01 +00:00
|
|
|
NS_FRAME_IS_SVG_TEXT |
|
|
|
|
NS_FRAME_IN_POPUP);
|
2000-05-04 08:35:42 +00:00
|
|
|
}
|
2012-01-25 01:21:28 +00:00
|
|
|
const nsStyleDisplay *disp = GetStyleDisplay();
|
|
|
|
if (disp->HasTransform()) {
|
2008-09-13 09:42:11 +00:00
|
|
|
// The frame gets reconstructed if we toggle the -moz-transform
|
|
|
|
// property, so we can set this bit here and then ignore it.
|
2010-08-13 13:31:31 +00:00
|
|
|
mState |= NS_FRAME_MAY_BE_TRANSFORMED;
|
2008-09-13 09:42:11 +00:00
|
|
|
}
|
2012-01-25 01:21:28 +00:00
|
|
|
|
2012-06-20 16:09:35 +00:00
|
|
|
if (nsLayoutUtils::FontSizeInflationEnabled(PresContext()) || !GetParent()
|
2012-01-25 01:21:28 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
// We have assertions that check inflation invariants even when
|
|
|
|
// font size inflation is not enabled.
|
|
|
|
|| true
|
|
|
|
#endif
|
|
|
|
) {
|
|
|
|
if (IsFontSizeInflationContainer(this, disp)) {
|
2012-04-16 22:32:12 +00:00
|
|
|
AddStateBits(NS_FRAME_FONT_INFLATION_CONTAINER);
|
|
|
|
if (!GetParent() ||
|
|
|
|
// I'd use NS_FRAME_OUT_OF_FLOW, but it's not set yet.
|
2012-08-02 11:38:50 +00:00
|
|
|
disp->IsFloating(this) || disp->IsAbsolutelyPositioned(this)) {
|
2012-04-16 22:32:12 +00:00
|
|
|
AddStateBits(NS_FRAME_FONT_INFLATION_FLOW_ROOT);
|
|
|
|
}
|
2012-01-25 01:21:28 +00:00
|
|
|
}
|
2012-04-16 22:32:12 +00:00
|
|
|
NS_ASSERTION(GetParent() ||
|
|
|
|
(GetStateBits() & NS_FRAME_FONT_INFLATION_CONTAINER),
|
|
|
|
"root frame should always be a container");
|
2012-01-25 01:21:28 +00:00
|
|
|
}
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
DidSetStyleContext(nullptr);
|
2004-09-28 18:37:50 +00:00
|
|
|
|
|
|
|
if (IsBoxWrapped())
|
2011-10-17 14:59:28 +00:00
|
|
|
InitBoxMetrics(false);
|
2004-09-28 18:37:50 +00:00
|
|
|
|
2003-02-22 00:32:13 +00:00
|
|
|
return NS_OK;
|
1998-12-03 06:31:43 +00:00
|
|
|
}
|
|
|
|
|
2011-08-24 20:54:30 +00:00
|
|
|
NS_IMETHODIMP nsFrame::SetInitialChildList(ChildListID aListID,
|
2009-07-28 12:53:20 +00:00
|
|
|
nsFrameList& aChildList)
|
1998-09-10 19:32:14 +00:00
|
|
|
{
|
1998-11-10 06:05:32 +00:00
|
|
|
// XXX This shouldn't be getting called at all, but currently is for backwards
|
|
|
|
// compatility reasons...
|
|
|
|
#if 0
|
|
|
|
NS_ERROR("not a container");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
#else
|
2009-07-28 12:53:20 +00:00
|
|
|
NS_ASSERTION(aChildList.IsEmpty(), "not a container");
|
1998-09-10 19:32:14 +00:00
|
|
|
return NS_OK;
|
1998-11-10 06:05:32 +00:00
|
|
|
#endif
|
1998-09-10 19:32:14 +00:00
|
|
|
}
|
|
|
|
|
1999-01-15 01:29:15 +00:00
|
|
|
NS_IMETHODIMP
|
2011-08-24 20:54:30 +00:00
|
|
|
nsFrame::AppendFrames(ChildListID aListID,
|
2009-07-30 17:23:32 +00:00
|
|
|
nsFrameList& aFrameList)
|
1999-01-15 01:29:15 +00:00
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
NS_PRECONDITION(false, "not a container");
|
1999-01-15 01:29:15 +00:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-08-24 20:54:30 +00:00
|
|
|
nsFrame::InsertFrames(ChildListID aListID,
|
1999-01-15 01:29:15 +00:00
|
|
|
nsIFrame* aPrevFrame,
|
2009-07-30 17:23:32 +00:00
|
|
|
nsFrameList& aFrameList)
|
1999-01-15 01:29:15 +00:00
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
NS_PRECONDITION(false, "not a container");
|
1999-01-15 01:29:15 +00:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-08-24 20:54:30 +00:00
|
|
|
nsFrame::RemoveFrame(ChildListID aListID,
|
1999-01-15 01:29:15 +00:00
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
NS_PRECONDITION(false, "not a container");
|
1999-01-15 01:29:15 +00:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
2006-04-10 00:16:29 +00:00
|
|
|
void
|
2009-12-24 05:21:15 +00:00
|
|
|
nsFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2009-05-15 03:08:41 +00:00
|
|
|
NS_ASSERTION(!nsContentUtils::IsSafeToRunScript(),
|
|
|
|
"destroy called on frame while scripts not blocked");
|
2009-12-24 05:20:41 +00:00
|
|
|
NS_ASSERTION(!GetNextSibling() && !GetPrevSibling(),
|
|
|
|
"Frames should be removed before destruction.");
|
2009-12-24 05:21:15 +00:00
|
|
|
NS_ASSERTION(aDestructRoot, "Must specify destruct root");
|
2009-05-15 03:08:41 +00:00
|
|
|
|
2008-10-01 00:51:05 +00:00
|
|
|
nsSVGEffects::InvalidateDirectRenderingObservers(this);
|
|
|
|
|
1999-10-27 03:56:14 +00:00
|
|
|
// Get the view pointer now before the frame properties disappear
|
|
|
|
// when we call NotifyDestroyingFrame()
|
2003-06-27 18:13:48 +00:00
|
|
|
nsIView* view = GetView();
|
2007-03-30 21:11:41 +00:00
|
|
|
nsPresContext* presContext = PresContext();
|
2004-04-12 21:53:22 +00:00
|
|
|
|
2006-04-10 00:16:29 +00:00
|
|
|
nsIPresShell *shell = presContext->GetPresShell();
|
2009-05-13 21:35:02 +00:00
|
|
|
if (mState & NS_FRAME_OUT_OF_FLOW) {
|
|
|
|
nsPlaceholderFrame* placeholder =
|
|
|
|
shell->FrameManager()->GetPlaceholderFrameFor(this);
|
2009-12-24 05:21:15 +00:00
|
|
|
NS_ASSERTION(!placeholder || (aDestructRoot != this),
|
|
|
|
"Don't call Destroy() on OOFs, call Destroy() on the placeholder.");
|
|
|
|
NS_ASSERTION(!placeholder ||
|
|
|
|
nsLayoutUtils::IsProperAncestorFrame(aDestructRoot, placeholder),
|
|
|
|
"Placeholder relationship should have been torn down already; "
|
|
|
|
"this might mean we have a stray placeholder in the tree.");
|
2009-05-13 21:35:02 +00:00
|
|
|
if (placeholder) {
|
|
|
|
shell->FrameManager()->UnregisterPlaceholderFrame(placeholder);
|
2012-07-30 14:20:58 +00:00
|
|
|
placeholder->SetOutOfFlowFrame(nullptr);
|
2009-05-13 21:35:02 +00:00
|
|
|
}
|
|
|
|
}
|
2011-08-25 08:31:11 +00:00
|
|
|
|
2011-09-01 07:10:22 +00:00
|
|
|
// If we have any IB split special siblings, clear their references to us.
|
2011-08-25 08:31:11 +00:00
|
|
|
// (Note: This has to happen before we call shell->NotifyDestroyingFrame,
|
|
|
|
// because that clears our Properties() table.)
|
|
|
|
if (mState & NS_FRAME_IS_SPECIAL) {
|
2011-09-01 07:10:22 +00:00
|
|
|
// Delete previous sibling's reference to me.
|
|
|
|
nsIFrame* prevSib = static_cast<nsIFrame*>
|
|
|
|
(Properties().Get(nsIFrame::IBSplitSpecialPrevSibling()));
|
|
|
|
if (prevSib) {
|
|
|
|
NS_WARN_IF_FALSE(this ==
|
|
|
|
prevSib->Properties().Get(nsIFrame::IBSplitSpecialSibling()),
|
|
|
|
"IB sibling chain is inconsistent");
|
|
|
|
prevSib->Properties().Delete(nsIFrame::IBSplitSpecialSibling());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Delete next sibling's reference to me.
|
2011-08-25 08:31:11 +00:00
|
|
|
nsIFrame* nextSib = static_cast<nsIFrame*>
|
|
|
|
(Properties().Get(nsIFrame::IBSplitSpecialSibling()));
|
|
|
|
if (nextSib) {
|
|
|
|
NS_WARN_IF_FALSE(this ==
|
|
|
|
nextSib->Properties().Get(nsIFrame::IBSplitSpecialPrevSibling()),
|
2011-09-01 07:10:22 +00:00
|
|
|
"IB sibling chain is inconsistent");
|
2011-08-25 08:31:11 +00:00
|
|
|
nextSib->Properties().Delete(nsIFrame::IBSplitSpecialPrevSibling());
|
|
|
|
}
|
|
|
|
}
|
2005-03-23 03:35:08 +00:00
|
|
|
|
2006-05-06 21:42:49 +00:00
|
|
|
shell->NotifyDestroyingFrame(this);
|
1999-06-25 04:22:15 +00:00
|
|
|
|
2011-12-20 09:15:41 +00:00
|
|
|
if (mState & NS_FRAME_EXTERNAL_REFERENCE) {
|
2006-05-06 21:42:49 +00:00
|
|
|
shell->ClearFrameRefs(this);
|
1998-11-19 00:43:36 +00:00
|
|
|
}
|
|
|
|
|
1999-10-27 03:56:14 +00:00
|
|
|
if (view) {
|
|
|
|
// Break association between view and frame
|
2012-07-30 14:20:58 +00:00
|
|
|
view->SetFrame(nullptr);
|
2009-08-18 03:21:06 +00:00
|
|
|
|
1999-10-27 03:56:14 +00:00
|
|
|
// Destroy the view
|
|
|
|
view->Destroy();
|
1998-08-10 02:28:23 +00:00
|
|
|
}
|
|
|
|
|
2009-12-24 21:20:05 +00:00
|
|
|
// Make sure that our deleted frame can't be returned from GetPrimaryFrame()
|
|
|
|
if (mContent && mContent->GetPrimaryFrame() == this) {
|
2012-07-30 14:20:58 +00:00
|
|
|
mContent->SetPrimaryFrame(nullptr);
|
2009-12-24 21:20:05 +00:00
|
|
|
}
|
|
|
|
|
2009-09-15 22:00:04 +00:00
|
|
|
// Must retrieve the object ID before calling destructors, so the
|
2009-09-12 16:49:24 +00:00
|
|
|
// vtable is still valid.
|
|
|
|
//
|
|
|
|
// Note to future tweakers: having the method that returns the
|
|
|
|
// object size call the destructor will not avoid an indirect call;
|
|
|
|
// the compiler cannot devirtualize the call to the destructor even
|
|
|
|
// if it's from a method defined in the same class.
|
|
|
|
|
2009-09-15 22:00:04 +00:00
|
|
|
nsQueryFrame::FrameIID id = GetFrameId();
|
2009-09-12 16:49:24 +00:00
|
|
|
this->~nsFrame();
|
1999-12-04 23:49:50 +00:00
|
|
|
|
2009-09-12 16:49:24 +00:00
|
|
|
// Now that we're totally cleaned out, we need to add ourselves to
|
|
|
|
// the presshell's recycler.
|
2009-09-15 22:00:04 +00:00
|
|
|
shell->FreeFrame(id, this);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-01-22 18:58:14 +00:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsFrame::GetOffsets(int32_t &aStart, int32_t &aEnd) const
|
1999-01-22 18:58:14 +00:00
|
|
|
{
|
|
|
|
aStart = 0;
|
|
|
|
aEnd = 0;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool
|
2009-02-19 19:03:28 +00:00
|
|
|
EqualImages(imgIRequest *aOldImage, imgIRequest *aNewImage)
|
|
|
|
{
|
|
|
|
if (aOldImage == aNewImage)
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2009-02-19 19:03:28 +00:00
|
|
|
|
|
|
|
if (!aOldImage || !aNewImage)
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2009-02-19 19:03:28 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> oldURI, newURI;
|
|
|
|
aOldImage->GetURI(getter_AddRefs(oldURI));
|
|
|
|
aNewImage->GetURI(getter_AddRefs(newURI));
|
2011-09-29 06:19:26 +00:00
|
|
|
bool equal;
|
2009-02-19 19:03:28 +00:00
|
|
|
return NS_SUCCEEDED(oldURI->Equals(newURI, &equal)) && equal;
|
|
|
|
}
|
|
|
|
|
1998-04-28 23:25:07 +00:00
|
|
|
// Subclass hook for style post processing
|
2008-10-13 22:03:28 +00:00
|
|
|
/* virtual */ void
|
2008-10-26 10:11:34 +00:00
|
|
|
nsFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
|
1998-04-28 23:25:07 +00:00
|
|
|
{
|
2012-08-13 22:04:19 +00:00
|
|
|
ImageLoader* imageLoader = PresContext()->Document()->StyleImageLoader();
|
|
|
|
|
|
|
|
// If the old context had a background image image and new context
|
|
|
|
// does not have the same image, clear the image load notifier
|
|
|
|
// (which keeps the image loading, if it still is) for the frame.
|
|
|
|
// We want to do this conservatively because some frames paint their
|
|
|
|
// backgrounds from some other frame's style data, and we don't want
|
|
|
|
// to clear those notifiers unless we have to. (They'll be reset
|
|
|
|
// when we paint, although we could miss a notification in that
|
|
|
|
// interval.)
|
|
|
|
const nsStyleBackground *oldBG = aOldStyleContext ?
|
|
|
|
aOldStyleContext->GetStyleBackground() :
|
|
|
|
nullptr;
|
|
|
|
const nsStyleBackground *newBG = GetStyleBackground();
|
|
|
|
if (oldBG) {
|
2009-02-20 05:29:21 +00:00
|
|
|
NS_FOR_VISIBLE_BACKGROUND_LAYERS_BACK_TO_FRONT(i, oldBG) {
|
2012-08-13 22:04:19 +00:00
|
|
|
// If there is an image in oldBG that's not in newBG, drop it.
|
2009-08-01 15:53:40 +00:00
|
|
|
if (i >= newBG->mImageCount ||
|
|
|
|
oldBG->mLayers[i].mImage != newBG->mLayers[i].mImage) {
|
2012-08-13 22:04:19 +00:00
|
|
|
const nsStyleImage& oldImage = oldBG->mLayers[i].mImage;
|
|
|
|
if (oldImage.GetType() != eStyleImageType_Image) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
imageLoader->DisassociateRequestFromFrame(oldImage.GetImageData(),
|
|
|
|
this);
|
|
|
|
}
|
2009-02-19 19:03:28 +00:00
|
|
|
}
|
2012-08-13 22:04:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_FOR_VISIBLE_BACKGROUND_LAYERS_BACK_TO_FRONT(i, newBG) {
|
|
|
|
// If there is an image in newBG that's not in oldBG, add it.
|
|
|
|
if (!oldBG || i >= oldBG->mImageCount ||
|
|
|
|
newBG->mLayers[i].mImage != oldBG->mLayers[i].mImage) {
|
|
|
|
const nsStyleImage& newImage = newBG->mLayers[i].mImage;
|
|
|
|
if (newImage.GetType() != eStyleImageType_Image) {
|
|
|
|
continue;
|
|
|
|
}
|
2010-03-02 01:57:43 +00:00
|
|
|
|
2012-08-13 22:04:19 +00:00
|
|
|
imageLoader->AssociateRequestToFrame(newImage.GetImageData(), this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aOldStyleContext) {
|
2010-03-02 01:57:43 +00:00
|
|
|
// If we detect a change on margin, padding or border, we store the old
|
|
|
|
// values on the frame itself between now and reflow, so if someone
|
|
|
|
// calls GetUsed(Margin|Border|Padding)() before the next reflow, we
|
|
|
|
// can give an accurate answer.
|
|
|
|
// We don't want to set the property if one already exists.
|
2010-03-29 01:46:55 +00:00
|
|
|
FrameProperties props = Properties();
|
2010-03-02 01:57:43 +00:00
|
|
|
nsMargin oldValue(0, 0, 0, 0);
|
|
|
|
nsMargin newValue(0, 0, 0, 0);
|
2010-03-03 00:04:44 +00:00
|
|
|
const nsStyleMargin* oldMargin = aOldStyleContext->PeekStyleMargin();
|
2010-03-02 01:57:43 +00:00
|
|
|
if (oldMargin && oldMargin->GetMargin(oldValue)) {
|
|
|
|
if ((!GetStyleMargin()->GetMargin(newValue) || oldValue != newValue) &&
|
2010-03-29 01:46:55 +00:00
|
|
|
!props.Get(UsedMarginProperty())) {
|
|
|
|
props.Set(UsedMarginProperty(), new nsMargin(oldValue));
|
2010-03-02 01:57:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-03 00:04:44 +00:00
|
|
|
const nsStylePadding* oldPadding = aOldStyleContext->PeekStylePadding();
|
2010-03-02 01:57:43 +00:00
|
|
|
if (oldPadding && oldPadding->GetPadding(oldValue)) {
|
|
|
|
if ((!GetStylePadding()->GetPadding(newValue) || oldValue != newValue) &&
|
2010-03-29 01:46:55 +00:00
|
|
|
!props.Get(UsedPaddingProperty())) {
|
|
|
|
props.Set(UsedPaddingProperty(), new nsMargin(oldValue));
|
2010-03-02 01:57:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-03 00:04:44 +00:00
|
|
|
const nsStyleBorder* oldBorder = aOldStyleContext->PeekStyleBorder();
|
2010-03-02 01:57:43 +00:00
|
|
|
if (oldBorder) {
|
2012-05-31 05:19:49 +00:00
|
|
|
oldValue = oldBorder->GetComputedBorder();
|
|
|
|
newValue = GetStyleBorder()->GetComputedBorder();
|
2010-03-02 01:57:43 +00:00
|
|
|
if (oldValue != newValue &&
|
2010-03-29 01:46:55 +00:00
|
|
|
!props.Get(UsedBorderProperty())) {
|
|
|
|
props.Set(UsedBorderProperty(), new nsMargin(oldValue));
|
2010-03-02 01:57:43 +00:00
|
|
|
}
|
|
|
|
}
|
2009-02-19 19:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
imgIRequest *oldBorderImage = aOldStyleContext
|
|
|
|
? aOldStyleContext->GetStyleBorder()->GetBorderImage()
|
2012-07-30 14:20:58 +00:00
|
|
|
: nullptr;
|
2012-08-13 22:04:19 +00:00
|
|
|
imgIRequest *newBorderImage = GetStyleBorder()->GetBorderImage();
|
2012-05-31 05:19:49 +00:00
|
|
|
// FIXME (Bug 759996): The following is no longer true.
|
2009-02-19 19:03:28 +00:00
|
|
|
// For border-images, we can't be as conservative (we need to set the
|
|
|
|
// new loaders if there has been any change) since the CalcDifference
|
2012-05-31 05:19:49 +00:00
|
|
|
// call depended on the result of GetComputedBorder() and that result
|
2009-02-19 19:03:28 +00:00
|
|
|
// depends on whether the image has loaded, start the image load now
|
|
|
|
// so that we'll get notified when it completes loading and can do a
|
|
|
|
// restyle. Otherwise, the image might finish loading from the
|
|
|
|
// network before we start listening to its notifications, and then
|
|
|
|
// we'll never know that it's finished loading. Likewise, we want to
|
|
|
|
// do this for freshly-created frames to prevent a similar race if the
|
|
|
|
// image loads between reflow (which can depend on whether the image
|
|
|
|
// is loaded) and paint. We also don't really care about any callers
|
|
|
|
// who try to paint borders with a different style context, because
|
|
|
|
// they won't have the correct size for the border either.
|
2012-08-13 22:04:19 +00:00
|
|
|
if (!EqualImages(oldBorderImage, newBorderImage)) {
|
2009-02-19 19:03:28 +00:00
|
|
|
// stop and restart the image loading/notification
|
2012-08-13 22:04:19 +00:00
|
|
|
if (oldBorderImage) {
|
|
|
|
imageLoader->DisassociateRequestFromFrame(oldBorderImage, this);
|
|
|
|
}
|
|
|
|
if (newBorderImage) {
|
|
|
|
imageLoader->AssociateRequestToFrame(newBorderImage, this);
|
|
|
|
}
|
2008-12-23 14:06:56 +00:00
|
|
|
}
|
2009-04-23 06:09:47 +00:00
|
|
|
|
|
|
|
// If the page contains markup that overrides text direction, and
|
|
|
|
// does not contain any characters that would activate the Unicode
|
|
|
|
// bidi algorithm, we need to call |SetBidiEnabled| on the pres
|
|
|
|
// context before reflow starts. See bug 115921.
|
|
|
|
if (GetStyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL) {
|
|
|
|
PresContext()->SetBidiEnabled();
|
|
|
|
}
|
1998-04-28 23:25:07 +00:00
|
|
|
}
|
|
|
|
|
2011-08-24 20:54:29 +00:00
|
|
|
// MSVC fails with link error "one or more multiply defined symbols found",
|
|
|
|
// gcc fails with "hidden symbol `nsIFrame::kPrincipalList' isn't defined"
|
|
|
|
// etc if they are not defined.
|
|
|
|
#ifndef _MSC_VER
|
|
|
|
// static nsIFrame constants; initialized in the header file.
|
|
|
|
const nsIFrame::ChildListID nsIFrame::kPrincipalList;
|
|
|
|
const nsIFrame::ChildListID nsIFrame::kAbsoluteList;
|
|
|
|
const nsIFrame::ChildListID nsIFrame::kBulletList;
|
|
|
|
const nsIFrame::ChildListID nsIFrame::kCaptionList;
|
|
|
|
const nsIFrame::ChildListID nsIFrame::kColGroupList;
|
|
|
|
const nsIFrame::ChildListID nsIFrame::kExcessOverflowContainersList;
|
|
|
|
const nsIFrame::ChildListID nsIFrame::kFixedList;
|
|
|
|
const nsIFrame::ChildListID nsIFrame::kFloatList;
|
|
|
|
const nsIFrame::ChildListID nsIFrame::kOverflowContainersList;
|
|
|
|
const nsIFrame::ChildListID nsIFrame::kOverflowList;
|
|
|
|
const nsIFrame::ChildListID nsIFrame::kOverflowOutOfFlowList;
|
|
|
|
const nsIFrame::ChildListID nsIFrame::kPopupList;
|
|
|
|
const nsIFrame::ChildListID nsIFrame::kPushedFloatsList;
|
|
|
|
const nsIFrame::ChildListID nsIFrame::kSelectPopupList;
|
|
|
|
const nsIFrame::ChildListID nsIFrame::kNoReflowPrincipalList;
|
|
|
|
#endif
|
|
|
|
|
2006-12-13 23:04:57 +00:00
|
|
|
/* virtual */ nsMargin
|
|
|
|
nsIFrame::GetUsedMargin() const
|
|
|
|
{
|
|
|
|
nsMargin margin(0, 0, 0, 0);
|
2012-08-28 18:14:52 +00:00
|
|
|
if (((mState & NS_FRAME_FIRST_REFLOW) &&
|
|
|
|
!(mState & NS_FRAME_IN_REFLOW)) ||
|
2012-08-02 11:38:48 +00:00
|
|
|
(mState & NS_FRAME_IS_SVG_TEXT))
|
2010-03-02 01:57:43 +00:00
|
|
|
return margin;
|
|
|
|
|
|
|
|
nsMargin *m = static_cast<nsMargin*>
|
2010-03-29 01:46:55 +00:00
|
|
|
(Properties().Get(UsedMarginProperty()));
|
2010-03-02 01:57:43 +00:00
|
|
|
if (m) {
|
|
|
|
margin = *m;
|
|
|
|
} else {
|
|
|
|
#ifdef DEBUG
|
2011-09-29 06:19:26 +00:00
|
|
|
bool hasMargin =
|
2010-03-02 01:57:43 +00:00
|
|
|
#endif
|
|
|
|
GetStyleMargin()->GetMargin(margin);
|
|
|
|
NS_ASSERTION(hasMargin, "We should have a margin here! (out of memory?)");
|
2001-02-07 09:57:26 +00:00
|
|
|
}
|
2006-12-13 23:04:57 +00:00
|
|
|
return margin;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nsMargin
|
|
|
|
nsIFrame::GetUsedBorder() const
|
|
|
|
{
|
2010-03-02 01:57:43 +00:00
|
|
|
nsMargin border(0, 0, 0, 0);
|
2012-08-28 18:14:52 +00:00
|
|
|
if (((mState & NS_FRAME_FIRST_REFLOW) &&
|
|
|
|
!(mState & NS_FRAME_IN_REFLOW)) ||
|
2012-08-02 11:38:48 +00:00
|
|
|
(mState & NS_FRAME_IS_SVG_TEXT))
|
2010-03-02 01:57:43 +00:00
|
|
|
return border;
|
2006-12-13 23:04:57 +00:00
|
|
|
|
2007-01-28 17:20:01 +00:00
|
|
|
// Theme methods don't use const-ness.
|
2007-07-08 07:08:04 +00:00
|
|
|
nsIFrame *mutable_this = const_cast<nsIFrame*>(this);
|
2007-01-28 17:20:01 +00:00
|
|
|
|
|
|
|
const nsStyleDisplay *disp = GetStyleDisplay();
|
|
|
|
if (mutable_this->IsThemed(disp)) {
|
2009-01-15 03:27:09 +00:00
|
|
|
nsIntMargin result;
|
2007-03-30 21:11:41 +00:00
|
|
|
nsPresContext *presContext = PresContext();
|
2007-01-28 17:20:01 +00:00
|
|
|
presContext->GetTheme()->GetWidgetBorder(presContext->DeviceContext(),
|
|
|
|
mutable_this, disp->mAppearance,
|
|
|
|
&result);
|
2010-03-02 01:57:43 +00:00
|
|
|
border.left = presContext->DevPixelsToAppUnits(result.left);
|
|
|
|
border.top = presContext->DevPixelsToAppUnits(result.top);
|
|
|
|
border.right = presContext->DevPixelsToAppUnits(result.right);
|
|
|
|
border.bottom = presContext->DevPixelsToAppUnits(result.bottom);
|
|
|
|
return border;
|
2007-01-28 17:20:01 +00:00
|
|
|
}
|
|
|
|
|
2010-03-02 01:57:43 +00:00
|
|
|
nsMargin *b = static_cast<nsMargin*>
|
2010-03-29 01:46:55 +00:00
|
|
|
(Properties().Get(UsedBorderProperty()));
|
2010-03-02 01:57:43 +00:00
|
|
|
if (b) {
|
|
|
|
border = *b;
|
|
|
|
} else {
|
2012-05-31 05:19:49 +00:00
|
|
|
border = GetStyleBorder()->GetComputedBorder();
|
2010-03-02 01:57:43 +00:00
|
|
|
}
|
|
|
|
return border;
|
2006-12-13 23:04:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nsMargin
|
|
|
|
nsIFrame::GetUsedPadding() const
|
|
|
|
{
|
|
|
|
nsMargin padding(0, 0, 0, 0);
|
2012-08-28 18:14:52 +00:00
|
|
|
if (((mState & NS_FRAME_FIRST_REFLOW) &&
|
|
|
|
!(mState & NS_FRAME_IN_REFLOW)) ||
|
2012-08-02 11:38:48 +00:00
|
|
|
(mState & NS_FRAME_IS_SVG_TEXT))
|
2010-03-02 01:57:43 +00:00
|
|
|
return padding;
|
2007-01-28 17:20:01 +00:00
|
|
|
|
|
|
|
// Theme methods don't use const-ness.
|
2007-07-08 07:08:04 +00:00
|
|
|
nsIFrame *mutable_this = const_cast<nsIFrame*>(this);
|
2007-01-28 17:20:01 +00:00
|
|
|
|
|
|
|
const nsStyleDisplay *disp = GetStyleDisplay();
|
|
|
|
if (mutable_this->IsThemed(disp)) {
|
2007-03-30 21:11:41 +00:00
|
|
|
nsPresContext *presContext = PresContext();
|
2009-01-15 03:27:09 +00:00
|
|
|
nsIntMargin widget;
|
2007-01-28 17:20:01 +00:00
|
|
|
if (presContext->GetTheme()->GetWidgetPadding(presContext->DeviceContext(),
|
|
|
|
mutable_this,
|
|
|
|
disp->mAppearance,
|
2009-01-15 03:27:09 +00:00
|
|
|
&widget)) {
|
|
|
|
padding.top = presContext->DevPixelsToAppUnits(widget.top);
|
|
|
|
padding.right = presContext->DevPixelsToAppUnits(widget.right);
|
|
|
|
padding.bottom = presContext->DevPixelsToAppUnits(widget.bottom);
|
|
|
|
padding.left = presContext->DevPixelsToAppUnits(widget.left);
|
2007-01-28 17:20:01 +00:00
|
|
|
return padding;
|
|
|
|
}
|
|
|
|
}
|
2010-03-02 01:57:43 +00:00
|
|
|
|
|
|
|
nsMargin *p = static_cast<nsMargin*>
|
2010-03-29 01:46:55 +00:00
|
|
|
(Properties().Get(UsedPaddingProperty()));
|
2010-03-02 01:57:43 +00:00
|
|
|
if (p) {
|
|
|
|
padding = *p;
|
|
|
|
} else {
|
|
|
|
#ifdef DEBUG
|
2011-09-29 06:19:26 +00:00
|
|
|
bool hasPadding =
|
2010-03-02 01:57:43 +00:00
|
|
|
#endif
|
|
|
|
GetStylePadding()->GetPadding(padding);
|
|
|
|
NS_ASSERTION(hasPadding, "We should have padding here! (out of memory?)");
|
2006-12-13 23:04:57 +00:00
|
|
|
}
|
|
|
|
return padding;
|
2001-02-07 09:57:26 +00:00
|
|
|
}
|
|
|
|
|
2006-12-20 01:23:45 +00:00
|
|
|
void
|
|
|
|
nsIFrame::ApplySkipSides(nsMargin& aMargin) const
|
|
|
|
{
|
2012-08-09 07:09:40 +00:00
|
|
|
int skipSides = GetSkipSides();
|
2006-12-20 01:23:45 +00:00
|
|
|
if (skipSides & (1 << NS_SIDE_TOP))
|
|
|
|
aMargin.top = 0;
|
|
|
|
if (skipSides & (1 << NS_SIDE_RIGHT))
|
|
|
|
aMargin.right = 0;
|
|
|
|
if (skipSides & (1 << NS_SIDE_BOTTOM))
|
|
|
|
aMargin.bottom = 0;
|
|
|
|
if (skipSides & (1 << NS_SIDE_LEFT))
|
|
|
|
aMargin.left = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRect
|
2011-04-19 03:07:22 +00:00
|
|
|
nsIFrame::GetPaddingRectRelativeToSelf() const
|
2006-12-20 01:23:45 +00:00
|
|
|
{
|
2011-04-19 03:07:22 +00:00
|
|
|
nsMargin bp(GetUsedBorder());
|
|
|
|
ApplySkipSides(bp);
|
|
|
|
nsRect r(0, 0, mRect.width, mRect.height);
|
|
|
|
r.Deflate(bp);
|
2006-12-20 01:23:45 +00:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2011-04-19 03:07:22 +00:00
|
|
|
nsRect
|
|
|
|
nsIFrame::GetPaddingRect() const
|
|
|
|
{
|
|
|
|
return GetPaddingRectRelativeToSelf() + GetPosition();
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2008-09-13 09:42:11 +00:00
|
|
|
nsIFrame::IsTransformed() const
|
|
|
|
{
|
2012-07-31 17:28:21 +00:00
|
|
|
return ((mState & NS_FRAME_MAY_BE_TRANSFORMED) &&
|
2012-05-17 04:05:09 +00:00
|
|
|
(GetStyleDisplay()->HasTransform() ||
|
2012-07-31 17:28:21 +00:00
|
|
|
IsSVGTransformed() ||
|
|
|
|
(mContent &&
|
2012-07-31 17:28:22 +00:00
|
|
|
nsLayoutUtils::HasAnimationsForCompositor(mContent,
|
2012-09-26 21:35:29 +00:00
|
|
|
eCSSProperty_transform) &&
|
|
|
|
mContent->GetPrimaryFrame() == this)));
|
2012-07-31 17:28:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
nsIFrame::HasOpacity() const
|
|
|
|
{
|
|
|
|
return GetStyleDisplay()->mOpacity < 1.0f || (mContent &&
|
2012-07-31 17:28:22 +00:00
|
|
|
nsLayoutUtils::HasAnimationsForCompositor(mContent,
|
2012-09-26 21:55:38 +00:00
|
|
|
eCSSProperty_opacity) &&
|
2012-09-26 21:35:29 +00:00
|
|
|
mContent->GetPrimaryFrame() == this);
|
2012-05-17 04:05:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
nsIFrame::IsSVGTransformed(gfxMatrix *aOwnTransforms,
|
|
|
|
gfxMatrix *aFromParentTransforms) const
|
|
|
|
{
|
|
|
|
return false;
|
2008-09-13 09:42:11 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2011-08-27 00:01:46 +00:00
|
|
|
nsIFrame::Preserves3DChildren() const
|
|
|
|
{
|
2012-09-11 03:13:35 +00:00
|
|
|
if (GetStyleDisplay()->mTransformStyle != NS_STYLE_TRANSFORM_STYLE_PRESERVE_3D ||
|
|
|
|
!GetStyleDisplay()->HasTransform())
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2011-09-04 22:25:35 +00:00
|
|
|
|
|
|
|
// If we're all scroll frame, then all descendants will be clipped, so we can't preserve 3d.
|
|
|
|
if (GetType() == nsGkAtoms::scrollFrame)
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2011-09-04 22:25:35 +00:00
|
|
|
|
|
|
|
nsRect temp;
|
2012-07-30 14:20:58 +00:00
|
|
|
return (!ApplyOverflowClipping(nullptr, this, GetStyleDisplay(), &temp) &&
|
|
|
|
!ApplyClipPropClipping(nullptr, GetStyleDisplay(), this, &temp) &&
|
2011-09-04 22:25:35 +00:00
|
|
|
!nsSVGIntegrationUtils::UsingEffectsForFrame(this));
|
2011-08-27 00:01:46 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2011-08-27 00:01:46 +00:00
|
|
|
nsIFrame::Preserves3D() const
|
|
|
|
{
|
2012-09-11 03:13:35 +00:00
|
|
|
if (!GetParent() || !GetParent()->Preserves3DChildren() ||
|
|
|
|
!GetStyleDisplay()->HasTransform()) {
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2011-08-27 00:01:46 +00:00
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2011-08-27 00:01:46 +00:00
|
|
|
}
|
|
|
|
|
2012-02-15 09:28:22 +00:00
|
|
|
bool
|
|
|
|
nsIFrame::HasPerspective() const
|
|
|
|
{
|
|
|
|
if (!IsTransformed()) {
|
|
|
|
return false;
|
|
|
|
}
|
2012-07-30 14:20:58 +00:00
|
|
|
const nsStyleDisplay* parentDisp = nullptr;
|
2012-02-15 09:28:22 +00:00
|
|
|
nsStyleContext* parentStyleContext = GetStyleContext()->GetParent();
|
|
|
|
if (parentStyleContext) {
|
|
|
|
parentDisp = parentStyleContext->GetStyleDisplay();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (parentDisp &&
|
|
|
|
parentDisp->mChildPerspective.GetUnit() == eStyleUnit_Coord &&
|
|
|
|
parentDisp->mChildPerspective.GetCoordValue() > 0.0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-03-12 02:04:25 +00:00
|
|
|
bool
|
|
|
|
nsIFrame::ChildrenHavePerspective() const
|
|
|
|
{
|
|
|
|
const nsStyleDisplay *disp = GetStyleContext()->GetStyleDisplay();
|
|
|
|
if (disp &&
|
|
|
|
disp->mChildPerspective.GetUnit() == eStyleUnit_Coord &&
|
|
|
|
disp->mChildPerspective.GetCoordValue() > 0.0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-12-20 01:23:45 +00:00
|
|
|
nsRect
|
2011-04-19 03:07:22 +00:00
|
|
|
nsIFrame::GetContentRectRelativeToSelf() const
|
2006-12-20 01:23:45 +00:00
|
|
|
{
|
|
|
|
nsMargin bp(GetUsedBorderAndPadding());
|
|
|
|
ApplySkipSides(bp);
|
2011-04-19 03:07:22 +00:00
|
|
|
nsRect r(0, 0, mRect.width, mRect.height);
|
2006-12-20 01:23:45 +00:00
|
|
|
r.Deflate(bp);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2011-04-19 03:07:22 +00:00
|
|
|
nsRect
|
|
|
|
nsIFrame::GetContentRect() const
|
|
|
|
{
|
|
|
|
return GetContentRectRelativeToSelf() + GetPosition();
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2010-09-07 22:20:34 +00:00
|
|
|
nsIFrame::ComputeBorderRadii(const nsStyleCorners& aBorderRadius,
|
2010-09-07 22:20:34 +00:00
|
|
|
const nsSize& aFrameSize,
|
2010-09-07 22:20:35 +00:00
|
|
|
const nsSize& aBorderArea,
|
2012-08-09 07:09:40 +00:00
|
|
|
int aSkipSides,
|
2010-09-07 22:20:34 +00:00
|
|
|
nscoord aRadii[8])
|
|
|
|
{
|
|
|
|
// Percentages are relative to whichever side they're on.
|
|
|
|
NS_FOR_CSS_HALF_CORNERS(i) {
|
|
|
|
const nsStyleCoord c = aBorderRadius.Get(i);
|
2010-09-07 22:20:34 +00:00
|
|
|
nscoord axis =
|
|
|
|
NS_HALF_CORNER_IS_X(i) ? aFrameSize.width : aFrameSize.height;
|
2010-09-07 22:20:34 +00:00
|
|
|
|
2010-09-09 15:21:45 +00:00
|
|
|
if (c.IsCoordPercentCalcUnit()) {
|
|
|
|
aRadii[i] = nsRuleNode::ComputeCoordPercentCalc(c, axis);
|
|
|
|
if (aRadii[i] < 0) {
|
|
|
|
// clamp calc()
|
2010-09-07 22:20:34 +00:00
|
|
|
aRadii[i] = 0;
|
2010-09-09 15:21:45 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
NS_NOTREACHED("ComputeBorderRadii: bad unit");
|
|
|
|
aRadii[i] = 0;
|
2010-09-07 22:20:34 +00:00
|
|
|
}
|
2010-09-07 22:20:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (aSkipSides & (1 << NS_SIDE_TOP)) {
|
|
|
|
aRadii[NS_CORNER_TOP_LEFT_X] = 0;
|
|
|
|
aRadii[NS_CORNER_TOP_LEFT_Y] = 0;
|
|
|
|
aRadii[NS_CORNER_TOP_RIGHT_X] = 0;
|
|
|
|
aRadii[NS_CORNER_TOP_RIGHT_Y] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aSkipSides & (1 << NS_SIDE_RIGHT)) {
|
|
|
|
aRadii[NS_CORNER_TOP_RIGHT_X] = 0;
|
|
|
|
aRadii[NS_CORNER_TOP_RIGHT_Y] = 0;
|
|
|
|
aRadii[NS_CORNER_BOTTOM_RIGHT_X] = 0;
|
|
|
|
aRadii[NS_CORNER_BOTTOM_RIGHT_Y] = 0;
|
|
|
|
}
|
2010-09-07 22:20:34 +00:00
|
|
|
|
2010-09-07 22:20:34 +00:00
|
|
|
if (aSkipSides & (1 << NS_SIDE_BOTTOM)) {
|
|
|
|
aRadii[NS_CORNER_BOTTOM_RIGHT_X] = 0;
|
|
|
|
aRadii[NS_CORNER_BOTTOM_RIGHT_Y] = 0;
|
|
|
|
aRadii[NS_CORNER_BOTTOM_LEFT_X] = 0;
|
|
|
|
aRadii[NS_CORNER_BOTTOM_LEFT_Y] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aSkipSides & (1 << NS_SIDE_LEFT)) {
|
|
|
|
aRadii[NS_CORNER_BOTTOM_LEFT_X] = 0;
|
|
|
|
aRadii[NS_CORNER_BOTTOM_LEFT_Y] = 0;
|
|
|
|
aRadii[NS_CORNER_TOP_LEFT_X] = 0;
|
|
|
|
aRadii[NS_CORNER_TOP_LEFT_Y] = 0;
|
|
|
|
}
|
|
|
|
|
2010-09-07 22:20:35 +00:00
|
|
|
// css3-background specifies this algorithm for reducing
|
|
|
|
// corner radii when they are too big.
|
2011-09-29 06:19:26 +00:00
|
|
|
bool haveRadius = false;
|
2010-09-07 22:20:35 +00:00
|
|
|
double ratio = 1.0f;
|
|
|
|
NS_FOR_CSS_SIDES(side) {
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t hc1 = NS_SIDE_TO_HALF_CORNER(side, false, true);
|
|
|
|
uint32_t hc2 = NS_SIDE_TO_HALF_CORNER(side, true, true);
|
2010-09-07 22:20:35 +00:00
|
|
|
nscoord length =
|
|
|
|
NS_SIDE_IS_VERTICAL(side) ? aBorderArea.height : aBorderArea.width;
|
|
|
|
nscoord sum = aRadii[hc1] + aRadii[hc2];
|
|
|
|
if (sum)
|
2011-10-17 14:59:28 +00:00
|
|
|
haveRadius = true;
|
2010-09-07 22:20:35 +00:00
|
|
|
|
|
|
|
// avoid floating point division in the normal case
|
|
|
|
if (length < sum)
|
|
|
|
ratio = NS_MIN(ratio, double(length)/sum);
|
|
|
|
}
|
|
|
|
if (ratio < 1.0) {
|
|
|
|
NS_FOR_CSS_HALF_CORNERS(corner) {
|
|
|
|
aRadii[corner] *= ratio;
|
2010-09-07 22:20:34 +00:00
|
|
|
}
|
2010-09-07 22:20:34 +00:00
|
|
|
}
|
2010-09-07 22:20:34 +00:00
|
|
|
|
2010-09-07 22:20:35 +00:00
|
|
|
return haveRadius;
|
2010-09-07 22:20:34 +00:00
|
|
|
}
|
|
|
|
|
2010-09-07 22:20:35 +00:00
|
|
|
/* static */ void
|
|
|
|
nsIFrame::InsetBorderRadii(nscoord aRadii[8], const nsMargin &aOffsets)
|
|
|
|
{
|
|
|
|
NS_FOR_CSS_SIDES(side) {
|
2011-04-19 03:07:22 +00:00
|
|
|
nscoord offset = aOffsets.Side(side);
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t hc1 = NS_SIDE_TO_HALF_CORNER(side, false, false);
|
|
|
|
uint32_t hc2 = NS_SIDE_TO_HALF_CORNER(side, true, false);
|
2010-09-07 22:20:35 +00:00
|
|
|
aRadii[hc1] = NS_MAX(0, aRadii[hc1] - offset);
|
|
|
|
aRadii[hc2] = NS_MAX(0, aRadii[hc2] - offset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ void
|
|
|
|
nsIFrame::OutsetBorderRadii(nscoord aRadii[8], const nsMargin &aOffsets)
|
|
|
|
{
|
|
|
|
NS_FOR_CSS_SIDES(side) {
|
2011-04-19 03:07:22 +00:00
|
|
|
nscoord offset = aOffsets.Side(side);
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t hc1 = NS_SIDE_TO_HALF_CORNER(side, false, false);
|
|
|
|
uint32_t hc2 = NS_SIDE_TO_HALF_CORNER(side, true, false);
|
2010-09-07 22:20:35 +00:00
|
|
|
if (aRadii[hc1] > 0)
|
|
|
|
aRadii[hc1] += offset;
|
|
|
|
if (aRadii[hc2] > 0)
|
|
|
|
aRadii[hc2] += offset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
/* virtual */ bool
|
2010-09-07 22:20:35 +00:00
|
|
|
nsIFrame::GetBorderRadii(nscoord aRadii[8]) const
|
|
|
|
{
|
2010-10-07 04:25:47 +00:00
|
|
|
if (IsThemed()) {
|
|
|
|
// When we're themed, the native theme code draws the border and
|
|
|
|
// background, and therefore it doesn't make sense to tell other
|
|
|
|
// code that's interested in border-radius that we have any radii.
|
|
|
|
//
|
|
|
|
// In an ideal world, we might have a way for the them to tell us an
|
|
|
|
// border radius, but since we don't, we're better off assuming
|
|
|
|
// zero.
|
|
|
|
NS_FOR_CSS_HALF_CORNERS(corner) {
|
|
|
|
aRadii[corner] = 0;
|
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2010-10-07 04:25:47 +00:00
|
|
|
}
|
2010-09-07 22:20:35 +00:00
|
|
|
nsSize size = GetSize();
|
|
|
|
return ComputeBorderRadii(GetStyleBorder()->mBorderRadius, size, size,
|
|
|
|
GetSkipSides(), aRadii);
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2010-09-07 22:20:35 +00:00
|
|
|
nsIFrame::GetPaddingBoxBorderRadii(nscoord aRadii[8]) const
|
|
|
|
{
|
|
|
|
if (!GetBorderRadii(aRadii))
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2010-09-07 22:20:35 +00:00
|
|
|
InsetBorderRadii(aRadii, GetUsedBorder());
|
|
|
|
NS_FOR_CSS_HALF_CORNERS(corner) {
|
|
|
|
if (aRadii[corner])
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2010-09-07 22:20:35 +00:00
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2010-09-07 22:20:35 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2010-09-07 22:20:35 +00:00
|
|
|
nsIFrame::GetContentBoxBorderRadii(nscoord aRadii[8]) const
|
|
|
|
{
|
|
|
|
if (!GetBorderRadii(aRadii))
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2010-09-07 22:20:35 +00:00
|
|
|
InsetBorderRadii(aRadii, GetUsedBorderAndPadding());
|
|
|
|
NS_FOR_CSS_HALF_CORNERS(corner) {
|
|
|
|
if (aRadii[corner])
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2010-09-07 22:20:35 +00:00
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2010-09-07 22:20:35 +00:00
|
|
|
}
|
|
|
|
|
2003-02-22 00:32:13 +00:00
|
|
|
nsStyleContext*
|
2012-08-22 15:56:38 +00:00
|
|
|
nsFrame::GetAdditionalStyleContext(int32_t aIndex) const
|
1999-09-03 23:35:14 +00:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(aIndex >= 0, "invalid index number");
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
1999-09-03 23:35:14 +00:00
|
|
|
}
|
|
|
|
|
2003-02-22 00:32:13 +00:00
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsFrame::SetAdditionalStyleContext(int32_t aIndex,
|
2003-02-22 00:32:13 +00:00
|
|
|
nsStyleContext* aStyleContext)
|
1999-09-03 23:35:14 +00:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(aIndex >= 0, "invalid index number");
|
|
|
|
}
|
|
|
|
|
2007-01-23 04:06:56 +00:00
|
|
|
nscoord
|
|
|
|
nsFrame::GetBaseline() const
|
|
|
|
{
|
2007-05-06 19:16:51 +00:00
|
|
|
NS_ASSERTION(!NS_SUBTREE_DIRTY(this),
|
2007-01-23 04:06:56 +00:00
|
|
|
"frame must not be dirty");
|
|
|
|
// Default to the bottom margin edge, per CSS2.1's definition of the
|
|
|
|
// 'baseline' value of 'vertical-align'.
|
|
|
|
return mRect.height + GetUsedMargin().bottom;
|
|
|
|
}
|
|
|
|
|
2012-03-08 01:57:37 +00:00
|
|
|
const nsFrameList&
|
2011-04-29 23:02:33 +00:00
|
|
|
nsFrame::GetChildList(ChildListID aListID) const
|
|
|
|
{
|
|
|
|
if (IsAbsoluteContainer() &&
|
|
|
|
aListID == GetAbsoluteListID()) {
|
|
|
|
return GetAbsoluteContainingBlock()->GetChildList();
|
|
|
|
} else {
|
|
|
|
return nsFrameList::EmptyList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsFrame::GetChildLists(nsTArray<ChildList>* aLists) const
|
|
|
|
{
|
|
|
|
if (IsAbsoluteContainer()) {
|
|
|
|
nsFrameList absoluteList = GetAbsoluteContainingBlock()->GetChildList();
|
|
|
|
absoluteList.AppendIfNonempty(aLists, GetAbsoluteListID());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-29 05:39:01 +00:00
|
|
|
void
|
|
|
|
nsIFrame::GetCrossDocChildLists(nsTArray<ChildList>* aLists)
|
|
|
|
{
|
|
|
|
nsSubDocumentFrame* subdocumentFrame = do_QueryFrame(this);
|
|
|
|
if (subdocumentFrame) {
|
|
|
|
// Descend into the subdocument
|
|
|
|
nsIFrame* root = subdocumentFrame->GetSubdocumentRootFrame();
|
|
|
|
if (root) {
|
|
|
|
aLists->AppendElement(nsIFrame::ChildList(
|
|
|
|
nsFrameList(root, nsLayoutUtils::GetLastSibling(root)),
|
|
|
|
nsIFrame::kPrincipalList));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GetChildLists(aLists);
|
|
|
|
}
|
|
|
|
|
2011-08-03 03:39:02 +00:00
|
|
|
static nsIFrame*
|
|
|
|
GetActiveSelectionFrame(nsPresContext* aPresContext, nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
nsIContent* capturingContent = nsIPresShell::GetCapturingContent();
|
|
|
|
if (capturingContent) {
|
|
|
|
nsIFrame* activeFrame = aPresContext->GetPrimaryFrameFor(capturingContent);
|
|
|
|
return activeFrame ? activeFrame : aFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
return aFrame;
|
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int16_t
|
2011-09-29 06:19:26 +00:00
|
|
|
nsFrame::DisplaySelection(nsPresContext* aPresContext, bool isOkToTurnOn)
|
1998-08-03 23:39:16 +00:00
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
int16_t selType = nsISelectionController::SELECTION_OFF;
|
1998-08-03 23:39:16 +00:00
|
|
|
|
2000-05-04 08:35:42 +00:00
|
|
|
nsCOMPtr<nsISelectionController> selCon;
|
2000-08-05 04:41:33 +00:00
|
|
|
nsresult result = GetSelectionController(aPresContext, getter_AddRefs(selCon));
|
2000-05-04 08:35:42 +00:00
|
|
|
if (NS_SUCCEEDED(result) && selCon) {
|
2000-08-05 04:41:33 +00:00
|
|
|
result = selCon->GetDisplaySelection(&selType);
|
|
|
|
if (NS_SUCCEEDED(result) && (selType != nsISelectionController::SELECTION_OFF)) {
|
|
|
|
// Check whether style allows selection.
|
2011-09-29 06:19:26 +00:00
|
|
|
bool selectable;
|
2012-07-30 14:20:58 +00:00
|
|
|
IsSelectable(&selectable, nullptr);
|
2000-08-05 04:41:33 +00:00
|
|
|
if (!selectable) {
|
|
|
|
selType = nsISelectionController::SELECTION_OFF;
|
2011-10-17 14:59:28 +00:00
|
|
|
isOkToTurnOn = false;
|
2000-05-16 22:16:05 +00:00
|
|
|
}
|
|
|
|
}
|
2000-08-05 04:41:33 +00:00
|
|
|
if (isOkToTurnOn && (selType == nsISelectionController::SELECTION_OFF)) {
|
2000-05-04 08:35:42 +00:00
|
|
|
selCon->SetDisplaySelection(nsISelectionController::SELECTION_ON);
|
2000-08-05 04:41:33 +00:00
|
|
|
selType = nsISelectionController::SELECTION_ON;
|
1998-08-03 23:39:16 +00:00
|
|
|
}
|
|
|
|
}
|
2000-08-05 04:41:33 +00:00
|
|
|
return selType;
|
1998-07-27 18:05:35 +00:00
|
|
|
}
|
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
class nsDisplaySelectionOverlay : public nsDisplayItem {
|
|
|
|
public:
|
2010-08-13 10:01:13 +00:00
|
|
|
nsDisplaySelectionOverlay(nsDisplayListBuilder* aBuilder,
|
2012-08-22 15:56:38 +00:00
|
|
|
nsFrame* aFrame, int16_t aSelectionValue)
|
2010-08-13 10:01:13 +00:00
|
|
|
: nsDisplayItem(aBuilder, aFrame), mSelectionValue(aSelectionValue) {
|
2006-01-29 18:48:58 +00:00
|
|
|
MOZ_COUNT_CTOR(nsDisplaySelectionOverlay);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplaySelectionOverlay() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplaySelectionOverlay);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-09-07 00:35:14 +00:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder,
|
2011-04-08 01:04:40 +00:00
|
|
|
nsRenderingContext* aCtx);
|
2010-07-15 21:07:49 +00:00
|
|
|
NS_DISPLAY_DECL_NAME("SelectionOverlay", TYPE_SELECTION_OVERLAY)
|
2006-01-26 02:29:17 +00:00
|
|
|
private:
|
2012-08-22 15:56:38 +00:00
|
|
|
int16_t mSelectionValue;
|
2006-01-26 02:29:17 +00:00
|
|
|
};
|
2000-04-25 04:43:11 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
void nsDisplaySelectionOverlay::Paint(nsDisplayListBuilder* aBuilder,
|
2011-04-08 01:04:40 +00:00
|
|
|
nsRenderingContext* aCtx)
|
2006-01-26 02:29:17 +00:00
|
|
|
{
|
2011-09-09 02:27:13 +00:00
|
|
|
LookAndFeel::ColorID colorID;
|
2006-06-17 01:05:26 +00:00
|
|
|
if (mSelectionValue == nsISelectionController::SELECTION_ON) {
|
2011-09-09 02:27:13 +00:00
|
|
|
colorID = LookAndFeel::eColorID_TextSelectBackground;
|
2006-06-17 01:05:26 +00:00
|
|
|
} else if (mSelectionValue == nsISelectionController::SELECTION_ATTENTION) {
|
2011-09-09 02:27:13 +00:00
|
|
|
colorID = LookAndFeel::eColorID_TextSelectBackgroundAttention;
|
2006-06-17 01:05:26 +00:00
|
|
|
} else {
|
2011-09-09 02:27:13 +00:00
|
|
|
colorID = LookAndFeel::eColorID_TextSelectBackgroundDisabled;
|
2006-06-17 01:05:26 +00:00
|
|
|
}
|
2006-03-16 21:42:50 +00:00
|
|
|
|
2011-09-09 02:27:13 +00:00
|
|
|
nscolor color = LookAndFeel::GetColor(colorID, NS_RGB(255, 255, 255));
|
2006-03-16 21:42:50 +00:00
|
|
|
|
|
|
|
gfxRGBA c(color);
|
|
|
|
c.a = .5;
|
|
|
|
|
2008-06-03 22:25:31 +00:00
|
|
|
gfxContext *ctx = aCtx->ThebesContext();
|
2006-03-16 21:42:50 +00:00
|
|
|
ctx->SetColor(c);
|
|
|
|
|
2009-09-07 00:35:14 +00:00
|
|
|
nsIntRect pxRect =
|
|
|
|
mVisibleRect.ToOutsidePixels(mFrame->PresContext()->AppUnitsPerDevPixel());
|
2007-03-24 09:21:35 +00:00
|
|
|
ctx->NewPath();
|
2011-10-17 14:59:28 +00:00
|
|
|
ctx->Rectangle(gfxRect(pxRect.x, pxRect.y, pxRect.width, pxRect.height), true);
|
2006-03-16 21:42:50 +00:00
|
|
|
ctx->Fill();
|
1999-04-10 17:32:22 +00:00
|
|
|
}
|
|
|
|
|
2002-08-06 23:56:50 +00:00
|
|
|
/********************************************************
|
|
|
|
* Refreshes each content's frame
|
|
|
|
*********************************************************/
|
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
nsresult
|
|
|
|
nsFrame::DisplaySelectionOverlay(nsDisplayListBuilder* aBuilder,
|
2010-09-09 15:21:46 +00:00
|
|
|
nsDisplayList* aList,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint16_t aContentType)
|
1998-12-18 15:54:23 +00:00
|
|
|
{
|
2011-12-20 09:15:41 +00:00
|
|
|
if (!IsSelected() || !IsVisibleForPainting(aBuilder))
|
2006-01-26 02:29:17 +00:00
|
|
|
return NS_OK;
|
|
|
|
|
2007-03-30 21:11:41 +00:00
|
|
|
nsPresContext* presContext = PresContext();
|
2006-01-26 02:29:17 +00:00
|
|
|
nsIPresShell *shell = presContext->PresShell();
|
|
|
|
if (!shell)
|
2000-08-08 23:48:42 +00:00
|
|
|
return NS_OK;
|
1998-05-08 18:33:42 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int16_t displaySelection = shell->GetSelectionFlags();
|
2006-01-26 02:29:17 +00:00
|
|
|
if (!(displaySelection & aContentType))
|
|
|
|
return NS_OK;
|
1999-05-17 00:21:18 +00:00
|
|
|
|
2007-11-22 20:47:33 +00:00
|
|
|
const nsFrameSelection* frameSelection = GetConstFrameSelection();
|
2012-08-22 15:56:38 +00:00
|
|
|
int16_t selectionValue = frameSelection->GetDisplaySelection();
|
2006-04-26 02:01:07 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
if (selectionValue <= nsISelectionController::SELECTION_HIDDEN)
|
|
|
|
return NS_OK; // selection is hidden or off
|
1999-07-15 18:19:03 +00:00
|
|
|
|
2003-09-27 04:18:26 +00:00
|
|
|
nsIContent *newContent = mContent->GetParent();
|
2000-05-11 04:25:43 +00:00
|
|
|
|
2003-07-28 21:25:13 +00:00
|
|
|
//check to see if we are anonymous content
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t offset = 0;
|
2003-07-28 21:25:13 +00:00
|
|
|
if (newContent) {
|
|
|
|
// XXXbz there has GOT to be a better way of determining this!
|
2003-09-27 04:18:26 +00:00
|
|
|
offset = newContent->IndexOf(mContent);
|
2000-05-11 04:25:43 +00:00
|
|
|
}
|
1999-04-26 04:02:04 +00:00
|
|
|
|
2000-05-11 04:25:43 +00:00
|
|
|
SelectionDetails *details;
|
2006-02-21 00:49:04 +00:00
|
|
|
//look up to see what selection(s) are on this frame
|
2011-10-17 14:59:28 +00:00
|
|
|
details = frameSelection->LookUpSelection(newContent, offset, 1, false);
|
2006-04-26 02:01:07 +00:00
|
|
|
if (!details)
|
|
|
|
return NS_OK;
|
2000-08-08 23:48:42 +00:00
|
|
|
|
2012-07-16 16:15:06 +00:00
|
|
|
bool normal = false;
|
2006-01-26 02:29:17 +00:00
|
|
|
while (details) {
|
2012-07-16 16:15:06 +00:00
|
|
|
if (details->mType == nsISelectionController::SELECTION_NORMAL) {
|
|
|
|
normal = true;
|
|
|
|
}
|
2006-01-26 02:29:17 +00:00
|
|
|
SelectionDetails *next = details->mNext;
|
1999-07-15 18:19:03 +00:00
|
|
|
delete details;
|
2006-01-26 02:29:17 +00:00
|
|
|
details = next;
|
1998-05-08 18:33:42 +00:00
|
|
|
}
|
2006-01-26 02:29:17 +00:00
|
|
|
|
2012-07-16 16:15:06 +00:00
|
|
|
if (!normal && aContentType == nsISelectionDisplay::DISPLAY_IMAGES) {
|
|
|
|
// Don't overlay an image if it's not in the primary selection.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-09-09 15:21:46 +00:00
|
|
|
return aList->AppendNewToTop(new (aBuilder)
|
2010-08-13 10:01:13 +00:00
|
|
|
nsDisplaySelectionOverlay(aBuilder, this, selectionValue));
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
nsresult
|
|
|
|
nsFrame::DisplayOutlineUnconditional(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
|
|
|
if (GetStyleOutline()->GetOutlineStyle() == NS_STYLE_BORDER_STYLE_NONE)
|
|
|
|
return NS_OK;
|
|
|
|
|
2010-08-13 10:01:13 +00:00
|
|
|
return aLists.Outlines()->AppendNewToTop(
|
|
|
|
new (aBuilder) nsDisplayOutline(aBuilder, this));
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsFrame::DisplayOutline(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
|
|
|
if (!IsVisibleForPainting(aBuilder))
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
return DisplayOutlineUnconditional(aBuilder, aLists);
|
|
|
|
}
|
|
|
|
|
2006-04-17 23:16:46 +00:00
|
|
|
nsresult
|
|
|
|
nsIFrame::DisplayCaret(nsDisplayListBuilder* aBuilder,
|
2010-03-27 04:33:17 +00:00
|
|
|
const nsRect& aDirtyRect, nsDisplayList* aList)
|
2006-04-17 23:16:46 +00:00
|
|
|
{
|
|
|
|
if (!IsVisibleForPainting(aBuilder))
|
|
|
|
return NS_OK;
|
|
|
|
|
2010-03-27 04:33:17 +00:00
|
|
|
return aList->AppendNewToTop(
|
2010-08-13 10:01:13 +00:00
|
|
|
new (aBuilder) nsDisplayCaret(aBuilder, this, aBuilder->GetCaret()));
|
2006-04-17 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2010-04-01 02:35:48 +00:00
|
|
|
nscolor
|
2012-08-22 15:56:38 +00:00
|
|
|
nsIFrame::GetCaretColorAt(int32_t aOffset)
|
2010-04-01 02:35:48 +00:00
|
|
|
{
|
|
|
|
// Use text color.
|
|
|
|
return GetStyleColor()->mColor;
|
|
|
|
}
|
|
|
|
|
2009-07-22 00:44:51 +00:00
|
|
|
nsresult
|
|
|
|
nsFrame::DisplayBackgroundUnconditional(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayListSet& aLists,
|
2012-04-13 11:44:06 +00:00
|
|
|
bool aForceBackground,
|
|
|
|
nsDisplayBackground** aBackground)
|
2009-07-22 00:44:51 +00:00
|
|
|
{
|
2012-09-13 10:34:23 +00:00
|
|
|
*aBackground = nullptr;
|
|
|
|
|
2009-07-22 00:44:51 +00:00
|
|
|
// Here we don't try to detect background propagation. Frames that might
|
|
|
|
// receive a propagated background should just set aForceBackground to
|
2011-10-17 14:59:28 +00:00
|
|
|
// true.
|
2009-07-22 00:44:51 +00:00
|
|
|
if (aBuilder->IsForEventDelivery() || aForceBackground ||
|
|
|
|
!GetStyleBackground()->IsTransparent() || GetStyleDisplay()->mAppearance) {
|
2012-09-13 10:34:23 +00:00
|
|
|
return nsDisplayBackground::AppendBackgroundItemsToTop(aBuilder, this,
|
|
|
|
aLists.BorderBackground(),
|
|
|
|
aBackground);
|
2009-07-22 00:44:51 +00:00
|
|
|
}
|
2012-09-13 10:34:23 +00:00
|
|
|
|
2009-07-22 00:44:51 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
nsresult
|
|
|
|
nsFrame::DisplayBorderBackgroundOutline(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayListSet& aLists,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aForceBackground)
|
2002-12-23 22:05:47 +00:00
|
|
|
{
|
|
|
|
// The visibility check belongs here since child elements have the
|
|
|
|
// opportunity to override the visibility property and display even if
|
|
|
|
// their parent is hidden.
|
2006-01-26 02:29:17 +00:00
|
|
|
if (!IsVisibleForPainting(aBuilder))
|
|
|
|
return NS_OK;
|
|
|
|
|
2012-04-16 05:43:33 +00:00
|
|
|
nsCSSShadowArray* shadows = GetStyleBorder()->mBoxShadow;
|
|
|
|
if (shadows && shadows->HasShadowWithInset(false)) {
|
2008-07-08 00:57:47 +00:00
|
|
|
nsresult rv = aLists.BorderBackground()->AppendNewToTop(new (aBuilder)
|
2010-08-13 10:01:13 +00:00
|
|
|
nsDisplayBoxShadowOuter(aBuilder, this));
|
2008-07-08 00:57:47 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
|
2012-04-13 11:44:06 +00:00
|
|
|
nsDisplayBackground* bg;
|
2009-07-22 00:44:51 +00:00
|
|
|
nsresult rv =
|
2012-04-13 11:44:06 +00:00
|
|
|
DisplayBackgroundUnconditional(aBuilder, aLists, aForceBackground, &bg);
|
2009-07-22 00:44:51 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2009-02-10 08:45:13 +00:00
|
|
|
|
2012-04-16 05:43:33 +00:00
|
|
|
if (shadows && shadows->HasShadowWithInset(true)) {
|
2009-07-22 00:44:51 +00:00
|
|
|
rv = aLists.BorderBackground()->AppendNewToTop(new (aBuilder)
|
2010-08-13 10:01:13 +00:00
|
|
|
nsDisplayBoxShadowInner(aBuilder, this));
|
2009-02-10 08:45:13 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
2012-04-13 11:44:06 +00:00
|
|
|
|
|
|
|
// If there's a themed background, we should not create a border item.
|
2012-04-18 05:14:31 +00:00
|
|
|
// It won't be rendered.
|
|
|
|
if ((!bg || !bg->IsThemed()) && GetStyleBorder()->HasBorder()) {
|
2009-07-22 00:44:51 +00:00
|
|
|
rv = aLists.BorderBackground()->AppendNewToTop(new (aBuilder)
|
2010-08-13 10:01:13 +00:00
|
|
|
nsDisplayBorder(aBuilder, this));
|
2006-01-26 02:29:17 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
return DisplayOutlineUnconditional(aBuilder, aLists);
|
|
|
|
}
|
|
|
|
|
2012-07-20 18:12:29 +00:00
|
|
|
inline static bool IsSVGContentWithCSSClip(const nsIFrame *aFrame)
|
|
|
|
{
|
|
|
|
// The CSS spec says that the 'clip' property only applies to absolutely
|
|
|
|
// positioned elements, whereas the SVG spec says that it applies to SVG
|
|
|
|
// elements regardless of the value of the 'position' property. Here we obey
|
|
|
|
// the CSS spec for outer-<svg> (since that's what we generally do), but
|
|
|
|
// obey the SVG spec for other SVG elements to which 'clip' applies.
|
|
|
|
nsIAtom *tag = aFrame->GetContent()->Tag();
|
|
|
|
return (aFrame->GetStateBits() & NS_FRAME_SVG_LAYOUT) &&
|
|
|
|
(tag == nsGkAtoms::svg || tag == nsGkAtoms::foreignObject);
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2012-03-02 08:28:56 +00:00
|
|
|
nsIFrame::GetClipPropClipRect(const nsStyleDisplay* aDisp, nsRect* aRect,
|
|
|
|
const nsSize& aSize) const
|
2006-06-08 01:11:43 +00:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(aRect, "Must have aRect out parameter");
|
|
|
|
|
2012-07-20 18:12:29 +00:00
|
|
|
if (!(aDisp->mClipFlags & NS_STYLE_CLIP_RECT) ||
|
2012-08-02 11:38:50 +00:00
|
|
|
!(aDisp->IsAbsolutelyPositioned(this) || IsSVGContentWithCSSClip(this))) {
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2012-07-20 18:12:29 +00:00
|
|
|
}
|
2006-06-08 01:11:43 +00:00
|
|
|
|
2007-03-29 01:31:26 +00:00
|
|
|
*aRect = aDisp->mClip;
|
|
|
|
if (NS_STYLE_CLIP_RIGHT_AUTO & aDisp->mClipFlags) {
|
2007-04-11 05:04:09 +00:00
|
|
|
aRect->width = aSize.width - aRect->x;
|
2006-06-08 01:11:43 +00:00
|
|
|
}
|
2007-03-29 01:31:26 +00:00
|
|
|
if (NS_STYLE_CLIP_BOTTOM_AUTO & aDisp->mClipFlags) {
|
2007-04-11 05:04:09 +00:00
|
|
|
aRect->height = aSize.height - aRect->y;
|
2006-06-08 01:11:43 +00:00
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2006-06-08 01:11:43 +00:00
|
|
|
}
|
|
|
|
|
2012-03-02 08:28:56 +00:00
|
|
|
static bool ApplyClipPropClipping(nsDisplayListBuilder* aBuilder,
|
2011-08-27 00:01:46 +00:00
|
|
|
const nsStyleDisplay* aDisp, const nsIFrame* aFrame,
|
2006-01-26 02:29:17 +00:00
|
|
|
nsRect* aRect) {
|
2012-03-02 08:28:56 +00:00
|
|
|
if (!aFrame->GetClipPropClipRect(aDisp, aRect, aFrame->GetSize()))
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2007-04-11 05:04:09 +00:00
|
|
|
|
2011-08-27 00:01:46 +00:00
|
|
|
if (aBuilder) {
|
|
|
|
*aRect += aBuilder->ToReferenceFrame(aFrame);
|
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool ApplyOverflowClipping(nsDisplayListBuilder* aBuilder,
|
2012-01-18 20:04:51 +00:00
|
|
|
const nsIFrame* aFrame,
|
|
|
|
const nsStyleDisplay* aDisp, nsRect* aRect) {
|
2006-01-26 02:29:17 +00:00
|
|
|
// REVIEW: from nsContainerFrame.cpp SyncFrameViewGeometryDependentProperties,
|
|
|
|
// except that that function used the border-edge for
|
|
|
|
// -moz-hidden-unscrollable which I don't think is correct... Also I've
|
|
|
|
// changed -moz-hidden-unscrollable to apply to any kind of frame.
|
|
|
|
|
|
|
|
// Only -moz-hidden-unscrollable is handled here (and 'hidden' for table
|
2010-10-07 01:01:24 +00:00
|
|
|
// frames, and any non-visible value for blocks in a paginated context).
|
|
|
|
// Other overflow clipping is applied by nsHTML/XULScrollFrame.
|
2012-01-18 20:04:51 +00:00
|
|
|
// We allow -moz-hidden-unscrollable to apply to any kind of frame. This
|
|
|
|
// is required by comboboxes which make their display text (an inline frame)
|
|
|
|
// have clipping.
|
|
|
|
if (!nsFrame::ApplyOverflowClipping(aFrame, aDisp)) {
|
|
|
|
return false;
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
2011-08-27 00:01:46 +00:00
|
|
|
*aRect = aFrame->GetPaddingRect() - aFrame->GetPosition();
|
|
|
|
if (aBuilder) {
|
|
|
|
*aRect += aBuilder->ToReferenceFrame(aFrame);
|
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class nsOverflowClipWrapper : public nsDisplayWrapper
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Create a wrapper to apply overflow clipping for aContainer.
|
2011-10-17 14:59:28 +00:00
|
|
|
* @param aClipBorderBackground set to true to clip the BorderBackground()
|
2006-01-26 02:29:17 +00:00
|
|
|
* list, otherwise it will not be clipped
|
2011-10-17 14:59:28 +00:00
|
|
|
* @param aClipAll set to true to clip all descendants, even those for
|
2006-01-26 02:29:17 +00:00
|
|
|
* which we aren't the containing block
|
|
|
|
*/
|
|
|
|
nsOverflowClipWrapper(nsIFrame* aContainer, const nsRect& aRect,
|
2010-09-09 15:21:46 +00:00
|
|
|
const nscoord aRadii[8],
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aClipBorderBackground, bool aClipAll)
|
2006-01-26 02:29:17 +00:00
|
|
|
: mContainer(aContainer), mRect(aRect),
|
2010-09-09 15:21:46 +00:00
|
|
|
mClipBorderBackground(aClipBorderBackground), mClipAll(aClipAll),
|
2011-10-17 14:59:28 +00:00
|
|
|
mHaveRadius(false)
|
2010-09-09 15:21:46 +00:00
|
|
|
{
|
|
|
|
memcpy(mRadii, aRadii, sizeof(mRadii));
|
|
|
|
NS_FOR_CSS_HALF_CORNERS(corner) {
|
|
|
|
if (aRadii[corner] > 0) {
|
2011-10-17 14:59:28 +00:00
|
|
|
mHaveRadius = true;
|
2010-09-09 15:21:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-09-29 06:19:26 +00:00
|
|
|
virtual bool WrapBorderBackground() { return mClipBorderBackground; }
|
2006-01-26 02:29:17 +00:00
|
|
|
virtual nsDisplayItem* WrapList(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsIFrame* aFrame, nsDisplayList* aList) {
|
|
|
|
// We are not a stacking context root. There is no valid underlying
|
|
|
|
// frame for the whole list. These items are all in-flow descendants so
|
|
|
|
// we can safely just clip them.
|
2010-09-09 15:21:46 +00:00
|
|
|
if (mHaveRadius) {
|
2012-07-30 14:20:58 +00:00
|
|
|
return new (aBuilder) nsDisplayClipRoundedRect(aBuilder, nullptr, aList,
|
2010-09-09 15:21:46 +00:00
|
|
|
mRect, mRadii);
|
|
|
|
}
|
2012-07-30 14:20:58 +00:00
|
|
|
return new (aBuilder) nsDisplayClip(aBuilder, nullptr, aList, mRect);
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
|
|
|
virtual nsDisplayItem* WrapItem(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsDisplayItem* aItem) {
|
|
|
|
nsIFrame* f = aItem->GetUnderlyingFrame();
|
2010-09-09 15:21:46 +00:00
|
|
|
if (mClipAll ||
|
2012-07-30 14:20:58 +00:00
|
|
|
nsLayoutUtils::IsProperAncestorFrame(mContainer, f, nullptr)) {
|
2010-09-09 15:21:46 +00:00
|
|
|
if (mHaveRadius) {
|
|
|
|
return new (aBuilder) nsDisplayClipRoundedRect(aBuilder, f, aItem,
|
|
|
|
mRect, mRadii);
|
|
|
|
}
|
2010-09-09 15:21:46 +00:00
|
|
|
return new (aBuilder) nsDisplayClip(aBuilder, f, aItem, mRect);
|
2010-09-09 15:21:46 +00:00
|
|
|
}
|
2006-01-26 02:29:17 +00:00
|
|
|
return aItem;
|
|
|
|
}
|
|
|
|
protected:
|
|
|
|
nsIFrame* mContainer;
|
|
|
|
nsRect mRect;
|
2010-09-09 15:21:46 +00:00
|
|
|
nscoord mRadii[8];
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mClipBorderBackground;
|
|
|
|
bool mClipAll;
|
|
|
|
bool mHaveRadius;
|
2006-01-26 02:29:17 +00:00
|
|
|
};
|
|
|
|
|
2012-03-02 08:28:56 +00:00
|
|
|
class nsDisplayClipPropWrapper : public nsDisplayWrapper
|
2006-01-26 02:29:17 +00:00
|
|
|
{
|
|
|
|
public:
|
2012-03-02 08:28:56 +00:00
|
|
|
nsDisplayClipPropWrapper(const nsRect& aRect)
|
2010-09-09 15:21:46 +00:00
|
|
|
: mRect(aRect) {}
|
2006-01-26 02:29:17 +00:00
|
|
|
virtual nsDisplayItem* WrapList(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsIFrame* aFrame, nsDisplayList* aList) {
|
|
|
|
// We are not a stacking context root. There is no valid underlying
|
|
|
|
// frame for the whole list.
|
2012-07-30 14:20:58 +00:00
|
|
|
return new (aBuilder) nsDisplayClip(aBuilder, nullptr, aList, mRect);
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
|
|
|
virtual nsDisplayItem* WrapItem(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsDisplayItem* aItem) {
|
2010-08-13 10:01:13 +00:00
|
|
|
return new (aBuilder) nsDisplayClip(aBuilder, aItem->GetUnderlyingFrame(),
|
2010-09-09 15:21:46 +00:00
|
|
|
aItem, mRect);
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
|
|
|
protected:
|
2008-04-18 09:21:21 +00:00
|
|
|
nsRect mRect;
|
2006-01-26 02:29:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsIFrame::OverflowClip(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayListSet& aFromSet,
|
|
|
|
const nsDisplayListSet& aToSet,
|
|
|
|
const nsRect& aClipRect,
|
2010-09-09 15:21:46 +00:00
|
|
|
const nscoord aClipRadii[8],
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aClipBorderBackground,
|
|
|
|
bool aClipAll)
|
2006-01-26 02:29:17 +00:00
|
|
|
{
|
2010-09-09 15:21:46 +00:00
|
|
|
nsOverflowClipWrapper wrapper(this, aClipRect, aClipRadii,
|
|
|
|
aClipBorderBackground, aClipAll);
|
2006-01-26 02:29:17 +00:00
|
|
|
return wrapper.WrapLists(aBuilder, this, aFromSet, aToSet);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
BuildDisplayListWithOverflowClip(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
|
|
|
|
const nsRect& aDirtyRect, const nsDisplayListSet& aSet,
|
2010-09-09 15:21:46 +00:00
|
|
|
const nsRect& aClipRect, const nscoord aClipRadii[8])
|
2006-01-26 02:29:17 +00:00
|
|
|
{
|
|
|
|
nsDisplayListCollection set;
|
|
|
|
nsresult rv = aFrame->BuildDisplayList(aBuilder, aDirtyRect, set);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2010-03-27 04:33:17 +00:00
|
|
|
rv = aBuilder->DisplayCaret(aFrame, aDirtyRect, aSet.Content());
|
2006-04-17 23:16:46 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2010-09-09 15:21:46 +00:00
|
|
|
|
|
|
|
return aFrame->OverflowClip(aBuilder, set, aSet, aClipRect, aClipRadii);
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
|
|
|
|
2012-06-25 19:59:42 +00:00
|
|
|
#ifdef DEBUG
|
2011-04-08 01:04:40 +00:00
|
|
|
static void PaintDebugBorder(nsIFrame* aFrame, nsRenderingContext* aCtx,
|
2007-02-20 20:22:19 +00:00
|
|
|
const nsRect& aDirtyRect, nsPoint aPt) {
|
|
|
|
nsRect r(aPt, aFrame->GetSize());
|
|
|
|
if (aFrame->HasView()) {
|
|
|
|
aCtx->SetColor(NS_RGB(0,0,255));
|
|
|
|
} else {
|
|
|
|
aCtx->SetColor(NS_RGB(255,0,0));
|
|
|
|
}
|
|
|
|
aCtx->DrawRect(r);
|
|
|
|
}
|
|
|
|
|
2011-04-08 01:04:40 +00:00
|
|
|
static void PaintEventTargetBorder(nsIFrame* aFrame, nsRenderingContext* aCtx,
|
2007-02-20 20:22:19 +00:00
|
|
|
const nsRect& aDirtyRect, nsPoint aPt) {
|
|
|
|
nsRect r(aPt, aFrame->GetSize());
|
|
|
|
aCtx->SetColor(NS_RGB(128,0,128));
|
|
|
|
aCtx->DrawRect(r);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
DisplayDebugBorders(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
|
|
|
|
const nsDisplayListSet& aLists) {
|
|
|
|
// Draw a border around the child
|
|
|
|
// REVIEW: From nsContainerFrame::PaintChild
|
2009-08-20 21:52:48 +00:00
|
|
|
if (nsFrame::GetShowFrameBorders() && !aFrame->GetRect().IsEmpty()) {
|
2007-02-20 20:22:19 +00:00
|
|
|
aLists.Outlines()->AppendNewToTop(new (aBuilder)
|
2010-08-13 10:01:13 +00:00
|
|
|
nsDisplayGeneric(aBuilder, aFrame, PaintDebugBorder, "DebugBorder",
|
2010-07-15 21:07:49 +00:00
|
|
|
nsDisplayItem::TYPE_DEBUG_BORDER));
|
2007-02-20 20:22:19 +00:00
|
|
|
}
|
|
|
|
// Draw a border around the current event target
|
2009-08-20 21:52:48 +00:00
|
|
|
if (nsFrame::GetShowEventTargetFrameBorder() &&
|
2007-03-30 21:11:41 +00:00
|
|
|
aFrame->PresContext()->PresShell()->GetDrawEventTargetFrame() == aFrame) {
|
2007-02-20 20:22:19 +00:00
|
|
|
aLists.Outlines()->AppendNewToTop(new (aBuilder)
|
2010-08-13 10:01:13 +00:00
|
|
|
nsDisplayGeneric(aBuilder, aFrame, PaintEventTargetBorder, "EventTargetBorder",
|
2010-07-15 21:07:49 +00:00
|
|
|
nsDisplayItem::TYPE_EVENT_TARGET_BORDER));
|
2007-02-20 20:22:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-08-27 00:01:46 +00:00
|
|
|
static nsresult
|
2012-08-22 15:56:38 +00:00
|
|
|
WrapPreserve3DListInternal(nsIFrame* aFrame, nsDisplayListBuilder *aBuilder, nsDisplayList *aList, uint32_t& aIndex)
|
2011-08-27 00:01:46 +00:00
|
|
|
{
|
2011-10-03 04:02:25 +00:00
|
|
|
if (aIndex > nsDisplayTransform::INDEX_MAX) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-08-27 00:01:46 +00:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsDisplayList newList;
|
2011-10-03 04:02:25 +00:00
|
|
|
nsDisplayList temp;
|
2011-08-27 00:01:46 +00:00
|
|
|
while (nsDisplayItem *item = aList->RemoveBottom()) {
|
2011-09-04 22:25:35 +00:00
|
|
|
nsIFrame *childFrame = item->GetUnderlyingFrame();
|
2011-10-03 04:02:25 +00:00
|
|
|
|
|
|
|
// We accumulate sequential items that aren't transforms into the 'temp' list
|
|
|
|
// and then flush this list into newList by wrapping the whole lot with a single
|
|
|
|
// nsDisplayTransform.
|
|
|
|
|
2011-11-17 03:45:41 +00:00
|
|
|
if (childFrame && (childFrame->GetParent()->Preserves3DChildren() || childFrame == aFrame)) {
|
2011-08-27 00:01:46 +00:00
|
|
|
switch (item->GetType()) {
|
|
|
|
case nsDisplayItem::TYPE_TRANSFORM: {
|
2011-10-03 04:02:25 +00:00
|
|
|
if (!temp.IsEmpty()) {
|
|
|
|
newList.AppendToTop(new (aBuilder) nsDisplayTransform(aBuilder, aFrame, &temp, aIndex++));
|
|
|
|
}
|
|
|
|
newList.AppendToTop(item);
|
2011-08-27 00:01:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case nsDisplayItem::TYPE_WRAP_LIST: {
|
2011-10-03 04:02:25 +00:00
|
|
|
if (!temp.IsEmpty()) {
|
|
|
|
newList.AppendToTop(new (aBuilder) nsDisplayTransform(aBuilder, aFrame, &temp, aIndex++));
|
|
|
|
}
|
2011-08-27 00:01:46 +00:00
|
|
|
nsDisplayWrapList *list = static_cast<nsDisplayWrapList*>(item);
|
2011-10-03 04:02:25 +00:00
|
|
|
rv = WrapPreserve3DListInternal(aFrame, aBuilder, list->GetList(), aIndex);
|
2011-10-06 21:21:44 +00:00
|
|
|
newList.AppendToTop(list->GetList());
|
|
|
|
list->~nsDisplayWrapList();
|
2011-08-27 00:01:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case nsDisplayItem::TYPE_OPACITY: {
|
2011-10-03 04:02:25 +00:00
|
|
|
if (!temp.IsEmpty()) {
|
|
|
|
newList.AppendToTop(new (aBuilder) nsDisplayTransform(aBuilder, aFrame, &temp, aIndex++));
|
|
|
|
}
|
2011-08-27 00:01:46 +00:00
|
|
|
nsDisplayOpacity *opacity = static_cast<nsDisplayOpacity*>(item);
|
2011-10-03 04:02:25 +00:00
|
|
|
rv = WrapPreserve3DListInternal(aFrame, aBuilder, opacity->GetList(), aIndex);
|
2012-04-19 02:40:43 +00:00
|
|
|
opacity->UpdateBounds(aBuilder);
|
2011-10-03 04:02:25 +00:00
|
|
|
newList.AppendToTop(item);
|
2011-08-27 00:01:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
2011-10-03 04:02:25 +00:00
|
|
|
temp.AppendToTop(item);
|
2011-08-27 00:01:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2011-10-03 04:02:25 +00:00
|
|
|
temp.AppendToTop(item);
|
2011-08-27 00:01:46 +00:00
|
|
|
}
|
|
|
|
|
2011-10-03 04:02:25 +00:00
|
|
|
if (NS_FAILED(rv) || !item || aIndex > nsDisplayTransform::INDEX_MAX)
|
2011-08-27 00:01:46 +00:00
|
|
|
return rv;
|
2011-10-03 04:02:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!temp.IsEmpty()) {
|
|
|
|
newList.AppendToTop(new (aBuilder) nsDisplayTransform(aBuilder, aFrame, &temp, aIndex++));
|
2011-08-27 00:01:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
aList->AppendToTop(&newList);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-10-03 04:02:25 +00:00
|
|
|
static nsresult
|
|
|
|
WrapPreserve3DList(nsIFrame* aFrame, nsDisplayListBuilder* aBuilder, nsDisplayList *aList)
|
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t index = 0;
|
2011-10-03 04:02:25 +00:00
|
|
|
return WrapPreserve3DListInternal(aFrame, aBuilder, aList, index);
|
|
|
|
}
|
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
nsresult
|
|
|
|
nsIFrame::BuildDisplayListForStackingContext(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsDisplayList* aList) {
|
2007-07-21 00:34:36 +00:00
|
|
|
if (GetStateBits() & NS_FRAME_TOO_DEEP_IN_FRAME_TREE)
|
2006-01-26 02:29:17 +00:00
|
|
|
return NS_OK;
|
2012-07-25 15:37:04 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
// Replaced elements have their visibility handled here, because
|
|
|
|
// they're visually atomic
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
if (IsFrameOfType(eReplaced) && !IsVisibleForPainting(aBuilder))
|
2006-01-26 02:29:17 +00:00
|
|
|
return NS_OK;
|
|
|
|
|
2012-03-02 08:28:56 +00:00
|
|
|
nsRect clipPropClip;
|
2006-01-26 02:29:17 +00:00
|
|
|
const nsStyleDisplay* disp = GetStyleDisplay();
|
2012-07-25 15:37:04 +00:00
|
|
|
// We can stop right away if this is a zero-opacity stacking context and
|
2012-10-06 13:03:23 +00:00
|
|
|
// we're painting, and we're not animating opacity. Don't do this
|
|
|
|
// if we're going to compute plugin geometry, since opacity-0 plugins
|
|
|
|
// need to have display items built for them.
|
2012-07-31 17:28:22 +00:00
|
|
|
if (disp->mOpacity == 0.0 && aBuilder->IsForPainting() &&
|
2012-10-06 13:03:23 +00:00
|
|
|
!aBuilder->WillComputePluginGeometry() &&
|
2012-07-31 17:28:22 +00:00
|
|
|
!nsLayoutUtils::HasAnimationsForCompositor(mContent,
|
|
|
|
eCSSProperty_opacity)) {
|
2009-10-27 01:43:55 +00:00
|
|
|
return NS_OK;
|
2012-07-31 17:28:22 +00:00
|
|
|
}
|
2009-10-27 01:43:55 +00:00
|
|
|
|
2012-03-02 08:28:56 +00:00
|
|
|
bool applyClipPropClipping =
|
|
|
|
ApplyClipPropClipping(aBuilder, disp, this, &clipPropClip);
|
2006-01-26 02:29:17 +00:00
|
|
|
nsRect dirtyRect = aDirtyRect;
|
2008-09-13 09:42:11 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool inTransform = aBuilder->IsInTransform();
|
2012-07-20 18:12:29 +00:00
|
|
|
if (IsTransformed()) {
|
2012-05-11 07:49:14 +00:00
|
|
|
if (aBuilder->IsForPainting() &&
|
|
|
|
nsDisplayTransform::ShouldPrerenderTransformedContent(aBuilder, this)) {
|
2011-07-22 22:28:51 +00:00
|
|
|
dirtyRect = GetVisualOverflowRectRelativeToSelf();
|
2011-12-18 21:57:35 +00:00
|
|
|
} else {
|
2012-07-26 04:33:31 +00:00
|
|
|
// Trying to back-transform arbitrary rects gives us really weird results. I believe
|
|
|
|
// this is from points that lie beyond the vanishing point. As a workaround we transform t
|
|
|
|
// he overflow rect into screen space and compare in that coordinate system.
|
2012-07-31 17:28:22 +00:00
|
|
|
|
2012-07-26 04:33:31 +00:00
|
|
|
// Transform the overflow rect into screen space
|
|
|
|
nsRect overflow = GetVisualOverflowRectRelativeToSelf();
|
|
|
|
nsPoint offset = aBuilder->ToReferenceFrame(this);
|
|
|
|
overflow += offset;
|
|
|
|
overflow = nsDisplayTransform::TransformRect(overflow, this, offset);
|
|
|
|
|
|
|
|
dirtyRect += offset;
|
|
|
|
|
|
|
|
if (dirtyRect.Intersects(overflow)) {
|
|
|
|
// If they intersect, we take our whole overflow rect. We could instead take the intersection
|
|
|
|
// and then reverse transform it but I doubt this extra work is worthwhile.
|
|
|
|
dirtyRect = GetVisualOverflowRectRelativeToSelf();
|
2012-05-11 07:49:14 +00:00
|
|
|
} else {
|
2012-07-26 04:33:31 +00:00
|
|
|
dirtyRect.SetEmpty();
|
2012-05-11 07:49:14 +00:00
|
|
|
}
|
|
|
|
if (!Preserves3DChildren() && !dirtyRect.Intersects(GetVisualOverflowRectRelativeToSelf())) {
|
|
|
|
return NS_OK;
|
2011-12-18 21:57:35 +00:00
|
|
|
}
|
2011-07-22 22:28:51 +00:00
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
inTransform = true;
|
2009-07-22 00:45:14 +00:00
|
|
|
}
|
|
|
|
|
2012-03-02 08:28:56 +00:00
|
|
|
if (applyClipPropClipping) {
|
2006-01-26 02:29:17 +00:00
|
|
|
dirtyRect.IntersectRect(dirtyRect,
|
2012-03-02 08:28:56 +00:00
|
|
|
clipPropClip - aBuilder->ToReferenceFrame(this));
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
2008-09-11 00:24:16 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool usingSVGEffects = nsSVGIntegrationUtils::UsingEffectsForFrame(this);
|
2008-09-11 00:24:16 +00:00
|
|
|
if (usingSVGEffects) {
|
|
|
|
dirtyRect =
|
|
|
|
nsSVGIntegrationUtils::GetRequiredSourceForInvalidArea(this, dirtyRect);
|
|
|
|
}
|
|
|
|
|
2011-05-16 17:27:24 +00:00
|
|
|
MarkAbsoluteFramesForDisplayList(aBuilder, dirtyRect);
|
2012-07-20 18:12:29 +00:00
|
|
|
|
2012-05-11 07:49:14 +00:00
|
|
|
// Preserve3DChildren() also guarantees that applyAbsPosClipping and usingSVGEffects are false
|
|
|
|
// We only modify the preserve-3d rect if we are the top of a preserve-3d heirarchy
|
|
|
|
if (Preserves3DChildren()) {
|
|
|
|
aBuilder->MarkPreserve3DFramesForDisplayList(this, aDirtyRect);
|
|
|
|
}
|
2011-04-29 23:02:33 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
nsDisplayListCollection set;
|
|
|
|
nsresult rv;
|
|
|
|
{
|
2012-04-18 05:14:14 +00:00
|
|
|
nsDisplayListBuilder::AutoBuildingDisplayList rootSetter(aBuilder, true);
|
2009-07-22 00:45:14 +00:00
|
|
|
nsDisplayListBuilder::AutoInTransformSetter
|
|
|
|
inTransformSetter(aBuilder, inTransform);
|
2006-01-26 02:29:17 +00:00
|
|
|
rv = BuildDisplayList(aBuilder, dirtyRect, set);
|
|
|
|
}
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
if (aBuilder->IsBackgroundOnly()) {
|
|
|
|
set.BlockBorderBackgrounds()->DeleteAll();
|
|
|
|
set.Floats()->DeleteAll();
|
|
|
|
set.Content()->DeleteAll();
|
|
|
|
set.PositionedDescendants()->DeleteAll();
|
|
|
|
set.Outlines()->DeleteAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
// This z-order sort also sorts secondarily by content order. We need to do
|
|
|
|
// this so that boxes produced by the same element are placed together
|
|
|
|
// in the sort. Consider a position:relative inline element that breaks
|
|
|
|
// across lines and has absolutely positioned children; all the abs-pos
|
|
|
|
// children should be z-ordered after all the boxes for the position:relative
|
|
|
|
// element itself.
|
|
|
|
set.PositionedDescendants()->SortByZOrder(aBuilder, GetContent());
|
|
|
|
|
|
|
|
nsRect overflowClip;
|
|
|
|
if (ApplyOverflowClipping(aBuilder, this, disp, &overflowClip)) {
|
2010-09-09 15:21:46 +00:00
|
|
|
nscoord radii[8];
|
|
|
|
this->GetPaddingBoxBorderRadii(radii);
|
|
|
|
nsOverflowClipWrapper wrapper(this, overflowClip, radii,
|
2011-10-17 14:59:28 +00:00
|
|
|
false, false);
|
2006-01-26 02:29:17 +00:00
|
|
|
rv = wrapper.WrapListsInPlace(aBuilder, this, set);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
// We didn't use overflowClip to restrict the dirty rect, since some of the
|
|
|
|
// descendants may not be clipped by it. Even if we end up with unnecessary
|
2009-09-07 00:35:14 +00:00
|
|
|
// display items, they'll be pruned during ComputeVisibility.
|
2006-01-26 02:29:17 +00:00
|
|
|
|
|
|
|
nsDisplayList resultList;
|
|
|
|
// Now follow the rules of http://www.w3.org/TR/CSS21/zindex.html
|
|
|
|
// 1,2: backgrounds and borders
|
|
|
|
resultList.AppendToTop(set.BorderBackground());
|
|
|
|
// 3: negative z-index children.
|
|
|
|
for (;;) {
|
|
|
|
nsDisplayItem* item = set.PositionedDescendants()->GetBottom();
|
|
|
|
if (item) {
|
|
|
|
nsIFrame* f = item->GetUnderlyingFrame();
|
|
|
|
NS_ASSERTION(f, "After sorting, every item in the list should have an underlying frame");
|
|
|
|
if (nsLayoutUtils::GetZIndex(f) < 0) {
|
|
|
|
set.PositionedDescendants()->RemoveBottom();
|
|
|
|
resultList.AppendToTop(item);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// 4: block backgrounds
|
|
|
|
resultList.AppendToTop(set.BlockBorderBackgrounds());
|
|
|
|
// 5: floats
|
|
|
|
resultList.AppendToTop(set.Floats());
|
2007-07-19 03:50:24 +00:00
|
|
|
// 7: general content
|
2006-01-26 02:29:17 +00:00
|
|
|
resultList.AppendToTop(set.Content());
|
2007-07-19 03:50:24 +00:00
|
|
|
// 7.5: outlines, in content tree order. We need to sort by content order
|
2006-01-26 02:29:17 +00:00
|
|
|
// because an element with outline that breaks and has children with outline
|
|
|
|
// might have placed child outline items between its own outline items.
|
|
|
|
// The element's outline items need to all come before any child outline
|
|
|
|
// items.
|
|
|
|
set.Outlines()->SortByContentOrder(aBuilder, GetContent());
|
2012-06-25 19:59:42 +00:00
|
|
|
#ifdef DEBUG
|
2007-02-20 20:22:19 +00:00
|
|
|
DisplayDebugBorders(aBuilder, this, set);
|
|
|
|
#endif
|
2007-03-25 05:30:59 +00:00
|
|
|
resultList.AppendToTop(set.Outlines());
|
2007-07-19 03:50:24 +00:00
|
|
|
// 8, 9: non-negative z-index children
|
|
|
|
resultList.AppendToTop(set.PositionedDescendants());
|
2007-02-20 20:22:19 +00:00
|
|
|
|
2011-09-08 11:15:00 +00:00
|
|
|
/* If we have absolute position clipping and we have, or will have, items to
|
|
|
|
* be clipped, wrap the list in a clip wrapper.
|
|
|
|
*/
|
2012-03-02 08:28:56 +00:00
|
|
|
if (applyClipPropClipping &&
|
2011-09-08 11:15:00 +00:00
|
|
|
(!resultList.IsEmpty() || usingSVGEffects)) {
|
2012-03-02 08:28:56 +00:00
|
|
|
nsDisplayClipPropWrapper wrapper(clipPropClip);
|
2006-01-26 02:29:17 +00:00
|
|
|
nsDisplayItem* item = wrapper.WrapList(aBuilder, this, &resultList);
|
|
|
|
if (!item)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
// resultList was emptied
|
|
|
|
resultList.AppendToTop(item);
|
|
|
|
}
|
2011-09-08 11:15:00 +00:00
|
|
|
/* If there are any SVG effects, wrap the list up in an SVG effects item
|
|
|
|
* (which also handles CSS group opacity). Note that we create an SVG effects
|
|
|
|
* item even if resultList is empty, since a filter can produce graphical
|
|
|
|
* output even if the element being filtered wouldn't otherwise do so.
|
|
|
|
*/
|
2008-09-11 00:24:16 +00:00
|
|
|
if (usingSVGEffects) {
|
2008-09-13 09:42:11 +00:00
|
|
|
/* List now emptied, so add the new list to the top. */
|
2010-08-13 10:01:13 +00:00
|
|
|
rv = resultList.AppendNewToTop(
|
|
|
|
new (aBuilder) nsDisplaySVGEffects(aBuilder, this, &resultList));
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
2011-09-08 11:15:00 +00:00
|
|
|
}
|
|
|
|
/* Else, if the list is non-empty and there is CSS group opacity without SVG
|
|
|
|
* effects, wrap it up in an opacity item.
|
2010-09-17 19:29:52 +00:00
|
|
|
*/
|
2012-07-31 17:28:21 +00:00
|
|
|
else if (HasOpacity() &&
|
2012-07-20 18:12:29 +00:00
|
|
|
!nsSVGUtils::CanOptimizeOpacity(this) &&
|
|
|
|
!resultList.IsEmpty()) {
|
2010-08-13 10:01:13 +00:00
|
|
|
rv = resultList.AppendNewToTop(
|
|
|
|
new (aBuilder) nsDisplayOpacity(aBuilder, this, &resultList));
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
2008-09-13 09:42:11 +00:00
|
|
|
}
|
|
|
|
|
2011-08-27 00:01:46 +00:00
|
|
|
/* If we're going to apply a transformation and don't have preserve-3d set, wrap
|
|
|
|
* everything in an nsDisplayTransform. If there's nothing in the list, don't add
|
|
|
|
* anything.
|
|
|
|
*
|
|
|
|
* For the preserve-3d case we want to individually wrap every child in the list with
|
|
|
|
* a separate nsDisplayTransform instead. When the child is already an nsDisplayTransform,
|
|
|
|
* we can skip this step, as the computed transform will already include our own.
|
|
|
|
*
|
|
|
|
* We also traverse into sublists created by nsDisplayWrapList or nsDisplayOpacity, so that
|
|
|
|
* we find all the correct children.
|
2008-09-13 09:42:11 +00:00
|
|
|
*/
|
2012-07-20 18:12:29 +00:00
|
|
|
if (IsTransformed() && !resultList.IsEmpty()) {
|
2011-08-27 00:01:46 +00:00
|
|
|
if (Preserves3DChildren()) {
|
|
|
|
rv = WrapPreserve3DList(this, aBuilder, &resultList);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
} else {
|
|
|
|
rv = resultList.AppendNewToTop(
|
2010-08-13 10:01:13 +00:00
|
|
|
new (aBuilder) nsDisplayTransform(aBuilder, this, &resultList));
|
2011-08-27 00:01:46 +00:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
}
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
2008-09-11 00:24:16 +00:00
|
|
|
|
2008-09-13 09:42:11 +00:00
|
|
|
aList->AppendToTop(&resultList);
|
2006-01-26 02:29:17 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2012-09-14 00:02:01 +00:00
|
|
|
static bool
|
|
|
|
IsRootScrollFrameActive(nsIPresShell* aPresShell)
|
|
|
|
{
|
|
|
|
nsIScrollableFrame* sf = aPresShell->GetRootScrollFrameAsScrollable();
|
|
|
|
return sf && sf->IsScrollingActive();
|
|
|
|
}
|
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
nsresult
|
|
|
|
nsIFrame::BuildDisplayListForChild(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsIFrame* aChild,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t aFlags) {
|
2006-01-26 02:29:17 +00:00
|
|
|
// If painting is restricted to just the background of the top level frame,
|
|
|
|
// then we have nothing to do here.
|
|
|
|
if (aBuilder->IsBackgroundOnly())
|
|
|
|
return NS_OK;
|
|
|
|
|
2011-11-08 00:09:39 +00:00
|
|
|
nsIFrame* child = aChild;
|
|
|
|
if (child->GetStateBits() & NS_FRAME_TOO_DEEP_IN_FRAME_TREE)
|
2006-01-26 02:29:17 +00:00
|
|
|
return NS_OK;
|
2012-07-20 18:12:29 +00:00
|
|
|
|
|
|
|
bool isSVG = (child->GetStateBits() & NS_FRAME_SVG_LAYOUT);
|
2011-04-29 23:02:33 +00:00
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
// true if this is a real or pseudo stacking context
|
2011-09-29 06:19:26 +00:00
|
|
|
bool pseudoStackingContext =
|
2006-01-26 02:29:17 +00:00
|
|
|
(aFlags & DISPLAY_CHILD_FORCE_PSEUDO_STACKING_CONTEXT) != 0;
|
2012-07-20 18:12:29 +00:00
|
|
|
if (!isSVG &&
|
|
|
|
(aFlags & DISPLAY_CHILD_INLINE) &&
|
2011-11-08 00:09:39 +00:00
|
|
|
!child->IsFrameOfType(eLineParticipant)) {
|
2006-09-19 20:58:36 +00:00
|
|
|
// child is a non-inline frame in an inline context, i.e.,
|
2006-01-26 02:29:17 +00:00
|
|
|
// it acts like inline-block or inline-table. Therefore it is a
|
|
|
|
// pseudo-stacking-context.
|
2011-10-17 14:59:28 +00:00
|
|
|
pseudoStackingContext = true;
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// dirty rect in child-relative coordinates
|
2011-11-08 00:09:39 +00:00
|
|
|
nsRect dirty = aDirtyRect - child->GetOffsetTo(this);
|
2006-01-26 02:29:17 +00:00
|
|
|
|
2011-11-08 00:09:39 +00:00
|
|
|
nsIAtom* childType = child->GetType();
|
2006-12-26 17:47:52 +00:00
|
|
|
if (childType == nsGkAtoms::placeholderFrame) {
|
2011-11-08 00:09:39 +00:00
|
|
|
nsPlaceholderFrame* placeholder = static_cast<nsPlaceholderFrame*>(child);
|
|
|
|
child = placeholder->GetOutOfFlowFrame();
|
|
|
|
NS_ASSERTION(child, "No out of flow frame?");
|
2011-11-08 00:09:39 +00:00
|
|
|
// If 'child' is a pushed float then it's owned by a block that's not an
|
|
|
|
// ancestor of the placeholder, and it will be painted by that block and
|
|
|
|
// should not be painted through the placeholder.
|
|
|
|
if (!child || nsLayoutUtils::IsPopup(child) ||
|
|
|
|
(child->GetStateBits() & NS_FRAME_IS_PUSHED_FLOAT))
|
2006-01-26 02:29:17 +00:00
|
|
|
return NS_OK;
|
2006-06-09 21:04:21 +00:00
|
|
|
// Make sure that any attempt to use childType below is disappointed. We
|
|
|
|
// could call GetType again but since we don't currently need it, let's
|
|
|
|
// avoid the virtual call.
|
2012-07-30 14:20:58 +00:00
|
|
|
childType = nullptr;
|
2007-07-21 00:34:36 +00:00
|
|
|
// Recheck NS_FRAME_TOO_DEEP_IN_FRAME_TREE
|
2011-11-08 00:09:39 +00:00
|
|
|
if (child->GetStateBits() & NS_FRAME_TOO_DEEP_IN_FRAME_TREE)
|
2006-01-26 02:29:17 +00:00
|
|
|
return NS_OK;
|
2007-07-08 07:08:04 +00:00
|
|
|
nsRect* savedDirty = static_cast<nsRect*>
|
2011-11-08 00:09:39 +00:00
|
|
|
(child->Properties().Get(nsDisplayListBuilder::OutOfFlowDirtyRectProperty()));
|
2006-01-26 02:29:17 +00:00
|
|
|
if (savedDirty) {
|
|
|
|
dirty = *savedDirty;
|
|
|
|
} else {
|
|
|
|
// The out-of-flow frame did not intersect the dirty area. We may still
|
|
|
|
// need to traverse into it, since it may contain placeholders we need
|
|
|
|
// to enter to reach other out-of-flow frames that are visible.
|
2011-04-19 03:07:23 +00:00
|
|
|
dirty.SetEmpty();
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
pseudoStackingContext = true;
|
2011-04-29 23:02:33 +00:00
|
|
|
}
|
2012-05-11 07:49:14 +00:00
|
|
|
if (child->Preserves3D()) {
|
|
|
|
nsRect* savedDirty = static_cast<nsRect*>
|
|
|
|
(child->Properties().Get(nsDisplayListBuilder::Preserve3DDirtyRectProperty()));
|
|
|
|
if (savedDirty) {
|
|
|
|
dirty = *savedDirty;
|
|
|
|
} else {
|
|
|
|
dirty.SetEmpty();
|
|
|
|
}
|
|
|
|
}
|
2011-04-29 23:02:33 +00:00
|
|
|
|
2011-11-08 00:09:39 +00:00
|
|
|
child->MarkAbsoluteFramesForDisplayList(aBuilder, dirty);
|
2011-04-29 23:02:33 +00:00
|
|
|
|
|
|
|
if (childType != nsGkAtoms::placeholderFrame &&
|
|
|
|
aBuilder->GetSelectedFramesOnly() &&
|
2011-11-08 00:09:39 +00:00
|
|
|
child->IsLeaf() &&
|
2011-12-20 09:15:41 +00:00
|
|
|
!aChild->IsSelected()) {
|
2010-07-12 20:24:33 +00:00
|
|
|
return NS_OK;
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
|
|
|
|
2010-12-07 13:54:50 +00:00
|
|
|
if (aBuilder->GetIncludeAllOutOfFlows() &&
|
2011-11-08 00:09:39 +00:00
|
|
|
(child->GetStateBits() & NS_FRAME_OUT_OF_FLOW)) {
|
|
|
|
dirty = child->GetVisualOverflowRect();
|
|
|
|
} else if (!(child->GetStateBits() & NS_FRAME_FORCE_DISPLAY_LIST_DESCEND_INTO)) {
|
|
|
|
// No need to descend into child to catch placeholders for visible
|
2006-09-19 22:05:33 +00:00
|
|
|
// positioned stuff. So see if we can short-circuit frame traversal here.
|
|
|
|
|
2011-11-08 00:09:39 +00:00
|
|
|
// We can stop if child's frame subtree's intersection with the
|
2009-03-30 00:29:36 +00:00
|
|
|
// dirty area is empty.
|
2006-09-19 22:05:33 +00:00
|
|
|
// If the child is a scrollframe that we want to ignore, then we need
|
|
|
|
// to descend into it because its scrolled child may intersect the dirty
|
|
|
|
// area even if the scrollframe itself doesn't.
|
2011-11-08 00:09:39 +00:00
|
|
|
if (child != aBuilder->GetIgnoreScrollFrame()) {
|
2009-03-30 00:29:36 +00:00
|
|
|
nsRect childDirty;
|
2012-04-09 17:44:32 +00:00
|
|
|
if (!childDirty.IntersectRect(dirty, child->GetVisualOverflowRect()))
|
2009-03-30 00:29:36 +00:00
|
|
|
return NS_OK;
|
|
|
|
// Usually we could set dirty to childDirty now but there's no
|
|
|
|
// benefit, and it can be confusing. It can especially confuse
|
|
|
|
// situations where we're going to ignore a scrollframe's clipping;
|
|
|
|
// we wouldn't want to clip the dirty area to the scrollframe's
|
|
|
|
// bounds in that case.
|
|
|
|
}
|
2006-09-19 22:05:33 +00:00
|
|
|
}
|
2006-01-26 02:29:17 +00:00
|
|
|
|
|
|
|
// XXX need to have inline-block and inline-table set pseudoStackingContext
|
|
|
|
|
|
|
|
const nsStyleDisplay* ourDisp = GetStyleDisplay();
|
|
|
|
// REVIEW: Taken from nsBoxFrame::Paint
|
|
|
|
// Don't paint our children if the theme object is a leaf.
|
|
|
|
if (IsThemed(ourDisp) &&
|
2007-03-30 21:11:41 +00:00
|
|
|
!PresContext()->GetTheme()->WidgetIsContainer(ourDisp->mAppearance))
|
2006-01-26 02:29:17 +00:00
|
|
|
return NS_OK;
|
|
|
|
|
2008-09-13 09:42:11 +00:00
|
|
|
// Child is composited if it's transformed, partially transparent, or has
|
|
|
|
// SVG effects.
|
2011-11-08 00:09:39 +00:00
|
|
|
const nsStyleDisplay* disp = child->GetStyleDisplay();
|
2012-07-31 17:28:21 +00:00
|
|
|
bool isVisuallyAtomic = child->HasOpacity()
|
2011-11-08 00:09:39 +00:00
|
|
|
|| child->IsTransformed()
|
|
|
|
|| nsSVGIntegrationUtils::UsingEffectsForFrame(child);
|
2011-05-30 07:34:50 +00:00
|
|
|
|
2012-08-02 11:38:50 +00:00
|
|
|
bool isPositioned = !isSVG && disp->IsPositioned(child);
|
2012-08-02 11:38:49 +00:00
|
|
|
if (isVisuallyAtomic || isPositioned || (!isSVG && disp->IsFloating(child)) ||
|
2012-07-20 18:12:29 +00:00
|
|
|
((disp->mClipFlags & NS_STYLE_CLIP_RECT) &&
|
2012-07-26 12:21:04 +00:00
|
|
|
IsSVGContentWithCSSClip(child)) ||
|
2009-08-31 18:25:35 +00:00
|
|
|
(aFlags & DISPLAY_CHILD_FORCE_STACKING_CONTEXT)) {
|
2006-01-26 02:29:17 +00:00
|
|
|
// If you change this, also change IsPseudoStackingContextFromStyle()
|
2011-10-17 14:59:28 +00:00
|
|
|
pseudoStackingContext = true;
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
2012-04-18 05:14:14 +00:00
|
|
|
|
2012-07-25 07:06:19 +00:00
|
|
|
// This controls later whether we build an nsDisplayWrapList or an
|
|
|
|
// nsDisplayFixedPosition. We check if we're already building a fixed-pos
|
|
|
|
// item and disallow nesting, to prevent the situation of bug #769541
|
|
|
|
// occurring.
|
2012-09-14 00:02:01 +00:00
|
|
|
// Don't build an nsDisplayFixedPosition if our root scroll frame is not
|
|
|
|
// active, that's pointless and the extra layer(s) created may be wasteful.
|
|
|
|
bool buildFixedPositionItem = disp->mPosition == NS_STYLE_POSITION_FIXED &&
|
|
|
|
!child->GetParent()->GetParent() && !aBuilder->IsInFixedPosition() &&
|
|
|
|
IsRootScrollFrameActive(PresContext()->PresShell()) && !isSVG;
|
2012-07-25 07:06:19 +00:00
|
|
|
|
2012-04-18 05:14:14 +00:00
|
|
|
nsDisplayListBuilder::AutoBuildingDisplayList
|
2012-07-25 07:06:19 +00:00
|
|
|
buildingForChild(aBuilder, child, pseudoStackingContext, buildFixedPositionItem);
|
2012-04-18 05:14:14 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
nsRect overflowClip;
|
2010-09-09 15:21:46 +00:00
|
|
|
nscoord overflowClipRadii[8];
|
2011-09-29 06:19:26 +00:00
|
|
|
bool applyOverflowClip =
|
2011-11-08 00:09:39 +00:00
|
|
|
ApplyOverflowClipping(aBuilder, child, disp, &overflowClip);
|
2010-09-09 15:21:46 +00:00
|
|
|
if (applyOverflowClip) {
|
2011-11-08 00:09:39 +00:00
|
|
|
child->GetPaddingBoxBorderRadii(overflowClipRadii);
|
2010-09-09 15:21:46 +00:00
|
|
|
}
|
2006-01-26 02:29:17 +00:00
|
|
|
// Don't use overflowClip to restrict the dirty rect, since some of the
|
|
|
|
// descendants may not be clipped by it. Even if we end up with unnecessary
|
2009-09-07 00:35:14 +00:00
|
|
|
// display items, they'll be pruned during ComputeVisibility. Note that
|
2006-01-26 02:29:17 +00:00
|
|
|
// this overflow-clipping here only applies to overflow:-moz-hidden-unscrollable;
|
|
|
|
// overflow:hidden etc creates an nsHTML/XULScrollFrame which does its own
|
|
|
|
// clipping.
|
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
if (!pseudoStackingContext) {
|
|
|
|
// THIS IS THE COMMON CASE.
|
|
|
|
// Not a pseudo or real stacking context. Do the simple thing and
|
|
|
|
// return early.
|
|
|
|
if (applyOverflowClip) {
|
2011-11-08 00:09:39 +00:00
|
|
|
rv = BuildDisplayListWithOverflowClip(aBuilder, child, dirty, aLists,
|
2010-09-09 15:21:46 +00:00
|
|
|
overflowClip, overflowClipRadii);
|
2006-01-26 02:29:17 +00:00
|
|
|
} else {
|
2011-11-08 00:09:39 +00:00
|
|
|
rv = child->BuildDisplayList(aBuilder, dirty, aLists);
|
2006-04-17 23:16:46 +00:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2011-11-08 00:09:39 +00:00
|
|
|
rv = aBuilder->DisplayCaret(child, dirty, aLists.Content());
|
2006-04-17 23:16:46 +00:00
|
|
|
}
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
2012-06-25 19:59:42 +00:00
|
|
|
#ifdef DEBUG
|
2011-11-08 00:09:39 +00:00
|
|
|
DisplayDebugBorders(aBuilder, child, aLists);
|
2007-02-20 20:22:19 +00:00
|
|
|
#endif
|
2006-04-17 23:16:46 +00:00
|
|
|
return rv;
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsDisplayList list;
|
|
|
|
nsDisplayList extraPositionedDescendants;
|
2011-11-08 00:09:39 +00:00
|
|
|
const nsStylePosition* pos = child->GetStylePosition();
|
2006-01-26 02:29:17 +00:00
|
|
|
if ((isPositioned && pos->mZIndex.GetUnit() == eStyleUnit_Integer) ||
|
2011-09-08 11:15:00 +00:00
|
|
|
isVisuallyAtomic || (aFlags & DISPLAY_CHILD_FORCE_STACKING_CONTEXT)) {
|
2006-01-26 02:29:17 +00:00
|
|
|
// True stacking context
|
2011-11-08 00:09:39 +00:00
|
|
|
rv = child->BuildDisplayListForStackingContext(aBuilder, dirty, &list);
|
2006-04-17 23:16:46 +00:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2011-11-08 00:09:39 +00:00
|
|
|
rv = aBuilder->DisplayCaret(child, dirty, &list);
|
2006-04-17 23:16:46 +00:00
|
|
|
}
|
2006-01-26 02:29:17 +00:00
|
|
|
} else {
|
|
|
|
nsRect clipRect;
|
2012-03-02 08:28:56 +00:00
|
|
|
bool applyClipPropClipping =
|
|
|
|
ApplyClipPropClipping(aBuilder, disp, child, &clipRect);
|
2007-10-19 17:41:29 +00:00
|
|
|
// A pseudo-stacking context (e.g., a positioned element with z-index auto).
|
2011-09-08 11:15:00 +00:00
|
|
|
// We allow positioned descendants of the child to escape to our parent
|
|
|
|
// stacking context's positioned descendant list, because they might be
|
2006-01-26 02:29:17 +00:00
|
|
|
// z-index:non-auto
|
|
|
|
nsDisplayListCollection pseudoStack;
|
|
|
|
nsRect clippedDirtyRect = dirty;
|
2012-03-02 08:28:56 +00:00
|
|
|
if (applyClipPropClipping) {
|
2006-01-26 02:29:17 +00:00
|
|
|
// clipRect is in builder-reference-frame coordinates,
|
2011-11-08 00:09:39 +00:00
|
|
|
// dirty/clippedDirtyRect are in child coordinates
|
2006-01-26 02:29:17 +00:00
|
|
|
clippedDirtyRect.IntersectRect(clippedDirtyRect,
|
2011-11-08 00:09:39 +00:00
|
|
|
clipRect - aBuilder->ToReferenceFrame(child));
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (applyOverflowClip) {
|
2011-11-08 00:09:39 +00:00
|
|
|
rv = BuildDisplayListWithOverflowClip(aBuilder, child, clippedDirtyRect,
|
2010-09-09 15:21:46 +00:00
|
|
|
pseudoStack, overflowClip,
|
|
|
|
overflowClipRadii);
|
2006-01-26 02:29:17 +00:00
|
|
|
} else {
|
2011-11-08 00:09:39 +00:00
|
|
|
rv = child->BuildDisplayList(aBuilder, clippedDirtyRect, pseudoStack);
|
2006-04-17 23:16:46 +00:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2011-11-08 00:09:39 +00:00
|
|
|
rv = aBuilder->DisplayCaret(child, dirty, pseudoStack.Content());
|
2006-04-17 23:16:46 +00:00
|
|
|
}
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2012-03-02 08:28:56 +00:00
|
|
|
if (applyClipPropClipping) {
|
|
|
|
nsDisplayClipPropWrapper wrapper(clipRect);
|
2011-11-08 00:09:39 +00:00
|
|
|
rv = wrapper.WrapListsInPlace(aBuilder, child, pseudoStack);
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
list.AppendToTop(pseudoStack.BorderBackground());
|
|
|
|
list.AppendToTop(pseudoStack.BlockBorderBackgrounds());
|
|
|
|
list.AppendToTop(pseudoStack.Floats());
|
|
|
|
list.AppendToTop(pseudoStack.Content());
|
2007-07-19 03:50:24 +00:00
|
|
|
list.AppendToTop(pseudoStack.Outlines());
|
2006-01-26 02:29:17 +00:00
|
|
|
extraPositionedDescendants.AppendToTop(pseudoStack.PositionedDescendants());
|
2012-06-25 19:59:42 +00:00
|
|
|
#ifdef DEBUG
|
2011-11-08 00:09:39 +00:00
|
|
|
DisplayDebugBorders(aBuilder, child, aLists);
|
2007-02-20 20:22:19 +00:00
|
|
|
#endif
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2011-09-08 11:15:00 +00:00
|
|
|
if (isPositioned || isVisuallyAtomic ||
|
2006-08-03 21:39:39 +00:00
|
|
|
(aFlags & DISPLAY_CHILD_FORCE_STACKING_CONTEXT)) {
|
2006-01-26 02:29:17 +00:00
|
|
|
// Genuine stacking contexts, and positioned pseudo-stacking-contexts,
|
|
|
|
// go in this level.
|
2012-04-16 05:43:47 +00:00
|
|
|
if (!list.IsEmpty()) {
|
2012-06-27 15:43:57 +00:00
|
|
|
// Make sure the root of a fixed position frame sub-tree gets the
|
|
|
|
// correct displaylist item type.
|
|
|
|
nsDisplayItem* item;
|
2012-07-25 07:06:19 +00:00
|
|
|
if (buildFixedPositionItem) {
|
|
|
|
item = new (aBuilder) nsDisplayFixedPosition(aBuilder, child, child, &list);
|
2012-06-27 15:43:57 +00:00
|
|
|
} else {
|
|
|
|
item = new (aBuilder) nsDisplayWrapList(aBuilder, child, &list);
|
|
|
|
}
|
2012-07-20 18:12:29 +00:00
|
|
|
if (isSVG) {
|
|
|
|
rv = aLists.Content()->AppendNewToTop(item);
|
|
|
|
} else {
|
|
|
|
rv = aLists.PositionedDescendants()->AppendNewToTop(item);
|
|
|
|
}
|
2012-04-16 05:43:47 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2012-07-25 07:06:19 +00:00
|
|
|
|
|
|
|
// Make sure that extra positioned descendants don't escape having
|
|
|
|
// their fixed-position metadata applied to them.
|
|
|
|
if (buildFixedPositionItem) {
|
|
|
|
while (!extraPositionedDescendants.IsEmpty()) {
|
|
|
|
item = extraPositionedDescendants.RemoveBottom();
|
|
|
|
nsDisplayList fixedPosDescendantList;
|
|
|
|
fixedPosDescendantList.AppendToTop(item);
|
|
|
|
aLists.PositionedDescendants()->AppendNewToTop(
|
|
|
|
new (aBuilder) nsDisplayFixedPosition(aBuilder, item->GetUnderlyingFrame(),
|
|
|
|
child, &fixedPosDescendantList));
|
|
|
|
}
|
|
|
|
}
|
2012-04-16 05:43:47 +00:00
|
|
|
}
|
2012-08-02 11:38:49 +00:00
|
|
|
} else if (!isSVG && disp->IsFloating(child)) {
|
2012-04-16 05:43:47 +00:00
|
|
|
if (!list.IsEmpty()) {
|
|
|
|
rv = aLists.Floats()->AppendNewToTop(new (aBuilder)
|
|
|
|
nsDisplayWrapList(aBuilder, child, &list));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
2006-01-26 02:29:17 +00:00
|
|
|
} else {
|
|
|
|
aLists.Content()->AppendToTop(&list);
|
|
|
|
}
|
|
|
|
// We delay placing the positioned descendants of positioned frames to here,
|
|
|
|
// because in the absence of z-index this is the correct order for them.
|
|
|
|
// This doesn't affect correctness because the positioned descendants list
|
|
|
|
// is sorted by z-order and content in BuildDisplayListForStackingContext,
|
|
|
|
// but it means that sort routine needs to do less work.
|
|
|
|
aLists.PositionedDescendants()->AppendToTop(&extraPositionedDescendants);
|
|
|
|
return NS_OK;
|
2002-12-23 22:05:47 +00:00
|
|
|
}
|
|
|
|
|
2011-04-29 23:02:33 +00:00
|
|
|
void
|
|
|
|
nsIFrame::MarkAbsoluteFramesForDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect)
|
|
|
|
{
|
|
|
|
if (IsAbsoluteContainer()) {
|
|
|
|
aBuilder->MarkFramesForDisplayList(this, GetAbsoluteContainingBlock()->GetChildList(), aDirtyRect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-09 15:21:47 +00:00
|
|
|
void
|
|
|
|
nsIFrame::WrapReplacedContentForBorderRadius(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsDisplayList* aFromList,
|
|
|
|
const nsDisplayListSet& aToLists)
|
|
|
|
{
|
|
|
|
nscoord radii[8];
|
|
|
|
if (GetContentBoxBorderRadii(radii)) {
|
|
|
|
// If we have a border-radius, we have to clip our content to that
|
|
|
|
// radius.
|
|
|
|
nsDisplayListCollection set;
|
|
|
|
set.Content()->AppendToTop(aFromList);
|
|
|
|
nsRect clipRect = GetContentRect() - GetPosition() +
|
|
|
|
aBuilder->ToReferenceFrame(this);
|
2011-10-17 14:59:28 +00:00
|
|
|
OverflowClip(aBuilder, set, aToLists, clipRect, radii, false, true);
|
2010-09-09 15:21:47 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
aToLists.Content()->AppendToTop(aFromList);
|
|
|
|
}
|
|
|
|
|
2000-02-11 01:24:59 +00:00
|
|
|
NS_IMETHODIMP
|
2011-09-26 20:55:04 +00:00
|
|
|
nsFrame::GetContentForEvent(nsEvent* aEvent,
|
2000-02-11 01:24:59 +00:00
|
|
|
nsIContent** aContent)
|
|
|
|
{
|
2009-09-02 02:46:33 +00:00
|
|
|
nsIFrame* f = nsLayoutUtils::GetNonGeneratedAncestor(this);
|
|
|
|
*aContent = f->GetContent();
|
2003-06-27 18:13:48 +00:00
|
|
|
NS_IF_ADDREF(*aContent);
|
|
|
|
return NS_OK;
|
2000-02-11 01:24:59 +00:00
|
|
|
}
|
|
|
|
|
2006-05-03 17:02:37 +00:00
|
|
|
void
|
|
|
|
nsFrame::FireDOMEvent(const nsAString& aDOMEventName, nsIContent *aContent)
|
|
|
|
{
|
2009-03-06 18:12:20 +00:00
|
|
|
nsIContent* target = aContent ? aContent : mContent;
|
|
|
|
|
|
|
|
if (target) {
|
2011-12-17 06:02:05 +00:00
|
|
|
nsRefPtr<nsAsyncDOMEvent> event =
|
|
|
|
new nsAsyncDOMEvent(target, aDOMEventName, true, false);
|
2011-04-29 05:02:16 +00:00
|
|
|
if (NS_FAILED(event->PostDOMEvent()))
|
2011-12-17 06:02:05 +00:00
|
|
|
NS_WARNING("Failed to dispatch nsAsyncDOMEvent");
|
2006-05-03 17:02:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-18 15:54:23 +00:00
|
|
|
NS_IMETHODIMP
|
2004-07-31 23:15:21 +00:00
|
|
|
nsFrame::HandleEvent(nsPresContext* aPresContext,
|
1998-12-18 15:54:23 +00:00
|
|
|
nsGUIEvent* aEvent,
|
1999-11-24 06:03:41 +00:00
|
|
|
nsEventStatus* aEventStatus)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2006-11-16 21:35:39 +00:00
|
|
|
|
2012-07-09 16:55:35 +00:00
|
|
|
if (aEvent->message == NS_MOUSE_MOVE || aEvent->message == NS_TOUCH_MOVE) {
|
2006-11-16 21:35:39 +00:00
|
|
|
return HandleDrag(aPresContext, aEvent, aEventStatus);
|
|
|
|
}
|
|
|
|
|
2012-07-09 16:55:35 +00:00
|
|
|
if ((aEvent->eventStructType == NS_MOUSE_EVENT &&
|
|
|
|
static_cast<nsMouseEvent*>(aEvent)->button == nsMouseEvent::eLeftButton) ||
|
|
|
|
aEvent->eventStructType == NS_TOUCH_EVENT) {
|
|
|
|
if (aEvent->message == NS_MOUSE_BUTTON_DOWN || aEvent->message == NS_TOUCH_START) {
|
2003-12-21 05:36:36 +00:00
|
|
|
HandlePress(aPresContext, aEvent, aEventStatus);
|
2012-07-09 16:55:35 +00:00
|
|
|
} else if (aEvent->message == NS_MOUSE_BUTTON_UP || aEvent->message == NS_TOUCH_END) {
|
2003-12-21 05:36:36 +00:00
|
|
|
HandleRelease(aPresContext, aEvent, aEventStatus);
|
2006-11-16 21:35:39 +00:00
|
|
|
}
|
|
|
|
}
|
1998-04-27 16:44:52 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-03-16 23:45:39 +00:00
|
|
|
NS_IMETHODIMP
|
2007-11-22 20:47:33 +00:00
|
|
|
nsFrame::GetDataForTableSelection(const nsFrameSelection *aFrameSelection,
|
2002-03-22 15:25:08 +00:00
|
|
|
nsIPresShell *aPresShell, nsMouseEvent *aMouseEvent,
|
2012-08-22 15:56:38 +00:00
|
|
|
nsIContent **aParentContent, int32_t *aContentOffset, int32_t *aTarget)
|
2000-03-16 23:45:39 +00:00
|
|
|
{
|
2002-03-22 15:25:08 +00:00
|
|
|
if (!aFrameSelection || !aPresShell || !aMouseEvent || !aParentContent || !aContentOffset || !aTarget)
|
2000-03-16 23:45:39 +00:00
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
*aParentContent = nullptr;
|
2000-03-16 23:45:39 +00:00
|
|
|
*aContentOffset = 0;
|
|
|
|
*aTarget = 0;
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int16_t displaySelection = aPresShell->GetSelectionFlags();
|
2002-03-22 15:25:08 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool selectingTableCells = aFrameSelection->GetTableCellSelection();
|
2002-03-22 15:25:08 +00:00
|
|
|
|
|
|
|
// DISPLAY_ALL means we're in an editor.
|
|
|
|
// If already in cell selection mode,
|
|
|
|
// continue selecting with mouse drag or end on mouse up,
|
|
|
|
// or when using shift key to extend block of cells
|
|
|
|
// (Mouse down does normal selection unless Ctrl/Cmd is pressed)
|
2011-09-29 06:19:26 +00:00
|
|
|
bool doTableSelection =
|
2002-03-22 15:25:08 +00:00
|
|
|
displaySelection == nsISelectionDisplay::DISPLAY_ALL && selectingTableCells &&
|
|
|
|
(aMouseEvent->message == NS_MOUSE_MOVE ||
|
2006-11-16 21:35:39 +00:00
|
|
|
(aMouseEvent->message == NS_MOUSE_BUTTON_UP &&
|
|
|
|
aMouseEvent->button == nsMouseEvent::eLeftButton) ||
|
2012-04-25 03:00:02 +00:00
|
|
|
aMouseEvent->IsShift());
|
2002-03-22 15:25:08 +00:00
|
|
|
|
|
|
|
if (!doTableSelection)
|
|
|
|
{
|
|
|
|
// In Browser, special 'table selection' key must be pressed for table selection
|
|
|
|
// or when just Shift is pressed and we're already in table/cell selection mode
|
2007-10-01 23:20:37 +00:00
|
|
|
#ifdef XP_MACOSX
|
2012-04-25 03:00:02 +00:00
|
|
|
doTableSelection = aMouseEvent->IsMeta() || (aMouseEvent->IsShift() && selectingTableCells);
|
2000-03-16 23:45:39 +00:00
|
|
|
#else
|
2012-04-25 03:00:02 +00:00
|
|
|
doTableSelection = aMouseEvent->IsControl() || (aMouseEvent->IsShift() && selectingTableCells);
|
2000-03-16 23:45:39 +00:00
|
|
|
#endif
|
2000-05-31 00:07:58 +00:00
|
|
|
}
|
2002-03-22 15:25:08 +00:00
|
|
|
if (!doTableSelection)
|
|
|
|
return NS_OK;
|
2000-03-16 23:45:39 +00:00
|
|
|
|
|
|
|
// Get the cell frame or table frame (or parent) of the current content node
|
|
|
|
nsIFrame *frame = this;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool foundCell = false;
|
|
|
|
bool foundTable = false;
|
2000-08-02 01:47:55 +00:00
|
|
|
|
|
|
|
// Get the limiting node to stop parent frame search
|
2006-04-26 02:01:07 +00:00
|
|
|
nsIContent* limiter = aFrameSelection->GetLimiter();
|
2000-08-02 01:47:55 +00:00
|
|
|
|
2010-11-01 23:04:12 +00:00
|
|
|
// If our content node is an ancestor of the limiting node,
|
|
|
|
// we should stop the search right now.
|
|
|
|
if (limiter && nsContentUtils::ContentIsDescendantOf(limiter, GetContent()))
|
|
|
|
return NS_OK;
|
|
|
|
|
2000-05-31 00:07:58 +00:00
|
|
|
//We don't initiate row/col selection from here now,
|
|
|
|
// but we may in future
|
2011-09-29 06:19:26 +00:00
|
|
|
//bool selectColumn = false;
|
|
|
|
//bool selectRow = false;
|
2006-04-26 02:01:07 +00:00
|
|
|
|
2010-03-20 21:54:19 +00:00
|
|
|
while (frame)
|
2000-03-16 23:45:39 +00:00
|
|
|
{
|
|
|
|
// Check for a table cell by querying to a known CellFrame interface
|
2009-01-12 19:20:59 +00:00
|
|
|
nsITableCellLayout *cellElement = do_QueryFrame(frame);
|
|
|
|
if (cellElement)
|
2000-03-16 23:45:39 +00:00
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
foundCell = true;
|
2000-05-31 00:07:58 +00:00
|
|
|
//TODO: If we want to use proximity to top or left border
|
|
|
|
// for row and column selection, this is the place to do it
|
2000-03-16 23:45:39 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// If not a cell, check for table
|
|
|
|
// This will happen when starting frame is the table or child of a table,
|
|
|
|
// such as a row (we were inbetween cells or in table border)
|
2009-01-12 19:20:59 +00:00
|
|
|
nsITableLayout *tableElement = do_QueryFrame(frame);
|
|
|
|
if (tableElement)
|
2000-03-16 23:45:39 +00:00
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
foundTable = true;
|
2000-05-16 03:03:13 +00:00
|
|
|
//TODO: How can we select row when along left table edge
|
|
|
|
// or select column when along top edge?
|
2000-03-16 23:45:39 +00:00
|
|
|
break;
|
2000-03-21 06:04:02 +00:00
|
|
|
} else {
|
2003-06-27 18:13:48 +00:00
|
|
|
frame = frame->GetParent();
|
2000-08-02 01:47:55 +00:00
|
|
|
// Stop if we have hit the selection's limiting content node
|
2006-04-26 02:01:07 +00:00
|
|
|
if (frame && frame->GetContent() == limiter)
|
2003-06-27 18:13:48 +00:00
|
|
|
break;
|
2000-03-16 23:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// We aren't in a cell or table
|
|
|
|
if (!foundCell && !foundTable) return NS_OK;
|
|
|
|
|
2003-06-27 18:13:48 +00:00
|
|
|
nsIContent* tableOrCellContent = frame->GetContent();
|
2000-03-16 23:45:39 +00:00
|
|
|
if (!tableOrCellContent) return NS_ERROR_FAILURE;
|
|
|
|
|
2003-07-28 21:25:13 +00:00
|
|
|
nsCOMPtr<nsIContent> parentContent = tableOrCellContent->GetParent();
|
2000-03-16 23:45:39 +00:00
|
|
|
if (!parentContent) return NS_ERROR_FAILURE;
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t offset = parentContent->IndexOf(tableOrCellContent);
|
2000-03-16 23:45:39 +00:00
|
|
|
// Not likely?
|
|
|
|
if (offset < 0) return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
// Everything is OK -- set the return values
|
|
|
|
*aParentContent = parentContent;
|
|
|
|
NS_ADDREF(*aParentContent);
|
|
|
|
|
|
|
|
*aContentOffset = offset;
|
|
|
|
|
2000-05-31 00:07:58 +00:00
|
|
|
#if 0
|
2000-05-16 03:03:13 +00:00
|
|
|
if (selectRow)
|
2000-12-20 22:13:54 +00:00
|
|
|
*aTarget = nsISelectionPrivate::TABLESELECTION_ROW;
|
2000-05-16 03:03:13 +00:00
|
|
|
else if (selectColumn)
|
2000-12-20 22:13:54 +00:00
|
|
|
*aTarget = nsISelectionPrivate::TABLESELECTION_COLUMN;
|
2000-05-31 00:07:58 +00:00
|
|
|
else
|
|
|
|
#endif
|
|
|
|
if (foundCell)
|
2000-12-20 22:13:54 +00:00
|
|
|
*aTarget = nsISelectionPrivate::TABLESELECTION_CELL;
|
2000-05-16 03:03:13 +00:00
|
|
|
else if (foundTable)
|
2000-12-20 22:13:54 +00:00
|
|
|
*aTarget = nsISelectionPrivate::TABLESELECTION_TABLE;
|
2000-03-16 23:45:39 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-08-08 23:48:42 +00:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsFrame::IsSelectable(bool* aSelectable, uint8_t* aSelectStyle) const
|
2000-08-08 23:48:42 +00:00
|
|
|
{
|
2005-11-20 22:05:24 +00:00
|
|
|
if (!aSelectable) //it's ok if aSelectStyle is null
|
2000-08-12 01:00:14 +00:00
|
|
|
return NS_ERROR_NULL_POINTER;
|
2000-08-05 04:41:33 +00:00
|
|
|
|
|
|
|
// Like 'visibility', we must check all the parents: if a parent
|
|
|
|
// is not selectable, none of its children is selectable.
|
2000-08-12 01:00:14 +00:00
|
|
|
//
|
|
|
|
// The -moz-all value acts similarly: if a frame has 'user-select:-moz-all',
|
|
|
|
// all its children are selectable, even those with 'user-select:none'.
|
|
|
|
//
|
|
|
|
// As a result, if 'none' and '-moz-all' are not present in the frame hierarchy,
|
|
|
|
// aSelectStyle returns the first style that is not AUTO. If these values
|
|
|
|
// are present in the frame hierarchy, aSelectStyle returns the style of the
|
|
|
|
// topmost parent that has either 'none' or '-moz-all'.
|
|
|
|
//
|
|
|
|
// For instance, if the frame hierarchy is:
|
|
|
|
// AUTO -> _MOZ_ALL -> NONE -> TEXT, the returned value is _MOZ_ALL
|
|
|
|
// TEXT -> NONE -> AUTO -> _MOZ_ALL, the returned value is NONE
|
|
|
|
// _MOZ_ALL -> TEXT -> AUTO -> AUTO, the returned value is _MOZ_ALL
|
|
|
|
// AUTO -> CELL -> TEXT -> AUTO, the returned value is TEXT
|
|
|
|
//
|
2012-08-22 15:56:38 +00:00
|
|
|
uint8_t selectStyle = NS_STYLE_USER_SELECT_AUTO;
|
2000-08-12 01:00:14 +00:00
|
|
|
nsIFrame* frame = (nsIFrame*)this;
|
|
|
|
|
2003-06-27 18:13:48 +00:00
|
|
|
while (frame) {
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleUIReset* userinterface = frame->GetStyleUIReset();
|
|
|
|
switch (userinterface->mUserSelect) {
|
|
|
|
case NS_STYLE_USER_SELECT_ALL:
|
|
|
|
case NS_STYLE_USER_SELECT_NONE:
|
|
|
|
case NS_STYLE_USER_SELECT_MOZ_ALL:
|
|
|
|
// override the previous values
|
|
|
|
selectStyle = userinterface->mUserSelect;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// otherwise return the first value which is not 'auto'
|
|
|
|
if (selectStyle == NS_STYLE_USER_SELECT_AUTO) {
|
2000-08-08 23:48:42 +00:00
|
|
|
selectStyle = userinterface->mUserSelect;
|
2003-05-15 03:42:21 +00:00
|
|
|
}
|
|
|
|
break;
|
2000-05-16 22:16:05 +00:00
|
|
|
}
|
2003-06-27 18:13:48 +00:00
|
|
|
frame = frame->GetParent();
|
2000-05-16 22:16:05 +00:00
|
|
|
}
|
2000-08-08 23:48:42 +00:00
|
|
|
|
2000-08-12 01:00:14 +00:00
|
|
|
// convert internal values to standard values
|
|
|
|
if (selectStyle == NS_STYLE_USER_SELECT_AUTO)
|
|
|
|
selectStyle = NS_STYLE_USER_SELECT_TEXT;
|
|
|
|
else
|
|
|
|
if (selectStyle == NS_STYLE_USER_SELECT_MOZ_ALL)
|
|
|
|
selectStyle = NS_STYLE_USER_SELECT_ALL;
|
2005-09-11 19:22:57 +00:00
|
|
|
else
|
|
|
|
if (selectStyle == NS_STYLE_USER_SELECT_MOZ_NONE)
|
|
|
|
selectStyle = NS_STYLE_USER_SELECT_NONE;
|
2000-08-12 01:00:14 +00:00
|
|
|
|
|
|
|
// return stuff
|
|
|
|
if (aSelectStyle)
|
|
|
|
*aSelectStyle = selectStyle;
|
2001-06-20 04:40:17 +00:00
|
|
|
if (mState & NS_FRAME_GENERATED_CONTENT)
|
2011-10-17 14:59:28 +00:00
|
|
|
*aSelectable = false;
|
2011-10-05 23:49:15 +00:00
|
|
|
else
|
|
|
|
*aSelectable = (selectStyle != NS_STYLE_USER_SELECT_NONE);
|
2000-08-05 04:41:33 +00:00
|
|
|
return NS_OK;
|
2000-04-12 03:04:11 +00:00
|
|
|
}
|
|
|
|
|
1998-05-08 18:33:42 +00:00
|
|
|
/**
|
|
|
|
* Handles the Mouse Press Event for the frame
|
|
|
|
*/
|
1999-02-12 17:45:58 +00:00
|
|
|
NS_IMETHODIMP
|
2004-07-31 23:15:21 +00:00
|
|
|
nsFrame::HandlePress(nsPresContext* aPresContext,
|
1999-02-12 17:45:58 +00:00
|
|
|
nsGUIEvent* aEvent,
|
1999-11-24 06:03:41 +00:00
|
|
|
nsEventStatus* aEventStatus)
|
1998-04-27 16:44:52 +00:00
|
|
|
{
|
massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-08 21:31:05 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aEventStatus);
|
|
|
|
if (nsEventStatus_eConsumeNoDefault == *aEventStatus) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-09-14 08:47:46 +00:00
|
|
|
|
2012-07-12 21:14:29 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aEvent);
|
|
|
|
if (aEvent->eventStructType == NS_TOUCH_EVENT) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-02-20 07:23:35 +00:00
|
|
|
//We often get out of sync state issues with mousedown events that
|
|
|
|
//get interrupted by alerts/dialogs.
|
|
|
|
//Check with the ESM to see if we should process this one
|
2011-04-21 17:35:52 +00:00
|
|
|
if (!aPresContext->EventStateManager()->EventStatusOK(aEvent))
|
2002-02-20 07:23:35 +00:00
|
|
|
return NS_OK;
|
|
|
|
|
2000-08-08 23:48:42 +00:00
|
|
|
nsresult rv;
|
2003-12-21 05:36:36 +00:00
|
|
|
nsIPresShell *shell = aPresContext->GetPresShell();
|
2000-09-14 08:47:46 +00:00
|
|
|
if (!shell)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2004-07-30 06:04:57 +00:00
|
|
|
// if we are in Navigator and the click is in a draggable node, we don't want
|
|
|
|
// to start selection because we don't want to interfere with a potential
|
|
|
|
// drag of said node and steal all its glory.
|
2012-08-22 15:56:38 +00:00
|
|
|
int16_t isEditor = shell->GetSelectionFlags();
|
2010-03-20 21:54:19 +00:00
|
|
|
//weaaak. only the editor can display frame selection not just text and images
|
2001-12-18 01:29:49 +00:00
|
|
|
isEditor = isEditor == nsISelectionDisplay::DISPLAY_ALL;
|
|
|
|
|
2005-08-23 03:57:07 +00:00
|
|
|
nsInputEvent* keyEvent = (nsInputEvent*)aEvent;
|
2012-04-25 03:00:02 +00:00
|
|
|
if (!keyEvent->IsAlt()) {
|
2002-04-01 04:27:50 +00:00
|
|
|
|
2003-07-28 21:25:13 +00:00
|
|
|
for (nsIContent* content = mContent; content;
|
|
|
|
content = content->GetParent()) {
|
2008-04-18 13:27:02 +00:00
|
|
|
if (nsContentUtils::ContentIsDraggable(content) &&
|
|
|
|
!content->IsEditable()) {
|
2004-07-30 06:04:57 +00:00
|
|
|
// coordinate stuff is the fix for bug #55921
|
2005-08-23 03:57:07 +00:00
|
|
|
if ((mRect - GetPosition()).Contains(
|
|
|
|
nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, this)))
|
2004-07-30 06:04:57 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
2008-04-18 13:27:02 +00:00
|
|
|
}
|
2000-09-14 08:47:46 +00:00
|
|
|
|
2011-08-03 03:39:02 +00:00
|
|
|
// check whether style allows selection
|
|
|
|
// if not, don't tell selection the mouse event even occurred.
|
2011-09-29 06:19:26 +00:00
|
|
|
bool selectable;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint8_t selectStyle;
|
2011-08-03 03:39:02 +00:00
|
|
|
rv = IsSelectable(&selectable, &selectStyle);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
// check for select: none
|
|
|
|
if (!selectable)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
// When implementing NS_STYLE_USER_SELECT_ELEMENT, NS_STYLE_USER_SELECT_ELEMENTS and
|
|
|
|
// NS_STYLE_USER_SELECT_TOGGLE, need to change this logic
|
2011-09-29 06:19:26 +00:00
|
|
|
bool useFrameSelection = (selectStyle == NS_STYLE_USER_SELECT_TEXT);
|
2000-08-08 23:48:42 +00:00
|
|
|
|
2011-08-03 03:39:02 +00:00
|
|
|
// If the mouse is dragged outside the nearest enclosing scrollable area
|
2009-09-13 13:13:16 +00:00
|
|
|
// while making a selection, the area will be scrolled. To do this, capture
|
2011-08-03 03:39:02 +00:00
|
|
|
// the mouse on the nearest scrollable frame. If there isn't a scrollable
|
|
|
|
// frame, or something else is already capturing the mouse, there's no
|
|
|
|
// reason to capture.
|
|
|
|
if (!nsIPresShell::GetCapturingContent()) {
|
|
|
|
nsIFrame* checkFrame = this;
|
2012-07-30 14:20:58 +00:00
|
|
|
nsIScrollableFrame *scrollFrame = nullptr;
|
2011-08-03 03:39:02 +00:00
|
|
|
while (checkFrame) {
|
|
|
|
scrollFrame = do_QueryFrame(checkFrame);
|
|
|
|
if (scrollFrame) {
|
|
|
|
nsIPresShell::SetCapturingContent(checkFrame->GetContent(), CAPTURE_IGNOREALLOWED);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
checkFrame = checkFrame->GetParent();
|
2009-09-13 13:13:16 +00:00
|
|
|
}
|
|
|
|
}
|
2009-03-30 10:12:35 +00:00
|
|
|
|
2011-08-03 03:39:02 +00:00
|
|
|
// XXX This is screwy; it really should use the selection frame, not the
|
|
|
|
// event frame
|
2012-07-30 14:20:58 +00:00
|
|
|
const nsFrameSelection* frameselection = nullptr;
|
2011-08-03 03:39:02 +00:00
|
|
|
if (useFrameSelection)
|
|
|
|
frameselection = GetConstFrameSelection();
|
|
|
|
else
|
|
|
|
frameselection = shell->ConstFrameSelection();
|
|
|
|
|
|
|
|
if (!frameselection || frameselection->GetDisplaySelection() == nsISelectionController::SELECTION_OFF)
|
2006-02-21 00:49:04 +00:00
|
|
|
return NS_OK;//nothing to do we cannot affect selection from here
|
2000-05-11 04:25:43 +00:00
|
|
|
|
1999-09-11 00:18:02 +00:00
|
|
|
nsMouseEvent *me = (nsMouseEvent *)aEvent;
|
2000-05-16 22:16:05 +00:00
|
|
|
|
2007-10-01 23:20:37 +00:00
|
|
|
#ifdef XP_MACOSX
|
2012-04-25 03:00:02 +00:00
|
|
|
if (me->IsControl())
|
2011-12-19 09:11:16 +00:00
|
|
|
return NS_OK;//short circuit. hard coded for mac due to time restraints.
|
2012-04-25 03:00:02 +00:00
|
|
|
bool control = me->IsMeta();
|
2008-10-17 19:46:33 +00:00
|
|
|
#else
|
2012-04-25 03:00:02 +00:00
|
|
|
bool control = me->IsControl();
|
2000-08-09 22:33:03 +00:00
|
|
|
#endif
|
2008-10-17 19:46:33 +00:00
|
|
|
|
2011-08-03 03:39:02 +00:00
|
|
|
nsRefPtr<nsFrameSelection> fc = const_cast<nsFrameSelection*>(frameselection);
|
2011-12-19 09:11:16 +00:00
|
|
|
if (me->clickCount > 1)
|
2000-05-16 22:16:05 +00:00
|
|
|
{
|
2007-11-22 20:47:33 +00:00
|
|
|
// These methods aren't const but can't actually delete anything,
|
|
|
|
// so no need for nsWeakFrame.
|
2011-10-17 14:59:28 +00:00
|
|
|
fc->SetMouseDownState(true);
|
|
|
|
fc->SetMouseDoubleDown(true);
|
2008-10-17 19:46:33 +00:00
|
|
|
return HandleMultiplePress(aPresContext, aEvent, aEventStatus, control);
|
2000-05-16 22:16:05 +00:00
|
|
|
}
|
1998-07-27 18:05:35 +00:00
|
|
|
|
2009-03-30 10:12:35 +00:00
|
|
|
nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, this);
|
2012-05-29 13:13:36 +00:00
|
|
|
ContentOffsets offsets = GetContentOffsetsFromPoint(pt, SKIP_HIDDEN);
|
2009-03-30 10:12:35 +00:00
|
|
|
|
2006-02-27 05:57:37 +00:00
|
|
|
if (!offsets.content)
|
|
|
|
return NS_ERROR_FAILURE;
|
2000-05-16 22:16:05 +00:00
|
|
|
|
2011-12-19 09:11:16 +00:00
|
|
|
// On touchables devices, touch the screen is usually a pan action,
|
2012-08-21 21:09:10 +00:00
|
|
|
// so let's reposition the caret if needed but do not select text
|
|
|
|
// if the touch did not happen over an editable element. Otherwise,
|
|
|
|
// let the user move the caret by tapping and dragging.
|
2012-08-16 15:51:46 +00:00
|
|
|
if (!offsets.content->IsEditable() &&
|
|
|
|
Preferences::GetBool("browser.ignoreNativeFrameTextSelection", false)) {
|
2011-12-19 09:11:16 +00:00
|
|
|
return fc->HandleClick(offsets.content, offsets.StartOffset(),
|
|
|
|
offsets.EndOffset(), false, false,
|
|
|
|
offsets.associateWithNext);
|
|
|
|
}
|
|
|
|
|
2000-05-31 00:07:58 +00:00
|
|
|
// Let Ctrl/Cmd+mouse down do table selection instead of drag initiation
|
|
|
|
nsCOMPtr<nsIContent>parentContent;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t contentOffset;
|
|
|
|
int32_t target;
|
2011-08-03 03:39:02 +00:00
|
|
|
rv = GetDataForTableSelection(frameselection, shell, me, getter_AddRefs(parentContent), &contentOffset, &target);
|
2000-05-31 00:07:58 +00:00
|
|
|
if (NS_SUCCEEDED(rv) && parentContent)
|
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
fc->SetMouseDownState(true);
|
2011-08-03 03:39:02 +00:00
|
|
|
return fc->HandleTableSelection(parentContent, contentOffset, target, me);
|
2000-05-31 00:07:58 +00:00
|
|
|
}
|
|
|
|
|
2011-08-03 03:39:02 +00:00
|
|
|
fc->SetDelayedCaretData(0);
|
2000-05-16 22:16:05 +00:00
|
|
|
|
2006-12-16 14:40:44 +00:00
|
|
|
// Check if any part of this frame is selected, and if the
|
|
|
|
// user clicked inside the selected region. If so, we delay
|
|
|
|
// starting a new selection since the user may be trying to
|
|
|
|
// drag the selected region to some other app.
|
|
|
|
|
|
|
|
SelectionDetails *details = 0;
|
2011-12-20 09:15:41 +00:00
|
|
|
if (GetContent()->IsSelectionDescendant())
|
2000-05-16 22:16:05 +00:00
|
|
|
{
|
2011-09-29 06:19:26 +00:00
|
|
|
bool inSelection = false;
|
2011-08-03 03:39:02 +00:00
|
|
|
details = frameselection->LookUpSelection(offsets.content, 0,
|
2011-10-17 14:59:28 +00:00
|
|
|
offsets.EndOffset(), false);
|
2000-05-16 22:16:05 +00:00
|
|
|
|
2006-12-16 14:40:44 +00:00
|
|
|
//
|
|
|
|
// If there are any details, check to see if the user clicked
|
|
|
|
// within any selected region of the frame.
|
|
|
|
//
|
2000-05-16 22:16:05 +00:00
|
|
|
|
2008-10-20 20:53:40 +00:00
|
|
|
SelectionDetails *curDetail = details;
|
2000-05-16 22:16:05 +00:00
|
|
|
|
2008-10-20 20:53:40 +00:00
|
|
|
while (curDetail)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
// If the user clicked inside a selection, then just
|
|
|
|
// return without doing anything. We will handle placing
|
|
|
|
// the caret later on when the mouse is released. We ignore
|
2011-05-02 17:50:18 +00:00
|
|
|
// the spellcheck, find and url formatting selections.
|
2008-10-20 20:53:40 +00:00
|
|
|
//
|
|
|
|
if (curDetail->mType != nsISelectionController::SELECTION_SPELLCHECK &&
|
|
|
|
curDetail->mType != nsISelectionController::SELECTION_FIND &&
|
2011-05-02 17:50:18 +00:00
|
|
|
curDetail->mType != nsISelectionController::SELECTION_URLSECONDARY &&
|
2008-10-20 20:53:40 +00:00
|
|
|
curDetail->mStart <= offsets.StartOffset() &&
|
|
|
|
offsets.EndOffset() <= curDetail->mEnd)
|
2000-03-16 23:45:39 +00:00
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
inSelection = true;
|
1998-12-14 18:34:14 +00:00
|
|
|
}
|
2006-12-16 14:40:44 +00:00
|
|
|
|
2008-10-20 20:53:40 +00:00
|
|
|
SelectionDetails *nextDetail = curDetail->mNext;
|
|
|
|
delete curDetail;
|
|
|
|
curDetail = nextDetail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (inSelection) {
|
2011-10-17 14:59:28 +00:00
|
|
|
fc->SetMouseDownState(false);
|
2011-08-03 03:39:02 +00:00
|
|
|
fc->SetDelayedCaretData(me);
|
2008-10-20 20:53:40 +00:00
|
|
|
return NS_OK;
|
1998-12-14 18:34:14 +00:00
|
|
|
}
|
|
|
|
}
|
2000-05-16 22:16:05 +00:00
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
fc->SetMouseDownState(true);
|
2000-05-16 22:16:05 +00:00
|
|
|
|
2007-11-22 20:47:33 +00:00
|
|
|
// Do not touch any nsFrame members after this point without adding
|
|
|
|
// weakFrame checks.
|
2011-08-03 03:39:02 +00:00
|
|
|
rv = fc->HandleClick(offsets.content, offsets.StartOffset(),
|
2012-04-25 03:00:02 +00:00
|
|
|
offsets.EndOffset(), me->IsShift(), control,
|
2007-11-22 20:47:33 +00:00
|
|
|
offsets.associateWithNext);
|
2006-02-27 05:57:37 +00:00
|
|
|
|
2003-04-07 14:28:51 +00:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
2006-02-27 05:57:37 +00:00
|
|
|
if (offsets.offset != offsets.secondaryOffset)
|
2011-08-03 03:39:02 +00:00
|
|
|
fc->MaintainSelection();
|
2003-07-21 19:51:34 +00:00
|
|
|
|
2012-04-25 03:00:02 +00:00
|
|
|
if (isEditor && !me->IsShift() &&
|
2006-02-27 05:57:37 +00:00
|
|
|
(offsets.EndOffset() - offsets.StartOffset()) == 1)
|
2003-04-07 14:28:51 +00:00
|
|
|
{
|
|
|
|
// A single node is selected and we aren't extending an existing
|
2005-12-07 23:08:39 +00:00
|
|
|
// selection, which means the user clicked directly on an object (either
|
|
|
|
// -moz-user-select: all or a non-text node without children).
|
|
|
|
// Therefore, disable selection extension during mouse moves.
|
|
|
|
// XXX This is a bit hacky; shouldn't editor be able to deal with this?
|
2011-10-17 14:59:28 +00:00
|
|
|
fc->SetMouseDownState(false);
|
2003-04-07 14:28:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
2005-12-07 23:08:39 +00:00
|
|
|
|
2012-09-10 21:02:23 +00:00
|
|
|
/*
|
|
|
|
* SelectByTypeAtPoint
|
|
|
|
*
|
|
|
|
* Search for selectable content at point and attempt to select
|
|
|
|
* based on the start and end selection behaviours.
|
|
|
|
*
|
|
|
|
* @param aPresContext Presentation context
|
|
|
|
* @param aPoint Point at which selection will occur. Coordinates
|
|
|
|
* should be relaitve to this frame.
|
|
|
|
* @param aBeginAmountType, aEndAmountType Selection behavior, see
|
|
|
|
* nsIFrame for definitions.
|
|
|
|
* @param aSelectFlags Selection flags defined in nsFame.h.
|
|
|
|
* @return success or failure at finding suitable content to select.
|
|
|
|
*/
|
|
|
|
nsresult
|
|
|
|
nsFrame::SelectByTypeAtPoint(nsPresContext* aPresContext,
|
|
|
|
const nsPoint& aPoint,
|
|
|
|
nsSelectionAmount aBeginAmountType,
|
|
|
|
nsSelectionAmount aEndAmountType,
|
|
|
|
uint32_t aSelectFlags)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aPresContext);
|
|
|
|
|
|
|
|
// No point in selecting if selection is turned off
|
|
|
|
if (DisplaySelection(aPresContext) == nsISelectionController::SELECTION_OFF)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
ContentOffsets offsets = GetContentOffsetsFromPoint(aPoint, SKIP_HIDDEN);
|
|
|
|
if (!offsets.content)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsIFrame* theFrame;
|
|
|
|
int32_t offset;
|
|
|
|
const nsFrameSelection* frameSelection =
|
|
|
|
PresContext()->GetPresShell()->ConstFrameSelection();
|
|
|
|
theFrame = frameSelection->
|
|
|
|
GetFrameForNodeOffset(offsets.content, offsets.offset,
|
|
|
|
nsFrameSelection::HINT(offsets.associateWithNext),
|
|
|
|
&offset);
|
|
|
|
if (!theFrame)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsFrame* frame = static_cast<nsFrame*>(theFrame);
|
|
|
|
return frame->PeekBackwardAndForward(aBeginAmountType, aEndAmountType,
|
|
|
|
offsets.offset, aPresContext,
|
|
|
|
aBeginAmountType != eSelectWord,
|
|
|
|
aSelectFlags);
|
|
|
|
}
|
|
|
|
|
1999-05-17 00:21:18 +00:00
|
|
|
/**
|
2000-05-16 22:48:28 +00:00
|
|
|
* Multiple Mouse Press -- line or paragraph selection -- for the frame.
|
|
|
|
* Wouldn't it be nice if this didn't have to be hardwired into Frame code?
|
1999-05-17 00:21:18 +00:00
|
|
|
*/
|
|
|
|
NS_IMETHODIMP
|
2012-09-10 21:02:23 +00:00
|
|
|
nsFrame::HandleMultiplePress(nsPresContext* aPresContext,
|
2008-10-17 19:46:33 +00:00
|
|
|
nsGUIEvent* aEvent,
|
|
|
|
nsEventStatus* aEventStatus,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aControlHeld)
|
1999-05-17 00:21:18 +00:00
|
|
|
{
|
2012-09-10 21:02:23 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aEvent);
|
massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-08 21:31:05 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aEventStatus);
|
|
|
|
|
2012-09-10 21:02:23 +00:00
|
|
|
if (nsEventStatus_eConsumeNoDefault == *aEventStatus ||
|
|
|
|
DisplaySelection(aPresContext) == nsISelectionController::SELECTION_OFF) {
|
1999-09-11 00:18:02 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-05-16 22:48:28 +00:00
|
|
|
|
|
|
|
// Find out whether we're doing line or paragraph selection.
|
2005-08-18 17:09:16 +00:00
|
|
|
// If browser.triple_click_selects_paragraph is true, triple-click selects paragraph.
|
|
|
|
// Otherwise, triple-click selects line, and quadruple-click selects paragraph
|
|
|
|
// (on platforms that support quadruple-click).
|
2005-12-07 23:08:39 +00:00
|
|
|
nsSelectionAmount beginAmount, endAmount;
|
1999-09-11 00:18:02 +00:00
|
|
|
nsMouseEvent *me = (nsMouseEvent *)aEvent;
|
2000-05-16 22:48:28 +00:00
|
|
|
if (!me) return NS_OK;
|
|
|
|
|
2005-12-07 23:08:39 +00:00
|
|
|
if (me->clickCount == 4) {
|
|
|
|
beginAmount = endAmount = eSelectParagraph;
|
|
|
|
} else if (me->clickCount == 3) {
|
2011-05-25 06:31:59 +00:00
|
|
|
if (Preferences::GetBool("browser.triple_click_selects_paragraph")) {
|
2005-12-07 23:08:39 +00:00
|
|
|
beginAmount = endAmount = eSelectParagraph;
|
|
|
|
} else {
|
|
|
|
beginAmount = eSelectBeginLine;
|
|
|
|
endAmount = eSelectEndLine;
|
|
|
|
}
|
|
|
|
} else if (me->clickCount == 2) {
|
|
|
|
// We only want inline frames; PeekBackwardAndForward dislikes blocks
|
|
|
|
beginAmount = endAmount = eSelectWord;
|
|
|
|
} else {
|
1999-09-11 00:18:02 +00:00
|
|
|
return NS_OK;
|
2005-12-07 23:08:39 +00:00
|
|
|
}
|
2000-05-16 22:48:28 +00:00
|
|
|
|
2012-09-10 21:02:23 +00:00
|
|
|
nsPoint relPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, this);
|
|
|
|
return SelectByTypeAtPoint(aPresContext, relPoint, beginAmount, endAmount,
|
|
|
|
(aControlHeld ? SELECT_ACCUMULATE : 0));
|
2000-05-16 22:48:28 +00:00
|
|
|
}
|
|
|
|
|
2012-09-10 21:02:23 +00:00
|
|
|
nsresult
|
2000-05-16 22:48:28 +00:00
|
|
|
nsFrame::PeekBackwardAndForward(nsSelectionAmount aAmountBack,
|
|
|
|
nsSelectionAmount aAmountForward,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aStartPos,
|
2004-07-31 23:15:21 +00:00
|
|
|
nsPresContext* aPresContext,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aJumpLines,
|
2012-09-10 21:02:23 +00:00
|
|
|
uint32_t aSelectFlags)
|
2000-05-16 22:48:28 +00:00
|
|
|
{
|
2007-01-04 16:47:04 +00:00
|
|
|
nsIFrame* baseFrame = this;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t baseOffset = aStartPos;
|
2008-10-17 19:46:33 +00:00
|
|
|
nsresult rv;
|
|
|
|
|
2007-01-04 16:47:04 +00:00
|
|
|
if (aAmountBack == eSelectWord) {
|
|
|
|
// To avoid selecting the previous word when at start of word,
|
|
|
|
// first move one character forward.
|
2012-03-26 16:09:38 +00:00
|
|
|
nsPeekOffsetStruct pos(eSelectCharacter,
|
|
|
|
eDirNext,
|
|
|
|
aStartPos,
|
|
|
|
0,
|
|
|
|
aJumpLines,
|
|
|
|
true, //limit on scrolled views
|
|
|
|
false,
|
|
|
|
false);
|
2007-01-04 16:47:04 +00:00
|
|
|
rv = PeekOffset(&pos);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
baseFrame = pos.mResultFrame;
|
|
|
|
baseOffset = pos.mContentOffset;
|
|
|
|
}
|
|
|
|
}
|
2008-10-17 19:46:33 +00:00
|
|
|
|
2012-03-26 16:09:38 +00:00
|
|
|
// Use peek offset one way then the other:
|
|
|
|
nsPeekOffsetStruct startpos(aAmountBack,
|
|
|
|
eDirPrevious,
|
|
|
|
baseOffset,
|
|
|
|
0,
|
|
|
|
aJumpLines,
|
|
|
|
true, //limit on scrolled views
|
|
|
|
false,
|
|
|
|
false);
|
2007-01-04 16:47:04 +00:00
|
|
|
rv = baseFrame->PeekOffset(&startpos);
|
2000-05-16 22:48:28 +00:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
2007-01-04 16:47:04 +00:00
|
|
|
|
2012-03-26 16:09:38 +00:00
|
|
|
nsPeekOffsetStruct endpos(aAmountForward,
|
|
|
|
eDirNext,
|
|
|
|
aStartPos,
|
|
|
|
0,
|
|
|
|
aJumpLines,
|
|
|
|
true, //limit on scrolled views
|
|
|
|
false,
|
|
|
|
false);
|
2006-09-11 20:43:01 +00:00
|
|
|
rv = PeekOffset(&endpos);
|
2000-05-16 22:48:28 +00:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
2008-10-17 19:46:33 +00:00
|
|
|
// Keep frameSelection alive.
|
|
|
|
nsRefPtr<nsFrameSelection> frameSelection = GetFrameSelection();
|
|
|
|
|
|
|
|
rv = frameSelection->HandleClick(startpos.mResultContent,
|
|
|
|
startpos.mContentOffset, startpos.mContentOffset,
|
2012-09-10 21:02:23 +00:00
|
|
|
false, (aSelectFlags & SELECT_ACCUMULATE),
|
2008-10-17 19:46:33 +00:00
|
|
|
nsFrameSelection::HINTRIGHT);
|
2000-05-16 22:48:28 +00:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
2008-10-17 19:46:33 +00:00
|
|
|
|
|
|
|
rv = frameSelection->HandleClick(endpos.mResultContent,
|
|
|
|
endpos.mContentOffset, endpos.mContentOffset,
|
2011-10-17 14:59:28 +00:00
|
|
|
true, false,
|
2008-10-17 19:46:33 +00:00
|
|
|
nsFrameSelection::HINTLEFT);
|
2000-05-16 22:48:28 +00:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
2003-07-21 19:51:34 +00:00
|
|
|
// maintain selection
|
2007-09-15 19:48:20 +00:00
|
|
|
return frameSelection->MaintainSelection(aAmountBack);
|
1999-05-17 00:21:18 +00:00
|
|
|
}
|
|
|
|
|
2011-08-03 03:39:02 +00:00
|
|
|
NS_IMETHODIMP nsFrame::HandleDrag(nsPresContext* aPresContext,
|
|
|
|
nsGUIEvent* aEvent,
|
|
|
|
nsEventStatus* aEventStatus)
|
1998-04-27 16:44:52 +00:00
|
|
|
{
|
2011-09-29 06:19:26 +00:00
|
|
|
bool selectable;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint8_t selectStyle;
|
2011-08-03 03:39:02 +00:00
|
|
|
IsSelectable(&selectable, &selectStyle);
|
|
|
|
// XXX Do we really need to exclude non-selectable content here?
|
|
|
|
// GetContentOffsetsFromPoint can handle it just fine, although some
|
|
|
|
// other stuff might not like it.
|
|
|
|
if (!selectable)
|
|
|
|
return NS_OK;
|
|
|
|
if (DisplaySelection(aPresContext) == nsISelectionController::SELECTION_OFF) {
|
|
|
|
return NS_OK;
|
1998-12-14 18:34:14 +00:00
|
|
|
}
|
2011-08-03 03:39:02 +00:00
|
|
|
nsIPresShell *presShell = aPresContext->PresShell();
|
1999-09-29 20:04:05 +00:00
|
|
|
|
2011-08-03 03:39:02 +00:00
|
|
|
nsRefPtr<nsFrameSelection> frameselection = GetFrameSelection();
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mouseDown = frameselection->GetMouseDownState();
|
2011-08-03 03:39:02 +00:00
|
|
|
if (!mouseDown)
|
|
|
|
return NS_OK;
|
2011-07-06 02:16:18 +00:00
|
|
|
|
2011-08-03 03:39:02 +00:00
|
|
|
frameselection->StopAutoScrollTimer();
|
2006-09-18 08:47:06 +00:00
|
|
|
|
2004-08-29 03:08:44 +00:00
|
|
|
// Check if we are dragging in a table cell
|
|
|
|
nsCOMPtr<nsIContent> parentContent;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t contentOffset;
|
|
|
|
int32_t target;
|
2011-08-03 03:39:02 +00:00
|
|
|
nsMouseEvent *me = (nsMouseEvent *)aEvent;
|
|
|
|
nsresult result;
|
|
|
|
result = GetDataForTableSelection(frameselection, presShell, me,
|
|
|
|
getter_AddRefs(parentContent),
|
|
|
|
&contentOffset, &target);
|
2004-08-29 03:08:44 +00:00
|
|
|
|
2009-11-24 19:29:48 +00:00
|
|
|
nsWeakFrame weakThis = this;
|
2011-08-03 03:39:02 +00:00
|
|
|
if (NS_SUCCEEDED(result) && parentContent) {
|
|
|
|
frameselection->HandleTableSelection(parentContent, contentOffset, target, me);
|
2005-08-23 03:57:07 +00:00
|
|
|
} else {
|
2005-09-04 20:04:23 +00:00
|
|
|
nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, this);
|
2011-08-03 03:39:02 +00:00
|
|
|
frameselection->HandleDrag(this, pt);
|
2005-08-23 03:57:07 +00:00
|
|
|
}
|
2004-08-29 03:08:44 +00:00
|
|
|
|
2009-11-24 19:29:48 +00:00
|
|
|
// The frameselection object notifies selection listeners synchronously above
|
|
|
|
// which might have killed us.
|
|
|
|
if (!weakThis.IsAlive()) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-08-03 03:39:02 +00:00
|
|
|
// get the nearest scrollframe
|
|
|
|
nsIFrame* checkFrame = this;
|
2012-07-30 14:20:58 +00:00
|
|
|
nsIScrollableFrame *scrollFrame = nullptr;
|
2011-08-03 03:39:02 +00:00
|
|
|
while (checkFrame) {
|
|
|
|
scrollFrame = do_QueryFrame(checkFrame);
|
|
|
|
if (scrollFrame) {
|
|
|
|
break;
|
2006-09-18 08:47:06 +00:00
|
|
|
}
|
2011-08-03 03:39:02 +00:00
|
|
|
checkFrame = checkFrame->GetParent();
|
2011-07-06 02:16:18 +00:00
|
|
|
}
|
|
|
|
|
2011-08-03 03:39:02 +00:00
|
|
|
if (scrollFrame) {
|
|
|
|
nsIFrame* capturingFrame = scrollFrame->GetScrolledFrame();
|
|
|
|
if (capturingFrame) {
|
|
|
|
nsPoint pt =
|
|
|
|
nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, capturingFrame);
|
|
|
|
frameselection->StartAutoScrollTimer(capturingFrame, pt, 30);
|
|
|
|
}
|
1998-12-14 18:34:14 +00:00
|
|
|
}
|
2009-09-13 13:13:16 +00:00
|
|
|
|
1998-04-27 16:44:52 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-08-03 03:39:02 +00:00
|
|
|
/**
|
|
|
|
* This static method handles part of the nsFrame::HandleRelease in a way
|
|
|
|
* which doesn't rely on the nsFrame object to stay alive.
|
|
|
|
*/
|
|
|
|
static nsresult
|
|
|
|
HandleFrameSelection(nsFrameSelection* aFrameSelection,
|
|
|
|
nsIFrame::ContentOffsets& aOffsets,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aHandleTableSel,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aContentOffsetForTableSel,
|
|
|
|
int32_t aTargetForTableSel,
|
2011-08-03 03:39:02 +00:00
|
|
|
nsIContent* aParentContentForTableSel,
|
|
|
|
nsGUIEvent* aEvent,
|
|
|
|
nsEventStatus* aEventStatus)
|
|
|
|
{
|
|
|
|
if (!aFrameSelection) {
|
|
|
|
return NS_OK;
|
2011-07-06 02:16:18 +00:00
|
|
|
}
|
2006-05-12 06:40:49 +00:00
|
|
|
|
2011-08-03 03:39:02 +00:00
|
|
|
nsresult rv = NS_OK;
|
2006-05-12 06:40:49 +00:00
|
|
|
|
2011-08-03 03:39:02 +00:00
|
|
|
if (nsEventStatus_eConsumeNoDefault != *aEventStatus) {
|
|
|
|
if (!aHandleTableSel) {
|
2012-05-24 10:36:08 +00:00
|
|
|
if (!aOffsets.content || !aFrameSelection->HasDelayedCaretData()) {
|
2011-08-03 03:39:02 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2006-05-12 06:40:49 +00:00
|
|
|
}
|
|
|
|
|
2011-08-03 03:39:02 +00:00
|
|
|
// We are doing this to simulate what we would have done on HandlePress.
|
|
|
|
// We didn't do it there to give the user an opportunity to drag
|
|
|
|
// the text, but since they didn't drag, we want to place the
|
|
|
|
// caret.
|
|
|
|
// However, we'll use the mouse position from the release, since:
|
|
|
|
// * it's easier
|
|
|
|
// * that's the normal click position to use (although really, in
|
|
|
|
// the normal case, small movements that don't count as a drag
|
|
|
|
// can do selection)
|
2011-10-17 14:59:28 +00:00
|
|
|
aFrameSelection->SetMouseDownState(true);
|
2011-08-03 03:39:02 +00:00
|
|
|
|
|
|
|
rv = aFrameSelection->HandleClick(aOffsets.content,
|
|
|
|
aOffsets.StartOffset(),
|
|
|
|
aOffsets.EndOffset(),
|
2012-05-24 10:36:08 +00:00
|
|
|
aFrameSelection->IsShiftDownInDelayedCaretData(),
|
|
|
|
false,
|
2011-08-03 03:39:02 +00:00
|
|
|
aOffsets.associateWithNext);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
} else if (aParentContentForTableSel) {
|
2011-10-17 14:59:28 +00:00
|
|
|
aFrameSelection->SetMouseDownState(false);
|
2011-08-03 03:39:02 +00:00
|
|
|
rv = aFrameSelection->HandleTableSelection(aParentContentForTableSel,
|
|
|
|
aContentOffsetForTableSel,
|
|
|
|
aTargetForTableSel,
|
|
|
|
(nsMouseEvent *)aEvent);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
2011-07-06 02:16:18 +00:00
|
|
|
}
|
2011-08-03 03:39:02 +00:00
|
|
|
aFrameSelection->SetDelayedCaretData(0);
|
2011-07-06 02:16:18 +00:00
|
|
|
}
|
2006-05-12 06:40:49 +00:00
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
aFrameSelection->SetMouseDownState(false);
|
2011-08-03 03:39:02 +00:00
|
|
|
aFrameSelection->StopAutoScrollTimer();
|
2000-05-16 22:16:05 +00:00
|
|
|
|
2011-08-03 03:39:02 +00:00
|
|
|
return NS_OK;
|
2011-07-06 02:16:18 +00:00
|
|
|
}
|
|
|
|
|
2011-08-03 03:39:02 +00:00
|
|
|
NS_IMETHODIMP nsFrame::HandleRelease(nsPresContext* aPresContext,
|
|
|
|
nsGUIEvent* aEvent,
|
|
|
|
nsEventStatus* aEventStatus)
|
2011-07-06 02:16:18 +00:00
|
|
|
{
|
2012-07-31 17:36:02 +00:00
|
|
|
if (aEvent->eventStructType != NS_MOUSE_EVENT) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-08-03 03:39:02 +00:00
|
|
|
nsIFrame* activeFrame = GetActiveSelectionFrame(aPresContext, this);
|
2011-07-06 02:16:18 +00:00
|
|
|
|
2011-08-03 03:39:02 +00:00
|
|
|
nsCOMPtr<nsIContent> captureContent = nsIPresShell::GetCapturingContent();
|
2011-07-06 02:16:18 +00:00
|
|
|
|
2011-08-03 03:39:02 +00:00
|
|
|
// We can unconditionally stop capturing because
|
|
|
|
// we should never be capturing when the mouse button is up
|
2012-07-30 14:20:58 +00:00
|
|
|
nsIPresShell::SetCapturingContent(nullptr, 0);
|
2011-02-03 17:08:30 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool selectionOff =
|
2011-08-03 03:39:02 +00:00
|
|
|
(DisplaySelection(aPresContext) == nsISelectionController::SELECTION_OFF);
|
1999-09-29 20:04:05 +00:00
|
|
|
|
2011-08-03 03:39:02 +00:00
|
|
|
nsRefPtr<nsFrameSelection> frameselection;
|
|
|
|
ContentOffsets offsets;
|
2011-07-06 02:16:18 +00:00
|
|
|
nsCOMPtr<nsIContent> parentContent;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t contentOffsetForTableSel = 0;
|
|
|
|
int32_t targetForTableSel = 0;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool handleTableSelection = true;
|
2011-08-03 03:39:02 +00:00
|
|
|
|
|
|
|
if (!selectionOff) {
|
|
|
|
frameselection = GetFrameSelection();
|
|
|
|
if (nsEventStatus_eConsumeNoDefault != *aEventStatus && frameselection) {
|
|
|
|
// Check if the frameselection recorded the mouse going down.
|
|
|
|
// If not, the user must have clicked in a part of the selection.
|
|
|
|
// Place the caret before continuing!
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mouseDown = frameselection->GetMouseDownState();
|
2011-08-03 03:39:02 +00:00
|
|
|
|
2012-05-24 10:36:08 +00:00
|
|
|
if (!mouseDown && frameselection->HasDelayedCaretData() &&
|
|
|
|
frameselection->GetClickCountInDelayedCaretData() < 2) {
|
2011-08-03 03:39:02 +00:00
|
|
|
nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, this);
|
2012-05-29 13:13:36 +00:00
|
|
|
offsets = GetContentOffsetsFromPoint(pt, SKIP_HIDDEN);
|
2011-10-17 14:59:28 +00:00
|
|
|
handleTableSelection = false;
|
2011-08-03 03:39:02 +00:00
|
|
|
} else {
|
|
|
|
GetDataForTableSelection(frameselection, PresContext()->PresShell(),
|
|
|
|
(nsMouseEvent *)aEvent,
|
|
|
|
getter_AddRefs(parentContent),
|
|
|
|
&contentOffsetForTableSel,
|
|
|
|
&targetForTableSel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-07-06 02:16:18 +00:00
|
|
|
|
2011-08-03 03:39:02 +00:00
|
|
|
// We might be capturing in some other document and the event just happened to
|
|
|
|
// trickle down here. Make sure that document's frame selection is notified.
|
|
|
|
// Note, this may cause the current nsFrame object to be deleted, bug 336592.
|
|
|
|
nsRefPtr<nsFrameSelection> frameSelection;
|
|
|
|
if (activeFrame != this &&
|
|
|
|
static_cast<nsFrame*>(activeFrame)->DisplaySelection(activeFrame->PresContext())
|
|
|
|
!= nsISelectionController::SELECTION_OFF) {
|
|
|
|
frameSelection = activeFrame->GetFrameSelection();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Also check the selection of the capturing content which might be in a
|
|
|
|
// different document.
|
|
|
|
if (!frameSelection && captureContent) {
|
|
|
|
nsIDocument* doc = captureContent->GetCurrentDoc();
|
|
|
|
if (doc) {
|
|
|
|
nsIPresShell* capturingShell = doc->GetShell();
|
|
|
|
if (capturingShell && capturingShell != PresContext()->GetPresShell()) {
|
|
|
|
frameSelection = capturingShell->FrameSelection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-05-12 06:40:49 +00:00
|
|
|
|
2011-08-03 03:39:02 +00:00
|
|
|
if (frameSelection) {
|
2011-10-17 14:59:28 +00:00
|
|
|
frameSelection->SetMouseDownState(false);
|
2011-08-03 03:39:02 +00:00
|
|
|
frameSelection->StopAutoScrollTimer();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Do not call any methods of the current object after this point!!!
|
|
|
|
// The object is perhaps dead!
|
|
|
|
|
|
|
|
return selectionOff
|
|
|
|
? NS_OK
|
|
|
|
: HandleFrameSelection(frameselection, offsets, handleTableSelection,
|
|
|
|
contentOffsetForTableSel, targetForTableSel,
|
|
|
|
parentContent, aEvent, aEventStatus);
|
1998-04-27 16:44:52 +00:00
|
|
|
}
|
|
|
|
|
2008-07-01 19:16:45 +00:00
|
|
|
struct NS_STACK_CLASS FrameContentRange {
|
2012-08-22 15:56:38 +00:00
|
|
|
FrameContentRange(nsIContent* aContent, int32_t aStart, int32_t aEnd) :
|
2005-12-07 23:08:39 +00:00
|
|
|
content(aContent), start(aStart), end(aEnd) { }
|
|
|
|
nsCOMPtr<nsIContent> content;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t start;
|
|
|
|
int32_t end;
|
2005-12-07 23:08:39 +00:00
|
|
|
};
|
1999-09-29 20:04:05 +00:00
|
|
|
|
2005-12-07 23:08:39 +00:00
|
|
|
// Retrieve the content offsets of a frame
|
2006-02-27 05:57:37 +00:00
|
|
|
static FrameContentRange GetRangeForFrame(nsIFrame* aFrame) {
|
2005-12-07 23:08:39 +00:00
|
|
|
nsCOMPtr<nsIContent> content, parent;
|
|
|
|
content = aFrame->GetContent();
|
2005-12-25 19:01:45 +00:00
|
|
|
if (!content) {
|
|
|
|
NS_WARNING("Frame has no content");
|
2012-07-30 14:20:58 +00:00
|
|
|
return FrameContentRange(nullptr, -1, -1);
|
2005-12-25 19:01:45 +00:00
|
|
|
}
|
2005-12-20 09:13:47 +00:00
|
|
|
nsIAtom* type = aFrame->GetType();
|
2006-12-26 17:47:52 +00:00
|
|
|
if (type == nsGkAtoms::textFrame) {
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t offset, offsetEnd;
|
2005-12-07 23:08:39 +00:00
|
|
|
aFrame->GetOffsets(offset, offsetEnd);
|
2006-02-27 05:57:37 +00:00
|
|
|
return FrameContentRange(content, offset, offsetEnd);
|
2005-12-07 23:08:39 +00:00
|
|
|
}
|
2006-12-26 17:47:52 +00:00
|
|
|
if (type == nsGkAtoms::brFrame) {
|
2005-12-20 09:13:47 +00:00
|
|
|
parent = content->GetParent();
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t beginOffset = parent->IndexOf(content);
|
2006-02-27 05:57:37 +00:00
|
|
|
return FrameContentRange(parent, beginOffset, beginOffset);
|
2005-12-20 09:13:47 +00:00
|
|
|
}
|
2005-12-07 23:08:39 +00:00
|
|
|
// Loop to deal with anonymous content, which has no index; this loop
|
|
|
|
// probably won't run more than twice under normal conditions
|
|
|
|
do {
|
|
|
|
parent = content->GetParent();
|
|
|
|
if (parent) {
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t beginOffset = parent->IndexOf(content);
|
2005-12-07 23:08:39 +00:00
|
|
|
if (beginOffset >= 0)
|
2006-02-27 05:57:37 +00:00
|
|
|
return FrameContentRange(parent, beginOffset, beginOffset + 1);
|
2005-12-07 23:08:39 +00:00
|
|
|
content = parent;
|
|
|
|
}
|
|
|
|
} while (parent);
|
1999-09-29 20:04:05 +00:00
|
|
|
|
2005-12-07 23:08:39 +00:00
|
|
|
// The root content node must act differently
|
2006-02-27 05:57:37 +00:00
|
|
|
return FrameContentRange(content, 0, content->GetChildCount());
|
2005-12-07 23:08:39 +00:00
|
|
|
}
|
1999-09-29 20:04:05 +00:00
|
|
|
|
2005-12-07 23:08:39 +00:00
|
|
|
// The FrameTarget represents the closest frame to a point that can be selected
|
|
|
|
// The frame is the frame represented, frameEdge says whether one end of the
|
|
|
|
// frame is the result (in which case different handling is needed), and
|
|
|
|
// afterFrame says which end is repersented if frameEdge is true
|
|
|
|
struct FrameTarget {
|
2011-09-29 06:19:26 +00:00
|
|
|
FrameTarget(nsIFrame* aFrame, bool aFrameEdge, bool aAfterFrame,
|
|
|
|
bool aEmptyBlock = false) :
|
2010-06-14 03:11:30 +00:00
|
|
|
frame(aFrame), frameEdge(aFrameEdge), afterFrame(aAfterFrame),
|
|
|
|
emptyBlock(aEmptyBlock) { }
|
2005-12-07 23:08:39 +00:00
|
|
|
static FrameTarget Null() {
|
2012-07-30 14:20:58 +00:00
|
|
|
return FrameTarget(nullptr, false, false);
|
2005-12-07 23:08:39 +00:00
|
|
|
}
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsNull() {
|
2005-12-07 23:08:39 +00:00
|
|
|
return !frame;
|
|
|
|
}
|
|
|
|
nsIFrame* frame;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool frameEdge;
|
|
|
|
bool afterFrame;
|
|
|
|
bool emptyBlock;
|
2005-12-07 23:08:39 +00:00
|
|
|
};
|
1999-09-29 20:04:05 +00:00
|
|
|
|
2005-12-07 23:08:39 +00:00
|
|
|
// See function implementation for information
|
2012-05-29 13:13:36 +00:00
|
|
|
static FrameTarget GetSelectionClosestFrame(nsIFrame* aFrame, nsPoint aPoint,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t aFlags);
|
1999-09-29 20:04:05 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
static bool SelfIsSelectable(nsIFrame* aFrame, uint32_t aFlags)
|
2005-12-07 23:08:39 +00:00
|
|
|
{
|
2012-05-29 13:13:36 +00:00
|
|
|
if ((aFlags & nsIFrame::SKIP_HIDDEN) &&
|
|
|
|
!aFrame->GetStyleVisibility()->IsVisible()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return !aFrame->IsGeneratedContentFrame() &&
|
|
|
|
aFrame->GetStyleUIReset()->mUserSelect != NS_STYLE_USER_SELECT_NONE;
|
2005-12-07 23:08:39 +00:00
|
|
|
}
|
1999-11-18 19:40:52 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool SelectionDescendToKids(nsIFrame* aFrame) {
|
2012-08-22 15:56:38 +00:00
|
|
|
uint8_t style = aFrame->GetStyleUIReset()->mUserSelect;
|
2005-12-07 23:08:39 +00:00
|
|
|
nsIFrame* parent = aFrame->GetParent();
|
|
|
|
// If we are only near (not directly over) then don't traverse
|
|
|
|
// frames with independent selection (e.g. text and list controls)
|
|
|
|
// unless we're already inside such a frame (see bug 268497). Note that this
|
|
|
|
// prevents any of the users of this method from entering form controls.
|
|
|
|
// XXX We might want some way to allow using the up-arrow to go into a form
|
|
|
|
// control, but the focus didn't work right anyway; it'd probably be enough
|
|
|
|
// if the left and right arrows could enter textboxes (which I don't believe
|
|
|
|
// they can at the moment)
|
|
|
|
return !aFrame->IsGeneratedContentFrame() &&
|
|
|
|
style != NS_STYLE_USER_SELECT_ALL &&
|
|
|
|
style != NS_STYLE_USER_SELECT_NONE &&
|
|
|
|
((parent->GetStateBits() & NS_FRAME_INDEPENDENT_SELECTION) ||
|
|
|
|
!(aFrame->GetStateBits() & NS_FRAME_INDEPENDENT_SELECTION));
|
|
|
|
}
|
1999-11-18 19:40:52 +00:00
|
|
|
|
2005-12-07 23:08:39 +00:00
|
|
|
static FrameTarget GetSelectionClosestFrameForChild(nsIFrame* aChild,
|
2012-05-29 13:13:36 +00:00
|
|
|
nsPoint aPoint,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t aFlags)
|
2005-12-07 23:08:39 +00:00
|
|
|
{
|
|
|
|
nsIFrame* parent = aChild->GetParent();
|
|
|
|
if (SelectionDescendToKids(aChild)) {
|
|
|
|
nsPoint pt = aPoint - aChild->GetOffsetTo(parent);
|
2012-05-29 13:13:36 +00:00
|
|
|
return GetSelectionClosestFrame(aChild, pt, aFlags);
|
2005-12-07 23:08:39 +00:00
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
return FrameTarget(aChild, false, false);
|
2005-12-07 23:08:39 +00:00
|
|
|
}
|
1999-11-18 19:40:52 +00:00
|
|
|
|
2005-12-07 23:08:39 +00:00
|
|
|
// When the cursor needs to be at the beginning of a block, it shouldn't be
|
|
|
|
// before the first child. A click on a block whose first child is a block
|
|
|
|
// should put the cursor in the child. The cursor shouldn't be between the
|
|
|
|
// blocks, because that's not where it's expected.
|
|
|
|
// Note that this method is guaranteed to succeed.
|
|
|
|
static FrameTarget DrillDownToSelectionFrame(nsIFrame* aFrame,
|
2012-08-22 15:56:38 +00:00
|
|
|
bool aEndFrame, uint32_t aFlags) {
|
2005-12-07 23:08:39 +00:00
|
|
|
if (SelectionDescendToKids(aFrame)) {
|
2012-07-30 14:20:58 +00:00
|
|
|
nsIFrame* result = nullptr;
|
2011-08-24 20:54:30 +00:00
|
|
|
nsIFrame *frame = aFrame->GetFirstPrincipalChild();
|
2005-12-07 23:08:39 +00:00
|
|
|
if (!aEndFrame) {
|
2012-05-29 13:13:36 +00:00
|
|
|
while (frame && (!SelfIsSelectable(frame, aFlags) ||
|
2005-12-07 23:08:39 +00:00
|
|
|
frame->IsEmpty()))
|
|
|
|
frame = frame->GetNextSibling();
|
|
|
|
if (frame)
|
|
|
|
result = frame;
|
|
|
|
} else {
|
|
|
|
// Because the frame tree is singly linked, to find the last frame,
|
|
|
|
// we have to iterate through all the frames
|
|
|
|
// XXX I have a feeling this could be slow for long blocks, although
|
|
|
|
// I can't find any slowdowns
|
|
|
|
while (frame) {
|
2012-05-29 13:13:36 +00:00
|
|
|
if (!frame->IsEmpty() && SelfIsSelectable(frame, aFlags))
|
2005-12-07 23:08:39 +00:00
|
|
|
result = frame;
|
|
|
|
frame = frame->GetNextSibling();
|
1999-11-18 19:40:52 +00:00
|
|
|
}
|
2005-12-07 23:08:39 +00:00
|
|
|
}
|
|
|
|
if (result)
|
2012-05-29 13:13:36 +00:00
|
|
|
return DrillDownToSelectionFrame(result, aEndFrame, aFlags);
|
2005-12-07 23:08:39 +00:00
|
|
|
}
|
|
|
|
// If the current frame has no targetable children, target the current frame
|
2011-10-17 14:59:28 +00:00
|
|
|
return FrameTarget(aFrame, true, aEndFrame);
|
2005-12-07 23:08:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// This method finds the closest valid FrameTarget on a given line; if there is
|
|
|
|
// no valid FrameTarget on the line, it returns a null FrameTarget
|
|
|
|
static FrameTarget GetSelectionClosestFrameForLine(
|
|
|
|
nsBlockFrame* aParent,
|
|
|
|
nsBlockFrame::line_iterator aLine,
|
2012-05-29 13:13:36 +00:00
|
|
|
nsPoint aPoint,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t aFlags)
|
2005-12-07 23:08:39 +00:00
|
|
|
{
|
|
|
|
nsIFrame *frame = aLine->mFirstChild;
|
|
|
|
// Account for end of lines (any iterator from the block is valid)
|
|
|
|
if (aLine == aParent->end_lines())
|
2012-05-29 13:13:36 +00:00
|
|
|
return DrillDownToSelectionFrame(aParent, true, aFlags);
|
2012-07-30 14:20:58 +00:00
|
|
|
nsIFrame *closestFromLeft = nullptr, *closestFromRight = nullptr;
|
2005-12-07 23:08:39 +00:00
|
|
|
nsRect rect = aLine->mBounds;
|
|
|
|
nscoord closestLeft = rect.x, closestRight = rect.XMost();
|
2012-08-22 15:56:38 +00:00
|
|
|
for (int32_t n = aLine->GetChildCount(); n;
|
2005-12-07 23:08:39 +00:00
|
|
|
--n, frame = frame->GetNextSibling()) {
|
2012-05-29 13:13:36 +00:00
|
|
|
if (!SelfIsSelectable(frame, aFlags) || frame->IsEmpty())
|
2005-12-07 23:08:39 +00:00
|
|
|
continue;
|
|
|
|
nsRect frameRect = frame->GetRect();
|
|
|
|
if (aPoint.x >= frameRect.x) {
|
|
|
|
if (aPoint.x < frameRect.XMost()) {
|
2012-05-29 13:13:36 +00:00
|
|
|
return GetSelectionClosestFrameForChild(frame, aPoint, aFlags);
|
2005-12-07 23:08:39 +00:00
|
|
|
}
|
|
|
|
if (frameRect.XMost() >= closestLeft) {
|
|
|
|
closestFromLeft = frame;
|
|
|
|
closestLeft = frameRect.XMost();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (frameRect.x <= closestRight) {
|
|
|
|
closestFromRight = frame;
|
|
|
|
closestRight = frameRect.x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!closestFromLeft && !closestFromRight) {
|
|
|
|
// We should only get here if there are no selectable frames on a line
|
|
|
|
// XXX Do we need more elaborate handling here?
|
|
|
|
return FrameTarget::Null();
|
|
|
|
}
|
|
|
|
if (closestFromLeft &&
|
|
|
|
(!closestFromRight ||
|
|
|
|
(abs(aPoint.x - closestLeft) <= abs(aPoint.x - closestRight)))) {
|
2012-05-29 13:13:36 +00:00
|
|
|
return GetSelectionClosestFrameForChild(closestFromLeft, aPoint, aFlags);
|
2005-12-07 23:08:39 +00:00
|
|
|
}
|
2012-05-29 13:13:36 +00:00
|
|
|
return GetSelectionClosestFrameForChild(closestFromRight, aPoint, aFlags);
|
2005-12-07 23:08:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// This method is for the special handling we do for block frames; they're
|
|
|
|
// special because they represent paragraphs and because they are organized
|
|
|
|
// into lines, which have bounds that are not stored elsewhere in the
|
|
|
|
// frame tree. Returns a null FrameTarget for frames which are not
|
2010-06-14 03:11:30 +00:00
|
|
|
// blocks or blocks with no lines except editable one.
|
2005-12-07 23:08:39 +00:00
|
|
|
static FrameTarget GetSelectionClosestFrameForBlock(nsIFrame* aFrame,
|
2012-05-29 13:13:36 +00:00
|
|
|
nsPoint aPoint,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t aFlags)
|
2005-12-07 23:08:39 +00:00
|
|
|
{
|
2008-07-13 22:10:23 +00:00
|
|
|
nsBlockFrame* bf = nsLayoutUtils::GetAsBlock(aFrame); // used only for QI
|
|
|
|
if (!bf)
|
2005-12-07 23:08:39 +00:00
|
|
|
return FrameTarget::Null();
|
|
|
|
|
|
|
|
// This code searches for the correct line
|
|
|
|
nsBlockFrame::line_iterator firstLine = bf->begin_lines();
|
|
|
|
nsBlockFrame::line_iterator end = bf->end_lines();
|
2010-06-14 03:11:30 +00:00
|
|
|
if (firstLine == end) {
|
|
|
|
nsIContent *blockContent = aFrame->GetContent();
|
2012-08-28 01:55:30 +00:00
|
|
|
if (blockContent) {
|
|
|
|
// Return with empty flag true.
|
2011-10-17 14:59:28 +00:00
|
|
|
return FrameTarget(aFrame, false, false, true);
|
2010-06-14 03:11:30 +00:00
|
|
|
}
|
2005-12-07 23:08:39 +00:00
|
|
|
return FrameTarget::Null();
|
2010-06-14 03:11:30 +00:00
|
|
|
}
|
2005-12-07 23:08:39 +00:00
|
|
|
nsBlockFrame::line_iterator curLine = firstLine;
|
|
|
|
nsBlockFrame::line_iterator closestLine = end;
|
|
|
|
while (curLine != end) {
|
|
|
|
// Check to see if our point lies with the line's Y bounds
|
|
|
|
nscoord y = aPoint.y - curLine->mBounds.y;
|
|
|
|
nscoord height = curLine->mBounds.height;
|
|
|
|
if (y >= 0 && y < height) {
|
|
|
|
closestLine = curLine;
|
|
|
|
break; // We found the line; stop looking
|
|
|
|
}
|
|
|
|
if (y < 0)
|
|
|
|
break;
|
|
|
|
++curLine;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (closestLine == end) {
|
|
|
|
nsBlockFrame::line_iterator prevLine = curLine.prev();
|
|
|
|
nsBlockFrame::line_iterator nextLine = curLine;
|
|
|
|
// Avoid empty lines
|
|
|
|
while (nextLine != end && nextLine->IsEmpty())
|
|
|
|
++nextLine;
|
|
|
|
while (prevLine != end && prevLine->IsEmpty())
|
|
|
|
--prevLine;
|
|
|
|
|
|
|
|
// This hidden pref dictates whether a point above or below all lines comes
|
|
|
|
// up with a line or the beginning or end of the frame; 0 on Windows,
|
|
|
|
// 1 on other platforms by default at the writing of this code
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t dragOutOfFrame =
|
2011-05-25 06:32:00 +00:00
|
|
|
Preferences::GetInt("browser.drag_out_of_frame_style");
|
2005-12-07 23:08:39 +00:00
|
|
|
|
|
|
|
if (prevLine == end) {
|
|
|
|
if (dragOutOfFrame == 1 || nextLine == end)
|
2012-05-29 13:13:36 +00:00
|
|
|
return DrillDownToSelectionFrame(aFrame, false, aFlags);
|
2005-12-07 23:08:39 +00:00
|
|
|
closestLine = nextLine;
|
|
|
|
} else if (nextLine == end) {
|
|
|
|
if (dragOutOfFrame == 1)
|
2012-05-29 13:13:36 +00:00
|
|
|
return DrillDownToSelectionFrame(aFrame, true, aFlags);
|
2005-12-07 23:08:39 +00:00
|
|
|
closestLine = prevLine;
|
|
|
|
} else { // Figure out which line is closer
|
|
|
|
if (aPoint.y - prevLine->mBounds.YMost() < nextLine->mBounds.y - aPoint.y)
|
|
|
|
closestLine = prevLine;
|
|
|
|
else
|
|
|
|
closestLine = nextLine;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
do {
|
|
|
|
FrameTarget target = GetSelectionClosestFrameForLine(bf, closestLine,
|
2012-05-29 13:13:36 +00:00
|
|
|
aPoint, aFlags);
|
2005-12-07 23:08:39 +00:00
|
|
|
if (!target.IsNull())
|
|
|
|
return target;
|
|
|
|
++closestLine;
|
|
|
|
} while (closestLine != end);
|
|
|
|
// Fall back to just targeting the last targetable place
|
2012-05-29 13:13:36 +00:00
|
|
|
return DrillDownToSelectionFrame(aFrame, true, aFlags);
|
2005-12-07 23:08:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetSelectionClosestFrame is the helper function that calculates the closest
|
|
|
|
// frame to the given point.
|
|
|
|
// It doesn't completely account for offset styles, so needs to be used in
|
|
|
|
// restricted environments.
|
2006-08-28 20:12:37 +00:00
|
|
|
// Cannot handle overlapping frames correctly, so it should receive the output
|
2005-12-07 23:08:39 +00:00
|
|
|
// of GetFrameForPoint
|
|
|
|
// Guaranteed to return a valid FrameTarget
|
2012-05-29 13:13:36 +00:00
|
|
|
static FrameTarget GetSelectionClosestFrame(nsIFrame* aFrame, nsPoint aPoint,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t aFlags)
|
2005-12-07 23:08:39 +00:00
|
|
|
{
|
|
|
|
{
|
|
|
|
// Handle blocks; if the frame isn't a block, the method fails
|
2012-05-29 13:13:36 +00:00
|
|
|
FrameTarget target = GetSelectionClosestFrameForBlock(aFrame, aPoint, aFlags);
|
2005-12-07 23:08:39 +00:00
|
|
|
if (!target.IsNull())
|
|
|
|
return target;
|
|
|
|
}
|
|
|
|
|
2011-08-24 20:54:30 +00:00
|
|
|
nsIFrame *kid = aFrame->GetFirstPrincipalChild();
|
2005-12-07 23:08:39 +00:00
|
|
|
|
|
|
|
if (kid) {
|
|
|
|
// Go through all the child frames to find the closest one
|
1999-11-18 19:40:52 +00:00
|
|
|
|
2005-12-07 23:08:39 +00:00
|
|
|
// Large number to force the comparison to succeed
|
|
|
|
const nscoord HUGE_DISTANCE = nscoord_MAX;
|
|
|
|
nscoord closestXDistance = HUGE_DISTANCE;
|
|
|
|
nscoord closestYDistance = HUGE_DISTANCE;
|
2012-07-30 14:20:58 +00:00
|
|
|
nsIFrame *closestFrame = nullptr;
|
2005-12-07 23:08:39 +00:00
|
|
|
|
2006-03-01 21:18:30 +00:00
|
|
|
for (; kid; kid = kid->GetNextSibling()) {
|
2012-05-29 13:13:36 +00:00
|
|
|
if (!SelfIsSelectable(kid, aFlags) || kid->IsEmpty())
|
2005-12-07 23:08:39 +00:00
|
|
|
continue;
|
1999-11-18 19:40:52 +00:00
|
|
|
|
2012-08-08 11:37:14 +00:00
|
|
|
if (nsLayoutUtils::PointIsCloserToRect(aPoint, kid->GetRect(),
|
|
|
|
closestXDistance,
|
|
|
|
closestYDistance))
|
|
|
|
closestFrame = kid;
|
2006-03-01 21:18:30 +00:00
|
|
|
}
|
2005-12-08 18:09:17 +00:00
|
|
|
if (closestFrame)
|
2012-05-29 13:13:36 +00:00
|
|
|
return GetSelectionClosestFrameForChild(closestFrame, aPoint, aFlags);
|
2000-10-28 22:17:53 +00:00
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
return FrameTarget(aFrame, false, false);
|
2005-12-07 23:08:39 +00:00
|
|
|
}
|
1999-09-29 20:04:05 +00:00
|
|
|
|
2006-02-27 05:57:37 +00:00
|
|
|
nsIFrame::ContentOffsets OffsetsForSingleFrame(nsIFrame* aFrame, nsPoint aPoint)
|
2005-12-07 23:08:39 +00:00
|
|
|
{
|
2006-02-27 05:57:37 +00:00
|
|
|
nsIFrame::ContentOffsets offsets;
|
|
|
|
FrameContentRange range = GetRangeForFrame(aFrame);
|
|
|
|
offsets.content = range.content;
|
|
|
|
// If there are continuations (meaning it's not one rectangle), this is the
|
|
|
|
// best this function can do
|
|
|
|
if (aFrame->GetNextContinuation() || aFrame->GetPrevContinuation()) {
|
|
|
|
offsets.offset = range.start;
|
|
|
|
offsets.secondaryOffset = range.end;
|
2011-10-17 14:59:28 +00:00
|
|
|
offsets.associateWithNext = true;
|
2006-02-27 05:57:37 +00:00
|
|
|
return offsets;
|
|
|
|
}
|
2000-08-08 23:48:42 +00:00
|
|
|
|
2006-02-27 05:57:37 +00:00
|
|
|
// Figure out whether the offsets should be over, after, or before the frame
|
|
|
|
nsRect rect(nsPoint(0, 0), aFrame->GetSize());
|
|
|
|
|
2012-08-02 11:38:51 +00:00
|
|
|
bool isBlock = aFrame->GetDisplay() != NS_STYLE_DISPLAY_INLINE;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool isRtl = (aFrame->GetStyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL);
|
2006-02-27 05:57:37 +00:00
|
|
|
if ((isBlock && rect.y < aPoint.y) ||
|
|
|
|
(!isBlock && ((isRtl && rect.x + rect.width / 2 > aPoint.x) ||
|
|
|
|
(!isRtl && rect.x + rect.width / 2 < aPoint.x)))) {
|
|
|
|
offsets.offset = range.end;
|
|
|
|
if (rect.Contains(aPoint))
|
|
|
|
offsets.secondaryOffset = range.start;
|
|
|
|
else
|
|
|
|
offsets.secondaryOffset = range.end;
|
|
|
|
} else {
|
|
|
|
offsets.offset = range.start;
|
|
|
|
if (rect.Contains(aPoint))
|
|
|
|
offsets.secondaryOffset = range.end;
|
|
|
|
else
|
|
|
|
offsets.secondaryOffset = range.start;
|
|
|
|
}
|
|
|
|
offsets.associateWithNext = (offsets.offset == range.start);
|
|
|
|
return offsets;
|
|
|
|
}
|
|
|
|
|
2006-03-13 01:13:25 +00:00
|
|
|
static nsIFrame* AdjustFrameForSelectionStyles(nsIFrame* aFrame) {
|
|
|
|
nsIFrame* adjustedFrame = aFrame;
|
|
|
|
for (nsIFrame* frame = aFrame; frame; frame = frame->GetParent())
|
2005-12-07 23:08:39 +00:00
|
|
|
{
|
|
|
|
// These are the conditions that make all children not able to handle
|
|
|
|
// a cursor.
|
|
|
|
if (frame->GetStyleUIReset()->mUserSelect == NS_STYLE_USER_SELECT_NONE ||
|
|
|
|
frame->GetStyleUIReset()->mUserSelect == NS_STYLE_USER_SELECT_ALL ||
|
|
|
|
frame->IsGeneratedContentFrame()) {
|
|
|
|
adjustedFrame = frame;
|
1999-09-29 20:04:05 +00:00
|
|
|
}
|
2005-12-07 23:08:39 +00:00
|
|
|
}
|
2006-03-13 01:13:25 +00:00
|
|
|
return adjustedFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-02 19:33:49 +00:00
|
|
|
nsIFrame::ContentOffsets nsIFrame::GetContentOffsetsFromPoint(nsPoint aPoint,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t aFlags)
|
2006-10-02 19:33:49 +00:00
|
|
|
{
|
|
|
|
nsIFrame *adjustedFrame;
|
2012-05-29 13:13:36 +00:00
|
|
|
if (aFlags & IGNORE_SELECTION_STYLE) {
|
2006-10-02 19:33:49 +00:00
|
|
|
adjustedFrame = this;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// This section of code deals with special selection styles. Note that
|
|
|
|
// -moz-none and -moz-all exist, even though they don't need to be explicitly
|
|
|
|
// handled.
|
|
|
|
// The offset is forced not to end up in generated content; content offsets
|
|
|
|
// cannot represent content outside of the document's content tree.
|
|
|
|
|
|
|
|
adjustedFrame = AdjustFrameForSelectionStyles(this);
|
|
|
|
|
|
|
|
// -moz-user-select: all needs special handling, because clicking on it
|
|
|
|
// should lead to the whole frame being selected
|
|
|
|
if (adjustedFrame && adjustedFrame->GetStyleUIReset()->mUserSelect ==
|
|
|
|
NS_STYLE_USER_SELECT_ALL) {
|
|
|
|
return OffsetsForSingleFrame(adjustedFrame, aPoint +
|
2006-02-27 05:57:37 +00:00
|
|
|
this->GetOffsetTo(adjustedFrame));
|
2006-10-02 19:33:49 +00:00
|
|
|
}
|
2006-02-27 05:57:37 +00:00
|
|
|
|
2006-10-02 19:33:49 +00:00
|
|
|
// For other cases, try to find a closest frame starting from the parent of
|
|
|
|
// the unselectable frame
|
|
|
|
if (adjustedFrame != this)
|
|
|
|
adjustedFrame = adjustedFrame->GetParent();
|
|
|
|
}
|
2005-12-07 23:08:39 +00:00
|
|
|
|
|
|
|
nsPoint adjustedPoint = aPoint + this->GetOffsetTo(adjustedFrame);
|
2006-10-02 19:33:49 +00:00
|
|
|
|
2012-05-29 13:13:36 +00:00
|
|
|
FrameTarget closest =
|
|
|
|
GetSelectionClosestFrame(adjustedFrame, adjustedPoint, aFlags);
|
2005-12-07 23:08:39 +00:00
|
|
|
|
2010-06-14 03:11:30 +00:00
|
|
|
if (closest.emptyBlock) {
|
|
|
|
ContentOffsets offsets;
|
|
|
|
NS_ASSERTION(closest.frame,
|
|
|
|
"closest.frame must not be null when it's empty");
|
|
|
|
offsets.content = closest.frame->GetContent();
|
|
|
|
offsets.offset = 0;
|
|
|
|
offsets.secondaryOffset = 0;
|
2011-10-17 14:59:28 +00:00
|
|
|
offsets.associateWithNext = true;
|
2010-06-14 03:11:30 +00:00
|
|
|
return offsets;
|
|
|
|
}
|
|
|
|
|
2005-12-07 23:08:39 +00:00
|
|
|
// If the correct offset is at one end of a frame, use offset-based
|
|
|
|
// calculation method
|
|
|
|
if (closest.frameEdge) {
|
2006-02-27 05:57:37 +00:00
|
|
|
ContentOffsets offsets;
|
|
|
|
FrameContentRange range = GetRangeForFrame(closest.frame);
|
|
|
|
offsets.content = range.content;
|
|
|
|
if (closest.afterFrame)
|
|
|
|
offsets.offset = range.end;
|
|
|
|
else
|
|
|
|
offsets.offset = range.start;
|
|
|
|
offsets.secondaryOffset = offsets.offset;
|
|
|
|
offsets.associateWithNext = (offsets.offset == range.start);
|
|
|
|
return offsets;
|
2005-12-07 23:08:39 +00:00
|
|
|
}
|
|
|
|
nsPoint pt = aPoint - closest.frame->GetOffsetTo(this);
|
2007-07-08 07:08:04 +00:00
|
|
|
return static_cast<nsFrame*>(closest.frame)->CalcContentOffsetsFromFramePoint(pt);
|
2005-12-07 23:08:39 +00:00
|
|
|
|
|
|
|
// XXX should I add some kind of offset standardization?
|
|
|
|
// consider <b>xxxxx</b><i>zzzzz</i>; should any click between the last
|
|
|
|
// x and first z put the cursor in the same logical position in addition
|
|
|
|
// to the same visual position?
|
|
|
|
}
|
|
|
|
|
2006-02-27 05:57:37 +00:00
|
|
|
nsIFrame::ContentOffsets nsFrame::CalcContentOffsetsFromFramePoint(nsPoint aPoint)
|
2005-12-07 23:08:39 +00:00
|
|
|
{
|
2006-02-27 05:57:37 +00:00
|
|
|
return OffsetsForSingleFrame(this, aPoint);
|
1999-09-29 20:04:05 +00:00
|
|
|
}
|
|
|
|
|
1998-11-18 05:25:26 +00:00
|
|
|
NS_IMETHODIMP
|
2004-12-30 21:56:11 +00:00
|
|
|
nsFrame::GetCursor(const nsPoint& aPoint,
|
|
|
|
nsIFrame::Cursor& aCursor)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2004-12-30 21:56:11 +00:00
|
|
|
FillCursorInformationFromStyle(GetStyleUserInterface(), aCursor);
|
|
|
|
if (NS_STYLE_CURSOR_AUTO == aCursor.mCursor) {
|
|
|
|
aCursor.mCursor = NS_STYLE_CURSOR_DEFAULT;
|
1998-11-18 02:11:54 +00:00
|
|
|
}
|
2004-12-30 21:56:11 +00:00
|
|
|
|
|
|
|
|
1998-11-18 05:25:26 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
// Resize and incremental reflow
|
1998-05-14 00:47:32 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
/* virtual */ void
|
|
|
|
nsFrame::MarkIntrinsicWidthsDirty()
|
|
|
|
{
|
|
|
|
// This version is meant only for what used to be box-to-block adaptors.
|
|
|
|
// It should not be called by other derived classes.
|
|
|
|
if (IsBoxWrapped()) {
|
|
|
|
nsBoxLayoutMetrics *metrics = BoxMetrics();
|
|
|
|
|
|
|
|
SizeNeedsRecalc(metrics->mPrefSize);
|
|
|
|
SizeNeedsRecalc(metrics->mMinSize);
|
|
|
|
SizeNeedsRecalc(metrics->mMaxSize);
|
|
|
|
SizeNeedsRecalc(metrics->mBlockPrefSize);
|
|
|
|
SizeNeedsRecalc(metrics->mBlockMinSize);
|
|
|
|
CoordNeedsRecalc(metrics->mFlex);
|
|
|
|
CoordNeedsRecalc(metrics->mAscent);
|
|
|
|
}
|
2012-04-16 22:32:12 +00:00
|
|
|
|
|
|
|
if (GetStateBits() & NS_FRAME_FONT_INFLATION_FLOW_ROOT) {
|
|
|
|
nsFontInflationData::MarkFontInflationDataTextDirty(this);
|
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nscoord
|
2011-04-08 01:04:40 +00:00
|
|
|
nsFrame::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 05:38:33 +00:00
|
|
|
{
|
|
|
|
nscoord result = 0;
|
|
|
|
DISPLAY_MIN_WIDTH(this, result);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nscoord
|
2011-04-08 01:04:40 +00:00
|
|
|
nsFrame::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 05:38:33 +00:00
|
|
|
{
|
|
|
|
nscoord result = 0;
|
|
|
|
DISPLAY_PREF_WIDTH(this, result);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ void
|
2011-04-08 01:04:40 +00:00
|
|
|
nsFrame::AddInlineMinWidth(nsRenderingContext *aRenderingContext,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsIFrame::InlineMinWidthData *aData)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(GetParent(), "Must have a parent if we get here!");
|
2011-09-29 06:19:26 +00:00
|
|
|
bool canBreak = !CanContinueTextRun() &&
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
GetParent()->GetStyleText()->WhiteSpaceCanWrap();
|
|
|
|
|
|
|
|
if (canBreak)
|
2007-06-21 22:32:47 +00:00
|
|
|
aData->OptionallyBreak(aRenderingContext);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
aData->trailingWhitespace = 0;
|
2011-10-17 14:59:28 +00:00
|
|
|
aData->skipWhitespace = false;
|
2012-07-30 14:20:58 +00:00
|
|
|
aData->trailingTextFrame = nullptr;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
aData->currentLine += nsLayoutUtils::IntrinsicForContainer(aRenderingContext,
|
|
|
|
this, nsLayoutUtils::MIN_WIDTH);
|
2011-10-17 14:59:28 +00:00
|
|
|
aData->atStartOfLine = false;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
if (canBreak)
|
2007-06-21 22:32:47 +00:00
|
|
|
aData->OptionallyBreak(aRenderingContext);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ void
|
2011-04-08 01:04:40 +00:00
|
|
|
nsFrame::AddInlinePrefWidth(nsRenderingContext *aRenderingContext,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsIFrame::InlinePrefWidthData *aData)
|
|
|
|
{
|
|
|
|
aData->trailingWhitespace = 0;
|
2011-10-17 14:59:28 +00:00
|
|
|
aData->skipWhitespace = false;
|
2007-09-24 17:30:42 +00:00
|
|
|
nscoord myPref = nsLayoutUtils::IntrinsicForContainer(aRenderingContext,
|
|
|
|
this, nsLayoutUtils::PREF_WIDTH);
|
|
|
|
aData->currentLine = NSCoordSaturatingAdd(aData->currentLine, myPref);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-04-08 01:04:40 +00:00
|
|
|
nsIFrame::InlineMinWidthData::ForceBreak(nsRenderingContext *aRenderingContext)
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
{
|
|
|
|
currentLine -= trailingWhitespace;
|
2009-09-16 15:01:36 +00:00
|
|
|
prevLines = NS_MAX(prevLines, currentLine);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
currentLine = trailingWhitespace = 0;
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0, i_end = floats.Length(); i != i_end; ++i) {
|
2012-08-10 11:16:52 +00:00
|
|
|
nscoord float_min = floats[i].Width();
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
if (float_min > prevLines)
|
|
|
|
prevLines = float_min;
|
|
|
|
}
|
|
|
|
floats.Clear();
|
2012-07-30 14:20:58 +00:00
|
|
|
trailingTextFrame = nullptr;
|
2011-10-17 14:59:28 +00:00
|
|
|
skipWhitespace = true;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-04-08 01:04:40 +00:00
|
|
|
nsIFrame::InlineMinWidthData::OptionallyBreak(nsRenderingContext *aRenderingContext,
|
2011-03-24 15:22:37 +00:00
|
|
|
nscoord aHyphenWidth)
|
2007-06-21 22:32:47 +00:00
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
trailingTextFrame = nullptr;
|
2007-06-21 22:32:47 +00:00
|
|
|
|
|
|
|
// If we can fit more content into a smaller width by staying on this
|
|
|
|
// line (because we're still at a negative offset due to negative
|
|
|
|
// text-indent or negative margin), don't break. Otherwise, do the
|
|
|
|
// same as ForceBreak. it doesn't really matter when we accumulate
|
|
|
|
// floats.
|
2011-03-24 15:22:37 +00:00
|
|
|
if (currentLine + aHyphenWidth < 0 || atStartOfLine)
|
2007-06-21 22:32:47 +00:00
|
|
|
return;
|
2011-03-24 15:22:37 +00:00
|
|
|
currentLine += aHyphenWidth;
|
2007-06-21 22:32:47 +00:00
|
|
|
ForceBreak(aRenderingContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-04-08 01:04:40 +00:00
|
|
|
nsIFrame::InlinePrefWidthData::ForceBreak(nsRenderingContext *aRenderingContext)
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
{
|
2009-02-03 14:42:18 +00:00
|
|
|
if (floats.Length() != 0) {
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// preferred widths accumulated for floats that have already
|
|
|
|
// been cleared past
|
|
|
|
nscoord floats_done = 0,
|
|
|
|
// preferred widths accumulated for floats that have not yet
|
|
|
|
// been cleared past
|
|
|
|
floats_cur_left = 0,
|
|
|
|
floats_cur_right = 0;
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0, i_end = floats.Length(); i != i_end; ++i) {
|
2012-08-10 11:16:52 +00:00
|
|
|
const FloatInfo& floatInfo = floats[i];
|
|
|
|
const nsStyleDisplay *floatDisp = floatInfo.Frame()->GetStyleDisplay();
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
if (floatDisp->mBreakType == NS_STYLE_CLEAR_LEFT ||
|
|
|
|
floatDisp->mBreakType == NS_STYLE_CLEAR_RIGHT ||
|
|
|
|
floatDisp->mBreakType == NS_STYLE_CLEAR_LEFT_AND_RIGHT) {
|
2008-03-07 21:20:03 +00:00
|
|
|
nscoord floats_cur = NSCoordSaturatingAdd(floats_cur_left,
|
|
|
|
floats_cur_right);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
if (floats_cur > floats_done)
|
|
|
|
floats_done = floats_cur;
|
|
|
|
if (floatDisp->mBreakType != NS_STYLE_CLEAR_RIGHT)
|
|
|
|
floats_cur_left = 0;
|
|
|
|
if (floatDisp->mBreakType != NS_STYLE_CLEAR_LEFT)
|
|
|
|
floats_cur_right = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord &floats_cur = floatDisp->mFloats == NS_STYLE_FLOAT_LEFT
|
|
|
|
? floats_cur_left : floats_cur_right;
|
2012-08-10 11:16:52 +00:00
|
|
|
nscoord floatWidth = floatInfo.Width();
|
2008-03-25 23:19:46 +00:00
|
|
|
// Negative-width floats don't change the available space so they
|
|
|
|
// shouldn't change our intrinsic line width either.
|
|
|
|
floats_cur =
|
2009-09-16 15:01:36 +00:00
|
|
|
NSCoordSaturatingAdd(floats_cur, NS_MAX(0, floatWidth));
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
}
|
|
|
|
|
2008-03-07 21:20:03 +00:00
|
|
|
nscoord floats_cur =
|
|
|
|
NSCoordSaturatingAdd(floats_cur_left, floats_cur_right);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
if (floats_cur > floats_done)
|
|
|
|
floats_done = floats_cur;
|
|
|
|
|
2007-11-09 17:16:36 +00:00
|
|
|
currentLine = NSCoordSaturatingAdd(currentLine, floats_done);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
|
|
|
floats.Clear();
|
|
|
|
}
|
|
|
|
|
2008-03-07 21:20:03 +00:00
|
|
|
currentLine =
|
|
|
|
NSCoordSaturatingSubtract(currentLine, trailingWhitespace, nscoord_MAX);
|
2009-09-16 15:01:36 +00:00
|
|
|
prevLines = NS_MAX(prevLines, currentLine);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
currentLine = trailingWhitespace = 0;
|
2011-10-17 14:59:28 +00:00
|
|
|
skipWhitespace = true;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-12-17 14:06:42 +00:00
|
|
|
AddCoord(const nsStyleCoord& aStyle,
|
2011-04-08 01:04:40 +00:00
|
|
|
nsRenderingContext* aRenderingContext,
|
2006-12-17 14:06:42 +00:00
|
|
|
nsIFrame* aFrame,
|
2010-09-09 15:21:46 +00:00
|
|
|
nscoord* aCoord, float* aPercent,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aClampNegativeToZero)
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
{
|
2010-09-11 16:27:13 +00:00
|
|
|
switch (aStyle.GetUnit()) {
|
|
|
|
case eStyleUnit_Coord: {
|
|
|
|
NS_ASSERTION(!aClampNegativeToZero || aStyle.GetCoordValue() >= 0,
|
|
|
|
"unexpected negative value");
|
|
|
|
*aCoord += aStyle.GetCoordValue();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case eStyleUnit_Percent: {
|
|
|
|
NS_ASSERTION(!aClampNegativeToZero || aStyle.GetPercentValue() >= 0.0f,
|
|
|
|
"unexpected negative value");
|
|
|
|
*aPercent += aStyle.GetPercentValue();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case eStyleUnit_Calc: {
|
|
|
|
const nsStyleCoord::Calc *calc = aStyle.GetCalcValue();
|
|
|
|
if (aClampNegativeToZero) {
|
|
|
|
// This is far from ideal when one is negative and one is positive.
|
|
|
|
*aCoord += NS_MAX(calc->mLength, 0);
|
|
|
|
*aPercent += NS_MAX(calc->mPercent, 0.0f);
|
|
|
|
} else {
|
|
|
|
*aCoord += calc->mLength;
|
|
|
|
*aPercent += calc->mPercent;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
return;
|
|
|
|
}
|
2010-09-09 15:21:46 +00:00
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nsIFrame::IntrinsicWidthOffsetData
|
2011-04-08 01:04:40 +00:00
|
|
|
nsFrame::IntrinsicWidthOffsets(nsRenderingContext* aRenderingContext)
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
{
|
|
|
|
IntrinsicWidthOffsetData result;
|
|
|
|
|
|
|
|
const nsStyleMargin *styleMargin = GetStyleMargin();
|
2008-03-06 00:05:26 +00:00
|
|
|
AddCoord(styleMargin->mMargin.GetLeft(), aRenderingContext, this,
|
2011-10-17 14:59:28 +00:00
|
|
|
&result.hMargin, &result.hPctMargin, false);
|
2008-03-06 00:05:26 +00:00
|
|
|
AddCoord(styleMargin->mMargin.GetRight(), aRenderingContext, this,
|
2011-10-17 14:59:28 +00:00
|
|
|
&result.hMargin, &result.hPctMargin, false);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
|
|
|
const nsStylePadding *stylePadding = GetStylePadding();
|
2008-03-06 00:05:26 +00:00
|
|
|
AddCoord(stylePadding->mPadding.GetLeft(), aRenderingContext, this,
|
2011-10-17 14:59:28 +00:00
|
|
|
&result.hPadding, &result.hPctPadding, true);
|
2008-03-06 00:05:26 +00:00
|
|
|
AddCoord(stylePadding->mPadding.GetRight(), aRenderingContext, this,
|
2011-10-17 14:59:28 +00:00
|
|
|
&result.hPadding, &result.hPctPadding, true);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
|
|
|
const nsStyleBorder *styleBorder = GetStyleBorder();
|
2012-05-31 05:19:49 +00:00
|
|
|
result.hBorder += styleBorder->GetComputedBorderWidth(NS_SIDE_LEFT);
|
|
|
|
result.hBorder += styleBorder->GetComputedBorderWidth(NS_SIDE_RIGHT);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
2007-01-28 17:20:01 +00:00
|
|
|
const nsStyleDisplay *disp = GetStyleDisplay();
|
|
|
|
if (IsThemed(disp)) {
|
2007-03-30 21:11:41 +00:00
|
|
|
nsPresContext *presContext = PresContext();
|
2007-01-28 17:20:01 +00:00
|
|
|
|
2009-01-15 03:27:09 +00:00
|
|
|
nsIntMargin border;
|
2007-01-28 17:20:01 +00:00
|
|
|
presContext->GetTheme()->GetWidgetBorder(presContext->DeviceContext(),
|
|
|
|
this, disp->mAppearance,
|
|
|
|
&border);
|
2007-02-07 07:46:44 +00:00
|
|
|
result.hBorder = presContext->DevPixelsToAppUnits(border.LeftRight());
|
2007-01-28 17:20:01 +00:00
|
|
|
|
2009-01-15 03:27:09 +00:00
|
|
|
nsIntMargin padding;
|
2007-01-28 17:20:01 +00:00
|
|
|
if (presContext->GetTheme()->GetWidgetPadding(presContext->DeviceContext(),
|
|
|
|
this, disp->mAppearance,
|
|
|
|
&padding)) {
|
2007-02-07 07:46:44 +00:00
|
|
|
result.hPadding = presContext->DevPixelsToAppUnits(padding.LeftRight());
|
2007-01-28 17:20:01 +00:00
|
|
|
result.hPctPadding = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2007-11-18 12:09:03 +00:00
|
|
|
/* virtual */ nsIFrame::IntrinsicSize
|
|
|
|
nsFrame::GetIntrinsicSize()
|
|
|
|
{
|
|
|
|
return IntrinsicSize(); // default is width/height set to eStyleUnit_None
|
|
|
|
}
|
|
|
|
|
2007-06-12 18:27:09 +00:00
|
|
|
/* virtual */ nsSize
|
|
|
|
nsFrame::GetIntrinsicRatio()
|
|
|
|
{
|
|
|
|
return nsSize(0, 0);
|
|
|
|
}
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
/* virtual */ nsSize
|
2011-04-08 01:04:40 +00:00
|
|
|
nsFrame::ComputeSize(nsRenderingContext *aRenderingContext,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsSize aCBSize, nscoord aAvailableWidth,
|
|
|
|
nsSize aMargin, nsSize aBorder, nsSize aPadding,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t aFlags)
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
{
|
|
|
|
nsSize result = ComputeAutoSize(aRenderingContext, aCBSize, aAvailableWidth,
|
2012-03-16 18:01:05 +00:00
|
|
|
aMargin, aBorder, aPadding,
|
|
|
|
aFlags & eShrinkWrap);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsSize boxSizingAdjust(0,0);
|
|
|
|
const nsStylePosition *stylePos = GetStylePosition();
|
|
|
|
|
|
|
|
switch (stylePos->mBoxSizing) {
|
|
|
|
case NS_STYLE_BOX_SIZING_BORDER:
|
|
|
|
boxSizingAdjust += aBorder;
|
|
|
|
// fall through
|
|
|
|
case NS_STYLE_BOX_SIZING_PADDING:
|
|
|
|
boxSizingAdjust += aPadding;
|
|
|
|
}
|
2007-05-03 23:11:00 +00:00
|
|
|
nscoord boxSizingToMarginEdgeWidth =
|
|
|
|
aMargin.width + aBorder.width + aPadding.width - boxSizingAdjust.width;
|
2012-09-05 21:13:37 +00:00
|
|
|
const nsStyleCoord* widthStyleCoord = &(stylePos->mWidth);
|
|
|
|
const nsStyleCoord* heightStyleCoord = &(stylePos->mHeight);
|
|
|
|
|
|
|
|
bool isFlexItem = IsFlexItem();
|
|
|
|
bool isHorizontalFlexItem = false;
|
|
|
|
|
|
|
|
#ifdef MOZ_FLEXBOX
|
|
|
|
if (isFlexItem) {
|
|
|
|
// Flex items use their "flex-basis" property in place of their main-size
|
|
|
|
// property (e.g. "width") for sizing purposes, *unless* they have
|
|
|
|
// "flex-basis:auto", in which case they use their main-size property after
|
|
|
|
// all.
|
|
|
|
uint32_t flexDirection = mParent->GetStylePosition()->mFlexDirection;
|
|
|
|
isHorizontalFlexItem =
|
|
|
|
flexDirection == NS_STYLE_FLEX_DIRECTION_ROW ||
|
|
|
|
flexDirection == NS_STYLE_FLEX_DIRECTION_ROW_REVERSE;
|
|
|
|
|
2012-10-17 02:04:29 +00:00
|
|
|
// NOTE: The logic here should match the similar chunk for determining
|
|
|
|
// widthStyleCoord and heightStyleCoord in
|
|
|
|
// nsLayoutUtils::ComputeSizeWithIntrinsicDimensions().
|
|
|
|
const nsStyleCoord* flexBasis = &(stylePos->mFlexBasis);
|
|
|
|
if (flexBasis->GetUnit() != eStyleUnit_Auto) {
|
2012-09-05 21:13:37 +00:00
|
|
|
if (isHorizontalFlexItem) {
|
2012-10-17 02:04:29 +00:00
|
|
|
widthStyleCoord = flexBasis;
|
2012-09-05 21:13:37 +00:00
|
|
|
} else {
|
2012-10-17 02:04:29 +00:00
|
|
|
// One caveat for vertical flex items: We don't support enumerated
|
|
|
|
// values (e.g. "max-content") for height properties yet. So, if our
|
|
|
|
// computed flex-basis is an enumerated value, we'll just behave as if
|
|
|
|
// it were "auto", which means "use the main-size property after all"
|
|
|
|
// (which is "height", in this case).
|
|
|
|
// NOTE: Once we support intrinsic sizing keywords for "height",
|
|
|
|
// we should remove this check.
|
|
|
|
if (flexBasis->GetUnit() != eStyleUnit_Enumerated) {
|
|
|
|
heightStyleCoord = flexBasis;
|
|
|
|
}
|
2012-09-05 21:13:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // MOZ_FLEXBOX
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// Compute width
|
|
|
|
|
2012-09-05 21:13:37 +00:00
|
|
|
if (widthStyleCoord->GetUnit() != eStyleUnit_Auto) {
|
2006-12-18 13:20:18 +00:00
|
|
|
result.width =
|
2007-05-03 23:11:00 +00:00
|
|
|
nsLayoutUtils::ComputeWidthValue(aRenderingContext, this,
|
|
|
|
aCBSize.width, boxSizingAdjust.width, boxSizingToMarginEdgeWidth,
|
2012-09-05 21:13:37 +00:00
|
|
|
*widthStyleCoord);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
}
|
|
|
|
|
2012-09-05 21:13:37 +00:00
|
|
|
// Flex items ignore their min & max sizing properties in their
|
|
|
|
// flex container's main-axis. (Those properties get applied later in
|
|
|
|
// the flexbox algorithm.)
|
|
|
|
if (stylePos->mMaxWidth.GetUnit() != eStyleUnit_None &&
|
|
|
|
!(isFlexItem && isHorizontalFlexItem)) {
|
2006-12-18 13:20:18 +00:00
|
|
|
nscoord maxWidth =
|
2007-05-03 23:11:00 +00:00
|
|
|
nsLayoutUtils::ComputeWidthValue(aRenderingContext, this,
|
|
|
|
aCBSize.width, boxSizingAdjust.width, boxSizingToMarginEdgeWidth,
|
|
|
|
stylePos->mMaxWidth);
|
2012-08-08 15:58:26 +00:00
|
|
|
result.width = NS_MIN(maxWidth, result.width);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
}
|
|
|
|
|
2012-09-04 23:26:10 +00:00
|
|
|
nscoord minWidth;
|
2012-09-05 21:13:37 +00:00
|
|
|
if (stylePos->mMinWidth.GetUnit() != eStyleUnit_Auto &&
|
|
|
|
!(isFlexItem && isHorizontalFlexItem)) {
|
2012-09-04 23:26:10 +00:00
|
|
|
minWidth =
|
|
|
|
nsLayoutUtils::ComputeWidthValue(aRenderingContext, this,
|
|
|
|
aCBSize.width, boxSizingAdjust.width, boxSizingToMarginEdgeWidth,
|
|
|
|
stylePos->mMinWidth);
|
|
|
|
} else {
|
|
|
|
// Treat "min-width: auto" as 0.
|
|
|
|
// NOTE: Technically, "auto" is supposed to behave like "min-content" on
|
|
|
|
// flex items. However, we don't need to worry about that here, because
|
|
|
|
// flex items' min-sizes are intentionally ignored until the flex
|
|
|
|
// container explicitly considers them during space distribution.
|
|
|
|
minWidth = 0;
|
|
|
|
}
|
2012-08-08 15:58:26 +00:00
|
|
|
result.width = NS_MAX(minWidth, result.width);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
|
|
|
// Compute height
|
2012-09-30 06:38:46 +00:00
|
|
|
// (but not if we're auto-height or if we recieved the "eUseAutoHeight"
|
|
|
|
// flag -- then, we'll just stick with the height that we already calculated
|
|
|
|
// in the initial ComputeAutoSize() call.)
|
|
|
|
if (!nsLayoutUtils::IsAutoHeight(*heightStyleCoord, aCBSize.height) &&
|
|
|
|
!(aFlags & nsIFrame::eUseAutoHeight)) {
|
2006-12-18 13:20:18 +00:00
|
|
|
result.height =
|
2012-08-08 15:58:26 +00:00
|
|
|
nsLayoutUtils::ComputeHeightValue(aCBSize.height,
|
|
|
|
boxSizingAdjust.height,
|
2012-09-05 21:13:37 +00:00
|
|
|
*heightStyleCoord);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (result.height != NS_UNCONSTRAINEDSIZE) {
|
2012-09-05 21:13:37 +00:00
|
|
|
if (!nsLayoutUtils::IsAutoHeight(stylePos->mMaxHeight, aCBSize.height) &&
|
|
|
|
!(isFlexItem && !isHorizontalFlexItem)) {
|
2006-12-18 13:20:18 +00:00
|
|
|
nscoord maxHeight =
|
2012-08-08 15:58:26 +00:00
|
|
|
nsLayoutUtils::ComputeHeightValue(aCBSize.height,
|
|
|
|
boxSizingAdjust.height,
|
|
|
|
stylePos->mMaxHeight);
|
|
|
|
result.height = NS_MIN(maxHeight, result.height);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
}
|
|
|
|
|
2012-09-05 21:13:37 +00:00
|
|
|
if (!nsLayoutUtils::IsAutoHeight(stylePos->mMinHeight, aCBSize.height) &&
|
|
|
|
!(isFlexItem && !isHorizontalFlexItem)) {
|
2006-12-18 13:20:18 +00:00
|
|
|
nscoord minHeight =
|
2012-08-08 15:58:26 +00:00
|
|
|
nsLayoutUtils::ComputeHeightValue(aCBSize.height,
|
|
|
|
boxSizingAdjust.height,
|
|
|
|
stylePos->mMinHeight);
|
|
|
|
result.height = NS_MAX(minHeight, result.height);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-17 22:31:07 +00:00
|
|
|
const nsStyleDisplay *disp = GetStyleDisplay();
|
|
|
|
if (IsThemed(disp)) {
|
2009-01-15 03:27:09 +00:00
|
|
|
nsIntSize widget(0, 0);
|
2011-09-29 06:19:26 +00:00
|
|
|
bool canOverride = true;
|
2007-03-30 21:11:41 +00:00
|
|
|
nsPresContext *presContext = PresContext();
|
2007-01-17 22:31:07 +00:00
|
|
|
presContext->GetTheme()->
|
|
|
|
GetMinimumWidgetSize(aRenderingContext, this, disp->mAppearance,
|
2009-01-15 03:27:09 +00:00
|
|
|
&widget, &canOverride);
|
2007-01-17 22:31:07 +00:00
|
|
|
|
2009-01-15 03:27:09 +00:00
|
|
|
nsSize size;
|
|
|
|
size.width = presContext->DevPixelsToAppUnits(widget.width);
|
|
|
|
size.height = presContext->DevPixelsToAppUnits(widget.height);
|
2007-01-17 22:31:07 +00:00
|
|
|
|
|
|
|
// GMWS() returns border-box; we need content-box
|
|
|
|
size.width -= aBorder.width + aPadding.width;
|
|
|
|
size.height -= aBorder.height + aPadding.height;
|
|
|
|
|
|
|
|
if (size.height > result.height || !canOverride)
|
|
|
|
result.height = size.height;
|
|
|
|
if (size.width > result.width || !canOverride)
|
|
|
|
result.width = size.width;
|
|
|
|
}
|
|
|
|
|
2012-08-08 15:58:26 +00:00
|
|
|
result.width = NS_MAX(0, result.width);
|
|
|
|
result.height = NS_MAX(0, result.height);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2007-10-12 08:30:54 +00:00
|
|
|
nsRect
|
|
|
|
nsIFrame::ComputeTightBounds(gfxContext* aContext) const
|
|
|
|
{
|
2010-10-07 04:25:46 +00:00
|
|
|
return GetVisualOverflowRect();
|
2007-10-12 08:30:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsRect
|
|
|
|
nsFrame::ComputeSimpleTightBounds(gfxContext* aContext) const
|
|
|
|
{
|
|
|
|
if (GetStyleOutline()->GetOutlineStyle() != NS_STYLE_BORDER_STYLE_NONE ||
|
2012-04-18 05:14:31 +00:00
|
|
|
GetStyleBorder()->HasBorder() || !GetStyleBackground()->IsTransparent() ||
|
2007-10-12 08:30:54 +00:00
|
|
|
GetStyleDisplay()->mAppearance) {
|
|
|
|
// Not necessarily tight, due to clipping, negative
|
|
|
|
// outline-offset, and lots of other issues, but that's OK
|
2010-10-07 04:25:46 +00:00
|
|
|
return GetVisualOverflowRect();
|
2007-10-12 08:30:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsRect r(0, 0, 0, 0);
|
2011-08-24 20:54:29 +00:00
|
|
|
ChildListIterator lists(this);
|
|
|
|
for (; !lists.IsDone(); lists.Next()) {
|
|
|
|
nsFrameList::Enumerator childFrames(lists.CurrentList());
|
|
|
|
for (; !childFrames.AtEnd(); childFrames.Next()) {
|
|
|
|
nsIFrame* child = childFrames.get();
|
|
|
|
r.UnionRect(r, child->ComputeTightBounds(aContext) + child->GetPosition());
|
2007-10-12 08:30:54 +00:00
|
|
|
}
|
2011-08-24 20:54:29 +00:00
|
|
|
}
|
2007-10-12 08:30:54 +00:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
/* virtual */ nsSize
|
2011-04-08 01:04:40 +00:00
|
|
|
nsFrame::ComputeAutoSize(nsRenderingContext *aRenderingContext,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsSize aCBSize, nscoord aAvailableWidth,
|
|
|
|
nsSize aMargin, nsSize aBorder, nsSize aPadding,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aShrinkWrap)
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
{
|
|
|
|
// Use basic shrink-wrapping as a default implementation.
|
|
|
|
nsSize result(0xdeadbeef, NS_UNCONSTRAINEDSIZE);
|
|
|
|
|
|
|
|
// don't bother setting it if the result won't be used
|
|
|
|
if (GetStylePosition()->mWidth.GetUnit() == eStyleUnit_Auto) {
|
|
|
|
nscoord availBased = aAvailableWidth - aMargin.width - aBorder.width -
|
|
|
|
aPadding.width;
|
|
|
|
result.width = ShrinkWidthToFit(aRenderingContext, availBased);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
2011-04-08 01:04:40 +00:00
|
|
|
nsFrame::ShrinkWidthToFit(nsRenderingContext *aRenderingContext,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nscoord aWidthInCB)
|
|
|
|
{
|
2012-01-25 01:21:29 +00:00
|
|
|
// If we're a container for font size inflation, then shrink
|
|
|
|
// wrapping inside of us should not apply font size inflation.
|
2012-05-21 05:18:27 +00:00
|
|
|
AutoMaybeDisableFontInflation an(this);
|
2012-01-25 01:21:29 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nscoord result;
|
|
|
|
nscoord minWidth = GetMinWidth(aRenderingContext);
|
|
|
|
if (minWidth > aWidthInCB) {
|
|
|
|
result = minWidth;
|
|
|
|
} else {
|
|
|
|
nscoord prefWidth = GetPrefWidth(aRenderingContext);
|
|
|
|
if (prefWidth > aWidthInCB) {
|
|
|
|
result = aWidthInCB;
|
|
|
|
} else {
|
|
|
|
result = prefWidth;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
1998-05-14 00:47:32 +00:00
|
|
|
|
1998-10-09 23:46:02 +00:00
|
|
|
NS_IMETHODIMP
|
2004-07-31 23:15:21 +00:00
|
|
|
nsFrame::WillReflow(nsPresContext* aPresContext)
|
1998-05-14 00:47:32 +00:00
|
|
|
{
|
2003-01-16 19:21:23 +00:00
|
|
|
#ifdef DEBUG_dbaron_off
|
2002-12-11 02:29:35 +00:00
|
|
|
// bug 81268
|
|
|
|
NS_ASSERTION(!(mState & NS_FRAME_IN_REFLOW),
|
|
|
|
"nsFrame::WillReflow: frame is already in reflow");
|
2002-12-11 03:35:21 +00:00
|
|
|
#endif
|
2002-12-11 02:29:35 +00:00
|
|
|
|
1998-06-25 16:33:10 +00:00
|
|
|
NS_FRAME_TRACE_MSG(NS_FRAME_TRACE_CALLS,
|
|
|
|
("WillReflow: oldState=%x", mState));
|
1998-05-14 00:47:32 +00:00
|
|
|
mState |= NS_FRAME_IN_REFLOW;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-09 23:46:02 +00:00
|
|
|
NS_IMETHODIMP
|
2004-07-31 23:15:21 +00:00
|
|
|
nsFrame::DidReflow(nsPresContext* aPresContext,
|
2001-12-07 14:51:12 +00:00
|
|
|
const nsHTMLReflowState* aReflowState,
|
|
|
|
nsDidReflowStatus aStatus)
|
1998-05-14 00:47:32 +00:00
|
|
|
{
|
1998-06-25 16:33:10 +00:00
|
|
|
NS_FRAME_TRACE_MSG(NS_FRAME_TRACE_CALLS,
|
|
|
|
("nsFrame::DidReflow: aStatus=%d", aStatus));
|
2011-04-29 23:02:33 +00:00
|
|
|
|
2012-08-29 05:49:16 +00:00
|
|
|
nsSVGEffects::InvalidateDirectRenderingObservers(this, nsSVGEffects::INVALIDATE_REFLOW);
|
|
|
|
|
1998-05-14 00:47:32 +00:00
|
|
|
if (NS_FRAME_REFLOW_FINISHED == aStatus) {
|
2000-01-12 08:28:24 +00:00
|
|
|
mState &= ~(NS_FRAME_IN_REFLOW | NS_FRAME_FIRST_REFLOW | NS_FRAME_IS_DIRTY |
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
1999-12-01 04:13:19 +00:00
|
|
|
}
|
1998-05-28 21:55:13 +00:00
|
|
|
|
2007-11-06 22:47:29 +00:00
|
|
|
// Notify the percent height observer if there is a percent height.
|
|
|
|
// The observer may be able to initiate another reflow with a computed
|
|
|
|
// height. This happens in the case where a table cell has no computed
|
|
|
|
// height but can fabricate one when the cell height is known.
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
if (aReflowState && aReflowState->mPercentHeightObserver &&
|
2010-08-25 10:17:55 +00:00
|
|
|
!GetPrevInFlow()) {
|
|
|
|
const nsStyleCoord &height = aReflowState->mStylePosition->mHeight;
|
|
|
|
if (height.HasPercent()) {
|
2002-04-10 21:32:41 +00:00
|
|
|
aReflowState->mPercentHeightObserver->NotifyPercentHeight(*aReflowState);
|
|
|
|
}
|
2001-12-07 14:51:12 +00:00
|
|
|
}
|
|
|
|
|
1998-05-14 00:47:32 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2011-04-29 23:02:33 +00:00
|
|
|
void
|
|
|
|
nsFrame::FinishReflowWithAbsoluteFrames(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
ReflowAbsoluteFrames(aPresContext, aDesiredSize, aReflowState, aStatus);
|
|
|
|
|
|
|
|
FinishAndStoreOverflow(&aDesiredSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsFrame::DestroyAbsoluteFrames(nsIFrame* aDestructRoot)
|
|
|
|
{
|
|
|
|
if (IsAbsoluteContainer()) {
|
|
|
|
GetAbsoluteContainingBlock()->DestroyFrames(this, aDestructRoot);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsFrame::ReflowAbsoluteFrames(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
if (HasAbsolutelyPositionedChildren()) {
|
|
|
|
nsAbsoluteContainingBlock* absoluteContainer = GetAbsoluteContainingBlock();
|
|
|
|
|
|
|
|
// Let the absolutely positioned container reflow any absolutely positioned
|
|
|
|
// child frames that need to be reflowed
|
|
|
|
|
|
|
|
// The containing block for the abs pos kids is formed by our padding edge.
|
|
|
|
nsMargin computedBorder =
|
|
|
|
aReflowState.mComputedBorderPadding - aReflowState.mComputedPadding;
|
|
|
|
nscoord containingBlockWidth =
|
|
|
|
aDesiredSize.width - computedBorder.LeftRight();
|
|
|
|
nscoord containingBlockHeight =
|
|
|
|
aDesiredSize.height - computedBorder.TopBottom();
|
|
|
|
|
|
|
|
nsContainerFrame* container = do_QueryFrame(this);
|
|
|
|
NS_ASSERTION(container, "Abs-pos children only supported on container frames for now");
|
|
|
|
|
|
|
|
absoluteContainer->Reflow(container, aPresContext, aReflowState, aStatus,
|
|
|
|
containingBlockWidth, containingBlockHeight,
|
|
|
|
true, true, true, // XXX could be optimized
|
|
|
|
&aDesiredSize.mOverflowAreas);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
/* virtual */ bool
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsFrame::CanContinueTextRun() const
|
2000-07-28 22:29:28 +00:00
|
|
|
{
|
|
|
|
// By default, a frame will *not* allow a text run to be continued
|
|
|
|
// through it.
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2000-07-28 22:29:28 +00:00
|
|
|
}
|
|
|
|
|
1998-10-09 23:46:02 +00:00
|
|
|
NS_IMETHODIMP
|
2004-07-31 23:15:21 +00:00
|
|
|
nsFrame::Reflow(nsPresContext* aPresContext,
|
1998-10-09 23:46:02 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsFrame");
|
1998-04-13 20:24:54 +00:00
|
|
|
aDesiredSize.width = 0;
|
|
|
|
aDesiredSize.height = 0;
|
1998-05-12 04:17:56 +00:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
2002-05-28 22:50:43 +00:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
1998-10-01 04:46:11 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-27 16:51:21 +00:00
|
|
|
NS_IMETHODIMP
|
2009-08-05 01:38:10 +00:00
|
|
|
nsFrame::CharacterDataChanged(CharacterDataChangeInfo* aInfo)
|
1998-10-27 16:51:21 +00:00
|
|
|
{
|
2004-02-20 21:38:31 +00:00
|
|
|
NS_NOTREACHED("should only be called for text frames");
|
|
|
|
return NS_OK;
|
1998-10-27 16:51:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsFrame::AttributeChanged(int32_t aNameSpaceID,
|
1998-10-27 16:51:21 +00:00
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aModType)
|
1998-09-18 19:53:27 +00:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
// Flow member functions
|
|
|
|
|
2006-12-20 03:52:34 +00:00
|
|
|
nsSplittableType
|
|
|
|
nsFrame::GetSplittableType() const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2006-12-20 03:52:34 +00:00
|
|
|
return NS_FRAME_NOT_SPLITTABLE;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2006-02-21 21:33:47 +00:00
|
|
|
nsIFrame* nsFrame::GetPrevContinuation() const
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2006-02-21 21:33:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsFrame::SetPrevContinuation(nsIFrame* aPrevContinuation)
|
|
|
|
{
|
|
|
|
// Ignore harmless requests to set it to NULL
|
|
|
|
if (aPrevContinuation) {
|
|
|
|
NS_ERROR("not splittable");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame* nsFrame::GetNextContinuation() const
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2006-02-21 21:33:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsFrame::SetNextContinuation(nsIFrame*)
|
|
|
|
{
|
|
|
|
NS_ERROR("not splittable");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame* nsFrame::GetPrevInFlowVirtual() const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-10-27 00:53:15 +00:00
|
|
|
NS_IMETHODIMP nsFrame::SetPrevInFlow(nsIFrame* aPrevInFlow)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-10-27 00:53:15 +00:00
|
|
|
// Ignore harmless requests to set it to NULL
|
|
|
|
if (aPrevInFlow) {
|
|
|
|
NS_ERROR("not splittable");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2006-02-21 21:33:47 +00:00
|
|
|
nsIFrame* nsFrame::GetNextInFlowVirtual() const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-10-09 23:46:02 +00:00
|
|
|
NS_IMETHODIMP nsFrame::SetNextInFlow(nsIFrame*)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
NS_ERROR("not splittable");
|
1998-05-08 17:02:35 +00:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2008-01-27 08:13:19 +00:00
|
|
|
nsIFrame* nsIFrame::GetTailContinuation()
|
|
|
|
{
|
|
|
|
nsIFrame* frame = this;
|
|
|
|
while (frame->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER) {
|
|
|
|
frame = frame->GetPrevContinuation();
|
|
|
|
NS_ASSERTION(frame, "first continuation can't be overflow container");
|
|
|
|
}
|
|
|
|
for (nsIFrame* next = frame->GetNextContinuation();
|
|
|
|
next && !(next->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER);
|
|
|
|
next = frame->GetNextContinuation()) {
|
|
|
|
frame = next;
|
|
|
|
}
|
|
|
|
NS_POSTCONDITION(frame, "illegal state in continuation chain.");
|
|
|
|
return frame;
|
|
|
|
}
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
NS_DECLARE_FRAME_PROPERTY(ViewProperty, nullptr)
|
2010-03-29 01:46:55 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
// Associated view object
|
2003-06-19 23:44:01 +00:00
|
|
|
nsIView*
|
Bug 190735. DeCOMtaminating nsIFrame and removing aPresContext parameters, in particular, the methods GetParent, GetContent, GetRect, GetOrigin, GetSize, SetRect, MoveTo, SizeTo, GetNextSibling, GetFrameState, SetFrameState, GetView, GetViewExternal, SetView, GetClosestView, GetParentWithView, AreAncestorViewsVisible, and GetWindow. For now we have compatibility wrappers, but soon we'll go through and change all the clients to use the new functions. r+sr=dbaron
2003-06-21 17:06:05 +00:00
|
|
|
nsIFrame::GetView() const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2003-06-19 23:44:01 +00:00
|
|
|
// Check the frame state bit and see if the frame has a view
|
2003-07-12 00:50:00 +00:00
|
|
|
if (!(GetStateBits() & NS_FRAME_HAS_VIEW))
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
1999-10-27 03:56:14 +00:00
|
|
|
|
2003-06-19 23:44:01 +00:00
|
|
|
// Check for a property on the frame
|
2010-03-29 01:46:55 +00:00
|
|
|
void* value = Properties().Get(ViewProperty());
|
2003-06-19 23:44:01 +00:00
|
|
|
NS_ASSERTION(value, "frame state bit was set but frame has no view");
|
2007-07-08 07:08:04 +00:00
|
|
|
return static_cast<nsIView*>(value);
|
2003-06-19 23:44:01 +00:00
|
|
|
}
|
1999-10-27 03:56:14 +00:00
|
|
|
|
2003-06-19 23:44:01 +00:00
|
|
|
/* virtual */ nsIView*
|
Bug 190735. DeCOMtaminating nsIFrame and removing aPresContext parameters, in particular, the methods GetParent, GetContent, GetRect, GetOrigin, GetSize, SetRect, MoveTo, SizeTo, GetNextSibling, GetFrameState, SetFrameState, GetView, GetViewExternal, SetView, GetClosestView, GetParentWithView, AreAncestorViewsVisible, and GetWindow. For now we have compatibility wrappers, but soon we'll go through and change all the clients to use the new functions. r+sr=dbaron
2003-06-21 17:06:05 +00:00
|
|
|
nsIFrame::GetViewExternal() const
|
2003-06-19 23:44:01 +00:00
|
|
|
{
|
Bug 190735. DeCOMtaminating nsIFrame and removing aPresContext parameters, in particular, the methods GetParent, GetContent, GetRect, GetOrigin, GetSize, SetRect, MoveTo, SizeTo, GetNextSibling, GetFrameState, SetFrameState, GetView, GetViewExternal, SetView, GetClosestView, GetParentWithView, AreAncestorViewsVisible, and GetWindow. For now we have compatibility wrappers, but soon we'll go through and change all the clients to use the new functions. r+sr=dbaron
2003-06-21 17:06:05 +00:00
|
|
|
return GetView();
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2003-06-19 23:44:01 +00:00
|
|
|
nsresult
|
Bug 190735. DeCOMtaminating nsIFrame and removing aPresContext parameters, in particular, the methods GetParent, GetContent, GetRect, GetOrigin, GetSize, SetRect, MoveTo, SizeTo, GetNextSibling, GetFrameState, SetFrameState, GetView, GetViewExternal, SetView, GetClosestView, GetParentWithView, AreAncestorViewsVisible, and GetWindow. For now we have compatibility wrappers, but soon we'll go through and change all the clients to use the new functions. r+sr=dbaron
2003-06-21 17:06:05 +00:00
|
|
|
nsIFrame::SetView(nsIView* aView)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-10-27 03:56:14 +00:00
|
|
|
if (aView) {
|
2011-11-21 17:53:20 +00:00
|
|
|
aView->SetFrame(this);
|
1999-10-27 03:56:14 +00:00
|
|
|
|
|
|
|
// Set a property on the frame
|
2010-03-29 01:46:55 +00:00
|
|
|
Properties().Set(ViewProperty(), aView);
|
2000-02-03 00:51:37 +00:00
|
|
|
|
|
|
|
// Set the frame state bit that says the frame has a view
|
2003-07-12 00:50:00 +00:00
|
|
|
AddStateBits(NS_FRAME_HAS_VIEW);
|
2001-08-01 04:37:17 +00:00
|
|
|
|
2003-07-12 00:50:00 +00:00
|
|
|
// Let all of the ancestors know they have a descendant with a view.
|
|
|
|
for (nsIFrame* f = GetParent();
|
|
|
|
f && !(f->GetStateBits() & NS_FRAME_HAS_CHILD_WITH_VIEW);
|
|
|
|
f = f->GetParent())
|
|
|
|
f->AddStateBits(NS_FRAME_HAS_CHILD_WITH_VIEW);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
1998-08-28 02:52:54 +00:00
|
|
|
|
1999-10-27 03:56:14 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2003-06-21 18:57:14 +00:00
|
|
|
nsIFrame* nsIFrame::GetAncestorWithViewExternal() const
|
|
|
|
{
|
|
|
|
return GetAncestorWithView();
|
|
|
|
}
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
// Find the first geometric parent that has a view
|
Bug 190735. DeCOMtaminating nsIFrame and removing aPresContext parameters, in particular, the methods GetParent, GetContent, GetRect, GetOrigin, GetSize, SetRect, MoveTo, SizeTo, GetNextSibling, GetFrameState, SetFrameState, GetView, GetViewExternal, SetView, GetClosestView, GetParentWithView, AreAncestorViewsVisible, and GetWindow. For now we have compatibility wrappers, but soon we'll go through and change all the clients to use the new functions. r+sr=dbaron
2003-06-21 17:06:05 +00:00
|
|
|
nsIFrame* nsIFrame::GetAncestorWithView() const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
for (nsIFrame* f = mParent; nullptr != f; f = f->GetParent()) {
|
Bug 190735. DeCOMtaminating nsIFrame and removing aPresContext parameters, in particular, the methods GetParent, GetContent, GetRect, GetOrigin, GetSize, SetRect, MoveTo, SizeTo, GetNextSibling, GetFrameState, SetFrameState, GetView, GetViewExternal, SetView, GetClosestView, GetParentWithView, AreAncestorViewsVisible, and GetWindow. For now we have compatibility wrappers, but soon we'll go through and change all the clients to use the new functions. r+sr=dbaron
2003-06-21 17:06:05 +00:00
|
|
|
if (f->HasView()) {
|
|
|
|
return f;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
}
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2004-11-03 16:16:57 +00:00
|
|
|
// virtual
|
|
|
|
nsPoint nsIFrame::GetOffsetToExternal(const nsIFrame* aOther) const
|
|
|
|
{
|
|
|
|
return GetOffsetTo(aOther);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsPoint nsIFrame::GetOffsetTo(const nsIFrame* aOther) const
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aOther,
|
|
|
|
"Must have frame for destination coordinate system!");
|
2010-07-19 02:23:47 +00:00
|
|
|
|
2010-07-19 02:23:48 +00:00
|
|
|
NS_ASSERTION(PresContext() == aOther->PresContext(),
|
|
|
|
"GetOffsetTo called on frames in different documents");
|
2010-07-19 02:23:47 +00:00
|
|
|
|
2004-11-03 16:16:57 +00:00
|
|
|
nsPoint offset(0, 0);
|
|
|
|
const nsIFrame* f;
|
2010-07-19 02:23:47 +00:00
|
|
|
for (f = this; f != aOther && f; f = f->GetParent()) {
|
2004-11-03 16:16:57 +00:00
|
|
|
offset += f->GetPosition();
|
|
|
|
}
|
2008-09-06 08:52:56 +00:00
|
|
|
|
2004-11-03 16:16:57 +00:00
|
|
|
if (f != aOther) {
|
2008-09-06 08:52:56 +00:00
|
|
|
// Looks like aOther wasn't an ancestor of |this|. So now we have
|
2010-07-19 02:23:47 +00:00
|
|
|
// the root-frame-relative position of |this| in |offset|. Convert back
|
2008-09-06 08:52:56 +00:00
|
|
|
// to the coordinates of aOther
|
|
|
|
while (aOther) {
|
|
|
|
offset -= aOther->GetPosition();
|
2010-07-19 02:23:47 +00:00
|
|
|
aOther = aOther->GetParent();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsPoint nsIFrame::GetOffsetToCrossDoc(const nsIFrame* aOther) const
|
|
|
|
{
|
|
|
|
return GetOffsetToCrossDoc(aOther, PresContext()->AppUnitsPerDevPixel());
|
|
|
|
}
|
|
|
|
|
|
|
|
nsPoint
|
2012-08-22 15:56:38 +00:00
|
|
|
nsIFrame::GetOffsetToCrossDoc(const nsIFrame* aOther, const int32_t aAPD) const
|
2010-07-19 02:23:47 +00:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(aOther,
|
|
|
|
"Must have frame for destination coordinate system!");
|
|
|
|
NS_ASSERTION(PresContext()->GetRootPresContext() ==
|
|
|
|
aOther->PresContext()->GetRootPresContext(),
|
|
|
|
"trying to get the offset between frames in different document "
|
|
|
|
"hierarchies?");
|
2011-05-31 22:53:21 +00:00
|
|
|
if (PresContext()->GetRootPresContext() !=
|
|
|
|
aOther->PresContext()->GetRootPresContext()) {
|
|
|
|
// crash right away, we are almost certainly going to crash anyway.
|
2011-10-05 23:55:02 +00:00
|
|
|
NS_RUNTIMEABORT("trying to get the offset between frames in different "
|
|
|
|
"document hierarchies?");
|
2011-05-31 22:53:21 +00:00
|
|
|
}
|
2010-07-19 02:23:47 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
const nsIFrame* root = nullptr;
|
2010-07-19 02:23:47 +00:00
|
|
|
// offset will hold the final offset
|
|
|
|
// docOffset holds the currently accumulated offset at the current APD, it
|
|
|
|
// will be converted and added to offset when the current APD changes.
|
|
|
|
nsPoint offset(0, 0), docOffset(0, 0);
|
|
|
|
const nsIFrame* f = this;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t currAPD = PresContext()->AppUnitsPerDevPixel();
|
2010-07-19 02:23:47 +00:00
|
|
|
while (f && f != aOther) {
|
|
|
|
docOffset += f->GetPosition();
|
|
|
|
nsIFrame* parent = f->GetParent();
|
|
|
|
if (parent) {
|
|
|
|
f = parent;
|
|
|
|
} else {
|
|
|
|
nsPoint newOffset(0, 0);
|
|
|
|
root = f;
|
|
|
|
f = nsLayoutUtils::GetCrossDocParentFrame(f, &newOffset);
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t newAPD = f ? f->PresContext()->AppUnitsPerDevPixel() : 0;
|
2010-07-19 02:23:47 +00:00
|
|
|
if (!f || newAPD != currAPD) {
|
|
|
|
// Convert docOffset to the right APD and add it to offset.
|
|
|
|
offset += docOffset.ConvertAppUnits(currAPD, aAPD);
|
|
|
|
docOffset.x = docOffset.y = 0;
|
|
|
|
}
|
|
|
|
currAPD = newAPD;
|
|
|
|
docOffset += newOffset;
|
2008-09-06 08:52:56 +00:00
|
|
|
}
|
2010-07-19 02:23:47 +00:00
|
|
|
}
|
|
|
|
if (f == aOther) {
|
|
|
|
offset += docOffset.ConvertAppUnits(currAPD, aAPD);
|
|
|
|
} else {
|
|
|
|
// Looks like aOther wasn't an ancestor of |this|. So now we have
|
|
|
|
// the root-document-relative position of |this| in |offset|. Subtract the
|
|
|
|
// root-document-relative position of |aOther| from |offset|.
|
|
|
|
// This call won't try to recurse again because root is an ancestor of
|
|
|
|
// aOther.
|
|
|
|
nsPoint negOffset = aOther->GetOffsetToCrossDoc(root, aAPD);
|
|
|
|
offset -= negOffset;
|
2004-11-03 16:16:57 +00:00
|
|
|
}
|
2008-09-06 08:52:56 +00:00
|
|
|
|
2004-11-03 16:16:57 +00:00
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
2004-11-23 17:26:19 +00:00
|
|
|
// virtual
|
|
|
|
nsIntRect nsIFrame::GetScreenRectExternal() const
|
|
|
|
{
|
|
|
|
return GetScreenRect();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIntRect nsIFrame::GetScreenRect() const
|
|
|
|
{
|
2009-11-15 16:16:44 +00:00
|
|
|
return GetScreenRectInAppUnits().ToNearestPixels(PresContext()->AppUnitsPerCSSPixel());
|
2008-06-16 01:26:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// virtual
|
|
|
|
nsRect nsIFrame::GetScreenRectInAppUnitsExternal() const
|
|
|
|
{
|
|
|
|
return GetScreenRectInAppUnits();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRect nsIFrame::GetScreenRectInAppUnits() const
|
|
|
|
{
|
2009-07-22 00:45:06 +00:00
|
|
|
nsPresContext* presContext = PresContext();
|
|
|
|
nsIFrame* rootFrame =
|
|
|
|
presContext->PresShell()->FrameManager()->GetRootFrame();
|
|
|
|
nsPoint rootScreenPos(0, 0);
|
|
|
|
nsPoint rootFrameOffsetInParent(0, 0);
|
|
|
|
nsIFrame* rootFrameParent =
|
|
|
|
nsLayoutUtils::GetCrossDocParentFrame(rootFrame, &rootFrameOffsetInParent);
|
|
|
|
if (rootFrameParent) {
|
|
|
|
nsRect parentScreenRectAppUnits = rootFrameParent->GetScreenRectInAppUnits();
|
|
|
|
nsPresContext* parentPresContext = rootFrameParent->PresContext();
|
|
|
|
double parentScale = double(presContext->AppUnitsPerDevPixel())/
|
|
|
|
parentPresContext->AppUnitsPerDevPixel();
|
|
|
|
nsPoint rootPt = parentScreenRectAppUnits.TopLeft() + rootFrameOffsetInParent;
|
|
|
|
rootScreenPos.x = NS_round(parentScale*rootPt.x);
|
|
|
|
rootScreenPos.y = NS_round(parentScale*rootPt.y);
|
|
|
|
} else {
|
|
|
|
nsCOMPtr<nsIWidget> rootWidget;
|
|
|
|
presContext->PresShell()->GetViewManager()->GetRootWidget(getter_AddRefs(rootWidget));
|
|
|
|
if (rootWidget) {
|
|
|
|
nsIntPoint rootDevPx = rootWidget->WidgetToScreenOffset();
|
|
|
|
rootScreenPos.x = presContext->DevPixelsToAppUnits(rootDevPx.x);
|
|
|
|
rootScreenPos.y = presContext->DevPixelsToAppUnits(rootDevPx.y);
|
2004-11-23 17:26:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-22 00:45:06 +00:00
|
|
|
return nsRect(rootScreenPos + GetOffsetTo(rootFrame), GetSize());
|
2004-11-23 17:26:19 +00:00
|
|
|
}
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
// Returns the offset from this frame to the closest geometric parent that
|
|
|
|
// has a view. Also returns the containing view or null in case of error
|
2004-12-26 19:48:54 +00:00
|
|
|
NS_IMETHODIMP nsFrame::GetOffsetFromView(nsPoint& aOffset,
|
|
|
|
nsIView** aView) const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
NS_PRECONDITION(nullptr != aView, "null OUT parameter pointer");
|
1998-04-17 01:41:24 +00:00
|
|
|
nsIFrame* frame = (nsIFrame*)this;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
*aView = nullptr;
|
1998-04-13 20:24:54 +00:00
|
|
|
aOffset.MoveTo(0, 0);
|
|
|
|
do {
|
2003-06-28 11:48:14 +00:00
|
|
|
aOffset += frame->GetPosition();
|
|
|
|
frame = frame->GetParent();
|
2003-06-19 23:44:01 +00:00
|
|
|
} while (frame && !frame->HasView());
|
|
|
|
if (frame)
|
2003-06-28 11:48:14 +00:00
|
|
|
*aView = frame->GetView();
|
1998-04-17 01:41:24 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2005-02-07 21:59:35 +00:00
|
|
|
nsIWidget*
|
2010-07-02 19:11:04 +00:00
|
|
|
nsIFrame::GetNearestWidget() const
|
2005-02-07 21:59:35 +00:00
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
return GetClosestView()->GetNearestWidget(nullptr);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2010-03-14 22:52:07 +00:00
|
|
|
nsIWidget*
|
2010-07-02 19:11:04 +00:00
|
|
|
nsIFrame::GetNearestWidget(nsPoint& aOffset) const
|
2010-03-14 22:52:07 +00:00
|
|
|
{
|
|
|
|
nsPoint offsetToView;
|
|
|
|
nsPoint offsetToWidget;
|
|
|
|
nsIWidget* widget =
|
|
|
|
GetClosestView(&offsetToView)->GetNearestWidget(&offsetToWidget);
|
|
|
|
aOffset = offsetToView + offsetToWidget;
|
|
|
|
return widget;
|
|
|
|
}
|
|
|
|
|
2003-10-31 20:19:18 +00:00
|
|
|
nsIAtom*
|
|
|
|
nsFrame::GetType() const
|
1999-02-09 05:44:13 +00:00
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
1999-02-09 05:44:13 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2005-08-16 22:52:48 +00:00
|
|
|
nsIFrame::IsLeaf() const
|
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2005-08-16 22:52:48 +00:00
|
|
|
}
|
|
|
|
|
2010-07-15 21:08:06 +00:00
|
|
|
class LayerActivity {
|
|
|
|
public:
|
2011-06-22 12:11:28 +00:00
|
|
|
LayerActivity(nsIFrame* aFrame) : mFrame(aFrame), mChangeHint(nsChangeHint(0)) {}
|
2010-07-15 21:08:06 +00:00
|
|
|
~LayerActivity();
|
|
|
|
nsExpirationState* GetExpirationState() { return &mState; }
|
|
|
|
|
|
|
|
nsIFrame* mFrame;
|
|
|
|
nsExpirationState mState;
|
2011-06-22 12:11:28 +00:00
|
|
|
// mChangeHint can be some combination of nsChangeHint_UpdateOpacityLayer and
|
|
|
|
// nsChangeHint_UpdateTransformLayer (or neither)
|
|
|
|
// The presence of those bits indicates whether opacity or transform
|
|
|
|
// changes have been detected.
|
|
|
|
nsChangeHint mChangeHint;
|
2010-07-15 21:08:06 +00:00
|
|
|
};
|
|
|
|
|
2012-01-03 18:38:10 +00:00
|
|
|
class LayerActivityTracker MOZ_FINAL : public nsExpirationTracker<LayerActivity,4> {
|
2010-07-15 21:08:06 +00:00
|
|
|
public:
|
|
|
|
// 75-100ms is a good timeout period. We use 4 generations of 25ms each.
|
|
|
|
enum { GENERATION_MS = 100 };
|
|
|
|
LayerActivityTracker()
|
|
|
|
: nsExpirationTracker<LayerActivity,4>(GENERATION_MS) {}
|
|
|
|
~LayerActivityTracker() {
|
|
|
|
AgeAllGenerations();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void NotifyExpired(LayerActivity* aObject);
|
|
|
|
};
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
static LayerActivityTracker* gLayerActivityTracker = nullptr;
|
2010-07-15 21:08:06 +00:00
|
|
|
|
|
|
|
LayerActivity::~LayerActivity()
|
|
|
|
{
|
|
|
|
if (mFrame) {
|
|
|
|
NS_ASSERTION(gLayerActivityTracker, "Should still have a tracker");
|
|
|
|
gLayerActivityTracker->RemoveObject(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void DestroyLayerActivity(void* aPropertyValue)
|
|
|
|
{
|
|
|
|
delete static_cast<LayerActivity*>(aPropertyValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_DECLARE_FRAME_PROPERTY(LayerActivityProperty, DestroyLayerActivity)
|
|
|
|
|
|
|
|
void
|
|
|
|
LayerActivityTracker::NotifyExpired(LayerActivity* aObject)
|
|
|
|
{
|
|
|
|
RemoveObject(aObject);
|
|
|
|
|
|
|
|
nsIFrame* f = aObject->mFrame;
|
2012-07-30 14:20:58 +00:00
|
|
|
aObject->mFrame = nullptr;
|
2012-09-25 23:59:56 +00:00
|
|
|
|
|
|
|
// if there are hints other than transform/opacity, invalidate, since we don't know what else to do.
|
|
|
|
if (aObject->mChangeHint & ~(nsChangeHint_UpdateOpacityLayer|nsChangeHint_UpdateTransformLayer)) {
|
|
|
|
f->InvalidateFrameSubtree();
|
|
|
|
} else {
|
|
|
|
if (aObject->mChangeHint & nsChangeHint_UpdateOpacityLayer) {
|
|
|
|
f->InvalidateFrameSubtree(nsDisplayItem::TYPE_OPACITY);
|
|
|
|
}
|
|
|
|
if (aObject->mChangeHint & nsChangeHint_UpdateTransformLayer) {
|
|
|
|
f->InvalidateFrameSubtree(nsDisplayItem::TYPE_TRANSFORM);
|
|
|
|
}
|
|
|
|
}
|
2010-07-15 21:08:06 +00:00
|
|
|
f->Properties().Delete(LayerActivityProperty());
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-06-22 12:11:28 +00:00
|
|
|
nsIFrame::MarkLayersActive(nsChangeHint aChangeHint)
|
2010-07-15 21:08:06 +00:00
|
|
|
{
|
|
|
|
FrameProperties properties = Properties();
|
|
|
|
LayerActivity* layerActivity =
|
|
|
|
static_cast<LayerActivity*>(properties.Get(LayerActivityProperty()));
|
|
|
|
if (layerActivity) {
|
|
|
|
gLayerActivityTracker->MarkUsed(layerActivity);
|
|
|
|
} else {
|
|
|
|
if (!gLayerActivityTracker) {
|
|
|
|
gLayerActivityTracker = new LayerActivityTracker();
|
|
|
|
}
|
|
|
|
layerActivity = new LayerActivity(this);
|
|
|
|
gLayerActivityTracker->AddObject(layerActivity);
|
|
|
|
properties.Set(LayerActivityProperty(), layerActivity);
|
|
|
|
}
|
2011-06-22 12:11:28 +00:00
|
|
|
NS_UpdateHint(layerActivity->mChangeHint, aChangeHint);
|
2010-07-15 21:08:06 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2010-07-15 21:08:06 +00:00
|
|
|
nsIFrame::AreLayersMarkedActive()
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
return Properties().Get(LayerActivityProperty()) != nullptr;
|
2010-07-15 21:08:06 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2011-06-22 12:11:28 +00:00
|
|
|
nsIFrame::AreLayersMarkedActive(nsChangeHint aChangeHint)
|
|
|
|
{
|
|
|
|
LayerActivity* layerActivity =
|
|
|
|
static_cast<LayerActivity*>(Properties().Get(LayerActivityProperty()));
|
|
|
|
return layerActivity && (layerActivity->mChangeHint & aChangeHint);
|
|
|
|
}
|
|
|
|
|
2010-07-15 21:08:06 +00:00
|
|
|
/* static */ void
|
|
|
|
nsFrame::ShutdownLayerActivityTimer()
|
|
|
|
{
|
|
|
|
delete gLayerActivityTracker;
|
2012-07-30 14:20:58 +00:00
|
|
|
gLayerActivityTracker = nullptr;
|
2010-07-15 21:08:06 +00:00
|
|
|
}
|
|
|
|
|
2011-07-22 22:28:51 +00:00
|
|
|
gfx3DMatrix
|
2012-09-13 00:32:53 +00:00
|
|
|
nsIFrame::GetTransformMatrix(const nsIFrame* aStopAtAncestor,
|
2011-12-28 03:24:18 +00:00
|
|
|
nsIFrame** aOutAncestor)
|
2008-09-13 09:42:11 +00:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(aOutAncestor, "Need a place to put the ancestor!");
|
|
|
|
|
|
|
|
/* If we're transformed, we want to hand back the combination
|
|
|
|
* transform/translate matrix that will apply our current transform, then
|
|
|
|
* shift us to our parent.
|
|
|
|
*/
|
|
|
|
if (IsTransformed()) {
|
|
|
|
/* Compute the delta to the parent, which we need because we are converting
|
|
|
|
* coordinates to our parent.
|
|
|
|
*/
|
2011-12-28 03:24:18 +00:00
|
|
|
NS_ASSERTION(nsLayoutUtils::GetCrossDocParentFrame(this),
|
2012-07-31 17:28:21 +00:00
|
|
|
"Cannot transform the viewport frame!");
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t scaleFactor = PresContext()->AppUnitsPerDevPixel();
|
2008-09-13 09:42:11 +00:00
|
|
|
|
2011-07-22 22:28:51 +00:00
|
|
|
gfx3DMatrix result =
|
2012-09-18 00:09:42 +00:00
|
|
|
nsDisplayTransform::GetResultingTransformMatrix(this, nsPoint(0, 0), scaleFactor, nullptr,
|
|
|
|
nullptr, nullptr, nullptr, nullptr, aOutAncestor);
|
2012-05-17 04:05:09 +00:00
|
|
|
// XXXjwatt: seems like this will double count offsets in the face of preserve-3d:
|
2011-08-27 00:01:46 +00:00
|
|
|
nsPoint delta = GetOffsetToCrossDoc(*aOutAncestor);
|
2008-09-13 09:42:11 +00:00
|
|
|
/* Combine the raw transform with a translation to our parent. */
|
2011-08-03 03:04:21 +00:00
|
|
|
result *= gfx3DMatrix::Translation
|
2011-07-22 22:28:51 +00:00
|
|
|
(NSAppUnitsToFloatPixels(delta.x, scaleFactor),
|
|
|
|
NSAppUnitsToFloatPixels(delta.y, scaleFactor),
|
|
|
|
0.0f);
|
2008-09-13 09:42:11 +00:00
|
|
|
return result;
|
|
|
|
}
|
2012-07-31 17:28:21 +00:00
|
|
|
|
2011-08-27 00:01:46 +00:00
|
|
|
*aOutAncestor = nsLayoutUtils::GetCrossDocParentFrame(this);
|
2012-07-31 17:28:21 +00:00
|
|
|
|
2008-09-13 09:42:11 +00:00
|
|
|
/* Otherwise, we're not transformed. In that case, we'll walk up the frame
|
|
|
|
* tree until we either hit the root frame or something that may be
|
|
|
|
* transformed. We'll then change coordinates into that frame, since we're
|
|
|
|
* guaranteed that nothing in-between can be transformed. First, however,
|
|
|
|
* we have to check to see if we have a parent. If not, we'll set the
|
|
|
|
* outparam to null (indicating that there's nothing left) and will hand back
|
|
|
|
* the identity matrix.
|
|
|
|
*/
|
|
|
|
if (!*aOutAncestor)
|
2011-07-22 22:28:51 +00:00
|
|
|
return gfx3DMatrix();
|
2008-09-13 09:42:11 +00:00
|
|
|
|
|
|
|
/* Keep iterating while the frame can't possibly be transformed. */
|
2011-12-28 03:24:18 +00:00
|
|
|
while (!(*aOutAncestor)->IsTransformed() && *aOutAncestor != aStopAtAncestor) {
|
2008-09-13 09:42:11 +00:00
|
|
|
/* If no parent, stop iterating. Otherwise, update the ancestor. */
|
|
|
|
nsIFrame* parent = nsLayoutUtils::GetCrossDocParentFrame(*aOutAncestor);
|
|
|
|
if (!parent)
|
|
|
|
break;
|
2008-09-11 00:24:16 +00:00
|
|
|
|
2008-09-13 09:42:11 +00:00
|
|
|
*aOutAncestor = parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_ASSERTION(*aOutAncestor, "Somehow ended up with a null ancestor...?");
|
|
|
|
|
|
|
|
/* Translate from this frame to our ancestor, if it exists. That's the
|
|
|
|
* entire transform, so we're done.
|
|
|
|
*/
|
2010-07-19 02:23:48 +00:00
|
|
|
nsPoint delta = GetOffsetToCrossDoc(*aOutAncestor);
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t scaleFactor = PresContext()->AppUnitsPerDevPixel();
|
2011-07-22 22:28:51 +00:00
|
|
|
return gfx3DMatrix().Translation
|
|
|
|
(NSAppUnitsToFloatPixels(delta.x, scaleFactor),
|
|
|
|
NSAppUnitsToFloatPixels(delta.y, scaleFactor),
|
|
|
|
0.0f);
|
2006-06-08 01:11:43 +00:00
|
|
|
}
|
1999-08-19 14:36:47 +00:00
|
|
|
|
2012-09-25 23:59:56 +00:00
|
|
|
static void InvalidateFrameInternal(nsIFrame *aFrame, bool aHasDisplayItem = true)
|
|
|
|
{
|
|
|
|
if (aHasDisplayItem) {
|
|
|
|
aFrame->AddStateBits(NS_FRAME_NEEDS_PAINT);
|
|
|
|
}
|
|
|
|
nsSVGEffects::InvalidateDirectRenderingObservers(aFrame);
|
|
|
|
nsIFrame *parent = nsLayoutUtils::GetCrossDocParentFrame(aFrame);
|
2012-09-30 06:20:24 +00:00
|
|
|
bool needsSchedulePaint = false;
|
2012-09-25 23:59:56 +00:00
|
|
|
while (parent && !parent->HasAnyStateBits(NS_FRAME_DESCENDANT_NEEDS_PAINT)) {
|
|
|
|
if (aHasDisplayItem) {
|
|
|
|
parent->AddStateBits(NS_FRAME_DESCENDANT_NEEDS_PAINT);
|
|
|
|
}
|
2012-10-17 08:00:00 +00:00
|
|
|
nsSVGEffects::InvalidateDirectRenderingObservers(parent);
|
|
|
|
|
2012-09-30 06:20:24 +00:00
|
|
|
// If we're inside a popup, then we need to make sure that we
|
|
|
|
// call schedule paint so that the NS_FRAME_UPDATE_LAYER_TREE
|
|
|
|
// flag gets added to the popup display root frame.
|
|
|
|
if (nsLayoutUtils::IsPopup(parent)) {
|
|
|
|
needsSchedulePaint = true;
|
2012-10-17 08:00:00 +00:00
|
|
|
break;
|
2012-09-30 06:20:24 +00:00
|
|
|
}
|
2012-09-25 23:59:56 +00:00
|
|
|
parent = nsLayoutUtils::GetCrossDocParentFrame(parent);
|
|
|
|
}
|
|
|
|
if (!aHasDisplayItem) {
|
|
|
|
return;
|
|
|
|
}
|
2012-09-30 06:20:24 +00:00
|
|
|
if (!parent || needsSchedulePaint) {
|
2012-09-25 23:59:56 +00:00
|
|
|
aFrame->SchedulePaint();
|
|
|
|
}
|
|
|
|
if (aFrame->HasAnyStateBits(NS_FRAME_HAS_INVALID_RECT)) {
|
|
|
|
aFrame->Properties().Delete(nsIFrame::InvalidationRect());
|
|
|
|
aFrame->RemoveStateBits(NS_FRAME_HAS_INVALID_RECT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-08 09:36:32 +00:00
|
|
|
void
|
2012-09-25 23:59:56 +00:00
|
|
|
nsIFrame::InvalidateFrameSubtree(uint32_t aDisplayItemKey)
|
2008-02-08 09:36:32 +00:00
|
|
|
{
|
2012-09-25 23:59:56 +00:00
|
|
|
bool hasDisplayItem =
|
|
|
|
!aDisplayItemKey || FrameLayerBuilder::HasRetainedDataFor(this, aDisplayItemKey);
|
2012-09-30 06:20:25 +00:00
|
|
|
InvalidateFrame(aDisplayItemKey);
|
2012-08-29 05:48:43 +00:00
|
|
|
|
2012-09-25 23:59:56 +00:00
|
|
|
if (HasAnyStateBits(NS_FRAME_ALL_DESCENDANTS_NEED_PAINT) || !hasDisplayItem) {
|
2012-08-29 05:48:43 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
AddStateBits(NS_FRAME_ALL_DESCENDANTS_NEED_PAINT);
|
2012-08-29 05:39:01 +00:00
|
|
|
|
|
|
|
nsAutoTArray<nsIFrame::ChildList,4> childListArray;
|
|
|
|
GetCrossDocChildLists(&childListArray);
|
|
|
|
|
|
|
|
nsIFrame::ChildListArrayIterator lists(childListArray);
|
|
|
|
for (; !lists.IsDone(); lists.Next()) {
|
|
|
|
nsFrameList::Enumerator childFrames(lists.CurrentList());
|
|
|
|
for (; !childFrames.AtEnd(); childFrames.Next()) {
|
2012-08-29 05:48:44 +00:00
|
|
|
childFrames.get()->InvalidateFrameSubtree();
|
2012-08-29 05:39:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsIFrame::ClearInvalidationStateBits()
|
|
|
|
{
|
|
|
|
if (HasAnyStateBits(NS_FRAME_DESCENDANT_NEEDS_PAINT)) {
|
|
|
|
nsAutoTArray<nsIFrame::ChildList,4> childListArray;
|
|
|
|
GetCrossDocChildLists(&childListArray);
|
|
|
|
|
|
|
|
nsIFrame::ChildListArrayIterator lists(childListArray);
|
|
|
|
for (; !lists.IsDone(); lists.Next()) {
|
|
|
|
nsFrameList::Enumerator childFrames(lists.CurrentList());
|
|
|
|
for (; !childFrames.AtEnd(); childFrames.Next()) {
|
|
|
|
childFrames.get()->ClearInvalidationStateBits();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-29 05:48:43 +00:00
|
|
|
RemoveStateBits(NS_FRAME_NEEDS_PAINT |
|
|
|
|
NS_FRAME_DESCENDANT_NEEDS_PAINT |
|
|
|
|
NS_FRAME_ALL_DESCENDANTS_NEED_PAINT);
|
2012-08-29 05:39:01 +00:00
|
|
|
}
|
|
|
|
|
2012-08-29 05:48:45 +00:00
|
|
|
void
|
2012-09-25 23:59:56 +00:00
|
|
|
nsIFrame::InvalidateFrame(uint32_t aDisplayItemKey)
|
2012-08-29 05:48:45 +00:00
|
|
|
{
|
2012-09-25 23:59:56 +00:00
|
|
|
bool hasDisplayItem =
|
|
|
|
!aDisplayItemKey || FrameLayerBuilder::HasRetainedDataFor(this, aDisplayItemKey);
|
|
|
|
InvalidateFrameInternal(this, hasDisplayItem);
|
2012-08-29 05:48:45 +00:00
|
|
|
}
|
|
|
|
|
2012-08-29 05:48:45 +00:00
|
|
|
void
|
2012-09-25 23:59:56 +00:00
|
|
|
nsIFrame::InvalidateFrameWithRect(const nsRect& aRect, uint32_t aDisplayItemKey)
|
2012-08-29 05:48:45 +00:00
|
|
|
{
|
2012-09-25 23:59:56 +00:00
|
|
|
bool hasDisplayItem =
|
|
|
|
!aDisplayItemKey || FrameLayerBuilder::HasRetainedDataFor(this, aDisplayItemKey);
|
2012-08-29 05:48:45 +00:00
|
|
|
bool alreadyInvalid = false;
|
|
|
|
if (!HasAnyStateBits(NS_FRAME_NEEDS_PAINT)) {
|
2012-09-25 23:59:56 +00:00
|
|
|
InvalidateFrameInternal(this, hasDisplayItem);
|
2012-08-29 05:48:45 +00:00
|
|
|
} else {
|
|
|
|
alreadyInvalid = true;
|
|
|
|
}
|
|
|
|
|
2012-09-25 23:59:56 +00:00
|
|
|
if (!hasDisplayItem) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-08-29 05:48:45 +00:00
|
|
|
nsRect *rect = static_cast<nsRect*>(Properties().Get(InvalidationRect()));
|
|
|
|
if (!rect) {
|
|
|
|
if (alreadyInvalid) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rect = new nsRect();
|
|
|
|
Properties().Set(InvalidationRect(), rect);
|
|
|
|
AddStateBits(NS_FRAME_HAS_INVALID_RECT);
|
|
|
|
}
|
|
|
|
|
|
|
|
*rect = rect->Union(aRect);
|
2012-08-29 05:39:01 +00:00
|
|
|
}
|
2012-10-03 05:55:52 +00:00
|
|
|
|
|
|
|
/*static*/ uint8_t nsIFrame::sLayerIsPrerenderedDataKey;
|
|
|
|
|
|
|
|
bool
|
|
|
|
nsIFrame::TryUpdateTransformOnly()
|
|
|
|
{
|
|
|
|
Layer* layer = FrameLayerBuilder::GetDedicatedLayer(
|
|
|
|
this, nsDisplayItem::TYPE_TRANSFORM);
|
|
|
|
if (!layer || !layer->HasUserData(LayerIsPrerenderedDataKey())) {
|
|
|
|
// If this layer isn't prerendered or we clip composites to our OS
|
|
|
|
// window, then we can't correctly optimize to an empty
|
|
|
|
// transaction in general.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
gfx3DMatrix transform3d;
|
|
|
|
if (!nsLayoutUtils::GetLayerTransformForFrame(this, &transform3d)) {
|
|
|
|
// We're not able to compute a layer transform that we know would
|
|
|
|
// be used at the next layers transaction, so we can't only update
|
|
|
|
// the transform and will need to schedule an invalidating paint.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
gfxMatrix transform, previousTransform;
|
|
|
|
// FIXME/bug 796690 and 796705: in general, changes to 3D
|
|
|
|
// transforms, or transform changes to properties other than
|
|
|
|
// translation, may lead us to choose a different rendering
|
|
|
|
// resolution for our layer. So if the transform is 3D or has a
|
|
|
|
// non-translation change, bail and schedule an invalidating paint.
|
|
|
|
// (We can often do better than this, for example for scale-down
|
|
|
|
// changes.)
|
|
|
|
static const gfx::Float kError = 0.0001;
|
|
|
|
if (!transform3d.Is2D(&transform) ||
|
|
|
|
!layer->GetTransform().Is2D(&previousTransform) ||
|
|
|
|
!gfx::FuzzyEqual(transform.xx, previousTransform.xx, kError) ||
|
|
|
|
!gfx::FuzzyEqual(transform.yy, previousTransform.yy, kError) ||
|
|
|
|
!gfx::FuzzyEqual(transform.xy, previousTransform.xy, kError) ||
|
|
|
|
!gfx::FuzzyEqual(transform.yx, previousTransform.yx, kError)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
layer->SetBaseTransformForNextTransaction(transform3d);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-08-29 05:39:01 +00:00
|
|
|
bool
|
2012-08-29 05:48:45 +00:00
|
|
|
nsIFrame::IsInvalid(nsRect& aRect)
|
2012-08-29 05:39:01 +00:00
|
|
|
{
|
2012-08-29 05:48:45 +00:00
|
|
|
if (!HasAnyStateBits(NS_FRAME_NEEDS_PAINT)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (HasAnyStateBits(NS_FRAME_HAS_INVALID_RECT)) {
|
|
|
|
nsRect *rect = static_cast<nsRect*>(Properties().Get(InvalidationRect()));
|
|
|
|
NS_ASSERTION(rect, "Must have an invalid rect if NS_FRAME_HAS_INVALID_RECT is set!");
|
|
|
|
aRect = *rect;
|
|
|
|
} else {
|
|
|
|
aRect.SetEmpty();
|
|
|
|
}
|
|
|
|
return true;
|
2008-02-08 09:36:32 +00:00
|
|
|
}
|
|
|
|
|
2012-08-29 05:39:01 +00:00
|
|
|
void
|
2012-08-29 05:48:15 +00:00
|
|
|
nsIFrame::SchedulePaint(uint32_t aFlags)
|
2012-08-29 05:39:01 +00:00
|
|
|
{
|
2012-08-29 05:48:15 +00:00
|
|
|
nsIFrame *displayRoot = nsLayoutUtils::GetDisplayRootFrame(this);
|
|
|
|
nsPresContext *pres = displayRoot->PresContext()->GetRootPresContext();
|
|
|
|
|
|
|
|
// No need to schedule a paint for an external document since they aren't
|
|
|
|
// painted directly.
|
|
|
|
if (!pres || (pres->Document() && pres->Document()->GetDisplayDocument())) {
|
|
|
|
return;
|
2012-08-29 05:39:01 +00:00
|
|
|
}
|
2012-08-29 05:48:15 +00:00
|
|
|
|
2012-08-29 05:39:01 +00:00
|
|
|
pres->PresShell()->ScheduleViewManagerFlush();
|
2012-08-29 05:48:15 +00:00
|
|
|
if (!(aFlags & PAINT_COMPOSITE_ONLY)) {
|
|
|
|
displayRoot->AddStateBits(NS_FRAME_UPDATE_LAYER_TREE);
|
|
|
|
}
|
2012-08-29 05:48:44 +00:00
|
|
|
nsIPresShell* shell = PresContext()->PresShell();
|
|
|
|
if (shell) {
|
|
|
|
shell->AddInvalidateHiddenPresShellObserver(pres->RefreshDriver());
|
|
|
|
}
|
2012-08-29 05:39:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Layer*
|
2012-08-29 05:47:18 +00:00
|
|
|
nsIFrame::InvalidateLayer(uint32_t aDisplayItemKey, const nsIntRect* aDamageRect)
|
2012-08-29 05:39:01 +00:00
|
|
|
{
|
|
|
|
NS_ASSERTION(aDisplayItemKey > 0, "Need a key");
|
|
|
|
|
|
|
|
Layer* layer = FrameLayerBuilder::GetDedicatedLayer(this, aDisplayItemKey);
|
2012-08-29 05:47:18 +00:00
|
|
|
if (aDamageRect && aDamageRect->IsEmpty()) {
|
|
|
|
return layer;
|
|
|
|
}
|
|
|
|
|
2012-08-29 05:39:01 +00:00
|
|
|
if (!layer) {
|
2012-09-25 23:59:56 +00:00
|
|
|
// Plugins can transition from not rendering anything to rendering,
|
|
|
|
// and still only call this. So always invalidate, with specifying
|
|
|
|
// the display item type just in case.
|
|
|
|
if (aDisplayItemKey == nsDisplayItem::TYPE_PLUGIN) {
|
|
|
|
InvalidateFrame();
|
|
|
|
} else {
|
|
|
|
InvalidateFrame(aDisplayItemKey);
|
|
|
|
}
|
2012-08-29 05:39:01 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2012-08-29 05:47:18 +00:00
|
|
|
if (aDamageRect) {
|
|
|
|
layer->AddInvalidRect(*aDamageRect);
|
|
|
|
} else {
|
|
|
|
layer->SetInvalidRectToVisibleRegion();
|
|
|
|
}
|
|
|
|
|
2012-08-29 05:48:15 +00:00
|
|
|
SchedulePaint(PAINT_COMPOSITE_ONLY);
|
2012-08-29 05:39:01 +00:00
|
|
|
return layer;
|
|
|
|
}
|
|
|
|
|
2012-09-27 15:34:46 +00:00
|
|
|
NS_DECLARE_FRAME_PROPERTY(DeferInvalidatesProperty, nsIFrame::DestroyRegion)
|
|
|
|
|
2010-07-15 21:07:50 +00:00
|
|
|
void
|
|
|
|
nsIFrame::BeginDeferringInvalidatesForDisplayRoot(const nsRegion& aExcludeRegion)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(nsLayoutUtils::GetDisplayRootFrame(this) == this,
|
|
|
|
"Can only call this on display roots");
|
|
|
|
Properties().Set(DeferInvalidatesProperty(), new nsRegion(aExcludeRegion));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsIFrame::EndDeferringInvalidatesForDisplayRoot()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(nsLayoutUtils::GetDisplayRootFrame(this) == this,
|
|
|
|
"Can only call this on display roots");
|
|
|
|
Properties().Delete(DeferInvalidatesProperty());
|
1998-06-02 05:28:11 +00:00
|
|
|
}
|
1998-05-13 22:38:09 +00:00
|
|
|
|
2008-10-21 07:42:28 +00:00
|
|
|
/**
|
|
|
|
* @param aAnyOutlineOrEffects set to true if this frame has any
|
|
|
|
* outline, SVG effects or box shadows that mean we need to invalidate
|
|
|
|
* the whole overflow area if the frame's size changes.
|
|
|
|
*/
|
2008-09-11 00:24:16 +00:00
|
|
|
static nsRect
|
2011-09-29 06:19:26 +00:00
|
|
|
ComputeOutlineAndEffectsRect(nsIFrame* aFrame, bool* aAnyOutlineOrEffects,
|
2008-09-11 00:24:16 +00:00
|
|
|
const nsRect& aOverflowRect,
|
2009-12-14 03:40:55 +00:00
|
|
|
const nsSize& aNewSize,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aStoreRectProperties) {
|
2008-09-11 00:24:16 +00:00
|
|
|
nsRect r = aOverflowRect;
|
2011-10-17 14:59:28 +00:00
|
|
|
*aAnyOutlineOrEffects = false;
|
2008-09-11 00:24:16 +00:00
|
|
|
|
2012-05-17 04:05:09 +00:00
|
|
|
if (aFrame->GetStateBits() & NS_FRAME_SVG_LAYOUT) {
|
|
|
|
// For SVG frames, we only need to account for filters.
|
|
|
|
// TODO: We could also take account of clipPath and mask to reduce the
|
|
|
|
// visual overflow, but that's not essential.
|
|
|
|
if (aFrame->GetStyleSVGReset()->mFilter) {
|
|
|
|
*aAnyOutlineOrEffects = true;
|
|
|
|
if (aStoreRectProperties) {
|
|
|
|
aFrame->Properties().
|
|
|
|
Set(nsIFrame::PreEffectsBBoxProperty(), new nsRect(r));
|
|
|
|
}
|
|
|
|
r = nsSVGUtils::GetPostFilterVisualOverflowRect(aFrame, aOverflowRect);
|
|
|
|
}
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2008-09-11 00:24:16 +00:00
|
|
|
// box-shadow
|
2010-08-23 09:30:07 +00:00
|
|
|
nsCSSShadowArray* boxShadows = aFrame->GetStyleBorder()->mBoxShadow;
|
2009-04-05 23:35:53 +00:00
|
|
|
if (boxShadows) {
|
2008-09-11 00:24:16 +00:00
|
|
|
nsRect shadows;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t A2D = aFrame->PresContext()->AppUnitsPerDevPixel();
|
|
|
|
for (uint32_t i = 0; i < boxShadows->Length(); ++i) {
|
2009-12-14 03:40:55 +00:00
|
|
|
nsRect tmpRect(nsPoint(0, 0), aNewSize);
|
2008-09-11 00:24:16 +00:00
|
|
|
nsCSSShadowItem* shadow = boxShadows->ShadowAt(i);
|
2009-02-10 08:45:13 +00:00
|
|
|
|
|
|
|
// inset shadows are never painted outside the frame
|
|
|
|
if (shadow->mInset)
|
|
|
|
continue;
|
2008-09-11 00:24:16 +00:00
|
|
|
|
2008-09-13 03:45:37 +00:00
|
|
|
tmpRect.MoveBy(nsPoint(shadow->mXOffset, shadow->mYOffset));
|
2010-09-11 16:27:12 +00:00
|
|
|
tmpRect.Inflate(shadow->mSpread, shadow->mSpread);
|
|
|
|
tmpRect.Inflate(
|
|
|
|
nsContextBoxBlur::GetBlurRadiusMargin(shadow->mRadius, A2D));
|
2008-09-11 00:24:16 +00:00
|
|
|
|
|
|
|
shadows.UnionRect(shadows, tmpRect);
|
|
|
|
}
|
|
|
|
r.UnionRect(r, shadows);
|
2011-10-17 14:59:28 +00:00
|
|
|
*aAnyOutlineOrEffects = true;
|
2008-09-11 00:24:16 +00:00
|
|
|
}
|
|
|
|
|
2004-08-26 00:07:56 +00:00
|
|
|
const nsStyleOutline* outline = aFrame->GetStyleOutline();
|
2012-08-22 15:56:38 +00:00
|
|
|
uint8_t outlineStyle = outline->GetOutlineStyle();
|
2004-03-10 03:09:05 +00:00
|
|
|
if (outlineStyle != NS_STYLE_BORDER_STYLE_NONE) {
|
|
|
|
nscoord width;
|
|
|
|
#ifdef DEBUG
|
2011-09-29 06:19:26 +00:00
|
|
|
bool result =
|
2004-03-10 03:09:05 +00:00
|
|
|
#endif
|
|
|
|
outline->GetOutlineWidth(width);
|
|
|
|
NS_ASSERTION(result, "GetOutlineWidth had no cached outline width");
|
|
|
|
if (width > 0) {
|
2008-09-11 00:24:16 +00:00
|
|
|
if (aStoreRectProperties) {
|
2010-03-29 01:46:55 +00:00
|
|
|
aFrame->Properties().
|
|
|
|
Set(nsIFrame::OutlineInnerRectProperty(), new nsRect(r));
|
2008-09-11 00:24:16 +00:00
|
|
|
}
|
|
|
|
|
2008-09-13 03:45:37 +00:00
|
|
|
nscoord offset = outline->mOutlineOffset;
|
2009-09-16 15:01:36 +00:00
|
|
|
nscoord inflateBy = NS_MAX(width + offset, 0);
|
2010-10-07 04:25:47 +00:00
|
|
|
// FIXME (bug 599652): We probably want outline to be drawn around
|
|
|
|
// something smaller than the visual overflow rect (perhaps the
|
|
|
|
// scrollable overflow rect is correct). When we change that, we
|
|
|
|
// need to keep this code (and the storing of properties just
|
|
|
|
// above) in sync with GetOutlineInnerRect in nsCSSRendering.cpp.
|
2004-10-26 12:57:15 +00:00
|
|
|
r.Inflate(inflateBy, inflateBy);
|
2011-10-17 14:59:28 +00:00
|
|
|
*aAnyOutlineOrEffects = true;
|
2008-09-11 00:24:16 +00:00
|
|
|
}
|
|
|
|
}
|
2011-12-22 23:34:45 +00:00
|
|
|
|
|
|
|
// border-image-outset.
|
|
|
|
// We need to include border-image-outset because it can cause the
|
|
|
|
// border image to be drawn beyond the border box.
|
|
|
|
|
|
|
|
// (1) It's important we not check whether there's a border-image
|
|
|
|
// since the style hint for a change in border image doesn't cause
|
|
|
|
// reflow, and that's probably more important than optimizing the
|
|
|
|
// overflow areas for the silly case of border-image-outset without
|
|
|
|
// border-image
|
|
|
|
// (2) It's important that we not check whether the border-image
|
|
|
|
// is actually loaded, since that would require us to reflow when
|
|
|
|
// the image loads.
|
|
|
|
const nsStyleBorder* styleBorder = aFrame->GetStyleBorder();
|
|
|
|
nsMargin outsetMargin = styleBorder->GetImageOutset();
|
|
|
|
|
|
|
|
if (outsetMargin != nsMargin(0, 0, 0, 0)) {
|
|
|
|
nsRect outsetRect(nsPoint(0, 0), aNewSize);
|
|
|
|
outsetRect.Inflate(outsetMargin);
|
|
|
|
r.UnionRect(r, outsetRect);
|
|
|
|
|
|
|
|
*aAnyOutlineOrEffects = true;
|
|
|
|
}
|
|
|
|
|
2008-09-11 00:24:16 +00:00
|
|
|
// Note that we don't remove the outlineInnerRect if a frame loses outline
|
|
|
|
// style. That would require an extra property lookup for every frame,
|
|
|
|
// or a new frame state bit to track whether a property had been stored,
|
|
|
|
// or something like that. It's not worth doing that here. At most it's
|
|
|
|
// only one heap-allocated rect per frame and it will be cleaned up when
|
|
|
|
// the frame dies.
|
|
|
|
|
|
|
|
if (nsSVGIntegrationUtils::UsingEffectsForFrame(aFrame)) {
|
2011-10-17 14:59:28 +00:00
|
|
|
*aAnyOutlineOrEffects = true;
|
2008-09-11 00:24:16 +00:00
|
|
|
if (aStoreRectProperties) {
|
2010-03-29 01:46:55 +00:00
|
|
|
aFrame->Properties().
|
|
|
|
Set(nsIFrame::PreEffectsBBoxProperty(), new nsRect(r));
|
2004-03-10 03:09:05 +00:00
|
|
|
}
|
2012-06-21 00:29:50 +00:00
|
|
|
r = nsSVGIntegrationUtils::ComputePostEffectsVisualOverflowRect(aFrame, r);
|
2004-03-10 03:09:05 +00:00
|
|
|
}
|
2008-09-11 00:24:16 +00:00
|
|
|
|
2004-03-10 03:09:05 +00:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2008-04-18 07:40:35 +00:00
|
|
|
nsPoint
|
|
|
|
nsIFrame::GetRelativeOffset(const nsStyleDisplay* aDisplay) const
|
|
|
|
{
|
2012-08-02 11:38:50 +00:00
|
|
|
if (!aDisplay ||
|
|
|
|
aDisplay->IsRelativelyPositioned(this)) {
|
2008-04-18 07:40:35 +00:00
|
|
|
nsPoint *offsets = static_cast<nsPoint*>
|
2010-03-29 01:46:55 +00:00
|
|
|
(Properties().Get(ComputedOffsetProperty()));
|
2008-04-18 07:40:35 +00:00
|
|
|
if (offsets) {
|
|
|
|
return *offsets;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nsPoint(0,0);
|
|
|
|
}
|
|
|
|
|
2004-08-26 00:07:56 +00:00
|
|
|
nsRect
|
2010-10-07 04:25:45 +00:00
|
|
|
nsIFrame::GetOverflowRect(nsOverflowType aType) const
|
2004-08-26 00:07:56 +00:00
|
|
|
{
|
2010-10-07 04:25:45 +00:00
|
|
|
NS_ABORT_IF_FALSE(aType == eVisualOverflow || aType == eScrollableOverflow,
|
|
|
|
"unexpected type");
|
|
|
|
|
2004-08-26 00:07:56 +00:00
|
|
|
// Note that in some cases the overflow area might not have been
|
|
|
|
// updated (yet) to reflect any outline set on the frame or the area
|
|
|
|
// of child frames. That's OK because any reflow that updates these
|
|
|
|
// areas will invalidate the appropriate area, so any (mis)uses of
|
|
|
|
// this method will be fixed up.
|
2008-02-20 07:08:55 +00:00
|
|
|
|
2009-04-06 00:31:50 +00:00
|
|
|
if (mOverflow.mType == NS_FRAME_OVERFLOW_LARGE) {
|
|
|
|
// there is an overflow rect, and it's not stored as deltas but as
|
|
|
|
// a separately-allocated rect
|
2010-10-07 04:25:45 +00:00
|
|
|
return static_cast<nsOverflowAreas*>(const_cast<nsIFrame*>(this)->
|
|
|
|
GetOverflowAreasProperty())->Overflow(aType);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aType == eVisualOverflow &&
|
|
|
|
mOverflow.mType != NS_FRAME_OVERFLOW_NONE) {
|
|
|
|
return GetVisualOverflowFromDeltas();
|
2009-04-06 00:31:50 +00:00
|
|
|
}
|
|
|
|
|
2010-10-07 04:25:45 +00:00
|
|
|
return nsRect(nsPoint(0, 0), GetSize());
|
|
|
|
}
|
|
|
|
|
|
|
|
nsOverflowAreas
|
|
|
|
nsIFrame::GetOverflowAreas() const
|
|
|
|
{
|
|
|
|
if (mOverflow.mType == NS_FRAME_OVERFLOW_LARGE) {
|
|
|
|
// there is an overflow rect, and it's not stored as deltas but as
|
|
|
|
// a separately-allocated rect
|
|
|
|
return *const_cast<nsIFrame*>(this)->GetOverflowAreasProperty();
|
|
|
|
}
|
|
|
|
|
|
|
|
return nsOverflowAreas(GetVisualOverflowFromDeltas(),
|
|
|
|
nsRect(nsPoint(0, 0), GetSize()));
|
2004-08-26 00:07:56 +00:00
|
|
|
}
|
2008-09-16 01:51:52 +00:00
|
|
|
|
|
|
|
nsRect
|
2010-10-07 04:25:45 +00:00
|
|
|
nsIFrame::GetScrollableOverflowRectRelativeToParent() const
|
2008-09-16 01:51:52 +00:00
|
|
|
{
|
2010-10-07 04:25:45 +00:00
|
|
|
return GetScrollableOverflowRect() + mRect.TopLeft();
|
2008-09-16 01:51:52 +00:00
|
|
|
}
|
2010-10-07 04:25:45 +00:00
|
|
|
|
2008-09-16 01:51:52 +00:00
|
|
|
nsRect
|
2010-10-07 04:25:45 +00:00
|
|
|
nsIFrame::GetVisualOverflowRectRelativeToSelf() const
|
2008-09-16 01:51:52 +00:00
|
|
|
{
|
2010-08-13 13:31:31 +00:00
|
|
|
if (IsTransformed()) {
|
2011-06-15 21:03:49 +00:00
|
|
|
nsOverflowAreas* preTransformOverflows = static_cast<nsOverflowAreas*>
|
|
|
|
(Properties().Get(PreTransformOverflowAreasProperty()));
|
|
|
|
if (preTransformOverflows)
|
|
|
|
return preTransformOverflows->VisualOverflow();
|
2010-03-29 01:46:58 +00:00
|
|
|
}
|
2010-10-07 04:25:45 +00:00
|
|
|
return GetVisualOverflowRect();
|
2008-09-16 01:51:52 +00:00
|
|
|
}
|
2008-10-21 07:42:28 +00:00
|
|
|
|
2012-06-26 10:49:23 +00:00
|
|
|
nsRect
|
|
|
|
nsIFrame::GetPreEffectsVisualOverflowRect() const
|
|
|
|
{
|
|
|
|
nsRect* r = static_cast<nsRect*>
|
|
|
|
(Properties().Get(nsIFrame::PreEffectsBBoxProperty()));
|
|
|
|
return r ? *r : GetVisualOverflowRectRelativeToSelf();
|
|
|
|
}
|
|
|
|
|
2011-06-15 21:03:49 +00:00
|
|
|
/* virtual */ bool
|
|
|
|
nsFrame::UpdateOverflow()
|
|
|
|
{
|
2012-08-14 09:04:24 +00:00
|
|
|
MOZ_ASSERT(!(mState & NS_FRAME_SVG_LAYOUT) ||
|
|
|
|
!(mState & NS_STATE_SVG_NONDISPLAY_CHILD),
|
|
|
|
"Non-display SVG do not maintain visual overflow rects");
|
|
|
|
|
2011-06-15 21:03:49 +00:00
|
|
|
nsRect rect(nsPoint(0, 0), GetSize());
|
|
|
|
nsOverflowAreas overflowAreas(rect, rect);
|
|
|
|
|
|
|
|
bool isBox = IsBoxFrame() || IsBoxWrapped();
|
|
|
|
if (!isBox || (!IsCollapsed() && !DoesClipChildren())) {
|
|
|
|
nsLayoutUtils::UnionChildOverflow(this, overflowAreas);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FinishAndStoreOverflow(overflowAreas, GetSize())) {
|
|
|
|
nsIView* view = GetView();
|
|
|
|
if (view) {
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t flags = 0;
|
2011-06-15 21:03:49 +00:00
|
|
|
GetLayoutFlags(flags);
|
|
|
|
|
|
|
|
if ((flags & NS_FRAME_NO_SIZE_VIEW) == 0) {
|
|
|
|
// Make sure the frame's view is properly sized.
|
|
|
|
nsIViewManager* vm = view->GetViewManager();
|
|
|
|
vm->ResizeView(view, overflowAreas.VisualOverflow(), true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2001-09-14 20:44:41 +00:00
|
|
|
// Define the MAX_FRAME_DEPTH to be the ContentSink's MAX_REFLOW_DEPTH plus
|
|
|
|
// 4 for the frames above the document's frames:
|
|
|
|
// the Viewport, GFXScroll, ScrollPort, and Canvas
|
|
|
|
#define MAX_FRAME_DEPTH (MAX_REFLOW_DEPTH+4)
|
1999-08-27 21:48:06 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
1999-08-27 21:48:06 +00:00
|
|
|
nsFrame::IsFrameTreeTooDeep(const nsHTMLReflowState& aReflowState,
|
2011-01-12 01:09:22 +00:00
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
nsReflowStatus& aStatus)
|
1999-08-27 21:48:06 +00:00
|
|
|
{
|
2001-09-14 20:44:41 +00:00
|
|
|
if (aReflowState.mReflowDepth > MAX_FRAME_DEPTH) {
|
2011-01-12 01:09:22 +00:00
|
|
|
NS_WARNING("frame tree too deep; setting zero size and returning");
|
2007-07-21 00:34:36 +00:00
|
|
|
mState |= NS_FRAME_TOO_DEEP_IN_FRAME_TREE;
|
2010-10-07 04:25:45 +00:00
|
|
|
ClearOverflowRects();
|
1999-08-27 21:48:06 +00:00
|
|
|
aMetrics.width = 0;
|
|
|
|
aMetrics.height = 0;
|
|
|
|
aMetrics.ascent = 0;
|
2001-10-25 01:08:40 +00:00
|
|
|
aMetrics.mCarriedOutBottomMargin.Zero();
|
2010-10-07 04:25:46 +00:00
|
|
|
aMetrics.mOverflowAreas.Clear();
|
2011-01-12 01:09:22 +00:00
|
|
|
|
|
|
|
if (GetNextInFlow()) {
|
|
|
|
// Reflow depth might vary between reflows, so we might have
|
|
|
|
// successfully reflowed and split this frame before. If so, we
|
|
|
|
// shouldn't delete its continuations.
|
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
|
|
|
} else {
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
}
|
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
1999-08-27 21:48:06 +00:00
|
|
|
}
|
2007-07-21 00:34:36 +00:00
|
|
|
mState &= ~NS_FRAME_TOO_DEEP_IN_FRAME_TREE;
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
1999-08-27 21:48:06 +00:00
|
|
|
}
|
|
|
|
|
2011-05-12 04:04:30 +00:00
|
|
|
bool
|
|
|
|
nsIFrame::IsBlockWrapper() const
|
1998-05-13 22:38:09 +00:00
|
|
|
{
|
2011-05-12 04:04:30 +00:00
|
|
|
nsIAtom *pseudoType = GetStyleContext()->GetPseudo();
|
|
|
|
return (pseudoType == nsCSSAnonBoxes::mozAnonymousBlock ||
|
|
|
|
pseudoType == nsCSSAnonBoxes::mozAnonymousPositionedBlock ||
|
|
|
|
pseudoType == nsCSSAnonBoxes::cellContent);
|
|
|
|
}
|
2007-01-27 19:35:29 +00:00
|
|
|
|
2011-05-12 04:04:30 +00:00
|
|
|
static nsIFrame*
|
|
|
|
GetNearestBlockContainer(nsIFrame* frame)
|
|
|
|
{
|
|
|
|
// The block wrappers we use to wrap blocks inside inlines aren't
|
|
|
|
// described in the CSS spec. We need to make them not be containing
|
|
|
|
// blocks.
|
|
|
|
// Since the parent of such a block is either a normal block or
|
|
|
|
// another such pseudo, this shouldn't cause anything bad to happen.
|
|
|
|
// Also the anonymous blocks inside table cells are not containing blocks.
|
|
|
|
while (frame->IsFrameOfType(nsIFrame::eLineParticipant) ||
|
2012-02-24 04:35:19 +00:00
|
|
|
frame->IsBlockWrapper() ||
|
|
|
|
// Table rows are not containing blocks either
|
|
|
|
frame->GetType() == nsGkAtoms::tableRowFrame) {
|
2011-05-12 04:04:30 +00:00
|
|
|
frame = frame->GetParent();
|
|
|
|
NS_ASSERTION(frame, "How come we got to the root frame without seeing a containing block?");
|
|
|
|
}
|
|
|
|
return frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame*
|
|
|
|
nsIFrame::GetContainingBlock() const
|
|
|
|
{
|
|
|
|
// MathML frames might have absolute positioning style, but they would
|
|
|
|
// still be in-flow. So we have to check to make sure that the frame
|
|
|
|
// is really out-of-flow too.
|
2012-08-02 11:38:50 +00:00
|
|
|
if (IsAbsolutelyPositioned() &&
|
2011-05-12 04:04:30 +00:00
|
|
|
(GetStateBits() & NS_FRAME_OUT_OF_FLOW)) {
|
|
|
|
return GetParent(); // the parent is always the containing block
|
|
|
|
}
|
|
|
|
return GetNearestBlockContainer(GetParent());
|
1998-05-13 22:38:09 +00:00
|
|
|
}
|
|
|
|
|
2012-06-25 19:59:42 +00:00
|
|
|
#ifdef DEBUG
|
2003-11-19 01:20:56 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t nsFrame::ContentIndexInContainer(const nsIFrame* aFrame)
|
1998-10-08 20:35:16 +00:00
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t result = -1;
|
1998-10-08 20:35:16 +00:00
|
|
|
|
2003-06-28 11:48:14 +00:00
|
|
|
nsIContent* content = aFrame->GetContent();
|
2003-06-13 20:10:01 +00:00
|
|
|
if (content) {
|
2003-07-28 21:25:13 +00:00
|
|
|
nsIContent* parentContent = content->GetParent();
|
2003-06-13 20:10:01 +00:00
|
|
|
if (parentContent) {
|
2003-09-27 04:18:26 +00:00
|
|
|
result = parentContent->IndexOf(content);
|
1998-10-08 20:35:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2001-08-03 07:34:28 +00:00
|
|
|
/**
|
|
|
|
* List a frame tree to stdout. Meant to be called from gdb.
|
|
|
|
*/
|
|
|
|
void
|
2007-02-18 17:34:09 +00:00
|
|
|
DebugListFrameTree(nsIFrame* aFrame)
|
2001-08-03 07:34:28 +00:00
|
|
|
{
|
2007-02-18 17:34:09 +00:00
|
|
|
((nsFrame*)aFrame)->List(stdout, 0);
|
2001-08-03 07:34:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
// Debugging
|
1998-11-19 17:22:29 +00:00
|
|
|
NS_IMETHODIMP
|
2012-09-19 14:36:35 +00:00
|
|
|
nsFrame::List(FILE* out, int32_t aIndent, uint32_t aFlags) const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-01-16 00:00:50 +00:00
|
|
|
IndentBy(out, aIndent);
|
|
|
|
ListTag(out);
|
2000-07-27 05:16:08 +00:00
|
|
|
#ifdef DEBUG_waterson
|
2007-07-08 07:08:04 +00:00
|
|
|
fprintf(out, " [parent=%p]", static_cast<void*>(mParent));
|
2000-07-27 05:16:08 +00:00
|
|
|
#endif
|
2003-06-19 23:44:01 +00:00
|
|
|
if (HasView()) {
|
2007-07-08 07:08:04 +00:00
|
|
|
fprintf(out, " [view=%p]", static_cast<void*>(GetView()));
|
1999-01-16 00:00:50 +00:00
|
|
|
}
|
1999-03-05 04:22:54 +00:00
|
|
|
fprintf(out, " {%d,%d,%d,%d}", mRect.x, mRect.y, mRect.width, mRect.height);
|
1999-01-16 00:00:50 +00:00
|
|
|
if (0 != mState) {
|
2011-12-20 03:46:39 +00:00
|
|
|
fprintf(out, " [state=%016llx]", (unsigned long long)mState);
|
1998-05-18 16:53:09 +00:00
|
|
|
}
|
2005-03-23 03:35:08 +00:00
|
|
|
nsIFrame* prevInFlow = GetPrevInFlow();
|
|
|
|
nsIFrame* nextInFlow = GetNextInFlow();
|
2012-07-30 14:20:58 +00:00
|
|
|
if (nullptr != prevInFlow) {
|
2007-07-08 07:08:04 +00:00
|
|
|
fprintf(out, " prev-in-flow=%p", static_cast<void*>(prevInFlow));
|
2005-03-23 03:35:08 +00:00
|
|
|
}
|
2012-07-30 14:20:58 +00:00
|
|
|
if (nullptr != nextInFlow) {
|
2007-07-08 07:08:04 +00:00
|
|
|
fprintf(out, " next-in-flow=%p", static_cast<void*>(nextInFlow));
|
2005-03-23 03:35:08 +00:00
|
|
|
}
|
2007-07-08 07:08:04 +00:00
|
|
|
fprintf(out, " [content=%p]", static_cast<void*>(mContent));
|
|
|
|
nsFrame* f = const_cast<nsFrame*>(this);
|
2010-10-07 04:25:47 +00:00
|
|
|
if (f->HasOverflowAreas()) {
|
|
|
|
nsRect overflowArea = f->GetVisualOverflowRect();
|
|
|
|
fprintf(out, " [vis-overflow=%d,%d,%d,%d]", overflowArea.x, overflowArea.y,
|
|
|
|
overflowArea.width, overflowArea.height);
|
|
|
|
overflowArea = f->GetScrollableOverflowRect();
|
|
|
|
fprintf(out, " [scr-overflow=%d,%d,%d,%d]", overflowArea.x, overflowArea.y,
|
2008-02-20 07:08:55 +00:00
|
|
|
overflowArea.width, overflowArea.height);
|
2004-08-26 00:07:56 +00:00
|
|
|
}
|
2010-06-25 21:51:17 +00:00
|
|
|
fprintf(out, " [sc=%p]", static_cast<void*>(mStyleContext));
|
1999-05-03 20:51:30 +00:00
|
|
|
fputs("\n", out);
|
1998-04-17 01:41:24 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-11-19 17:22:29 +00:00
|
|
|
NS_IMETHODIMP
|
2001-11-14 01:33:42 +00:00
|
|
|
nsFrame::GetFrameName(nsAString& aResult) const
|
1998-11-19 17:22:29 +00:00
|
|
|
{
|
2001-11-14 01:33:42 +00:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("Frame"), aResult);
|
1998-11-19 17:22:29 +00:00
|
|
|
}
|
|
|
|
|
2004-04-04 01:48:16 +00:00
|
|
|
NS_IMETHODIMP_(nsFrameState)
|
|
|
|
nsFrame::GetDebugStateBits() const
|
|
|
|
{
|
|
|
|
// We'll ignore these flags for the purposes of comparing frame state:
|
|
|
|
//
|
|
|
|
// NS_FRAME_EXTERNAL_REFERENCE
|
|
|
|
// because this is set by the event state manager or the
|
|
|
|
// caret code when a frame is focused. Depending on whether
|
|
|
|
// or not the regression tests are run as the focused window
|
|
|
|
// will make this value vary randomly.
|
|
|
|
#define IRRELEVANT_FRAME_STATE_FLAGS NS_FRAME_EXTERNAL_REFERENCE
|
|
|
|
|
|
|
|
#define FRAME_STATE_MASK (~(IRRELEVANT_FRAME_STATE_FLAGS))
|
|
|
|
|
|
|
|
return GetStateBits() & FRAME_STATE_MASK;
|
|
|
|
}
|
|
|
|
|
1998-11-19 17:22:29 +00:00
|
|
|
nsresult
|
2001-11-14 01:33:42 +00:00
|
|
|
nsFrame::MakeFrameName(const nsAString& aType, nsAString& aResult) const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2001-11-14 01:33:42 +00:00
|
|
|
aResult = aType;
|
2006-05-05 06:52:21 +00:00
|
|
|
if (mContent && !mContent->IsNodeOfType(nsINode::eTEXT)) {
|
2005-06-16 13:10:58 +00:00
|
|
|
nsAutoString buf;
|
|
|
|
mContent->Tag()->ToString(buf);
|
2012-08-14 05:39:11 +00:00
|
|
|
if (GetType() == nsGkAtoms::subDocumentFrame) {
|
|
|
|
nsAutoString src;
|
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::src, src);
|
|
|
|
buf.Append(NS_LITERAL_STRING(" src=") + src);
|
|
|
|
}
|
2005-06-16 13:10:58 +00:00
|
|
|
aResult.Append(NS_LITERAL_STRING("(") + buf + NS_LITERAL_STRING(")"));
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
1998-11-19 17:22:29 +00:00
|
|
|
char buf[40];
|
1998-11-19 18:51:53 +00:00
|
|
|
PR_snprintf(buf, sizeof(buf), "(%d)", ContentIndexInContainer(this));
|
2003-11-01 10:57:41 +00:00
|
|
|
AppendASCIItoUTF16(buf, aResult);
|
1998-11-19 17:22:29 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-11-19 17:55:22 +00:00
|
|
|
void
|
|
|
|
nsFrame::XMLQuote(nsString& aString)
|
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t i, len = aString.Length();
|
1998-11-19 17:55:22 +00:00
|
|
|
for (i = 0; i < len; i++) {
|
1999-04-20 07:20:21 +00:00
|
|
|
PRUnichar ch = aString.CharAt(i);
|
1998-11-19 17:55:22 +00:00
|
|
|
if (ch == '<') {
|
2001-12-16 11:58:03 +00:00
|
|
|
nsAutoString tmp(NS_LITERAL_STRING("<"));
|
1998-11-19 17:55:22 +00:00
|
|
|
aString.Cut(i, 1);
|
|
|
|
aString.Insert(tmp, i);
|
|
|
|
len += 3;
|
|
|
|
i += 3;
|
|
|
|
}
|
|
|
|
else if (ch == '>') {
|
2001-12-16 11:58:03 +00:00
|
|
|
nsAutoString tmp(NS_LITERAL_STRING(">"));
|
1998-11-19 17:55:22 +00:00
|
|
|
aString.Cut(i, 1);
|
|
|
|
aString.Insert(tmp, i);
|
|
|
|
len += 3;
|
|
|
|
i += 3;
|
|
|
|
}
|
1999-02-04 16:28:36 +00:00
|
|
|
else if (ch == '\"') {
|
2001-12-16 11:58:03 +00:00
|
|
|
nsAutoString tmp(NS_LITERAL_STRING("""));
|
1998-11-19 17:55:22 +00:00
|
|
|
aString.Cut(i, 1);
|
|
|
|
aString.Insert(tmp, i);
|
|
|
|
len += 5;
|
|
|
|
i += 5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-05-04 16:27:40 +00:00
|
|
|
#endif
|
1998-11-19 17:55:22 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2006-01-26 02:29:17 +00:00
|
|
|
nsIFrame::IsVisibleForPainting(nsDisplayListBuilder* aBuilder) {
|
|
|
|
if (!GetStyleVisibility()->IsVisible())
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2006-01-26 02:29:17 +00:00
|
|
|
nsISelection* sel = aBuilder->GetBoundingSelection();
|
|
|
|
return !sel || IsVisibleInSelection(sel);
|
2001-01-27 14:09:34 +00:00
|
|
|
}
|
2000-05-04 08:35:42 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2006-01-26 02:29:17 +00:00
|
|
|
nsIFrame::IsVisibleForPainting() {
|
|
|
|
if (!GetStyleVisibility()->IsVisible())
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2000-05-04 08:35:42 +00:00
|
|
|
|
2007-03-30 21:11:41 +00:00
|
|
|
nsPresContext* pc = PresContext();
|
2006-01-26 02:29:17 +00:00
|
|
|
if (!pc->IsRenderingOnlySelection())
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2006-01-26 02:29:17 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsISelectionController> selcon(do_QueryInterface(pc->PresShell()));
|
|
|
|
if (selcon) {
|
|
|
|
nsCOMPtr<nsISelection> sel;
|
|
|
|
selcon->GetSelection(nsISelectionController::SELECTION_NORMAL,
|
|
|
|
getter_AddRefs(sel));
|
|
|
|
if (sel)
|
|
|
|
return IsVisibleInSelection(sel);
|
2001-03-08 02:46:44 +00:00
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
2001-03-08 02:46:44 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2006-01-26 02:29:17 +00:00
|
|
|
nsIFrame::IsVisibleInSelection(nsDisplayListBuilder* aBuilder) {
|
|
|
|
nsISelection* sel = aBuilder->GetBoundingSelection();
|
|
|
|
return !sel || IsVisibleInSelection(sel);
|
|
|
|
}
|
2001-03-08 02:46:44 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2006-01-26 02:29:17 +00:00
|
|
|
nsIFrame::IsVisibleOrCollapsedForPainting(nsDisplayListBuilder* aBuilder) {
|
|
|
|
if (!GetStyleVisibility()->IsVisibleOrCollapsed())
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2006-01-26 02:29:17 +00:00
|
|
|
nsISelection* sel = aBuilder->GetBoundingSelection();
|
|
|
|
return !sel || IsVisibleInSelection(sel);
|
|
|
|
}
|
2001-03-08 02:46:44 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2006-01-26 02:29:17 +00:00
|
|
|
nsIFrame::IsVisibleInSelection(nsISelection* aSelection)
|
|
|
|
{
|
2011-12-20 09:15:41 +00:00
|
|
|
if (!GetContent() || !GetContent()->IsSelectionDescendant()) {
|
|
|
|
return false;
|
|
|
|
}
|
2006-01-26 02:29:17 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(mContent));
|
2011-09-29 06:19:26 +00:00
|
|
|
bool vis;
|
2011-10-17 14:59:28 +00:00
|
|
|
nsresult rv = aSelection->ContainsNode(node, true, &vis);
|
2006-01-26 02:29:17 +00:00
|
|
|
return NS_FAILED(rv) || vis;
|
2001-03-08 02:46:44 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
/* virtual */ bool
|
2003-11-10 23:36:06 +00:00
|
|
|
nsFrame::IsEmpty()
|
2001-10-25 01:08:40 +00:00
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2001-10-25 01:08:40 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2006-02-27 04:15:05 +00:00
|
|
|
nsIFrame::CachedIsEmpty()
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(!(GetStateBits() & NS_FRAME_IS_DIRTY),
|
|
|
|
"Must only be called on reflowed lines");
|
|
|
|
return IsEmpty();
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
/* virtual */ bool
|
2004-11-15 05:01:11 +00:00
|
|
|
nsFrame::IsSelfEmpty()
|
2004-11-14 20:22:58 +00:00
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2004-11-14 20:22:58 +00:00
|
|
|
}
|
|
|
|
|
2000-05-31 03:20:02 +00:00
|
|
|
NS_IMETHODIMP
|
2004-07-31 23:15:21 +00:00
|
|
|
nsFrame::GetSelectionController(nsPresContext *aPresContext, nsISelectionController **aSelCon)
|
2000-05-04 08:35:42 +00:00
|
|
|
{
|
|
|
|
if (!aPresContext || !aSelCon)
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
2005-01-16 18:44:01 +00:00
|
|
|
|
|
|
|
nsIFrame *frame = this;
|
|
|
|
while (frame && (frame->GetStateBits() & NS_FRAME_INDEPENDENT_SELECTION)) {
|
2009-01-12 19:20:59 +00:00
|
|
|
nsITextControlFrame *tcf = do_QueryFrame(frame);
|
|
|
|
if (tcf) {
|
2010-04-21 20:17:41 +00:00
|
|
|
return tcf->GetOwnedSelectionController(aSelCon);
|
2000-05-04 08:35:42 +00:00
|
|
|
}
|
2005-01-16 18:44:01 +00:00
|
|
|
frame = frame->GetParent();
|
2000-05-04 08:35:42 +00:00
|
|
|
}
|
2005-01-16 18:44:01 +00:00
|
|
|
|
2006-02-21 00:49:04 +00:00
|
|
|
return CallQueryInterface(aPresContext->GetPresShell(), aSelCon);
|
2000-05-04 08:35:42 +00:00
|
|
|
}
|
|
|
|
|
2007-11-22 20:47:33 +00:00
|
|
|
already_AddRefed<nsFrameSelection>
|
|
|
|
nsIFrame::GetFrameSelection()
|
|
|
|
{
|
|
|
|
nsFrameSelection* fs =
|
|
|
|
const_cast<nsFrameSelection*>(GetConstFrameSelection());
|
|
|
|
NS_IF_ADDREF(fs);
|
|
|
|
return fs;
|
|
|
|
}
|
|
|
|
|
|
|
|
const nsFrameSelection*
|
2011-12-20 09:15:41 +00:00
|
|
|
nsIFrame::GetConstFrameSelection() const
|
2006-02-21 00:49:04 +00:00
|
|
|
{
|
2011-12-20 09:15:41 +00:00
|
|
|
nsIFrame* frame = const_cast<nsIFrame*>(this);
|
2006-02-21 00:49:04 +00:00
|
|
|
while (frame && (frame->GetStateBits() & NS_FRAME_INDEPENDENT_SELECTION)) {
|
2011-12-20 09:15:41 +00:00
|
|
|
nsITextControlFrame* tcf = do_QueryFrame(frame);
|
2009-01-12 19:20:59 +00:00
|
|
|
if (tcf) {
|
2006-02-21 00:49:04 +00:00
|
|
|
return tcf->GetOwnedFrameSelection();
|
|
|
|
}
|
|
|
|
frame = frame->GetParent();
|
|
|
|
}
|
2000-05-04 08:35:42 +00:00
|
|
|
|
2007-11-22 20:47:33 +00:00
|
|
|
return PresContext()->PresShell()->ConstFrameSelection();
|
2006-02-21 00:49:04 +00:00
|
|
|
}
|
2000-05-04 08:35:42 +00:00
|
|
|
|
2012-06-25 19:59:42 +00:00
|
|
|
#ifdef DEBUG
|
1998-11-19 17:22:29 +00:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsFrame::DumpRegressionData(nsPresContext* aPresContext, FILE* out, int32_t aIndent)
|
1998-11-19 17:22:29 +00:00
|
|
|
{
|
|
|
|
IndentBy(out, aIndent);
|
2012-09-14 20:09:52 +00:00
|
|
|
fprintf(out, "<frame va=\"%p\" type=\"", (void*)this);
|
1998-11-19 17:22:29 +00:00
|
|
|
nsAutoString name;
|
|
|
|
GetFrameName(name);
|
1998-11-19 17:55:22 +00:00
|
|
|
XMLQuote(name);
|
2006-02-03 14:18:39 +00:00
|
|
|
fputs(NS_LossyConvertUTF16toASCII(name).get(), out);
|
2012-09-14 20:09:52 +00:00
|
|
|
fprintf(out, "\" state=\"%016llx\" parent=\"%p\">\n",
|
|
|
|
(unsigned long long)GetDebugStateBits(), (void*)mParent);
|
1998-11-19 17:22:29 +00:00
|
|
|
|
|
|
|
aIndent++;
|
2009-02-10 04:36:54 +00:00
|
|
|
DumpBaseRegressionData(aPresContext, out, aIndent);
|
1998-11-19 17:22:29 +00:00
|
|
|
aIndent--;
|
|
|
|
|
|
|
|
IndentBy(out, aIndent);
|
|
|
|
fprintf(out, "</frame>\n");
|
1998-05-05 23:56:50 +00:00
|
|
|
|
1998-04-17 01:41:24 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-11-19 17:22:29 +00:00
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsFrame::DumpBaseRegressionData(nsPresContext* aPresContext, FILE* out, int32_t aIndent)
|
1998-11-19 17:22:29 +00:00
|
|
|
{
|
2009-09-18 11:09:36 +00:00
|
|
|
if (GetNextSibling()) {
|
1998-11-19 17:22:29 +00:00
|
|
|
IndentBy(out, aIndent);
|
2012-09-14 20:09:52 +00:00
|
|
|
fprintf(out, "<next-sibling va=\"%p\"/>\n", (void*)GetNextSibling());
|
1998-11-19 17:22:29 +00:00
|
|
|
}
|
|
|
|
|
2003-06-19 23:44:01 +00:00
|
|
|
if (HasView()) {
|
1998-11-19 17:22:29 +00:00
|
|
|
IndentBy(out, aIndent);
|
2012-09-14 20:09:52 +00:00
|
|
|
fprintf(out, "<view va=\"%p\">\n", (void*)GetView());
|
1998-11-19 17:22:29 +00:00
|
|
|
aIndent++;
|
|
|
|
// XXX add in code to dump out view state too...
|
|
|
|
aIndent--;
|
|
|
|
IndentBy(out, aIndent);
|
|
|
|
fprintf(out, "</view>\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
IndentBy(out, aIndent);
|
1999-02-08 17:56:00 +00:00
|
|
|
fprintf(out, "<bbox x=\"%d\" y=\"%d\" w=\"%d\" h=\"%d\"/>\n",
|
1998-11-19 17:22:29 +00:00
|
|
|
mRect.x, mRect.y, mRect.width, mRect.height);
|
|
|
|
|
|
|
|
// Now dump all of the children on all of the child lists
|
2011-08-24 20:54:29 +00:00
|
|
|
ChildListIterator lists(this);
|
|
|
|
for (; !lists.IsDone(); lists.Next()) {
|
|
|
|
IndentBy(out, aIndent);
|
|
|
|
if (lists.CurrentID() != kPrincipalList) {
|
|
|
|
fprintf(out, "<child-list name=\"%s\">\n", mozilla::layout::ChildListName(lists.CurrentID()));
|
1998-11-19 17:22:29 +00:00
|
|
|
}
|
2011-08-24 20:54:29 +00:00
|
|
|
else {
|
|
|
|
fprintf(out, "<child-list>\n");
|
|
|
|
}
|
|
|
|
aIndent++;
|
|
|
|
nsFrameList::Enumerator childFrames(lists.CurrentList());
|
|
|
|
for (; !childFrames.AtEnd(); childFrames.Next()) {
|
|
|
|
nsIFrame* kid = childFrames.get();
|
|
|
|
kid->DumpRegressionData(aPresContext, out, aIndent);
|
|
|
|
}
|
|
|
|
aIndent--;
|
|
|
|
IndentBy(out, aIndent);
|
|
|
|
fprintf(out, "</child-list>\n");
|
|
|
|
}
|
1998-11-19 17:22:29 +00:00
|
|
|
}
|
1999-11-01 22:12:45 +00:00
|
|
|
#endif
|
1998-04-27 16:44:52 +00:00
|
|
|
|
2011-12-20 09:15:41 +00:00
|
|
|
bool
|
|
|
|
nsIFrame::IsFrameSelected() const
|
1998-12-14 18:34:14 +00:00
|
|
|
{
|
2011-12-20 09:15:41 +00:00
|
|
|
NS_ASSERTION(!GetContent() || GetContent()->IsSelectionDescendant(),
|
|
|
|
"use the public IsSelected() instead");
|
|
|
|
return nsRange::IsNodeSelected(GetContent(), 0,
|
|
|
|
GetContent()->GetChildCount());
|
1998-12-14 18:34:14 +00:00
|
|
|
}
|
|
|
|
|
1999-02-12 00:02:31 +00:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsFrame::GetPointFromOffset(int32_t inOffset, nsPoint* outPoint)
|
1999-02-12 00:02:31 +00:00
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
NS_PRECONDITION(outPoint != nullptr, "Null parameter");
|
2010-03-04 22:52:59 +00:00
|
|
|
nsRect contentRect = GetContentRect() - GetPosition();
|
|
|
|
nsPoint pt = contentRect.TopLeft();
|
1999-10-22 00:19:18 +00:00
|
|
|
if (mContent)
|
|
|
|
{
|
2003-07-28 21:25:13 +00:00
|
|
|
nsIContent* newContent = mContent->GetParent();
|
1999-10-22 00:19:18 +00:00
|
|
|
if (newContent){
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t newOffset = newContent->IndexOf(mContent);
|
2003-09-27 04:18:26 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool isRTL = (NS_GET_EMBEDDING_LEVEL(this) & 1) == 1;
|
2008-09-15 15:40:25 +00:00
|
|
|
if ((!isRTL && inOffset > newOffset) ||
|
2010-03-04 22:52:59 +00:00
|
|
|
(isRTL && inOffset <= newOffset)) {
|
|
|
|
pt = contentRect.TopRight();
|
|
|
|
}
|
1999-10-22 00:19:18 +00:00
|
|
|
}
|
|
|
|
}
|
2010-03-04 22:52:59 +00:00
|
|
|
*outPoint = pt;
|
1999-02-12 00:02:31 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsFrame::GetChildFrameContainingOffset(int32_t inContentOffset, bool inHint, int32_t* outFrameContentOffset, nsIFrame **outChildFrame)
|
1999-02-12 00:02:31 +00:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(outChildFrame && outFrameContentOffset, "Null parameter");
|
2012-08-22 15:56:38 +00:00
|
|
|
*outFrameContentOffset = (int32_t)inHint;
|
2002-08-06 23:56:50 +00:00
|
|
|
//the best frame to reflect any given offset would be a visible frame if possible
|
|
|
|
//i.e. we are looking for a valid frame to place the blinking caret
|
2003-06-28 11:48:14 +00:00
|
|
|
nsRect rect = GetRect();
|
2002-08-06 23:56:50 +00:00
|
|
|
if (!rect.width || !rect.height)
|
|
|
|
{
|
|
|
|
//if we have a 0 width or height then lets look for another frame that possibly has
|
|
|
|
//the same content. If we have no frames in flow then just let us return 'this' frame
|
2004-09-14 02:28:03 +00:00
|
|
|
nsIFrame* nextFlow = GetNextInFlow();
|
|
|
|
if (nextFlow)
|
2002-08-06 23:56:50 +00:00
|
|
|
return nextFlow->GetChildFrameContainingOffset(inContentOffset, inHint, outFrameContentOffset, outChildFrame);
|
|
|
|
}
|
1999-02-12 00:02:31 +00:00
|
|
|
*outChildFrame = this;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-01-22 18:58:14 +00:00
|
|
|
|
2000-05-16 22:48:28 +00:00
|
|
|
//
|
|
|
|
// What I've pieced together about this routine:
|
|
|
|
// Starting with a block frame (from which a line frame can be gotten)
|
|
|
|
// and a line number, drill down and get the first/last selectable
|
|
|
|
// frame on that line, depending on aPos->mDirection.
|
|
|
|
// aOutSideLimit != 0 means ignore aLineStart, instead work from
|
|
|
|
// the end (if > 0) or beginning (if < 0).
|
|
|
|
//
|
1999-08-24 21:51:47 +00:00
|
|
|
nsresult
|
2004-07-31 23:15:21 +00:00
|
|
|
nsFrame::GetNextPrevLineFromeBlockFrame(nsPresContext* aPresContext,
|
1999-10-26 04:44:41 +00:00
|
|
|
nsPeekOffsetStruct *aPos,
|
1999-07-15 18:19:03 +00:00
|
|
|
nsIFrame *aBlockFrame,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aLineStart,
|
|
|
|
int8_t aOutSideLimit
|
1999-07-15 18:19:03 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
//magic numbers aLineStart will be -1 for end of block 0 will be start of block
|
1999-10-13 01:15:26 +00:00
|
|
|
if (!aBlockFrame || !aPos)
|
1999-07-15 18:19:03 +00:00
|
|
|
return NS_ERROR_NULL_POINTER;
|
1999-09-01 01:02:16 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
aPos->mResultFrame = nullptr;
|
|
|
|
aPos->mResultContent = nullptr;
|
2006-07-13 06:06:29 +00:00
|
|
|
aPos->mAttachForward = (aPos->mDirection == eDirNext);
|
1999-10-13 01:15:26 +00:00
|
|
|
|
2008-10-30 19:17:59 +00:00
|
|
|
nsAutoLineIterator it = aBlockFrame->GetLineIterator();
|
|
|
|
if (!it)
|
|
|
|
return NS_ERROR_FAILURE;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t searchingLine = aLineStart;
|
|
|
|
int32_t countLines = it->GetNumLines();
|
1999-07-15 18:19:03 +00:00
|
|
|
if (aOutSideLimit > 0) //start at end
|
|
|
|
searchingLine = countLines;
|
2005-11-20 22:05:24 +00:00
|
|
|
else if (aOutSideLimit <0)//start at beginning
|
2000-05-11 01:04:39 +00:00
|
|
|
searchingLine = -1;//"next" will be 0
|
1999-07-15 18:19:03 +00:00
|
|
|
else
|
2000-05-11 01:04:39 +00:00
|
|
|
if ((aPos->mDirection == eDirPrevious && searchingLine == 0) ||
|
|
|
|
(aPos->mDirection == eDirNext && searchingLine >= (countLines -1) )){
|
1999-07-15 18:19:03 +00:00
|
|
|
//we need to jump to new block frame.
|
2000-05-11 01:04:39 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t lineFrameCount;
|
2012-07-30 14:20:58 +00:00
|
|
|
nsIFrame *resultFrame = nullptr;
|
|
|
|
nsIFrame *farStoppingFrame = nullptr; //we keep searching until we find a "this" frame then we go to next line
|
|
|
|
nsIFrame *nearStoppingFrame = nullptr; //if we are backing up from edge, stop here
|
1999-07-15 18:19:03 +00:00
|
|
|
nsIFrame *firstFrame;
|
|
|
|
nsIFrame *lastFrame;
|
2002-08-06 23:56:50 +00:00
|
|
|
nsRect rect;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool isBeforeFirstFrame, isAfterLastFrame;
|
|
|
|
bool found = false;
|
2008-10-30 19:17:59 +00:00
|
|
|
|
|
|
|
nsresult result = NS_OK;
|
1999-07-15 18:19:03 +00:00
|
|
|
while (!found)
|
|
|
|
{
|
1999-10-13 01:15:26 +00:00
|
|
|
if (aPos->mDirection == eDirPrevious)
|
1999-07-15 18:19:03 +00:00
|
|
|
searchingLine --;
|
|
|
|
else
|
|
|
|
searchingLine ++;
|
1999-10-13 01:15:26 +00:00
|
|
|
if ((aPos->mDirection == eDirPrevious && searchingLine < 0) ||
|
|
|
|
(aPos->mDirection == eDirNext && searchingLine >= countLines ))
|
1999-09-10 18:29:37 +00:00
|
|
|
{
|
2000-05-11 01:04:39 +00:00
|
|
|
//we need to jump to new block frame.
|
1999-09-10 18:29:37 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t lineFlags;
|
1999-10-12 23:25:19 +00:00
|
|
|
result = it->GetLine(searchingLine, &firstFrame, &lineFrameCount,
|
2002-08-06 23:56:50 +00:00
|
|
|
rect, &lineFlags);
|
2002-08-20 22:42:26 +00:00
|
|
|
if (!lineFrameCount)
|
1999-09-10 18:29:37 +00:00
|
|
|
continue;
|
1999-07-15 18:19:03 +00:00
|
|
|
if (NS_SUCCEEDED(result)){
|
|
|
|
lastFrame = firstFrame;
|
|
|
|
for (;lineFrameCount > 1;lineFrameCount --){
|
2000-05-11 01:04:39 +00:00
|
|
|
//result = lastFrame->GetNextSibling(&lastFrame, searchingLine);
|
2000-06-16 22:28:10 +00:00
|
|
|
result = it->GetNextSiblingOnLine(lastFrame, searchingLine);
|
2001-05-25 20:27:41 +00:00
|
|
|
if (NS_FAILED(result) || !lastFrame){
|
2005-10-17 00:03:05 +00:00
|
|
|
NS_ERROR("GetLine promised more frames than could be found");
|
2001-05-25 20:27:41 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
1999-07-15 18:19:03 +00:00
|
|
|
}
|
|
|
|
}
|
2000-01-22 01:16:50 +00:00
|
|
|
GetLastLeaf(aPresContext, &lastFrame);
|
1999-07-15 18:19:03 +00:00
|
|
|
|
1999-10-13 01:15:26 +00:00
|
|
|
if (aPos->mDirection == eDirNext){
|
1999-07-15 18:19:03 +00:00
|
|
|
nearStoppingFrame = firstFrame;
|
|
|
|
farStoppingFrame = lastFrame;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
nearStoppingFrame = lastFrame;
|
|
|
|
farStoppingFrame = firstFrame;
|
|
|
|
}
|
1999-09-10 18:29:37 +00:00
|
|
|
nsPoint offset;
|
|
|
|
nsIView * view; //used for call of get offset from view
|
2004-12-26 19:48:54 +00:00
|
|
|
aBlockFrame->GetOffsetFromView(offset,&view);
|
1999-10-13 01:15:26 +00:00
|
|
|
nscoord newDesiredX = aPos->mDesiredX - offset.x;//get desired x into blockframe coordinates!
|
1999-09-10 18:29:37 +00:00
|
|
|
result = it->FindFrameAt(searchingLine, newDesiredX, &resultFrame, &isBeforeFirstFrame, &isAfterLastFrame);
|
2000-05-14 00:10:25 +00:00
|
|
|
if(NS_FAILED(result))
|
|
|
|
continue;
|
1999-07-15 18:19:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(result) && resultFrame)
|
|
|
|
{
|
|
|
|
//check to see if this is ANOTHER blockframe inside the other one if so then call into its lines
|
2008-10-30 19:17:59 +00:00
|
|
|
nsAutoLineIterator newIt = resultFrame->GetLineIterator();
|
|
|
|
if (newIt)
|
1999-07-15 18:19:03 +00:00
|
|
|
{
|
1999-10-13 01:15:26 +00:00
|
|
|
aPos->mResultFrame = resultFrame;
|
1999-09-01 21:40:16 +00:00
|
|
|
return NS_OK;
|
1999-07-15 18:19:03 +00:00
|
|
|
}
|
|
|
|
//resultFrame is not a block frame
|
2008-10-30 19:17:59 +00:00
|
|
|
result = NS_ERROR_FAILURE;
|
1999-07-15 18:19:03 +00:00
|
|
|
|
2012-10-15 18:35:50 +00:00
|
|
|
nsCOMPtr<nsIFrameEnumerator> frameTraversal;
|
|
|
|
result = NS_NewFrameTraversal(getter_AddRefs(frameTraversal),
|
|
|
|
aPresContext, resultFrame,
|
|
|
|
ePostOrder,
|
|
|
|
false, // aVisual
|
|
|
|
aPos->mScrollViewStop,
|
|
|
|
false // aFollowOOFs
|
|
|
|
);
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
return result;
|
|
|
|
|
1999-07-15 18:19:03 +00:00
|
|
|
nsIFrame *storeOldResultFrame = resultFrame;
|
|
|
|
while ( !found ){
|
1999-10-13 01:15:26 +00:00
|
|
|
nsPoint point;
|
|
|
|
point.x = aPos->mDesiredX;
|
2000-05-11 01:04:39 +00:00
|
|
|
|
2003-06-28 11:48:14 +00:00
|
|
|
nsRect tempRect = resultFrame->GetRect();
|
2000-08-09 22:33:03 +00:00
|
|
|
nsPoint offset;
|
|
|
|
nsIView * view; //used for call of get offset from view
|
2004-12-26 19:48:54 +00:00
|
|
|
result = resultFrame->GetOffsetFromView(offset, &view);
|
2000-08-09 22:33:03 +00:00
|
|
|
if (NS_FAILED(result))
|
|
|
|
return result;
|
|
|
|
point.y = tempRect.height + offset.y;
|
|
|
|
|
2012-10-15 18:35:50 +00:00
|
|
|
//special check. if we allow non-text selection then we can allow a hit location to fall before a table.
|
2000-09-15 07:02:05 +00:00
|
|
|
//otherwise there is no way to get and click signal to fall before a table (it being a line iterator itself)
|
2003-12-21 05:36:36 +00:00
|
|
|
nsIPresShell *shell = aPresContext->GetPresShell();
|
2000-09-15 07:02:05 +00:00
|
|
|
if (!shell)
|
|
|
|
return NS_ERROR_FAILURE;
|
2012-08-22 15:56:38 +00:00
|
|
|
int16_t isEditor = shell->GetSelectionFlags();
|
2001-12-18 01:29:49 +00:00
|
|
|
isEditor = isEditor == nsISelectionDisplay::DISPLAY_ALL;
|
2010-03-20 21:54:19 +00:00
|
|
|
if ( isEditor )
|
2000-09-15 07:02:05 +00:00
|
|
|
{
|
2006-12-26 17:47:52 +00:00
|
|
|
if (resultFrame->GetType() == nsGkAtoms::tableOuterFrame)
|
2000-09-15 07:02:05 +00:00
|
|
|
{
|
2003-10-31 20:19:18 +00:00
|
|
|
if (((point.x - offset.x + tempRect.x)<0) || ((point.x - offset.x+ tempRect.x)>tempRect.width))//off left/right side
|
2000-09-15 07:02:05 +00:00
|
|
|
{
|
2003-10-31 20:19:18 +00:00
|
|
|
nsIContent* content = resultFrame->GetContent();
|
|
|
|
if (content)
|
2000-09-15 07:02:05 +00:00
|
|
|
{
|
2003-10-31 20:19:18 +00:00
|
|
|
nsIContent* parent = content->GetParent();
|
|
|
|
if (parent)
|
2000-09-15 07:02:05 +00:00
|
|
|
{
|
2003-10-31 20:19:18 +00:00
|
|
|
aPos->mResultContent = parent;
|
|
|
|
aPos->mContentOffset = parent->IndexOf(content);
|
2011-10-17 14:59:28 +00:00
|
|
|
aPos->mAttachForward = false;
|
2003-10-31 20:19:18 +00:00
|
|
|
if ((point.x - offset.x+ tempRect.x)>tempRect.width)
|
2000-09-15 07:02:05 +00:00
|
|
|
{
|
2003-10-31 20:19:18 +00:00
|
|
|
aPos->mContentOffset++;//go to end of this frame
|
2011-10-17 14:59:28 +00:00
|
|
|
aPos->mAttachForward = true;
|
2000-09-15 07:02:05 +00:00
|
|
|
}
|
2003-10-31 20:19:18 +00:00
|
|
|
//result frame is the result frames parent.
|
|
|
|
aPos->mResultFrame = resultFrame->GetParent();
|
|
|
|
return NS_POSITION_BEFORE_TABLE;
|
2000-09-15 07:02:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-19 23:44:01 +00:00
|
|
|
if (!resultFrame->HasView())
|
2000-04-12 03:04:11 +00:00
|
|
|
{
|
2005-10-30 13:05:45 +00:00
|
|
|
nsIView* view;
|
|
|
|
nsPoint offset;
|
|
|
|
resultFrame->GetOffsetFromView(offset, &view);
|
2006-02-27 05:57:37 +00:00
|
|
|
ContentOffsets offsets =
|
|
|
|
resultFrame->GetContentOffsetsFromPoint(point - offset);
|
|
|
|
aPos->mResultContent = offsets.content;
|
|
|
|
aPos->mContentOffset = offsets.offset;
|
2006-07-13 06:06:29 +00:00
|
|
|
aPos->mAttachForward = offsets.associateWithNext;
|
2006-02-27 05:57:37 +00:00
|
|
|
if (offsets.content)
|
2005-03-29 03:28:10 +00:00
|
|
|
{
|
2011-09-29 06:19:26 +00:00
|
|
|
bool selectable;
|
2012-07-30 14:20:58 +00:00
|
|
|
resultFrame->IsSelectable(&selectable, nullptr);
|
2005-03-29 03:28:10 +00:00
|
|
|
if (selectable)
|
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
found = true;
|
2005-03-29 03:28:10 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2000-04-12 03:04:11 +00:00
|
|
|
}
|
2005-03-29 03:28:10 +00:00
|
|
|
|
|
|
|
if (aPos->mDirection == eDirPrevious && (resultFrame == farStoppingFrame))
|
|
|
|
break;
|
|
|
|
if (aPos->mDirection == eDirNext && (resultFrame == nearStoppingFrame))
|
|
|
|
break;
|
|
|
|
//always try previous on THAT line if that fails go the other way
|
2012-10-15 18:35:50 +00:00
|
|
|
frameTraversal->Prev();
|
|
|
|
resultFrame = frameTraversal->CurrentItem();
|
2008-10-30 17:15:22 +00:00
|
|
|
if (!resultFrame)
|
|
|
|
return NS_ERROR_FAILURE;
|
1999-07-15 18:19:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!found){
|
|
|
|
resultFrame = storeOldResultFrame;
|
2012-08-06 03:00:55 +00:00
|
|
|
|
2012-10-15 18:35:50 +00:00
|
|
|
result = NS_NewFrameTraversal(getter_AddRefs(frameTraversal),
|
|
|
|
aPresContext, resultFrame,
|
|
|
|
eLeaf,
|
|
|
|
false, // aVisual
|
|
|
|
aPos->mScrollViewStop,
|
|
|
|
false // aFollowOOFs
|
|
|
|
);
|
1999-07-15 18:19:03 +00:00
|
|
|
}
|
|
|
|
while ( !found ){
|
2006-02-27 05:57:37 +00:00
|
|
|
nsPoint point(aPos->mDesiredX, 0);
|
2005-09-04 20:04:23 +00:00
|
|
|
nsIView* view;
|
|
|
|
nsPoint offset;
|
|
|
|
resultFrame->GetOffsetFromView(offset, &view);
|
2006-02-27 05:57:37 +00:00
|
|
|
ContentOffsets offsets =
|
|
|
|
resultFrame->GetContentOffsetsFromPoint(point - offset);
|
|
|
|
aPos->mResultContent = offsets.content;
|
|
|
|
aPos->mContentOffset = offsets.offset;
|
2006-07-13 06:06:29 +00:00
|
|
|
aPos->mAttachForward = offsets.associateWithNext;
|
2006-02-27 05:57:37 +00:00
|
|
|
if (offsets.content)
|
1999-10-13 01:15:26 +00:00
|
|
|
{
|
2011-09-29 06:19:26 +00:00
|
|
|
bool selectable;
|
2012-07-30 14:20:58 +00:00
|
|
|
resultFrame->IsSelectable(&selectable, nullptr);
|
2005-03-29 03:28:10 +00:00
|
|
|
if (selectable)
|
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
found = true;
|
2005-03-29 03:28:10 +00:00
|
|
|
if (resultFrame == farStoppingFrame)
|
2011-10-17 14:59:28 +00:00
|
|
|
aPos->mAttachForward = false;
|
2005-03-29 03:28:10 +00:00
|
|
|
else
|
2011-10-17 14:59:28 +00:00
|
|
|
aPos->mAttachForward = true;
|
1999-07-15 18:19:03 +00:00
|
|
|
break;
|
2005-03-29 03:28:10 +00:00
|
|
|
}
|
1999-07-15 18:19:03 +00:00
|
|
|
}
|
2005-03-29 03:28:10 +00:00
|
|
|
if (aPos->mDirection == eDirPrevious && (resultFrame == nearStoppingFrame))
|
|
|
|
break;
|
|
|
|
if (aPos->mDirection == eDirNext && (resultFrame == farStoppingFrame))
|
|
|
|
break;
|
|
|
|
//previous didnt work now we try "next"
|
2012-10-15 18:35:50 +00:00
|
|
|
frameTraversal->Next();
|
|
|
|
nsIFrame *tempFrame = frameTraversal->CurrentItem();
|
2008-10-30 17:15:22 +00:00
|
|
|
if (!tempFrame)
|
2005-03-29 03:28:10 +00:00
|
|
|
break;
|
2008-10-30 17:15:22 +00:00
|
|
|
resultFrame = tempFrame;
|
1999-07-15 18:19:03 +00:00
|
|
|
}
|
1999-10-13 01:15:26 +00:00
|
|
|
aPos->mResultFrame = resultFrame;
|
1999-07-15 18:19:03 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
//we need to jump to new block frame.
|
1999-10-13 01:15:26 +00:00
|
|
|
aPos->mAmount = eSelectLine;
|
|
|
|
aPos->mStartOffset = 0;
|
2006-07-13 06:06:29 +00:00
|
|
|
aPos->mAttachForward = !(aPos->mDirection == eDirNext);
|
1999-10-13 01:15:26 +00:00
|
|
|
if (aPos->mDirection == eDirPrevious)
|
|
|
|
aPos->mStartOffset = -1;//start from end
|
2006-09-11 20:43:01 +00:00
|
|
|
return aBlockFrame->PeekOffset(aPos);
|
1999-07-15 18:19:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-03-26 16:09:38 +00:00
|
|
|
nsIFrame::CaretPosition
|
|
|
|
nsIFrame::GetExtremeCaretPosition(bool aStart)
|
2004-11-29 20:28:46 +00:00
|
|
|
{
|
2012-03-26 16:09:38 +00:00
|
|
|
CaretPosition result;
|
2004-11-29 20:28:46 +00:00
|
|
|
|
2012-05-29 13:13:36 +00:00
|
|
|
FrameTarget targetFrame = DrillDownToSelectionFrame(this, !aStart, 0);
|
2006-03-13 01:13:25 +00:00
|
|
|
FrameContentRange range = GetRangeForFrame(targetFrame.frame);
|
|
|
|
result.mResultContent = range.content;
|
|
|
|
result.mContentOffset = aStart ? range.start : range.end;
|
2004-11-29 20:28:46 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2005-08-18 17:09:16 +00:00
|
|
|
// Find the first (or last) descendant of the given frame
|
|
|
|
// which is either a block frame or a BRFrame.
|
2005-09-18 12:41:40 +00:00
|
|
|
static nsContentAndOffset
|
2005-08-18 17:09:16 +00:00
|
|
|
FindBlockFrameOrBR(nsIFrame* aFrame, nsDirection aDirection)
|
|
|
|
{
|
2005-09-18 12:41:40 +00:00
|
|
|
nsContentAndOffset result;
|
2012-07-30 14:20:58 +00:00
|
|
|
result.mContent = nullptr;
|
2008-02-23 10:54:29 +00:00
|
|
|
result.mOffset = 0;
|
2006-03-01 19:28:42 +00:00
|
|
|
|
2006-05-29 08:32:46 +00:00
|
|
|
if (aFrame->IsGeneratedContentFrame())
|
|
|
|
return result;
|
|
|
|
|
2006-03-01 19:28:42 +00:00
|
|
|
// Treat form controls as inline leaves
|
|
|
|
// XXX we really need a way to determine whether a frame is inline-level
|
2009-01-12 19:20:59 +00:00
|
|
|
nsIFormControlFrame* fcf = do_QueryFrame(aFrame);
|
|
|
|
if (fcf)
|
2006-03-01 19:28:42 +00:00
|
|
|
return result;
|
|
|
|
|
|
|
|
// Check the frame itself
|
2005-08-18 17:09:16 +00:00
|
|
|
// Fall through "special" block frames because their mContent is the content
|
|
|
|
// of the inline frames they were created from. The first/last child of
|
|
|
|
// such frames is the real block frame we're looking for.
|
2008-09-15 15:40:25 +00:00
|
|
|
if ((nsLayoutUtils::GetAsBlock(aFrame) && !(aFrame->GetStateBits() & NS_FRAME_IS_SPECIAL)) ||
|
2006-12-26 17:47:52 +00:00
|
|
|
aFrame->GetType() == nsGkAtoms::brFrame) {
|
2005-09-18 12:41:40 +00:00
|
|
|
nsIContent* content = aFrame->GetContent();
|
|
|
|
result.mContent = content->GetParent();
|
2008-02-23 10:54:29 +00:00
|
|
|
// In some cases (bug 310589, bug 370174) we end up here with a null content.
|
|
|
|
// This probably shouldn't ever happen, but since it sometimes does, we want
|
|
|
|
// to avoid crashing here.
|
|
|
|
NS_ASSERTION(result.mContent, "Unexpected orphan content");
|
2008-02-22 21:21:15 +00:00
|
|
|
if (result.mContent)
|
|
|
|
result.mOffset = result.mContent->IndexOf(content) +
|
|
|
|
(aDirection == eDirPrevious ? 1 : 0);
|
2005-09-18 12:41:40 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2006-03-01 19:28:42 +00:00
|
|
|
// If this is a preformatted text frame, see if it ends with a newline
|
2005-12-06 00:32:52 +00:00
|
|
|
if (aFrame->HasTerminalNewline() &&
|
2008-08-12 08:31:56 +00:00
|
|
|
aFrame->GetStyleContext()->GetStyleText()->NewlineIsSignificant()) {
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t startOffset, endOffset;
|
2005-09-18 12:41:40 +00:00
|
|
|
aFrame->GetOffsets(startOffset, endOffset);
|
|
|
|
result.mContent = aFrame->GetContent();
|
|
|
|
result.mOffset = endOffset - (aDirection == eDirPrevious ? 0 : 1);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2006-03-01 19:28:42 +00:00
|
|
|
// Iterate over children and call ourselves recursively
|
2005-08-18 17:09:16 +00:00
|
|
|
if (aDirection == eDirPrevious) {
|
2011-08-24 20:54:30 +00:00
|
|
|
nsIFrame* child = aFrame->GetLastChild(nsIFrame::kPrincipalList);
|
2005-09-18 12:41:40 +00:00
|
|
|
while(child && !result.mContent) {
|
|
|
|
result = FindBlockFrameOrBR(child, aDirection);
|
2009-10-02 16:27:37 +00:00
|
|
|
child = child->GetPrevSibling();
|
2005-08-18 17:09:16 +00:00
|
|
|
}
|
|
|
|
} else { // eDirNext
|
2011-08-24 20:54:30 +00:00
|
|
|
nsIFrame* child = aFrame->GetFirstPrincipalChild();
|
2005-09-18 12:41:40 +00:00
|
|
|
while(child && !result.mContent) {
|
|
|
|
result = FindBlockFrameOrBR(child, aDirection);
|
2005-08-18 17:09:16 +00:00
|
|
|
child = child->GetNextSibling();
|
2000-05-16 22:48:28 +00:00
|
|
|
}
|
|
|
|
}
|
2005-09-18 12:41:40 +00:00
|
|
|
return result;
|
2000-05-16 22:48:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2006-09-11 20:43:01 +00:00
|
|
|
nsIFrame::PeekOffsetParagraph(nsPeekOffsetStruct *aPos)
|
2000-05-16 22:48:28 +00:00
|
|
|
{
|
2005-08-18 17:09:16 +00:00
|
|
|
nsIFrame* frame = this;
|
2005-09-18 12:41:40 +00:00
|
|
|
nsContentAndOffset blockFrameOrBR;
|
2012-07-30 14:20:58 +00:00
|
|
|
blockFrameOrBR.mContent = nullptr;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool reachedBlockAncestor = false;
|
2000-05-16 22:48:28 +00:00
|
|
|
|
2005-08-18 17:09:16 +00:00
|
|
|
// Go through containing frames until reaching a block frame.
|
|
|
|
// In each step, search the previous (or next) siblings for the closest
|
|
|
|
// "stop frame" (a block frame or a BRFrame).
|
|
|
|
// If found, set it to be the selection boundray and abort.
|
|
|
|
|
|
|
|
if (aPos->mDirection == eDirPrevious) {
|
|
|
|
while (!reachedBlockAncestor) {
|
2005-08-28 08:20:34 +00:00
|
|
|
nsIFrame* parent = frame->GetParent();
|
2007-04-14 16:34:12 +00:00
|
|
|
// Treat a frame associated with the root content as if it were a block frame.
|
|
|
|
if (!frame->mContent || !frame->mContent->GetParent()) {
|
2011-10-17 14:59:28 +00:00
|
|
|
reachedBlockAncestor = true;
|
2005-08-28 08:20:34 +00:00
|
|
|
break;
|
|
|
|
}
|
2009-10-02 16:27:37 +00:00
|
|
|
nsIFrame* sibling = frame->GetPrevSibling();
|
2005-09-18 12:41:40 +00:00
|
|
|
while (sibling && !blockFrameOrBR.mContent) {
|
|
|
|
blockFrameOrBR = FindBlockFrameOrBR(sibling, eDirPrevious);
|
2009-10-02 16:27:37 +00:00
|
|
|
sibling = sibling->GetPrevSibling();
|
2005-08-18 17:09:16 +00:00
|
|
|
}
|
2005-09-18 12:41:40 +00:00
|
|
|
if (blockFrameOrBR.mContent) {
|
|
|
|
aPos->mResultContent = blockFrameOrBR.mContent;
|
|
|
|
aPos->mContentOffset = blockFrameOrBR.mOffset;
|
2000-05-16 22:48:28 +00:00
|
|
|
break;
|
|
|
|
}
|
2005-08-28 08:20:34 +00:00
|
|
|
frame = parent;
|
2012-07-30 14:20:58 +00:00
|
|
|
reachedBlockAncestor = (nsLayoutUtils::GetAsBlock(frame) != nullptr);
|
2000-05-16 22:48:28 +00:00
|
|
|
}
|
2005-08-18 17:09:16 +00:00
|
|
|
if (reachedBlockAncestor) { // no "stop frame" found
|
|
|
|
aPos->mResultContent = frame->GetContent();
|
|
|
|
aPos->mContentOffset = 0;
|
|
|
|
}
|
|
|
|
} else { // eDirNext
|
|
|
|
while (!reachedBlockAncestor) {
|
2005-08-28 08:20:34 +00:00
|
|
|
nsIFrame* parent = frame->GetParent();
|
2007-04-14 16:34:12 +00:00
|
|
|
// Treat a frame associated with the root content as if it were a block frame.
|
|
|
|
if (!frame->mContent || !frame->mContent->GetParent()) {
|
2011-10-17 14:59:28 +00:00
|
|
|
reachedBlockAncestor = true;
|
2005-08-28 08:20:34 +00:00
|
|
|
break;
|
|
|
|
}
|
2005-09-18 12:41:40 +00:00
|
|
|
nsIFrame* sibling = frame;
|
|
|
|
while (sibling && !blockFrameOrBR.mContent) {
|
|
|
|
blockFrameOrBR = FindBlockFrameOrBR(sibling, eDirNext);
|
2005-08-18 17:09:16 +00:00
|
|
|
sibling = sibling->GetNextSibling();
|
|
|
|
}
|
2005-09-18 12:41:40 +00:00
|
|
|
if (blockFrameOrBR.mContent) {
|
|
|
|
aPos->mResultContent = blockFrameOrBR.mContent;
|
|
|
|
aPos->mContentOffset = blockFrameOrBR.mOffset;
|
2005-08-18 17:09:16 +00:00
|
|
|
break;
|
|
|
|
}
|
2005-08-28 08:20:34 +00:00
|
|
|
frame = parent;
|
2012-07-30 14:20:58 +00:00
|
|
|
reachedBlockAncestor = (nsLayoutUtils::GetAsBlock(frame) != nullptr);
|
2005-08-18 17:09:16 +00:00
|
|
|
}
|
|
|
|
if (reachedBlockAncestor) { // no "stop frame" found
|
|
|
|
aPos->mResultContent = frame->GetContent();
|
2005-08-28 08:20:34 +00:00
|
|
|
if (aPos->mResultContent)
|
|
|
|
aPos->mContentOffset = aPos->mResultContent->GetChildCount();
|
2000-05-16 22:48:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2006-09-11 20:43:01 +00:00
|
|
|
// Determine movement direction relative to frame
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool IsMovingInFrameDirection(nsIFrame* frame, nsDirection aDirection, bool aVisual)
|
2006-09-11 20:43:01 +00:00
|
|
|
{
|
2011-09-29 06:19:26 +00:00
|
|
|
bool isReverseDirection = aVisual ?
|
2011-10-17 14:59:28 +00:00
|
|
|
(NS_GET_EMBEDDING_LEVEL(frame) & 1) != (NS_GET_BASE_LEVEL(frame) & 1) : false;
|
2006-09-11 20:43:01 +00:00
|
|
|
return aDirection == (isReverseDirection ? eDirPrevious : eDirNext);
|
|
|
|
}
|
|
|
|
|
2006-09-11 08:03:28 +00:00
|
|
|
NS_IMETHODIMP
|
2006-09-11 20:43:01 +00:00
|
|
|
nsIFrame::PeekOffset(nsPeekOffsetStruct* aPos)
|
1999-09-10 18:29:37 +00:00
|
|
|
{
|
2006-07-13 06:06:29 +00:00
|
|
|
if (!aPos)
|
1999-02-10 18:55:25 +00:00
|
|
|
return NS_ERROR_NULL_POINTER;
|
2006-07-13 06:06:29 +00:00
|
|
|
nsresult result = NS_ERROR_FAILURE;
|
2003-09-27 04:18:26 +00:00
|
|
|
|
2006-09-11 20:43:01 +00:00
|
|
|
if (mState & NS_FRAME_IS_DIRTY)
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
2003-09-27 04:18:26 +00:00
|
|
|
|
2006-09-11 20:43:01 +00:00
|
|
|
// Translate content offset to be relative to frame
|
|
|
|
FrameContentRange range = GetRangeForFrame(this);
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t offset = aPos->mStartOffset - range.start;
|
2006-09-11 20:43:01 +00:00
|
|
|
nsIFrame* current = this;
|
|
|
|
|
|
|
|
switch (aPos->mAmount) {
|
|
|
|
case eSelectCharacter:
|
2010-12-16 22:17:41 +00:00
|
|
|
case eSelectCluster:
|
2006-09-11 20:43:01 +00:00
|
|
|
{
|
2011-09-29 06:19:26 +00:00
|
|
|
bool eatingNonRenderableWS = false;
|
|
|
|
bool done = false;
|
|
|
|
bool jumpedLine = false;
|
2006-09-11 20:43:01 +00:00
|
|
|
|
|
|
|
while (!done) {
|
2011-09-29 06:19:26 +00:00
|
|
|
bool movingInFrameDirection =
|
2006-09-11 20:43:01 +00:00
|
|
|
IsMovingInFrameDirection(current, aPos->mDirection, aPos->mVisual);
|
2005-09-19 05:16:25 +00:00
|
|
|
|
2006-09-11 20:43:01 +00:00
|
|
|
if (eatingNonRenderableWS)
|
|
|
|
done = current->PeekOffsetNoAmount(movingInFrameDirection, &offset);
|
|
|
|
else
|
2010-12-16 22:17:41 +00:00
|
|
|
done = current->PeekOffsetCharacter(movingInFrameDirection, &offset,
|
|
|
|
aPos->mAmount == eSelectCluster);
|
2006-09-11 20:43:01 +00:00
|
|
|
|
|
|
|
if (!done) {
|
|
|
|
result =
|
|
|
|
current->GetFrameFromDirection(aPos->mDirection, aPos->mVisual,
|
|
|
|
aPos->mJumpLines, aPos->mScrollViewStop,
|
|
|
|
¤t, &offset, &jumpedLine);
|
2004-10-09 06:14:44 +00:00
|
|
|
if (NS_FAILED(result))
|
|
|
|
return result;
|
2006-09-11 20:43:01 +00:00
|
|
|
|
|
|
|
// If we jumped lines, it's as if we found a character, but we still need
|
|
|
|
// to eat non-renderable content on the new line.
|
|
|
|
if (jumpedLine)
|
2011-10-17 14:59:28 +00:00
|
|
|
eatingNonRenderableWS = true;
|
1999-10-22 00:19:18 +00:00
|
|
|
}
|
|
|
|
}
|
2006-09-11 20:43:01 +00:00
|
|
|
|
|
|
|
// Set outputs
|
|
|
|
range = GetRangeForFrame(current);
|
|
|
|
aPos->mResultFrame = current;
|
|
|
|
aPos->mResultContent = range.content;
|
|
|
|
// Output offset is relative to content, not frame
|
|
|
|
aPos->mContentOffset = offset < 0 ? range.end : range.start + offset;
|
2010-07-14 01:49:16 +00:00
|
|
|
// If we're dealing with a text frame and moving backward positions us at
|
|
|
|
// the end of that line, decrease the offset by one to make sure that
|
|
|
|
// we're placed before the linefeed character on the previous line.
|
|
|
|
if (offset < 0 && jumpedLine &&
|
|
|
|
aPos->mDirection == eDirPrevious &&
|
|
|
|
current->GetStyleText()->NewlineIsSignificant() &&
|
|
|
|
current->HasTerminalNewline()) {
|
|
|
|
--aPos->mContentOffset;
|
|
|
|
}
|
2006-09-11 20:43:01 +00:00
|
|
|
|
1999-10-22 00:19:18 +00:00
|
|
|
break;
|
2006-07-18 07:32:58 +00:00
|
|
|
}
|
2011-03-20 19:49:06 +00:00
|
|
|
case eSelectWordNoSpace:
|
|
|
|
// eSelectWordNoSpace means that we should not be eating any whitespace when
|
|
|
|
// moving to the adjacent word. This means that we should set aPos->
|
|
|
|
// mWordMovementType to eEndWord if we're moving forwards, and to eStartWord
|
|
|
|
// if we're moving backwards.
|
|
|
|
if (aPos->mDirection == eDirPrevious) {
|
|
|
|
aPos->mWordMovementType = eStartWord;
|
|
|
|
} else {
|
|
|
|
aPos->mWordMovementType = eEndWord;
|
|
|
|
}
|
|
|
|
// Intentionally fall through the eSelectWord case.
|
2006-09-11 20:43:01 +00:00
|
|
|
case eSelectWord:
|
1999-09-25 23:33:02 +00:00
|
|
|
{
|
2006-09-11 20:43:01 +00:00
|
|
|
// wordSelectEatSpace means "are we looking for a boundary between whitespace
|
|
|
|
// and non-whitespace (in the direction we're moving in)".
|
|
|
|
// It is true when moving forward and looking for a beginning of a word, or
|
|
|
|
// when moving backwards and looking for an end of a word.
|
2011-09-29 06:19:26 +00:00
|
|
|
bool wordSelectEatSpace;
|
2006-09-11 20:43:01 +00:00
|
|
|
if (aPos->mWordMovementType != eDefaultBehavior) {
|
|
|
|
// aPos->mWordMovementType possible values:
|
|
|
|
// eEndWord: eat the space if we're moving backwards
|
|
|
|
// eStartWord: eat the space if we're moving forwards
|
|
|
|
wordSelectEatSpace = ((aPos->mWordMovementType == eEndWord) == (aPos->mDirection == eDirPrevious));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Use the hidden preference which is based on operating system behavior.
|
|
|
|
// This pref only affects whether moving forward by word should go to the end of this word or start of the next word.
|
|
|
|
// When going backwards, the start of the word is always used, on every operating system.
|
2007-07-02 23:36:59 +00:00
|
|
|
wordSelectEatSpace = aPos->mDirection == eDirNext &&
|
2011-05-25 06:31:59 +00:00
|
|
|
Preferences::GetBool("layout.word_select.eat_space_to_next_word");
|
2007-07-02 23:36:59 +00:00
|
|
|
}
|
2006-09-11 20:43:01 +00:00
|
|
|
|
2007-08-30 03:10:19 +00:00
|
|
|
// mSawBeforeType means "we already saw characters of the type
|
2006-09-11 20:43:01 +00:00
|
|
|
// before the boundary we're looking for". Examples:
|
|
|
|
// 1. If we're moving forward, looking for a word beginning (i.e. a boundary
|
2011-10-17 14:59:28 +00:00
|
|
|
// between whitespace and non-whitespace), then eatingWS==true means
|
2006-09-11 20:43:01 +00:00
|
|
|
// "we already saw some whitespace".
|
|
|
|
// 2. If we're moving backward, looking for a word beginning (i.e. a boundary
|
2011-10-17 14:59:28 +00:00
|
|
|
// between non-whitespace and whitespace), then eatingWS==true means
|
2006-09-11 20:43:01 +00:00
|
|
|
// "we already saw some non-whitespace".
|
2007-08-30 03:10:19 +00:00
|
|
|
PeekWordState state;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t offsetAdjustment = 0;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool done = false;
|
2006-09-11 20:43:01 +00:00
|
|
|
while (!done) {
|
2011-09-29 06:19:26 +00:00
|
|
|
bool movingInFrameDirection =
|
2006-09-11 20:43:01 +00:00
|
|
|
IsMovingInFrameDirection(current, aPos->mDirection, aPos->mVisual);
|
|
|
|
|
2007-08-30 03:10:19 +00:00
|
|
|
done = current->PeekOffsetWord(movingInFrameDirection, wordSelectEatSpace,
|
|
|
|
aPos->mIsKeyboardSelect, &offset, &state);
|
2006-09-11 20:43:01 +00:00
|
|
|
|
|
|
|
if (!done) {
|
|
|
|
nsIFrame* nextFrame;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t nextFrameOffset;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool jumpedLine;
|
2006-09-11 20:43:01 +00:00
|
|
|
result =
|
|
|
|
current->GetFrameFromDirection(aPos->mDirection, aPos->mVisual,
|
|
|
|
aPos->mJumpLines, aPos->mScrollViewStop,
|
|
|
|
&nextFrame, &nextFrameOffset, &jumpedLine);
|
|
|
|
// We can't jump lines if we're looking for whitespace following
|
|
|
|
// non-whitespace, and we already encountered non-whitespace.
|
|
|
|
if (NS_FAILED(result) ||
|
2008-09-15 15:40:25 +00:00
|
|
|
(jumpedLine && !wordSelectEatSpace && state.mSawBeforeType)) {
|
2011-10-17 14:59:28 +00:00
|
|
|
done = true;
|
2011-03-30 15:56:48 +00:00
|
|
|
// If we've crossed the line boundary, check to make sure that we
|
|
|
|
// have not consumed a trailing newline as whitesapce if it's significant.
|
|
|
|
if (jumpedLine && wordSelectEatSpace &&
|
|
|
|
current->HasTerminalNewline() &&
|
|
|
|
current->GetStyleText()->NewlineIsSignificant()) {
|
|
|
|
offsetAdjustment = -1;
|
|
|
|
}
|
2006-09-11 20:43:01 +00:00
|
|
|
} else {
|
2007-11-08 04:33:28 +00:00
|
|
|
if (jumpedLine) {
|
|
|
|
state.mContext.Truncate();
|
|
|
|
}
|
2006-09-11 20:43:01 +00:00
|
|
|
current = nextFrame;
|
|
|
|
offset = nextFrameOffset;
|
|
|
|
// Jumping a line is equivalent to encountering whitespace
|
|
|
|
if (wordSelectEatSpace && jumpedLine)
|
2007-08-30 03:10:19 +00:00
|
|
|
state.SetSawBeforeType();
|
2006-09-11 20:43:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set outputs
|
|
|
|
range = GetRangeForFrame(current);
|
|
|
|
aPos->mResultFrame = current;
|
2006-07-18 07:32:58 +00:00
|
|
|
aPos->mResultContent = range.content;
|
2006-09-11 20:43:01 +00:00
|
|
|
// Output offset is relative to content, not frame
|
2011-03-30 15:56:48 +00:00
|
|
|
aPos->mContentOffset = (offset < 0 ? range.end : range.start + offset) + offsetAdjustment;
|
2006-07-18 07:32:58 +00:00
|
|
|
break;
|
|
|
|
}
|
1999-06-19 20:36:44 +00:00
|
|
|
case eSelectLine :
|
|
|
|
{
|
2008-10-30 19:17:59 +00:00
|
|
|
nsAutoLineIterator iter;
|
1999-06-19 20:36:44 +00:00
|
|
|
nsIFrame *blockFrame = this;
|
|
|
|
|
1999-07-15 18:19:03 +00:00
|
|
|
while (NS_FAILED(result)){
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t thisLine = nsFrame::GetLineNumber(blockFrame, aPos->mScrollViewStop, &blockFrame);
|
2001-05-24 01:10:19 +00:00
|
|
|
if (thisLine < 0)
|
|
|
|
return NS_ERROR_FAILURE;
|
2008-10-30 19:17:59 +00:00
|
|
|
iter = blockFrame->GetLineIterator();
|
|
|
|
NS_ASSERTION(iter, "GetLineNumber() succeeded but no block frame?");
|
|
|
|
result = NS_OK;
|
2001-05-24 01:10:19 +00:00
|
|
|
|
1999-09-01 21:40:16 +00:00
|
|
|
int edgeCase = 0;//no edge case. this should look at thisLine
|
2006-09-11 20:43:01 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool doneLooping = false;//tells us when no more block frames hit.
|
2005-11-20 22:05:24 +00:00
|
|
|
//this part will find a frame or a block frame. if it's a block frame
|
1999-09-01 21:40:16 +00:00
|
|
|
//it will "drill down" to find a viable frame or it will return an error.
|
2001-04-12 23:38:32 +00:00
|
|
|
nsIFrame *lastFrame = this;
|
1999-09-01 21:40:16 +00:00
|
|
|
do {
|
2007-03-30 21:11:41 +00:00
|
|
|
result = nsFrame::GetNextPrevLineFromeBlockFrame(PresContext(),
|
2006-09-11 20:43:01 +00:00
|
|
|
aPos,
|
|
|
|
blockFrame,
|
|
|
|
thisLine,
|
|
|
|
edgeCase //start from thisLine
|
2001-04-12 23:38:32 +00:00
|
|
|
);
|
|
|
|
if (NS_SUCCEEDED(result) && (!aPos->mResultFrame || aPos->mResultFrame == lastFrame))//we came back to same spot! keep going
|
1999-09-22 06:12:44 +00:00
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
aPos->mResultFrame = nullptr;
|
1999-09-22 06:12:44 +00:00
|
|
|
if (aPos->mDirection == eDirPrevious)
|
|
|
|
thisLine--;
|
|
|
|
else
|
|
|
|
thisLine++;
|
|
|
|
}
|
2001-04-12 23:38:32 +00:00
|
|
|
else //if failure or success with different frame.
|
2011-10-17 14:59:28 +00:00
|
|
|
doneLooping = true; //do not continue with while loop
|
2001-04-12 23:38:32 +00:00
|
|
|
|
|
|
|
lastFrame = aPos->mResultFrame; //set last frame
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(result) && aPos->mResultFrame
|
|
|
|
&& blockFrame != aPos->mResultFrame)// make sure block element is not the same as the one we had before
|
2000-12-27 00:22:25 +00:00
|
|
|
{
|
2001-06-20 04:40:17 +00:00
|
|
|
/* SPECIAL CHECK FOR TABLE NAVIGATION
|
|
|
|
tables need to navigate also and the frame that supports it is nsTableRowGroupFrame which is INSIDE
|
|
|
|
nsTableOuterFrame. if we have stumbled onto an nsTableOuter we need to drill into nsTableRowGroup
|
2005-11-20 22:05:24 +00:00
|
|
|
if we hit a header or footer that's ok just go into them,
|
2001-06-20 04:40:17 +00:00
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
bool searchTableBool = false;
|
2006-12-26 17:47:52 +00:00
|
|
|
if (aPos->mResultFrame->GetType() == nsGkAtoms::tableOuterFrame ||
|
|
|
|
aPos->mResultFrame->GetType() == nsGkAtoms::tableCellFrame)
|
2001-06-20 04:40:17 +00:00
|
|
|
{
|
2011-08-24 20:54:30 +00:00
|
|
|
nsIFrame *frame = aPos->mResultFrame->GetFirstPrincipalChild();
|
2001-06-20 04:40:17 +00:00
|
|
|
//got the table frame now
|
|
|
|
while(frame) //ok time to drill down to find iterator
|
|
|
|
{
|
2008-10-30 19:17:59 +00:00
|
|
|
iter = frame->GetLineIterator();
|
|
|
|
if (iter)
|
2001-06-20 04:40:17 +00:00
|
|
|
{
|
2004-09-02 05:02:53 +00:00
|
|
|
aPos->mResultFrame = frame;
|
2011-10-17 14:59:28 +00:00
|
|
|
searchTableBool = true;
|
2008-10-30 19:17:59 +00:00
|
|
|
result = NS_OK;
|
2004-09-02 05:02:53 +00:00
|
|
|
break; //while(frame)
|
2001-06-20 04:40:17 +00:00
|
|
|
}
|
2008-10-30 19:17:59 +00:00
|
|
|
result = NS_ERROR_FAILURE;
|
2011-08-24 20:54:30 +00:00
|
|
|
frame = frame->GetFirstPrincipalChild();
|
2001-06-20 04:40:17 +00:00
|
|
|
}
|
|
|
|
}
|
2008-10-30 19:17:59 +00:00
|
|
|
|
|
|
|
if (!searchTableBool) {
|
|
|
|
iter = aPos->mResultFrame->GetLineIterator();
|
|
|
|
result = iter ? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|
2001-04-12 23:38:32 +00:00
|
|
|
if (NS_SUCCEEDED(result) && iter)//we've struck another block element!
|
1999-09-01 21:40:16 +00:00
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
doneLooping = false;
|
1999-09-10 18:29:37 +00:00
|
|
|
if (aPos->mDirection == eDirPrevious)
|
1999-09-01 21:40:16 +00:00
|
|
|
edgeCase = 1;//far edge, search from end backwards
|
|
|
|
else
|
|
|
|
edgeCase = -1;//near edge search from beginning onwards
|
|
|
|
thisLine=0;//this line means nothing now.
|
|
|
|
//everything else means something so keep looking "inside" the block
|
1999-09-10 18:29:37 +00:00
|
|
|
blockFrame = aPos->mResultFrame;
|
1999-09-01 21:40:16 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
else
|
2001-04-12 23:38:32 +00:00
|
|
|
{
|
1999-09-01 21:40:16 +00:00
|
|
|
result = NS_OK;//THIS is to mean that everything is ok to the containing while loop
|
2001-04-12 23:38:32 +00:00
|
|
|
break;
|
|
|
|
}
|
1999-09-01 21:40:16 +00:00
|
|
|
}
|
2001-04-12 23:38:32 +00:00
|
|
|
} while (!doneLooping);
|
1999-06-19 20:36:44 +00:00
|
|
|
}
|
2006-09-11 20:43:01 +00:00
|
|
|
return result;
|
1999-06-19 20:36:44 +00:00
|
|
|
}
|
2000-05-16 22:48:28 +00:00
|
|
|
|
|
|
|
case eSelectParagraph:
|
2006-09-11 20:43:01 +00:00
|
|
|
return PeekOffsetParagraph(aPos);
|
2000-05-16 22:48:28 +00:00
|
|
|
|
1999-09-07 23:40:17 +00:00
|
|
|
case eSelectBeginLine:
|
|
|
|
case eSelectEndLine:
|
|
|
|
{
|
2006-03-13 01:13:25 +00:00
|
|
|
// Adjusted so that the caret can't get confused when content changes
|
|
|
|
nsIFrame* blockFrame = AdjustFrameForSelectionStyles(this);
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t thisLine = nsFrame::GetLineNumber(blockFrame, aPos->mScrollViewStop, &blockFrame);
|
2006-03-20 09:20:49 +00:00
|
|
|
if (thisLine < 0)
|
2006-03-13 01:13:25 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2008-10-30 19:17:59 +00:00
|
|
|
nsAutoLineIterator it = blockFrame->GetLineIterator();
|
|
|
|
NS_ASSERTION(it, "GetLineNumber() succeeded but no block frame?");
|
2000-05-16 22:48:28 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t lineFrameCount;
|
1999-09-07 23:40:17 +00:00
|
|
|
nsIFrame *firstFrame;
|
2006-03-13 01:13:25 +00:00
|
|
|
nsRect usedRect;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t lineFlags;
|
2012-07-30 14:20:58 +00:00
|
|
|
nsIFrame* baseFrame = nullptr;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool endOfLine = (eSelectEndLine == aPos->mAmount);
|
2006-08-03 06:24:11 +00:00
|
|
|
|
|
|
|
#ifdef IBMBIDI
|
2007-03-30 21:11:41 +00:00
|
|
|
if (aPos->mVisual && PresContext()->BidiEnabled()) {
|
2011-09-29 06:19:26 +00:00
|
|
|
bool lineIsRTL = it->GetDirection();
|
|
|
|
bool isReordered;
|
2006-08-03 06:24:11 +00:00
|
|
|
nsIFrame *lastFrame;
|
|
|
|
result = it->CheckLineOrder(thisLine, &isReordered, &firstFrame, &lastFrame);
|
|
|
|
baseFrame = endOfLine ? lastFrame : firstFrame;
|
2007-08-29 07:22:42 +00:00
|
|
|
if (baseFrame) {
|
|
|
|
nsBidiLevel embeddingLevel = nsBidiPresUtils::GetFrameEmbeddingLevel(baseFrame);
|
|
|
|
// If the direction of the frame on the edge is opposite to that of the line,
|
|
|
|
// we'll need to drill down to its opposite end, so reverse endOfLine.
|
|
|
|
if ((embeddingLevel & 1) == !lineIsRTL)
|
|
|
|
endOfLine = !endOfLine;
|
|
|
|
}
|
2006-08-03 06:24:11 +00:00
|
|
|
} else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
it->GetLine(thisLine, &firstFrame, &lineFrameCount, usedRect, &lineFlags);
|
|
|
|
|
|
|
|
nsIFrame* frame = firstFrame;
|
2012-08-22 15:56:38 +00:00
|
|
|
for (int32_t count = lineFrameCount; count;
|
2006-08-03 06:24:11 +00:00
|
|
|
--count, frame = frame->GetNextSibling()) {
|
|
|
|
if (!frame->IsGeneratedContentFrame()) {
|
|
|
|
baseFrame = frame;
|
|
|
|
if (!endOfLine)
|
|
|
|
break;
|
|
|
|
}
|
2006-03-13 01:13:25 +00:00
|
|
|
}
|
1999-09-07 23:40:17 +00:00
|
|
|
}
|
2006-03-13 01:13:25 +00:00
|
|
|
if (!baseFrame)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
FrameTarget targetFrame = DrillDownToSelectionFrame(baseFrame,
|
2012-05-29 13:13:36 +00:00
|
|
|
endOfLine, 0);
|
2006-03-13 01:13:25 +00:00
|
|
|
FrameContentRange range = GetRangeForFrame(targetFrame.frame);
|
|
|
|
aPos->mResultContent = range.content;
|
|
|
|
aPos->mContentOffset = endOfLine ? range.end : range.start;
|
2010-09-16 18:40:26 +00:00
|
|
|
if (endOfLine && targetFrame.frame->HasTerminalNewline()) {
|
|
|
|
// Do not position the caret after the terminating newline if we're
|
|
|
|
// trying to move to the end of line (see bug 596506)
|
|
|
|
--aPos->mContentOffset;
|
|
|
|
}
|
2006-08-03 06:24:11 +00:00
|
|
|
aPos->mResultFrame = targetFrame.frame;
|
2006-07-13 06:06:29 +00:00
|
|
|
aPos->mAttachForward = (aPos->mContentOffset == range.start);
|
2006-03-13 01:13:25 +00:00
|
|
|
if (!range.content)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
return NS_OK;
|
2000-05-16 22:48:28 +00:00
|
|
|
}
|
1999-10-22 00:19:18 +00:00
|
|
|
|
1999-06-19 20:36:44 +00:00
|
|
|
default:
|
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
NS_ASSERTION(false, "Invalid amount");
|
2006-09-11 20:43:01 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
1999-10-22 00:19:18 +00:00
|
|
|
}
|
2006-09-11 20:43:01 +00:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2012-08-22 15:56:38 +00:00
|
|
|
nsFrame::PeekOffsetNoAmount(bool aForward, int32_t* aOffset)
|
2006-09-11 20:43:01 +00:00
|
|
|
{
|
|
|
|
NS_ASSERTION (aOffset && *aOffset <= 1, "aOffset out of range");
|
|
|
|
// Sure, we can stop right here.
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2006-09-11 06:39:56 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2012-08-22 15:56:38 +00:00
|
|
|
nsFrame::PeekOffsetCharacter(bool aForward, int32_t* aOffset,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aRespectClusters)
|
2006-09-11 20:43:01 +00:00
|
|
|
{
|
|
|
|
NS_ASSERTION (aOffset && *aOffset <= 1, "aOffset out of range");
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t startOffset = *aOffset;
|
2006-09-11 20:43:01 +00:00
|
|
|
// A negative offset means "end of frame", which in our case means offset 1.
|
|
|
|
if (startOffset < 0)
|
|
|
|
startOffset = 1;
|
|
|
|
if (aForward == (startOffset == 0)) {
|
|
|
|
// We're before the frame and moving forward, or after it and moving backwards:
|
|
|
|
// skip to the other side and we're done.
|
|
|
|
*aOffset = 1 - startOffset;
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2006-09-11 20:43:01 +00:00
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2006-09-11 20:43:01 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
|
|
|
nsFrame::PeekOffsetWord(bool aForward, bool aWordSelectEatSpace, bool aIsKeyboardSelect,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t* aOffset, PeekWordState* aState)
|
2006-09-11 20:43:01 +00:00
|
|
|
{
|
|
|
|
NS_ASSERTION (aOffset && *aOffset <= 1, "aOffset out of range");
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t startOffset = *aOffset;
|
2007-11-08 04:33:28 +00:00
|
|
|
// This isn't text, so truncate the context
|
|
|
|
aState->mContext.Truncate();
|
2006-09-11 20:43:01 +00:00
|
|
|
if (startOffset < 0)
|
|
|
|
startOffset = 1;
|
|
|
|
if (aForward == (startOffset == 0)) {
|
|
|
|
// We're before the frame and moving forward, or after it and moving backwards.
|
|
|
|
// If we're looking for non-whitespace, we found it (without skipping this frame).
|
2007-08-30 03:10:19 +00:00
|
|
|
if (!aState->mAtStart) {
|
|
|
|
if (aState->mLastCharWasPunctuation) {
|
|
|
|
// We're not punctuation, so this is a punctuation boundary.
|
2011-10-17 14:59:28 +00:00
|
|
|
if (BreakWordBetweenPunctuation(aState, aForward, false, false, aIsKeyboardSelect))
|
|
|
|
return true;
|
2007-08-30 03:10:19 +00:00
|
|
|
} else {
|
|
|
|
// This is not a punctuation boundary.
|
|
|
|
if (aWordSelectEatSpace && aState->mSawBeforeType)
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2007-08-30 03:10:19 +00:00
|
|
|
}
|
|
|
|
}
|
2006-09-11 20:43:01 +00:00
|
|
|
// Otherwise skip to the other side and note that we encountered non-whitespace.
|
|
|
|
*aOffset = 1 - startOffset;
|
2011-10-17 14:59:28 +00:00
|
|
|
aState->Update(false, // not punctuation
|
|
|
|
false // not whitespace
|
2008-03-03 08:37:34 +00:00
|
|
|
);
|
2006-09-11 20:43:01 +00:00
|
|
|
if (!aWordSelectEatSpace)
|
2007-08-30 03:10:19 +00:00
|
|
|
aState->SetSawBeforeType();
|
2006-09-11 20:43:01 +00:00
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2006-09-11 20:43:01 +00:00
|
|
|
}
|
2000-07-26 11:31:12 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2008-03-03 08:37:34 +00:00
|
|
|
nsFrame::BreakWordBetweenPunctuation(const PeekWordState* aState,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aForward,
|
|
|
|
bool aPunctAfter, bool aWhitespaceAfter,
|
|
|
|
bool aIsKeyboardSelect)
|
2008-03-03 08:37:34 +00:00
|
|
|
{
|
|
|
|
NS_ASSERTION(aPunctAfter != aState->mLastCharWasPunctuation,
|
|
|
|
"Call this only at punctuation boundaries");
|
|
|
|
if (aState->mLastCharWasWhitespace) {
|
|
|
|
// We always stop between whitespace and punctuation
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2008-03-03 08:37:34 +00:00
|
|
|
}
|
2011-05-25 06:31:59 +00:00
|
|
|
if (!Preferences::GetBool("layout.word_select.stop_at_punctuation")) {
|
2008-03-03 08:37:34 +00:00
|
|
|
// When this pref is false, we never stop at a punctuation boundary unless
|
|
|
|
// it's after whitespace
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2007-08-30 03:10:19 +00:00
|
|
|
}
|
|
|
|
if (!aIsKeyboardSelect) {
|
|
|
|
// mouse caret movement (e.g. word selection) always stops at every punctuation boundary
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2007-08-30 03:10:19 +00:00
|
|
|
}
|
2011-09-29 06:19:26 +00:00
|
|
|
bool afterPunct = aForward ? aState->mLastCharWasPunctuation : aPunctAfter;
|
2008-03-03 08:37:34 +00:00
|
|
|
if (!afterPunct) {
|
|
|
|
// keyboard caret movement only stops after punctuation (in content order)
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2008-03-03 08:37:34 +00:00
|
|
|
}
|
|
|
|
// Stop only if we've seen some non-punctuation since the last whitespace;
|
|
|
|
// don't stop after punctuation that follows whitespace.
|
|
|
|
return aState->mSeenNonPunctuationSinceWhitespace;
|
2007-08-30 03:10:19 +00:00
|
|
|
}
|
|
|
|
|
2000-07-26 11:31:12 +00:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsFrame::CheckVisibility(nsPresContext* , int32_t , int32_t , bool , bool *, bool *)
|
2000-07-26 11:31:12 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t
|
2011-09-29 06:19:26 +00:00
|
|
|
nsFrame::GetLineNumber(nsIFrame *aFrame, bool aLockScroll, nsIFrame** aContainingBlock)
|
1999-10-22 00:19:18 +00:00
|
|
|
{
|
2006-03-20 09:20:49 +00:00
|
|
|
NS_ASSERTION(aFrame, "null aFrame");
|
2007-03-30 21:11:41 +00:00
|
|
|
nsFrameManager* frameManager = aFrame->PresContext()->FrameManager();
|
1999-10-22 00:19:18 +00:00
|
|
|
nsIFrame *blockFrame = aFrame;
|
|
|
|
nsIFrame *thisBlock;
|
2008-10-30 19:17:59 +00:00
|
|
|
nsAutoLineIterator it;
|
1999-10-22 00:19:18 +00:00
|
|
|
nsresult result = NS_ERROR_FAILURE;
|
|
|
|
while (NS_FAILED(result) && blockFrame)
|
|
|
|
{
|
|
|
|
thisBlock = blockFrame;
|
2006-03-20 09:20:49 +00:00
|
|
|
if (thisBlock->GetStateBits() & NS_FRAME_OUT_OF_FLOW) {
|
|
|
|
//if we are searching for a frame that is not in flow we will not find it.
|
|
|
|
//we must instead look for its placeholder
|
2007-10-02 05:57:45 +00:00
|
|
|
if (thisBlock->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER) {
|
|
|
|
// abspos continuations don't have placeholders, get the fif
|
|
|
|
thisBlock = thisBlock->GetFirstInFlow();
|
|
|
|
}
|
2006-03-20 09:20:49 +00:00
|
|
|
thisBlock = frameManager->GetPlaceholderFrameFor(thisBlock);
|
|
|
|
if (!thisBlock)
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
blockFrame = thisBlock->GetParent();
|
2003-06-28 11:48:14 +00:00
|
|
|
result = NS_OK;
|
|
|
|
if (blockFrame) {
|
2008-10-09 10:22:30 +00:00
|
|
|
if (aLockScroll && blockFrame->GetType() == nsGkAtoms::scrollFrame)
|
|
|
|
return -1;
|
2008-10-30 19:17:59 +00:00
|
|
|
it = blockFrame->GetLineIterator();
|
|
|
|
if (!it)
|
|
|
|
result = NS_ERROR_FAILURE;
|
1999-10-22 00:19:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!blockFrame || !it)
|
2006-03-20 09:20:49 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (aContainingBlock)
|
|
|
|
*aContainingBlock = blockFrame;
|
2008-10-30 19:17:59 +00:00
|
|
|
return it->FindLineContaining(thisBlock);
|
1999-10-22 00:19:18 +00:00
|
|
|
}
|
1999-09-22 04:12:23 +00:00
|
|
|
|
2006-08-07 11:24:57 +00:00
|
|
|
nsresult
|
2011-09-29 06:19:26 +00:00
|
|
|
nsIFrame::GetFrameFromDirection(nsDirection aDirection, bool aVisual,
|
|
|
|
bool aJumpLines, bool aScrollViewStop,
|
2012-08-22 15:56:38 +00:00
|
|
|
nsIFrame** aOutFrame, int32_t* aOutOffset, bool* aOutJumpedLine)
|
2008-10-30 19:17:59 +00:00
|
|
|
{
|
|
|
|
nsresult result;
|
|
|
|
|
2006-09-11 20:43:01 +00:00
|
|
|
if (!aOutFrame || !aOutOffset || !aOutJumpedLine)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
2007-03-30 21:11:41 +00:00
|
|
|
nsPresContext* presContext = PresContext();
|
2012-07-30 14:20:58 +00:00
|
|
|
*aOutFrame = nullptr;
|
2006-09-11 20:43:01 +00:00
|
|
|
*aOutOffset = 0;
|
2011-10-17 14:59:28 +00:00
|
|
|
*aOutJumpedLine = false;
|
2006-09-11 20:43:01 +00:00
|
|
|
|
2006-03-23 08:30:30 +00:00
|
|
|
// Find the prev/next selectable frame
|
2011-09-29 06:19:26 +00:00
|
|
|
bool selectable = false;
|
2006-03-23 08:30:30 +00:00
|
|
|
nsIFrame *traversedFrame = this;
|
|
|
|
while (!selectable) {
|
|
|
|
nsIFrame *blockFrame;
|
2001-03-09 03:29:00 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t thisLine = nsFrame::GetLineNumber(traversedFrame, aScrollViewStop, &blockFrame);
|
2006-03-20 09:20:49 +00:00
|
|
|
if (thisLine < 0)
|
2001-03-09 03:29:00 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2008-10-30 19:17:59 +00:00
|
|
|
|
|
|
|
nsAutoLineIterator it = blockFrame->GetLineIterator();
|
|
|
|
NS_ASSERTION(it, "GetLineNumber() succeeded but no block frame?");
|
2006-03-20 09:20:49 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool atLineEdge;
|
2006-03-23 08:30:30 +00:00
|
|
|
nsIFrame *firstFrame;
|
|
|
|
nsIFrame *lastFrame;
|
|
|
|
#ifdef IBMBIDI
|
2006-09-11 20:43:01 +00:00
|
|
|
if (aVisual && presContext->BidiEnabled()) {
|
2011-09-29 06:19:26 +00:00
|
|
|
bool lineIsRTL = it->GetDirection();
|
|
|
|
bool isReordered;
|
2006-07-12 11:22:18 +00:00
|
|
|
result = it->CheckLineOrder(thisLine, &isReordered, &firstFrame, &lastFrame);
|
2006-09-11 20:43:01 +00:00
|
|
|
nsIFrame** framePtr = aDirection == eDirPrevious ? &firstFrame : &lastFrame;
|
2006-08-04 05:40:57 +00:00
|
|
|
if (*framePtr) {
|
|
|
|
nsBidiLevel embeddingLevel = nsBidiPresUtils::GetFrameEmbeddingLevel(*framePtr);
|
2008-09-15 15:40:25 +00:00
|
|
|
if ((((embeddingLevel & 1) && lineIsRTL) || (!(embeddingLevel & 1) && !lineIsRTL)) ==
|
2006-09-11 20:43:01 +00:00
|
|
|
(aDirection == eDirPrevious)) {
|
|
|
|
nsFrame::GetFirstLeaf(presContext, framePtr);
|
2006-08-04 05:40:57 +00:00
|
|
|
} else {
|
2006-09-11 20:43:01 +00:00
|
|
|
nsFrame::GetLastLeaf(presContext, framePtr);
|
2006-08-04 05:40:57 +00:00
|
|
|
}
|
|
|
|
atLineEdge = *framePtr == traversedFrame;
|
2006-07-12 11:22:18 +00:00
|
|
|
} else {
|
2011-10-17 14:59:28 +00:00
|
|
|
atLineEdge = true;
|
2006-07-12 11:22:18 +00:00
|
|
|
}
|
|
|
|
} else
|
2006-03-23 08:30:30 +00:00
|
|
|
#endif
|
2001-03-09 03:29:00 +00:00
|
|
|
{
|
2006-07-12 11:22:18 +00:00
|
|
|
nsRect nonUsedRect;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t lineFrameCount;
|
|
|
|
uint32_t lineFlags;
|
2006-03-23 08:30:30 +00:00
|
|
|
result = it->GetLine(thisLine, &firstFrame, &lineFrameCount,nonUsedRect,
|
2001-03-09 03:29:00 +00:00
|
|
|
&lineFlags);
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
return result;
|
|
|
|
|
2006-09-11 20:43:01 +00:00
|
|
|
if (aDirection == eDirPrevious) {
|
|
|
|
nsFrame::GetFirstLeaf(presContext, &firstFrame);
|
2006-07-12 11:22:18 +00:00
|
|
|
atLineEdge = firstFrame == traversedFrame;
|
|
|
|
} else { // eDirNext
|
|
|
|
lastFrame = firstFrame;
|
|
|
|
for (;lineFrameCount > 1;lineFrameCount --){
|
|
|
|
result = it->GetNextSiblingOnLine(lastFrame, thisLine);
|
|
|
|
if (NS_FAILED(result) || !lastFrame){
|
2010-06-17 20:28:38 +00:00
|
|
|
NS_ERROR("should not be reached nsFrame");
|
2006-07-12 11:22:18 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2001-03-09 03:29:00 +00:00
|
|
|
}
|
2006-09-11 20:43:01 +00:00
|
|
|
nsFrame::GetLastLeaf(presContext, &lastFrame);
|
2006-07-12 11:22:18 +00:00
|
|
|
atLineEdge = lastFrame == traversedFrame;
|
2001-03-09 03:29:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-11 20:43:01 +00:00
|
|
|
if (atLineEdge) {
|
2011-10-17 14:59:28 +00:00
|
|
|
*aOutJumpedLine = true;
|
2006-09-11 20:43:01 +00:00
|
|
|
if (!aJumpLines)
|
|
|
|
return NS_ERROR_FAILURE; //we are done. cannot jump lines
|
2001-03-09 03:29:00 +00:00
|
|
|
}
|
2006-09-11 20:43:01 +00:00
|
|
|
|
2012-10-15 18:35:50 +00:00
|
|
|
nsCOMPtr<nsIFrameEnumerator> frameTraversal;
|
|
|
|
result = NS_NewFrameTraversal(getter_AddRefs(frameTraversal),
|
|
|
|
presContext, traversedFrame,
|
|
|
|
eLeaf,
|
|
|
|
aVisual && presContext->BidiEnabled(),
|
|
|
|
aScrollViewStop,
|
|
|
|
true // aFollowOOFs
|
|
|
|
);
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
return result;
|
2006-03-23 08:30:30 +00:00
|
|
|
|
2006-09-11 20:43:01 +00:00
|
|
|
if (aDirection == eDirNext)
|
2012-10-15 18:35:50 +00:00
|
|
|
frameTraversal->Next();
|
2006-09-11 20:43:01 +00:00
|
|
|
else
|
2012-10-15 18:35:50 +00:00
|
|
|
frameTraversal->Prev();
|
2006-09-11 20:43:01 +00:00
|
|
|
|
2012-10-15 18:35:50 +00:00
|
|
|
traversedFrame = frameTraversal->CurrentItem();
|
2008-10-30 17:15:22 +00:00
|
|
|
if (!traversedFrame)
|
|
|
|
return NS_ERROR_FAILURE;
|
2012-07-30 14:20:58 +00:00
|
|
|
traversedFrame->IsSelectable(&selectable, nullptr);
|
2006-03-23 08:30:30 +00:00
|
|
|
} // while (!selectable)
|
2006-09-11 20:43:01 +00:00
|
|
|
|
|
|
|
*aOutOffset = (aDirection == eDirNext) ? 0 : -1;
|
|
|
|
|
2001-03-09 03:29:00 +00:00
|
|
|
#ifdef IBMBIDI
|
2006-09-11 20:43:01 +00:00
|
|
|
if (aVisual) {
|
2012-08-22 15:56:38 +00:00
|
|
|
uint8_t newLevel = NS_GET_EMBEDDING_LEVEL(traversedFrame);
|
|
|
|
uint8_t newBaseLevel = NS_GET_BASE_LEVEL(traversedFrame);
|
2006-04-08 14:45:48 +00:00
|
|
|
if ((newLevel & 1) != (newBaseLevel & 1)) // The new frame is reverse-direction, go to the other end
|
2006-09-11 20:43:01 +00:00
|
|
|
*aOutOffset = -1 - *aOutOffset;
|
2006-04-08 14:45:48 +00:00
|
|
|
}
|
2001-03-09 03:29:00 +00:00
|
|
|
#endif
|
2006-09-11 20:43:01 +00:00
|
|
|
*aOutFrame = traversedFrame;
|
1999-10-22 00:19:18 +00:00
|
|
|
return NS_OK;
|
1999-02-02 00:23:40 +00:00
|
|
|
}
|
|
|
|
|
2004-11-03 16:16:57 +00:00
|
|
|
nsIView* nsIFrame::GetClosestView(nsPoint* aOffset) const
|
1999-09-29 20:04:05 +00:00
|
|
|
{
|
2004-11-03 16:16:57 +00:00
|
|
|
nsPoint offset(0,0);
|
|
|
|
for (const nsIFrame *f = this; f; f = f->GetParent()) {
|
|
|
|
if (f->HasView()) {
|
|
|
|
if (aOffset)
|
|
|
|
*aOffset = offset;
|
Bug 190735. DeCOMtaminating nsIFrame and removing aPresContext parameters, in particular, the methods GetParent, GetContent, GetRect, GetOrigin, GetSize, SetRect, MoveTo, SizeTo, GetNextSibling, GetFrameState, SetFrameState, GetView, GetViewExternal, SetView, GetClosestView, GetParentWithView, AreAncestorViewsVisible, and GetWindow. For now we have compatibility wrappers, but soon we'll go through and change all the clients to use the new functions. r+sr=dbaron
2003-06-21 17:06:05 +00:00
|
|
|
return f->GetView();
|
2004-11-03 16:16:57 +00:00
|
|
|
}
|
|
|
|
offset += f->GetPosition();
|
|
|
|
}
|
1999-09-29 20:04:05 +00:00
|
|
|
|
2004-11-03 16:16:57 +00:00
|
|
|
NS_NOTREACHED("No view on any parent? How did that happen?");
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
1999-09-29 20:04:05 +00:00
|
|
|
}
|
|
|
|
|
2000-01-12 08:28:24 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
/* virtual */ void
|
|
|
|
nsFrame::ChildIsDirty(nsIFrame* aChild)
|
2000-01-12 08:28:24 +00:00
|
|
|
{
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
NS_NOTREACHED("should never be called on a frame that doesn't inherit from "
|
|
|
|
"nsContainerFrame");
|
2000-01-12 08:28:24 +00:00
|
|
|
}
|
|
|
|
|
2000-09-12 22:47:09 +00:00
|
|
|
|
2001-08-17 03:13:07 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2012-09-28 21:53:44 +00:00
|
|
|
a11y::AccType
|
|
|
|
nsFrame::AccessibleType()
|
2001-05-17 23:52:32 +00:00
|
|
|
{
|
2012-09-28 21:53:44 +00:00
|
|
|
return a11y::eNoAccessible;
|
2001-05-17 23:52:32 +00:00
|
|
|
}
|
2001-08-17 03:13:07 +00:00
|
|
|
#endif
|
2001-05-17 23:52:32 +00:00
|
|
|
|
2010-10-07 04:25:45 +00:00
|
|
|
NS_DECLARE_FRAME_PROPERTY(OverflowAreasProperty,
|
|
|
|
nsIFrame::DestroyOverflowAreas)
|
2010-03-29 01:46:55 +00:00
|
|
|
|
2011-12-05 12:38:46 +00:00
|
|
|
bool
|
2010-10-07 04:25:45 +00:00
|
|
|
nsIFrame::ClearOverflowRects()
|
2010-03-29 01:46:55 +00:00
|
|
|
{
|
2011-12-05 12:38:46 +00:00
|
|
|
if (mOverflow.mType == NS_FRAME_OVERFLOW_NONE) {
|
|
|
|
return false;
|
|
|
|
}
|
2010-10-07 04:25:45 +00:00
|
|
|
if (mOverflow.mType == NS_FRAME_OVERFLOW_LARGE) {
|
|
|
|
Properties().Delete(OverflowAreasProperty());
|
|
|
|
}
|
2010-03-29 01:46:55 +00:00
|
|
|
mOverflow.mType = NS_FRAME_OVERFLOW_NONE;
|
2011-12-05 12:38:46 +00:00
|
|
|
return true;
|
2010-03-29 01:46:55 +00:00
|
|
|
}
|
|
|
|
|
2008-02-20 07:08:55 +00:00
|
|
|
/** Create or retrieve the previously stored overflow area, if the frame does
|
2012-07-30 14:20:58 +00:00
|
|
|
* not overflow and no creation is required return nullptr.
|
2008-02-20 07:08:55 +00:00
|
|
|
* @return pointer to the overflow area rectangle
|
|
|
|
*/
|
2010-10-07 04:25:45 +00:00
|
|
|
nsOverflowAreas*
|
|
|
|
nsIFrame::GetOverflowAreasProperty()
|
2003-05-31 10:32:19 +00:00
|
|
|
{
|
2010-03-29 01:46:55 +00:00
|
|
|
FrameProperties props = Properties();
|
2010-10-07 04:25:45 +00:00
|
|
|
nsOverflowAreas *overflow =
|
|
|
|
static_cast<nsOverflowAreas*>(props.Get(OverflowAreasProperty()));
|
2004-02-23 21:29:06 +00:00
|
|
|
|
2010-10-07 04:25:45 +00:00
|
|
|
if (overflow) {
|
|
|
|
return overflow; // the property already exists
|
2003-05-31 10:32:19 +00:00
|
|
|
}
|
|
|
|
|
2010-10-07 04:25:45 +00:00
|
|
|
// The property isn't set yet, so allocate a new rect, set the property,
|
|
|
|
// and return the newly allocated rect
|
|
|
|
overflow = new nsOverflowAreas;
|
|
|
|
props.Set(OverflowAreasProperty(), overflow);
|
|
|
|
return overflow;
|
2003-05-31 10:32:19 +00:00
|
|
|
}
|
|
|
|
|
2009-04-06 00:31:50 +00:00
|
|
|
/** Set the overflowArea rect, storing it as deltas or a separate rect
|
|
|
|
* depending on its size in relation to the primary frame rect.
|
|
|
|
*/
|
2011-12-05 12:38:46 +00:00
|
|
|
bool
|
2010-10-07 04:25:45 +00:00
|
|
|
nsIFrame::SetOverflowAreas(const nsOverflowAreas& aOverflowAreas)
|
2009-04-06 00:31:50 +00:00
|
|
|
{
|
2010-10-07 04:25:45 +00:00
|
|
|
if (mOverflow.mType == NS_FRAME_OVERFLOW_LARGE) {
|
|
|
|
nsOverflowAreas *overflow =
|
|
|
|
static_cast<nsOverflowAreas*>(Properties().Get(OverflowAreasProperty()));
|
2011-12-05 12:38:46 +00:00
|
|
|
bool changed = *overflow != aOverflowAreas;
|
2010-10-07 04:25:45 +00:00
|
|
|
*overflow = aOverflowAreas;
|
|
|
|
|
|
|
|
// Don't bother with converting to the deltas form if we already
|
|
|
|
// have a property.
|
2011-12-05 12:38:46 +00:00
|
|
|
return changed;
|
2010-10-07 04:25:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const nsRect& vis = aOverflowAreas.VisualOverflow();
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t l = -vis.x, // left edge: positive delta is leftwards
|
2010-10-07 04:25:45 +00:00
|
|
|
t = -vis.y, // top: positive is upwards
|
|
|
|
r = vis.XMost() - mRect.width, // right: positive is rightwards
|
|
|
|
b = vis.YMost() - mRect.height; // bottom: positive is downwards
|
2011-04-19 03:07:23 +00:00
|
|
|
if (aOverflowAreas.ScrollableOverflow().IsEqualEdges(nsRect(nsPoint(0, 0), GetSize())) &&
|
2010-10-07 04:25:45 +00:00
|
|
|
l <= NS_FRAME_OVERFLOW_DELTA_MAX &&
|
2009-04-06 00:31:50 +00:00
|
|
|
t <= NS_FRAME_OVERFLOW_DELTA_MAX &&
|
|
|
|
r <= NS_FRAME_OVERFLOW_DELTA_MAX &&
|
|
|
|
b <= NS_FRAME_OVERFLOW_DELTA_MAX &&
|
2010-10-07 04:25:45 +00:00
|
|
|
// we have to check these against zero because we *never* want to
|
|
|
|
// set a frame as having no overflow in this function. This is
|
|
|
|
// because FinishAndStoreOverflow calls this function prior to
|
|
|
|
// SetRect based on whether the overflow areas match aNewSize.
|
|
|
|
// In the case where the overflow areas exactly match mRect but
|
|
|
|
// do not match aNewSize, we need to store overflow in a property
|
|
|
|
// so that our eventual SetRect/SetSize will know that it has to
|
|
|
|
// reset our overflow areas.
|
2009-04-06 00:31:50 +00:00
|
|
|
(l | t | r | b) != 0) {
|
2011-12-05 12:38:46 +00:00
|
|
|
VisualDeltas oldDeltas = mOverflow.mVisualDeltas;
|
2009-04-06 00:31:50 +00:00
|
|
|
// It's a "small" overflow area so we store the deltas for each edge
|
|
|
|
// directly in the frame, rather than allocating a separate rect.
|
2010-10-07 04:25:45 +00:00
|
|
|
// If they're all zero, that's fine; we're setting things to
|
|
|
|
// no-overflow.
|
|
|
|
mOverflow.mVisualDeltas.mLeft = l;
|
|
|
|
mOverflow.mVisualDeltas.mTop = t;
|
|
|
|
mOverflow.mVisualDeltas.mRight = r;
|
|
|
|
mOverflow.mVisualDeltas.mBottom = b;
|
2011-12-05 12:38:46 +00:00
|
|
|
// There was no scrollable overflow before, and there isn't now.
|
|
|
|
return oldDeltas != mOverflow.mVisualDeltas;
|
2009-04-06 00:31:50 +00:00
|
|
|
} else {
|
2011-12-05 12:38:46 +00:00
|
|
|
bool changed = !aOverflowAreas.ScrollableOverflow().IsEqualEdges(nsRect(nsPoint(0, 0), GetSize())) ||
|
|
|
|
!aOverflowAreas.VisualOverflow().IsEqualEdges(GetVisualOverflowFromDeltas());
|
|
|
|
|
2009-04-06 00:31:50 +00:00
|
|
|
// it's a large overflow area that we need to store as a property
|
|
|
|
mOverflow.mType = NS_FRAME_OVERFLOW_LARGE;
|
2010-10-07 04:25:45 +00:00
|
|
|
nsOverflowAreas* overflow = GetOverflowAreasProperty();
|
|
|
|
NS_ASSERTION(overflow, "should have created areas");
|
|
|
|
*overflow = aOverflowAreas;
|
2011-12-05 12:38:46 +00:00
|
|
|
return changed;
|
2009-04-06 00:31:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
inline bool
|
2008-04-06 03:55:15 +00:00
|
|
|
IsInlineFrame(nsIFrame *aFrame)
|
|
|
|
{
|
|
|
|
nsIAtom *type = aFrame->GetType();
|
2011-04-29 23:02:33 +00:00
|
|
|
return type == nsGkAtoms::inlineFrame;
|
2008-04-06 03:55:15 +00:00
|
|
|
}
|
|
|
|
|
2011-12-05 12:38:46 +00:00
|
|
|
bool
|
2010-10-07 04:25:45 +00:00
|
|
|
nsIFrame::FinishAndStoreOverflow(nsOverflowAreas& aOverflowAreas,
|
|
|
|
nsSize aNewSize)
|
2004-07-16 16:56:21 +00:00
|
|
|
{
|
2012-10-26 10:56:48 +00:00
|
|
|
NS_ASSERTION(!((GetStateBits() & NS_FRAME_SVG_LAYOUT) &&
|
|
|
|
(GetStateBits() & NS_STATE_SVG_NONDISPLAY_CHILD)),
|
2012-10-26 11:03:07 +00:00
|
|
|
"Don't call - overflow rects not maintained on these SVG frames");
|
2012-10-26 10:56:48 +00:00
|
|
|
|
2010-10-07 04:25:45 +00:00
|
|
|
nsRect bounds(nsPoint(0, 0), aNewSize);
|
2011-10-14 20:43:38 +00:00
|
|
|
// Store the passed in overflow area if we are a preserve-3d frame,
|
|
|
|
// and it's not just the frame bounds.
|
2012-02-15 09:28:22 +00:00
|
|
|
if ((Preserves3D() || HasPerspective()) && (!aOverflowAreas.VisualOverflow().IsEqualEdges(bounds) ||
|
2011-10-14 20:43:38 +00:00
|
|
|
!aOverflowAreas.ScrollableOverflow().IsEqualEdges(bounds))) {
|
|
|
|
nsOverflowAreas* initial =
|
|
|
|
static_cast<nsOverflowAreas*>(Properties().Get(nsIFrame::InitialOverflowProperty()));
|
|
|
|
if (!initial) {
|
|
|
|
Properties().Set(nsIFrame::InitialOverflowProperty(),
|
|
|
|
new nsOverflowAreas(aOverflowAreas));
|
|
|
|
} else if (initial != &aOverflowAreas) {
|
|
|
|
*initial = aOverflowAreas;
|
|
|
|
}
|
|
|
|
}
|
2010-10-07 04:25:45 +00:00
|
|
|
|
2004-07-16 16:56:21 +00:00
|
|
|
// This is now called FinishAndStoreOverflow() instead of
|
|
|
|
// StoreOverflow() because frame-generic ways of adding overflow
|
2007-01-17 22:31:07 +00:00
|
|
|
// can happen here, e.g. CSS2 outline and native theme.
|
2012-01-02 22:55:35 +00:00
|
|
|
// If the overflow area width or height is nscoord_MAX, then a
|
|
|
|
// saturating union may have encounted an overflow, so the overflow may not
|
|
|
|
// contain the frame border-box. Don't warn in that case.
|
2012-05-17 04:05:09 +00:00
|
|
|
// Don't warn for SVG either, since SVG doesn't need the overflow area
|
|
|
|
// to contain the frame bounds.
|
2010-10-07 04:25:45 +00:00
|
|
|
NS_FOR_FRAME_OVERFLOW_TYPES(otype) {
|
2012-01-02 22:55:35 +00:00
|
|
|
DebugOnly<nsRect*> r = &aOverflowAreas.Overflow(otype);
|
2010-10-07 04:25:45 +00:00
|
|
|
NS_ASSERTION(aNewSize.width == 0 || aNewSize.height == 0 ||
|
2012-01-02 22:55:35 +00:00
|
|
|
r->width == nscoord_MAX || r->height == nscoord_MAX ||
|
2012-05-17 04:05:09 +00:00
|
|
|
(mState & NS_FRAME_SVG_LAYOUT) ||
|
2012-01-02 22:55:35 +00:00
|
|
|
r->Contains(nsRect(nsPoint(0,0), aNewSize)),
|
2010-10-07 04:25:45 +00:00
|
|
|
"Computed overflow area must contain frame bounds");
|
|
|
|
}
|
2004-07-16 16:56:21 +00:00
|
|
|
|
2010-06-28 00:28:21 +00:00
|
|
|
// If we clip our children, clear accumulated overflow area. The
|
|
|
|
// children are actually clipped to the padding-box, but since the
|
|
|
|
// overflow area should include the entire border-box, just set it to
|
|
|
|
// the border-box here.
|
2012-01-18 20:04:51 +00:00
|
|
|
const nsStyleDisplay* disp = GetStyleDisplay();
|
2010-06-28 00:28:21 +00:00
|
|
|
NS_ASSERTION((disp->mOverflowY == NS_STYLE_OVERFLOW_CLIP) ==
|
|
|
|
(disp->mOverflowX == NS_STYLE_OVERFLOW_CLIP),
|
|
|
|
"If one overflow is clip, the other should be too");
|
2012-01-18 20:04:51 +00:00
|
|
|
if (nsFrame::ApplyOverflowClipping(this, disp)) {
|
2010-06-28 00:28:21 +00:00
|
|
|
// The contents are actually clipped to the padding area
|
2010-10-07 04:25:45 +00:00
|
|
|
aOverflowAreas.SetAllTo(bounds);
|
2010-06-28 00:28:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Overflow area must always include the frame's top-left and bottom-right,
|
2012-05-17 04:05:09 +00:00
|
|
|
// even if the frame rect is empty (so we can scroll to those positions).
|
2010-06-28 00:28:21 +00:00
|
|
|
// Pending a real fix for bug 426879, don't do this for inline frames
|
|
|
|
// with zero width.
|
2012-05-17 04:05:09 +00:00
|
|
|
// Do not do this for SVG either, since it will usually massively increase
|
|
|
|
// the area unnecessarily.
|
|
|
|
if ((aNewSize.width != 0 || !IsInlineFrame(this)) &&
|
|
|
|
!(GetStateBits() & NS_FRAME_SVG_LAYOUT)) {
|
2010-10-07 04:25:45 +00:00
|
|
|
NS_FOR_FRAME_OVERFLOW_TYPES(otype) {
|
|
|
|
nsRect& o = aOverflowAreas.Overflow(otype);
|
2011-04-19 03:07:23 +00:00
|
|
|
o.UnionRectEdges(o, bounds);
|
2010-10-07 04:25:45 +00:00
|
|
|
}
|
2010-06-28 00:28:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Note that NS_STYLE_OVERFLOW_CLIP doesn't clip the frame background,
|
|
|
|
// so we add theme background overflow here so it's not clipped.
|
2007-09-15 15:14:27 +00:00
|
|
|
if (!IsBoxWrapped() && IsThemed(disp)) {
|
2010-10-07 04:25:45 +00:00
|
|
|
nsRect r(bounds);
|
2007-03-30 21:11:41 +00:00
|
|
|
nsPresContext *presContext = PresContext();
|
2007-01-17 22:31:07 +00:00
|
|
|
if (presContext->GetTheme()->
|
|
|
|
GetWidgetOverflow(presContext->DeviceContext(), this,
|
|
|
|
disp->mAppearance, &r)) {
|
2011-07-06 10:03:23 +00:00
|
|
|
nsRect& vo = aOverflowAreas.VisualOverflow();
|
|
|
|
vo.UnionRectEdges(vo, r);
|
2007-01-17 22:31:07 +00:00
|
|
|
}
|
|
|
|
}
|
2010-10-07 04:25:45 +00:00
|
|
|
|
|
|
|
// Nothing in here should affect scrollable overflow.
|
2011-09-29 06:19:26 +00:00
|
|
|
bool hasOutlineOrEffects;
|
2010-10-07 04:25:45 +00:00
|
|
|
aOverflowAreas.VisualOverflow() =
|
2010-09-02 18:07:37 +00:00
|
|
|
ComputeOutlineAndEffectsRect(this, &hasOutlineOrEffects,
|
2010-10-07 04:25:45 +00:00
|
|
|
aOverflowAreas.VisualOverflow(), aNewSize,
|
2011-10-17 14:59:28 +00:00
|
|
|
true);
|
2010-09-02 18:07:37 +00:00
|
|
|
|
|
|
|
// Absolute position clipping
|
2012-03-02 08:28:56 +00:00
|
|
|
bool didHaveClipPropClip = (GetStateBits() & NS_FRAME_HAS_CLIP) != 0;
|
|
|
|
nsRect clipPropClipRect;
|
|
|
|
bool hasClipPropClip = GetClipPropClipRect(disp, &clipPropClipRect, aNewSize);
|
|
|
|
if (hasClipPropClip) {
|
2010-10-07 04:25:45 +00:00
|
|
|
NS_FOR_FRAME_OVERFLOW_TYPES(otype) {
|
|
|
|
nsRect& o = aOverflowAreas.Overflow(otype);
|
2012-03-02 08:28:56 +00:00
|
|
|
o.IntersectRect(o, clipPropClipRect);
|
2010-10-07 04:25:45 +00:00
|
|
|
}
|
2010-09-02 18:07:37 +00:00
|
|
|
AddStateBits(NS_FRAME_HAS_CLIP);
|
|
|
|
} else {
|
|
|
|
RemoveStateBits(NS_FRAME_HAS_CLIP);
|
|
|
|
}
|
2007-03-27 03:58:17 +00:00
|
|
|
|
2012-02-06 05:14:00 +00:00
|
|
|
bool preTransformVisualOverflowChanged =
|
|
|
|
!GetVisualOverflowRectRelativeToSelf().IsEqualInterior(aOverflowAreas.VisualOverflow());
|
|
|
|
|
2008-09-16 01:51:52 +00:00
|
|
|
/* If we're transformed, transform the overflow rect by the current transformation. */
|
2011-09-29 06:19:26 +00:00
|
|
|
bool hasTransform = IsTransformed();
|
2010-03-29 01:46:58 +00:00
|
|
|
if (hasTransform) {
|
2011-06-15 21:03:49 +00:00
|
|
|
Properties().Set(nsIFrame::PreTransformOverflowAreasProperty(),
|
|
|
|
new nsOverflowAreas(aOverflowAreas));
|
2008-09-16 01:51:52 +00:00
|
|
|
/* Since our size might not actually have been computed yet, we need to make sure that we use the
|
|
|
|
* correct dimensions by overriding the stored bounding rectangle with the value the caller has
|
|
|
|
* ensured us we'll use.
|
|
|
|
*/
|
|
|
|
nsRect newBounds(nsPoint(0, 0), aNewSize);
|
2010-10-07 04:25:45 +00:00
|
|
|
// Transform affects both overflow areas.
|
2011-11-17 03:45:39 +00:00
|
|
|
NS_FOR_FRAME_OVERFLOW_TYPES(otype) {
|
|
|
|
nsRect& o = aOverflowAreas.Overflow(otype);
|
|
|
|
o = nsDisplayTransform::TransformRect(o, this, nsPoint(0, 0), &newBounds);
|
|
|
|
}
|
|
|
|
if (Preserves3DChildren()) {
|
2011-08-27 00:01:46 +00:00
|
|
|
ComputePreserve3DChildrenOverflow(aOverflowAreas, newBounds);
|
2012-03-12 02:04:25 +00:00
|
|
|
} else if (ChildrenHavePerspective()) {
|
|
|
|
RecomputePerspectiveChildrenOverflow(this->GetStyleContext(), &newBounds);
|
2010-10-07 04:25:45 +00:00
|
|
|
}
|
2011-06-15 21:03:49 +00:00
|
|
|
} else {
|
|
|
|
Properties().Delete(nsIFrame::PreTransformOverflowAreasProperty());
|
2012-03-12 02:04:25 +00:00
|
|
|
if (ChildrenHavePerspective()) {
|
|
|
|
nsRect newBounds(nsPoint(0, 0), aNewSize);
|
|
|
|
RecomputePerspectiveChildrenOverflow(this->GetStyleContext(), &newBounds);
|
|
|
|
}
|
2008-09-16 01:51:52 +00:00
|
|
|
}
|
2012-03-12 02:04:25 +00:00
|
|
|
|
2008-10-21 07:42:28 +00:00
|
|
|
|
2011-12-05 12:38:46 +00:00
|
|
|
bool anyOverflowChanged;
|
2010-10-07 04:25:45 +00:00
|
|
|
if (aOverflowAreas != nsOverflowAreas(bounds, bounds)) {
|
2011-12-05 12:38:46 +00:00
|
|
|
anyOverflowChanged = SetOverflowAreas(aOverflowAreas);
|
2010-10-07 04:25:45 +00:00
|
|
|
} else {
|
2011-12-05 12:38:46 +00:00
|
|
|
anyOverflowChanged = ClearOverflowRects();
|
2008-10-21 07:42:28 +00:00
|
|
|
}
|
|
|
|
|
2012-02-06 05:14:00 +00:00
|
|
|
if (preTransformVisualOverflowChanged) {
|
2010-09-02 18:07:37 +00:00
|
|
|
if (hasOutlineOrEffects) {
|
|
|
|
// When there's an outline or box-shadow or SVG effects,
|
|
|
|
// changes to those styles might require repainting of the old and new
|
|
|
|
// overflow areas. Repainting of the old overflow area is handled in
|
|
|
|
// nsCSSFrameConstructor::DoApplyRenderingChangeToTree in response
|
|
|
|
// to nsChangeHint_RepaintFrame. Since the new overflow area is not
|
|
|
|
// known at that time, we have to handle it here.
|
|
|
|
// If the overflow area hasn't changed, then we don't have to do
|
|
|
|
// anything here since repainting the old overflow area was enough.
|
|
|
|
// If there is no outline or other effects now, then we don't have
|
|
|
|
// to do anything here since removing those styles can't require
|
|
|
|
// repainting of areas that weren't in the old overflow area.
|
2012-08-29 05:39:31 +00:00
|
|
|
InvalidateFrame();
|
2012-03-02 08:28:56 +00:00
|
|
|
} else if (hasClipPropClip || didHaveClipPropClip) {
|
2010-09-02 18:07:37 +00:00
|
|
|
// If we are (or were) clipped by the 'clip' property, and our
|
|
|
|
// overflow area changes, it might be because the clipping changed.
|
|
|
|
// The nsChangeHint_RepaintFrame for the style change will only
|
|
|
|
// repaint the old overflow area, so if the overflow area has
|
|
|
|
// changed (in particular, if it grows), we have to repaint the
|
|
|
|
// new area here.
|
2012-08-29 05:39:31 +00:00
|
|
|
InvalidateFrame();
|
2010-09-02 18:07:37 +00:00
|
|
|
}
|
2008-09-16 01:51:52 +00:00
|
|
|
}
|
2012-09-27 15:34:46 +00:00
|
|
|
|
2012-08-29 05:49:16 +00:00
|
|
|
if (anyOverflowChanged) {
|
|
|
|
nsSVGEffects::InvalidateDirectRenderingObservers(this);
|
|
|
|
}
|
2011-12-05 12:38:46 +00:00
|
|
|
return anyOverflowChanged;
|
2003-05-31 10:32:19 +00:00
|
|
|
}
|
|
|
|
|
2012-02-15 09:28:22 +00:00
|
|
|
void
|
2012-03-12 02:04:25 +00:00
|
|
|
nsIFrame::RecomputePerspectiveChildrenOverflow(const nsStyleContext* aStartStyle, const nsRect* aBounds)
|
2012-02-15 09:28:22 +00:00
|
|
|
{
|
|
|
|
// Children may check our size when getting our transform, make sure it's valid.
|
|
|
|
nsSize oldSize = GetSize();
|
|
|
|
if (aBounds) {
|
|
|
|
SetSize(aBounds->Size());
|
|
|
|
}
|
|
|
|
nsIFrame::ChildListIterator lists(this);
|
|
|
|
for (; !lists.IsDone(); lists.Next()) {
|
|
|
|
nsFrameList::Enumerator childFrames(lists.CurrentList());
|
|
|
|
for (; !childFrames.AtEnd(); childFrames.Next()) {
|
|
|
|
nsIFrame* child = childFrames.get();
|
2012-10-26 10:56:48 +00:00
|
|
|
if ((child->GetStateBits() & NS_FRAME_SVG_LAYOUT) &&
|
|
|
|
(child->GetStateBits() & NS_STATE_SVG_NONDISPLAY_CHILD)) {
|
|
|
|
continue; // frame does not maintain overflow rects
|
|
|
|
}
|
2012-02-15 09:28:22 +00:00
|
|
|
if (child->HasPerspective()) {
|
|
|
|
nsOverflowAreas* overflow =
|
|
|
|
static_cast<nsOverflowAreas*>(child->Properties().Get(nsIFrame::InitialOverflowProperty()));
|
|
|
|
nsRect bounds(nsPoint(0, 0), child->GetSize());
|
|
|
|
if (overflow) {
|
|
|
|
child->FinishAndStoreOverflow(*overflow, bounds.Size());
|
|
|
|
} else {
|
|
|
|
nsOverflowAreas boundsOverflow;
|
|
|
|
boundsOverflow.SetAllTo(bounds);
|
|
|
|
child->FinishAndStoreOverflow(boundsOverflow, bounds.Size());
|
|
|
|
}
|
2012-03-12 02:04:25 +00:00
|
|
|
} else if (child->GetStyleContext()->GetParent() == aStartStyle ||
|
|
|
|
child->GetStyleContext() == aStartStyle) {
|
2012-10-26 10:56:48 +00:00
|
|
|
// If a frame is using perspective, then the size used to compute
|
|
|
|
// perspective-origin is the size of the frame belonging to its parent
|
|
|
|
// style context. We must find any descendant frames using our size
|
|
|
|
// (by recurse into frames with the same style context, or a direct
|
|
|
|
// child style context) to update their overflow rects too.
|
2012-07-30 14:20:58 +00:00
|
|
|
child->RecomputePerspectiveChildrenOverflow(aStartStyle, nullptr);
|
2012-02-15 09:28:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Restore our old size just in case something depends on this elesewhere.
|
|
|
|
SetSize(oldSize);
|
|
|
|
}
|
|
|
|
|
2011-10-14 20:43:38 +00:00
|
|
|
/* The overflow rects for leaf nodes in a preserve-3d hierarchy depends on
|
|
|
|
* the mRect value for their parents (since we use their transform, and transform
|
|
|
|
* depends on this for transform-origin etc). These weren't necessarily correct
|
|
|
|
* when we reflowed initially, so walk over all preserve-3d children and repeat the
|
|
|
|
* overflow calculation.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
RecomputePreserve3DChildrenOverflow(nsIFrame* aFrame, const nsRect* aBounds)
|
|
|
|
{
|
|
|
|
// Children may check our size when getting our transform, make sure it's valid.
|
|
|
|
nsSize oldSize = aFrame->GetSize();
|
|
|
|
if (aBounds) {
|
|
|
|
aFrame->SetSize(aBounds->Size());
|
|
|
|
}
|
|
|
|
nsIFrame::ChildListIterator lists(aFrame);
|
|
|
|
for (; !lists.IsDone(); lists.Next()) {
|
|
|
|
nsFrameList::Enumerator childFrames(lists.CurrentList());
|
|
|
|
for (; !childFrames.AtEnd(); childFrames.Next()) {
|
|
|
|
nsIFrame* child = childFrames.get();
|
2012-10-26 10:56:48 +00:00
|
|
|
if ((child->GetStateBits() & NS_FRAME_SVG_LAYOUT) &&
|
|
|
|
(child->GetStateBits() & NS_STATE_SVG_NONDISPLAY_CHILD)) {
|
|
|
|
continue; // frame does not maintain overflow rects
|
|
|
|
}
|
2011-10-14 20:43:38 +00:00
|
|
|
if (child->Preserves3DChildren()) {
|
|
|
|
RecomputePreserve3DChildrenOverflow(child, NULL);
|
|
|
|
} else if (child->Preserves3D()) {
|
|
|
|
nsOverflowAreas* overflow =
|
|
|
|
static_cast<nsOverflowAreas*>(child->Properties().Get(nsIFrame::InitialOverflowProperty()));
|
|
|
|
nsRect bounds(nsPoint(0, 0), child->GetSize());
|
|
|
|
if (overflow) {
|
|
|
|
child->FinishAndStoreOverflow(*overflow, bounds.Size());
|
|
|
|
} else {
|
|
|
|
nsOverflowAreas boundsOverflow;
|
|
|
|
boundsOverflow.SetAllTo(bounds);
|
|
|
|
child->FinishAndStoreOverflow(boundsOverflow, bounds.Size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Restore our old size just in case something depends on this elesewhere.
|
|
|
|
aFrame->SetSize(oldSize);
|
|
|
|
|
|
|
|
// Only repeat computing our overflow in recursive calls since the initial caller is still
|
|
|
|
// in the middle of doing this and we don't want an infinite loop.
|
|
|
|
if (!aBounds) {
|
|
|
|
nsOverflowAreas* overflow =
|
|
|
|
static_cast<nsOverflowAreas*>(aFrame->Properties().Get(nsIFrame::InitialOverflowProperty()));
|
|
|
|
nsRect bounds(nsPoint(0, 0), aFrame->GetSize());
|
|
|
|
if (overflow) {
|
|
|
|
overflow->UnionAllWith(bounds);
|
|
|
|
aFrame->FinishAndStoreOverflow(*overflow, bounds.Size());
|
|
|
|
} else {
|
|
|
|
nsOverflowAreas boundsOverflow;
|
|
|
|
boundsOverflow.SetAllTo(bounds);
|
|
|
|
aFrame->FinishAndStoreOverflow(boundsOverflow, bounds.Size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-27 00:01:46 +00:00
|
|
|
void
|
|
|
|
nsIFrame::ComputePreserve3DChildrenOverflow(nsOverflowAreas& aOverflowAreas, const nsRect& aBounds)
|
|
|
|
{
|
|
|
|
// When we are preserving 3d we need to iterate over all children separately.
|
|
|
|
// If the child also preserves 3d then their overflow will already been in our
|
|
|
|
// coordinate space, otherwise we need to transform.
|
2011-10-14 20:43:38 +00:00
|
|
|
|
|
|
|
// If we're the top frame in a preserve 3d chain then we need to recalculate the overflow
|
|
|
|
// areas of all our children since they will have used our size/offset which was invalid at
|
|
|
|
// the time.
|
|
|
|
if (!Preserves3D()) {
|
|
|
|
RecomputePreserve3DChildrenOverflow(this, &aBounds);
|
|
|
|
}
|
|
|
|
|
2011-08-27 00:01:46 +00:00
|
|
|
nsRect childVisual;
|
|
|
|
nsRect childScrollable;
|
|
|
|
nsIFrame::ChildListIterator lists(this);
|
|
|
|
for (; !lists.IsDone(); lists.Next()) {
|
|
|
|
nsFrameList::Enumerator childFrames(lists.CurrentList());
|
|
|
|
for (; !childFrames.AtEnd(); childFrames.Next()) {
|
|
|
|
nsIFrame* child = childFrames.get();
|
2011-10-14 20:43:38 +00:00
|
|
|
nsPoint offset = child->GetPosition();
|
|
|
|
nsRect visual = child->GetVisualOverflowRect();
|
|
|
|
nsRect scrollable = child->GetScrollableOverflowRect();
|
|
|
|
visual.MoveBy(offset);
|
|
|
|
scrollable.MoveBy(offset);
|
2011-08-27 00:01:46 +00:00
|
|
|
if (child->Preserves3D()) {
|
2011-10-14 20:43:38 +00:00
|
|
|
childVisual = childVisual.Union(visual);
|
|
|
|
childScrollable = childScrollable.Union(scrollable);
|
2011-08-27 00:01:46 +00:00
|
|
|
} else {
|
|
|
|
childVisual =
|
2011-10-14 20:43:38 +00:00
|
|
|
childVisual.Union(nsDisplayTransform::TransformRect(visual,
|
2011-08-27 00:01:46 +00:00
|
|
|
this, nsPoint(0,0), &aBounds));
|
|
|
|
childScrollable =
|
2011-10-14 20:43:38 +00:00
|
|
|
childScrollable.Union(nsDisplayTransform::TransformRect(scrollable,
|
2011-08-27 00:01:46 +00:00
|
|
|
this, nsPoint(0,0), &aBounds));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-17 03:45:39 +00:00
|
|
|
aOverflowAreas.Overflow(eVisualOverflow) = aOverflowAreas.Overflow(eVisualOverflow).Union(childVisual);
|
|
|
|
aOverflowAreas.Overflow(eScrollableOverflow) = aOverflowAreas.Overflow(eScrollableOverflow).Union(childScrollable);
|
2011-08-27 00:01:46 +00:00
|
|
|
}
|
|
|
|
|
2003-09-13 16:21:41 +00:00
|
|
|
void
|
2010-10-07 04:25:45 +00:00
|
|
|
nsFrame::ConsiderChildOverflow(nsOverflowAreas& aOverflowAreas,
|
2004-12-27 15:05:18 +00:00
|
|
|
nsIFrame* aChildFrame)
|
2003-09-13 16:21:41 +00:00
|
|
|
{
|
2011-06-15 21:03:49 +00:00
|
|
|
aOverflowAreas.UnionWith(aChildFrame->GetOverflowAreas() +
|
|
|
|
aChildFrame->GetPosition());
|
2003-09-13 16:21:41 +00:00
|
|
|
}
|
|
|
|
|
2003-06-15 00:55:00 +00:00
|
|
|
/**
|
2009-09-18 18:00:20 +00:00
|
|
|
* This function takes a "special" frame and _if_ that frame is an anonymous
|
|
|
|
* block created by an ib split it returns the block's preceding inline. This
|
|
|
|
* is needed because the split inline's style context is the parent of the
|
|
|
|
* anonymous block's style context.
|
2003-06-15 00:55:00 +00:00
|
|
|
*
|
2011-07-08 00:57:55 +00:00
|
|
|
* If aFrame is not an anonymous block, null is returned.
|
2003-06-15 00:55:00 +00:00
|
|
|
*/
|
2009-09-18 18:00:20 +00:00
|
|
|
static nsIFrame*
|
2012-02-15 09:28:21 +00:00
|
|
|
GetIBSpecialSiblingForAnonymousBlock(const nsIFrame* aFrame)
|
2003-06-15 00:55:00 +00:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(aFrame, "Must have a non-null frame!");
|
2003-06-28 11:48:14 +00:00
|
|
|
NS_ASSERTION(aFrame->GetStateBits() & NS_FRAME_IS_SPECIAL,
|
2003-06-15 00:55:00 +00:00
|
|
|
"GetIBSpecialSibling should not be called on a non-special frame");
|
2008-09-11 00:24:16 +00:00
|
|
|
|
2009-10-29 21:17:56 +00:00
|
|
|
nsIAtom* type = aFrame->GetStyleContext()->GetPseudo();
|
2008-09-11 00:24:16 +00:00
|
|
|
if (type != nsCSSAnonBoxes::mozAnonymousBlock &&
|
|
|
|
type != nsCSSAnonBoxes::mozAnonymousPositionedBlock) {
|
2009-09-18 18:00:20 +00:00
|
|
|
// it's not an anonymous block
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2008-09-11 00:24:16 +00:00
|
|
|
}
|
|
|
|
|
2009-09-18 18:00:20 +00:00
|
|
|
// Find the first continuation of the frame. (Ugh. This ends up
|
2003-06-15 00:55:00 +00:00
|
|
|
// being O(N^2) when it is called O(N) times.)
|
2009-09-18 18:00:20 +00:00
|
|
|
aFrame = aFrame->GetFirstContinuation();
|
2003-06-15 00:55:00 +00:00
|
|
|
|
|
|
|
/*
|
2006-12-26 17:47:52 +00:00
|
|
|
* Now look up the nsGkAtoms::IBSplitSpecialPrevSibling
|
2009-09-18 18:00:20 +00:00
|
|
|
* property.
|
2003-06-15 00:55:00 +00:00
|
|
|
*/
|
2010-03-29 01:46:55 +00:00
|
|
|
nsIFrame *specialSibling = static_cast<nsIFrame*>
|
|
|
|
(aFrame->Properties().Get(nsIFrame::IBSplitSpecialPrevSibling()));
|
2009-09-18 18:00:20 +00:00
|
|
|
NS_ASSERTION(specialSibling, "Broken frame tree?");
|
|
|
|
return specialSibling;
|
2005-12-17 18:58:47 +00:00
|
|
|
}
|
|
|
|
|
2003-06-15 00:55:00 +00:00
|
|
|
/**
|
|
|
|
* Get the parent, corrected for the mangled frame tree resulting from
|
|
|
|
* having a block within an inline. The result only differs from the
|
|
|
|
* result of |GetParent| when |GetParent| returns an anonymous block
|
|
|
|
* that was created for an element that was 'display: inline' because
|
|
|
|
* that element contained a block.
|
|
|
|
*
|
2003-10-11 12:00:05 +00:00
|
|
|
* Also skip anonymous scrolled-content parents; inherit directly from the
|
|
|
|
* outer scroll frame.
|
2003-06-15 00:55:00 +00:00
|
|
|
*/
|
2011-09-12 16:08:07 +00:00
|
|
|
static nsIFrame*
|
|
|
|
GetCorrectedParent(const nsIFrame* aFrame)
|
2003-06-15 00:55:00 +00:00
|
|
|
{
|
2003-06-28 11:48:14 +00:00
|
|
|
nsIFrame *parent = aFrame->GetParent();
|
2007-04-15 23:14:26 +00:00
|
|
|
if (!parent) {
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2007-04-15 23:14:26 +00:00
|
|
|
}
|
|
|
|
|
2011-09-12 16:08:07 +00:00
|
|
|
// Outer tables are always anon boxes; if we're in here for an outer
|
|
|
|
// table, that actually means its the _inner_ table that wants to
|
|
|
|
// know its parent. So get the pseudo of the inner in that case.
|
|
|
|
nsIAtom* pseudo = aFrame->GetStyleContext()->GetPseudo();
|
|
|
|
if (pseudo == nsCSSAnonBoxes::tableOuter) {
|
|
|
|
pseudo = aFrame->GetFirstPrincipalChild()->GetStyleContext()->GetPseudo();
|
|
|
|
}
|
|
|
|
return nsFrame::CorrectStyleParentFrame(parent, pseudo);
|
2007-04-15 23:14:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* static */
|
|
|
|
nsIFrame*
|
|
|
|
nsFrame::CorrectStyleParentFrame(nsIFrame* aProspectiveParent,
|
|
|
|
nsIAtom* aChildPseudo)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aProspectiveParent, "Must have a prospective parent");
|
|
|
|
|
|
|
|
// Anon boxes are parented to their actual parent already, except
|
|
|
|
// for non-elements. Those should not be treated as an anon box.
|
|
|
|
if (aChildPseudo && aChildPseudo != nsCSSAnonBoxes::mozNonElement &&
|
|
|
|
nsCSSAnonBoxes::IsAnonBox(aChildPseudo)) {
|
|
|
|
NS_ASSERTION(aChildPseudo != nsCSSAnonBoxes::mozAnonymousBlock &&
|
|
|
|
aChildPseudo != nsCSSAnonBoxes::mozAnonymousPositionedBlock,
|
|
|
|
"Should have dealt with kids that have NS_FRAME_IS_SPECIAL "
|
|
|
|
"elsewhere");
|
|
|
|
return aProspectiveParent;
|
|
|
|
}
|
|
|
|
|
2007-10-19 17:41:29 +00:00
|
|
|
// Otherwise, walk up out of all anon boxes. For placeholder frames, walk out
|
2010-04-02 06:07:43 +00:00
|
|
|
// of all pseudo-elements as well. Otherwise ReparentStyleContext could cause
|
2007-07-18 02:01:32 +00:00
|
|
|
// style data to be out of sync with the frame tree.
|
2007-04-15 23:14:26 +00:00
|
|
|
nsIFrame* parent = aProspectiveParent;
|
|
|
|
do {
|
|
|
|
if (parent->GetStateBits() & NS_FRAME_IS_SPECIAL) {
|
2009-09-18 18:00:20 +00:00
|
|
|
nsIFrame* sibling = GetIBSpecialSiblingForAnonymousBlock(parent);
|
2005-12-17 18:58:47 +00:00
|
|
|
|
2007-04-15 23:14:26 +00:00
|
|
|
if (sibling) {
|
2009-09-18 18:00:20 +00:00
|
|
|
// |parent| was a block in an {ib} split; use the inline as
|
2007-04-15 23:14:26 +00:00
|
|
|
// |the style parent.
|
|
|
|
parent = sibling;
|
2003-10-11 12:00:05 +00:00
|
|
|
}
|
2003-06-15 00:55:00 +00:00
|
|
|
}
|
2007-04-15 23:14:26 +00:00
|
|
|
|
2009-10-29 21:17:56 +00:00
|
|
|
nsIAtom* parentPseudo = parent->GetStyleContext()->GetPseudo();
|
2007-07-18 02:01:32 +00:00
|
|
|
if (!parentPseudo ||
|
|
|
|
(!nsCSSAnonBoxes::IsAnonBox(parentPseudo) &&
|
|
|
|
// nsPlaceholderFrame pases in nsGkAtoms::placeholderFrame for
|
|
|
|
// aChildPseudo (even though that's not a valid pseudo-type) just to
|
|
|
|
// trigger this behavior of walking up to the nearest non-pseudo
|
|
|
|
// ancestor.
|
|
|
|
aChildPseudo != nsGkAtoms::placeholderFrame)) {
|
2007-04-15 23:14:26 +00:00
|
|
|
return parent;
|
2003-06-15 00:55:00 +00:00
|
|
|
}
|
|
|
|
|
2007-04-15 23:14:26 +00:00
|
|
|
parent = parent->GetParent();
|
|
|
|
} while (parent);
|
|
|
|
|
2009-10-29 21:17:56 +00:00
|
|
|
if (aProspectiveParent->GetStyleContext()->GetPseudo() ==
|
2008-09-08 08:13:17 +00:00
|
|
|
nsCSSAnonBoxes::viewportScroll) {
|
|
|
|
// aProspectiveParent is the scrollframe for a viewport
|
|
|
|
// and the kids are the anonymous scrollbars
|
|
|
|
return aProspectiveParent;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We can get here if the root element is absolutely positioned.
|
|
|
|
// We can't test for this very accurately, but it can only happen
|
|
|
|
// when the prospective parent is a canvas frame.
|
|
|
|
NS_ASSERTION(aProspectiveParent->GetType() == nsGkAtoms::canvasFrame,
|
2007-04-15 23:14:26 +00:00
|
|
|
"Should have found a parent before this");
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2003-06-15 00:55:00 +00:00
|
|
|
}
|
|
|
|
|
2011-09-12 16:08:07 +00:00
|
|
|
nsIFrame*
|
2012-02-15 09:28:21 +00:00
|
|
|
nsFrame::DoGetParentStyleContextFrame() const
|
2002-03-27 02:38:13 +00:00
|
|
|
{
|
2006-08-12 02:14:39 +00:00
|
|
|
if (mContent && !mContent->GetParent() &&
|
2009-10-29 21:17:56 +00:00
|
|
|
!GetStyleContext()->GetPseudo()) {
|
2004-03-29 16:00:38 +00:00
|
|
|
// we're a frame for the root. We have no style context parent.
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2004-03-29 16:00:38 +00:00
|
|
|
}
|
|
|
|
|
2002-03-27 02:38:13 +00:00
|
|
|
if (!(mState & NS_FRAME_OUT_OF_FLOW)) {
|
2002-09-12 20:33:11 +00:00
|
|
|
/*
|
2009-09-18 18:00:20 +00:00
|
|
|
* If this frame is an anonymous block created when an inline with a block
|
|
|
|
* inside it got split, then the parent style context is on its preceding
|
|
|
|
* inline. We can get to it using GetIBSpecialSiblingForAnonymousBlock.
|
2002-09-12 20:33:11 +00:00
|
|
|
*/
|
|
|
|
if (mState & NS_FRAME_IS_SPECIAL) {
|
2011-09-12 16:08:07 +00:00
|
|
|
nsIFrame* specialSibling = GetIBSpecialSiblingForAnonymousBlock(this);
|
|
|
|
if (specialSibling) {
|
|
|
|
return specialSibling;
|
2007-04-15 23:14:26 +00:00
|
|
|
}
|
2002-09-12 20:33:11 +00:00
|
|
|
}
|
|
|
|
|
2002-03-27 02:38:13 +00:00
|
|
|
// If this frame is one of the blocks that split an inline, we must
|
|
|
|
// return the "special" inline parent, i.e., the parent that this
|
|
|
|
// frame would have if we didn't mangle the frame structure.
|
2011-09-12 16:08:07 +00:00
|
|
|
return GetCorrectedParent(this);
|
2002-03-27 02:38:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// For out-of-flow frames, we must resolve underneath the
|
|
|
|
// placeholder's parent.
|
2012-02-15 09:28:21 +00:00
|
|
|
const nsIFrame* oofFrame = this;
|
2009-08-31 18:25:36 +00:00
|
|
|
if ((oofFrame->GetStateBits() & NS_FRAME_OUT_OF_FLOW) &&
|
|
|
|
GetPrevInFlow()) {
|
|
|
|
// Out of flows that are continuations do not
|
2007-10-02 05:57:45 +00:00
|
|
|
// have placeholders. Use their first-in-flow's placeholder.
|
|
|
|
oofFrame = oofFrame->GetFirstInFlow();
|
|
|
|
}
|
2011-09-12 16:08:07 +00:00
|
|
|
nsIFrame* placeholder = oofFrame->PresContext()->FrameManager()->
|
|
|
|
GetPlaceholderFrameFor(oofFrame);
|
2002-03-27 02:38:13 +00:00
|
|
|
if (!placeholder) {
|
|
|
|
NS_NOTREACHED("no placeholder frame for out-of-flow frame");
|
2011-09-12 16:08:07 +00:00
|
|
|
return GetCorrectedParent(this);
|
2002-03-27 02:38:13 +00:00
|
|
|
}
|
2011-09-12 16:08:07 +00:00
|
|
|
return placeholder->GetParentStyleContextFrame();
|
2000-09-12 22:47:09 +00:00
|
|
|
}
|
|
|
|
|
1999-10-22 00:19:18 +00:00
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsFrame::GetLastLeaf(nsPresContext* aPresContext, nsIFrame **aFrame)
|
1999-07-15 18:19:03 +00:00
|
|
|
{
|
|
|
|
if (!aFrame || !*aFrame)
|
|
|
|
return;
|
|
|
|
nsIFrame *child = *aFrame;
|
2001-05-11 08:04:29 +00:00
|
|
|
//if we are a block frame then go for the last line of 'this'
|
1999-07-15 18:19:03 +00:00
|
|
|
while (1){
|
2011-08-24 20:54:30 +00:00
|
|
|
child = child->GetFirstPrincipalChild();
|
2004-01-09 14:20:53 +00:00
|
|
|
if (!child)
|
1999-07-15 18:19:03 +00:00
|
|
|
return;//nothing to do
|
2005-01-26 06:46:35 +00:00
|
|
|
nsIFrame* siblingFrame;
|
|
|
|
nsIContent* content;
|
|
|
|
//ignore anonymous elements, e.g. mozTableAdd* mozTableRemove*
|
|
|
|
//see bug 278197 comment #12 #13 for details
|
|
|
|
while ((siblingFrame = child->GetNextSibling()) &&
|
|
|
|
(content = siblingFrame->GetContent()) &&
|
2008-07-23 04:50:20 +00:00
|
|
|
!content->IsRootOfNativeAnonymousSubtree())
|
2005-01-26 06:46:35 +00:00
|
|
|
child = siblingFrame;
|
1999-07-15 18:19:03 +00:00
|
|
|
*aFrame = child;
|
|
|
|
}
|
|
|
|
}
|
1998-05-08 18:33:42 +00:00
|
|
|
|
1999-10-22 00:19:18 +00:00
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsFrame::GetFirstLeaf(nsPresContext* aPresContext, nsIFrame **aFrame)
|
1999-10-22 00:19:18 +00:00
|
|
|
{
|
|
|
|
if (!aFrame || !*aFrame)
|
|
|
|
return;
|
|
|
|
nsIFrame *child = *aFrame;
|
|
|
|
while (1){
|
2011-08-24 20:54:30 +00:00
|
|
|
child = child->GetFirstPrincipalChild();
|
2004-01-09 14:20:53 +00:00
|
|
|
if (!child)
|
1999-10-22 00:19:18 +00:00
|
|
|
return;//nothing to do
|
|
|
|
*aFrame = child;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-10 20:56:49 +00:00
|
|
|
/* virtual */ const void*
|
2004-06-01 06:20:16 +00:00
|
|
|
nsFrame::GetStyleDataExternal(nsStyleStructID aSID) const
|
2001-03-09 03:29:00 +00:00
|
|
|
{
|
2004-06-01 06:20:16 +00:00
|
|
|
NS_ASSERTION(mStyleContext, "unexpected null pointer");
|
|
|
|
return mStyleContext->GetStyleData(aSID);
|
2001-03-09 03:29:00 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
/* virtual */ bool
|
2012-08-22 15:56:38 +00:00
|
|
|
nsIFrame::IsFocusable(int32_t *aTabIndex, bool aWithMouse)
|
2004-07-24 21:12:43 +00:00
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t tabIndex = -1;
|
2005-07-21 19:27:18 +00:00
|
|
|
if (aTabIndex) {
|
|
|
|
*aTabIndex = -1; // Default for early return is not focusable
|
|
|
|
}
|
2011-09-29 06:19:26 +00:00
|
|
|
bool isFocusable = false;
|
2004-07-24 21:12:43 +00:00
|
|
|
|
2011-10-26 23:57:55 +00:00
|
|
|
if (mContent && mContent->IsElement() && IsVisibleConsideringAncestors()) {
|
|
|
|
const nsStyleUserInterface* ui = GetStyleUserInterface();
|
|
|
|
if (ui->mUserFocus != NS_STYLE_USER_FOCUS_IGNORE &&
|
|
|
|
ui->mUserFocus != NS_STYLE_USER_FOCUS_NONE) {
|
|
|
|
// Pass in default tabindex of -1 for nonfocusable and 0 for focusable
|
|
|
|
tabIndex = 0;
|
|
|
|
}
|
|
|
|
isFocusable = mContent->IsFocusable(&tabIndex, aWithMouse);
|
|
|
|
if (!isFocusable && !aWithMouse &&
|
|
|
|
GetType() == nsGkAtoms::scrollFrame &&
|
|
|
|
mContent->IsHTML() &&
|
|
|
|
!mContent->IsRootOfNativeAnonymousSubtree() &&
|
|
|
|
mContent->GetParent() &&
|
|
|
|
!mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::tabindex)) {
|
|
|
|
// Elements with scrollable view are focusable with script & tabbable
|
|
|
|
// Otherwise you couldn't scroll them with keyboard, which is
|
|
|
|
// an accessibility issue (e.g. Section 508 rules)
|
|
|
|
// However, we don't make them to be focusable with the mouse,
|
|
|
|
// because the extra focus outlines are considered unnecessarily ugly.
|
|
|
|
// When clicked on, the selection position within the element
|
|
|
|
// will be enough to make them keyboard scrollable.
|
|
|
|
nsIScrollableFrame *scrollFrame = do_QueryFrame(this);
|
|
|
|
if (scrollFrame &&
|
|
|
|
scrollFrame->GetScrollbarStyles() != nsIScrollableFrame::ScrollbarStyles(NS_STYLE_OVERFLOW_HIDDEN, NS_STYLE_OVERFLOW_HIDDEN) &&
|
|
|
|
!scrollFrame->GetScrollRange().IsEqualEdges(nsRect(0, 0, 0, 0))) {
|
|
|
|
// Scroll bars will be used for overflow
|
|
|
|
isFocusable = true;
|
|
|
|
tabIndex = 0;
|
2004-09-01 14:58:34 +00:00
|
|
|
}
|
2004-07-24 21:12:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aTabIndex) {
|
|
|
|
*aTabIndex = tabIndex;
|
|
|
|
}
|
|
|
|
return isFocusable;
|
|
|
|
}
|
|
|
|
|
2005-12-06 00:32:52 +00:00
|
|
|
/**
|
2011-10-17 14:59:28 +00:00
|
|
|
* @return true if this text frame ends with a newline character. It
|
|
|
|
* should return false if this is not a text frame.
|
2005-12-06 00:32:52 +00:00
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2005-12-06 00:32:52 +00:00
|
|
|
nsIFrame::HasTerminalNewline() const
|
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2005-12-06 00:32:52 +00:00
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
static uint8_t
|
|
|
|
ConvertSVGDominantBaselineToVerticalAlign(uint8_t aDominantBaseline)
|
2012-08-02 11:38:48 +00:00
|
|
|
{
|
|
|
|
switch (aDominantBaseline) {
|
|
|
|
case NS_STYLE_DOMINANT_BASELINE_HANGING:
|
|
|
|
case NS_STYLE_DOMINANT_BASELINE_TEXT_BEFORE_EDGE:
|
|
|
|
return NS_STYLE_VERTICAL_ALIGN_TEXT_TOP;
|
|
|
|
case NS_STYLE_DOMINANT_BASELINE_TEXT_AFTER_EDGE:
|
|
|
|
case NS_STYLE_DOMINANT_BASELINE_IDEOGRAPHIC:
|
|
|
|
return NS_STYLE_VERTICAL_ALIGN_TEXT_BOTTOM;
|
|
|
|
case NS_STYLE_DOMINANT_BASELINE_CENTRAL:
|
|
|
|
case NS_STYLE_DOMINANT_BASELINE_MIDDLE:
|
|
|
|
return NS_STYLE_VERTICAL_ALIGN_MIDDLE;
|
|
|
|
case NS_STYLE_DOMINANT_BASELINE_AUTO:
|
|
|
|
case NS_STYLE_DOMINANT_BASELINE_ALPHABETIC:
|
|
|
|
return NS_STYLE_VERTICAL_ALIGN_BASELINE;
|
|
|
|
default:
|
|
|
|
NS_NOTREACHED("unexpected aDominantBaseline value");
|
|
|
|
return NS_STYLE_VERTICAL_ALIGN_BASELINE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint8_t
|
2012-08-02 11:38:48 +00:00
|
|
|
nsIFrame::VerticalAlignEnum() const
|
|
|
|
{
|
|
|
|
if (mState & NS_FRAME_IS_SVG_TEXT) {
|
2012-08-22 15:56:38 +00:00
|
|
|
uint8_t dominantBaseline;
|
2012-08-02 11:38:48 +00:00
|
|
|
for (const nsIFrame* frame = this; frame; frame = frame->GetParent()) {
|
|
|
|
dominantBaseline = frame->GetStyleSVGReset()->mDominantBaseline;
|
|
|
|
if (dominantBaseline != NS_STYLE_DOMINANT_BASELINE_AUTO ||
|
|
|
|
frame->GetType() == nsGkAtoms::svgTextFrame) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ConvertSVGDominantBaselineToVerticalAlign(dominantBaseline);
|
|
|
|
}
|
|
|
|
|
|
|
|
const nsStyleCoord& verticalAlign =
|
|
|
|
GetStyleContext()->GetStyleTextReset()->mVerticalAlign;
|
|
|
|
if (verticalAlign.GetUnit() == eStyleUnit_Enumerated) {
|
|
|
|
return verticalAlign.GetIntValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
return eInvalidVerticalAlign;
|
|
|
|
}
|
|
|
|
|
2004-12-30 21:56:11 +00:00
|
|
|
/* static */
|
|
|
|
void nsFrame::FillCursorInformationFromStyle(const nsStyleUserInterface* ui,
|
|
|
|
nsIFrame::Cursor& aCursor)
|
|
|
|
{
|
|
|
|
aCursor.mCursor = ui->mCursor;
|
2011-10-17 14:59:28 +00:00
|
|
|
aCursor.mHaveHotspot = false;
|
2005-07-01 04:29:42 +00:00
|
|
|
aCursor.mHotspotX = aCursor.mHotspotY = 0.0f;
|
2004-12-30 21:56:11 +00:00
|
|
|
|
2005-07-01 04:29:42 +00:00
|
|
|
for (nsCursorImage *item = ui->mCursorArray,
|
|
|
|
*item_end = ui->mCursorArray + ui->mCursorArrayLength;
|
|
|
|
item < item_end; ++item) {
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t status;
|
2010-08-16 16:19:26 +00:00
|
|
|
nsresult rv = item->GetImage()->GetImageStatus(&status);
|
2009-09-12 22:44:18 +00:00
|
|
|
if (NS_SUCCEEDED(rv) && (status & imgIRequest::STATUS_LOAD_COMPLETE)) {
|
2004-12-30 21:56:11 +00:00
|
|
|
// This is the one we want
|
2010-08-16 16:19:26 +00:00
|
|
|
item->GetImage()->GetImage(getter_AddRefs(aCursor.mContainer));
|
2005-07-01 04:29:42 +00:00
|
|
|
aCursor.mHaveHotspot = item->mHaveHotspot;
|
|
|
|
aCursor.mHotspotX = item->mHotspotX;
|
|
|
|
aCursor.mHotspotY = item->mHotspotY;
|
2004-12-30 21:56:11 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-09-28 18:37:50 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFrame::RefreshSizeCache(nsBoxLayoutState& aState)
|
|
|
|
{
|
2007-04-01 15:15:17 +00:00
|
|
|
// XXXbz this comment needs some rewriting to make sense in the
|
|
|
|
// post-reflow-branch world.
|
|
|
|
|
2004-09-28 18:37:50 +00:00
|
|
|
// Ok we need to compute our minimum, preferred, and maximum sizes.
|
|
|
|
// 1) Maximum size. This is easy. Its infinite unless it is overloaded by CSS.
|
|
|
|
// 2) Preferred size. This is a little harder. This is the size the block would be
|
|
|
|
// if it were laid out on an infinite canvas. So we can get this by reflowing
|
|
|
|
// the block with and INTRINSIC width and height. We can also do a nice optimization
|
|
|
|
// for incremental reflow. If the reflow is incremental then we can pass a flag to
|
|
|
|
// have the block compute the preferred width for us! Preferred height can just be
|
|
|
|
// the minimum height;
|
|
|
|
// 3) Minimum size. This is a toughy. We can pass the block a flag asking for the max element
|
|
|
|
// size. That would give us the width. Unfortunately you can only ask for a maxElementSize
|
|
|
|
// during an incremental reflow. So on other reflows we will just have to use 0.
|
|
|
|
// The min height on the other hand is fairly easy we need to get the largest
|
|
|
|
// line height. This can be done with the line iterator.
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// if we do have a rendering context
|
2004-09-28 18:37:50 +00:00
|
|
|
nsresult rv = NS_OK;
|
2011-04-08 01:04:40 +00:00
|
|
|
nsRenderingContext* rendContext = aState.GetRenderingContext();
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
if (rendContext) {
|
2004-09-28 18:37:50 +00:00
|
|
|
nsPresContext* presContext = aState.PresContext();
|
|
|
|
|
2005-11-20 22:05:24 +00:00
|
|
|
// If we don't have any HTML constraints and it's a resize, then nothing in the block
|
2004-09-28 18:37:50 +00:00
|
|
|
// could have changed, so no refresh is necessary.
|
|
|
|
nsBoxLayoutMetrics* metrics = BoxMetrics();
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
if (!DoesNeedRecalc(metrics->mBlockPrefSize))
|
2005-04-28 21:57:22 +00:00
|
|
|
return NS_OK;
|
2004-09-28 18:37:50 +00:00
|
|
|
|
|
|
|
// the rect we plan to size to.
|
2012-08-29 05:39:31 +00:00
|
|
|
nsRect rect = GetRect();
|
2004-09-28 18:37:50 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsMargin bp(0,0,0,0);
|
|
|
|
GetBorderAndPadding(bp);
|
2004-09-28 18:37:50 +00:00
|
|
|
|
2012-01-25 01:21:29 +00:00
|
|
|
{
|
|
|
|
// If we're a container for font size inflation, then shrink
|
|
|
|
// wrapping inside of us should not apply font size inflation.
|
2012-05-21 05:18:27 +00:00
|
|
|
AutoMaybeDisableFontInflation an(this);
|
2012-01-25 01:21:29 +00:00
|
|
|
|
|
|
|
metrics->mBlockPrefSize.width =
|
|
|
|
GetPrefWidth(rendContext) + bp.LeftRight();
|
|
|
|
metrics->mBlockMinSize.width =
|
|
|
|
GetMinWidth(rendContext) + bp.LeftRight();
|
|
|
|
}
|
2005-12-15 23:08:07 +00:00
|
|
|
|
2004-09-28 18:37:50 +00:00
|
|
|
// do the nasty.
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsHTMLReflowMetrics desiredSize;
|
|
|
|
rv = BoxReflow(aState, presContext, desiredSize, rendContext,
|
|
|
|
rect.x, rect.y,
|
|
|
|
metrics->mBlockPrefSize.width, NS_UNCONSTRAINEDSIZE);
|
2004-09-28 18:37:50 +00:00
|
|
|
|
2008-03-13 09:14:16 +00:00
|
|
|
metrics->mBlockMinSize.height = 0;
|
|
|
|
// ok we need the max ascent of the items on the line. So to do this
|
|
|
|
// ask the block for its line iterator. Get the max ascent.
|
2008-10-30 19:17:59 +00:00
|
|
|
nsAutoLineIterator lines = GetLineIterator();
|
2008-03-13 09:14:16 +00:00
|
|
|
if (lines)
|
|
|
|
{
|
|
|
|
metrics->mBlockMinSize.height = 0;
|
|
|
|
int count = 0;
|
2012-07-30 14:20:58 +00:00
|
|
|
nsIFrame* firstFrame = nullptr;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t framesOnLine;
|
2008-03-13 09:14:16 +00:00
|
|
|
nsRect lineBounds;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t lineFlags;
|
2008-03-13 09:14:16 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
lines->GetLine(count, &firstFrame, &framesOnLine, lineBounds, &lineFlags);
|
|
|
|
|
|
|
|
if (lineBounds.height > metrics->mBlockMinSize.height)
|
|
|
|
metrics->mBlockMinSize.height = lineBounds.height;
|
|
|
|
|
|
|
|
count++;
|
|
|
|
} while(firstFrame);
|
|
|
|
} else {
|
|
|
|
metrics->mBlockMinSize.height = desiredSize.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
metrics->mBlockPrefSize.height = metrics->mBlockMinSize.height;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
2007-01-23 04:06:56 +00:00
|
|
|
if (desiredSize.ascent == nsHTMLReflowMetrics::ASK_FOR_BASELINE) {
|
|
|
|
if (!nsLayoutUtils::GetFirstLineBaseline(this, &metrics->mBlockAscent))
|
|
|
|
metrics->mBlockAscent = GetBaseline();
|
|
|
|
} else {
|
|
|
|
metrics->mBlockAscent = desiredSize.ascent;
|
|
|
|
}
|
2004-09-28 18:37:50 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG_adaptor
|
|
|
|
printf("min=(%d,%d), pref=(%d,%d), ascent=%d\n", metrics->mBlockMinSize.width,
|
|
|
|
metrics->mBlockMinSize.height,
|
|
|
|
metrics->mBlockPrefSize.width,
|
|
|
|
metrics->mBlockPrefSize.height,
|
|
|
|
metrics->mBlockAscent);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2008-10-30 19:17:59 +00:00
|
|
|
/* virtual */ nsILineIterator*
|
|
|
|
nsFrame::GetLineIterator()
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2008-10-30 19:17:59 +00:00
|
|
|
}
|
|
|
|
|
2007-01-08 02:57:59 +00:00
|
|
|
nsSize
|
|
|
|
nsFrame::GetPrefSize(nsBoxLayoutState& aState)
|
2004-09-28 18:37:50 +00:00
|
|
|
{
|
2007-01-08 02:57:59 +00:00
|
|
|
nsSize size(0,0);
|
|
|
|
DISPLAY_PREF_SIZE(this, size);
|
2004-09-28 18:37:50 +00:00
|
|
|
// If the size is cached, and there are no HTML constraints that we might
|
|
|
|
// be depending on, then we just return the cached size.
|
|
|
|
nsBoxLayoutMetrics *metrics = BoxMetrics();
|
2005-04-28 21:57:22 +00:00
|
|
|
if (!DoesNeedRecalc(metrics->mPrefSize)) {
|
2010-03-18 19:58:15 +00:00
|
|
|
return metrics->mPrefSize;
|
2004-09-28 18:37:50 +00:00
|
|
|
}
|
|
|
|
|
2011-06-15 21:03:49 +00:00
|
|
|
if (IsCollapsed())
|
2007-01-08 02:57:59 +00:00
|
|
|
return size;
|
2004-09-28 18:37:50 +00:00
|
|
|
|
2007-01-08 02:57:59 +00:00
|
|
|
// get our size in CSS.
|
2011-09-29 06:19:26 +00:00
|
|
|
bool widthSet, heightSet;
|
2012-08-06 03:00:57 +00:00
|
|
|
bool completelyRedefined = nsIFrame::AddCSSPrefSize(this, size, widthSet, heightSet);
|
2004-09-28 18:37:50 +00:00
|
|
|
|
2007-01-08 02:57:59 +00:00
|
|
|
// Refresh our caches with new sizes.
|
|
|
|
if (!completelyRedefined) {
|
|
|
|
RefreshSizeCache(aState);
|
2010-03-18 19:58:15 +00:00
|
|
|
nsSize blockSize = metrics->mBlockPrefSize;
|
2007-01-08 02:57:59 +00:00
|
|
|
|
|
|
|
// notice we don't need to add our borders or padding
|
|
|
|
// in. That's because the block did it for us.
|
2010-03-18 19:58:15 +00:00
|
|
|
if (!widthSet)
|
|
|
|
size.width = blockSize.width;
|
|
|
|
if (!heightSet)
|
|
|
|
size.height = blockSize.height;
|
2007-01-08 02:57:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
metrics->mPrefSize = size;
|
|
|
|
return size;
|
2004-09-28 18:37:50 +00:00
|
|
|
}
|
|
|
|
|
2007-01-08 02:57:59 +00:00
|
|
|
nsSize
|
|
|
|
nsFrame::GetMinSize(nsBoxLayoutState& aState)
|
2004-09-28 18:37:50 +00:00
|
|
|
{
|
2007-01-08 02:57:59 +00:00
|
|
|
nsSize size(0,0);
|
|
|
|
DISPLAY_MIN_SIZE(this, size);
|
2004-09-28 18:37:50 +00:00
|
|
|
// Don't use the cache if we have HTMLReflowState constraints --- they might have changed
|
|
|
|
nsBoxLayoutMetrics *metrics = BoxMetrics();
|
2005-04-28 21:57:22 +00:00
|
|
|
if (!DoesNeedRecalc(metrics->mMinSize)) {
|
2007-01-08 02:57:59 +00:00
|
|
|
size = metrics->mMinSize;
|
|
|
|
return size;
|
2004-09-28 18:37:50 +00:00
|
|
|
}
|
|
|
|
|
2011-06-15 21:03:49 +00:00
|
|
|
if (IsCollapsed())
|
2007-01-08 02:57:59 +00:00
|
|
|
return size;
|
2004-09-28 18:37:50 +00:00
|
|
|
|
2007-01-08 02:57:59 +00:00
|
|
|
// get our size in CSS.
|
2011-09-29 06:19:26 +00:00
|
|
|
bool widthSet, heightSet;
|
|
|
|
bool completelyRedefined =
|
2012-08-06 03:00:57 +00:00
|
|
|
nsIFrame::AddCSSMinSize(aState, this, size, widthSet, heightSet);
|
2004-09-28 18:37:50 +00:00
|
|
|
|
2007-01-08 02:57:59 +00:00
|
|
|
// Refresh our caches with new sizes.
|
|
|
|
if (!completelyRedefined) {
|
|
|
|
RefreshSizeCache(aState);
|
2010-03-18 19:58:15 +00:00
|
|
|
nsSize blockSize = metrics->mBlockMinSize;
|
|
|
|
|
|
|
|
if (!widthSet)
|
|
|
|
size.width = blockSize.width;
|
|
|
|
if (!heightSet)
|
|
|
|
size.height = blockSize.height;
|
2007-01-08 02:57:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
metrics->mMinSize = size;
|
|
|
|
return size;
|
2004-09-28 18:37:50 +00:00
|
|
|
}
|
|
|
|
|
2007-01-08 02:57:59 +00:00
|
|
|
nsSize
|
|
|
|
nsFrame::GetMaxSize(nsBoxLayoutState& aState)
|
2004-09-28 18:37:50 +00:00
|
|
|
{
|
2007-01-08 02:57:59 +00:00
|
|
|
nsSize size(NS_INTRINSICSIZE, NS_INTRINSICSIZE);
|
|
|
|
DISPLAY_MAX_SIZE(this, size);
|
2004-09-28 18:37:50 +00:00
|
|
|
// Don't use the cache if we have HTMLReflowState constraints --- they might have changed
|
|
|
|
nsBoxLayoutMetrics *metrics = BoxMetrics();
|
2005-04-28 21:57:22 +00:00
|
|
|
if (!DoesNeedRecalc(metrics->mMaxSize)) {
|
2007-01-08 02:57:59 +00:00
|
|
|
size = metrics->mMaxSize;
|
|
|
|
return size;
|
2004-09-28 18:37:50 +00:00
|
|
|
}
|
|
|
|
|
2011-06-15 21:03:49 +00:00
|
|
|
if (IsCollapsed())
|
2007-01-08 02:57:59 +00:00
|
|
|
return size;
|
2004-09-28 18:37:50 +00:00
|
|
|
|
2007-01-08 02:57:59 +00:00
|
|
|
size = nsBox::GetMaxSize(aState);
|
|
|
|
metrics->mMaxSize = size;
|
2004-09-28 18:37:50 +00:00
|
|
|
|
2007-01-08 02:57:59 +00:00
|
|
|
return size;
|
2004-09-28 18:37:50 +00:00
|
|
|
}
|
|
|
|
|
2007-01-31 16:02:42 +00:00
|
|
|
nscoord
|
|
|
|
nsFrame::GetFlex(nsBoxLayoutState& aState)
|
2004-09-28 18:37:50 +00:00
|
|
|
{
|
|
|
|
nsBoxLayoutMetrics *metrics = BoxMetrics();
|
2007-01-31 16:02:42 +00:00
|
|
|
if (!DoesNeedRecalc(metrics->mFlex))
|
|
|
|
return metrics->mFlex;
|
2004-09-28 18:37:50 +00:00
|
|
|
|
2007-01-31 16:02:42 +00:00
|
|
|
metrics->mFlex = nsBox::GetFlex(aState);
|
2004-09-28 18:37:50 +00:00
|
|
|
|
2007-01-31 16:02:42 +00:00
|
|
|
return metrics->mFlex;
|
2004-09-28 18:37:50 +00:00
|
|
|
}
|
|
|
|
|
2007-01-31 16:02:42 +00:00
|
|
|
nscoord
|
|
|
|
nsFrame::GetBoxAscent(nsBoxLayoutState& aState)
|
2004-09-28 18:37:50 +00:00
|
|
|
{
|
|
|
|
nsBoxLayoutMetrics *metrics = BoxMetrics();
|
2007-01-31 16:02:42 +00:00
|
|
|
if (!DoesNeedRecalc(metrics->mAscent))
|
|
|
|
return metrics->mAscent;
|
2004-09-28 18:37:50 +00:00
|
|
|
|
2011-06-15 21:03:49 +00:00
|
|
|
if (IsCollapsed()) {
|
2004-09-28 18:37:50 +00:00
|
|
|
metrics->mAscent = 0;
|
|
|
|
} else {
|
|
|
|
// Refresh our caches with new sizes.
|
|
|
|
RefreshSizeCache(aState);
|
|
|
|
metrics->mAscent = metrics->mBlockAscent;
|
|
|
|
}
|
|
|
|
|
2007-01-31 16:02:42 +00:00
|
|
|
return metrics->mAscent;
|
2004-09-28 18:37:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsFrame::DoLayout(nsBoxLayoutState& aState)
|
|
|
|
{
|
|
|
|
nsRect ourRect(mRect);
|
|
|
|
|
2011-04-08 01:04:40 +00:00
|
|
|
nsRenderingContext* rendContext = aState.GetRenderingContext();
|
2004-09-28 18:37:50 +00:00
|
|
|
nsPresContext* presContext = aState.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 05:38:33 +00:00
|
|
|
nsHTMLReflowMetrics desiredSize;
|
2004-09-28 18:37:50 +00:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
if (rendContext) {
|
2004-09-28 18:37:50 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
rv = BoxReflow(aState, presContext, desiredSize, rendContext,
|
2004-09-28 18:37:50 +00:00
|
|
|
ourRect.x, ourRect.y, ourRect.width, ourRect.height);
|
|
|
|
|
2011-06-15 21:03:49 +00:00
|
|
|
if (IsCollapsed()) {
|
2004-09-28 18:37:50 +00:00
|
|
|
SetSize(nsSize(0, 0));
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// if our child needs to be bigger. This might happend with
|
|
|
|
// wrapping text. There is no way to predict its height until we
|
|
|
|
// reflow it. Now that we know the height reshuffle upward.
|
|
|
|
if (desiredSize.width > ourRect.width ||
|
|
|
|
desiredSize.height > ourRect.height) {
|
|
|
|
|
|
|
|
#ifdef DEBUG_GROW
|
|
|
|
DumpBox(stdout);
|
|
|
|
printf(" GREW from (%d,%d) -> (%d,%d)\n",
|
|
|
|
ourRect.width, ourRect.height,
|
|
|
|
desiredSize.width, desiredSize.height);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (desiredSize.width > ourRect.width)
|
|
|
|
ourRect.width = desiredSize.width;
|
|
|
|
|
|
|
|
if (desiredSize.height > ourRect.height)
|
|
|
|
ourRect.height = desiredSize.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ensure our size is what we think is should be. Someone could have
|
|
|
|
// reset the frame to be smaller or something dumb like that.
|
|
|
|
SetSize(nsSize(ourRect.width, ourRect.height));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-14 03:40:55 +00:00
|
|
|
// Should we do this if IsCollapsed() is true?
|
|
|
|
nsSize size(GetSize());
|
2010-10-07 04:25:46 +00:00
|
|
|
desiredSize.width = size.width;
|
|
|
|
desiredSize.height = size.height;
|
|
|
|
desiredSize.UnionOverflowAreasWithDesiredBounds();
|
2012-03-10 22:50:51 +00:00
|
|
|
|
|
|
|
if (HasAbsolutelyPositionedChildren()) {
|
|
|
|
// Set up a |reflowState| to pass into ReflowAbsoluteFrames
|
|
|
|
nsHTMLReflowState reflowState(aState.PresContext(), this,
|
|
|
|
aState.GetRenderingContext(),
|
2012-06-13 19:49:41 +00:00
|
|
|
nsSize(size.width, NS_UNCONSTRAINEDSIZE),
|
|
|
|
nsHTMLReflowState::DUMMY_PARENT_REFLOW_STATE);
|
2012-03-10 22:50:51 +00:00
|
|
|
|
|
|
|
// Set up a |reflowStatus| to pass into ReflowAbsoluteFrames
|
|
|
|
// (just a dummy value; hopefully that's OK)
|
|
|
|
nsReflowStatus reflowStatus = NS_FRAME_COMPLETE;
|
|
|
|
ReflowAbsoluteFrames(aState.PresContext(), desiredSize,
|
|
|
|
reflowState, reflowStatus);
|
|
|
|
}
|
|
|
|
|
2010-10-07 04:25:45 +00:00
|
|
|
FinishAndStoreOverflow(desiredSize.mOverflowAreas, size);
|
2009-12-14 03:40:55 +00:00
|
|
|
|
2004-09-28 18:37:50 +00:00
|
|
|
SyncLayout(aState);
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsFrame::BoxReflow(nsBoxLayoutState& aState,
|
2004-09-28 18:37:50 +00:00
|
|
|
nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
2011-04-08 01:04:40 +00:00
|
|
|
nsRenderingContext* aRenderingContext,
|
2004-09-28 18:37:50 +00:00
|
|
|
nscoord aX,
|
|
|
|
nscoord aY,
|
|
|
|
nscoord aWidth,
|
|
|
|
nscoord aHeight,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aMoveFrame)
|
2004-09-28 18:37:50 +00:00
|
|
|
{
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsBoxToBlockAdaptor");
|
2004-09-28 18:37:50 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG_REFLOW
|
|
|
|
nsAdaptorAddIndents();
|
|
|
|
printf("Reflowing: ");
|
|
|
|
nsFrame::ListTag(stdout, mFrame);
|
|
|
|
printf("\n");
|
|
|
|
gIndent2++;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//printf("width=%d, height=%d\n", aWidth, aHeight);
|
|
|
|
/*
|
2012-08-06 03:00:57 +00:00
|
|
|
nsIFrame* parent;
|
2004-09-28 18:37:50 +00:00
|
|
|
GetParentBox(&parent);
|
|
|
|
|
|
|
|
// if (parent->GetStateBits() & NS_STATE_CURRENTLY_IN_DEBUG)
|
|
|
|
// printf("In debug\n");
|
|
|
|
*/
|
|
|
|
|
|
|
|
nsBoxLayoutMetrics *metrics = BoxMetrics();
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsReflowStatus status = NS_FRAME_COMPLETE;
|
2004-09-28 18:37:50 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool needsReflow = NS_SUBTREE_DIRTY(this);
|
2004-09-28 18:37:50 +00:00
|
|
|
|
|
|
|
// if we don't need a reflow then
|
|
|
|
// lets see if we are already that size. Yes? then don't even reflow. We are done.
|
|
|
|
if (!needsReflow) {
|
|
|
|
|
|
|
|
if (aWidth != NS_INTRINSICSIZE && aHeight != NS_INTRINSICSIZE) {
|
|
|
|
|
|
|
|
// if the new calculated size has a 0 width or a 0 height
|
|
|
|
if ((metrics->mLastSize.width == 0 || metrics->mLastSize.height == 0) && (aWidth == 0 || aHeight == 0)) {
|
2011-10-17 14:59:28 +00:00
|
|
|
needsReflow = false;
|
2004-09-28 18:37:50 +00:00
|
|
|
aDesiredSize.width = aWidth;
|
|
|
|
aDesiredSize.height = aHeight;
|
|
|
|
SetSize(nsSize(aDesiredSize.width, aDesiredSize.height));
|
|
|
|
} else {
|
|
|
|
aDesiredSize.width = metrics->mLastSize.width;
|
|
|
|
aDesiredSize.height = metrics->mLastSize.height;
|
|
|
|
|
|
|
|
// remove the margin. The rect of our child does not include it but our calculated size does.
|
|
|
|
// don't reflow if we are already the right 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 05:38:33 +00:00
|
|
|
if (metrics->mLastSize.width == aWidth && metrics->mLastSize.height == aHeight)
|
2011-10-17 14:59:28 +00:00
|
|
|
needsReflow = false;
|
2004-09-28 18:37:50 +00:00
|
|
|
else
|
2011-10-17 14:59:28 +00:00
|
|
|
needsReflow = true;
|
2004-09-28 18:37:50 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// if the width or height are intrinsic alway reflow because
|
|
|
|
// we don't know what it should be.
|
2011-10-17 14:59:28 +00:00
|
|
|
needsReflow = true;
|
2004-09-28 18:37:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ok now reflow the child into the spacers calculated space
|
|
|
|
if (needsReflow) {
|
|
|
|
|
|
|
|
aDesiredSize.width = 0;
|
|
|
|
aDesiredSize.height = 0;
|
|
|
|
|
|
|
|
// create a reflow state to tell our child to flow at the given 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 05:38:33 +00:00
|
|
|
// Construct a bogus parent reflow state so that there's a usable
|
|
|
|
// containing block reflow state.
|
|
|
|
nsMargin margin(0,0,0,0);
|
|
|
|
GetMargin(margin);
|
|
|
|
|
|
|
|
nsSize parentSize(aWidth, aHeight);
|
|
|
|
if (parentSize.height != NS_INTRINSICSIZE)
|
|
|
|
parentSize.height += margin.TopBottom();
|
|
|
|
if (parentSize.width != NS_INTRINSICSIZE)
|
|
|
|
parentSize.width += margin.LeftRight();
|
|
|
|
|
|
|
|
nsIFrame *parentFrame = GetParent();
|
|
|
|
nsFrameState savedState = parentFrame->GetStateBits();
|
|
|
|
nsHTMLReflowState parentReflowState(aPresContext, parentFrame,
|
|
|
|
aRenderingContext,
|
2012-06-13 19:49:41 +00:00
|
|
|
parentSize,
|
|
|
|
nsHTMLReflowState::DUMMY_PARENT_REFLOW_STATE);
|
2010-06-09 05:28:14 +00:00
|
|
|
parentFrame->RemoveStateBits(~nsFrameState(0));
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
parentFrame->AddStateBits(savedState);
|
|
|
|
|
|
|
|
// This may not do very much useful, but it's probably worth trying.
|
|
|
|
if (parentSize.width != NS_INTRINSICSIZE)
|
2010-05-01 10:40:22 +00:00
|
|
|
parentReflowState.SetComputedWidth(NS_MAX(parentSize.width, 0));
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
if (parentSize.height != NS_INTRINSICSIZE)
|
2010-05-01 10:40:22 +00:00
|
|
|
parentReflowState.SetComputedHeight(NS_MAX(parentSize.height, 0));
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
parentReflowState.mComputedMargin.SizeTo(0, 0, 0, 0);
|
2007-01-17 05:19:35 +00:00
|
|
|
// XXX use box methods
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
parentFrame->GetPadding(parentReflowState.mComputedPadding);
|
|
|
|
parentFrame->GetBorder(parentReflowState.mComputedBorderPadding);
|
|
|
|
parentReflowState.mComputedBorderPadding +=
|
|
|
|
parentReflowState.mComputedPadding;
|
|
|
|
|
|
|
|
// XXX Is it OK that this reflow state has no parent reflow state?
|
|
|
|
// (It used to have a bogus parent, skipping all the boxes).
|
2007-04-01 15:15:17 +00:00
|
|
|
nsSize availSize(aWidth, NS_INTRINSICSIZE);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsHTMLReflowState reflowState(aPresContext, this, aRenderingContext,
|
2012-06-13 19:49:41 +00:00
|
|
|
availSize,
|
|
|
|
nsHTMLReflowState::DUMMY_PARENT_REFLOW_STATE);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
|
|
|
// Construct the parent chain manually since constructing it normally
|
|
|
|
// messes up dimensions.
|
2011-11-24 02:48:23 +00:00
|
|
|
const nsHTMLReflowState *outerReflowState = aState.OuterReflowState();
|
|
|
|
NS_ASSERTION(!outerReflowState || outerReflowState->frame != this,
|
|
|
|
"in and out of XUL on a single frame?");
|
|
|
|
if (outerReflowState && outerReflowState->frame == parentFrame) {
|
|
|
|
// We're a frame (such as a text control frame) that jumps into
|
|
|
|
// box reflow and then straight out of it on the child frame.
|
|
|
|
// This means we actually have a real parent reflow state.
|
2012-01-25 01:21:29 +00:00
|
|
|
// nsLayoutUtils::InflationMinFontSizeFor used to need this to be
|
|
|
|
// linked up correctly for text control frames, so do so here).
|
2011-11-24 02:48:23 +00:00
|
|
|
reflowState.parentReflowState = outerReflowState;
|
|
|
|
reflowState.mCBReflowState = outerReflowState;
|
|
|
|
} else {
|
|
|
|
reflowState.parentReflowState = &parentReflowState;
|
|
|
|
reflowState.mCBReflowState = &parentReflowState;
|
|
|
|
}
|
2008-04-10 04:39:41 +00:00
|
|
|
reflowState.mReflowDepth = aState.GetReflowDepth();
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
|
|
|
// mComputedWidth and mComputedHeight are content-box, not
|
|
|
|
// border-box
|
2007-01-17 05:19:35 +00:00
|
|
|
if (aWidth != NS_INTRINSICSIZE) {
|
2007-01-26 00:05:12 +00:00
|
|
|
nscoord computedWidth =
|
2007-01-17 05:19:35 +00:00
|
|
|
aWidth - reflowState.mComputedBorderPadding.LeftRight();
|
2009-09-16 15:01:36 +00:00
|
|
|
computedWidth = NS_MAX(computedWidth, 0);
|
2007-01-26 00:05:12 +00:00
|
|
|
reflowState.SetComputedWidth(computedWidth);
|
2007-01-17 05:19:35 +00:00
|
|
|
}
|
2009-06-12 07:33:51 +00:00
|
|
|
|
|
|
|
// Most child frames of box frames (e.g. subdocument or scroll frames)
|
|
|
|
// need to be constrained to the provided size and overflow as necessary.
|
|
|
|
// The one exception are block frames, because we need to know their
|
|
|
|
// natural height excluding any overflow area which may be caused by
|
|
|
|
// various CSS effects such as shadow or outline.
|
|
|
|
if (!IsFrameOfType(eBlockFrame)) {
|
|
|
|
if (aHeight != NS_INTRINSICSIZE) {
|
|
|
|
nscoord computedHeight =
|
|
|
|
aHeight - reflowState.mComputedBorderPadding.TopBottom();
|
2009-09-16 15:01:36 +00:00
|
|
|
computedHeight = NS_MAX(computedHeight, 0);
|
2009-06-12 07:33:51 +00:00
|
|
|
reflowState.SetComputedHeight(computedHeight);
|
|
|
|
} else {
|
|
|
|
reflowState.SetComputedHeight(
|
|
|
|
ComputeSize(aRenderingContext, availSize, availSize.width,
|
|
|
|
nsSize(reflowState.mComputedMargin.LeftRight(),
|
|
|
|
reflowState.mComputedMargin.TopBottom()),
|
|
|
|
nsSize(reflowState.mComputedBorderPadding.LeftRight() -
|
|
|
|
reflowState.mComputedPadding.LeftRight(),
|
|
|
|
reflowState.mComputedBorderPadding.TopBottom() -
|
|
|
|
reflowState.mComputedPadding.TopBottom()),
|
|
|
|
nsSize(reflowState.mComputedPadding.LeftRight(),
|
|
|
|
reflowState.mComputedPadding.TopBottom()),
|
2011-10-17 14:59:28 +00:00
|
|
|
false).height
|
2009-06-12 07:33:51 +00:00
|
|
|
);
|
|
|
|
}
|
2007-01-17 05:19:35 +00:00
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
|
|
|
// Box layout calls SetRect before Layout, whereas non-box layout
|
|
|
|
// calls SetRect after Reflow.
|
|
|
|
// XXX Perhaps we should be doing this by twiddling the rect back to
|
|
|
|
// mLastSize before calling Reflow and then switching it back, but
|
|
|
|
// However, mLastSize can also be the size passed to BoxReflow by
|
|
|
|
// RefreshSizeCache, so that doesn't really make sense.
|
2011-11-24 02:48:23 +00:00
|
|
|
if (metrics->mLastSize.width != aWidth) {
|
2011-10-17 14:59:28 +00:00
|
|
|
reflowState.mFlags.mHResize = true;
|
2011-11-24 02:48:23 +00:00
|
|
|
|
|
|
|
// When font size inflation is enabled, a horizontal resize
|
|
|
|
// requires a full reflow. See nsHTMLReflowState::InitResizeFlags
|
|
|
|
// for more details.
|
|
|
|
if (nsLayoutUtils::FontSizeInflationEnabled(aPresContext)) {
|
|
|
|
AddStateBits(NS_FRAME_IS_DIRTY);
|
|
|
|
}
|
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
if (metrics->mLastSize.height != aHeight)
|
2011-10-17 14:59:28 +00:00
|
|
|
reflowState.mFlags.mVResize = true;
|
2004-09-28 18:37:50 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG_REFLOW
|
|
|
|
nsAdaptorAddIndents();
|
2007-08-02 18:08:05 +00:00
|
|
|
printf("Size=(%d,%d)\n",reflowState.ComputedWidth(),
|
|
|
|
reflowState.ComputedHeight());
|
2004-09-28 18:37:50 +00:00
|
|
|
nsAdaptorAddIndents();
|
|
|
|
nsAdaptorPrintReason(reflowState);
|
|
|
|
printf("\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// place the child and reflow
|
|
|
|
WillReflow(aPresContext);
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
Reflow(aPresContext, aDesiredSize, reflowState, status);
|
2004-09-28 18:37:50 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
NS_ASSERTION(NS_FRAME_IS_COMPLETE(status), "bad status");
|
2004-09-28 18:37:50 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t layoutFlags = aState.LayoutFlags();
|
2004-09-28 18:37:50 +00:00
|
|
|
nsContainerFrame::FinishReflowChild(this, aPresContext, &reflowState,
|
|
|
|
aDesiredSize, aX, aY, layoutFlags | NS_FRAME_NO_MOVE_FRAME);
|
2007-01-23 04:06:56 +00:00
|
|
|
|
|
|
|
// Save the ascent. (bug 103925)
|
2011-06-15 21:03:49 +00:00
|
|
|
if (IsCollapsed()) {
|
2007-01-23 04:06:56 +00:00
|
|
|
metrics->mAscent = 0;
|
|
|
|
} else {
|
|
|
|
if (aDesiredSize.ascent == nsHTMLReflowMetrics::ASK_FOR_BASELINE) {
|
|
|
|
if (!nsLayoutUtils::GetFirstLineBaseline(this, &metrics->mAscent))
|
|
|
|
metrics->mAscent = GetBaseline();
|
|
|
|
} else
|
|
|
|
metrics->mAscent = aDesiredSize.ascent;
|
|
|
|
}
|
|
|
|
|
2004-09-28 18:37:50 +00:00
|
|
|
} else {
|
|
|
|
aDesiredSize.ascent = metrics->mBlockAscent;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG_REFLOW
|
|
|
|
if (aHeight != NS_INTRINSICSIZE && aDesiredSize.height != aHeight)
|
|
|
|
{
|
|
|
|
nsAdaptorAddIndents();
|
|
|
|
printf("*****got taller!*****\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
if (aWidth != NS_INTRINSICSIZE && aDesiredSize.width != aWidth)
|
|
|
|
{
|
|
|
|
nsAdaptorAddIndents();
|
|
|
|
printf("*****got wider!******\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (aWidth == NS_INTRINSICSIZE)
|
|
|
|
aWidth = aDesiredSize.width;
|
|
|
|
|
|
|
|
if (aHeight == NS_INTRINSICSIZE)
|
|
|
|
aHeight = aDesiredSize.height;
|
|
|
|
|
|
|
|
metrics->mLastSize.width = aDesiredSize.width;
|
|
|
|
metrics->mLastSize.height = aDesiredSize.height;
|
|
|
|
|
|
|
|
#ifdef DEBUG_REFLOW
|
|
|
|
gIndent2--;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-03-29 01:46:55 +00:00
|
|
|
static void
|
|
|
|
DestroyBoxMetrics(void* aPropertyValue)
|
|
|
|
{
|
|
|
|
delete static_cast<nsBoxLayoutMetrics*>(aPropertyValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_DECLARE_FRAME_PROPERTY(BoxMetricsProperty, DestroyBoxMetrics)
|
|
|
|
|
2004-09-28 18:37:50 +00:00
|
|
|
nsBoxLayoutMetrics*
|
|
|
|
nsFrame::BoxMetrics() const
|
|
|
|
{
|
|
|
|
nsBoxLayoutMetrics* metrics =
|
2010-03-29 01:46:55 +00:00
|
|
|
static_cast<nsBoxLayoutMetrics*>(Properties().Get(BoxMetricsProperty()));
|
2004-09-28 18:37:50 +00:00
|
|
|
NS_ASSERTION(metrics, "A box layout method was called but InitBoxMetrics was never called");
|
|
|
|
return metrics;
|
|
|
|
}
|
|
|
|
|
2012-08-29 05:39:01 +00:00
|
|
|
/**
|
|
|
|
* Adds the NS_FRAME_IN_POPUP state bit to the current frame,
|
|
|
|
* and all descendant frames (including cross-doc ones).
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
AddInPopupStateBitToDescendants(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
aFrame->AddStateBits(NS_FRAME_IN_POPUP);
|
|
|
|
|
|
|
|
nsAutoTArray<nsIFrame::ChildList,4> childListArray;
|
|
|
|
aFrame->GetCrossDocChildLists(&childListArray);
|
|
|
|
|
|
|
|
nsIFrame::ChildListArrayIterator lists(childListArray);
|
|
|
|
for (; !lists.IsDone(); lists.Next()) {
|
|
|
|
nsFrameList::Enumerator childFrames(lists.CurrentList());
|
|
|
|
for (; !childFrames.AtEnd(); childFrames.Next()) {
|
|
|
|
AddInPopupStateBitToDescendants(childFrames.get());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes the NS_FRAME_IN_POPUP state bit from the current
|
|
|
|
* frames and all descendant frames (including cross-doc ones),
|
|
|
|
* unless the frame is a popup itself.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
RemoveInPopupStateBitFromDescendants(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
if (!aFrame->HasAnyStateBits(NS_FRAME_IN_POPUP) ||
|
|
|
|
aFrame->GetType() == nsGkAtoms::listControlFrame ||
|
|
|
|
aFrame->GetType() == nsGkAtoms::menuPopupFrame) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
aFrame->RemoveStateBits(NS_FRAME_IN_POPUP);
|
|
|
|
|
|
|
|
nsAutoTArray<nsIFrame::ChildList,4> childListArray;
|
|
|
|
aFrame->GetCrossDocChildLists(&childListArray);
|
|
|
|
|
|
|
|
nsIFrame::ChildListArrayIterator lists(childListArray);
|
|
|
|
for (; !lists.IsDone(); lists.Next()) {
|
|
|
|
nsFrameList::Enumerator childFrames(lists.CurrentList());
|
|
|
|
for (; !childFrames.AtEnd(); childFrames.Next()) {
|
|
|
|
RemoveInPopupStateBitFromDescendants(childFrames.get());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-31 00:46:26 +00:00
|
|
|
void
|
|
|
|
nsFrame::SetParent(nsIFrame* aParent)
|
2004-09-28 18:37:50 +00:00
|
|
|
{
|
2011-09-29 06:19:26 +00:00
|
|
|
bool wasBoxWrapped = IsBoxWrapped();
|
2010-08-31 00:46:26 +00:00
|
|
|
mParent = aParent;
|
2010-03-29 01:46:55 +00:00
|
|
|
if (!wasBoxWrapped && IsBoxWrapped()) {
|
2011-10-17 14:59:28 +00:00
|
|
|
InitBoxMetrics(true);
|
2010-03-29 01:46:55 +00:00
|
|
|
} else if (wasBoxWrapped && !IsBoxWrapped()) {
|
|
|
|
Properties().Delete(BoxMetricsProperty());
|
|
|
|
}
|
2004-09-28 18:37:50 +00:00
|
|
|
|
2010-08-31 00:46:26 +00:00
|
|
|
if (GetStateBits() & (NS_FRAME_HAS_VIEW | NS_FRAME_HAS_CHILD_WITH_VIEW)) {
|
|
|
|
for (nsIFrame* f = aParent;
|
|
|
|
f && !(f->GetStateBits() & NS_FRAME_HAS_CHILD_WITH_VIEW);
|
|
|
|
f = f->GetParent()) {
|
|
|
|
f->AddStateBits(NS_FRAME_HAS_CHILD_WITH_VIEW);
|
|
|
|
}
|
|
|
|
}
|
2012-08-29 05:39:01 +00:00
|
|
|
|
|
|
|
if (HasInvalidFrameInSubtree()) {
|
|
|
|
for (nsIFrame* f = aParent;
|
|
|
|
f && !f->HasAnyStateBits(NS_FRAME_DESCENDANT_NEEDS_PAINT);
|
|
|
|
f = nsLayoutUtils::GetCrossDocParentFrame(f)) {
|
|
|
|
f->AddStateBits(NS_FRAME_DESCENDANT_NEEDS_PAINT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aParent->HasAnyStateBits(NS_FRAME_IN_POPUP)) {
|
|
|
|
AddInPopupStateBitToDescendants(this);
|
|
|
|
} else {
|
|
|
|
RemoveInPopupStateBitFromDescendants(this);
|
|
|
|
}
|
2012-08-29 05:48:43 +00:00
|
|
|
|
|
|
|
// If our new parent only has invalid children, then we just invalidate
|
|
|
|
// ourselves too. This is probably faster than clearing the flag all
|
|
|
|
// the way up the frame tree.
|
|
|
|
if (aParent->HasAnyStateBits(NS_FRAME_ALL_DESCENDANTS_NEED_PAINT)) {
|
2012-08-29 05:48:44 +00:00
|
|
|
InvalidateFrame();
|
2012-08-29 05:48:43 +00:00
|
|
|
}
|
2004-09-28 18:37:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-09-29 06:19:26 +00:00
|
|
|
nsFrame::InitBoxMetrics(bool aClear)
|
2004-09-28 18:37:50 +00:00
|
|
|
{
|
2010-03-29 01:46:55 +00:00
|
|
|
FrameProperties props = Properties();
|
|
|
|
if (aClear) {
|
|
|
|
props.Delete(BoxMetricsProperty());
|
|
|
|
}
|
2004-09-28 18:37:50 +00:00
|
|
|
|
|
|
|
nsBoxLayoutMetrics *metrics = new nsBoxLayoutMetrics();
|
2010-03-29 01:46:55 +00:00
|
|
|
props.Set(BoxMetricsProperty(), metrics);
|
2004-09-28 18:37:50 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsFrame::MarkIntrinsicWidthsDirty();
|
2004-09-28 18:37:50 +00:00
|
|
|
metrics->mBlockAscent = 0;
|
|
|
|
metrics->mLastSize.SizeTo(0, 0);
|
|
|
|
}
|
|
|
|
|
2012-10-11 05:44:59 +00:00
|
|
|
void
|
|
|
|
nsIFrame::CreateOwnLayerIfNeeded(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsDisplayList* aList)
|
|
|
|
{
|
|
|
|
if (GetContent()->HasAttr(kNameSpaceID_None, nsGkAtoms::layer)) {
|
|
|
|
aList->AppendNewToTop(new (aBuilder)
|
|
|
|
nsDisplayOwnLayer(aBuilder, this, aList));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-09-28 18:37:50 +00:00
|
|
|
// Box layout debugging
|
|
|
|
#ifdef DEBUG_REFLOW
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t gIndent2 = 0;
|
2004-09-28 18:37:50 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
nsAdaptorAddIndents()
|
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
for(int32_t i=0; i < gIndent2; i++)
|
2004-09-28 18:37:50 +00:00
|
|
|
{
|
|
|
|
printf(" ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsAdaptorPrintReason(nsHTMLReflowState& aReflowState)
|
|
|
|
{
|
|
|
|
char* reflowReasonString;
|
|
|
|
|
|
|
|
switch(aReflowState.reason)
|
|
|
|
{
|
|
|
|
case eReflowReason_Initial:
|
|
|
|
reflowReasonString = "initial";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eReflowReason_Resize:
|
|
|
|
reflowReasonString = "resize";
|
|
|
|
break;
|
|
|
|
case eReflowReason_Dirty:
|
|
|
|
reflowReasonString = "dirty";
|
|
|
|
break;
|
|
|
|
case eReflowReason_StyleChange:
|
|
|
|
reflowReasonString = "stylechange";
|
|
|
|
break;
|
|
|
|
case eReflowReason_Incremental:
|
|
|
|
{
|
2005-02-08 00:59:52 +00:00
|
|
|
switch (aReflowState.reflowCommand->Type()) {
|
2004-09-28 18:37:50 +00:00
|
|
|
case eReflowType_StyleChanged:
|
|
|
|
reflowReasonString = "incremental (StyleChanged)";
|
|
|
|
break;
|
|
|
|
case eReflowType_ReflowDirty:
|
|
|
|
reflowReasonString = "incremental (ReflowDirty)";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
reflowReasonString = "incremental (Unknown)";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
reflowReasonString = "unknown";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("%s",reflowReasonString);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#ifdef DEBUG_LAYOUT
|
|
|
|
void
|
|
|
|
nsFrame::GetBoxName(nsAutoString& aName)
|
|
|
|
{
|
2009-08-20 21:52:48 +00:00
|
|
|
GetFrameName(aName);
|
2004-09-28 18:37:50 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-06-25 19:59:42 +00:00
|
|
|
#ifdef DEBUG
|
1998-05-20 16:24:13 +00:00
|
|
|
static void
|
2012-08-09 07:09:40 +00:00
|
|
|
GetTagName(nsFrame* aFrame, nsIContent* aContent, int aResultSize,
|
1998-05-20 16:24:13 +00:00
|
|
|
char* aResult)
|
|
|
|
{
|
2003-06-13 20:10:01 +00:00
|
|
|
if (aContent) {
|
2010-03-08 15:45:00 +00:00
|
|
|
PR_snprintf(aResult, aResultSize, "%s@%p",
|
|
|
|
nsAtomCString(aContent->Tag()).get(), aFrame);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
PR_snprintf(aResult, aResultSize, "@%p", aFrame);
|
1998-05-20 16:24:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-09-29 06:19:26 +00:00
|
|
|
nsFrame::Trace(const char* aMethod, bool aEnter)
|
1998-05-20 16:24:13 +00:00
|
|
|
{
|
|
|
|
if (NS_FRAME_LOG_TEST(gLogModule, NS_FRAME_TRACE_CALLS)) {
|
|
|
|
char tagbuf[40];
|
|
|
|
GetTagName(this, mContent, sizeof(tagbuf), tagbuf);
|
|
|
|
PR_LogPrint("%s: %s %s", tagbuf, aEnter ? "enter" : "exit", aMethod);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-09-29 06:19:26 +00:00
|
|
|
nsFrame::Trace(const char* aMethod, bool aEnter, nsReflowStatus aStatus)
|
1998-05-20 16:24:13 +00:00
|
|
|
{
|
|
|
|
if (NS_FRAME_LOG_TEST(gLogModule, NS_FRAME_TRACE_CALLS)) {
|
|
|
|
char tagbuf[40];
|
|
|
|
GetTagName(this, mContent, sizeof(tagbuf), tagbuf);
|
|
|
|
PR_LogPrint("%s: %s %s, status=%scomplete%s",
|
|
|
|
tagbuf, aEnter ? "enter" : "exit", aMethod,
|
|
|
|
NS_FRAME_IS_NOT_COMPLETE(aStatus) ? "not" : "",
|
|
|
|
(NS_FRAME_REFLOW_NEXTINFLOW & aStatus) ? "+reflow" : "");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsFrame::TraceMsg(const char* aFormatString, ...)
|
|
|
|
{
|
|
|
|
if (NS_FRAME_LOG_TEST(gLogModule, NS_FRAME_TRACE_CALLS)) {
|
|
|
|
// Format arguments into a buffer
|
|
|
|
char argbuf[200];
|
|
|
|
va_list ap;
|
|
|
|
va_start(ap, aFormatString);
|
|
|
|
PR_vsnprintf(argbuf, sizeof(argbuf), aFormatString, ap);
|
|
|
|
va_end(ap);
|
|
|
|
|
|
|
|
char tagbuf[40];
|
|
|
|
GetTagName(this, mContent, sizeof(tagbuf), tagbuf);
|
|
|
|
PR_LogPrint("%s: %s", tagbuf, argbuf);
|
|
|
|
}
|
|
|
|
}
|
1999-07-24 02:37:06 +00:00
|
|
|
|
|
|
|
void
|
2009-07-28 12:53:20 +00:00
|
|
|
nsFrame::VerifyDirtyBitSet(const nsFrameList& aFrameList)
|
1999-07-24 02:37:06 +00:00
|
|
|
{
|
2009-07-28 12:53:20 +00:00
|
|
|
for (nsFrameList::Enumerator e(aFrameList); !e.AtEnd(); e.Next()) {
|
|
|
|
NS_ASSERTION(e.get()->GetStateBits() & NS_FRAME_IS_DIRTY,
|
|
|
|
"dirty bit not set");
|
1999-07-24 02:37:06 +00:00
|
|
|
}
|
|
|
|
}
|
2000-01-12 08:28:24 +00:00
|
|
|
|
2001-10-29 01:43:59 +00:00
|
|
|
// Start Display Reflow
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
DR_cookie::DR_cookie(nsPresContext* aPresContext,
|
2001-11-14 13:40:03 +00:00
|
|
|
nsIFrame* aFrame,
|
2001-10-29 01:43:59 +00:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
nsReflowStatus& aStatus)
|
2001-11-14 13:40:03 +00:00
|
|
|
:mPresContext(aPresContext), mFrame(aFrame), mReflowState(aReflowState), mMetrics(aMetrics), mStatus(aStatus)
|
2001-10-29 01:43:59 +00:00
|
|
|
{
|
2003-03-22 15:09:17 +00:00
|
|
|
MOZ_COUNT_CTOR(DR_cookie);
|
2001-11-14 13:40:03 +00:00
|
|
|
mValue = nsFrame::DisplayReflowEnter(aPresContext, mFrame, mReflowState);
|
2001-10-29 01:43:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DR_cookie::~DR_cookie()
|
|
|
|
{
|
2003-03-22 15:09:17 +00:00
|
|
|
MOZ_COUNT_DTOR(DR_cookie);
|
2001-11-14 13:40:03 +00:00
|
|
|
nsFrame::DisplayReflowExit(mPresContext, mFrame, mMetrics, mStatus, mValue);
|
2001-10-29 01:43:59 +00:00
|
|
|
}
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
DR_layout_cookie::DR_layout_cookie(nsIFrame* aFrame)
|
|
|
|
: mFrame(aFrame)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(DR_layout_cookie);
|
|
|
|
mValue = nsFrame::DisplayLayoutEnter(mFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
DR_layout_cookie::~DR_layout_cookie()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(DR_layout_cookie);
|
|
|
|
nsFrame::DisplayLayoutExit(mFrame, mValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
DR_intrinsic_width_cookie::DR_intrinsic_width_cookie(
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
const char* aType,
|
|
|
|
nscoord& aResult)
|
|
|
|
: mFrame(aFrame)
|
|
|
|
, mType(aType)
|
|
|
|
, mResult(aResult)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(DR_intrinsic_width_cookie);
|
|
|
|
mValue = nsFrame::DisplayIntrinsicWidthEnter(mFrame, mType);
|
|
|
|
}
|
|
|
|
|
|
|
|
DR_intrinsic_width_cookie::~DR_intrinsic_width_cookie()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(DR_intrinsic_width_cookie);
|
|
|
|
nsFrame::DisplayIntrinsicWidthExit(mFrame, mType, mResult, mValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
DR_intrinsic_size_cookie::DR_intrinsic_size_cookie(
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
const char* aType,
|
|
|
|
nsSize& aResult)
|
|
|
|
: mFrame(aFrame)
|
|
|
|
, mType(aType)
|
|
|
|
, mResult(aResult)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(DR_intrinsic_size_cookie);
|
|
|
|
mValue = nsFrame::DisplayIntrinsicSizeEnter(mFrame, mType);
|
|
|
|
}
|
|
|
|
|
|
|
|
DR_intrinsic_size_cookie::~DR_intrinsic_size_cookie()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(DR_intrinsic_size_cookie);
|
|
|
|
nsFrame::DisplayIntrinsicSizeExit(mFrame, mType, mResult, mValue);
|
|
|
|
}
|
|
|
|
|
2010-05-01 21:40:16 +00:00
|
|
|
DR_init_constraints_cookie::DR_init_constraints_cookie(
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsHTMLReflowState* aState,
|
|
|
|
nscoord aCBWidth,
|
|
|
|
nscoord aCBHeight,
|
|
|
|
const nsMargin* aMargin,
|
|
|
|
const nsMargin* aPadding)
|
|
|
|
: mFrame(aFrame)
|
|
|
|
, mState(aState)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(DR_init_constraints_cookie);
|
|
|
|
mValue = nsHTMLReflowState::DisplayInitConstraintsEnter(mFrame, mState,
|
|
|
|
aCBWidth, aCBHeight,
|
|
|
|
aMargin, aPadding);
|
|
|
|
}
|
|
|
|
|
|
|
|
DR_init_constraints_cookie::~DR_init_constraints_cookie()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(DR_init_constraints_cookie);
|
|
|
|
nsHTMLReflowState::DisplayInitConstraintsExit(mFrame, mState, mValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
DR_init_offsets_cookie::DR_init_offsets_cookie(
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsCSSOffsetState* aState,
|
|
|
|
nscoord aCBWidth,
|
|
|
|
const nsMargin* aMargin,
|
|
|
|
const nsMargin* aPadding)
|
|
|
|
: mFrame(aFrame)
|
|
|
|
, mState(aState)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(DR_init_offsets_cookie);
|
|
|
|
mValue = nsCSSOffsetState::DisplayInitOffsetsEnter(mFrame, mState, aCBWidth,
|
|
|
|
aMargin, aPadding);
|
|
|
|
}
|
|
|
|
|
|
|
|
DR_init_offsets_cookie::~DR_init_offsets_cookie()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(DR_init_offsets_cookie);
|
|
|
|
nsCSSOffsetState::DisplayInitOffsetsExit(mFrame, mState, mValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
DR_init_type_cookie::DR_init_type_cookie(
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsHTMLReflowState* aState)
|
|
|
|
: mFrame(aFrame)
|
|
|
|
, mState(aState)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(DR_init_type_cookie);
|
|
|
|
mValue = nsHTMLReflowState::DisplayInitFrameTypeEnter(mFrame, mState);
|
|
|
|
}
|
|
|
|
|
|
|
|
DR_init_type_cookie::~DR_init_type_cookie()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(DR_init_type_cookie);
|
|
|
|
nsHTMLReflowState::DisplayInitFrameTypeExit(mFrame, mState, mValue);
|
|
|
|
}
|
|
|
|
|
2001-10-29 01:43:59 +00:00
|
|
|
struct DR_FrameTypeInfo;
|
|
|
|
struct DR_FrameTreeNode;
|
|
|
|
struct DR_Rule;
|
|
|
|
|
|
|
|
struct DR_State
|
|
|
|
{
|
|
|
|
DR_State();
|
|
|
|
~DR_State();
|
|
|
|
void Init();
|
|
|
|
void AddFrameTypeInfo(nsIAtom* aFrameType,
|
2004-02-06 23:11:46 +00:00
|
|
|
const char* aFrameNameAbbrev,
|
|
|
|
const char* aFrameName);
|
2001-10-29 01:43:59 +00:00
|
|
|
DR_FrameTypeInfo* GetFrameTypeInfo(nsIAtom* aFrameType);
|
|
|
|
DR_FrameTypeInfo* GetFrameTypeInfo(char* aFrameName);
|
|
|
|
void InitFrameTypeTable();
|
|
|
|
DR_FrameTreeNode* CreateTreeNode(nsIFrame* aFrame,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
const nsHTMLReflowState* aReflowState);
|
2001-10-29 01:43:59 +00:00
|
|
|
void FindMatchingRule(DR_FrameTreeNode& aNode);
|
2011-09-29 06:19:26 +00:00
|
|
|
bool RuleMatches(DR_Rule& aRule,
|
2001-10-29 01:43:59 +00:00
|
|
|
DR_FrameTreeNode& aNode);
|
2011-09-29 06:19:26 +00:00
|
|
|
bool GetToken(FILE* aFile,
|
2010-04-06 19:42:41 +00:00
|
|
|
char* aBuf,
|
|
|
|
size_t aBufSize);
|
2001-10-29 01:43:59 +00:00
|
|
|
DR_Rule* ParseRule(FILE* aFile);
|
|
|
|
void ParseRulesFile();
|
2009-02-03 14:42:18 +00:00
|
|
|
void AddRule(nsTArray<DR_Rule*>& aRules,
|
|
|
|
DR_Rule& aRule);
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsWhiteSpace(int c);
|
|
|
|
bool GetNumber(char* aBuf,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t& aNumber);
|
2001-10-29 01:43:59 +00:00
|
|
|
void PrettyUC(nscoord aSize,
|
|
|
|
char* aBuf);
|
2010-05-01 21:40:16 +00:00
|
|
|
void PrintMargin(const char* tag, const nsMargin* aMargin);
|
2001-10-29 01:43:59 +00:00
|
|
|
void DisplayFrameTypeInfo(nsIFrame* aFrame,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aIndent);
|
2001-10-29 01:43:59 +00:00
|
|
|
void DeleteTreeNode(DR_FrameTreeNode& aNode);
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mInited;
|
|
|
|
bool mActive;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t mCount;
|
|
|
|
int32_t mAssert;
|
|
|
|
int32_t mIndent;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mIndentUndisplayedFrames;
|
|
|
|
bool mDisplayPixelErrors;
|
2009-02-03 14:42:18 +00:00
|
|
|
nsTArray<DR_Rule*> mWildRules;
|
2009-03-12 07:26:29 +00:00
|
|
|
nsTArray<DR_FrameTypeInfo> mFrameTypeTable;
|
2001-10-29 01:43:59 +00:00
|
|
|
// reflow specific state
|
2009-02-03 14:42:18 +00:00
|
|
|
nsTArray<DR_FrameTreeNode*> mFrameTreeLeaves;
|
2001-10-29 01:43:59 +00:00
|
|
|
};
|
|
|
|
|
2003-03-22 15:09:17 +00:00
|
|
|
static DR_State *DR_state; // the one and only DR_State
|
2001-10-29 01:43:59 +00:00
|
|
|
|
|
|
|
struct DR_RulePart
|
|
|
|
{
|
|
|
|
DR_RulePart(nsIAtom* aFrameType) : mFrameType(aFrameType), mNext(0) {}
|
|
|
|
void Destroy();
|
|
|
|
|
|
|
|
nsIAtom* mFrameType;
|
|
|
|
DR_RulePart* mNext;
|
|
|
|
};
|
|
|
|
|
|
|
|
void DR_RulePart::Destroy()
|
|
|
|
{
|
|
|
|
if (mNext) {
|
|
|
|
mNext->Destroy();
|
|
|
|
}
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct DR_Rule
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
DR_Rule() : mLength(0), mTarget(nullptr), mDisplay(false) {
|
2003-03-22 15:09:17 +00:00
|
|
|
MOZ_COUNT_CTOR(DR_Rule);
|
|
|
|
}
|
|
|
|
~DR_Rule() {
|
|
|
|
if (mTarget) mTarget->Destroy();
|
|
|
|
MOZ_COUNT_DTOR(DR_Rule);
|
|
|
|
}
|
2001-10-29 01:43:59 +00:00
|
|
|
void AddPart(nsIAtom* aFrameType);
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mLength;
|
2001-10-29 01:43:59 +00:00
|
|
|
DR_RulePart* mTarget;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mDisplay;
|
2001-10-29 01:43:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void DR_Rule::AddPart(nsIAtom* aFrameType)
|
|
|
|
{
|
|
|
|
DR_RulePart* newPart = new DR_RulePart(aFrameType);
|
|
|
|
newPart->mNext = mTarget;
|
|
|
|
mTarget = newPart;
|
|
|
|
mLength++;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct DR_FrameTypeInfo
|
|
|
|
{
|
2004-02-06 23:11:46 +00:00
|
|
|
DR_FrameTypeInfo(nsIAtom* aFrmeType, const char* aFrameNameAbbrev, const char* aFrameName);
|
2001-10-31 14:45:12 +00:00
|
|
|
~DR_FrameTypeInfo() {
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t numElements;
|
2009-02-03 14:42:18 +00:00
|
|
|
numElements = mRules.Length();
|
2012-08-22 15:56:38 +00:00
|
|
|
for (int32_t i = numElements - 1; i >= 0; i--) {
|
2009-02-03 14:42:18 +00:00
|
|
|
delete mRules.ElementAt(i);
|
2001-10-31 14:45:12 +00:00
|
|
|
}
|
|
|
|
}
|
2001-10-29 01:43:59 +00:00
|
|
|
|
|
|
|
nsIAtom* mType;
|
|
|
|
char mNameAbbrev[16];
|
|
|
|
char mName[32];
|
2009-02-03 14:42:18 +00:00
|
|
|
nsTArray<DR_Rule*> mRules;
|
2009-03-12 07:26:29 +00:00
|
|
|
private:
|
2011-12-16 19:42:07 +00:00
|
|
|
DR_FrameTypeInfo& operator=(const DR_FrameTypeInfo&) MOZ_DELETE;
|
2001-10-29 01:43:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
DR_FrameTypeInfo::DR_FrameTypeInfo(nsIAtom* aFrameType,
|
2004-02-06 23:11:46 +00:00
|
|
|
const char* aFrameNameAbbrev,
|
|
|
|
const char* aFrameName)
|
2001-10-29 01:43:59 +00:00
|
|
|
{
|
|
|
|
mType = aFrameType;
|
2011-03-28 23:07:27 +00:00
|
|
|
PL_strncpyz(mNameAbbrev, aFrameNameAbbrev, sizeof(mNameAbbrev));
|
|
|
|
PL_strncpyz(mName, aFrameName, sizeof(mName));
|
2001-10-29 01:43:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct DR_FrameTreeNode
|
|
|
|
{
|
2003-03-22 15:09:17 +00:00
|
|
|
DR_FrameTreeNode(nsIFrame* aFrame, DR_FrameTreeNode* aParent) : mFrame(aFrame), mParent(aParent), mDisplay(0), mIndent(0)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(DR_FrameTreeNode);
|
|
|
|
}
|
|
|
|
|
|
|
|
~DR_FrameTreeNode()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(DR_FrameTreeNode);
|
|
|
|
}
|
2001-10-29 01:43:59 +00:00
|
|
|
|
|
|
|
nsIFrame* mFrame;
|
|
|
|
DR_FrameTreeNode* mParent;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mDisplay;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mIndent;
|
2001-10-29 01:43:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// DR_State implementation
|
|
|
|
|
|
|
|
DR_State::DR_State()
|
2011-10-17 14:59:28 +00:00
|
|
|
: mInited(false), mActive(false), mCount(0), mAssert(-1), mIndent(0),
|
|
|
|
mIndentUndisplayedFrames(false), mDisplayPixelErrors(false)
|
2003-03-22 15:09:17 +00:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(DR_State);
|
|
|
|
}
|
2001-10-29 01:43:59 +00:00
|
|
|
|
|
|
|
void DR_State::Init()
|
|
|
|
{
|
|
|
|
char* env = PR_GetEnv("GECKO_DISPLAY_REFLOW_ASSERT");
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t num;
|
2001-10-29 01:43:59 +00:00
|
|
|
if (env) {
|
|
|
|
if (GetNumber(env, num))
|
|
|
|
mAssert = num;
|
|
|
|
else
|
|
|
|
printf("GECKO_DISPLAY_REFLOW_ASSERT - invalid value = %s", env);
|
|
|
|
}
|
|
|
|
|
|
|
|
env = PR_GetEnv("GECKO_DISPLAY_REFLOW_INDENT_START");
|
|
|
|
if (env) {
|
|
|
|
if (GetNumber(env, num))
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
mIndent = num;
|
2001-10-29 01:43:59 +00:00
|
|
|
else
|
|
|
|
printf("GECKO_DISPLAY_REFLOW_INDENT_START - invalid value = %s", env);
|
|
|
|
}
|
|
|
|
|
|
|
|
env = PR_GetEnv("GECKO_DISPLAY_REFLOW_INDENT_UNDISPLAYED_FRAMES");
|
|
|
|
if (env) {
|
|
|
|
if (GetNumber(env, num))
|
|
|
|
mIndentUndisplayedFrames = num;
|
|
|
|
else
|
|
|
|
printf("GECKO_DISPLAY_REFLOW_INDENT_UNDISPLAYED_FRAMES - invalid value = %s", env);
|
|
|
|
}
|
2001-11-14 13:40:03 +00:00
|
|
|
|
|
|
|
env = PR_GetEnv("GECKO_DISPLAY_REFLOW_FLAG_PIXEL_ERRORS");
|
|
|
|
if (env) {
|
|
|
|
if (GetNumber(env, num))
|
|
|
|
mDisplayPixelErrors = num;
|
|
|
|
else
|
|
|
|
printf("GECKO_DISPLAY_REFLOW_FLAG_PIXEL_ERRORS - invalid value = %s", env);
|
|
|
|
}
|
|
|
|
|
2001-10-29 01:43:59 +00:00
|
|
|
InitFrameTypeTable();
|
|
|
|
ParseRulesFile();
|
2011-10-17 14:59:28 +00:00
|
|
|
mInited = true;
|
2001-10-29 01:43:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DR_State::~DR_State()
|
|
|
|
{
|
2003-03-22 15:09:17 +00:00
|
|
|
MOZ_COUNT_DTOR(DR_State);
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t numElements, i;
|
2009-02-03 14:42:18 +00:00
|
|
|
numElements = mWildRules.Length();
|
2001-10-31 14:45:12 +00:00
|
|
|
for (i = numElements - 1; i >= 0; i--) {
|
2009-02-03 14:42:18 +00:00
|
|
|
delete mWildRules.ElementAt(i);
|
2001-10-31 14:45:12 +00:00
|
|
|
}
|
2009-02-03 14:42:18 +00:00
|
|
|
numElements = mFrameTreeLeaves.Length();
|
2001-10-31 14:45:12 +00:00
|
|
|
for (i = numElements - 1; i >= 0; i--) {
|
2009-02-03 14:42:18 +00:00
|
|
|
delete mFrameTreeLeaves.ElementAt(i);
|
2001-10-31 14:45:12 +00:00
|
|
|
}
|
2001-10-29 01:43:59 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool DR_State::GetNumber(char* aBuf,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t& aNumber)
|
2001-10-29 01:43:59 +00:00
|
|
|
{
|
|
|
|
if (sscanf(aBuf, "%d", &aNumber) > 0)
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2001-10-29 01:43:59 +00:00
|
|
|
else
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2001-10-29 01:43:59 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool DR_State::IsWhiteSpace(int c) {
|
2001-10-29 01:43:59 +00:00
|
|
|
return (c == ' ') || (c == '\t') || (c == '\n') || (c == '\r');
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool DR_State::GetToken(FILE* aFile,
|
2010-04-06 19:42:41 +00:00
|
|
|
char* aBuf,
|
|
|
|
size_t aBufSize)
|
2001-10-29 01:43:59 +00:00
|
|
|
{
|
2011-09-29 06:19:26 +00:00
|
|
|
bool haveToken = false;
|
2001-10-29 01:43:59 +00:00
|
|
|
aBuf[0] = 0;
|
|
|
|
// get the 1st non whitespace char
|
|
|
|
int c = -1;
|
|
|
|
for (c = getc(aFile); (c > 0) && IsWhiteSpace(c); c = getc(aFile)) {
|
|
|
|
}
|
|
|
|
|
|
|
|
if (c > 0) {
|
2011-10-17 14:59:28 +00:00
|
|
|
haveToken = true;
|
2001-10-29 01:43:59 +00:00
|
|
|
aBuf[0] = c;
|
|
|
|
// get everything up to the next whitespace char
|
2010-04-06 19:42:41 +00:00
|
|
|
size_t cX;
|
|
|
|
for (cX = 1; cX + 1 < aBufSize ; cX++) {
|
|
|
|
c = getc(aFile);
|
2001-10-29 01:43:59 +00:00
|
|
|
if (c < 0) { // EOF
|
|
|
|
ungetc(' ', aFile);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (IsWhiteSpace(c)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aBuf[cX] = c;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aBuf[cX] = 0;
|
|
|
|
}
|
|
|
|
return haveToken;
|
|
|
|
}
|
|
|
|
|
|
|
|
DR_Rule* DR_State::ParseRule(FILE* aFile)
|
|
|
|
{
|
|
|
|
char buf[128];
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t doDisplay;
|
2012-07-30 14:20:58 +00:00
|
|
|
DR_Rule* rule = nullptr;
|
2010-04-06 19:42:41 +00:00
|
|
|
while (GetToken(aFile, buf, sizeof(buf))) {
|
2001-10-29 01:43:59 +00:00
|
|
|
if (GetNumber(buf, doDisplay)) {
|
|
|
|
if (rule) {
|
2007-10-10 00:00:05 +00:00
|
|
|
rule->mDisplay = !!doDisplay;
|
2001-10-29 01:43:59 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("unexpected token - %s \n", buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (!rule) {
|
|
|
|
rule = new DR_Rule;
|
|
|
|
}
|
|
|
|
if (strcmp(buf, "*") == 0) {
|
2012-07-30 14:20:58 +00:00
|
|
|
rule->AddPart(nullptr);
|
2001-10-29 01:43:59 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
DR_FrameTypeInfo* info = GetFrameTypeInfo(buf);
|
|
|
|
if (info) {
|
|
|
|
rule->AddPart(info->mType);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("invalid frame type - %s \n", buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rule;
|
|
|
|
}
|
|
|
|
|
2009-02-03 14:42:18 +00:00
|
|
|
void DR_State::AddRule(nsTArray<DR_Rule*>& aRules,
|
|
|
|
DR_Rule& aRule)
|
2001-10-29 01:43:59 +00:00
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t numRules = aRules.Length();
|
|
|
|
for (int32_t ruleX = 0; ruleX < numRules; ruleX++) {
|
2009-02-03 14:42:18 +00:00
|
|
|
DR_Rule* rule = aRules.ElementAt(ruleX);
|
2001-10-29 01:43:59 +00:00
|
|
|
NS_ASSERTION(rule, "program error");
|
|
|
|
if (aRule.mLength > rule->mLength) {
|
2009-02-03 14:42:18 +00:00
|
|
|
aRules.InsertElementAt(ruleX, &aRule);
|
2001-10-29 01:43:59 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aRules.AppendElement(&aRule);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DR_State::ParseRulesFile()
|
|
|
|
{
|
|
|
|
char* path = PR_GetEnv("GECKO_DISPLAY_REFLOW_RULES_FILE");
|
|
|
|
if (path) {
|
|
|
|
FILE* inFile = fopen(path, "r");
|
|
|
|
if (inFile) {
|
|
|
|
for (DR_Rule* rule = ParseRule(inFile); rule; rule = ParseRule(inFile)) {
|
|
|
|
if (rule->mTarget) {
|
|
|
|
nsIAtom* fType = rule->mTarget->mFrameType;
|
|
|
|
if (fType) {
|
|
|
|
DR_FrameTypeInfo* info = GetFrameTypeInfo(fType);
|
|
|
|
if (info) {
|
|
|
|
AddRule(info->mRules, *rule);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
AddRule(mWildRules, *rule);
|
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
mActive = true;
|
2001-10-29 01:43:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DR_State::AddFrameTypeInfo(nsIAtom* aFrameType,
|
2004-02-06 23:11:46 +00:00
|
|
|
const char* aFrameNameAbbrev,
|
|
|
|
const char* aFrameName)
|
2001-10-29 01:43:59 +00:00
|
|
|
{
|
2009-03-12 07:26:29 +00:00
|
|
|
mFrameTypeTable.AppendElement(DR_FrameTypeInfo(aFrameType, aFrameNameAbbrev, aFrameName));
|
2001-10-29 01:43:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DR_FrameTypeInfo* DR_State::GetFrameTypeInfo(nsIAtom* aFrameType)
|
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t numEntries = mFrameTypeTable.Length();
|
2002-04-16 02:42:09 +00:00
|
|
|
NS_ASSERTION(numEntries != 0, "empty FrameTypeTable");
|
2012-08-22 15:56:38 +00:00
|
|
|
for (int32_t i = 0; i < numEntries; i++) {
|
2009-03-12 07:26:29 +00:00
|
|
|
DR_FrameTypeInfo& info = mFrameTypeTable.ElementAt(i);
|
|
|
|
if (info.mType == aFrameType) {
|
|
|
|
return &info;
|
2001-10-29 01:43:59 +00:00
|
|
|
}
|
|
|
|
}
|
2009-03-12 07:26:29 +00:00
|
|
|
return &mFrameTypeTable.ElementAt(numEntries - 1); // return unknown frame type
|
2001-10-29 01:43:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DR_FrameTypeInfo* DR_State::GetFrameTypeInfo(char* aFrameName)
|
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t numEntries = mFrameTypeTable.Length();
|
2002-04-16 02:42:09 +00:00
|
|
|
NS_ASSERTION(numEntries != 0, "empty FrameTypeTable");
|
2012-08-22 15:56:38 +00:00
|
|
|
for (int32_t i = 0; i < numEntries; i++) {
|
2009-03-12 07:26:29 +00:00
|
|
|
DR_FrameTypeInfo& info = mFrameTypeTable.ElementAt(i);
|
|
|
|
if ((strcmp(aFrameName, info.mName) == 0) || (strcmp(aFrameName, info.mNameAbbrev) == 0)) {
|
|
|
|
return &info;
|
2001-10-29 01:43:59 +00:00
|
|
|
}
|
|
|
|
}
|
2009-03-12 07:26:29 +00:00
|
|
|
return &mFrameTypeTable.ElementAt(numEntries - 1); // return unknown frame type
|
2001-10-29 01:43:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DR_State::InitFrameTypeTable()
|
|
|
|
{
|
2006-12-26 17:47:52 +00:00
|
|
|
AddFrameTypeInfo(nsGkAtoms::blockFrame, "block", "block");
|
|
|
|
AddFrameTypeInfo(nsGkAtoms::brFrame, "br", "br");
|
|
|
|
AddFrameTypeInfo(nsGkAtoms::bulletFrame, "bullet", "bullet");
|
|
|
|
AddFrameTypeInfo(nsGkAtoms::gfxButtonControlFrame, "button", "gfxButtonControl");
|
|
|
|
AddFrameTypeInfo(nsGkAtoms::HTMLButtonControlFrame, "HTMLbutton", "HTMLButtonControl");
|
|
|
|
AddFrameTypeInfo(nsGkAtoms::HTMLCanvasFrame, "HTMLCanvas","HTMLCanvas");
|
|
|
|
AddFrameTypeInfo(nsGkAtoms::subDocumentFrame, "subdoc", "subDocument");
|
|
|
|
AddFrameTypeInfo(nsGkAtoms::imageFrame, "img", "image");
|
|
|
|
AddFrameTypeInfo(nsGkAtoms::inlineFrame, "inline", "inline");
|
|
|
|
AddFrameTypeInfo(nsGkAtoms::letterFrame, "letter", "letter");
|
|
|
|
AddFrameTypeInfo(nsGkAtoms::lineFrame, "line", "line");
|
|
|
|
AddFrameTypeInfo(nsGkAtoms::listControlFrame, "select", "select");
|
|
|
|
AddFrameTypeInfo(nsGkAtoms::objectFrame, "obj", "object");
|
|
|
|
AddFrameTypeInfo(nsGkAtoms::pageFrame, "page", "page");
|
|
|
|
AddFrameTypeInfo(nsGkAtoms::placeholderFrame, "place", "placeholder");
|
|
|
|
AddFrameTypeInfo(nsGkAtoms::canvasFrame, "canvas", "canvas");
|
|
|
|
AddFrameTypeInfo(nsGkAtoms::rootFrame, "root", "root");
|
|
|
|
AddFrameTypeInfo(nsGkAtoms::scrollFrame, "scroll", "scroll");
|
|
|
|
AddFrameTypeInfo(nsGkAtoms::tableCaptionFrame, "caption", "tableCaption");
|
|
|
|
AddFrameTypeInfo(nsGkAtoms::tableCellFrame, "cell", "tableCell");
|
|
|
|
AddFrameTypeInfo(nsGkAtoms::bcTableCellFrame, "bcCell", "bcTableCell");
|
|
|
|
AddFrameTypeInfo(nsGkAtoms::tableColFrame, "col", "tableCol");
|
|
|
|
AddFrameTypeInfo(nsGkAtoms::tableColGroupFrame, "colG", "tableColGroup");
|
|
|
|
AddFrameTypeInfo(nsGkAtoms::tableFrame, "tbl", "table");
|
|
|
|
AddFrameTypeInfo(nsGkAtoms::tableOuterFrame, "tblO", "tableOuter");
|
|
|
|
AddFrameTypeInfo(nsGkAtoms::tableRowGroupFrame, "rowG", "tableRowGroup");
|
|
|
|
AddFrameTypeInfo(nsGkAtoms::tableRowFrame, "row", "tableRow");
|
|
|
|
AddFrameTypeInfo(nsGkAtoms::textInputFrame, "textCtl", "textInput");
|
|
|
|
AddFrameTypeInfo(nsGkAtoms::textFrame, "text", "text");
|
|
|
|
AddFrameTypeInfo(nsGkAtoms::viewportFrame, "VP", "viewport");
|
2008-12-29 15:07:38 +00:00
|
|
|
#ifdef MOZ_XUL
|
|
|
|
AddFrameTypeInfo(nsGkAtoms::XULLabelFrame, "XULLabel", "XULLabel");
|
2010-05-01 21:40:16 +00:00
|
|
|
AddFrameTypeInfo(nsGkAtoms::boxFrame, "Box", "Box");
|
|
|
|
AddFrameTypeInfo(nsGkAtoms::sliderFrame, "Slider", "Slider");
|
|
|
|
AddFrameTypeInfo(nsGkAtoms::popupSetFrame, "PopupSet", "PopupSet");
|
2008-12-29 15:07:38 +00:00
|
|
|
#endif
|
2012-07-30 14:20:58 +00:00
|
|
|
AddFrameTypeInfo(nullptr, "unknown", "unknown");
|
2001-10-29 01:43:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DR_State::DisplayFrameTypeInfo(nsIFrame* aFrame,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aIndent)
|
2001-10-29 01:43:59 +00:00
|
|
|
{
|
2003-10-31 20:19:18 +00:00
|
|
|
DR_FrameTypeInfo* frameTypeInfo = GetFrameTypeInfo(aFrame->GetType());
|
2001-10-29 01:43:59 +00:00
|
|
|
if (frameTypeInfo) {
|
2012-08-22 15:56:38 +00:00
|
|
|
for (int32_t i = 0; i < aIndent; i++) {
|
2001-10-29 01:43:59 +00:00
|
|
|
printf(" ");
|
|
|
|
}
|
2002-04-16 02:42:09 +00:00
|
|
|
if(!strcmp(frameTypeInfo->mNameAbbrev, "unknown")) {
|
2009-08-20 21:52:48 +00:00
|
|
|
if (aFrame) {
|
|
|
|
nsAutoString name;
|
|
|
|
aFrame->GetFrameName(name);
|
2006-02-03 14:18:39 +00:00
|
|
|
printf("%s %p ", NS_LossyConvertUTF16toASCII(name).get(), (void*)aFrame);
|
2001-12-07 10:02:31 +00:00
|
|
|
}
|
|
|
|
else {
|
2002-08-24 14:41:28 +00:00
|
|
|
printf("%s %p ", frameTypeInfo->mNameAbbrev, (void*)aFrame);
|
2001-12-07 10:02:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2002-08-24 14:41:28 +00:00
|
|
|
printf("%s %p ", frameTypeInfo->mNameAbbrev, (void*)aFrame);
|
2001-12-07 10:02:31 +00:00
|
|
|
}
|
2001-10-29 01:43:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool DR_State::RuleMatches(DR_Rule& aRule,
|
2001-10-29 01:43:59 +00:00
|
|
|
DR_FrameTreeNode& aNode)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aRule.mTarget, "program error");
|
|
|
|
|
|
|
|
DR_RulePart* rulePart;
|
|
|
|
DR_FrameTreeNode* parentNode;
|
|
|
|
for (rulePart = aRule.mTarget->mNext, parentNode = aNode.mParent;
|
|
|
|
rulePart && parentNode;
|
|
|
|
rulePart = rulePart->mNext, parentNode = parentNode->mParent) {
|
|
|
|
if (rulePart->mFrameType) {
|
|
|
|
if (parentNode->mFrame) {
|
2003-10-31 20:19:18 +00:00
|
|
|
if (rulePart->mFrameType != parentNode->mFrame->GetType()) {
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2001-10-29 01:43:59 +00:00
|
|
|
}
|
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
else NS_ASSERTION(false, "program error");
|
2001-10-29 01:43:59 +00:00
|
|
|
}
|
|
|
|
// else wild card match
|
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2001-10-29 01:43:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DR_State::FindMatchingRule(DR_FrameTreeNode& aNode)
|
|
|
|
{
|
|
|
|
if (!aNode.mFrame) {
|
2011-10-17 14:59:28 +00:00
|
|
|
NS_ASSERTION(false, "invalid DR_FrameTreeNode \n");
|
2001-10-29 01:43:59 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool matchingRule = false;
|
2001-10-29 01:43:59 +00:00
|
|
|
|
2003-10-31 20:19:18 +00:00
|
|
|
DR_FrameTypeInfo* info = GetFrameTypeInfo(aNode.mFrame->GetType());
|
2001-10-29 01:43:59 +00:00
|
|
|
NS_ASSERTION(info, "program error");
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t numRules = info->mRules.Length();
|
|
|
|
for (int32_t ruleX = 0; ruleX < numRules; ruleX++) {
|
2009-02-03 14:42:18 +00:00
|
|
|
DR_Rule* rule = info->mRules.ElementAt(ruleX);
|
2001-10-29 01:43:59 +00:00
|
|
|
if (rule && RuleMatches(*rule, aNode)) {
|
|
|
|
aNode.mDisplay = rule->mDisplay;
|
2011-10-17 14:59:28 +00:00
|
|
|
matchingRule = true;
|
2001-10-29 01:43:59 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!matchingRule) {
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t numWildRules = mWildRules.Length();
|
|
|
|
for (int32_t ruleX = 0; ruleX < numWildRules; ruleX++) {
|
2009-02-03 14:42:18 +00:00
|
|
|
DR_Rule* rule = mWildRules.ElementAt(ruleX);
|
2001-10-29 01:43:59 +00:00
|
|
|
if (rule && RuleMatches(*rule, aNode)) {
|
|
|
|
aNode.mDisplay = rule->mDisplay;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DR_FrameTreeNode* DR_State::CreateTreeNode(nsIFrame* aFrame,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
const nsHTMLReflowState* aReflowState)
|
2001-10-29 01:43:59 +00:00
|
|
|
{
|
|
|
|
// find the frame of the parent reflow state (usually just the parent of aFrame)
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsIFrame* parentFrame;
|
|
|
|
if (aReflowState) {
|
|
|
|
const nsHTMLReflowState* parentRS = aReflowState->parentReflowState;
|
2012-07-30 14:20:58 +00:00
|
|
|
parentFrame = (parentRS) ? parentRS->frame : nullptr;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
} else {
|
|
|
|
parentFrame = aFrame->GetParent();
|
|
|
|
}
|
2001-10-29 01:43:59 +00:00
|
|
|
|
|
|
|
// find the parent tree node leaf
|
2012-07-30 14:20:58 +00:00
|
|
|
DR_FrameTreeNode* parentNode = nullptr;
|
2002-01-03 09:00:40 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
DR_FrameTreeNode* lastLeaf = nullptr;
|
2009-02-03 14:42:18 +00:00
|
|
|
if(mFrameTreeLeaves.Length())
|
2009-03-12 07:26:29 +00:00
|
|
|
lastLeaf = mFrameTreeLeaves.ElementAt(mFrameTreeLeaves.Length() - 1);
|
2001-10-29 01:43:59 +00:00
|
|
|
if (lastLeaf) {
|
|
|
|
for (parentNode = lastLeaf; parentNode && (parentNode->mFrame != parentFrame); parentNode = parentNode->mParent) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DR_FrameTreeNode* newNode = new DR_FrameTreeNode(aFrame, parentNode);
|
|
|
|
FindMatchingRule(*newNode);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
|
|
|
newNode->mIndent = mIndent;
|
|
|
|
if (newNode->mDisplay || mIndentUndisplayedFrames) {
|
|
|
|
++mIndent;
|
|
|
|
}
|
|
|
|
|
2002-01-03 09:00:40 +00:00
|
|
|
if (lastLeaf && (lastLeaf == parentNode)) {
|
2009-02-03 14:42:18 +00:00
|
|
|
mFrameTreeLeaves.RemoveElementAt(mFrameTreeLeaves.Length() - 1);
|
2001-10-29 01:43:59 +00:00
|
|
|
}
|
|
|
|
mFrameTreeLeaves.AppendElement(newNode);
|
|
|
|
mCount++;
|
|
|
|
|
|
|
|
return newNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DR_State::PrettyUC(nscoord aSize,
|
|
|
|
char* aBuf)
|
|
|
|
{
|
|
|
|
if (NS_UNCONSTRAINEDSIZE == aSize) {
|
|
|
|
strcpy(aBuf, "UC");
|
|
|
|
}
|
|
|
|
else {
|
2004-01-09 14:20:53 +00:00
|
|
|
if ((nscoord)0xdeadbeefU == aSize)
|
2001-12-07 10:02:31 +00:00
|
|
|
{
|
|
|
|
strcpy(aBuf, "deadbeef");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
sprintf(aBuf, "%d", aSize);
|
|
|
|
}
|
2001-10-29 01:43:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-01 21:40:16 +00:00
|
|
|
void DR_State::PrintMargin(const char *tag, const nsMargin* aMargin)
|
|
|
|
{
|
|
|
|
if (aMargin) {
|
|
|
|
char t[16], r[16], b[16], l[16];
|
|
|
|
PrettyUC(aMargin->top, t);
|
|
|
|
PrettyUC(aMargin->right, r);
|
|
|
|
PrettyUC(aMargin->bottom, b);
|
|
|
|
PrettyUC(aMargin->left, l);
|
|
|
|
printf(" %s=%s,%s,%s,%s", tag, t, r, b, l);
|
|
|
|
} else {
|
|
|
|
// use %p here for consistency with other null-pointer printouts
|
|
|
|
printf(" %s=%p", tag, (void*)aMargin);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-10-29 01:43:59 +00:00
|
|
|
void DR_State::DeleteTreeNode(DR_FrameTreeNode& aNode)
|
|
|
|
{
|
|
|
|
mFrameTreeLeaves.RemoveElement(&aNode);
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t numLeaves = mFrameTreeLeaves.Length();
|
2009-02-03 14:42:18 +00:00
|
|
|
if ((0 == numLeaves) || (aNode.mParent != mFrameTreeLeaves.ElementAt(numLeaves - 1))) {
|
2001-10-29 01:43:59 +00:00
|
|
|
mFrameTreeLeaves.AppendElement(aNode.mParent);
|
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
|
|
|
if (aNode.mDisplay || mIndentUndisplayedFrames) {
|
|
|
|
--mIndent;
|
|
|
|
}
|
2001-10-29 01:43:59 +00:00
|
|
|
// delete the tree node
|
|
|
|
delete &aNode;
|
|
|
|
}
|
|
|
|
|
2001-11-14 13:40:03 +00:00
|
|
|
static void
|
|
|
|
CheckPixelError(nscoord aSize,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aPixelToTwips)
|
2001-11-14 13:40:03 +00:00
|
|
|
{
|
|
|
|
if (NS_UNCONSTRAINEDSIZE != aSize) {
|
2007-02-07 07:46:44 +00:00
|
|
|
if ((aSize % aPixelToTwips) > 0) {
|
2001-11-14 13:40:03 +00:00
|
|
|
printf("VALUE %d is not a whole pixel \n", aSize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
static void DisplayReflowEnterPrint(nsPresContext* aPresContext,
|
2001-11-27 01:45:46 +00:00
|
|
|
nsIFrame* aFrame,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
DR_FrameTreeNode& aTreeNode,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aChanged)
|
2001-10-29 01:43:59 +00:00
|
|
|
{
|
2001-11-27 01:45:46 +00:00
|
|
|
if (aTreeNode.mDisplay) {
|
2003-03-22 15:09:17 +00:00
|
|
|
DR_state->DisplayFrameTypeInfo(aFrame, aTreeNode.mIndent);
|
2001-10-29 01:43:59 +00:00
|
|
|
|
|
|
|
char width[16];
|
|
|
|
char height[16];
|
2003-04-06 08:36:19 +00:00
|
|
|
|
2003-03-22 15:09:17 +00:00
|
|
|
DR_state->PrettyUC(aReflowState.availableWidth, width);
|
|
|
|
DR_state->PrettyUC(aReflowState.availableHeight, height);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
printf("Reflow a=%s,%s ", width, height);
|
2001-10-29 01:43:59 +00:00
|
|
|
|
2007-01-26 00:05:12 +00:00
|
|
|
DR_state->PrettyUC(aReflowState.ComputedWidth(), width);
|
2007-08-02 18:08:05 +00:00
|
|
|
DR_state->PrettyUC(aReflowState.ComputedHeight(), height);
|
2001-10-29 01:43:59 +00:00
|
|
|
printf("c=%s,%s ", width, height);
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
if (aFrame->GetStateBits() & NS_FRAME_IS_DIRTY)
|
|
|
|
printf("dirty ");
|
|
|
|
|
|
|
|
if (aFrame->GetStateBits() & NS_FRAME_HAS_DIRTY_CHILDREN)
|
|
|
|
printf("dirty-children ");
|
|
|
|
|
|
|
|
if (aReflowState.mFlags.mSpecialHeightReflow)
|
|
|
|
printf("special-height ");
|
|
|
|
|
|
|
|
if (aReflowState.mFlags.mHResize)
|
|
|
|
printf("h-resize ");
|
|
|
|
|
|
|
|
if (aReflowState.mFlags.mVResize)
|
|
|
|
printf("v-resize ");
|
|
|
|
|
2004-09-14 02:28:03 +00:00
|
|
|
nsIFrame* inFlow = aFrame->GetPrevInFlow();
|
2001-10-29 01:43:59 +00:00
|
|
|
if (inFlow) {
|
2002-08-24 14:41:28 +00:00
|
|
|
printf("pif=%p ", (void*)inFlow);
|
2001-10-29 01:43:59 +00:00
|
|
|
}
|
2004-09-14 02:28:03 +00:00
|
|
|
inFlow = aFrame->GetNextInFlow();
|
2001-10-29 01:43:59 +00:00
|
|
|
if (inFlow) {
|
2002-08-24 14:41:28 +00:00
|
|
|
printf("nif=%p ", (void*)inFlow);
|
2001-10-29 01:43:59 +00:00
|
|
|
}
|
2001-11-27 01:45:46 +00:00
|
|
|
if (aChanged)
|
|
|
|
printf("CHANGED \n");
|
|
|
|
else
|
2003-03-22 15:09:17 +00:00
|
|
|
printf("cnt=%d \n", DR_state->mCount);
|
|
|
|
if (DR_state->mDisplayPixelErrors) {
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t p2t = aPresContext->AppUnitsPerDevPixel();
|
2001-11-14 13:40:03 +00:00
|
|
|
CheckPixelError(aReflowState.availableWidth, p2t);
|
|
|
|
CheckPixelError(aReflowState.availableHeight, p2t);
|
2007-01-26 00:05:12 +00:00
|
|
|
CheckPixelError(aReflowState.ComputedWidth(), p2t);
|
2007-08-02 18:08:05 +00:00
|
|
|
CheckPixelError(aReflowState.ComputedHeight(), p2t);
|
2001-11-14 13:40:03 +00:00
|
|
|
}
|
2001-10-29 01:43:59 +00:00
|
|
|
}
|
2001-11-27 01:45:46 +00:00
|
|
|
}
|
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
void* nsFrame::DisplayReflowEnter(nsPresContext* aPresContext,
|
2001-11-27 01:45:46 +00:00
|
|
|
nsIFrame* aFrame,
|
|
|
|
const nsHTMLReflowState& aReflowState)
|
|
|
|
{
|
2003-03-22 15:09:17 +00:00
|
|
|
if (!DR_state->mInited) DR_state->Init();
|
2012-07-30 14:20:58 +00:00
|
|
|
if (!DR_state->mActive) return nullptr;
|
2001-11-27 01:45:46 +00:00
|
|
|
|
|
|
|
NS_ASSERTION(aFrame, "invalid call");
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
DR_FrameTreeNode* treeNode = DR_state->CreateTreeNode(aFrame, &aReflowState);
|
2001-11-27 01:45:46 +00:00
|
|
|
if (treeNode) {
|
2011-10-17 14:59:28 +00:00
|
|
|
DisplayReflowEnterPrint(aPresContext, aFrame, aReflowState, *treeNode, false);
|
2001-11-27 01:45:46 +00:00
|
|
|
}
|
2001-10-29 01:43:59 +00:00
|
|
|
return treeNode;
|
|
|
|
}
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
void* nsFrame::DisplayLayoutEnter(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
if (!DR_state->mInited) DR_state->Init();
|
2012-07-30 14:20:58 +00:00
|
|
|
if (!DR_state->mActive) return nullptr;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
|
|
|
NS_ASSERTION(aFrame, "invalid call");
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
DR_FrameTreeNode* treeNode = DR_state->CreateTreeNode(aFrame, nullptr);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
if (treeNode && treeNode->mDisplay) {
|
|
|
|
DR_state->DisplayFrameTypeInfo(aFrame, treeNode->mIndent);
|
|
|
|
printf("Layout\n");
|
|
|
|
}
|
|
|
|
return treeNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
void* nsFrame::DisplayIntrinsicWidthEnter(nsIFrame* aFrame,
|
|
|
|
const char* aType)
|
|
|
|
{
|
|
|
|
if (!DR_state->mInited) DR_state->Init();
|
2012-07-30 14:20:58 +00:00
|
|
|
if (!DR_state->mActive) return nullptr;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
|
|
|
NS_ASSERTION(aFrame, "invalid call");
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
DR_FrameTreeNode* treeNode = DR_state->CreateTreeNode(aFrame, nullptr);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
if (treeNode && treeNode->mDisplay) {
|
|
|
|
DR_state->DisplayFrameTypeInfo(aFrame, treeNode->mIndent);
|
|
|
|
printf("Get%sWidth\n", aType);
|
|
|
|
}
|
|
|
|
return treeNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
void* nsFrame::DisplayIntrinsicSizeEnter(nsIFrame* aFrame,
|
|
|
|
const char* aType)
|
|
|
|
{
|
|
|
|
if (!DR_state->mInited) DR_state->Init();
|
2012-07-30 14:20:58 +00:00
|
|
|
if (!DR_state->mActive) return nullptr;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
|
|
|
NS_ASSERTION(aFrame, "invalid call");
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
DR_FrameTreeNode* treeNode = DR_state->CreateTreeNode(aFrame, nullptr);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
if (treeNode && treeNode->mDisplay) {
|
|
|
|
DR_state->DisplayFrameTypeInfo(aFrame, treeNode->mIndent);
|
|
|
|
printf("Get%sSize\n", aType);
|
|
|
|
}
|
|
|
|
return treeNode;
|
|
|
|
}
|
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
void nsFrame::DisplayReflowExit(nsPresContext* aPresContext,
|
2001-11-14 13:40:03 +00:00
|
|
|
nsIFrame* aFrame,
|
2001-10-29 01:43:59 +00:00
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
nsReflowStatus aStatus,
|
|
|
|
void* aFrameTreeNode)
|
|
|
|
{
|
2003-03-22 15:09:17 +00:00
|
|
|
if (!DR_state->mActive) return;
|
2001-10-29 01:43:59 +00:00
|
|
|
|
|
|
|
NS_ASSERTION(aFrame, "DisplayReflowExit - invalid call");
|
|
|
|
if (!aFrameTreeNode) return;
|
|
|
|
|
|
|
|
DR_FrameTreeNode* treeNode = (DR_FrameTreeNode*)aFrameTreeNode;
|
|
|
|
if (treeNode->mDisplay) {
|
2003-03-22 15:09:17 +00:00
|
|
|
DR_state->DisplayFrameTypeInfo(aFrame, treeNode->mIndent);
|
2001-10-29 01:43:59 +00:00
|
|
|
|
|
|
|
char width[16];
|
|
|
|
char height[16];
|
2003-04-06 08:36:19 +00:00
|
|
|
char x[16];
|
|
|
|
char y[16];
|
2003-03-22 15:09:17 +00:00
|
|
|
DR_state->PrettyUC(aMetrics.width, width);
|
|
|
|
DR_state->PrettyUC(aMetrics.height, height);
|
2009-01-29 20:39:22 +00:00
|
|
|
printf("Reflow d=%s,%s", width, height);
|
2001-10-29 01:43:59 +00:00
|
|
|
|
2007-07-26 04:03:29 +00:00
|
|
|
if (!NS_FRAME_IS_FULLY_COMPLETE(aStatus)) {
|
2009-01-29 20:39:22 +00:00
|
|
|
printf(" status=0x%x", aStatus);
|
2003-04-06 08:36:19 +00:00
|
|
|
}
|
2010-10-07 04:25:47 +00:00
|
|
|
if (aFrame->HasOverflowAreas()) {
|
|
|
|
DR_state->PrettyUC(aMetrics.VisualOverflow().x, x);
|
|
|
|
DR_state->PrettyUC(aMetrics.VisualOverflow().y, y);
|
|
|
|
DR_state->PrettyUC(aMetrics.VisualOverflow().width, width);
|
|
|
|
DR_state->PrettyUC(aMetrics.VisualOverflow().height, height);
|
|
|
|
printf(" vis-o=(%s,%s) %s x %s", x, y, width, height);
|
|
|
|
|
|
|
|
nsRect storedOverflow = aFrame->GetVisualOverflowRect();
|
|
|
|
DR_state->PrettyUC(storedOverflow.x, x);
|
|
|
|
DR_state->PrettyUC(storedOverflow.y, y);
|
|
|
|
DR_state->PrettyUC(storedOverflow.width, width);
|
|
|
|
DR_state->PrettyUC(storedOverflow.height, height);
|
|
|
|
printf(" vis-sto=(%s,%s) %s x %s", x, y, width, height);
|
|
|
|
|
|
|
|
DR_state->PrettyUC(aMetrics.ScrollableOverflow().x, x);
|
|
|
|
DR_state->PrettyUC(aMetrics.ScrollableOverflow().y, y);
|
|
|
|
DR_state->PrettyUC(aMetrics.ScrollableOverflow().width, width);
|
|
|
|
DR_state->PrettyUC(aMetrics.ScrollableOverflow().height, height);
|
|
|
|
printf(" scr-o=(%s,%s) %s x %s", x, y, width, height);
|
2010-05-01 21:40:16 +00:00
|
|
|
|
2010-10-07 04:25:47 +00:00
|
|
|
storedOverflow = aFrame->GetScrollableOverflowRect();
|
2010-05-01 21:40:16 +00:00
|
|
|
DR_state->PrettyUC(storedOverflow.x, x);
|
|
|
|
DR_state->PrettyUC(storedOverflow.y, y);
|
|
|
|
DR_state->PrettyUC(storedOverflow.width, width);
|
|
|
|
DR_state->PrettyUC(storedOverflow.height, height);
|
2010-10-07 04:25:47 +00:00
|
|
|
printf(" scr-sto=(%s,%s) %s x %s", x, y, width, height);
|
2001-10-29 01:43:59 +00:00
|
|
|
}
|
|
|
|
printf("\n");
|
2003-03-22 15:09:17 +00:00
|
|
|
if (DR_state->mDisplayPixelErrors) {
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t p2t = aPresContext->AppUnitsPerDevPixel();
|
2001-11-14 13:40:03 +00:00
|
|
|
CheckPixelError(aMetrics.width, p2t);
|
|
|
|
CheckPixelError(aMetrics.height, p2t);
|
|
|
|
}
|
2001-10-29 01:43:59 +00:00
|
|
|
}
|
2003-03-22 15:09:17 +00:00
|
|
|
DR_state->DeleteTreeNode(*treeNode);
|
|
|
|
}
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
void nsFrame::DisplayLayoutExit(nsIFrame* aFrame,
|
|
|
|
void* aFrameTreeNode)
|
|
|
|
{
|
|
|
|
if (!DR_state->mActive) return;
|
|
|
|
|
|
|
|
NS_ASSERTION(aFrame, "non-null frame required");
|
|
|
|
if (!aFrameTreeNode) return;
|
|
|
|
|
|
|
|
DR_FrameTreeNode* treeNode = (DR_FrameTreeNode*)aFrameTreeNode;
|
|
|
|
if (treeNode->mDisplay) {
|
|
|
|
DR_state->DisplayFrameTypeInfo(aFrame, treeNode->mIndent);
|
|
|
|
nsRect rect = aFrame->GetRect();
|
|
|
|
printf("Layout=%d,%d,%d,%d\n", rect.x, rect.y, rect.width, rect.height);
|
|
|
|
}
|
|
|
|
DR_state->DeleteTreeNode(*treeNode);
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsFrame::DisplayIntrinsicWidthExit(nsIFrame* aFrame,
|
|
|
|
const char* aType,
|
|
|
|
nscoord aResult,
|
|
|
|
void* aFrameTreeNode)
|
|
|
|
{
|
|
|
|
if (!DR_state->mActive) return;
|
|
|
|
|
|
|
|
NS_ASSERTION(aFrame, "non-null frame required");
|
|
|
|
if (!aFrameTreeNode) return;
|
|
|
|
|
|
|
|
DR_FrameTreeNode* treeNode = (DR_FrameTreeNode*)aFrameTreeNode;
|
|
|
|
if (treeNode->mDisplay) {
|
|
|
|
DR_state->DisplayFrameTypeInfo(aFrame, treeNode->mIndent);
|
2010-01-09 15:33:03 +00:00
|
|
|
char width[16];
|
|
|
|
DR_state->PrettyUC(aResult, width);
|
|
|
|
printf("Get%sWidth=%s\n", aType, width);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
}
|
|
|
|
DR_state->DeleteTreeNode(*treeNode);
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsFrame::DisplayIntrinsicSizeExit(nsIFrame* aFrame,
|
|
|
|
const char* aType,
|
|
|
|
nsSize aResult,
|
|
|
|
void* aFrameTreeNode)
|
|
|
|
{
|
|
|
|
if (!DR_state->mActive) return;
|
|
|
|
|
|
|
|
NS_ASSERTION(aFrame, "non-null frame required");
|
|
|
|
if (!aFrameTreeNode) return;
|
|
|
|
|
|
|
|
DR_FrameTreeNode* treeNode = (DR_FrameTreeNode*)aFrameTreeNode;
|
|
|
|
if (treeNode->mDisplay) {
|
|
|
|
DR_state->DisplayFrameTypeInfo(aFrame, treeNode->mIndent);
|
|
|
|
|
|
|
|
char width[16];
|
|
|
|
char height[16];
|
|
|
|
DR_state->PrettyUC(aResult.width, width);
|
|
|
|
DR_state->PrettyUC(aResult.height, height);
|
|
|
|
printf("Get%sSize=%s,%s\n", aType, width, height);
|
|
|
|
}
|
|
|
|
DR_state->DeleteTreeNode(*treeNode);
|
|
|
|
}
|
|
|
|
|
2003-03-22 15:09:17 +00:00
|
|
|
/* static */ void
|
|
|
|
nsFrame::DisplayReflowStartup()
|
|
|
|
{
|
|
|
|
DR_state = new DR_State();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ void
|
|
|
|
nsFrame::DisplayReflowShutdown()
|
|
|
|
{
|
|
|
|
delete DR_state;
|
2012-07-30 14:20:58 +00:00
|
|
|
DR_state = nullptr;
|
2001-10-29 01:43:59 +00:00
|
|
|
}
|
|
|
|
|
2001-11-27 01:45:46 +00:00
|
|
|
void DR_cookie::Change() const
|
|
|
|
{
|
|
|
|
DR_FrameTreeNode* treeNode = (DR_FrameTreeNode*)mValue;
|
|
|
|
if (treeNode && treeNode->mDisplay) {
|
2011-10-17 14:59:28 +00:00
|
|
|
DisplayReflowEnterPrint(mPresContext, mFrame, mReflowState, *treeNode, true);
|
2001-11-27 01:45:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-01 21:40:16 +00:00
|
|
|
/* static */ void*
|
|
|
|
nsHTMLReflowState::DisplayInitConstraintsEnter(nsIFrame* aFrame,
|
|
|
|
nsHTMLReflowState* aState,
|
|
|
|
nscoord aContainingBlockWidth,
|
|
|
|
nscoord aContainingBlockHeight,
|
|
|
|
const nsMargin* aBorder,
|
|
|
|
const nsMargin* aPadding)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aFrame, "non-null frame required");
|
|
|
|
NS_PRECONDITION(aState, "non-null state required");
|
|
|
|
|
|
|
|
if (!DR_state->mInited) DR_state->Init();
|
2012-07-30 14:20:58 +00:00
|
|
|
if (!DR_state->mActive) return nullptr;
|
2010-05-01 21:40:16 +00:00
|
|
|
|
|
|
|
DR_FrameTreeNode* treeNode = DR_state->CreateTreeNode(aFrame, aState);
|
|
|
|
if (treeNode && treeNode->mDisplay) {
|
|
|
|
DR_state->DisplayFrameTypeInfo(aFrame, treeNode->mIndent);
|
|
|
|
|
|
|
|
printf("InitConstraints parent=%p",
|
|
|
|
(void*)aState->parentReflowState);
|
|
|
|
|
|
|
|
char width[16];
|
|
|
|
char height[16];
|
|
|
|
|
|
|
|
DR_state->PrettyUC(aContainingBlockWidth, width);
|
|
|
|
DR_state->PrettyUC(aContainingBlockHeight, height);
|
|
|
|
printf(" cb=%s,%s", width, height);
|
|
|
|
|
|
|
|
DR_state->PrettyUC(aState->availableWidth, width);
|
|
|
|
DR_state->PrettyUC(aState->availableHeight, height);
|
|
|
|
printf(" as=%s,%s", width, height);
|
|
|
|
|
|
|
|
DR_state->PrintMargin("b", aBorder);
|
|
|
|
DR_state->PrintMargin("p", aPadding);
|
|
|
|
putchar('\n');
|
|
|
|
}
|
|
|
|
return treeNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ void
|
|
|
|
nsHTMLReflowState::DisplayInitConstraintsExit(nsIFrame* aFrame,
|
|
|
|
nsHTMLReflowState* aState,
|
|
|
|
void* aValue)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aFrame, "non-null frame required");
|
|
|
|
NS_PRECONDITION(aState, "non-null state required");
|
|
|
|
|
|
|
|
if (!DR_state->mActive) return;
|
|
|
|
if (!aValue) return;
|
|
|
|
|
|
|
|
DR_FrameTreeNode* treeNode = (DR_FrameTreeNode*)aValue;
|
|
|
|
if (treeNode->mDisplay) {
|
|
|
|
DR_state->DisplayFrameTypeInfo(aFrame, treeNode->mIndent);
|
|
|
|
char cmiw[16], cw[16], cmxw[16], cmih[16], ch[16], cmxh[16];
|
|
|
|
DR_state->PrettyUC(aState->mComputedMinWidth, cmiw);
|
|
|
|
DR_state->PrettyUC(aState->mComputedWidth, cw);
|
|
|
|
DR_state->PrettyUC(aState->mComputedMaxWidth, cmxw);
|
|
|
|
DR_state->PrettyUC(aState->mComputedMinHeight, cmih);
|
|
|
|
DR_state->PrettyUC(aState->mComputedHeight, ch);
|
|
|
|
DR_state->PrettyUC(aState->mComputedMaxHeight, cmxh);
|
|
|
|
printf("InitConstraints= cw=(%s <= %s <= %s) ch=(%s <= %s <= %s)",
|
|
|
|
cmiw, cw, cmxw, cmih, ch, cmxh);
|
|
|
|
DR_state->PrintMargin("co", &aState->mComputedOffsets);
|
|
|
|
putchar('\n');
|
|
|
|
}
|
|
|
|
DR_state->DeleteTreeNode(*treeNode);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* static */ void*
|
|
|
|
nsCSSOffsetState::DisplayInitOffsetsEnter(nsIFrame* aFrame,
|
|
|
|
nsCSSOffsetState* aState,
|
|
|
|
nscoord aContainingBlockWidth,
|
|
|
|
const nsMargin* aBorder,
|
|
|
|
const nsMargin* aPadding)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aFrame, "non-null frame required");
|
|
|
|
NS_PRECONDITION(aState, "non-null state required");
|
|
|
|
|
|
|
|
if (!DR_state->mInited) DR_state->Init();
|
2012-07-30 14:20:58 +00:00
|
|
|
if (!DR_state->mActive) return nullptr;
|
2010-05-01 21:40:16 +00:00
|
|
|
|
|
|
|
// aState is not necessarily a nsHTMLReflowState
|
2012-07-30 14:20:58 +00:00
|
|
|
DR_FrameTreeNode* treeNode = DR_state->CreateTreeNode(aFrame, nullptr);
|
2010-05-01 21:40:16 +00:00
|
|
|
if (treeNode && treeNode->mDisplay) {
|
|
|
|
DR_state->DisplayFrameTypeInfo(aFrame, treeNode->mIndent);
|
|
|
|
|
|
|
|
char width[16];
|
|
|
|
DR_state->PrettyUC(aContainingBlockWidth, width);
|
|
|
|
printf("InitOffsets cbw=%s", width);
|
|
|
|
DR_state->PrintMargin("b", aBorder);
|
|
|
|
DR_state->PrintMargin("p", aPadding);
|
|
|
|
putchar('\n');
|
|
|
|
}
|
|
|
|
return treeNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ void
|
|
|
|
nsCSSOffsetState::DisplayInitOffsetsExit(nsIFrame* aFrame,
|
|
|
|
nsCSSOffsetState* aState,
|
|
|
|
void* aValue)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aFrame, "non-null frame required");
|
|
|
|
NS_PRECONDITION(aState, "non-null state required");
|
|
|
|
|
|
|
|
if (!DR_state->mActive) return;
|
|
|
|
if (!aValue) return;
|
|
|
|
|
|
|
|
DR_FrameTreeNode* treeNode = (DR_FrameTreeNode*)aValue;
|
|
|
|
if (treeNode->mDisplay) {
|
|
|
|
DR_state->DisplayFrameTypeInfo(aFrame, treeNode->mIndent);
|
|
|
|
printf("InitOffsets=");
|
|
|
|
DR_state->PrintMargin("m", &aState->mComputedMargin);
|
|
|
|
DR_state->PrintMargin("p", &aState->mComputedPadding);
|
|
|
|
DR_state->PrintMargin("p+b", &aState->mComputedBorderPadding);
|
|
|
|
putchar('\n');
|
|
|
|
}
|
|
|
|
DR_state->DeleteTreeNode(*treeNode);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ void*
|
|
|
|
nsHTMLReflowState::DisplayInitFrameTypeEnter(nsIFrame* aFrame,
|
|
|
|
nsHTMLReflowState* aState)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aFrame, "non-null frame required");
|
|
|
|
NS_PRECONDITION(aState, "non-null state required");
|
|
|
|
|
|
|
|
if (!DR_state->mInited) DR_state->Init();
|
2012-07-30 14:20:58 +00:00
|
|
|
if (!DR_state->mActive) return nullptr;
|
2010-05-01 21:40:16 +00:00
|
|
|
|
|
|
|
// we don't print anything here
|
|
|
|
return DR_state->CreateTreeNode(aFrame, aState);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ void
|
|
|
|
nsHTMLReflowState::DisplayInitFrameTypeExit(nsIFrame* aFrame,
|
|
|
|
nsHTMLReflowState* aState,
|
|
|
|
void* aValue)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aFrame, "non-null frame required");
|
|
|
|
NS_PRECONDITION(aState, "non-null state required");
|
|
|
|
|
|
|
|
if (!DR_state->mActive) return;
|
|
|
|
if (!aValue) return;
|
|
|
|
|
|
|
|
DR_FrameTreeNode* treeNode = (DR_FrameTreeNode*)aValue;
|
|
|
|
if (treeNode->mDisplay) {
|
|
|
|
DR_state->DisplayFrameTypeInfo(aFrame, treeNode->mIndent);
|
|
|
|
printf("InitFrameType");
|
|
|
|
|
|
|
|
const nsStyleDisplay *disp = aState->mStyleDisplay;
|
|
|
|
|
|
|
|
if (aFrame->GetStateBits() & NS_FRAME_OUT_OF_FLOW)
|
|
|
|
printf(" out-of-flow");
|
|
|
|
if (aFrame->GetPrevInFlow())
|
|
|
|
printf(" prev-in-flow");
|
2012-08-02 11:38:50 +00:00
|
|
|
if (aFrame->IsAbsolutelyPositioned())
|
2010-05-01 21:40:16 +00:00
|
|
|
printf(" abspos");
|
2012-08-02 11:38:49 +00:00
|
|
|
if (aFrame->IsFloating())
|
2010-05-01 21:40:16 +00:00
|
|
|
printf(" float");
|
|
|
|
|
|
|
|
// This array must exactly match the NS_STYLE_DISPLAY constants.
|
|
|
|
const char *const displayTypes[] = {
|
|
|
|
"none", "block", "inline", "inline-block", "list-item", "marker",
|
|
|
|
"run-in", "compact", "table", "inline-table", "table-row-group",
|
|
|
|
"table-column", "table-column-group", "table-header-group",
|
|
|
|
"table-footer-group", "table-row", "table-cell", "table-caption",
|
|
|
|
"box", "inline-box",
|
|
|
|
#ifdef MOZ_XUL
|
|
|
|
"grid", "inline-grid", "grid-group", "grid-line", "stack",
|
|
|
|
"inline-stack", "deck", "popup", "groupbox",
|
|
|
|
#endif
|
|
|
|
};
|
2011-10-11 05:50:08 +00:00
|
|
|
if (disp->mDisplay >= ArrayLength(displayTypes))
|
2010-05-01 21:40:16 +00:00
|
|
|
printf(" display=%u", disp->mDisplay);
|
|
|
|
else
|
|
|
|
printf(" display=%s", displayTypes[disp->mDisplay]);
|
|
|
|
|
|
|
|
// This array must exactly match the NS_CSS_FRAME_TYPE constants.
|
|
|
|
const char *const cssFrameTypes[] = {
|
|
|
|
"unknown", "inline", "block", "floating", "absolute", "internal-table"
|
|
|
|
};
|
|
|
|
nsCSSFrameType bareType = NS_FRAME_GET_TYPE(aState->mFrameType);
|
|
|
|
bool repNoBlock = NS_FRAME_IS_REPLACED_NOBLOCK(aState->mFrameType);
|
|
|
|
bool repBlock = NS_FRAME_IS_REPLACED_CONTAINS_BLOCK(aState->mFrameType);
|
|
|
|
|
2011-10-11 05:50:08 +00:00
|
|
|
if (bareType >= ArrayLength(cssFrameTypes)) {
|
2010-05-01 21:40:16 +00:00
|
|
|
printf(" result=type %u", bareType);
|
|
|
|
} else {
|
|
|
|
printf(" result=%s", cssFrameTypes[bareType]);
|
|
|
|
}
|
|
|
|
printf("%s%s\n", repNoBlock ? " +rep" : "", repBlock ? " +repBlk" : "");
|
|
|
|
}
|
|
|
|
DR_state->DeleteTreeNode(*treeNode);
|
|
|
|
}
|
|
|
|
|
2001-10-29 01:43:59 +00:00
|
|
|
#endif
|
|
|
|
// End Display Reflow
|
|
|
|
|
1998-05-20 16:24:13 +00:00
|
|
|
#endif
|