diff --git a/content/shared/public/nsXULAtomList.h b/content/shared/public/nsXULAtomList.h index fae78a9f6db..2fcba57bb81 100644 --- a/content/shared/public/nsXULAtomList.h +++ b/content/shared/public/nsXULAtomList.h @@ -46,11 +46,11 @@ XUL_ATOM(slider, "slider") XUL_ATOM(colorpicker, "colorpicker") XUL_ATOM(palettename, "palettename") XUL_ATOM(fontpicker, "fontpicker") -XUL_ATOM(radio, "radio") XUL_ATOM(text, "text") XUL_ATOM(toolbar, "toolbar") XUL_ATOM(toolbaritem, "toolbaritem") XUL_ATOM(toolbox, "toolbox") +XUL_ATOM(image, "image") // The tree atoms XUL_ATOM(tree, "tree") // The start of a tree view diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 6a806bbfea9..291a5ab4b2d 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -2033,6 +2033,7 @@ nsCSSFrameConstructor::TableIsValidCellContent(nsIPresContext* aPresContext, #ifdef INCLUDE_XUL if ( (nsXULAtoms::button == tag.get()) || (nsXULAtoms::titledbutton == tag.get()) || + (nsXULAtoms::image == tag.get()) || (nsXULAtoms::grippy == tag.get()) || (nsXULAtoms::splitter == tag.get()) || (nsXULAtoms::slider == tag.get()) || @@ -2042,7 +2043,6 @@ nsCSSFrameConstructor::TableIsValidCellContent(nsIPresContext* aPresContext, (nsXULAtoms::thumb == tag.get()) || (nsXULAtoms::colorpicker == tag.get()) || (nsXULAtoms::fontpicker == tag.get()) || - (nsXULAtoms::radio == tag.get()) || (nsXULAtoms::text == tag.get()) || (nsXULAtoms::widget == tag.get()) || (nsXULAtoms::tree == tag.get()) || @@ -4293,7 +4293,9 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, } // End of BOX CONSTRUCTION logic // TITLED BUTTON CONSTRUCTION - else if (aTag == nsXULAtoms::titledbutton) { + else if (aTag == nsXULAtoms::titledbutton || + aTag == nsXULAtoms::image || + aTag == nsXULAtoms::text) { processChildren = PR_TRUE; isReplaced = PR_TRUE; rv = NS_NewTitledButtonFrame(aPresShell, &newFrame); diff --git a/layout/html/style/src/nsCSSFrameConstructor.cpp b/layout/html/style/src/nsCSSFrameConstructor.cpp index 6a806bbfea9..291a5ab4b2d 100644 --- a/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -2033,6 +2033,7 @@ nsCSSFrameConstructor::TableIsValidCellContent(nsIPresContext* aPresContext, #ifdef INCLUDE_XUL if ( (nsXULAtoms::button == tag.get()) || (nsXULAtoms::titledbutton == tag.get()) || + (nsXULAtoms::image == tag.get()) || (nsXULAtoms::grippy == tag.get()) || (nsXULAtoms::splitter == tag.get()) || (nsXULAtoms::slider == tag.get()) || @@ -2042,7 +2043,6 @@ nsCSSFrameConstructor::TableIsValidCellContent(nsIPresContext* aPresContext, (nsXULAtoms::thumb == tag.get()) || (nsXULAtoms::colorpicker == tag.get()) || (nsXULAtoms::fontpicker == tag.get()) || - (nsXULAtoms::radio == tag.get()) || (nsXULAtoms::text == tag.get()) || (nsXULAtoms::widget == tag.get()) || (nsXULAtoms::tree == tag.get()) || @@ -4293,7 +4293,9 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, } // End of BOX CONSTRUCTION logic // TITLED BUTTON CONSTRUCTION - else if (aTag == nsXULAtoms::titledbutton) { + else if (aTag == nsXULAtoms::titledbutton || + aTag == nsXULAtoms::image || + aTag == nsXULAtoms::text) { processChildren = PR_TRUE; isReplaced = PR_TRUE; rv = NS_NewTitledButtonFrame(aPresShell, &newFrame); diff --git a/layout/xul/base/public/Makefile.in b/layout/xul/base/public/Makefile.in index fa72264c494..3a5dc5e2e9f 100644 --- a/layout/xul/base/public/Makefile.in +++ b/layout/xul/base/public/Makefile.in @@ -29,6 +29,7 @@ include $(DEPTH)/config/autoconf.mk MODULE = layout EXPORTS = \ + nsIMenuFrame.h \ nsIPopupSetFrame.h \ nsITreeFrame.h \ $(NULL) diff --git a/layout/xul/base/public/Manifest b/layout/xul/base/public/Manifest index caa5a4db02d..3a525574bc5 100644 --- a/layout/xul/base/public/Manifest +++ b/layout/xul/base/public/Manifest @@ -1,3 +1,4 @@ +nsIMenuFrame.h nsIPopupSetFrame.h nsITreeFrame.h diff --git a/layout/xul/base/public/makefile.win b/layout/xul/base/public/makefile.win index 339d73c044f..9bc5dbc5eb4 100644 --- a/layout/xul/base/public/makefile.win +++ b/layout/xul/base/public/makefile.win @@ -22,6 +22,7 @@ DEPTH=..\..\..\.. EXPORTS = \ + nsIMenuFrame.h \ nsIPopupSetFrame.h \ nsITreeFrame.h \ $(NULL) diff --git a/layout/xul/base/public/nsIMenuFrame.h b/layout/xul/base/public/nsIMenuFrame.h new file mode 100644 index 00000000000..b006d277e35 --- /dev/null +++ b/layout/xul/base/public/nsIMenuFrame.h @@ -0,0 +1,66 @@ +/* -*- 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. + * + * Contributor(s): + */ + +#ifndef nsIMenuFrame_h___ +#define nsIMenuFrame_h___ + +// {6A4CDE51-6C05-11d3-BB50-00104B7B7DEB} +#define NS_IMENUFRAME_IID \ +{ 0x6a4cde51, 0x6c05, 0x11d3, { 0xbb, 0x50, 0x0, 0x10, 0x4b, 0x7b, 0x7d, 0xeb } } + +class nsIMenuParent; + +enum nsMenuType { + eMenuType_Normal = 0, + eMenuType_Checkbox = 1, + eMenuType_Radio = 2 +}; + +class nsIMenuFrame : public nsISupports { + +public: + static const nsIID& GetIID() { static nsIID iid = NS_IMENUFRAME_IID; return iid; } + + NS_IMETHOD ActivateMenu(PRBool aFlag) = 0; + NS_IMETHOD SelectMenu(PRBool aFlag) = 0; + NS_IMETHOD OpenMenu(PRBool aFlag) = 0; + + NS_IMETHOD MenuIsOpen(PRBool& aResult) = 0; + NS_IMETHOD MenuIsContainer(PRBool& aResult) = 0; + NS_IMETHOD MenuIsChecked(PRBool& aResult) = 0; + + NS_IMETHOD SelectFirstItem() = 0; + + NS_IMETHOD Escape(PRBool& aHandledFlag) = 0; + NS_IMETHOD Enter() = 0; + NS_IMETHOD ShortcutNavigation(PRUint32 aLetter, PRBool& aHandledFlag) = 0; + NS_IMETHOD KeyboardNavigation(PRUint32 aDirection, PRBool& aHandledFlag) = 0; + + NS_IMETHOD GetMenuParent(nsIMenuParent** aMenuParent) = 0; + NS_IMETHOD GetRadioGroupName(nsString &aName) = 0; + NS_IMETHOD GetMenuType(nsMenuType &aType) = 0; + + NS_IMETHOD MarkAsGenerated() = 0; +}; + +#endif + diff --git a/layout/xul/base/src/nsIMenuFrame.h b/layout/xul/base/src/nsIMenuFrame.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/layout/xul/base/src/nsMenuBarListener.cpp b/layout/xul/base/src/nsMenuBarListener.cpp index 3a1deb18483..ab9cb760edd 100644 --- a/layout/xul/base/src/nsMenuBarListener.cpp +++ b/layout/xul/base/src/nsMenuBarListener.cpp @@ -180,25 +180,12 @@ nsMenuBarListener::MouseDown(nsIDOMEvent* aMouseEvent) nsresult nsMenuBarListener::MouseUp(nsIDOMEvent* aMouseEvent) { - if (!mMenuBarFrame->IsOpen() && mMenuBarFrame->IsActive()) { - mMenuBarFrame->ToggleMenuActiveState(); - PRBool handled; - mMenuBarFrame->Escape(handled); - mAltKeyDown = PR_FALSE; - } return NS_OK; // means I am NOT consuming event } nsresult nsMenuBarListener::MouseClick(nsIDOMEvent* aMouseEvent) { - if (!mMenuBarFrame->IsOpen() && mMenuBarFrame->IsActive()) { - mMenuBarFrame->ToggleMenuActiveState(); - PRBool handled; - mMenuBarFrame->Escape(handled); - mAltKeyDown = PR_FALSE; - } - return NS_OK; // means I am NOT consuming event } diff --git a/layout/xul/base/src/nsToolbarFrame.cpp b/layout/xul/base/src/nsToolbarFrame.cpp index 680c39c7348..dd5f8879ae1 100644 --- a/layout/xul/base/src/nsToolbarFrame.cpp +++ b/layout/xul/base/src/nsToolbarFrame.cpp @@ -324,22 +324,6 @@ nsToolbarFrame :: HandleEvent ( nsIPresContext* aPresContext, if ( !aEvent ) return nsEventStatus_eIgnore; - switch (aEvent->message) { - - case NS_MOUSE_ACTIVATE: - // Does the toolbar accept activation/focus? Check style - nsCOMPtr context; - GetStyleContext(getter_AddRefs(context)); - - const nsStyleUserInterface* styleStruct = (const nsStyleUserInterface*)context->GetStyleData(eStyleStruct_UserInterface); - if (NS_STYLE_USER_FOCUS_IGNORE == styleStruct->mUserFocus) { - // we want to surpress the blur and the following focus - if(aEvent->eventStructType == NS_MOUSE_EVENT) - ((nsMouseEvent*)aEvent)->acceptActivation = PR_FALSE; - } - break; - } - //XXX this needs to change when I am really handling the D&D events return nsBoxFrame::HandleEvent(aPresContext, aEvent, aEventStatus); diff --git a/layout/xul/base/src/nsTreeRowGroupFrame.cpp b/layout/xul/base/src/nsTreeRowGroupFrame.cpp index 16217e5bb14..117b8029ac9 100644 --- a/layout/xul/base/src/nsTreeRowGroupFrame.cpp +++ b/layout/xul/base/src/nsTreeRowGroupFrame.cpp @@ -51,6 +51,9 @@ #include "nsIViewManager.h" #include "nsIView.h" +// XXX This should probably be based off the height of a row in pixels +#define SCROLL_FACTOR 16 + // I added the following function to improve keeping the frame // chains in synch with the table. repackage as appropriate - karnaze void GetRowStartAndCount(nsIFrame* aFrame, @@ -689,17 +692,21 @@ nsTreeRowGroupFrame::ComputeTotalRowCount(PRInt32& aCount, nsIContent* aParent) NS_IMETHODIMP nsTreeRowGroupFrame::PositionChanged(nsIPresContext* aPresContext, PRInt32 aOldIndex, PRInt32 aNewIndex) { + PRInt32 oldIndex, newIndex; + oldIndex = aOldIndex / SCROLL_FACTOR; + newIndex = aNewIndex / SCROLL_FACTOR; + #ifdef DEBUG_tree printf("PositionChanged from %d to %d (mCurrentIndex is %d)\n", - aOldIndex, aNewIndex, mCurrentIndex); + oldIndex, newIndex, mCurrentIndex); #endif - if (aNewIndex < 0) + if (newIndex < 0) return NS_OK; - if (aOldIndex == aNewIndex) + if (oldIndex == newIndex) return NS_OK; - mCurrentIndex = aNewIndex; + mCurrentIndex = newIndex; // Get our row count. PRInt32 rowCount; @@ -710,7 +717,7 @@ nsTreeRowGroupFrame::PositionChanged(nsIPresContext* aPresContext, PRInt32 aOldI nsTableFrame::GetTableFrame(this, tableFrame); // Figure out how many rows we need to lose (if we moved down) or gain (if we moved up). - PRInt32 delta = aNewIndex > aOldIndex ? aNewIndex - aOldIndex : aOldIndex - aNewIndex; + PRInt32 delta = newIndex > oldIndex ? newIndex - oldIndex : oldIndex - newIndex; #ifdef DEBUG_tree printf("Scrolling, the delta is: %d\n", delta); @@ -732,7 +739,7 @@ nsTreeRowGroupFrame::PositionChanged(nsIPresContext* aPresContext, PRInt32 aOldI PRInt32 loseRows = delta; // scrolling down - if (aNewIndex > aOldIndex) { + if (newIndex > oldIndex) { // Figure out how many rows we have to lose off the top. DestroyRows(tableFrame, aPresContext, loseRows); } @@ -775,7 +782,7 @@ nsTreeRowGroupFrame::PositionChanged(nsIPresContext* aPresContext, PRInt32 aOldI } nsCOMPtr topRowContent; - FindRowContentAtIndex(aNewIndex, mContent, getter_AddRefs(topRowContent)); + FindRowContentAtIndex(newIndex, mContent, getter_AddRefs(topRowContent)); if (topRowContent) ConstructContentChain(topRowContent); @@ -801,6 +808,7 @@ nsTreeRowGroupFrame::PagedUpDown() mScrollbar->GetContent(getter_AddRefs(scrollbarContent)); rowGroupCount--; + rowGroupCount *= SCROLL_FACTOR; char ch[100]; sprintf(ch,"%d", rowGroupCount); @@ -825,8 +833,11 @@ nsTreeRowGroupFrame::SetScrollbarFrame(nsIPresContext* aPresContext, nsIFrame* a nsCOMPtr scrollbarContent; aFrame->GetContent(getter_AddRefs(scrollbarContent)); + nsAutoString scrollFactor; + scrollFactor.Append(SCROLL_FACTOR); + scrollbarContent->SetAttribute(kNameSpaceID_None, nsXULAtoms::curpos, "0", PR_FALSE); - scrollbarContent->SetAttribute(kNameSpaceID_None, nsXULAtoms::increment, "1", PR_FALSE); + scrollbarContent->SetAttribute(kNameSpaceID_None, nsXULAtoms::increment, scrollFactor, PR_FALSE); scrollbarContent->SetAttribute(kNameSpaceID_None, nsXULAtoms::pageincrement, "1", PR_FALSE); scrollbarContent->SetAttribute(kNameSpaceID_None, nsXULAtoms::maxpos, "5000", PR_FALSE); @@ -1492,7 +1503,8 @@ void nsTreeRowGroupFrame::OnContentRemoved(nsIPresContext* aPresContext, if (mScrollbar) { mCurrentIndex--; nsAutoString indexStr; - indexStr.Append(mCurrentIndex); + PRInt32 pixelIndex = mCurrentIndex * SCROLL_FACTOR; + indexStr.Append(pixelIndex); nsCOMPtr scrollbarContent; mScrollbar->GetContent(getter_AddRefs(scrollbarContent)); @@ -1619,6 +1631,7 @@ nsTreeRowGroupFrame::ReflowScrollbar(nsIPresContext* aPresContext) rowCount -= (pageRowCount-2); + rowCount *= SCROLL_FACTOR; char ch[100]; sprintf(ch,"%d", rowCount); maxpos = ch; @@ -1831,6 +1844,7 @@ nsTreeRowGroupFrame::EnsureRowIsVisible(PRInt32 aRowIndex) value=""; #endif + scrollTo *= SCROLL_FACTOR; value.Append(scrollTo); scrollbarContent->SetAttribute(kNameSpaceID_None, nsXULAtoms::curpos, value, PR_TRUE); @@ -1888,6 +1902,8 @@ void nsTreeRowGroupFrame::ScrollByLines(nsIPresContext* aPresContext, nsAutoString value; value.Append(scrollTo); + scrollTo *= SCROLL_FACTOR; + nsCOMPtr scrollbarContent; mScrollbar->GetContent(getter_AddRefs(scrollbarContent)); if (scrollbarContent) diff --git a/layout/xul/content/src/nsXULAtomList.h b/layout/xul/content/src/nsXULAtomList.h index fae78a9f6db..2fcba57bb81 100644 --- a/layout/xul/content/src/nsXULAtomList.h +++ b/layout/xul/content/src/nsXULAtomList.h @@ -46,11 +46,11 @@ XUL_ATOM(slider, "slider") XUL_ATOM(colorpicker, "colorpicker") XUL_ATOM(palettename, "palettename") XUL_ATOM(fontpicker, "fontpicker") -XUL_ATOM(radio, "radio") XUL_ATOM(text, "text") XUL_ATOM(toolbar, "toolbar") XUL_ATOM(toolbaritem, "toolbaritem") XUL_ATOM(toolbox, "toolbox") +XUL_ATOM(image, "image") // The tree atoms XUL_ATOM(tree, "tree") // The start of a tree view