Merge mozilla-central and mozilla-inbound

This commit is contained in:
Ehsan Akhgari 2011-06-28 18:43:09 -04:00
Родитель df8be532a5 f3e14ab46c
Коммит 157101cbf6
43 изменённых файлов: 790 добавлений и 570 удалений

Просмотреть файл

@ -708,6 +708,7 @@ public:
* See nsIDOMEventTarget
*/
NS_DECL_NSIDOMEVENTTARGET
using nsIDOMEventTarget::AddEventListener;
/**
* Adds a mutation observer to be notified when this node, or any of its

Просмотреть файл

@ -1746,6 +1746,7 @@ GK_ATOM(pageBreakFrame, "PageBreakFrame")
GK_ATOM(pageContentFrame, "PageContentFrame")
GK_ATOM(placeholderFrame, "PlaceholderFrame")
GK_ATOM(popupSetFrame, "PopupSetFrame")
GK_ATOM(positionedInlineFrame, "PositionedInlineFrame")
GK_ATOM(canvasFrame, "CanvasFrame")
GK_ATOM(rootFrame, "RootFrame")
GK_ATOM(scrollFrame, "ScrollFrame")

Просмотреть файл

@ -153,19 +153,21 @@ template <class T> struct StripConst<const T> { typedef T result; };
* Traits class for identifying POD types. Until C++0x, there is no automatic
* way to detect PODs, so for the moment it is done manually.
*/
template <class T> struct IsPodType { static const bool result = false; };
template <> struct IsPodType<char> { static const bool result = true; };
template <> struct IsPodType<signed char> { static const bool result = true; };
template <> struct IsPodType<unsigned char> { static const bool result = true; };
template <> struct IsPodType<short> { static const bool result = true; };
template <> struct IsPodType<unsigned short> { static const bool result = true; };
template <> struct IsPodType<int> { static const bool result = true; };
template <> struct IsPodType<unsigned int> { static const bool result = true; };
template <> struct IsPodType<long> { static const bool result = true; };
template <> struct IsPodType<unsigned long> { static const bool result = true; };
template <> struct IsPodType<float> { static const bool result = true; };
template <> struct IsPodType<double> { static const bool result = true; };
template <typename T> struct IsPodType<T *> { static const bool result = true; };
template <class T> struct IsPodType { static const bool result = false; };
template <> struct IsPodType<char> { static const bool result = true; };
template <> struct IsPodType<signed char> { static const bool result = true; };
template <> struct IsPodType<unsigned char> { static const bool result = true; };
template <> struct IsPodType<short> { static const bool result = true; };
template <> struct IsPodType<unsigned short> { static const bool result = true; };
template <> struct IsPodType<int> { static const bool result = true; };
template <> struct IsPodType<unsigned int> { static const bool result = true; };
template <> struct IsPodType<long> { static const bool result = true; };
template <> struct IsPodType<unsigned long> { static const bool result = true; };
template <> struct IsPodType<long long> { static const bool result = true; };
template <> struct IsPodType<unsigned long long> { static const bool result = true; };
template <> struct IsPodType<float> { static const bool result = true; };
template <> struct IsPodType<double> { static const bool result = true; };
template <typename T> struct IsPodType<T *> { static const bool result = true; };
/* Return the size/end of an array without using macros. */
template <class T, size_t N> inline T *ArraySize(T (&)[N]) { return N; }

Просмотреть файл

