From 2bc2cb55f37106631c549bebca342041c68279b7 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Fri, 9 Sep 2011 11:27:13 +0900 Subject: [PATCH] Bug 669028 part.12 layout/xul should use mozilla::LookAndFeel rather than nsILookAndFeel r=roc --- layout/xul/base/src/nsMenuFrame.cpp | 19 +++++------------- layout/xul/base/src/nsMenuPopupFrame.cpp | 8 +++----- .../xul/base/src/nsScrollbarButtonFrame.cpp | 16 ++++++++------- layout/xul/base/src/nsSliderFrame.cpp | 17 ++++++---------- layout/xul/base/src/nsSplitterFrame.cpp | 1 - layout/xul/base/src/nsXULPopupManager.cpp | 17 ++++++++-------- .../xul/base/src/tree/src/nsTreeBodyFrame.cpp | 20 +++++++++---------- .../xul/base/src/tree/src/nsTreeBodyFrame.h | 4 ++-- 8 files changed, 44 insertions(+), 58 deletions(-) diff --git a/layout/xul/base/src/nsMenuFrame.cpp b/layout/xul/base/src/nsMenuFrame.cpp index 3842a9156d41..1f1f0d01ecb0 100644 --- a/layout/xul/base/src/nsMenuFrame.cpp +++ b/layout/xul/base/src/nsMenuFrame.cpp @@ -55,9 +55,7 @@ #include "nsMenuBarFrame.h" #include "nsIDocument.h" #include "nsIDOMElement.h" -#include "nsILookAndFeel.h" #include "nsIComponentManager.h" -#include "nsWidgetsCID.h" #include "nsBoxLayoutState.h" #include "nsIScrollableFrame.h" #include "nsBindingManager.h" @@ -79,6 +77,7 @@ #include "nsIDOMXULMenuListElement.h" #include "mozilla/Services.h" #include "mozilla/Preferences.h" +#include "mozilla/LookAndFeel.h" using namespace mozilla; @@ -90,8 +89,6 @@ using namespace mozilla; static PRInt32 gEatMouseMove = PR_FALSE; -static NS_DEFINE_IID(kLookAndFeelCID, NS_LOOKANDFEEL_CID); - const PRInt32 kBlinkDelay = 67; // milliseconds // this class is used for dispatching menu activation events asynchronously. @@ -520,11 +517,8 @@ nsMenuFrame::HandleEvent(nsPresContext* aPresContext, // past the menu. This conditional check ensures that only menus have this // behaviour if (!IsDisabled() && IsMenu() && !IsOpen() && !mOpenTimer && !mMenuParent->IsMenuBar()) { - PRInt32 menuDelay = 300; // ms - - nsCOMPtr lookAndFeel(do_GetService(kLookAndFeelCID)); - if (lookAndFeel) - lookAndFeel->GetMetric(nsILookAndFeel::eMetric_SubmenuDelay, menuDelay); + PRInt32 menuDelay = + LookAndFeel::GetInt(LookAndFeel::eIntID_SubmenuDelay, 300); // ms // We're a menu, we're built, we're closed, and no timer has been kicked off. mOpenTimer = do_CreateInstance("@mozilla.org/timer;1"); @@ -1161,11 +1155,8 @@ nsMenuFrame::Execute(nsGUIEvent *aEvent) PRBool nsMenuFrame::ShouldBlink() { - PRInt32 shouldBlink = 0; - nsCOMPtr lookAndFeel(do_GetService(kLookAndFeelCID)); - if (lookAndFeel) { - lookAndFeel->GetMetric(nsILookAndFeel::eMetric_ChosenMenuItemsShouldBlink, shouldBlink); - } + PRInt32 shouldBlink = + LookAndFeel::GetInt(LookAndFeel::eIntID_ChosenMenuItemsShouldBlink, 0); if (!shouldBlink) return PR_FALSE; diff --git a/layout/xul/base/src/nsMenuPopupFrame.cpp b/layout/xul/base/src/nsMenuPopupFrame.cpp index aefc2aae0f73..41a6446ae436 100644 --- a/layout/xul/base/src/nsMenuPopupFrame.cpp +++ b/layout/xul/base/src/nsMenuPopupFrame.cpp @@ -61,7 +61,6 @@ #include "nsFrameManager.h" #include "nsIDocument.h" #include "nsRect.h" -#include "nsILookAndFeel.h" #include "nsIComponentManager.h" #include "nsBoxLayoutState.h" #include "nsIScrollableFrame.h" @@ -87,6 +86,7 @@ #include "nsThemeConstants.h" #include "nsDisplayList.h" #include "mozilla/Preferences.h" +#include "mozilla/LookAndFeel.h" using namespace mozilla; @@ -150,10 +150,8 @@ nsMenuPopupFrame::Init(nsIContent* aContent, // lookup if we're allowed to overlap the OS bar (menubar/taskbar) from the // look&feel object - PRInt32 tempBool; - presContext->LookAndFeel()-> - GetMetric(nsILookAndFeel::eMetric_MenusCanOverlapOSBar, tempBool); - mMenuCanOverlapOSBar = tempBool; + mMenuCanOverlapOSBar = + LookAndFeel::GetInt(LookAndFeel::eIntID_MenusCanOverlapOSBar) != 0; rv = CreatePopupViewForFrame(); NS_ENSURE_SUCCESS(rv, rv); diff --git a/layout/xul/base/src/nsScrollbarButtonFrame.cpp b/layout/xul/base/src/nsScrollbarButtonFrame.cpp index d784966c4ae2..532ec2e8de86 100644 --- a/layout/xul/base/src/nsScrollbarButtonFrame.cpp +++ b/layout/xul/base/src/nsScrollbarButtonFrame.cpp @@ -53,7 +53,9 @@ #include "nsIScrollbarMediator.h" #include "nsRepeatService.h" #include "nsGUIEvent.h" -#include "nsILookAndFeel.h" +#include "mozilla/LookAndFeel.h" + +using namespace mozilla; // // NS_NewToolbarFrame @@ -100,16 +102,16 @@ nsScrollbarButtonFrame::HandleButtonPress(nsPresContext* aPresContext, nsEventStatus* aEventStatus) { // Get the desired action for the scrollbar button. - nsILookAndFeel::nsMetricID tmpAction; + LookAndFeel::IntID tmpAction; if (aEvent->eventStructType == NS_MOUSE_EVENT && aEvent->message == NS_MOUSE_BUTTON_DOWN) { PRUint16 button = static_cast(aEvent)->button; if (button == nsMouseEvent::eLeftButton) { - tmpAction = nsILookAndFeel::eMetric_ScrollButtonLeftMouseButtonAction; + tmpAction = LookAndFeel::eIntID_ScrollButtonLeftMouseButtonAction; } else if (button == nsMouseEvent::eMiddleButton) { - tmpAction = nsILookAndFeel::eMetric_ScrollButtonMiddleMouseButtonAction; + tmpAction = LookAndFeel::eIntID_ScrollButtonMiddleMouseButtonAction; } else if (button == nsMouseEvent::eRightButton) { - tmpAction = nsILookAndFeel::eMetric_ScrollButtonRightMouseButtonAction; + tmpAction = LookAndFeel::eIntID_ScrollButtonRightMouseButtonAction; } else { return PR_FALSE; } @@ -119,9 +121,9 @@ nsScrollbarButtonFrame::HandleButtonPress(nsPresContext* aPresContext, // Get the button action metric from the pres. shell. PRInt32 pressedButtonAction; - if (NS_FAILED(aPresContext->LookAndFeel()->GetMetric(tmpAction, - pressedButtonAction))) + if (NS_FAILED(LookAndFeel::GetInt(tmpAction, &pressedButtonAction))) { return PR_FALSE; + } // get the scrollbar control nsIFrame* scrollbar; diff --git a/layout/xul/base/src/nsSliderFrame.cpp b/layout/xul/base/src/nsSliderFrame.cpp index 227ae79fcbda..9aac2803ba44 100644 --- a/layout/xul/base/src/nsSliderFrame.cpp +++ b/layout/xul/base/src/nsSliderFrame.cpp @@ -61,7 +61,6 @@ #include "nsISliderListener.h" #include "nsIScrollbarMediator.h" #include "nsScrollbarFrame.h" -#include "nsILookAndFeel.h" #include "nsRepeatService.h" #include "nsBoxLayoutState.h" #include "nsSprocketLayout.h" @@ -71,6 +70,7 @@ #include "nsLayoutUtils.h" #include "nsDisplayList.h" #include "mozilla/Preferences.h" +#include "mozilla/LookAndFeel.h" using namespace mozilla; @@ -609,16 +609,11 @@ nsSliderFrame::GetScrollToClick() // if there was no scrollbar, always scroll on click PRBool scrollToClick = PR_FALSE; - nsresult rv; - nsCOMPtr lookNFeel = - do_GetService("@mozilla.org/widget/lookandfeel;1", &rv); - if (NS_SUCCEEDED(rv)) { - PRInt32 scrollToClickMetric; - rv = lookNFeel->GetMetric(nsILookAndFeel::eMetric_ScrollToClick, - scrollToClickMetric); - if (NS_SUCCEEDED(rv) && scrollToClickMetric == 1) - scrollToClick = PR_TRUE; - } + PRInt32 scrollToClickMetric; + nsresult rv = LookAndFeel::GetInt(LookAndFeel::eIntID_ScrollToClick, + &scrollToClickMetric); + if (NS_SUCCEEDED(rv) && scrollToClickMetric == 1) + scrollToClick = PR_TRUE; return scrollToClick; #else diff --git a/layout/xul/base/src/nsSplitterFrame.cpp b/layout/xul/base/src/nsSplitterFrame.cpp index 420b6e02e89d..38dfe33ed7ac 100644 --- a/layout/xul/base/src/nsSplitterFrame.cpp +++ b/layout/xul/base/src/nsSplitterFrame.cpp @@ -59,7 +59,6 @@ #include "nsIPresShell.h" #include "nsFrameList.h" #include "nsHTMLParts.h" -#include "nsILookAndFeel.h" #include "nsStyleContext.h" #include "nsBoxLayoutState.h" #include "nsIXBLService.h" diff --git a/layout/xul/base/src/nsXULPopupManager.cpp b/layout/xul/base/src/nsXULPopupManager.cpp index 4fd18e8c396c..738b7d4a40fd 100644 --- a/layout/xul/base/src/nsXULPopupManager.cpp +++ b/layout/xul/base/src/nsXULPopupManager.cpp @@ -53,7 +53,6 @@ #include "nsCSSFrameConstructor.h" #include "nsLayoutUtils.h" #include "nsIViewManager.h" -#include "nsILookAndFeel.h" #include "nsIComponentManager.h" #include "nsITimer.h" #include "nsFocusManager.h" @@ -71,6 +70,9 @@ #include "nsFrameManager.h" #include "nsIObserverService.h" #include "mozilla/Services.h" +#include "mozilla/LookAndFeel.h" + +using namespace mozilla; #define FLAG_ALT 0x01 #define FLAG_CONTROL 0x02 @@ -1016,9 +1018,8 @@ nsXULPopupManager::HidePopupAfterDelay(nsMenuPopupFrame* aPopup) // Kick off a close timer. KillMenuTimer(); - PRInt32 menuDelay = 300; // ms - aPopup->PresContext()->LookAndFeel()-> - GetMetric(nsILookAndFeel::eMetric_SubmenuDelay, menuDelay); + PRInt32 menuDelay = + LookAndFeel::GetInt(LookAndFeel::eIntID_SubmenuDelay, 300); // ms // Kick off the timer. mCloseTimer = do_CreateInstance("@mozilla.org/timer;1"); @@ -2092,11 +2093,11 @@ nsXULPopupManager::IsValidMenuItem(nsPresContext* aPresContext, return PR_FALSE; } - PRInt32 skipNavigatingDisabledMenuItem = PR_TRUE; + PRBool skipNavigatingDisabledMenuItem = PR_TRUE; if (aOnPopup) { - aPresContext->LookAndFeel()-> - GetMetric(nsILookAndFeel::eMetric_SkipNavigatingDisabledMenuItem, - skipNavigatingDisabledMenuItem); + skipNavigatingDisabledMenuItem = + LookAndFeel::GetInt(LookAndFeel::eIntID_SkipNavigatingDisabledMenuItem, + 0) != 0; } return !(skipNavigatingDisabledMenuItem && diff --git a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp index 9208b049e28e..b50238ee03b7 100644 --- a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp +++ b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp @@ -107,6 +107,8 @@ #include "nsBidiUtils.h" #endif +using namespace mozilla; + // Enumeration function that cancels all the image requests in our cache static PLDHashOperator CancelImageRequest(const nsAString& aKey, @@ -1793,13 +1795,12 @@ nsTreeBodyFrame::MarkDirtyIfSelect() } nsresult -nsTreeBodyFrame::CreateTimer(const nsILookAndFeel::nsMetricID aID, +nsTreeBodyFrame::CreateTimer(const LookAndFeel::IntID aID, nsTimerCallbackFunc aFunc, PRInt32 aType, nsITimer** aTimer) { // Get the delay from the look and feel service. - PRInt32 delay = 0; - PresContext()->LookAndFeel()->GetMetric(aID, delay); + PRInt32 delay = LookAndFeel::GetInt(aID, 0); nsCOMPtr timer; @@ -2633,7 +2634,7 @@ nsTreeBodyFrame::HandleEvent(nsPresContext* aPresContext, } // Set a timer to trigger the tree scrolling. - CreateTimer(nsILookAndFeel::eMetric_TreeLazyScrollDelay, + CreateTimer(LookAndFeel::eIntID_TreeLazyScrollDelay, LazyScrollCallback, nsITimer::TYPE_ONE_SHOT, getter_AddRefs(mSlots->mTimer)); } @@ -2671,7 +2672,7 @@ nsTreeBodyFrame::HandleEvent(nsPresContext* aPresContext, mView->IsContainerOpen(mSlots->mDropRow, &isOpen); if (!isOpen) { // This node isn't expanded, set a timer to expand it. - CreateTimer(nsILookAndFeel::eMetric_TreeOpenDelay, + CreateTimer(LookAndFeel::eIntID_TreeOpenDelay, OpenCallback, nsITimer::TYPE_ONE_SHOT, getter_AddRefs(mSlots->mTimer)); } @@ -2748,7 +2749,7 @@ nsTreeBodyFrame::HandleEvent(nsPresContext* aPresContext, if (!mSlots->mArray.IsEmpty()) { // Close all spring loaded folders except the drop folder. - CreateTimer(nsILookAndFeel::eMetric_TreeCloseDelay, + CreateTimer(LookAndFeel::eIntID_TreeCloseDelay, CloseCallback, nsITimer::TYPE_ONE_SHOT, getter_AddRefs(mSlots->mTimer)); } @@ -4347,9 +4348,8 @@ nsTreeBodyFrame::ComputeDropPosition(nsGUIEvent* aEvent, PRInt32* aRow, PRInt16* if (CanAutoScroll(*aRow)) { // Get the max value from the look and feel service. - PRInt32 scrollLinesMax = 0; - PresContext()->LookAndFeel()-> - GetMetric(nsILookAndFeel::eMetric_TreeScrollLinesMax, scrollLinesMax); + PRInt32 scrollLinesMax = + LookAndFeel::GetInt(LookAndFeel::eIntID_TreeScrollLinesMax, 0); scrollLinesMax--; if (scrollLinesMax < 0) scrollLinesMax = 0; @@ -4409,7 +4409,7 @@ nsTreeBodyFrame::LazyScrollCallback(nsITimer *aTimer, void *aClosure) if (self->mView) { // Set a new timer to scroll the tree repeatedly. - self->CreateTimer(nsILookAndFeel::eMetric_TreeScrollDelay, + self->CreateTimer(LookAndFeel::eIntID_TreeScrollDelay, ScrollCallback, nsITimer::TYPE_REPEATING_SLACK, getter_AddRefs(self->mSlots->mTimer)); self->ScrollByLines(self->mSlots->mScrollLines); diff --git a/layout/xul/base/src/tree/src/nsTreeBodyFrame.h b/layout/xul/base/src/tree/src/nsTreeBodyFrame.h index b0633503edb9..d29d58f59755 100644 --- a/layout/xul/base/src/tree/src/nsTreeBodyFrame.h +++ b/layout/xul/base/src/tree/src/nsTreeBodyFrame.h @@ -51,7 +51,6 @@ #include "nsIDragSession.h" #include "nsITimer.h" #include "nsIReflowCallback.h" -#include "nsILookAndFeel.h" #include "nsTArray.h" #include "nsTreeStyleCache.h" #include "nsTreeColumns.h" @@ -62,6 +61,7 @@ #include "imgIDecoderObserver.h" #include "nsScrollbarFrame.h" #include "nsThreadUtils.h" +#include "mozilla/LookAndFeel.h" class nsOverflowChecker; @@ -441,7 +441,7 @@ protected: // opening/closing folders or tree scrolling. // aID is type of the action, aFunc is the function to be called when // the timer fires and aType is type of timer - one shot or repeating. - nsresult CreateTimer(const nsILookAndFeel::nsMetricID aID, + nsresult CreateTimer(const mozilla::LookAndFeel::IntID aID, nsTimerCallbackFunc aFunc, PRInt32 aType, nsITimer** aTimer);