From acee7d0ebafdecbfad3f5d21dcbdb0288fe2721e Mon Sep 17 00:00:00 2001 From: "dbaron%dbaron.org" Date: Sat, 20 Aug 2005 07:13:26 +0000 Subject: [PATCH] Clean up API (and its callers) for getting style data: remove unneeded null checks and switch to new inline member functions (one for each struct) that return values. b=197205 r+sr=roc a=brendan --- widget/src/windows/nsNativeThemeWin.cpp | 16 ++++++---------- widget/src/xpwidgets/nsNativeTheme.cpp | 6 ++---- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/widget/src/windows/nsNativeThemeWin.cpp b/widget/src/windows/nsNativeThemeWin.cpp index 6e07890ed49b..6bfec9a4fa9a 100644 --- a/widget/src/windows/nsNativeThemeWin.cpp +++ b/widget/src/windows/nsNativeThemeWin.cpp @@ -1128,8 +1128,7 @@ PRBool nsNativeThemeWin::IsWidgetStyled(nsIPresContext* aPresContext, nsIFrame* } // Check whether background differs from default - const nsStyleBackground* ourBG; - ::GetStyleData(aFrame, &ourBG); + const nsStyleBackground* ourBG = aFrame->GetStyleBackground(); if (ourBG->mBackgroundColor != defaultBGColor || ourBG->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT || @@ -1137,8 +1136,7 @@ PRBool nsNativeThemeWin::IsWidgetStyled(nsIPresContext* aPresContext, nsIFrame* return PR_TRUE; // Check whether border style or color differs from default - const nsStyleBorder* ourBorder; - ::GetStyleData(aFrame, &ourBorder); + const nsStyleBorder* ourBorder = aFrame->GetStyleBorder(); for (PRInt32 i = 0; i < 4; i++) { if (ourBorder->GetBorderStyle(i) != defaultBorderStyle) @@ -1259,9 +1257,8 @@ nsNativeThemeWin::ClassicGetWidgetBorder(nsIDeviceContext* aContext, { switch (aWidgetType) { case NS_THEME_BUTTON: { - const nsStyleUserInterface *uiData = nsnull; - ::GetStyleData(aFrame, &uiData); - if (uiData && uiData->mUserFocus == NS_STYLE_USER_FOCUS_IGNORE) { + const nsStyleUserInterface *uiData = aFrame->GetStyleUserInterface(); + if (uiData->mUserFocus == NS_STYLE_USER_FOCUS_IGNORE) { // use different padding for non-focusable buttons (*aResult).top = (*aResult).left = 1; (*aResult).bottom = (*aResult).right = 2; @@ -1415,10 +1412,9 @@ nsresult nsNativeThemeWin::ClassicGetThemePartAndState(nsIFrame* aFrame, PRUint8 else { if (contentState & NS_EVENT_STATE_ACTIVE && contentState & NS_EVENT_STATE_HOVER) { aState |= DFCS_PUSHED; - const nsStyleUserInterface *uiData = nsnull; - ::GetStyleData(aFrame, &uiData); + const nsStyleUserInterface *uiData = aFrame->GetStyleUserInterface(); // The down state is flat if the button is focusable - if (uiData && uiData->mUserFocus == NS_STYLE_USER_FOCUS_NORMAL) { + if (uiData->mUserFocus == NS_STYLE_USER_FOCUS_NORMAL) { nsCOMPtr content; aFrame->GetContent(getter_AddRefs(content)); if (!content->IsContentOfType(nsIContent::eHTML)) diff --git a/widget/src/xpwidgets/nsNativeTheme.cpp b/widget/src/xpwidgets/nsNativeTheme.cpp index 38fd9b334ad6..7815dd91bc48 100644 --- a/widget/src/xpwidgets/nsNativeTheme.cpp +++ b/widget/src/xpwidgets/nsNativeTheme.cpp @@ -281,8 +281,7 @@ nsNativeTheme::IsWidgetStyled(nsIPresContext* aPresContext, nsIFrame* aFrame, } // Check whether background differs from default - const nsStyleBackground* ourBG; - ::GetStyleData(aFrame, &ourBG); + const nsStyleBackground* ourBG = aFrame->GetStyleBackground(); if (defaultBGTransparent) { if (!(ourBG->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT)) @@ -295,8 +294,7 @@ nsNativeTheme::IsWidgetStyled(nsIPresContext* aPresContext, nsIFrame* aFrame, return PR_TRUE; // Check whether border style or color differs from default - const nsStyleBorder* ourBorder; - ::GetStyleData(aFrame, &ourBorder); + const nsStyleBorder* ourBorder = aFrame->GetStyleBorder(); for (PRInt32 i = 0; i < 4; ++i) { if (ourBorder->GetBorderStyle(i) != defaultBorderStyle)