@ -1020,10 +1020,6 @@ nsFrameConstructorState::PushAbsoluteContainingBlock(nsIFrame* aNewAbsoluteConta
*/
mFixedPosIsAbsPos = (aNewAbsoluteContainingBlock &&
aNewAbsoluteContainingBlock->GetStyleDisplay()->HasTransform());
if (aNewAbsoluteContainingBlock) {
aNewAbsoluteContainingBlock->MarkAsAbsoluteContainingBlock();
}
}
void
@ -1219,14 +1215,7 @@ nsFrameConstructorState::ProcessFrameInsertions(nsAbsoluteItems& aFrameItems,
nsresult rv = NS_OK;
if (childList.IsEmpty() &&
(containingBlock->GetStateBits() & NS_FRAME_FIRST_REFLOW)) {
// If we're injecting absolutely positioned frames, inject them on the
// absolute containing block
if (aChildListName == containingBlock->GetAbsoluteListName()) {
rv = containingBlock->GetAbsoluteContainingBlock()->
SetInitialChildList(containingBlock, aChildListName, aFrameItems);
} else {
rv = containingBlock->SetInitialChildList(aChildListName, aFrameItems);
}
rv = containingBlock->SetInitialChildList(aChildListName, aFrameItems);
} else {
// Note that whether the frame construction context is doing an append or
// not is not helpful here, since it could be appending to some frame in
@ -1244,7 +1233,7 @@ nsFrameConstructorState::ProcessFrameInsertions(nsAbsoluteItems& aFrameItems,
if (!lastChild ||
nsLayoutUtils::CompareTreePosition(lastChild, firstNewFrame, containingBlock) < 0) {
// no lastChild, or lastChild comes before the new children, so just append
rv = mFrameManager->AppendFrames(containingBlock, aChildListName, aFrameItems);
rv = containingBlock->AppendFrames(aChildListName, aFrameItems);
} else {
// try the other children
nsIFrame* insertionPoint = nsnull;
@ -1259,8 +1248,8 @@ nsFrameConstructorState::ProcessFrameInsertions(nsAbsoluteItems& aFrameItems,
}
insertionPoint = f;
}
rv = mFrameManager->InsertFrames(containingBlock, aChildListName,
insertionPoint, aFrameItems);
rv = containingBlock->InsertFrames(aChildListName, insertionPoint,
aFrameItems);
}
}
@ -2553,8 +2542,6 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIFrame** aNewFrame)
// The viewport is the containing block for 'fixed' elements
mFixedContainingBlock = viewportFrame;
// Make it an absolute container for fixed-pos elements
mFixedContainingBlock->MarkAsAbsoluteContainingBlock();
*aNewFrame = viewportFrame;
return NS_OK;
@ -2839,8 +2826,6 @@ nsCSSFrameConstructor::ConstructPageFrame(nsIPresShell* aPresShell,
pageContentFrame->Init(nsnull, aPageFrame, prevPageContentFrame);
SetInitialSingleChild(aPageFrame, pageContentFrame);
mFixedContainingBlock = pageContentFrame;
// Make it an absolute container for fixed-pos elements
mFixedContainingBlock->MarkAsAbsoluteContainingBlock();
nsRefPtr<nsStyleContext> canvasPseudoStyle;
canvasPseudoStyle = styleSet->ResolveAnonymousBoxStyle(nsCSSAnonBoxes::canvas,
@ -5528,7 +5513,7 @@ nsCSSFrameConstructor::GetAbsoluteContainingBlock(nsIFrame* aFrame)
#ifdef MOZ_XUL
nsGkAtoms::XULLabelFrame == frameType ||
#endif
(nsGkAtoms::inlineFrame == frameType && wrappedFrame->IsAbsoluteContainer())) {
nsGkAtoms::positionedInlineFrame == frameType) {
containingBlock = wrappedFrame;
} else if (nsGkAtoms::fieldSetFrame == frameType) {
// If the positioned frame is a fieldset, use the area frame inside it.
@ -8484,6 +8469,13 @@ nsCSSFrameConstructor::CreateContinuingFrame(nsPresContext* aPresContext,
if (newFrame) {
newFrame->Init(content, aParentFrame, aFrame);
}
} else if (nsGkAtoms::positionedInlineFrame == frameType) {
newFrame = NS_NewPositionedInlineFrame(shell, styleContext);
if (newFrame) {
newFrame->Init(content, aParentFrame, aFrame);
}
} else if (nsGkAtoms::pageFrame == frameType) {
nsIFrame* canvasFrame;
@ -10714,7 +10706,11 @@ nsCSSFrameConstructor::ConstructInline(nsFrameConstructorState& aState,
NS_STYLE_DISPLAY_INLINE == aDisplay->mDisplay &&
(NS_STYLE_POSITION_RELATIVE == aDisplay->mPosition ||
aDisplay->HasTransform());
newFrame = NS_NewInlineFrame(mPresShell, styleContext);
if (positioned) {
newFrame = NS_NewPositionedInlineFrame(mPresShell, styleContext);
} else {
newFrame = NS_NewInlineFrame(mPresShell, styleContext);
}
// Initialize the frame
InitAndRestoreFrame(aState, content, aParentFrame, nsnull, newFrame);
@ -10723,7 +10719,7 @@ nsCSSFrameConstructor::ConstructInline(nsFrameConstructorState& aState,
// because the object's destructor is significant
// this is part of the fix for bug 42372
if (positioned) {
if (positioned) {
// Relatively positioned frames becomes a container for child
// frames that are positioned
aState.PushAbsoluteContainingBlock(newFrame, absoluteSaveState);
@ -10822,15 +10818,17 @@ nsCSSFrameConstructor::CreateIBSiblings(nsFrameConstructorState& aState,
// Now grab the initial inlines in aChildItems and put them into an inline
// frame
nsIFrame* inlineFrame = NS_NewInlineFrame(mPresShell, styleContext);
nsIFrame* inlineFrame;
if (aIsPositioned) {
inlineFrame = NS_NewPositionedInlineFrame(mPresShell, styleContext);
}
else {
inlineFrame = NS_NewInlineFrame(mPresShell, styleContext);
}
InitAndRestoreFrame(aState, content, parentFrame, nsnull, inlineFrame,
PR_FALSE);
if (aIsPositioned) {
inlineFrame->MarkAsAbsoluteContainingBlock();
}
if (aChildItems.NotEmpty()) {
nsFrameList::FrameLinkEnumerator firstBlock(aChildItems);
FindFirstBlock(firstBlock);

Просмотреть файл

@ -2545,7 +2545,8 @@ PrepareBackgroundLayer(nsPresContext* aPresContext,
nsIAtom* frameType = aForFrame->GetType();
nsIFrame* geometryFrame = aForFrame;
if (frameType == nsGkAtoms::inlineFrame) {
if (frameType == nsGkAtoms::inlineFrame ||
frameType == nsGkAtoms::positionedInlineFrame) {
// XXXjwalden Strictly speaking this is not quite faithful to how
// background-break is supposed to interact with background-origin values,
// but it's a non-trivial amount of work to make it fully conformant, and

Просмотреть файл

@ -178,7 +178,7 @@ static const char sPrintOptionsContractID[] = "@mozilla.org/gfx/printset
//focus
#include "nsIDOMEventTarget.h"
#include "nsIDOMFocusListener.h"
#include "nsIDOMEventListener.h"
#include "nsISelectionController.h"
#include "nsBidiUtils.h"
@ -261,7 +261,7 @@ protected:
/** editor Implementation of the FocusListener interface
*/
class nsDocViewerFocusListener : public nsIDOMFocusListener
class nsDocViewerFocusListener : public nsIDOMEventListener
{
public:
/** default constructor
@ -271,15 +271,9 @@ public:
*/
virtual ~nsDocViewerFocusListener();
/*interfaces for addref and release and queryinterface*/
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMEVENTLISTENER
/*BEGIN implementations of focus event handler interface*/
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
NS_IMETHOD Focus(nsIDOMEvent* aEvent);
NS_IMETHOD Blur(nsIDOMEvent* aEvent);
/*END implementations of focus event handler interface*/
nsresult Init(DocumentViewerImpl *aDocViewer);
private:
@ -455,7 +449,7 @@ protected:
nsCOMPtr<nsIPresShell> mPresShell;
nsCOMPtr<nsISelectionListener> mSelectionListener;
nsCOMPtr<nsIDOMFocusListener> mFocusListener;
nsRefPtr<nsDocViewerFocusListener> mFocusListener;
nsCOMPtr<nsIContentViewer> mPreviousViewer;
nsCOMPtr<nsISHEntry> mSHEntry;
@ -814,7 +808,7 @@ DocumentViewerImpl::InitPresentationStuff(PRBool aDoInitialReflow)
return rv;
// Save old listener so we can unregister it
nsCOMPtr<nsIDOMFocusListener> oldFocusListener = mFocusListener;
nsRefPtr<nsDocViewerFocusListener> oldFocusListener = mFocusListener;
// focus listener
//
@ -828,13 +822,18 @@ DocumentViewerImpl::InitPresentationStuff(PRBool aDoInitialReflow)
mFocusListener = focusListener;
if (mDocument) {
rv = mDocument->AddEventListenerByIID(mFocusListener,
NS_GET_IID(nsIDOMFocusListener));
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to register focus listener");
mDocument->AddEventListener(NS_LITERAL_STRING("focus"),
mFocusListener,
PR_FALSE, PR_FALSE);
mDocument->AddEventListener(NS_LITERAL_STRING("blur"),
mFocusListener,
PR_FALSE, PR_FALSE);
if (oldFocusListener) {
rv = mDocument->RemoveEventListenerByIID(oldFocusListener,
NS_GET_IID(nsIDOMFocusListener));
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to remove focus listener");
mDocument->RemoveEventListener(NS_LITERAL_STRING("focus"),
oldFocusListener, PR_FALSE);
mDocument->RemoveEventListener(NS_LITERAL_STRING("blur"),
oldFocusListener, PR_FALSE);
}
}
@ -1413,8 +1412,10 @@ DocumentViewerImpl::Open(nsISupports *aState, nsISHEntry *aSHEntry)
SyncParentSubDocMap();
if (mFocusListener && mDocument) {
mDocument->AddEventListenerByIID(mFocusListener,
NS_GET_IID(nsIDOMFocusListener));
mDocument->AddEventListener(NS_LITERAL_STRING("focus"), mFocusListener,
PR_FALSE, PR_FALSE);
mDocument->AddEventListener(NS_LITERAL_STRING("blur"), mFocusListener,
PR_FALSE, PR_FALSE);
}
// XXX re-enable image animations once that works correctly
@ -1491,8 +1492,10 @@ DocumentViewerImpl::Close(nsISHEntry *aSHEntry)
}
if (mFocusListener && mDocument) {
mDocument->RemoveEventListenerByIID(mFocusListener,
NS_GET_IID(nsIDOMFocusListener));
mDocument->RemoveEventListener(NS_LITERAL_STRING("focus"), mFocusListener,
PR_FALSE);
mDocument->RemoveEventListener(NS_LITERAL_STRING("blur"), mFocusListener,
PR_FALSE);
}
return NS_OK;
@ -3528,8 +3531,7 @@ NS_IMETHODIMP nsDocViewerSelectionListener::NotifySelectionChanged(nsIDOMDocumen
}
//nsDocViewerFocusListener
NS_IMPL_ISUPPORTS2(nsDocViewerFocusListener,
nsIDOMFocusListener,
NS_IMPL_ISUPPORTS1(nsDocViewerFocusListener,
nsIDOMEventListener)
nsDocViewerFocusListener::nsDocViewerFocusListener()
@ -3542,60 +3544,39 @@ nsDocViewerFocusListener::~nsDocViewerFocusListener(){}
nsresult
nsDocViewerFocusListener::HandleEvent(nsIDOMEvent* aEvent)
{
NS_ENSURE_STATE(mDocViewer);
nsCOMPtr<nsIPresShell> shell;
nsresult rv = mDocViewer->GetPresShell(getter_AddRefs(shell));
NS_ENSURE_TRUE(shell, NS_ERROR_FAILURE);
nsCOMPtr<nsISelectionController> selCon = do_QueryInterface(shell);
PRInt16 selectionStatus;
selCon->GetDisplaySelection(&selectionStatus);
nsAutoString eventType;
aEvent->GetType(eventType);
if (eventType.EqualsLiteral("focus")) {
// If selection was disabled, re-enable it.
if(selectionStatus == nsISelectionController::SELECTION_DISABLED ||
selectionStatus == nsISelectionController::SELECTION_HIDDEN) {
selCon->SetDisplaySelection(nsISelectionController::SELECTION_ON);
selCon->RepaintSelection(nsISelectionController::SELECTION_NORMAL);
}
} else {
NS_ABORT_IF_FALSE(eventType.EqualsLiteral("blur"),
"Unexpected event type");
// If selection was on, disable it.
if(selectionStatus == nsISelectionController::SELECTION_ON ||
selectionStatus == nsISelectionController::SELECTION_ATTENTION) {
selCon->SetDisplaySelection(nsISelectionController::SELECTION_DISABLED);
selCon->RepaintSelection(nsISelectionController::SELECTION_NORMAL);
}
}
return NS_OK;
}
NS_IMETHODIMP
nsDocViewerFocusListener::Focus(nsIDOMEvent* aEvent)
{
nsCOMPtr<nsIPresShell> shell;
if(!mDocViewer)
return NS_ERROR_FAILURE;
nsresult result = mDocViewer->GetPresShell(getter_AddRefs(shell));
if(NS_FAILED(result) || !shell)
return result?result:NS_ERROR_FAILURE;
nsCOMPtr<nsISelectionController> selCon;
selCon = do_QueryInterface(shell);
PRInt16 selectionStatus;
selCon->GetDisplaySelection(&selectionStatus);
// If selection was disabled, re-enable it.
if(selectionStatus == nsISelectionController::SELECTION_DISABLED ||
selectionStatus == nsISelectionController::SELECTION_HIDDEN)
{
selCon->SetDisplaySelection(nsISelectionController::SELECTION_ON);
selCon->RepaintSelection(nsISelectionController::SELECTION_NORMAL);
}
return result;
}
NS_IMETHODIMP
nsDocViewerFocusListener::Blur(nsIDOMEvent* aEvent)
{
nsCOMPtr<nsIPresShell> shell;
if(!mDocViewer)
return NS_ERROR_FAILURE;
nsresult result = mDocViewer->GetPresShell(getter_AddRefs(shell));
if(NS_FAILED(result) || !shell)
return result?result:NS_ERROR_FAILURE;
nsCOMPtr<nsISelectionController> selCon;
selCon = do_QueryInterface(shell);
PRInt16 selectionStatus;
selCon->GetDisplaySelection(&selectionStatus);
// If selection was on, disable it.
if(selectionStatus == nsISelectionController::SELECTION_ON ||
selectionStatus == nsISelectionController::SELECTION_ATTENTION)
{
selCon->SetDisplaySelection(nsISelectionController::SELECTION_DISABLED);
selCon->RepaintSelection(nsISelectionController::SELECTION_NORMAL);
}
return result;
}
nsresult
nsDocViewerFocusListener::Init(DocumentViewerImpl *aDocViewer)
{

Просмотреть файл

@ -93,7 +93,6 @@
#include "imgIRequest.h"
#include "nsTransitionManager.h"
#include "RestyleTracker.h"
#include "nsAbsoluteContainingBlock.h"
#include "nsFrameManager.h"
#include "nsRuleProcessorData.h"
@ -472,19 +471,6 @@ nsFrameManager::ClearAllUndisplayedContentIn(nsIContent* aParentContent)
}
//----------------------------------------------------------------------
nsresult
nsFrameManager::AppendFrames(nsIFrame* aParentFrame,
nsIAtom* aListName,
nsFrameList& aFrameList)
{
if (aParentFrame->IsAbsoluteContainer() &&
aListName == aParentFrame->GetAbsoluteListName()) {
return aParentFrame->GetAbsoluteContainingBlock()->
AppendFrames(aParentFrame, aListName, aFrameList);
} else {
return aParentFrame->AppendFrames(aListName, aFrameList);
}
}
nsresult
nsFrameManager::InsertFrames(nsIFrame* aParentFrame,
@ -497,13 +483,7 @@ nsFrameManager::InsertFrames(nsIFrame* aParentFrame,
&& !IS_TRUE_OVERFLOW_CONTAINER(aPrevFrame),
"aPrevFrame must be the last continuation in its chain!");
if (aParentFrame->IsAbsoluteContainer() &&
aListName == aParentFrame->GetAbsoluteListName()) {
return aParentFrame->GetAbsoluteContainingBlock()->
InsertFrames(aParentFrame, aListName, aPrevFrame, aFrameList);
} else {
return aParentFrame->InsertFrames(aListName, aPrevFrame, aFrameList);
}
return aParentFrame->InsertFrames(aListName, aPrevFrame, aFrameList);
}
nsresult
@ -528,15 +508,7 @@ nsFrameManager::RemoveFrame(nsIAtom* aListName,
NS_ASSERTION(!(aOldFrame->GetStateBits() & NS_FRAME_OUT_OF_FLOW &&
GetPlaceholderFrameFor(aOldFrame)),
"Must call RemoveFrame on placeholder for out-of-flows.");
nsresult rv = NS_OK;
nsIFrame* parentFrame = aOldFrame->GetParent();
if (parentFrame->IsAbsoluteContainer() &&
aListName == parentFrame->GetAbsoluteListName()) {
parentFrame->GetAbsoluteContainingBlock()->
RemoveFrame(parentFrame, aListName, aOldFrame);
} else {
rv = parentFrame->RemoveFrame(aListName, aOldFrame);
}
nsresult rv = aOldFrame->GetParent()->RemoveFrame(aListName, aOldFrame);
mIsDestroyingFrames = wasDestroyingFrames;

Просмотреть файл

@ -124,7 +124,10 @@ public:
// Functions for manipulating the frame model
NS_HIDDEN_(nsresult) AppendFrames(nsIFrame* aParentFrame,
nsIAtom* aListName,
nsFrameList& aFrameList);
nsFrameList& aFrameList)
{
return aParentFrame->AppendFrames(aListName, aFrameList);
}
NS_HIDDEN_(nsresult) InsertFrames(nsIFrame* aParentFrame,
nsIAtom* aListName,

Просмотреть файл

@ -173,6 +173,7 @@ The entries in the reflow log can be controlled on a frame level. For instance
<tr><td>obj</td><td>object</td></tr>
<tr><td>page</td><td>page</td></tr>
<tr><td>place</td><td>placeholder</td></tr>
<tr><td>posInline</td><td>positionedInline</td></tr>
<tr><td>canvas</td><td>canvas</td></tr>
<tr><td>root</td><td>root</td></tr>
<tr><td>scroll</td><td>scroll</td></tr>

Просмотреть файл

@ -427,7 +427,7 @@ nsAbsoluteContainingBlock::ReflowAbsoluteFrame(nsIFrame* aDelegat
PRBool constrainHeight = (aReflowState.availableHeight != NS_UNCONSTRAINEDSIZE)
&& aConstrainHeight
// Don't split if told not to (e.g. for fixed frames)
&& (aDelegatingFrame->GetType() != nsGkAtoms::inlineFrame)
&& (aDelegatingFrame->GetType() != nsGkAtoms::positionedInlineFrame)
//XXX we don't handle splitting frames for inline absolute containing blocks yet
&& (aKidFrame->GetRect().y <= aReflowState.availableHeight);
// Don't split things below the fold. (Ideally we shouldn't *have*

Просмотреть файл

@ -308,7 +308,7 @@ nsBlockFrame::~nsBlockFrame()
void
nsBlockFrame::DestroyFrom(nsIFrame* aDestructRoot)
{
DestroyAbsoluteFrames(aDestructRoot);
mAbsoluteContainer.DestroyFrames(this, aDestructRoot);
// Outside bullets are not in our child-list so check for them here
// and delete them when present.
if (mBullet && HaveOutsideBullet()) {
@ -585,7 +585,10 @@ nsBlockFrame::GetCaretBaseline() const
nsFrameList
nsBlockFrame::GetChildList(nsIAtom* aListName) const
{
if (nsnull == aListName) {
if (nsGkAtoms::absoluteList == aListName) {
return mAbsoluteContainer.GetChildList();
}
else if (nsnull == aListName) {
return mFrames;
}
else if (aListName == nsGkAtoms::overflowList) {
@ -617,7 +620,8 @@ nsBlockFrame::GetChildList(nsIAtom* aListName) const
#define NS_BLOCK_FRAME_OVERFLOW_OOF_LIST_INDEX (NS_CONTAINER_LIST_COUNT_INCL_OC + 0)
#define NS_BLOCK_FRAME_FLOAT_LIST_INDEX (NS_CONTAINER_LIST_COUNT_INCL_OC + 1)
#define NS_BLOCK_FRAME_BULLET_LIST_INDEX (NS_CONTAINER_LIST_COUNT_INCL_OC + 2)
#define NS_BLOCK_FRAME_PUSHED_FLOATS_LIST_INDEX (NS_CONTAINER_LIST_COUNT_INCL_OC + 3)
#define NS_BLOCK_FRAME_ABSOLUTE_LIST_INDEX (NS_CONTAINER_LIST_COUNT_INCL_OC + 3)
#define NS_BLOCK_FRAME_PUSHED_FLOATS_LIST_INDEX (NS_CONTAINER_LIST_COUNT_INCL_OC + 4)
// If adding/removing lists, don't forget to update the count in nsBlockFrame.h
nsIAtom*
@ -633,6 +637,8 @@ nsBlockFrame::GetAdditionalChildListName(PRInt32 aIndex) const
return nsGkAtoms::bulletList;
case NS_BLOCK_FRAME_OVERFLOW_OOF_LIST_INDEX:
return nsGkAtoms::overflowOutOfFlowList;
case NS_BLOCK_FRAME_ABSOLUTE_LIST_INDEX:
return nsGkAtoms::absoluteList;
case NS_BLOCK_FRAME_PUSHED_FLOATS_LIST_INDEX:
return nsGkAtoms::pushedFloatsList;
default:
@ -1170,8 +1176,7 @@ nsBlockFrame::Reflow(nsPresContext* aPresContext,
// resetting the size. Because of this, we must not reflow our abs-pos children
// in that situation --- what we think is our "new size"
// will not be our real new size. This also happens to be more efficient.
if (HasAbsolutelyPositionedChildren()) {
nsAbsoluteContainingBlock* absoluteContainer = GetAbsoluteContainingBlock();
if (mAbsoluteContainer.HasAbsoluteFrames()) {
PRBool haveInterrupt = aPresContext->HasPendingInterrupt();
if (reflowState->WillReflowAgainForClearance() ||
haveInterrupt) {
@ -1182,9 +1187,9 @@ nsBlockFrame::Reflow(nsPresContext* aPresContext,
// better than that, because we don't really know what our size will be,
// and it might in fact not change on the followup reflow!
if (haveInterrupt && (GetStateBits() & NS_FRAME_IS_DIRTY)) {
absoluteContainer->MarkAllFramesDirty();
mAbsoluteContainer.MarkAllFramesDirty();
} else {
absoluteContainer->MarkSizeDependentFramesDirty();
mAbsoluteContainer.MarkSizeDependentFramesDirty();
}
} else {
nsSize containingBlockSize =
@ -1208,12 +1213,12 @@ nsBlockFrame::Reflow(nsPresContext* aPresContext,
!(isRoot && NS_UNCONSTRAINEDSIZE == reflowState->ComputedHeight()) &&
aMetrics.height != oldSize.height;
absoluteContainer->Reflow(this, aPresContext, *reflowState,
state.mReflowStatus,
containingBlockSize.width,
containingBlockSize.height, PR_TRUE,
cbWidthChanged, cbHeightChanged,
&aMetrics.mOverflowAreas);
rv = mAbsoluteContainer.Reflow(this, aPresContext, *reflowState,
state.mReflowStatus,
containingBlockSize.width,
containingBlockSize.height, PR_TRUE,
cbWidthChanged, cbHeightChanged,
&aMetrics.mOverflowAreas);
//XXXfr Why isn't this rv (and others in this file) checked/returned?
}
@ -4703,7 +4708,10 @@ nsBlockFrame::AppendFrames(nsIAtom* aListName,
return NS_OK;
}
if (aListName) {
if (nsGkAtoms::floatList == aListName) {
if (nsGkAtoms::absoluteList == aListName) {
return mAbsoluteContainer.AppendFrames(this, aListName, aFrameList);
}
else if (nsGkAtoms::floatList == aListName) {
mFloats.AppendFrames(nsnull, aFrameList);
return NS_OK;
}
@ -4748,7 +4756,11 @@ nsBlockFrame::InsertFrames(nsIAtom* aListName,
"inserting after sibling frame with different parent");
if (aListName) {
if (nsGkAtoms::floatList == aListName) {
if (nsGkAtoms::absoluteList == aListName) {
return mAbsoluteContainer.InsertFrames(this, aListName, aPrevFrame,
aFrameList);
}
else if (nsGkAtoms::floatList == aListName) {
mFloats.InsertFrames(this, aPrevFrame, aFrameList);
return NS_OK;
}
@ -5009,6 +5021,10 @@ nsBlockFrame::RemoveFrame(nsIAtom* aListName,
MarkSameFloatManagerLinesDirty(this);
}
}
else if (nsGkAtoms::absoluteList == aListName) {
mAbsoluteContainer.RemoveFrame(this, aListName, aOldFrame);
return NS_OK;
}
else if (nsGkAtoms::floatList == aListName) {
// Make sure to mark affected lines dirty for the float frame
// we are removing; this way is a bit messy, but so is the rest of the code.
@ -5051,9 +5067,9 @@ nsBlockFrame::DoRemoveOutOfFlowFrame(nsIFrame* aFrame)
const nsStyleDisplay* display = aFrame->GetStyleDisplay();
if (display->IsAbsolutelyPositioned()) {
// This also deletes the next-in-flows
block->GetAbsoluteContainingBlock()->RemoveFrame(block,
nsGkAtoms::absoluteList,
aFrame);
block->mAbsoluteContainer.RemoveFrame(block,
nsGkAtoms::absoluteList,
aFrame);
}
else {
// First remove aFrame's next-in-flows
@ -6252,6 +6268,8 @@ nsBlockFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
}
aBuilder->MarkFramesForDisplayList(this, mFloats, aDirtyRect);
aBuilder->MarkFramesForDisplayList(this, mAbsoluteContainer.GetChildList(),
aDirtyRect);
// Prepare for text-overflow processing.
nsAutoPtr<TextOverflow> textOverflow(
@ -6515,7 +6533,10 @@ nsBlockFrame::SetInitialChildList(nsIAtom* aListName,
{
nsresult rv = NS_OK;
if (nsGkAtoms::floatList == aListName) {
if (nsGkAtoms::absoluteList == aListName) {
mAbsoluteContainer.SetInitialChildList(this, aListName, aChildList);
}
else if (nsGkAtoms::floatList == aListName) {
mFloats.SetFrames(aChildList);
}
else {

Просмотреть файл

@ -84,7 +84,7 @@ class nsIntervalSet;
* Child list name indices
* @see #GetAdditionalChildListName()
*/
#define NS_BLOCK_LIST_COUNT (NS_CONTAINER_LIST_COUNT_INCL_OC + 4)
#define NS_BLOCK_LIST_COUNT (NS_CONTAINER_LIST_COUNT_INCL_OC + 5)
/**
* Some invariants:
@ -341,6 +341,7 @@ protected:
: nsHTMLContainerFrame(aContext)
, mMinWidth(NS_INTRINSIC_WIDTH_UNKNOWN)
, mPrefWidth(NS_INTRINSIC_WIDTH_UNKNOWN)
, mAbsoluteContainer(nsGkAtoms::absoluteList)
{
#ifdef DEBUG
InitDebugFlags();
@ -776,6 +777,10 @@ protected:
friend class nsBlockReflowState;
friend class nsBlockInFlowLineIterator;
private:
nsAbsoluteContainingBlock mAbsoluteContainer;
#ifdef DEBUG
public:
static PRBool gLamePaintMetrics;

Просмотреть файл

@ -52,6 +52,7 @@
#include "nsIPresShell.h"
#include "nsIScrollPositionListener.h"
#include "nsDisplayList.h"
#include "nsAbsoluteContainingBlock.h"
#include "nsCSSFrameConstructor.h"
#include "nsFrameManager.h"
@ -64,6 +65,8 @@
//#define DEBUG_CANVAS_FOCUS
#endif
#define CANVAS_ABS_POS_CHILD_LIST NS_CONTAINER_LIST_COUNT_INCL_OC
nsIFrame*
NS_NewCanvasFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
@ -80,7 +83,8 @@ NS_QUERYFRAME_TAIL_INHERITING(nsHTMLContainerFrame)
void
nsCanvasFrame::DestroyFrom(nsIFrame* aDestructRoot)
{
DestroyAbsoluteFrames(aDestructRoot);
mAbsoluteContainer.DestroyFrames(this, aDestructRoot);
nsIScrollableFrame* sf =
PresContext()->GetPresShell()->GetRootScrollFrameAsScrollable();
if (sf) {
@ -122,6 +126,9 @@ NS_IMETHODIMP
nsCanvasFrame::SetInitialChildList(nsIAtom* aListName,
nsFrameList& aChildList)
{
if (nsGkAtoms::absoluteList == aListName)
return mAbsoluteContainer.SetInitialChildList(this, aListName, aChildList);
NS_ASSERTION(aListName || aChildList.IsEmpty() || aChildList.OnlyChild(),
"Primary child list can have at most one frame in it");
return nsHTMLContainerFrame::SetInitialChildList(aListName, aChildList);
@ -131,6 +138,9 @@ NS_IMETHODIMP
nsCanvasFrame::AppendFrames(nsIAtom* aListName,
nsFrameList& aFrameList)
{
if (nsGkAtoms::absoluteList == aListName)
return mAbsoluteContainer.AppendFrames(this, aListName, aFrameList);
NS_ASSERTION(!aListName, "unexpected child list name");
NS_PRECONDITION(mFrames.IsEmpty(), "already have a child frame");
if (aListName) {
@ -163,6 +173,9 @@ nsCanvasFrame::InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsFrameList& aFrameList)
{
if (nsGkAtoms::absoluteList == aListName)
return mAbsoluteContainer.InsertFrames(this, aListName, aPrevFrame, aFrameList);
// Because we only support a single child frame inserting is the same
// as appending
NS_PRECONDITION(!aPrevFrame, "unexpected previous sibling frame");
@ -176,6 +189,11 @@ NS_IMETHODIMP
nsCanvasFrame::RemoveFrame(nsIAtom* aListName,
nsIFrame* aOldFrame)
{
if (nsGkAtoms::absoluteList == aListName) {
mAbsoluteContainer.RemoveFrame(this, aListName, aOldFrame);
return NS_OK;
}
NS_ASSERTION(!aListName, "unexpected child list name");
if (aListName) {
// We only support the unnamed principal child list
@ -200,6 +218,24 @@ nsCanvasFrame::RemoveFrame(nsIAtom* aListName,
return NS_OK;
}
nsIAtom*
nsCanvasFrame::GetAdditionalChildListName(PRInt32 aIndex) const
{
if (CANVAS_ABS_POS_CHILD_LIST == aIndex)
return nsGkAtoms::absoluteList;
return nsHTMLContainerFrame::GetAdditionalChildListName(aIndex);
}
nsFrameList
nsCanvasFrame::GetChildList(nsIAtom* aListName) const
{
if (nsGkAtoms::absoluteList == aListName)
return mAbsoluteContainer.GetChildList();
return nsHTMLContainerFrame::GetChildList(aListName);
}
nsRect nsCanvasFrame::CanvasArea() const
{
// Not clear which overflow rect we want here, but it probably doesn't
@ -278,6 +314,9 @@ nsCanvasFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
DisplayOverflowContainers(aBuilder, aDirtyRect, aLists);
}
aBuilder->MarkFramesForDisplayList(this, mAbsoluteContainer.GetChildList(),
aDirtyRect);
// Force a background to be shown. We may have a background propagated to us,
// in which case GetStyleBackground wouldn't have the right background
// and the code in nsFrame::DisplayBorderBackgroundOutline might not give us
@ -514,6 +553,15 @@ nsCanvasFrame::Reflow(nsPresContext* aPresContext,
aDesiredSize.mOverflowAreas.UnionWith(
kidDesiredSize.mOverflowAreas + kidPt);
if (mAbsoluteContainer.HasAbsoluteFrames()) {
PRBool widthChanged = aDesiredSize.width != mRect.width;
PRBool heightChanged = aDesiredSize.height != mRect.height;
mAbsoluteContainer.Reflow(this, aPresContext, aReflowState, aStatus,
aDesiredSize.width, aDesiredSize.height,
PR_TRUE, widthChanged, heightChanged,
&aDesiredSize.mOverflowAreas);
}
// Handle invalidating fixed-attachment backgrounds propagated to the
// canvas when the canvas size (and therefore the background positioning
// area's size) changes. Such backgrounds are not invalidated in the
@ -554,7 +602,7 @@ nsCanvasFrame::Reflow(nsPresContext* aPresContext,
aStatus);
}
FinishReflowWithAbsoluteFrames(aPresContext, aDesiredSize, aReflowState, aStatus);
FinishAndStoreOverflow(&aDesiredSize);
NS_FRAME_TRACE_REFLOW_OUT("nsCanvasFrame::Reflow", aStatus);
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);

Просмотреть файл

@ -42,6 +42,7 @@
#include "nsHTMLContainerFrame.h"
#include "nsIScrollPositionListener.h"
#include "nsAbsoluteContainingBlock.h"
#include "nsDisplayList.h"
#include "nsGkAtoms.h"
@ -63,7 +64,8 @@ public:
nsCanvasFrame(nsStyleContext* aContext)
: nsHTMLContainerFrame(aContext),
mDoPaintFocus(PR_FALSE),
mAddedScrollPositionListener(PR_FALSE) {}
mAddedScrollPositionListener(PR_FALSE),
mAbsoluteContainer(nsGkAtoms::absoluteList) {}
NS_DECL_QUERYFRAME_TARGET(nsCanvasFrame)
NS_DECL_QUERYFRAME
@ -82,6 +84,9 @@ public:
NS_IMETHOD RemoveFrame(nsIAtom* aListName,
nsIFrame* aOldFrame);
virtual nsIAtom* GetAdditionalChildListName(PRInt32 aIndex) const;
virtual nsFrameList GetChildList(nsIAtom* aListName) const;
virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext);
virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext);
NS_IMETHOD Reflow(nsPresContext* aPresContext,
@ -147,6 +152,7 @@ protected:
// Data members
PRPackedBool mDoPaintFocus;
PRPackedBool mAddedScrollPositionListener;
nsAbsoluteContainingBlock mAbsoluteContainer;
};
/**

Просмотреть файл

@ -319,12 +319,12 @@ nsContainerFrame::GetChildList(nsIAtom* aListName) const
return list ? *list : nsFrameList::EmptyList();
}
return nsSplittableFrame::GetChildList(aListName);
return nsFrameList::EmptyList();
}
#define NS_CONTAINER_FRAME_OVERFLOW_LIST_INDEX 1
#define NS_CONTAINER_FRAME_OVERFLOW_CONTAINERS_LIST_INDEX 2
#define NS_CONTAINER_FRAME_EXCESS_OVERFLOW_CONTAINERS_LIST_INDEX 3
#define NS_CONTAINER_FRAME_OVERFLOW_LIST_INDEX 0
#define NS_CONTAINER_FRAME_OVERFLOW_CONTAINERS_LIST_INDEX 1
#define NS_CONTAINER_FRAME_EXCESS_OVERFLOW_CONTAINERS_LIST_INDEX 2
// If adding/removing lists, don't forget to update count in .h file
@ -339,7 +339,7 @@ nsContainerFrame::GetAdditionalChildListName(PRInt32 aIndex) const
else if (NS_CONTAINER_FRAME_EXCESS_OVERFLOW_CONTAINERS_LIST_INDEX == aIndex)
return nsGkAtoms::excessOverflowContainersList;
}
return nsSplittableFrame::GetAdditionalChildListName(aIndex);
return nsnull;
}
/////////////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -50,7 +50,9 @@
* Child list name indices
* @see #GetAdditionalChildListName()
*/
#define NS_CONTAINER_LIST_COUNT_INCL_OC 4
#define NS_CONTAINER_LIST_COUNT_SANS_OC 1
// for frames that don't use overflow containers
#define NS_CONTAINER_LIST_COUNT_INCL_OC 3
// for frames that support overflow containers
// Option flags for ReflowChild() and FinishReflowChild()

Просмотреть файл

@ -122,7 +122,6 @@
#include "gfxContext.h"
#include "CSSCalc.h"
#include "nsAbsoluteContainingBlock.h"
#include "mozilla/Preferences.h"
@ -255,34 +254,6 @@ nsFrame::RootFrameList(nsPresContext* aPresContext, FILE* out, PRInt32 aIndent)
}
#endif
static void
DestroyAbsoluteContainingBlock(void* aPropertyValue)
{
delete static_cast<nsAbsoluteContainingBlock*>(aPropertyValue);
}
NS_DECLARE_FRAME_PROPERTY(AbsoluteContainingBlockProperty, DestroyAbsoluteContainingBlock)
PRBool
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
nsIFrame::MarkAsAbsoluteContainingBlock() {
AddStateBits(NS_FRAME_HAS_ABSPOS_CHILDREN);
Properties().Set(AbsoluteContainingBlockProperty(), new nsAbsoluteContainingBlock(GetAbsoluteListName()));
}
void
NS_MergeReflowStatusInto(nsReflowStatus* aPrimary, nsReflowStatus aSecondary)
{
@ -953,23 +924,13 @@ nsIAtom*
nsFrame::GetAdditionalChildListName(PRInt32 aIndex) const
{
NS_PRECONDITION(aIndex >= 0, "invalid index number");
// An index of 0 should always be an absolute list, we should ignore anything
// else if child frame types have ignored them.
if (aIndex == 0) {
return GetAbsoluteListName();
}
return nsnull;
}
nsFrameList
nsFrame::GetChildList(nsIAtom* aListName) const
{
if (IsAbsoluteContainer() &&
aListName == GetAbsoluteListName()) {
return GetAbsoluteContainingBlock()->GetChildList();
} else {
return nsFrameList::EmptyList();
}
return nsFrameList::EmptyList();
}
static nsIFrame*
@ -1489,9 +1450,6 @@ nsIFrame::BuildDisplayListForStackingContext(nsDisplayListBuilder* aBuilder,
nsSVGIntegrationUtils::GetRequiredSourceForInvalidArea(this, dirtyRect);
}
// Mark the display list items for absolutely positioned children
MarkAbsoluteFramesForDisplayList(aBuilder, dirtyRect);
nsDisplayListCollection set;
nsresult rv;
{
@ -1624,7 +1582,7 @@ nsIFrame::BuildDisplayListForChild(nsDisplayListBuilder* aBuilder,
if (aChild->GetStateBits() & NS_FRAME_TOO_DEEP_IN_FRAME_TREE)
return NS_OK;
const nsStyleDisplay* disp = aChild->GetStyleDisplay();
// PR_TRUE if this is a real or pseudo stacking context
PRBool pseudoStackingContext =
@ -1670,15 +1628,9 @@ nsIFrame::BuildDisplayListForChild(nsDisplayListBuilder* aBuilder,
dirty.SetEmpty();
}
pseudoStackingContext = PR_TRUE;
}
// Mark the display list items for absolutely positioned children
aChild->MarkAbsoluteFramesForDisplayList(aBuilder, dirty);
if (childType != nsGkAtoms::placeholderFrame &&
aBuilder->GetSelectedFramesOnly() &&
aChild->IsLeaf() &&
!(aChild->GetStateBits() & NS_FRAME_SELECTED_CONTENT)) {
} else if (aBuilder->GetSelectedFramesOnly() &&
aChild->IsLeaf() &&
!(aChild->GetStateBits() & NS_FRAME_SELECTED_CONTENT)) {
return NS_OK;
}
@ -1841,15 +1793,6 @@ nsIFrame::BuildDisplayListForChild(nsDisplayListBuilder* aBuilder,
return NS_OK;
}
void
nsIFrame::MarkAbsoluteFramesForDisplayList(nsDisplayListBuilder* aBuilder,
const nsRect& aDirtyRect)
{
if (IsAbsoluteContainer()) {
aBuilder->MarkFramesForDisplayList(this, GetAbsoluteContainingBlock()->GetChildList(), aDirtyRect);
}
}
void
nsIFrame::WrapReplacedContentForBorderRadius(nsDisplayListBuilder* aBuilder,
nsDisplayList* aFromList,
@ -3600,7 +3543,6 @@ nsFrame::DidReflow(nsPresContext* aPresContext,
{
NS_FRAME_TRACE_MSG(NS_FRAME_TRACE_CALLS,
("nsFrame::DidReflow: aStatus=%d", aStatus));
if (NS_FRAME_REFLOW_FINISHED == aStatus) {
mState &= ~(NS_FRAME_IN_REFLOW | NS_FRAME_FIRST_REFLOW | NS_FRAME_IS_DIRTY |
NS_FRAME_HAS_DIRTY_CHILDREN);
@ -3621,55 +3563,6 @@ nsFrame::DidReflow(nsPresContext* aPresContext,
return NS_OK;
}
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,
PR_TRUE, PR_TRUE, PR_TRUE, // XXX could be optimized
&aDesiredSize.mOverflowAreas);
}
}
/* virtual */ PRBool
nsFrame::CanContinueTextRun() const
{
@ -6270,7 +6163,8 @@ inline PRBool
IsInlineFrame(nsIFrame *aFrame)
{
nsIAtom *type = aFrame->GetType();
return type == nsGkAtoms::inlineFrame;
return type == nsGkAtoms::inlineFrame ||
type == nsGkAtoms::positionedInlineFrame;
}
void
@ -7985,6 +7879,7 @@ void DR_State::InitFrameTypeTable()
AddFrameTypeInfo(nsGkAtoms::objectFrame, "obj", "object");
AddFrameTypeInfo(nsGkAtoms::pageFrame, "page", "page");
AddFrameTypeInfo(nsGkAtoms::placeholderFrame, "place", "placeholder");
AddFrameTypeInfo(nsGkAtoms::positionedInlineFrame, "posInline", "positionedInline");
AddFrameTypeInfo(nsGkAtoms::canvasFrame, "canvas", "canvas");
AddFrameTypeInfo(nsGkAtoms::rootFrame, "root", "root");
AddFrameTypeInfo(nsGkAtoms::scrollFrame, "scroll", "scroll");

Просмотреть файл

@ -328,15 +328,6 @@ public:
NS_IMETHOD DidReflow(nsPresContext* aPresContext,
const nsHTMLReflowState* aReflowState,
nsDidReflowStatus aStatus);
void ReflowAbsoluteFrames(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
void FinishReflowWithAbsoluteFrames(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
void DestroyAbsoluteFrames(nsIFrame* aDestructRoot);
virtual PRBool CanContinueTextRun() const;
// Selection Methods

Просмотреть файл

@ -139,6 +139,8 @@ NS_NewImageFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
nsIFrame*
NS_NewInlineFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
nsIFrame*
NS_NewPositionedInlineFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
nsIFrame*
NS_NewObjectFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
nsIFrame*
NS_NewTextFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);

Просмотреть файл

@ -1573,7 +1573,7 @@ nsHTMLReflowState::ComputeContainingBlockRectangle(nsPresContext* aPres
if (NS_FRAME_GET_TYPE(aContainingBlockRS->mFrameType) == NS_CSS_FRAME_TYPE_INLINE) {
// Base our size on the actual size of the frame. In cases when this is
// completely bogus (eg initial reflow), this code shouldn't even be
// called, since the code in nsInlineFrame::Reflow will pass in
// called, since the code in nsPositionedInlineFrame::Reflow will pass in
// the containing block dimensions to our constructor.
// XXXbz we should be taking the in-flows into account too, but
// that's very hard.

Просмотреть файл

@ -103,7 +103,6 @@ class gfxSkipChars;
class gfxSkipCharsIterator;
class gfxContext;
class nsLineList_iterator;
class nsAbsoluteContainingBlock;
struct nsPeekOffsetStruct;
struct nsPoint;
@ -286,9 +285,6 @@ typedef PRUint64 nsFrameState;
// bit; we could free up this bit with a little extra complexity.
#define NS_FRAME_UPDATE_LAYER_TREE NS_FRAME_STATE_BIT(36)
// Frame can accept absolutely positioned children.
#define NS_FRAME_HAS_ABSPOS_CHILDREN NS_FRAME_STATE_BIT(37)
// The lower 20 bits and upper 32 bits of the frame state are reserved
// by this API.
#define NS_FRAME_RESERVED ~NS_FRAME_IMPL_RESERVED
@ -588,8 +584,6 @@ public:
* name means the unnamed principal child list
* @param aChildList list of child frames. Each of the frames has its
* NS_FRAME_IS_DIRTY bit set. Must not be empty.
* This method cannot handle the child list returned by
* GetAbsoluteListName().
* @return NS_ERROR_INVALID_ARG if there is no child list with the specified
* name,
* NS_ERROR_UNEXPECTED if the frame is an atomic frame or if the
@ -2707,17 +2701,7 @@ NS_PTR_TO_INT32(frame->Properties().Get(nsIFrame::EmbeddingLevelProperty()))
}
}
}
/**
* Accessors for the absolute containing block.
*/
PRBool IsAbsoluteContainer() const { return !!(mState & NS_FRAME_HAS_ABSPOS_CHILDREN); }
PRBool HasAbsolutelyPositionedChildren() const;
nsAbsoluteContainingBlock* GetAbsoluteContainingBlock() const;
virtual void MarkAsAbsoluteContainingBlock();
// Child frame types override this function to select their own child list name
virtual nsIAtom* GetAbsoluteListName() const { return nsGkAtoms::absoluteList; }
protected:
// Members
nsRect mRect;
@ -2728,8 +2712,6 @@ private:
nsIFrame* mNextSibling; // doubly-linked list of frames
nsIFrame* mPrevSibling; // Do not touch outside SetNextSibling!
void MarkAbsoluteFramesForDisplayList(nsDisplayListBuilder* aBuilder, const nsRect& aDirtyRect);
static void DestroyPaintedPresShellList(void* propertyValue) {
nsTArray<nsWeakPtr>* list = static_cast<nsTArray<nsWeakPtr>*>(propertyValue);
list->Clear();

Просмотреть файл

@ -703,9 +703,8 @@ nsImageMap::~nsImageMap()
NS_ASSERTION(mAreas.Length() == 0, "Destroy was not called");
}
NS_IMPL_ISUPPORTS3(nsImageMap,
NS_IMPL_ISUPPORTS2(nsImageMap,
nsIMutationObserver,
nsIDOMFocusListener,
nsIDOMEventListener)
nsresult
@ -740,7 +739,10 @@ nsImageMap::FreeAreas()
"Unexpected primary frame");
area->mArea->SetPrimaryFrame(nsnull);
area->mArea->RemoveEventListenerByIID(this, NS_GET_IID(nsIDOMFocusListener));
area->mArea->RemoveEventListener(NS_LITERAL_STRING("focus"), this,
PR_FALSE);
area->mArea->RemoveEventListener(NS_LITERAL_STRING("blur"), this,
PR_FALSE);
delete area;
}
mAreas.Clear();
@ -859,7 +861,10 @@ nsImageMap::AddArea(nsIContent* aArea)
return NS_ERROR_OUT_OF_MEMORY;
//Add focus listener to track area focus changes
aArea->AddEventListenerByIID(this, NS_GET_IID(nsIDOMFocusListener));
aArea->AddEventListener(NS_LITERAL_STRING("focus"), this, PR_FALSE,
PR_FALSE);
aArea->AddEventListener(NS_LITERAL_STRING("blur"), this, PR_FALSE,
PR_FALSE);
// This is a nasty hack. It needs to go away: see bug 135040. Once this is
// removed, the code added to nsCSSFrameConstructor::RestyleElement,
@ -961,20 +966,14 @@ nsImageMap::ContentRemoved(nsIDocument *aDocument,
}
nsresult
nsImageMap::Focus(nsIDOMEvent* aEvent)
nsImageMap::HandleEvent(nsIDOMEvent* aEvent)
{
return ChangeFocus(aEvent, PR_TRUE);
}
nsAutoString eventType;
aEvent->GetType(eventType);
PRBool focus = eventType.EqualsLiteral("focus");
NS_ABORT_IF_FALSE(focus == !eventType.EqualsLiteral("blur"),
"Unexpected event type");
nsresult
nsImageMap::Blur(nsIDOMEvent* aEvent)
{
return ChangeFocus(aEvent, PR_FALSE);
}
nsresult
nsImageMap::ChangeFocus(nsIDOMEvent* aEvent, PRBool aFocus)
{
//Set which one of our areas changed focus
nsCOMPtr<nsIDOMEventTarget> target;
if (NS_SUCCEEDED(aEvent->GetTarget(getter_AddRefs(target))) && target) {
@ -985,7 +984,7 @@ nsImageMap::ChangeFocus(nsIDOMEvent* aEvent, PRBool aFocus)
Area* area = mAreas.ElementAt(i);
if (area->mArea == targetContent) {
//Set or Remove internal focus
area->HasFocus(aFocus);
area->HasFocus(focus);
//Now invalidate the rect
nsIFrame* imgFrame = targetContent->GetPrimaryFrame();
if (imgFrame) {
@ -1001,12 +1000,6 @@ nsImageMap::ChangeFocus(nsIDOMEvent* aEvent, PRBool aFocus)
return NS_OK;
}
nsresult
nsImageMap::HandleEvent(nsIDOMEvent* aEvent)
{
return NS_OK;
}
void
nsImageMap::Destroy(void)
{

Просмотреть файл

@ -44,14 +44,15 @@
#include "nsCoord.h"
#include "nsTArray.h"
#include "nsStubMutationObserver.h"
#include "nsIDOMFocusListener.h"
#include "nsIDOMEventListener.h"
#include "nsIFrame.h"
class Area;
class nsIDOMEvent;
class nsRenderingContext;
class nsImageMap : public nsStubMutationObserver, public nsIDOMFocusListener
class nsImageMap : public nsStubMutationObserver,
public nsIDOMEventListener
{
public:
nsImageMap();
@ -84,10 +85,8 @@ public:
NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
//nsIDOMFocusListener
NS_IMETHOD Focus(nsIDOMEvent* aEvent);
NS_IMETHOD Blur(nsIDOMEvent* aEvent);
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
//nsIDOMEventListener
NS_DECL_NSIDOMEVENTLISTENER
nsresult GetBoundsForAreaContent(nsIContent *aContent,
nsRect& aBounds);
@ -103,8 +102,6 @@ protected:
nsresult AddArea(nsIContent* aArea);
nsresult ChangeFocus(nsIDOMEvent* aEvent, PRBool aFocus);
void MaybeUpdateAreas(nsIContent *aContent);
nsIPresShell* mPresShell; // WEAK - owns the frame that owns us

Просмотреть файл

@ -47,6 +47,7 @@
#include "nsIPresShell.h"
#include "nsPresContext.h"
#include "nsRenderingContext.h"
#include "nsAbsoluteContainingBlock.h"
#include "nsCSSAnonBoxes.h"
#include "nsAutoPtr.h"
#include "nsFrameManager.h"
@ -413,9 +414,7 @@ nsInlineFrame::Reflow(nsPresContext* aPresContext,
}
rv = ReflowFrames(aPresContext, aReflowState, irs, aMetrics, aStatus);
ReflowAbsoluteFrames(aPresContext, aMetrics, aReflowState, aStatus);
// Note: the line layout code will properly compute our
// overflow-rect state for us.
@ -923,13 +922,6 @@ nsInlineFrame::GetBaseline() const
return NS_MIN(mRect.height, ascent + GetUsedBorderAndPadding().top);
}
void
nsInlineFrame::DestroyFrom(nsIFrame* aDestructRoot)
{
DestroyAbsoluteFrames(aDestructRoot);
nsInlineFrameSuper::DestroyFrom(aDestructRoot);
}
#ifdef ACCESSIBILITY
already_AddRefed<nsAccessible>
nsInlineFrame::CreateAccessible()
@ -1109,8 +1101,6 @@ nsFirstLineFrame::Reflow(nsPresContext* aPresContext,
rv = ReflowFrames(aPresContext, aReflowState, irs, aMetrics, aStatus);
aReflowState.mLineLayout->SetInFirstLine(PR_FALSE);
ReflowAbsoluteFrames(aPresContext, aMetrics, aReflowState, aStatus);
// Note: the line layout code will properly compute our overflow state for us
return rv;
@ -1131,3 +1121,162 @@ nsFirstLineFrame::PullOverflowsFromPrevInFlow()
}
}
//////////////////////////////////////////////////////////////////////
nsIFrame*
NS_NewPositionedInlineFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
{
return new (aPresShell) nsPositionedInlineFrame(aContext);
}
NS_IMPL_FRAMEARENA_HELPERS(nsPositionedInlineFrame)
void
nsPositionedInlineFrame::DestroyFrom(nsIFrame* aDestructRoot)
{
mAbsoluteContainer.DestroyFrames(this, aDestructRoot);
nsInlineFrame::DestroyFrom(aDestructRoot);
}
NS_IMETHODIMP
nsPositionedInlineFrame::SetInitialChildList(nsIAtom* aListName,
nsFrameList& aChildList)
{
nsresult rv;
if (nsGkAtoms::absoluteList == aListName) {
rv = mAbsoluteContainer.SetInitialChildList(this, aListName, aChildList);
} else {
rv = nsInlineFrame::SetInitialChildList(aListName, aChildList);
}
return rv;
}
NS_IMETHODIMP
nsPositionedInlineFrame::AppendFrames(nsIAtom* aListName,
nsFrameList& aFrameList)
{
nsresult rv;
if (nsGkAtoms::absoluteList == aListName) {
rv = mAbsoluteContainer.AppendFrames(this, aListName, aFrameList);
} else {
rv = nsInlineFrame::AppendFrames(aListName, aFrameList);
}
return rv;
}
NS_IMETHODIMP
nsPositionedInlineFrame::InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsFrameList& aFrameList)
{
nsresult rv;
if (nsGkAtoms::absoluteList == aListName) {
rv = mAbsoluteContainer.InsertFrames(this, aListName, aPrevFrame,
aFrameList);
} else {
rv = nsInlineFrame::InsertFrames(aListName, aPrevFrame, aFrameList);
}
return rv;
}
NS_IMETHODIMP
nsPositionedInlineFrame::RemoveFrame(nsIAtom* aListName,
nsIFrame* aOldFrame)
{
nsresult rv;
if (nsGkAtoms::absoluteList == aListName) {
mAbsoluteContainer.RemoveFrame(this, aListName, aOldFrame);
rv = NS_OK;
} else {
rv = nsInlineFrame::RemoveFrame(aListName, aOldFrame);
}
return rv;
}
NS_IMETHODIMP
nsPositionedInlineFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsRect& aDirtyRect,
const nsDisplayListSet& aLists)
{
aBuilder->MarkFramesForDisplayList(this, mAbsoluteContainer.GetChildList(),
aDirtyRect);
return nsHTMLContainerFrame::BuildDisplayList(aBuilder, aDirtyRect, aLists);
}
nsIAtom*
nsPositionedInlineFrame::GetAdditionalChildListName(PRInt32 aIndex) const
{
if (0 == aIndex) {
return nsGkAtoms::absoluteList;
}
return nsnull;
}
nsFrameList
nsPositionedInlineFrame::GetChildList(nsIAtom* aListName) const
{
if (nsGkAtoms::absoluteList == aListName)
return mAbsoluteContainer.GetChildList();
return nsInlineFrame::GetChildList(aListName);
}
nsIAtom*
nsPositionedInlineFrame::GetType() const
{
return nsGkAtoms::positionedInlineFrame;
}
NS_IMETHODIMP
nsPositionedInlineFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
nsresult rv = NS_OK;
// Don't bother optimizing for fast incremental reflow of absolute
// children of an inline
// Let the inline frame do its reflow first
rv = nsInlineFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
// Let the absolutely positioned container reflow any absolutely positioned
// child frames that need to be reflowed
// We want to do this under either of two conditions:
// 1. If we didn't do the incremental reflow above.
// 2. If our size changed.
// Even though it's the padding edge that's the containing block, we
// can use our rect (the border edge) since if the border style
// changed, the reflow would have been targeted at us so we'd satisfy
// condition 1.
if (NS_SUCCEEDED(rv) &&
mAbsoluteContainer.HasAbsoluteFrames()) {
// 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();
// Factor the absolutely positioned child bounds into the overflow area
// Don't include this frame's bounds, nor its inline descendants' bounds,
// and don't store the overflow property.
// That will all be done by nsLineLayout::RelativePositionFrames.
rv = mAbsoluteContainer.Reflow(this, aPresContext, aReflowState, aStatus,
containingBlockWidth, containingBlockHeight,
PR_TRUE, PR_TRUE, PR_TRUE, // XXX could be optimized
&aDesiredSize.mOverflowAreas);
}
return rv;
}

Просмотреть файл

@ -41,6 +41,7 @@
#define nsInlineFrame_h___
#include "nsHTMLContainerFrame.h"
#include "nsAbsoluteContainingBlock.h"
#include "nsLineLayout.h"
class nsAnonymousBlockFrame;
@ -96,8 +97,6 @@ public:
virtual PRBool IsEmpty();
virtual PRBool IsSelfEmpty();
virtual void DestroyFrom(nsIFrame* aDestructRoot);
virtual PRBool PeekOffsetCharacter(PRBool aForward, PRInt32* aOffset,
PRBool aRespectClusters = PR_TRUE);
@ -228,4 +227,53 @@ protected:
PRBool* aIsComplete);
};
//----------------------------------------------------------------------
// Derived class created for relatively positioned inline-level elements
// that acts as a containing block for child absolutely positioned
// elements
class nsPositionedInlineFrame : public nsInlineFrame
{
public:
NS_DECL_FRAMEARENA_HELPERS
nsPositionedInlineFrame(nsStyleContext* aContext)
: nsInlineFrame(aContext)
, mAbsoluteContainer(nsGkAtoms::absoluteList)
{}
virtual ~nsPositionedInlineFrame() { } // useful for debugging
virtual void DestroyFrom(nsIFrame* aDestructRoot);
NS_IMETHOD SetInitialChildList(nsIAtom* aListName,
nsFrameList& aChildList);
NS_IMETHOD AppendFrames(nsIAtom* aListName,
nsFrameList& aFrameList);
NS_IMETHOD InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsFrameList& aFrameList);
NS_IMETHOD RemoveFrame(nsIAtom* aListName,
nsIFrame* aOldFrame);
NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsRect& aDirtyRect,
const nsDisplayListSet& aLists);
virtual nsIAtom* GetAdditionalChildListName(PRInt32 aIndex) const;
virtual nsFrameList GetChildList(nsIAtom* aListName) const;
NS_IMETHOD Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
virtual nsIAtom* GetType() const;
protected:
nsAbsoluteContainingBlock mAbsoluteContainer;
};
#endif /* nsInlineFrame_h___ */

Просмотреть файл

@ -662,7 +662,8 @@ IsPercentageAware(const nsIFrame* aFrame)
}
// Some of these things don't apply to non-replaced inline frames
// (that is, fType == nsGkAtoms::inlineFrame), but we won't bother making
// (that is, fType == nsGkAtoms::inlineFrame || fType ==
// nsGkAtoms::positionedInlineFrame), but we won't bother making
// things unnecessarily complicated, since they'll probably be set
// quite rarely.

Просмотреть файл

@ -137,10 +137,13 @@ nsPageContentFrame::Reflow(nsPresContext* aPresContext,
NS_ASSERTION(aPresContext->IsDynamic() || !NS_FRAME_IS_FULLY_COMPLETE(aStatus) ||
!frame->GetNextInFlow(), "bad child flow list");
}
// Reflow our fixed frames
// Reflow our fixed frames
nsReflowStatus fixedStatus = NS_FRAME_COMPLETE;
ReflowAbsoluteFrames(aPresContext, aDesiredSize, aReflowState, fixedStatus);
mFixedContainer.Reflow(this, aPresContext, aReflowState, fixedStatus,
aReflowState.availableWidth,
aReflowState.availableHeight,
PR_FALSE, PR_TRUE, PR_TRUE, // XXX could be optimized
nsnull /* ignore overflow */);
NS_ASSERTION(NS_FRAME_IS_COMPLETE(fixedStatus), "fixed frames can be truncated, but not incomplete");
// Return our desired size

Просмотреть файл

@ -184,6 +184,7 @@ public:
nsPageFrame_id,
nsPlaceholderFrame_id,
nsPopupSetFrame_id,
nsPositionedInlineFrame_id,
nsProgressFrame_id,
nsProgressMeterFrame_id,
nsResizerFrame_id,

Просмотреть файл

@ -47,7 +47,6 @@
#include "nsIScrollableFrame.h"
#include "nsDisplayList.h"
#include "FrameLayerBuilder.h"
#include "nsAbsoluteContainingBlock.h"
using namespace mozilla;
@ -70,7 +69,7 @@ ViewportFrame::Init(nsIContent* aContent,
void
ViewportFrame::DestroyFrom(nsIFrame* aDestructRoot)
{
DestroyAbsoluteFrames(aDestructRoot);
mFixedContainer.DestroyFrames(this, aDestructRoot);
nsContainerFrame::DestroyFrom(aDestructRoot);
}
@ -78,11 +77,20 @@ NS_IMETHODIMP
ViewportFrame::SetInitialChildList(nsIAtom* aListName,
nsFrameList& aChildList)
{
nsresult rv = NS_OK;
// See which child list to add the frames to
#ifdef NS_DEBUG
nsFrame::VerifyDirtyBitSet(aChildList);
#endif
return nsContainerFrame::SetInitialChildList(aListName, aChildList);
if (nsGkAtoms::fixedList == aListName) {
rv = mFixedContainer.SetInitialChildList(this, aListName, aChildList);
}
else {
rv = nsContainerFrame::SetInitialChildList(aListName, aChildList);
}
return rv;
}
NS_IMETHODIMP
@ -90,6 +98,13 @@ ViewportFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsRect& aDirtyRect,
const nsDisplayListSet& aLists)
{
// We don't need any special painting or event handling. We just need to
// mark our visible out-of-flow frames (i.e., the fixed position frames) so
// that display list construction is guaranteed to recurse into their
// ancestors.
aBuilder->MarkFramesForDisplayList(this, mFixedContainer.GetChildList(),
aDirtyRect);
nsIFrame* kid = mFrames.FirstChild();
if (!kid)
return NS_OK;
@ -104,9 +119,18 @@ NS_IMETHODIMP
ViewportFrame::AppendFrames(nsIAtom* aListName,
nsFrameList& aFrameList)
{
NS_ASSERTION(!aListName, "unexpected child list");
NS_ASSERTION(GetChildList(nsnull).IsEmpty(), "Shouldn't have any kids!");
return nsContainerFrame::AppendFrames(aListName, aFrameList);
nsresult rv = NS_OK;
if (nsGkAtoms::fixedList == aListName) {
rv = mFixedContainer.AppendFrames(this, aListName, aFrameList);
}
else {
NS_ASSERTION(!aListName, "unexpected child list");
NS_ASSERTION(GetChildList(nsnull).IsEmpty(), "Shouldn't have any kids!");
rv = nsContainerFrame::AppendFrames(aListName, aFrameList);
}
return rv;
}
NS_IMETHODIMP
@ -114,17 +138,57 @@ ViewportFrame::InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsFrameList& aFrameList)
{
NS_ASSERTION(!aListName, "unexpected child list");
NS_ASSERTION(GetChildList(nsnull).IsEmpty(), "Shouldn't have any kids!");
return nsContainerFrame::InsertFrames(aListName, aPrevFrame, aFrameList);
nsresult rv = NS_OK;
if (nsGkAtoms::fixedList == aListName) {
rv = mFixedContainer.InsertFrames(this, aListName, aPrevFrame, aFrameList);
}
else {
NS_ASSERTION(!aListName, "unexpected child list");
NS_ASSERTION(GetChildList(nsnull).IsEmpty(), "Shouldn't have any kids!");
rv = nsContainerFrame::InsertFrames(aListName, aPrevFrame, aFrameList);
}
return rv;
}
NS_IMETHODIMP
ViewportFrame::RemoveFrame(nsIAtom* aListName,
nsIFrame* aOldFrame)
{
NS_ASSERTION(!aListName, "unexpected child list");
return nsContainerFrame::RemoveFrame(aListName, aOldFrame);
nsresult rv = NS_OK;
if (nsGkAtoms::fixedList == aListName) {
mFixedContainer.RemoveFrame(this, aListName, aOldFrame);
rv = NS_OK;
}
else {
NS_ASSERTION(!aListName, "unexpected child list");
rv = nsContainerFrame::RemoveFrame(aListName, aOldFrame);
}
return rv;
}
nsIAtom*
ViewportFrame::GetAdditionalChildListName(PRInt32 aIndex) const
{
NS_PRECONDITION(aIndex >= 0, "illegal index");
if (0 == aIndex) {
return nsGkAtoms::fixedList;
}
return nsnull;
}
nsFrameList
ViewportFrame::GetChildList(nsIAtom* aListName) const
{
if (nsGkAtoms::fixedList == aListName)
return mFixedContainer.GetChildList();
return nsContainerFrame::GetChildList(aListName);
}
/* virtual */ nscoord
@ -136,6 +200,8 @@ ViewportFrame::GetMinWidth(nsRenderingContext *aRenderingContext)
result = 0;
else
result = mFrames.FirstChild()->GetMinWidth(aRenderingContext);
// XXXldb Deal with mFixedContainer (matters for SizeToContent)!
return result;
}
@ -149,6 +215,8 @@ ViewportFrame::GetPrefWidth(nsRenderingContext *aRenderingContext)
result = 0;
else
result = mFrames.FirstChild()->GetPrefWidth(aRenderingContext);
// XXXldb Deal with mFixedContainer (matters for SizeToContent)!
return result;
}
@ -246,24 +314,20 @@ ViewportFrame::Reflow(nsPresContext* aPresContext,
// to reflect the available space for the fixed items
nsHTMLReflowState reflowState(aReflowState);
nsPoint offset = AdjustReflowStateForScrollbars(&reflowState);
#ifdef DEBUG
if (IsAbsoluteContainer()) {
NS_ASSERTION(GetAbsoluteContainingBlock()->GetChildList().IsEmpty() ||
(offset.x == 0 && offset.y == 0),
"We don't handle correct positioning of fixed frames with "
"scrollbars in odd positions");
}
NS_ASSERTION(mFixedContainer.GetChildList().IsEmpty() ||
(offset.x == 0 && offset.y == 0),
"We don't handle correct positioning of fixed frames with "
"scrollbars in odd positions");
#endif
if (IsAbsoluteContainer()) {
// Just reflow all the fixed-pos frames.
rv = GetAbsoluteContainingBlock()->Reflow(this, aPresContext, reflowState, aStatus,
reflowState.ComputedWidth(),
reflowState.ComputedHeight(),
PR_FALSE, PR_TRUE, PR_TRUE, // XXX could be optimized
nsnull /* ignore overflow */);
}
// Just reflow all the fixed-pos frames.
rv = mFixedContainer.Reflow(this, aPresContext, reflowState, aStatus,
reflowState.ComputedWidth(),
reflowState.ComputedHeight(),
PR_FALSE, PR_TRUE, PR_TRUE, // XXX could be optimized
nsnull /* ignore overflow */);
// If we were dirty then do a repaint
if (GetStateBits() & NS_FRAME_IS_DIRTY) {

Просмотреть файл

@ -45,13 +45,15 @@
#include "nsContainerFrame.h"
#include "nsGkAtoms.h"
#include "nsAbsoluteContainingBlock.h"
class nsPresContext;
/**
* ViewportFrame is the parent of a single child - the doc root frame or a scroll frame
* containing the doc root frame. ViewportFrame stores this child in its primary child
* list.
* list. It stores fixed positioned items in a secondary child list and its mFixedContainer
* delegate handles them.
*/
class ViewportFrame : public nsContainerFrame {
public:
@ -61,6 +63,7 @@ public:
ViewportFrame(nsStyleContext* aContext)
: nsContainerFrame(aContext)
, mFixedContainer(nsGkAtoms::fixedList)
{}
virtual ~ViewportFrame() { } // useful for debugging
@ -83,6 +86,10 @@ public:
NS_IMETHOD RemoveFrame(nsIAtom* aListName,
nsIFrame* aOldFrame);
virtual nsIAtom* GetAdditionalChildListName(PRInt32 aIndex) const;
virtual nsFrameList GetChildList(nsIAtom* aListName) const;
NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsRect& aDirtyRect,
const nsDisplayListSet& aLists);
@ -111,11 +118,13 @@ public:
NS_IMETHOD GetFrameName(nsAString& aResult) const;
#endif
private:
virtual nsIAtom* GetAbsoluteListName() const { return nsGkAtoms::fixedList; }
protected:
nsPoint AdjustReflowStateForScrollbars(nsHTMLReflowState* aReflowState) const;
protected:
// position: fixed content is really content which is absolutely positioned with
// respect to the viewport.
nsAbsoluteContainingBlock mFixedContainer;
};

Просмотреть файл

@ -54,7 +54,6 @@
#include "nsIDOMElement.h"
#include "nsIDOMEventTarget.h"
#include "nsIDOMMouseListener.h"
#include "nsMathMLmactionFrame.h"
#include "nsAutoPtr.h"
@ -85,8 +84,14 @@ nsMathMLmactionFrame::~nsMathMLmactionFrame()
{
// unregister us as a mouse event listener ...
// printf("maction:%p unregistering as mouse event listener ...\n", this);
if (mListener)
mContent->RemoveEventListenerByIID(mListener, NS_GET_IID(nsIDOMMouseListener));
if (mListener) {
mContent->RemoveEventListener(NS_LITERAL_STRING("click"), mListener,
PR_FALSE);
mContent->RemoveEventListener(NS_LITERAL_STRING("mouseover"), mListener,
PR_FALSE);
mContent->RemoveEventListener(NS_LITERAL_STRING("mouseout"), mListener,
PR_FALSE);
}
}
NS_IMETHODIMP
@ -255,7 +260,12 @@ nsMathMLmactionFrame::SetInitialChildList(nsIAtom* aListName,
// create mouse event listener and register it
mListener = new nsMathMLmactionFrame::MouseListener(this);
// printf("maction:%p registering as mouse event listener ...\n", this);
mContent->AddEventListenerByIID(mListener, NS_GET_IID(nsIDOMMouseListener));
mContent->AddEventListener(NS_LITERAL_STRING("click"), mListener,
PR_FALSE, PR_FALSE);
mContent->AddEventListener(NS_LITERAL_STRING("mouseover"), mListener,
PR_FALSE, PR_FALSE);
mContent->AddEventListener(NS_LITERAL_STRING("mouseout"), mListener,
PR_FALSE, PR_FALSE);
}
return rv;
}
@ -339,9 +349,8 @@ nsMathMLmactionFrame::Place(nsRenderingContext& aRenderingContext,
// Event handlers
// ################################################################
NS_IMPL_ISUPPORTS2(nsMathMLmactionFrame::MouseListener,
nsIDOMEventListener,
nsIDOMMouseListener)
NS_IMPL_ISUPPORTS1(nsMathMLmactionFrame::MouseListener,
nsIDOMEventListener)
// helper to show a msg on the status bar
@ -366,9 +375,23 @@ ShowStatus(nsPresContext* aPresContext, nsString& aStatusMsg)
}
NS_IMETHODIMP
nsMathMLmactionFrame::MouseListener::MouseOver(nsIDOMEvent* aMouseEvent)
nsMathMLmactionFrame::MouseListener::HandleEvent(nsIDOMEvent* aEvent)
{
mOwner->MouseOver();
nsAutoString eventType;
aEvent->GetType(eventType);
if (eventType.EqualsLiteral("mouseover")) {
mOwner->MouseOver();
}
else if (eventType.EqualsLiteral("mouseclick")) {
mOwner->MouseClick();
}
else if (eventType.EqualsLiteral("mouseout")) {
mOwner->MouseOut();
}
else {
NS_ABORT();
}
return NS_OK;
}
@ -387,13 +410,6 @@ nsMathMLmactionFrame::MouseOver()
}
}
NS_IMETHODIMP
nsMathMLmactionFrame::MouseListener::MouseOut(nsIDOMEvent* aMouseEvent)
{
mOwner->MouseOut();
return NS_OK;
}
void
nsMathMLmactionFrame::MouseOut()
{
@ -405,13 +421,6 @@ nsMathMLmactionFrame::MouseOut()
}
}
NS_IMETHODIMP
nsMathMLmactionFrame::MouseListener::MouseClick(nsIDOMEvent* aMouseEvent)
{
mOwner->MouseClick();
return NS_OK;
}
void
nsMathMLmactionFrame::MouseClick()
{

Просмотреть файл

@ -41,6 +41,7 @@
#include "nsCOMPtr.h"
#include "nsMathMLContainerFrame.h"
#include "nsIDOMEventListener.h"
//
// <maction> -- bind actions to a subexpression
@ -87,30 +88,13 @@ private:
void MouseOver();
void MouseOut();
class MouseListener : public nsIDOMMouseListener {
class MouseListener : public nsIDOMEventListener
{
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMEVENTLISTENER
MouseListener(nsMathMLmactionFrame* aOwner) : mOwner(aOwner) { };
//#define DEBUG_mouse 1
#if DEBUG_mouse
#define MOUSE(_msg) printf("maction:%p MOUSE: "#_msg" ...\n", mOwner);
#else
#define MOUSE(_msg)
#endif
// nsIDOMMouseListener methods
NS_IMETHOD MouseDown(nsIDOMEvent* aMouseEvent) { MOUSE(down) return NS_OK; }
NS_IMETHOD MouseUp(nsIDOMEvent* aMouseEvent) { MOUSE(up) return NS_OK; }
NS_IMETHOD MouseClick(nsIDOMEvent* aMouseEvent);// { MOUSE(click) return NS_OK; }
NS_IMETHOD MouseDblClick(nsIDOMEvent* aMouseEvent) { MOUSE(dblclik) return NS_OK; }
NS_IMETHOD MouseOver(nsIDOMEvent* aMouseEvent);// { MOUSE(over) return NS_OK; }
NS_IMETHOD MouseOut(nsIDOMEvent* aMouseEvent);// { MOUSE(out) return NS_OK; }
// nsIDOMEventListener methods
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) { MOUSE(event); return NS_OK; }
nsMathMLmactionFrame* mOwner;
};

Просмотреть файл

@ -1,12 +0,0 @@
<!DOCTYPE html>
<div>test</div>
<style>
body {
width: 100px; height: 300px;
position: absolute;
-moz-transform: scale(0.5);
}
div { position: absolute; }
</style>

Просмотреть файл

@ -1643,7 +1643,6 @@ HTTP(..) == 654057-1.html 654057-1-ref.html
fails-if(layersGPUAccelerated&&cocoaWidget) == 654950-1.html 654950-1-ref.html # Quartz alpha blending doesn't match GL alpha blending
== 652775-1.html 652775-1-ref.html
== 655549-1.html 655549-1-ref.html
!= 656875.html about:blank
== 658952.html 658952-ref.html
== 664127-1.xul 664127-1-ref.xul
== 660682-1.html 660682-1-ref.html

Просмотреть файл

@ -1086,7 +1086,7 @@ nsTableFrame::GetAdditionalChildListName(PRInt32 aIndex) const
if (aIndex == NS_TABLE_FRAME_OVERFLOW_LIST_INDEX) {
return nsGkAtoms::overflowList;
}
return nsHTMLContainerFrame::GetAdditionalChildListName(aIndex);
return nsnull;
}
nsRect

Просмотреть файл

@ -227,7 +227,7 @@ nsTableOuterFrame::GetChildList(nsIAtom* aListName) const
if (!aListName) {
return mFrames;
}
return nsHTMLContainerFrame::GetChildList(aListName);
return nsFrameList::EmptyList();
}
nsIAtom*
@ -236,7 +236,7 @@ nsTableOuterFrame::GetAdditionalChildListName(PRInt32 aIndex) const
if (aIndex == NS_TABLE_FRAME_CAPTION_LIST_INDEX) {
return nsGkAtoms::captionList;
}
return nsHTMLContainerFrame::GetAdditionalChildListName(aIndex);
return nsnull;
}
NS_IMETHODIMP

Просмотреть файл

@ -398,7 +398,7 @@ nsMenuFrame::GetAdditionalChildListName(PRInt32 aIndex) const
if (NS_MENU_POPUP_LIST_INDEX == aIndex) {
return nsGkAtoms::popupList;
}
return nsBoxFrame::GetAdditionalChildListName(aIndex);
return nsnull;
}
void

Просмотреть файл

@ -859,21 +859,11 @@ nsSliderFrame::SetInitialChildList(nsIAtom* aListName,
}
nsresult
nsSliderMediator::MouseDown(nsIDOMEvent* aMouseEvent)
nsSliderMediator::HandleEvent(nsIDOMEvent* aEvent)
{
// Only process the event if the thumb is not being dragged.
if (mSlider && !mSlider->isDraggingThumb())
return mSlider->MouseDown(aMouseEvent);
return NS_OK;
}
nsresult
nsSliderMediator::MouseUp(nsIDOMEvent* aMouseEvent)
{
// Only process the event if the thumb is not being dragged.
if (mSlider && !mSlider->isDraggingThumb())
return mSlider->MouseUp(aMouseEvent);
return mSlider->MouseDown(aEvent);
return NS_OK;
}
@ -885,11 +875,14 @@ nsSliderFrame::MouseDown(nsIDOMEvent* aMouseEvent)
printf("Begin dragging\n");
#endif
nsCOMPtr<nsIDOMMouseEvent> mouseEvent(do_QueryInterface(aMouseEvent));
if (!mouseEvent)
return NS_OK;
if (mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::disabled,
nsGkAtoms::_true, eCaseMatters))
return NS_OK;
nsCOMPtr<nsIDOMMouseEvent> mouseEvent(do_QueryInterface(aMouseEvent));
PRUint16 button = 0;
mouseEvent->GetButton(&button);
if (!(button == 0 || (button == 1 && gMiddlePref)))
@ -955,16 +948,6 @@ nsSliderFrame::MouseDown(nsIDOMEvent* aMouseEvent)
return NS_OK;
}
nsresult
nsSliderFrame::MouseUp(nsIDOMEvent* aMouseEvent)
{
#ifdef DEBUG_SLIDER
printf("Finish dragging\n");
#endif
return NS_OK;
}
void
nsSliderFrame::DragThumb(PRBool aGrabMouseEvents)
{
@ -998,7 +981,8 @@ nsSliderFrame::AddListener()
nsIFrame* thumbFrame = mFrames.FirstChild();
if (thumbFrame) {
thumbFrame->GetContent()->
AddEventListenerByIID(mMediator, NS_GET_IID(nsIDOMMouseListener));
AddEventListener(NS_LITERAL_STRING("mousedown"), mMediator, PR_FALSE,
PR_FALSE);
}
}
@ -1012,7 +996,7 @@ nsSliderFrame::RemoveListener()
return;
thumbFrame->GetContent()->
RemoveEventListenerByIID(mMediator, NS_GET_IID(nsIDOMMouseListener));
RemoveEventListener(NS_LITERAL_STRING("mousedown"), mMediator, PR_FALSE);
}
NS_IMETHODIMP
@ -1154,6 +1138,5 @@ void nsSliderFrame::Notify(void)
}
}
NS_IMPL_ISUPPORTS2(nsSliderMediator,
nsIDOMMouseListener,
NS_IMPL_ISUPPORTS1(nsSliderMediator,
nsIDOMEventListener)

Просмотреть файл

@ -44,7 +44,7 @@
#include "nsIAtom.h"
#include "nsCOMPtr.h"
#include "nsITimer.h"
#include "nsIDOMMouseListener.h"
#include "nsIDOMEventListener.h"
class nsString;
class nsITimer;
@ -52,7 +52,7 @@ class nsSliderFrame;
nsIFrame* NS_NewSliderFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
class nsSliderMediator : public nsIDOMMouseListener
class nsSliderMediator : public nsIDOMEventListener
{
public:
@ -65,51 +65,7 @@ public:
virtual void SetSlider(nsSliderFrame* aSlider) { mSlider = aSlider; }
/**
* Processes a mouse down event
* @param aMouseEvent @see nsIDOMEvent.h
* @returns whether the event was consumed or ignored. @see nsresult
*/
NS_IMETHOD MouseDown(nsIDOMEvent* aMouseEvent);
/**
* Processes a mouse up event
* @param aMouseEvent @see nsIDOMEvent.h
* @returns whether the event was consumed or ignored. @see nsresult
*/
NS_IMETHOD MouseUp(nsIDOMEvent* aMouseEvent);
/**
* Processes a mouse click event
* @param aMouseEvent @see nsIDOMEvent.h
* @returns whether the event was consumed or ignored. @see nsresult
*
*/
NS_IMETHOD MouseClick(nsIDOMEvent* aMouseEvent) { return NS_OK; }
/**
* Processes a mouse click event
* @param aMouseEvent @see nsIDOMEvent.h
* @returns whether the event was consumed or ignored. @see nsresult
*
*/
NS_IMETHOD MouseDblClick(nsIDOMEvent* aMouseEvent) { return NS_OK; }
/**
* Processes a mouse enter event
* @param aMouseEvent @see nsIDOMEvent.h
* @returns whether the event was consumed or ignored. @see nsresult
*/
NS_IMETHOD MouseOver(nsIDOMEvent* aMouseEvent) { return NS_OK; }
/**
* Processes a mouse leave event
* @param aMouseEvent @see nsIDOMEvent.h
* @returns whether the event was consumed or ignored. @see nsresult
*/
NS_IMETHOD MouseOut(nsIDOMEvent* aMouseEvent) { return NS_OK; }
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; }
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
};
class nsSliderFrame : public nsBoxFrame
@ -173,10 +129,7 @@ public:
virtual nsIAtom* GetType() const;
NS_IMETHOD MouseDown(nsIDOMEvent* aMouseEvent);
NS_IMETHOD MouseUp(nsIDOMEvent* aMouseEvent);
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; }
nsresult MouseDown(nsIDOMEvent* aMouseEvent);
static PRInt32 GetCurrentPosition(nsIContent* content);
static PRInt32 GetMinPosition(nsIContent* content);

Просмотреть файл

@ -53,9 +53,8 @@
#include "nsIDocument.h"
#include "nsINameSpaceManager.h"
#include "nsScrollbarButtonFrame.h"
#include "nsIDOMMouseListener.h"
#include "nsIDOMMouseMotionListener.h"
#include "nsIDOMEventTarget.h"
#include "nsIDOMEventListener.h"
#include "nsIDOMMouseEvent.h"
#include "nsIPresShell.h"
#include "nsFrameList.h"
@ -85,11 +84,12 @@ public:
PRInt32 index;
};
class nsSplitterFrameInner : public nsIDOMMouseListener, public nsIDOMMouseMotionListener {
class nsSplitterFrameInner : public nsIDOMEventListener
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMEVENTLISTENER
nsSplitterFrameInner(nsSplitterFrame* aSplitter)
{
@ -100,18 +100,9 @@ public:
void Disconnect() { mOuter = nsnull; }
// mouse listener
NS_IMETHOD MouseDown(nsIDOMEvent* aMouseEvent);
NS_IMETHOD MouseUp(nsIDOMEvent* aMouseEvent);
NS_IMETHOD MouseClick(nsIDOMEvent* aMouseEvent) { return NS_OK; }
NS_IMETHOD MouseDblClick(nsIDOMEvent* aMouseEvent) { return NS_OK; }
NS_IMETHOD MouseOver(nsIDOMEvent* aMouseEvent) { return NS_OK; }
NS_IMETHOD MouseOut(nsIDOMEvent* aMouseEvent) { return MouseMove(aMouseEvent); }
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; }
// mouse motion listener
NS_IMETHOD MouseMove(nsIDOMEvent* aMouseEvent);
NS_IMETHOD DragMove(nsIDOMEvent* aMouseEvent) { return NS_OK; }
nsresult MouseDown(nsIDOMEvent* aMouseEvent);
nsresult MouseUp(nsIDOMEvent* aMouseEvent);
nsresult MouseMove(nsIDOMEvent* aMouseEvent);
void MouseDrag(nsPresContext* aPresContext, nsGUIEvent* aEvent);
void MouseUp(nsPresContext* aPresContext, nsGUIEvent* aEvent);
@ -167,14 +158,7 @@ public:
};
NS_IMPL_ADDREF(nsSplitterFrameInner)
NS_IMPL_RELEASE(nsSplitterFrameInner)
NS_INTERFACE_MAP_BEGIN(nsSplitterFrameInner)
NS_INTERFACE_MAP_ENTRY(nsIDOMMouseListener)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIDOMEventListener,nsIDOMMouseListener)
NS_INTERFACE_MAP_ENTRY(nsIDOMMouseMotionListener)
NS_INTERFACE_MAP_END
NS_IMPL_ISUPPORTS1(nsSplitterFrameInner, nsIDOMEventListener)
nsSplitterFrameInner::ResizeType
nsSplitterFrameInner::GetResizeBefore()
@ -599,11 +583,13 @@ void
nsSplitterFrameInner::AddListener(nsPresContext* aPresContext)
{
mOuter->GetContent()->
AddEventListenerByIID(static_cast<nsIDOMMouseListener*>(this),
NS_GET_IID(nsIDOMMouseListener));
AddEventListener(NS_LITERAL_STRING("mouseup"), this, PR_FALSE, PR_FALSE);
mOuter->GetContent()->
AddEventListenerByIID(static_cast<nsIDOMMouseMotionListener*>(this),
NS_GET_IID(nsIDOMMouseMotionListener));
AddEventListener(NS_LITERAL_STRING("mousedown"), this, PR_FALSE, PR_FALSE);
mOuter->GetContent()->
AddEventListener(NS_LITERAL_STRING("mousemove"), this, PR_FALSE, PR_FALSE);
mOuter->GetContent()->
AddEventListener(NS_LITERAL_STRING("mouseout"), this, PR_FALSE, PR_FALSE);
}
void
@ -611,11 +597,30 @@ nsSplitterFrameInner::RemoveListener()
{
ENSURE_TRUE(mOuter);
mOuter->GetContent()->
RemoveEventListenerByIID(static_cast<nsIDOMMouseListener*>(this),
NS_GET_IID(nsIDOMMouseListener));
RemoveEventListener(NS_LITERAL_STRING("mouseup"), this, PR_FALSE);
mOuter->GetContent()->
RemoveEventListenerByIID(static_cast<nsIDOMMouseMotionListener*>(this),
NS_GET_IID(nsIDOMMouseMotionListener));
RemoveEventListener(NS_LITERAL_STRING("mousedown"), this, PR_FALSE);
mOuter->GetContent()->
RemoveEventListener(NS_LITERAL_STRING("mousemove"), this, PR_FALSE);
mOuter->GetContent()->
RemoveEventListener(NS_LITERAL_STRING("mouseout"), this, PR_FALSE);
}
nsresult
nsSplitterFrameInner::HandleEvent(nsIDOMEvent* aEvent)
{
nsAutoString eventType;
aEvent->GetType(eventType);
if (eventType.EqualsLiteral("mouseup"))
return MouseUp(aEvent);
if (eventType.EqualsLiteral("mousedown"))
return MouseDown(aEvent);
if (eventType.EqualsLiteral("mousemove") ||
eventType.EqualsLiteral("mouseout"))
return MouseMove(aEvent);
NS_ABORT();
return NS_OK;
}
nsresult
@ -634,6 +639,8 @@ nsSplitterFrameInner::MouseDown(nsIDOMEvent* aMouseEvent)
{
NS_ENSURE_TRUE(mOuter, NS_OK);
nsCOMPtr<nsIDOMMouseEvent> mouseEvent(do_QueryInterface(aMouseEvent));
if (!mouseEvent)
return NS_OK;
PRUint16 button = 0;
mouseEvent->GetButton(&button);
@ -814,8 +821,9 @@ nsSplitterFrameInner::MouseMove(nsIDOMEvent* aMouseEvent)
if (mDragging)
return NS_OK;
nsCOMPtr<nsIDOMMouseListener> kungfuDeathGrip(this);
mOuter->mContent->SetAttr(kNameSpaceID_None, nsGkAtoms::state, NS_LITERAL_STRING("dragging"), PR_TRUE);
nsCOMPtr<nsIDOMEventListener> kungfuDeathGrip(this);
mOuter->mContent->SetAttr(kNameSpaceID_None, nsGkAtoms::state,
NS_LITERAL_STRING("dragging"), PR_TRUE);
RemoveListener();
mDragging = PR_TRUE;

Просмотреть файл

@ -66,6 +66,7 @@ const PREF_EM_UPDATE_URL = "extensions.update.url";
const PREF_EM_ENABLED_ADDONS = "extensions.enabledAddons";
const PREF_EM_EXTENSION_FORMAT = "extensions.";
const PREF_EM_ENABLED_SCOPES = "extensions.enabledScopes";
const PREF_EM_AUTO_DISABLED_SCOPES = "extensions.autoDisableScopes";
const PREF_EM_SHOW_MISMATCH_UI = "extensions.showMismatchUI";
const PREF_EM_DISABLED_ADDONS_LIST = "extensions.disabledAddons";
const PREF_XPI_ENABLED = "xpinstall.enabled";
@ -2559,6 +2560,11 @@ var XPIProvider = {
newAddon.installDate = aAddonState.mtime;
newAddon.updateDate = aAddonState.mtime;
// Check if the add-on is in a scope where add-ons should install disabled
let disablingScopes = Prefs.getIntPref(PREF_EM_AUTO_DISABLED_SCOPES, 0);
if (aInstallLocation.scope & disablingScopes)
newAddon.userDisabled = true;
// If there is migration data then apply it.
if (aMigrateData) {
LOG("Migrating data from old database");

Просмотреть файл

@ -1063,6 +1063,9 @@ Services.prefs.setBoolPref("extensions.logging.enabled", true);
// By default only load extensions from the profile install location
Services.prefs.setIntPref("extensions.enabledScopes", AddonManager.SCOPE_PROFILE);
// By default don't disable add-ons from any scope
Services.prefs.setIntPref("extensions.autoDisableScopes", 0);
// By default, don't cache add-ons in AddonRepository.jsm
Services.prefs.setBoolPref("extensions.getAddons.cache.enabled", false);

Просмотреть файл

@ -717,6 +717,116 @@ function run_test_11() {
do_check_not_in_crash_annotation(addon1.id, addon1.version);
do_check_not_in_crash_annotation(addon2.id, addon2.version);
end_test();
run_test_12();
});
}
// Test that auto-disabling for specific scopes works
function run_test_12() {
Services.prefs.setIntPref("extensions.autoDisableScopes", AddonManager.SCOPE_USER);
writeInstallRDFForExtension(addon1, profileDir);
writeInstallRDFForExtension(addon2, userDir);
writeInstallRDFForExtension(addon3, globalDir);
restartManager();
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",
"addon4@tests.mozilla.org",
"addon5@tests.mozilla.org"],
function([a1, a2, a3, a4, a5]) {
do_check_neq(a1, null);
do_check_false(a1.userDisabled);
do_check_true(a1.isActive);
do_check_neq(a2, null);
do_check_true(a2.userDisabled);
do_check_false(a2.isActive);
do_check_neq(a3, null);
do_check_false(a3.userDisabled);
do_check_true(a3.isActive);
var dest = profileDir.clone();
dest.append(do_get_expected_addon_name("addon1@tests.mozilla.org"));
dest.remove(true);
dest = userDir.clone();
dest.append(do_get_expected_addon_name("addon2@tests.mozilla.org"));
dest.remove(true);
dest = globalDir.clone();
dest.append(do_get_expected_addon_name("addon3@tests.mozilla.org"));
dest.remove(true);
restartManager();
Services.prefs.setIntPref("extensions.autoDisableScopes", AddonManager.SCOPE_SYSTEM);
writeInstallRDFForExtension(addon1, profileDir);
writeInstallRDFForExtension(addon2, userDir);
writeInstallRDFForExtension(addon3, globalDir);
restartManager();
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",
"addon4@tests.mozilla.org",
"addon5@tests.mozilla.org"],
function([a1, a2, a3, a4, a5]) {
do_check_neq(a1, null);
do_check_false(a1.userDisabled);
do_check_true(a1.isActive);
do_check_neq(a2, null);
do_check_false(a2.userDisabled);
do_check_true(a2.isActive);
do_check_neq(a3, null);
do_check_true(a3.userDisabled);
do_check_false(a3.isActive);
var dest = profileDir.clone();
dest.append(do_get_expected_addon_name("addon1@tests.mozilla.org"));
dest.remove(true);
dest = userDir.clone();
dest.append(do_get_expected_addon_name("addon2@tests.mozilla.org"));
dest.remove(true);
dest = globalDir.clone();
dest.append(do_get_expected_addon_name("addon3@tests.mozilla.org"));
dest.remove(true);
restartManager();
Services.prefs.setIntPref("extensions.autoDisableScopes", AddonManager.SCOPE_USER + AddonManager.SCOPE_SYSTEM);
writeInstallRDFForExtension(addon1, profileDir);
writeInstallRDFForExtension(addon2, userDir);
writeInstallRDFForExtension(addon3, globalDir);
restartManager();
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",
"addon4@tests.mozilla.org",
"addon5@tests.mozilla.org"],
function([a1, a2, a3, a4, a5]) {
do_check_neq(a1, null);
do_check_false(a1.userDisabled);
do_check_true(a1.isActive);
do_check_neq(a2, null);
do_check_true(a2.userDisabled);
do_check_false(a2.isActive);
do_check_neq(a3, null);
do_check_true(a3.userDisabled);
do_check_false(a3.isActive);
end_test();
});
});
});
}