2000-03-31 07:02:06 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Netscape Public
|
|
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape Communications
|
|
|
|
* Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
2000-06-06 01:25:03 +00:00
|
|
|
* Author: Eric D Vaughan <evaughan@netscape.com>
|
|
|
|
*
|
2000-03-31 07:02:06 +00:00
|
|
|
* Contributor(s):
|
|
|
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "nsBoxLayoutState.h"
|
|
|
|
#include "nsBox.h"
|
|
|
|
#include "nsBoxFrame.h"
|
|
|
|
#include "nsIStyleContext.h"
|
|
|
|
#include "nsIPresContext.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsIViewManager.h"
|
|
|
|
#include "nsIView.h"
|
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsHTMLContainerFrame.h"
|
|
|
|
#include "nsINameSpaceManager.h"
|
|
|
|
#include "nsHTMLAtoms.h"
|
|
|
|
#include "nsXULAtoms.h"
|
2000-06-02 22:15:09 +00:00
|
|
|
#include "nsIDOMNode.h"
|
|
|
|
#include "nsIDOMNamedNodeMap.h"
|
|
|
|
#include "nsIDOMAttr.h"
|
2001-07-16 02:40:48 +00:00
|
|
|
#include "nsIWidget.h"
|
2000-06-02 22:15:09 +00:00
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2000-06-06 01:25:03 +00:00
|
|
|
//#define DEBUG_LAYOUT
|
2000-04-25 07:10:48 +00:00
|
|
|
|
2000-05-15 04:12:31 +00:00
|
|
|
#ifdef DEBUG_COELESCED
|
2000-04-25 07:10:48 +00:00
|
|
|
static PRInt32 coelesced = 0;
|
2000-05-15 04:12:31 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
PRInt32 gIndent = 0;
|
|
|
|
PRInt32 gLayout = 0;
|
|
|
|
|
2000-06-06 01:25:03 +00:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2000-05-15 04:12:31 +00:00
|
|
|
void
|
|
|
|
nsBoxAddIndents()
|
|
|
|
{
|
|
|
|
for(PRInt32 i=0; i < gIndent; i++)
|
|
|
|
{
|
2000-10-28 22:17:53 +00:00
|
|
|
printf(" ");
|
2000-05-15 04:12:31 +00:00
|
|
|
}
|
|
|
|
}
|
2000-06-02 22:15:09 +00:00
|
|
|
#endif
|
2000-05-15 04:12:31 +00:00
|
|
|
|
|
|
|
void
|
2000-06-02 22:15:09 +00:00
|
|
|
nsBox::AppendAttribute(const nsAutoString& aAttribute, const nsAutoString& aValue, nsAutoString& aResult)
|
2000-05-15 04:12:31 +00:00
|
|
|
{
|
2000-06-02 22:15:09 +00:00
|
|
|
aResult.Append(aAttribute);
|
|
|
|
aResult.AppendWithConversion("='");
|
|
|
|
aResult.Append(aValue);
|
|
|
|
aResult.AppendWithConversion("' ");
|
2000-05-15 04:12:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBox::ListBox(nsAutoString& aResult)
|
|
|
|
{
|
|
|
|
nsAutoString name;
|
|
|
|
nsIFrame* frame;
|
|
|
|
GetFrame(&frame);
|
|
|
|
GetBoxName(name);
|
|
|
|
|
2000-06-02 22:15:09 +00:00
|
|
|
char addr[100];
|
|
|
|
sprintf(addr, "[@%p] ", frame);
|
|
|
|
|
|
|
|
aResult.AppendWithConversion(addr);
|
2000-05-15 04:12:31 +00:00
|
|
|
aResult.Append(name);
|
2000-06-02 22:15:09 +00:00
|
|
|
aResult.AppendWithConversion(" ");
|
2000-05-15 04:12:31 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> content;
|
|
|
|
frame->GetContent(getter_AddRefs(content));
|
|
|
|
|
2000-06-02 22:15:09 +00:00
|
|
|
// add on all the set attributes
|
2000-05-15 04:12:31 +00:00
|
|
|
if (content) {
|
2000-06-02 22:15:09 +00:00
|
|
|
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(content));
|
|
|
|
nsCOMPtr<nsIDOMNamedNodeMap> namedMap;
|
|
|
|
|
|
|
|
node->GetAttributes(getter_AddRefs(namedMap));
|
|
|
|
PRUint32 length;
|
|
|
|
namedMap->GetLength(&length);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMNode> attribute;
|
|
|
|
for (PRUint32 i = 0; i < length; ++i)
|
|
|
|
{
|
|
|
|
namedMap->Item(i, getter_AddRefs(attribute));
|
|
|
|
nsCOMPtr<nsIDOMAttr> attr(do_QueryInterface(attribute));
|
|
|
|
attr->GetName(name);
|
|
|
|
nsAutoString value;
|
|
|
|
attr->GetValue(value);
|
|
|
|
AppendAttribute(name, value, aResult);
|
|
|
|
}
|
2000-05-15 04:12:31 +00:00
|
|
|
}
|
2000-06-02 22:15:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::DumpBox(FILE* aFile)
|
|
|
|
{
|
|
|
|
nsAutoString s;
|
|
|
|
ListBox(s);
|
|
|
|
char ch[1000];
|
|
|
|
s.ToCString(ch,1000);
|
|
|
|
fprintf(aFile, "%s", ch);
|
|
|
|
return NS_OK;
|
2000-05-15 04:12:31 +00:00
|
|
|
}
|
2000-04-25 07:10:48 +00:00
|
|
|
|
2000-06-22 00:48:49 +00:00
|
|
|
/**
|
|
|
|
* Hack for deck who requires that all its children has widgets
|
|
|
|
*/
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::ChildrenMustHaveWidgets(PRBool& aMust)
|
|
|
|
{
|
|
|
|
aMust = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-05-15 04:12:31 +00:00
|
|
|
void
|
|
|
|
nsBox::GetBoxName(nsAutoString& aName)
|
|
|
|
{
|
|
|
|
aName.AssignWithConversion("Box");
|
|
|
|
}
|
|
|
|
|
2000-07-07 22:24:06 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::BeginLayout(nsBoxLayoutState& aState)
|
2000-05-15 04:12:31 +00:00
|
|
|
{
|
2000-06-06 01:25:03 +00:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2000-05-15 04:12:31 +00:00
|
|
|
|
|
|
|
nsBoxAddIndents();
|
|
|
|
|
|
|
|
nsAutoString reason;
|
|
|
|
switch(aState.GetLayoutReason())
|
|
|
|
{
|
|
|
|
case nsBoxLayoutState::Dirty:
|
|
|
|
reason.AssignWithConversion("Dirty");
|
|
|
|
break;
|
|
|
|
case nsBoxLayoutState::Initial:
|
|
|
|
reason.AssignWithConversion("Initial");
|
|
|
|
break;
|
|
|
|
case nsBoxLayoutState::Resize:
|
|
|
|
reason.AssignWithConversion("Resize");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
char ch[100];
|
|
|
|
reason.ToCString(ch,100);
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("%s Layout: ", ch);
|
2000-06-02 22:15:09 +00:00
|
|
|
DumpBox(stdout);
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("\n");
|
2000-05-15 04:12:31 +00:00
|
|
|
gIndent++;
|
|
|
|
#endif
|
2000-07-07 22:24:06 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
2000-05-15 04:12:31 +00:00
|
|
|
}
|
|
|
|
|
2000-07-07 22:24:06 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::DoLayout(nsBoxLayoutState& aState)
|
2000-05-15 04:12:31 +00:00
|
|
|
{
|
2000-07-07 22:24:06 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::EndLayout(nsBoxLayoutState& aState)
|
|
|
|
{
|
|
|
|
|
2000-06-06 01:25:03 +00:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2000-05-15 04:12:31 +00:00
|
|
|
--gIndent;
|
|
|
|
#endif
|
2000-07-07 22:24:06 +00:00
|
|
|
|
|
|
|
return SyncLayout(aState);
|
2000-05-15 04:12:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef REFLOW_COELESCED
|
2000-04-25 07:10:48 +00:00
|
|
|
void Coelesced()
|
|
|
|
{
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("Coelesed=%d\n", ++coelesced);
|
2000-05-15 04:12:31 +00:00
|
|
|
|
2000-04-25 07:10:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2000-04-26 04:00:29 +00:00
|
|
|
nsBox::nsBox(nsIPresShell* aShell):mMouseThrough(unset),
|
2000-04-25 07:10:48 +00:00
|
|
|
mNextChild(nsnull),
|
2000-04-26 04:00:29 +00:00
|
|
|
mParentBox(nsnull)
|
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
{
|
|
|
|
//mX = 0;
|
|
|
|
//mY = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::GetInset(nsMargin& margin)
|
|
|
|
{
|
|
|
|
margin.SizeTo(0,0,0,0);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::IsDirty(PRBool& aDirty)
|
|
|
|
{
|
|
|
|
nsFrameState state;
|
|
|
|
nsIFrame* frame;
|
|
|
|
GetFrame(&frame);
|
|
|
|
frame->GetFrameState(&state);
|
2000-04-25 07:10:48 +00:00
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
aDirty = (state & NS_FRAME_IS_DIRTY);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::HasDirtyChildren(PRBool& aDirty)
|
|
|
|
{
|
|
|
|
nsFrameState state;
|
|
|
|
nsIFrame* frame;
|
|
|
|
GetFrame(&frame);
|
|
|
|
frame->GetFrameState(&state);
|
2000-04-25 07:10:48 +00:00
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
aDirty = (state & NS_FRAME_HAS_DIRTY_CHILDREN);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::MarkDirty(nsBoxLayoutState& aState)
|
|
|
|
{
|
|
|
|
NeedsRecalc();
|
|
|
|
|
|
|
|
nsFrameState state;
|
|
|
|
nsIFrame* frame;
|
|
|
|
GetFrame(&frame);
|
|
|
|
frame->GetFrameState(&state);
|
|
|
|
|
|
|
|
// only reflow if we aren't already dirty.
|
2000-04-25 07:10:48 +00:00
|
|
|
if (state & NS_FRAME_IS_DIRTY) {
|
2000-05-15 04:12:31 +00:00
|
|
|
#ifdef DEBUG_COELESCED
|
2000-04-25 07:10:48 +00:00
|
|
|
Coelesced();
|
|
|
|
#endif
|
2000-03-31 07:02:06 +00:00
|
|
|
return NS_OK;
|
2000-04-25 07:10:48 +00:00
|
|
|
}
|
2000-03-31 07:02:06 +00:00
|
|
|
|
|
|
|
state |= NS_FRAME_IS_DIRTY;
|
|
|
|
frame->SetFrameState(state);
|
|
|
|
|
2000-04-18 00:17:00 +00:00
|
|
|
nsCOMPtr<nsIBoxLayout> layout;
|
|
|
|
GetLayoutManager(getter_AddRefs(layout));
|
|
|
|
if (layout)
|
|
|
|
layout->BecameDirty(this, aState);
|
2000-04-13 07:43:39 +00:00
|
|
|
|
2000-04-25 07:10:48 +00:00
|
|
|
if (state & NS_FRAME_HAS_DIRTY_CHILDREN) {
|
2000-05-15 04:12:31 +00:00
|
|
|
#ifdef DEBUG_COELESCED
|
2000-04-25 07:10:48 +00:00
|
|
|
Coelesced();
|
|
|
|
#endif
|
2000-04-18 00:17:00 +00:00
|
|
|
return NS_OK;
|
2000-04-25 07:10:48 +00:00
|
|
|
}
|
2000-04-18 00:17:00 +00:00
|
|
|
|
|
|
|
nsIBox* parent = nsnull;
|
|
|
|
GetParentBox(&parent);
|
|
|
|
if (parent)
|
|
|
|
return parent->RelayoutDirtyChild(aState, this);
|
|
|
|
else {
|
2000-04-26 04:00:29 +00:00
|
|
|
nsIFrame* parentFrame = nsnull;
|
|
|
|
frame->GetParent(&parentFrame);
|
2000-04-18 00:17:00 +00:00
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
|
|
|
aState.GetPresShell(getter_AddRefs(shell));
|
2000-04-26 04:00:29 +00:00
|
|
|
return parentFrame->ReflowDirtyChild(shell, frame);
|
2000-04-18 00:17:00 +00:00
|
|
|
}
|
2000-03-31 07:02:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::MarkDirtyChildren(nsBoxLayoutState& aState)
|
|
|
|
{
|
2000-04-18 00:17:00 +00:00
|
|
|
return RelayoutDirtyChild(aState, nsnull);
|
|
|
|
}
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2000-04-25 07:10:48 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::MarkStyleChange(nsBoxLayoutState& aState)
|
|
|
|
{
|
|
|
|
NeedsRecalc();
|
|
|
|
|
|
|
|
if (HasStyleChange())
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
// iterate through all children making them dirty
|
|
|
|
MarkChildrenStyleChange();
|
|
|
|
|
2000-06-20 09:21:42 +00:00
|
|
|
nsCOMPtr<nsIBoxLayout> layout;
|
|
|
|
GetLayoutManager(getter_AddRefs(layout));
|
|
|
|
if (layout)
|
|
|
|
layout->BecameDirty(this, aState);
|
|
|
|
|
2000-04-25 07:10:48 +00:00
|
|
|
nsIBox* parent = nsnull;
|
|
|
|
GetParentBox(&parent);
|
|
|
|
if (parent)
|
|
|
|
return parent->RelayoutDirtyChild(aState, this);
|
|
|
|
else {
|
|
|
|
/*
|
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
|
|
|
aState.GetPresShell(getter_AddRefs(shell));
|
|
|
|
nsIFrame* frame = nsnull;
|
|
|
|
GetFrame(&frame);
|
|
|
|
nsFrame::CreateAndPostReflowCommand(shell, frame,
|
|
|
|
nsIReflowCommand::StyleChange, nsnull, nsnull, nsnull);
|
|
|
|
return NS_OK;
|
|
|
|
*/
|
|
|
|
nsIFrame* frame = nsnull;
|
|
|
|
GetFrame(&frame);
|
2000-04-26 04:00:29 +00:00
|
|
|
nsIFrame* parentFrame = nsnull;
|
|
|
|
frame->GetParent(&parentFrame);
|
2000-04-25 07:10:48 +00:00
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
|
|
|
aState.GetPresShell(getter_AddRefs(shell));
|
2000-04-26 04:00:29 +00:00
|
|
|
return parentFrame->ReflowDirtyChild(shell, frame);
|
2000-04-25 07:10:48 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsBox::HasStyleChange()
|
|
|
|
{
|
|
|
|
PRBool aDirty = PR_FALSE;
|
|
|
|
IsDirty(aDirty);
|
|
|
|
return aDirty;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBox::SetStyleChangeFlag(PRBool aDirty)
|
|
|
|
{
|
|
|
|
NeedsRecalc();
|
|
|
|
|
|
|
|
nsFrameState state;
|
|
|
|
nsIFrame* frame;
|
|
|
|
GetFrame(&frame);
|
|
|
|
frame->GetFrameState(&state);
|
|
|
|
state |= (NS_FRAME_IS_DIRTY | NS_FRAME_HAS_DIRTY_CHILDREN);
|
|
|
|
frame->SetFrameState(state);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::MarkChildrenStyleChange()
|
|
|
|
{
|
|
|
|
// only reflow if we aren't already dirty.
|
|
|
|
if (HasStyleChange()) {
|
2000-05-15 04:12:31 +00:00
|
|
|
#ifdef DEBUG_COELESCED
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("StyleChange reflows coelesced=%d\n", ++StyleCoelesced);
|
2000-04-25 07:10:48 +00:00
|
|
|
#endif
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
SetStyleChangeFlag(PR_TRUE);
|
|
|
|
|
|
|
|
nsIBox* child = nsnull;
|
|
|
|
GetChildBox(&child);
|
|
|
|
while(child)
|
|
|
|
{
|
|
|
|
child->MarkChildrenStyleChange();
|
|
|
|
child->GetNextBox(&child);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::RelayoutStyleChange(nsBoxLayoutState& aState, nsIBox* aChild)
|
|
|
|
{
|
|
|
|
NS_ERROR("Don't call this!!");
|
|
|
|
|
|
|
|
/*
|
|
|
|
nsFrameState state;
|
|
|
|
nsIFrame* frame;
|
|
|
|
GetFrame(&frame);
|
|
|
|
frame->GetFrameState(&state);
|
|
|
|
|
|
|
|
// if we are not dirty mark ourselves dirty and tell our parent we are dirty too.
|
|
|
|
if (!HasStyleChange()) {
|
|
|
|
// Mark yourself as dirty and needing to be recalculated
|
|
|
|
SetStyleChangeFlag(PR_TRUE);
|
|
|
|
NeedsRecalc();
|
|
|
|
|
|
|
|
if (aChild != nsnull) {
|
|
|
|
nsCOMPtr<nsIBoxLayout> layout;
|
|
|
|
GetLayoutManager(getter_AddRefs(layout));
|
|
|
|
if (layout)
|
|
|
|
layout->ChildBecameDirty(this, aState, aChild);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIBox* parent = nsnull;
|
|
|
|
GetParentBox(&parent);
|
|
|
|
if (parent)
|
|
|
|
return parent->RelayoutStyleChange(aState, this);
|
|
|
|
else {
|
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
|
|
|
aState.GetPresShell(getter_AddRefs(shell));
|
|
|
|
nsIFrame* frame = nsnull;
|
|
|
|
aChild->GetFrame(&frame);
|
|
|
|
nsFrame::CreateAndPostReflowCommand(shell, frame,
|
|
|
|
nsIReflowCommand::StyleChanged, nsnull, nsnull, nsnull);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
} else {
|
2000-05-15 04:12:31 +00:00
|
|
|
#ifdef DEBUG_COELESCED
|
2000-04-25 07:10:48 +00:00
|
|
|
Coelesced();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-04-18 00:17:00 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::RelayoutDirtyChild(nsBoxLayoutState& aState, nsIBox* aChild)
|
|
|
|
{
|
|
|
|
nsFrameState state;
|
|
|
|
nsIFrame* frame;
|
|
|
|
GetFrame(&frame);
|
|
|
|
frame->GetFrameState(&state);
|
|
|
|
|
2000-07-10 20:10:27 +00:00
|
|
|
if (aChild != nsnull) {
|
|
|
|
nsCOMPtr<nsIBoxLayout> layout;
|
|
|
|
GetLayoutManager(getter_AddRefs(layout));
|
|
|
|
if (layout)
|
|
|
|
layout->ChildBecameDirty(this, aState, aChild);
|
|
|
|
}
|
|
|
|
|
2000-04-18 00:17:00 +00:00
|
|
|
// if we are not dirty mark ourselves dirty and tell our parent we are dirty too.
|
|
|
|
if (!(state & NS_FRAME_HAS_DIRTY_CHILDREN)) {
|
|
|
|
// Mark yourself as dirty and needing to be recalculated
|
|
|
|
state |= NS_FRAME_HAS_DIRTY_CHILDREN;
|
|
|
|
frame->SetFrameState(state);
|
|
|
|
NeedsRecalc();
|
|
|
|
|
2001-03-21 05:32:22 +00:00
|
|
|
nsIBox* parentBox = nsnull;
|
|
|
|
GetParentBox(&parentBox);
|
|
|
|
if (parentBox)
|
|
|
|
return parentBox->RelayoutDirtyChild(aState, this);
|
|
|
|
nsIFrame* parent = nsnull;
|
|
|
|
frame->GetParent(&parent);
|
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
|
|
|
aState.GetPresShell(getter_AddRefs(shell));
|
|
|
|
return parent->ReflowDirtyChild(shell, frame);
|
2000-04-25 07:10:48 +00:00
|
|
|
} else {
|
2000-05-15 04:12:31 +00:00
|
|
|
#ifdef DEBUG_COELESCED
|
2000-04-25 07:10:48 +00:00
|
|
|
Coelesced();
|
|
|
|
#endif
|
2000-04-18 00:17:00 +00:00
|
|
|
}
|
2000-04-13 07:43:39 +00:00
|
|
|
|
2000-04-18 00:17:00 +00:00
|
|
|
return NS_OK;
|
2000-03-31 07:02:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::GetVAlign(Valignment& aAlign)
|
|
|
|
{
|
|
|
|
aAlign = vAlign_Top;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::GetHAlign(Halignment& aAlign)
|
|
|
|
{
|
|
|
|
aAlign = hAlign_Left;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::GetClientRect(nsRect& aClientRect)
|
|
|
|
{
|
|
|
|
GetContentRect(aClientRect);
|
|
|
|
|
|
|
|
nsMargin borderPadding;
|
|
|
|
GetBorderAndPadding(borderPadding);
|
|
|
|
|
|
|
|
aClientRect.Deflate(borderPadding);
|
|
|
|
|
|
|
|
nsMargin insets;
|
|
|
|
GetInset(insets);
|
|
|
|
|
|
|
|
aClientRect.Deflate(insets);
|
|
|
|
if (aClientRect.width < 0)
|
|
|
|
aClientRect.width = 0;
|
|
|
|
|
|
|
|
if (aClientRect.height < 0)
|
|
|
|
aClientRect.height = 0;
|
|
|
|
|
|
|
|
// NS_ASSERTION(aClientRect.width >=0 && aClientRect.height >= 0, "Content Size < 0");
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::GetContentRect(nsRect& aContentRect)
|
|
|
|
{
|
|
|
|
GetBounds(aContentRect);
|
|
|
|
aContentRect.x = 0;
|
|
|
|
aContentRect.y = 0;
|
2000-06-02 22:15:09 +00:00
|
|
|
NS_BOX_ASSERTION(this, aContentRect.width >=0 && aContentRect.height >= 0, "Content Size < 0");
|
2000-03-31 07:02:06 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::GetBounds(nsRect& aRect)
|
|
|
|
{
|
|
|
|
nsIFrame* frame = nsnull;
|
|
|
|
GetFrame(&frame);
|
|
|
|
|
|
|
|
return frame->GetRect(aRect);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2000-04-25 07:10:48 +00:00
|
|
|
nsBox::SetBounds(nsBoxLayoutState& aState, const nsRect& aRect)
|
2000-03-31 07:02:06 +00:00
|
|
|
{
|
2000-06-02 22:15:09 +00:00
|
|
|
NS_BOX_ASSERTION(this, aRect.width >=0 && aRect.height >= 0, "SetBounds Size < 0");
|
2000-03-31 07:02:06 +00:00
|
|
|
|
|
|
|
nsRect rect(0,0,0,0);
|
|
|
|
GetBounds(rect);
|
|
|
|
|
|
|
|
nsIFrame* frame = nsnull;
|
|
|
|
GetFrame(&frame);
|
|
|
|
|
2000-04-25 07:10:48 +00:00
|
|
|
nsIPresContext* presContext = aState.GetPresContext();
|
|
|
|
|
|
|
|
PRUint32 flags = 0;
|
|
|
|
GetLayoutFlags(flags);
|
|
|
|
|
|
|
|
PRUint32 stateFlags = 0;
|
|
|
|
aState.GetLayoutFlags(stateFlags);
|
|
|
|
|
|
|
|
flags |= stateFlags;
|
|
|
|
|
|
|
|
if (flags & NS_FRAME_NO_MOVE_FRAME)
|
|
|
|
frame->SizeTo(presContext, aRect.width, aRect.height);
|
|
|
|
else
|
|
|
|
frame->SetRect(presContext, aRect);
|
2000-03-31 07:02:06 +00:00
|
|
|
|
|
|
|
|
2000-04-25 07:10:48 +00:00
|
|
|
if (!(flags & NS_FRAME_NO_MOVE_VIEW) || !(flags & NS_FRAME_NO_MOVE_CHILD_VIEWS))
|
|
|
|
{
|
|
|
|
nsIView* view;
|
|
|
|
frame->GetView(presContext, &view);
|
|
|
|
if (view) {
|
|
|
|
if (!(flags & NS_FRAME_NO_MOVE_VIEW)) {
|
|
|
|
nsContainerFrame::PositionFrameView(presContext, frame, view);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!(flags & NS_FRAME_NO_MOVE_CHILD_VIEWS)) {
|
|
|
|
// only if the origin changed
|
|
|
|
if ((rect.x != aRect.x) || (rect.y != aRect.y)) {
|
|
|
|
nsContainerFrame::PositionChildViews(presContext, frame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2000-03-31 07:02:06 +00:00
|
|
|
// only if the origin changed
|
|
|
|
if ((rect.x != aRect.x) || (rect.y != aRect.y)) {
|
|
|
|
nsIView* view;
|
|
|
|
frame->GetView(presContext, &view);
|
|
|
|
if (view) {
|
|
|
|
nsContainerFrame::PositionFrameView(presContext, frame, view);
|
|
|
|
} else {
|
|
|
|
nsContainerFrame::PositionChildViews(presContext, frame);
|
|
|
|
}
|
|
|
|
}
|
2000-04-25 07:10:48 +00:00
|
|
|
*/
|
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-04-25 07:10:48 +00:00
|
|
|
void
|
|
|
|
nsBox::GetLayoutFlags(PRUint32& aFlags)
|
|
|
|
{
|
|
|
|
aFlags = 0;
|
|
|
|
}
|
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::GetBorderAndPadding(nsMargin& aBorderAndPadding)
|
|
|
|
{
|
2001-02-07 09:57:26 +00:00
|
|
|
nsMargin border;
|
|
|
|
nsresult rv = GetBorder(border);
|
2001-01-20 22:46:54 +00:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
2001-01-25 02:58:12 +00:00
|
|
|
nsMargin padding;
|
2001-02-07 09:57:26 +00:00
|
|
|
rv = GetPadding(padding);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
aBorderAndPadding.SizeTo(0,0,0,0);
|
|
|
|
aBorderAndPadding += border;
|
|
|
|
aBorderAndPadding += padding;
|
|
|
|
|
2000-04-25 07:10:48 +00:00
|
|
|
return rv;
|
2000-03-31 07:02:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::GetBorder(nsMargin& aMargin)
|
|
|
|
{
|
|
|
|
nsIFrame* frame = nsnull;
|
|
|
|
GetFrame(&frame);
|
|
|
|
|
2001-02-07 09:57:26 +00:00
|
|
|
const nsStyleBorder* border;
|
|
|
|
nsresult rv = frame->GetStyleData(eStyleStruct_Border,
|
|
|
|
(const nsStyleStruct*&) border);
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2000-04-25 07:10:48 +00:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
aMargin.SizeTo(0,0,0,0);
|
2001-02-07 09:57:26 +00:00
|
|
|
border->GetBorder(aMargin);
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2000-04-25 07:10:48 +00:00
|
|
|
return rv;
|
2000-03-31 07:02:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::GetPadding(nsMargin& aMargin)
|
|
|
|
{
|
|
|
|
nsIFrame* frame = nsnull;
|
|
|
|
GetFrame(&frame);
|
|
|
|
|
2001-02-07 09:57:26 +00:00
|
|
|
const nsStylePadding* padding;
|
|
|
|
nsresult rv = frame->GetStyleData(eStyleStruct_Padding,
|
|
|
|
(const nsStyleStruct*&) padding);
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2000-04-25 07:10:48 +00:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
aMargin.SizeTo(0,0,0,0);
|
2001-02-07 09:57:26 +00:00
|
|
|
padding->GetPadding(aMargin);
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2000-04-25 07:10:48 +00:00
|
|
|
return rv;
|
2000-03-31 07:02:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::GetMargin(nsMargin& aMargin)
|
|
|
|
{
|
|
|
|
nsIFrame* frame = nsnull;
|
|
|
|
GetFrame(&frame);
|
|
|
|
|
2001-02-07 09:57:26 +00:00
|
|
|
const nsStyleMargin* margin;
|
|
|
|
nsresult rv = frame->GetStyleData(eStyleStruct_Margin,
|
|
|
|
(const nsStyleStruct*&) margin);
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2000-04-25 07:10:48 +00:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
aMargin.SizeTo(0,0,0,0);
|
2001-02-07 09:57:26 +00:00
|
|
|
margin->GetMargin(aMargin);
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2000-04-25 07:10:48 +00:00
|
|
|
return rv;
|
2000-03-31 07:02:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::GetChildBox(nsIBox** aBox)
|
|
|
|
{
|
|
|
|
*aBox = nsnull;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::GetNextBox(nsIBox** aBox)
|
|
|
|
{
|
|
|
|
*aBox = mNextChild;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::SetNextBox(nsIBox* aBox)
|
|
|
|
{
|
|
|
|
mNextChild = aBox;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::SetParentBox(nsIBox* aParent)
|
|
|
|
{
|
|
|
|
mParentBox = aParent;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::GetParentBox(nsIBox** aParent)
|
|
|
|
{
|
|
|
|
*aParent = mParentBox;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::NeedsRecalc()
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsBox::SetDebug(nsBoxLayoutState& aState, PRBool aDebug)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBox::SizeNeedsRecalc(nsSize& aSize)
|
|
|
|
{
|
|
|
|
aSize.width = -1;
|
|
|
|
aSize.height = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBox::CoordNeedsRecalc(PRInt32& aFlex)
|
|
|
|
{
|
|
|
|
aFlex = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsBox::DoesNeedRecalc(const nsSize& aSize)
|
|
|
|
{
|
|
|
|
return (aSize.width == -1 || aSize.height == -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsBox::DoesNeedRecalc(nscoord aCoord)
|
|
|
|
{
|
|
|
|
return (aCoord == -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsBox::GetWasCollapsed(nsBoxLayoutState& aState)
|
|
|
|
{
|
|
|
|
nsIFrame* frame = nsnull;
|
|
|
|
GetFrame(&frame);
|
|
|
|
nsFrameState state;
|
|
|
|
frame->GetFrameState(&state);
|
|
|
|
|
|
|
|
return (state & NS_STATE_IS_COLLAPSED);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBox::SetWasCollapsed(nsBoxLayoutState& aState, PRBool aCollapsed)
|
|
|
|
{
|
|
|
|
nsIFrame* frame;
|
|
|
|
GetFrame(&frame);
|
|
|
|
nsFrameState state;
|
|
|
|
frame->GetFrameState(&state);
|
|
|
|
if (aCollapsed)
|
|
|
|
state |= NS_STATE_IS_COLLAPSED;
|
|
|
|
else
|
|
|
|
state &= ~NS_STATE_IS_COLLAPSED;
|
|
|
|
|
|
|
|
frame->SetFrameState(state);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::Collapse(nsBoxLayoutState& aState)
|
|
|
|
{
|
|
|
|
// if (GetWasCollapsed(aState))
|
|
|
|
// return NS_OK;
|
|
|
|
|
|
|
|
SetWasCollapsed(aState, PR_TRUE);
|
|
|
|
nsIFrame* frame;
|
|
|
|
GetFrame(&frame);
|
|
|
|
SetBounds(aState, nsRect(0,0,0,0));
|
|
|
|
|
|
|
|
return CollapseChild(aState, frame, PR_TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsBox::CollapseChild(nsBoxLayoutState& aState, nsIFrame* aFrame, PRBool aHide)
|
|
|
|
{
|
|
|
|
nsIPresContext* presContext = aState.GetPresContext();
|
|
|
|
|
|
|
|
// shrink the view
|
|
|
|
nsIView* view = nsnull;
|
|
|
|
aFrame->GetView(presContext, &view);
|
|
|
|
|
|
|
|
// if we find a view stop right here. All views under it
|
|
|
|
// will be clipped.
|
|
|
|
if (view) {
|
|
|
|
// already hidden? We are done.
|
|
|
|
nsViewVisibility v;
|
|
|
|
view->GetVisibility(v);
|
|
|
|
//if (v == nsViewVisibility_kHide)
|
|
|
|
//return NS_OK;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIWidget> widget;
|
|
|
|
view->GetWidget(*getter_AddRefs(widget));
|
|
|
|
if (aHide) {
|
|
|
|
view->SetVisibility(nsViewVisibility_kHide);
|
|
|
|
} else {
|
|
|
|
view->SetVisibility(nsViewVisibility_kShow);
|
|
|
|
}
|
|
|
|
if (widget) {
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// collapse the child
|
|
|
|
nsIFrame* child = nsnull;
|
|
|
|
aFrame->FirstChild(presContext, nsnull,&child);
|
|
|
|
|
|
|
|
while (nsnull != child)
|
|
|
|
{
|
|
|
|
CollapseChild(aState, child, aHide);
|
|
|
|
nsresult rv = child->GetNextSibling(&child);
|
|
|
|
NS_ASSERTION(rv == NS_OK,"failed to get next child");
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::UnCollapse(nsBoxLayoutState& aState)
|
|
|
|
{
|
|
|
|
if (!GetWasCollapsed(aState))
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
SetWasCollapsed(aState, PR_FALSE);
|
|
|
|
|
|
|
|
return UnCollapseChild(aState, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsBox::UnCollapseChild(nsBoxLayoutState& aState, nsIBox* aBox)
|
|
|
|
{
|
|
|
|
nsIFrame* frame;
|
|
|
|
aBox->GetFrame(&frame);
|
|
|
|
|
|
|
|
// collapse the child
|
|
|
|
nsIBox* child = nsnull;
|
|
|
|
aBox->GetChildBox(&child);
|
|
|
|
|
|
|
|
if (child == nsnull) {
|
|
|
|
nsFrameState childState;
|
|
|
|
frame->GetFrameState(&childState);
|
|
|
|
childState |= NS_FRAME_IS_DIRTY;
|
|
|
|
frame->SetFrameState(childState);
|
|
|
|
} else {
|
|
|
|
child->GetFrame(&frame);
|
|
|
|
nsFrameState childState;
|
|
|
|
frame->GetFrameState(&childState);
|
|
|
|
childState |= NS_FRAME_HAS_DIRTY_CHILDREN;
|
|
|
|
frame->SetFrameState(childState);
|
|
|
|
|
|
|
|
while (nsnull != child)
|
|
|
|
{
|
|
|
|
UnCollapseChild(aState, child);
|
|
|
|
nsresult rv = child->GetNextBox(&child);
|
|
|
|
NS_ASSERTION(rv == NS_OK,"failed to get next child");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::SetLayoutManager(nsIBoxLayout* aLayout)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::GetLayoutManager(nsIBoxLayout** aLayout)
|
|
|
|
{
|
|
|
|
*aLayout = nsnull;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::GetPrefSize(nsBoxLayoutState& aState, nsSize& aSize)
|
|
|
|
{
|
|
|
|
aSize.width = 0;
|
|
|
|
aSize.height = 0;
|
2000-05-16 20:46:08 +00:00
|
|
|
|
|
|
|
PRBool collapsed = PR_FALSE;
|
|
|
|
IsCollapsed(aState, collapsed);
|
|
|
|
if (collapsed)
|
|
|
|
return NS_OK;
|
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
AddBorderAndPadding(aSize);
|
|
|
|
AddInset(aSize);
|
|
|
|
nsIBox::AddCSSPrefSize(aState, this, aSize);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::GetMinSize(nsBoxLayoutState& aState, nsSize& aSize)
|
|
|
|
{
|
|
|
|
aSize.width = 0;
|
|
|
|
aSize.height = 0;
|
2000-05-16 20:46:08 +00:00
|
|
|
|
|
|
|
PRBool collapsed = PR_FALSE;
|
|
|
|
IsCollapsed(aState, collapsed);
|
|
|
|
if (collapsed)
|
|
|
|
return NS_OK;
|
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
AddBorderAndPadding(aSize);
|
|
|
|
AddInset(aSize);
|
|
|
|
nsIBox::AddCSSMinSize(aState, this, aSize);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::GetMaxSize(nsBoxLayoutState& aState, nsSize& aSize)
|
|
|
|
{
|
|
|
|
aSize.width = NS_INTRINSICSIZE;
|
|
|
|
aSize.height = NS_INTRINSICSIZE;
|
2000-05-16 20:46:08 +00:00
|
|
|
|
|
|
|
PRBool collapsed = PR_FALSE;
|
|
|
|
IsCollapsed(aState, collapsed);
|
|
|
|
if (collapsed)
|
|
|
|
return NS_OK;
|
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
AddBorderAndPadding(aSize);
|
|
|
|
AddInset(aSize);
|
|
|
|
nsIBox::AddCSSMaxSize(aState, this, aSize);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::GetFlex(nsBoxLayoutState& aState, nscoord& aFlex)
|
|
|
|
{
|
|
|
|
aFlex = 0;
|
2000-05-16 20:46:08 +00:00
|
|
|
|
|
|
|
PRBool collapsed = PR_FALSE;
|
|
|
|
IsCollapsed(aState, collapsed);
|
|
|
|
if (collapsed)
|
|
|
|
return NS_OK;
|
|
|
|
|
2000-04-18 00:17:00 +00:00
|
|
|
GetDefaultFlex(aFlex);
|
2000-03-31 07:02:06 +00:00
|
|
|
nsIBox::AddCSSFlex(aState, this, aFlex);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::GetAscent(nsBoxLayoutState& aState, nscoord& aAscent)
|
|
|
|
{
|
2000-05-16 20:46:08 +00:00
|
|
|
aAscent = 0;
|
|
|
|
PRBool collapsed = PR_FALSE;
|
|
|
|
IsCollapsed(aState, collapsed);
|
|
|
|
if (collapsed)
|
|
|
|
return NS_OK;
|
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
nsSize size(0,0);
|
|
|
|
nsresult rv = GetPrefSize(aState, size);
|
|
|
|
aAscent = size.height;
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::IsCollapsed(nsBoxLayoutState& aState, PRBool& aCollapsed)
|
|
|
|
{
|
|
|
|
aCollapsed = PR_FALSE;
|
|
|
|
nsIBox::AddCSSCollapsed(aState, this, aCollapsed);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::Layout(nsBoxLayoutState& aState)
|
|
|
|
{
|
2000-07-07 22:24:06 +00:00
|
|
|
BeginLayout(aState);
|
2000-05-15 04:12:31 +00:00
|
|
|
|
2000-07-07 22:24:06 +00:00
|
|
|
DoLayout(aState);
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2000-07-07 22:24:06 +00:00
|
|
|
EndLayout(aState);
|
2000-05-15 04:12:31 +00:00
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::GetOrientation(PRBool& aIsHorizontal)
|
|
|
|
{
|
|
|
|
nsIFrame* frame = nsnull;
|
|
|
|
GetFrame(&frame);
|
|
|
|
nsFrameState state;
|
|
|
|
frame->GetFrameState(&state);
|
|
|
|
aIsHorizontal = (state & NS_STATE_IS_HORIZONTAL);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsBox::SyncLayout(nsBoxLayoutState& aState)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
PRBool collapsed = PR_FALSE;
|
|
|
|
IsCollapsed(aState, collapsed);
|
|
|
|
if (collapsed) {
|
|
|
|
CollapseChild(aState, this, PR_TRUE);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
PRBool dirty = PR_FALSE;
|
|
|
|
IsDirty(dirty);
|
|
|
|
if (dirty || aState.GetLayoutReason() == nsBoxLayoutState::Initial)
|
|
|
|
Redraw(aState);
|
|
|
|
|
|
|
|
nsFrameState state;
|
|
|
|
nsIFrame* frame;
|
|
|
|
GetFrame(&frame);
|
|
|
|
frame->GetFrameState(&state);
|
2000-04-25 07:10:48 +00:00
|
|
|
state &= ~(NS_FRAME_HAS_DIRTY_CHILDREN | NS_FRAME_IS_DIRTY | NS_FRAME_FIRST_REFLOW | NS_FRAME_IN_REFLOW);
|
2000-03-31 07:02:06 +00:00
|
|
|
frame->SetFrameState(state);
|
|
|
|
|
|
|
|
nsIPresContext* presContext = aState.GetPresContext();
|
|
|
|
nsRect rect(0,0,0,0);
|
|
|
|
GetBounds(rect);
|
2000-04-25 07:10:48 +00:00
|
|
|
|
|
|
|
PRUint32 flags = 0;
|
|
|
|
GetLayoutFlags(flags);
|
|
|
|
|
|
|
|
PRUint32 stateFlags = 0;
|
|
|
|
aState.GetLayoutFlags(stateFlags);
|
|
|
|
|
|
|
|
flags |= stateFlags;
|
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
nsIView* view;
|
|
|
|
frame->GetView(presContext, &view);
|
|
|
|
|
|
|
|
/*
|
|
|
|
// only if the origin changed
|
|
|
|
if ((mX != rect.x) || (mY != rect.y)) {
|
|
|
|
if (view) {
|
|
|
|
nsContainerFrame::PositionFrameView(presContext, frame, view);
|
|
|
|
} else
|
|
|
|
nsContainerFrame::PositionChildViews(presContext, frame);
|
|
|
|
|
|
|
|
mX = rect.x;
|
|
|
|
mY = rect.y;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (view) {
|
|
|
|
// Make sure the frame's view is properly sized and positioned and has
|
|
|
|
// things like opacity correct
|
|
|
|
nsHTMLContainerFrame::SyncFrameViewAfterReflow(
|
|
|
|
presContext,
|
|
|
|
frame,
|
|
|
|
view,
|
|
|
|
nsnull,
|
2000-04-25 07:10:48 +00:00
|
|
|
flags);
|
2000-03-31 07:02:06 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::Redraw(nsBoxLayoutState& aState,
|
|
|
|
const nsRect* aDamageRect,
|
|
|
|
PRBool aImmediate)
|
|
|
|
{
|
2000-10-07 00:49:08 +00:00
|
|
|
if (aState.GetDisablePainting())
|
|
|
|
return NS_OK;
|
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
nsIPresContext* presContext = aState.GetPresContext();
|
|
|
|
const nsHTMLReflowState* s = aState.GetReflowState();
|
|
|
|
if (s) {
|
|
|
|
if (s->reason != eReflowReason_Incremental)
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-04-25 19:52:49 +00:00
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
|
|
|
presContext->GetShell(getter_AddRefs(shell));
|
|
|
|
PRBool suppressed = PR_FALSE;
|
|
|
|
shell->IsPaintingSuppressed(&suppressed);
|
|
|
|
if (suppressed)
|
|
|
|
return NS_OK; // Don't redraw. Painting is still suppressed.
|
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
nsIFrame* frame = nsnull;
|
|
|
|
GetFrame(&frame);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIViewManager> viewManager;
|
|
|
|
nsRect damageRect(0,0,0,0);
|
|
|
|
if (aDamageRect)
|
|
|
|
damageRect = *aDamageRect;
|
|
|
|
else
|
|
|
|
GetContentRect(damageRect);
|
|
|
|
|
|
|
|
// Checks to see if the damaged rect should be infalted
|
|
|
|
// to include the outline
|
2001-02-07 09:57:26 +00:00
|
|
|
const nsStyleOutline* outline;
|
|
|
|
frame->GetStyleData(eStyleStruct_Outline, (const nsStyleStruct*&)outline);
|
2000-03-31 07:02:06 +00:00
|
|
|
nscoord width;
|
2001-02-07 09:57:26 +00:00
|
|
|
outline->GetOutlineWidth(width);
|
2000-03-31 07:02:06 +00:00
|
|
|
if (width > 0) {
|
|
|
|
damageRect.Inflate(width, width);
|
|
|
|
}
|
|
|
|
|
|
|
|
PRUint32 flags = aImmediate ? NS_VMREFRESH_IMMEDIATE : NS_VMREFRESH_NO_SYNC;
|
|
|
|
nsIView* view;
|
|
|
|
|
|
|
|
frame->GetView(presContext, &view);
|
|
|
|
if (view) {
|
|
|
|
view->GetViewManager(*getter_AddRefs(viewManager));
|
|
|
|
viewManager->UpdateView(view, damageRect, flags);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
nsRect rect(damageRect);
|
|
|
|
nsPoint offset;
|
|
|
|
|
|
|
|
frame->GetOffsetFromView(presContext, offset, &view);
|
2000-06-02 22:15:09 +00:00
|
|
|
NS_BOX_ASSERTION(this, nsnull != view, "no view");
|
2000-03-31 07:02:06 +00:00
|
|
|
rect += offset;
|
|
|
|
view->GetViewManager(*getter_AddRefs(viewManager));
|
|
|
|
viewManager->UpdateView(view, rect, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsIBox::AddCSSPrefSize(nsBoxLayoutState& aState, nsIBox* aBox, nsSize& aSize)
|
|
|
|
{
|
|
|
|
PRBool widthSet = PR_FALSE;
|
|
|
|
PRBool heightSet = PR_FALSE;
|
|
|
|
nsIFrame* frame = nsnull;
|
|
|
|
aBox->GetFrame(&frame);
|
|
|
|
|
|
|
|
// add in the css min, max, pref
|
|
|
|
const nsStylePosition* position;
|
|
|
|
frame->GetStyleData(eStyleStruct_Position,
|
|
|
|
(const nsStyleStruct*&) position);
|
|
|
|
|
|
|
|
// see if the width or height was specifically set
|
|
|
|
if (position->mWidth.GetUnit() == eStyleUnit_Coord) {
|
|
|
|
aSize.width = position->mWidth.GetCoordValue();
|
|
|
|
widthSet = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (position->mHeight.GetUnit() == eStyleUnit_Coord) {
|
|
|
|
aSize.height = position->mHeight.GetCoordValue();
|
|
|
|
heightSet = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> content;
|
|
|
|
frame->GetContent(getter_AddRefs(content));
|
|
|
|
|
|
|
|
if (content) {
|
2000-04-25 07:10:48 +00:00
|
|
|
nsIPresContext* presContext = aState.GetPresContext();
|
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
nsAutoString value;
|
|
|
|
PRInt32 error;
|
|
|
|
|
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::width, value))
|
|
|
|
{
|
|
|
|
float p2t;
|
|
|
|
presContext->GetScaledPixelsToTwips(&p2t);
|
|
|
|
|
|
|
|
value.Trim("%");
|
|
|
|
|
|
|
|
aSize.width = NSIntPixelsToTwips(value.ToInteger(&error), p2t);
|
|
|
|
widthSet = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::height, value))
|
|
|
|
{
|
|
|
|
float p2t;
|
|
|
|
presContext->GetScaledPixelsToTwips(&p2t);
|
|
|
|
|
|
|
|
value.Trim("%");
|
|
|
|
|
|
|
|
aSize.height = NSIntPixelsToTwips(value.ToInteger(&error), p2t);
|
|
|
|
heightSet = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (widthSet && heightSet);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsIBox::AddCSSMinSize(nsBoxLayoutState& aState, nsIBox* aBox, nsSize& aSize)
|
|
|
|
{
|
|
|
|
|
|
|
|
PRBool widthSet = PR_FALSE;
|
|
|
|
PRBool heightSet = PR_FALSE;
|
|
|
|
|
|
|
|
nsIFrame* frame = nsnull;
|
|
|
|
aBox->GetFrame(&frame);
|
|
|
|
|
|
|
|
// add in the css min, max, pref
|
|
|
|
const nsStylePosition* position;
|
|
|
|
frame->GetStyleData(eStyleStruct_Position,
|
|
|
|
(const nsStyleStruct*&) position);
|
|
|
|
|
|
|
|
// same for min size. Unfortunately min size is always set to 0. So for now
|
|
|
|
// we will assume 0 means not set.
|
|
|
|
if (position->mMinWidth.GetUnit() == eStyleUnit_Coord) {
|
|
|
|
nscoord min = position->mMinWidth.GetCoordValue();
|
|
|
|
if (min != 0) {
|
|
|
|
aSize.width = min;
|
|
|
|
widthSet = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (position->mMinHeight.GetUnit() == eStyleUnit_Coord) {
|
|
|
|
nscoord min = position->mMinHeight.GetCoordValue();
|
|
|
|
if (min != 0) {
|
|
|
|
aSize.height = min;
|
|
|
|
heightSet = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-12-07 10:18:40 +00:00
|
|
|
nsCOMPtr<nsIContent> content;
|
|
|
|
frame->GetContent(getter_AddRefs(content));
|
|
|
|
|
|
|
|
if (content) {
|
|
|
|
nsIPresContext* presContext = aState.GetPresContext();
|
|
|
|
|
|
|
|
nsAutoString value;
|
|
|
|
PRInt32 error;
|
|
|
|
|
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttribute(kNameSpaceID_None, nsXULAtoms::minwidth, value))
|
|
|
|
{
|
|
|
|
float p2t;
|
|
|
|
presContext->GetScaledPixelsToTwips(&p2t);
|
|
|
|
|
|
|
|
value.Trim("%");
|
|
|
|
|
|
|
|
nscoord val = NSIntPixelsToTwips(value.ToInteger(&error), p2t);
|
|
|
|
if (val > aSize.width)
|
|
|
|
aSize.width = val;
|
|
|
|
widthSet = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttribute(kNameSpaceID_None, nsXULAtoms::minheight, value))
|
|
|
|
{
|
|
|
|
float p2t;
|
|
|
|
presContext->GetScaledPixelsToTwips(&p2t);
|
|
|
|
|
|
|
|
value.Trim("%");
|
|
|
|
|
|
|
|
nscoord val = NSIntPixelsToTwips(value.ToInteger(&error), p2t);
|
|
|
|
if (val > aSize.height)
|
|
|
|
aSize.height = val;
|
|
|
|
|
|
|
|
heightSet = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
return (widthSet && heightSet);
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsIBox::AddCSSMaxSize(nsBoxLayoutState& aState, nsIBox* aBox, nsSize& aSize)
|
|
|
|
{
|
|
|
|
|
|
|
|
PRBool widthSet = PR_FALSE;
|
|
|
|
PRBool heightSet = PR_FALSE;
|
|
|
|
|
|
|
|
nsIFrame* frame = nsnull;
|
|
|
|
aBox->GetFrame(&frame);
|
|
|
|
|
|
|
|
// add in the css min, max, pref
|
|
|
|
const nsStylePosition* position;
|
|
|
|
frame->GetStyleData(eStyleStruct_Position,
|
|
|
|
(const nsStyleStruct*&) position);
|
|
|
|
|
|
|
|
// and max
|
|
|
|
if (position->mMaxWidth.GetUnit() == eStyleUnit_Coord) {
|
|
|
|
nscoord max = position->mMaxWidth.GetCoordValue();
|
|
|
|
aSize.width = max;
|
|
|
|
widthSet = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (position->mMaxHeight.GetUnit() == eStyleUnit_Coord) {
|
|
|
|
nscoord max = position->mMaxHeight.GetCoordValue();
|
|
|
|
aSize.height = max;
|
|
|
|
heightSet = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsIBox::AddCSSFlex(nsBoxLayoutState& aState, nsIBox* aBox, nscoord& aFlex)
|
|
|
|
{
|
|
|
|
PRBool flexSet = PR_FALSE;
|
|
|
|
|
|
|
|
nsIFrame* frame = nsnull;
|
|
|
|
aBox->GetFrame(&frame);
|
|
|
|
|
|
|
|
// get the flexibility
|
|
|
|
nsCOMPtr<nsIContent> content;
|
|
|
|
frame->GetContent(getter_AddRefs(content));
|
|
|
|
|
|
|
|
if (content) {
|
|
|
|
PRInt32 error;
|
|
|
|
nsAutoString value;
|
|
|
|
|
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttribute(kNameSpaceID_None, nsXULAtoms::flex, value))
|
|
|
|
{
|
|
|
|
value.Trim("%");
|
|
|
|
aFlex = value.ToInteger(&error);
|
|
|
|
flexSet = PR_TRUE;
|
|
|
|
}
|
2001-08-02 00:09:27 +00:00
|
|
|
else {
|
|
|
|
// No attribute value. Check CSS.
|
|
|
|
const nsStyleXUL* boxInfo;
|
|
|
|
frame->GetStyleData(eStyleStruct_XUL, (const nsStyleStruct*&)boxInfo);
|
|
|
|
if (boxInfo->mBoxFlex > 0.0f) {
|
|
|
|
// The flex was defined in CSS.
|
|
|
|
aFlex = (nscoord)boxInfo->mBoxFlex;
|
|
|
|
flexSet = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
2000-03-31 07:02:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return flexSet;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsIBox::AddCSSCollapsed(nsBoxLayoutState& aState, nsIBox* aBox, PRBool& aCollapsed)
|
|
|
|
{
|
|
|
|
nsIFrame* frame = nsnull;
|
|
|
|
aBox->GetFrame(&frame);
|
2001-05-31 22:19:43 +00:00
|
|
|
const nsStyleVisibility* vis;
|
|
|
|
frame->GetStyleData(eStyleStruct_Visibility, ((const nsStyleStruct *&)vis));
|
|
|
|
aCollapsed = vis->mVisible == NS_STYLE_VISIBILITY_COLLAPSE;
|
2000-03-31 07:02:06 +00:00
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBox::AddBorderAndPadding(nsSize& aSize)
|
|
|
|
{
|
|
|
|
AddBorderAndPadding(this, aSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBox::AddMargin(nsSize& aSize)
|
|
|
|
{
|
|
|
|
AddMargin(this, aSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBox::AddInset(nsSize& aSize)
|
|
|
|
{
|
|
|
|
AddInset(this, aSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBox::AddBorderAndPadding(nsIBox* aBox, nsSize& aSize)
|
|
|
|
{
|
|
|
|
nsMargin borderPadding(0,0,0,0);
|
|
|
|
aBox->GetBorderAndPadding(borderPadding);
|
|
|
|
AddMargin(aSize, borderPadding);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBox::AddMargin(nsIBox* aChild, nsSize& aSize)
|
|
|
|
{
|
|
|
|
nsMargin margin(0,0,0,0);
|
|
|
|
aChild->GetMargin(margin);
|
|
|
|
AddMargin(aSize, margin);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBox::AddMargin(nsSize& aSize, const nsMargin& aMargin)
|
|
|
|
{
|
|
|
|
if (aSize.width != NS_INTRINSICSIZE)
|
|
|
|
aSize.width += aMargin.left + aMargin.right;
|
|
|
|
|
|
|
|
if (aSize.height != NS_INTRINSICSIZE)
|
|
|
|
aSize.height += aMargin.top + aMargin.bottom;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBox::AddInset(nsIBox* aBox, nsSize& aSize)
|
|
|
|
{
|
|
|
|
nsMargin margin(0,0,0,0);
|
|
|
|
aBox->GetInset(margin);
|
|
|
|
AddMargin(aSize, margin);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBox::BoundsCheck(nsSize& aMinSize, nsSize& aPrefSize, nsSize& aMaxSize)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (aMinSize.width > aMaxSize.width)
|
|
|
|
aMinSize.width = aMaxSize.width;
|
|
|
|
|
|
|
|
if (aMinSize.height > aMaxSize.height)
|
|
|
|
aMinSize.height = aMaxSize.height;
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
if (aMinSize.width > aMaxSize.width)
|
|
|
|
aMaxSize.width = aMinSize.width;
|
|
|
|
|
|
|
|
if (aMinSize.height > aMaxSize.height)
|
|
|
|
aMaxSize.height = aMinSize.height;
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (aPrefSize.width > aMaxSize.width)
|
|
|
|
aPrefSize.width = aMaxSize.width;
|
|
|
|
|
|
|
|
if (aPrefSize.height > aMaxSize.height)
|
|
|
|
aPrefSize.height = aMaxSize.height;
|
|
|
|
|
|
|
|
if (aPrefSize.width < aMinSize.width)
|
|
|
|
aPrefSize.width = aMinSize.width;
|
|
|
|
|
|
|
|
if (aPrefSize.height < aMinSize.height)
|
|
|
|
aPrefSize.height = aMinSize.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::GetDebugBoxAt( const nsPoint& aPoint,
|
|
|
|
nsIBox** aBox)
|
|
|
|
{
|
|
|
|
nsRect rect;
|
|
|
|
GetBounds(rect);
|
|
|
|
|
|
|
|
if (!rect.Contains(aPoint))
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsIBox* child = nsnull;
|
|
|
|
nsIBox* hit = nsnull;
|
|
|
|
GetChildBox(&child);
|
|
|
|
|
|
|
|
*aBox = nsnull;
|
2001-02-06 23:28:17 +00:00
|
|
|
nsPoint tmp;
|
2000-03-31 07:02:06 +00:00
|
|
|
tmp.MoveTo(aPoint.x - rect.x, aPoint.y - rect.y);
|
|
|
|
while (nsnull != child) {
|
|
|
|
nsresult rv = child->GetDebugBoxAt(tmp, &hit);
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rv) && hit) {
|
|
|
|
*aBox = hit;
|
|
|
|
}
|
|
|
|
child->GetNextBox(&child);
|
|
|
|
}
|
|
|
|
|
|
|
|
// found a child
|
|
|
|
if (*aBox) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// see if it is in our in our insets
|
|
|
|
nsMargin m;
|
|
|
|
GetBorderAndPadding(m);
|
|
|
|
rect.Deflate(m);
|
|
|
|
if (rect.Contains(aPoint)) {
|
|
|
|
GetInset(m);
|
|
|
|
rect.Deflate(m);
|
|
|
|
if (!rect.Contains(aPoint)) {
|
|
|
|
*aBox = this;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::GetDebug(PRBool& aDebug)
|
|
|
|
{
|
|
|
|
aDebug = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-04-18 00:17:00 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBox::GetMouseThrough(PRBool& aMouseThrough)
|
|
|
|
{
|
|
|
|
switch(mMouseThrough)
|
|
|
|
{
|
|
|
|
case always:
|
|
|
|
aMouseThrough = PR_TRUE;
|
|
|
|
return NS_OK;
|
|
|
|
case never:
|
|
|
|
aMouseThrough = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
case unset:
|
|
|
|
{
|
|
|
|
nsIBox* parent = nsnull;
|
|
|
|
GetParentBox(&parent);
|
|
|
|
if (parent)
|
|
|
|
return parent->GetMouseThrough(aMouseThrough);
|
|
|
|
else {
|
|
|
|
aMouseThrough = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsBox::GetDefaultFlex(PRInt32& aFlex)
|
|
|
|
{
|
|
|
|
aFlex = 0;
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
2000-05-15 04:12:31 +00:00
|
|
|
|
2000-04-05 06:41:27 +00:00
|
|
|
// nsISupports
|
|
|
|
NS_IMETHODIMP_(nsrefcnt)
|
|
|
|
nsBox::AddRef(void)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP_(nsrefcnt)
|
|
|
|
nsBox::Release(void)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// QueryInterface
|
|
|
|
//
|
|
|
|
NS_INTERFACE_MAP_BEGIN(nsBox)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIBox)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|