Closed Bug 1242135 Opened 8 years ago Closed 8 years ago

Annotate intentional switch fallthrough in widget/gtk/

Categories

(Core :: Widget: Gtk, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla47
Tracking Status
firefox46 --- affected
firefox47 --- fixed

People

(Reporter: cpeterson, Assigned: cpeterson)

References

Details

Attachments

(1 file)

clang's -Wimplicit-fallthrough warnings (not yet enabled in mozilla-central) warn about switch cases that fall through without a break or return statement. MOZ_FALLTHROUGH (bug 1215411) is an annotation to suppress -Wimplicit-fallthrough warnings where the fallthrough is intentional.

widget/gtk/nsNativeThemeGTK.cpp:1032:3: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
widget/gtk/nsNativeThemeGTK.cpp:1058:3: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
widget/gtk/nsNativeThemeGTK.cpp:1274:3: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
widget/gtk/nsNativeThemeGTK.cpp:1718:3: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
Attachment #8711303 - Flags: review?(karlt)
Comment on attachment 8711303 [details] [diff] [review]
gtk_Wimplicit-fallthrough.patch

>@@ -1023,16 +1023,17 @@ nsNativeThemeGTK::GetExtraSizeForWidget(
>         gint top, left, bottom, right;
>         moz_gtk_button_get_default_overflow(&top, &left, &bottom, &right);
>         aExtra->top = top;
>         aExtra->right = right;
>         aExtra->bottom = bottom;
>         aExtra->left = left;
>         break;
>       }
>+      MOZ_FALLTHROUGH; // to get button's outline size
>     }
>   case NS_THEME_FOCUS_OUTLINE:

This fallthrough is actually a bug as it was meant to fall through to the default case.
It is a regression from one or both of these changesets:
https://hg.mozilla.org/mozilla-central/rev/13c6e0ecf8a7#l2.108
https://hg.mozilla.org/mozilla-central/rev/3ad397becd2b#l4.60

NS_THEME_FOCUS_OUTLINE is actually something special.  If there is a need for
extra size for button focus then it should be calculated differently, but I
don't expect there is a need.

Can you return false instead of MOZ_FALLTHROUGH here, please?
If that somehow causes test failures, then please change the comment to FIXME
or similar.
Attachment #8711303 - Flags: review?(karlt) → review+
Thanks. I will re-test without the fallthrough. I suspected the NS_THEME_FOCUS_OUTLINE fallthrough might have beeen unintentional (a bug!) but I could also imagine some special case where non-default themed buttons needed to include their outline size. :)
https://hg.mozilla.org/mozilla-central/rev/b28431d80522
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla47
Blocks: 1253170
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: