diff options
Diffstat (limited to 'widget')
41 files changed, 617 insertions, 2254 deletions
diff --git a/widget/EventMessageList.h b/widget/EventMessageList.h index 55fc7375e..7fe642637 100644 --- a/widget/EventMessageList.h +++ b/widget/EventMessageList.h @@ -448,6 +448,9 @@ NS_EVENT_MESSAGE(eEditorInput) NS_EVENT_MESSAGE(eSelectStart) NS_EVENT_MESSAGE(eSelectionChange) +// visibility change +NS_EVENT_MESSAGE(eVisibilityChange) + // Details element events. NS_EVENT_MESSAGE(eToggle) diff --git a/widget/GfxInfoBase.cpp b/widget/GfxInfoBase.cpp index e53db69c5..c937f5099 100644 --- a/widget/GfxInfoBase.cpp +++ b/widget/GfxInfoBase.cpp @@ -37,10 +37,6 @@ #include "gfxConfig.h" #include "DriverCrashGuard.h" -#if defined(MOZ_CRASHREPORTER) -#include "nsExceptionHandler.h" -#endif - using namespace mozilla::widget; using namespace mozilla; using mozilla::MutexAutoLock; @@ -245,13 +241,7 @@ RemovePrefForDriverVersion() static OperatingSystem BlacklistOSToOperatingSystem(const nsAString& os) { - if (os.EqualsLiteral("WINNT 5.1")) - return OperatingSystem::WindowsXP; - else if (os.EqualsLiteral("WINNT 5.2")) - return OperatingSystem::WindowsServer2003; - else if (os.EqualsLiteral("WINNT 6.0")) - return OperatingSystem::WindowsVista; - else if (os.EqualsLiteral("WINNT 6.1")) + if (os.EqualsLiteral("WINNT 6.1")) return OperatingSystem::Windows7; else if (os.EqualsLiteral("WINNT 6.2")) return OperatingSystem::Windows8; diff --git a/widget/GfxInfoX11.cpp b/widget/GfxInfoX11.cpp index f490bed52..4297aaa93 100644 --- a/widget/GfxInfoX11.cpp +++ b/widget/GfxInfoX11.cpp @@ -15,11 +15,6 @@ #include "GfxInfoX11.h" -#ifdef MOZ_CRASHREPORTER -#include "nsExceptionHandler.h" -#include "nsICrashReporter.h" -#endif - namespace mozilla { namespace widget { @@ -176,9 +171,6 @@ GfxInfo::GetData() mAdapterDescription.Append(nsDependentCString(buf)); mAdapterDescription.Append('\n'); } -#ifdef MOZ_CRASHREPORTER - CrashReporter::AppendAppNotesToCrashReport(mAdapterDescription); -#endif return; } @@ -194,9 +186,6 @@ GfxInfo::GetData() if (mHasTextureFromPixmap) note.AppendLiteral(" -- texture_from_pixmap"); note.Append('\n'); -#ifdef MOZ_CRASHREPORTER - CrashReporter::AppendAppNotesToCrashReport(note); -#endif // determine the major OpenGL version. That's the first integer in the version string. mGLMajorVersion = strtol(mVersion.get(), 0, 10); diff --git a/widget/LookAndFeel.h b/widget/LookAndFeel.h index e2502c559..cf84b3308 100644 --- a/widget/LookAndFeel.h +++ b/widget/LookAndFeel.h @@ -440,9 +440,7 @@ public: * Operating system versions. */ enum OperatingSystemVersion { - eOperatingSystemVersion_WindowsXP = 0, - eOperatingSystemVersion_WindowsVista, - eOperatingSystemVersion_Windows7, + eOperatingSystemVersion_Windows7 = 2, eOperatingSystemVersion_Windows8, eOperatingSystemVersion_Windows10, eOperatingSystemVersion_Unknown diff --git a/widget/android/GfxInfo.cpp b/widget/android/GfxInfo.cpp index af63184a7..181629e96 100644 --- a/widget/android/GfxInfo.cpp +++ b/widget/android/GfxInfo.cpp @@ -15,12 +15,6 @@ #include "nsIWindowWatcher.h" #include "nsServiceManagerUtils.h" -#if defined(MOZ_CRASHREPORTER) -#include "nsExceptionHandler.h" -#include "nsICrashReporter.h" -#define NS_CRASHREPORTER_CONTRACTID "@mozilla.org/toolkit/crash-reporter;1" -#endif - namespace mozilla { namespace widget { @@ -351,21 +345,7 @@ GfxInfo::GetIsGPU2Active(bool* aIsGPU2Active) void GfxInfo::AddCrashReportAnnotations() { -#if defined(MOZ_CRASHREPORTER) - CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterVendorID"), - mGLStrings->Vendor()); - CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterDeviceID"), - mGLStrings->Renderer()); - CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterDriverVersion"), - mGLStrings->Version()); - - /* Add an App Note for now so that we get the data immediately. These - * can go away after we store the above in the socorro db */ - nsAutoCString note; - note.AppendPrintf("AdapterDescription: '%s'\n", mAdapterDescription.get()); - - CrashReporter::AppendAppNotesToCrashReport(note); -#endif + /*** STUB ***/ } const nsTArray<GfxDriverInfo>& diff --git a/widget/android/jni/Utils.cpp b/widget/android/jni/Utils.cpp index 145f7e9ea..919588851 100644 --- a/widget/android/jni/Utils.cpp +++ b/widget/android/jni/Utils.cpp @@ -9,10 +9,6 @@ #include "GeneratedJNIWrappers.h" #include "nsAppShell.h" -#ifdef MOZ_CRASHREPORTER -#include "nsExceptionHandler.h" -#endif - namespace mozilla { namespace jni { @@ -192,12 +188,6 @@ bool ReportException(JNIEnv* aEnv, jthrowable aExc, jstring aStack) { bool result = true; -#ifdef MOZ_CRASHREPORTER - result &= NS_SUCCEEDED(CrashReporter::AnnotateCrashReport( - NS_LITERAL_CSTRING("JavaStackTrace"), - String::Ref::From(aStack)->ToCString())); -#endif // MOZ_CRASHREPORTER - if (sOOMErrorClass && aEnv->IsInstanceOf(aExc, sOOMErrorClass)) { NS_ABORT_OOM(0); // Unknown OOM size } diff --git a/widget/android/nsAppShell.cpp b/widget/android/nsAppShell.cpp index fefd711d0..09548c27b 100644 --- a/widget/android/nsAppShell.cpp +++ b/widget/android/nsAppShell.cpp @@ -53,11 +53,6 @@ #include "mozilla/Logging.h" #endif -#ifdef MOZ_CRASHREPORTER -#include "nsICrashReporter.h" -#include "nsExceptionHandler.h" -#endif - #include "AndroidAlerts.h" #include "ANRReporter.h" #include "GeckoBatteryManager.h" diff --git a/widget/cocoa/GfxInfo.mm b/widget/cocoa/GfxInfo.mm index 6789ae8b2..74333c514 100644 --- a/widget/cocoa/GfxInfo.mm +++ b/widget/cocoa/GfxInfo.mm @@ -18,12 +18,6 @@ #import <IOKit/IOKitLib.h> #import <Cocoa/Cocoa.h> -#if defined(MOZ_CRASHREPORTER) -#include "nsExceptionHandler.h" -#include "nsICrashReporter.h" -#define NS_CRASHREPORTER_CONTRACTID "@mozilla.org/toolkit/crash-reporter;1" -#endif - using namespace mozilla; using namespace mozilla::widget; @@ -273,33 +267,7 @@ GfxInfo::GetIsGPU2Active(bool* aIsGPU2Active) void GfxInfo::AddCrashReportAnnotations() { -#if defined(MOZ_CRASHREPORTER) - nsString deviceID, vendorID, driverVersion; - nsAutoCString narrowDeviceID, narrowVendorID, narrowDriverVersion; - - GetAdapterDeviceID(deviceID); - CopyUTF16toUTF8(deviceID, narrowDeviceID); - GetAdapterVendorID(vendorID); - CopyUTF16toUTF8(vendorID, narrowVendorID); - GetAdapterDriverVersion(driverVersion); - CopyUTF16toUTF8(driverVersion, narrowDriverVersion); - - CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterVendorID"), - narrowVendorID); - CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterDeviceID"), - narrowDeviceID); - CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterDriverVersion"), - narrowDriverVersion); - /* Add an App Note for now so that we get the data immediately. These - * can go away after we store the above in the socorro db */ - nsAutoCString note; - /* AppendPrintf only supports 32 character strings, mrghh. */ - note.Append("AdapterVendorID: "); - note.Append(narrowVendorID); - note.Append(", AdapterDeviceID: "); - note.Append(narrowDeviceID); - CrashReporter::AppendAppNotesToCrashReport(note); -#endif + /*** STUB ***/ } // We don't support checking driver versions on Mac. diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm index 92ccd8b6c..8f72a81be 100644 --- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -77,9 +77,6 @@ #include "nsAccessibilityService.h" #include "mozilla/a11y/Platform.h" #endif -#ifdef MOZ_CRASHREPORTER -#include "nsExceptionHandler.h" -#endif #include "mozilla/Preferences.h" @@ -5373,31 +5370,14 @@ GetIntegerDeltaForEvent(NSEvent* aEvent) #if !defined(RELEASE_OR_BETA) || defined(DEBUG) if (!Preferences::GetBool("intl.allow-insecure-text-input", false) && mGeckoChild && mTextInputHandler && mTextInputHandler->IsFocused()) { -#ifdef MOZ_CRASHREPORTER - NSWindow* window = [self window]; - NSString* info = [NSString stringWithFormat:@"\nview [%@], window [%@], window is key %i, is fullscreen %i, app is active %i", - self, window, [window isKeyWindow], ([window styleMask] & (1 << 14)) != 0, - [NSApp isActive]]; - nsAutoCString additionalInfo([info UTF8String]); -#endif if (mGeckoChild->GetInputContext().IsPasswordEditor() && !TextInputHandler::IsSecureEventInputEnabled()) { #define CRASH_MESSAGE "A password editor has focus, but not in secure input mode" -#ifdef MOZ_CRASHREPORTER - CrashReporter::AppendAppNotesToCrashReport(NS_LITERAL_CSTRING("\nBug 893973: ") + - NS_LITERAL_CSTRING(CRASH_MESSAGE)); - CrashReporter::AppendAppNotesToCrashReport(additionalInfo); -#endif MOZ_CRASH(CRASH_MESSAGE); #undef CRASH_MESSAGE } else if (!mGeckoChild->GetInputContext().IsPasswordEditor() && TextInputHandler::IsSecureEventInputEnabled()) { #define CRASH_MESSAGE "A non-password editor has focus, but in secure input mode" -#ifdef MOZ_CRASHREPORTER - CrashReporter::AppendAppNotesToCrashReport(NS_LITERAL_CSTRING("\nBug 893973: ") + - NS_LITERAL_CSTRING(CRASH_MESSAGE)); - CrashReporter::AppendAppNotesToCrashReport(additionalInfo); -#endif MOZ_CRASH(CRASH_MESSAGE); #undef CRASH_MESSAGE } diff --git a/widget/gtk/WidgetStyleCache.cpp b/widget/gtk/WidgetStyleCache.cpp index fd099681f..f35a451aa 100644 --- a/widget/gtk/WidgetStyleCache.cpp +++ b/widget/gtk/WidgetStyleCache.cpp @@ -434,15 +434,6 @@ CreateScrolledWindowWidget() } static GtkWidget* -CreateTextViewWidget() -{ - GtkWidget* widget = gtk_text_view_new(); - gtk_container_add(GTK_CONTAINER(GetWidget(MOZ_GTK_SCROLLED_WINDOW)), - widget); - return widget; -} - -static GtkWidget* CreateMenuSeparatorWidget() { GtkWidget* widget = gtk_separator_menu_item_new(); @@ -591,8 +582,6 @@ CreateWidget(WidgetNodeType aWidgetType) return CreateEntryWidget(); case MOZ_GTK_SCROLLED_WINDOW: return CreateScrolledWindowWidget(); - case MOZ_GTK_TEXT_VIEW: - return CreateTextViewWidget(); case MOZ_GTK_TREEVIEW: return CreateTreeViewWidget(); case MOZ_GTK_TREE_HEADER_CELL: @@ -637,6 +626,24 @@ GetWidget(WidgetNodeType aWidgetType) GtkWidget* widget = sWidgetStorage[aWidgetType]; if (!widget) { widget = CreateWidget(aWidgetType); + // Some widgets (MOZ_GTK_COMBOBOX_SEPARATOR for instance) may not be + // available or implemented. + if (!widget) + return nullptr; + // In GTK versions prior to 3.18, automatic invalidation of style contexts + // for widgets was delayed until the next resize event. Gecko however, + // typically uses the style context before the resize event runs and so an + // explicit invalidation may be required. This is necessary if a style + // property was retrieved before all changes were made to the style + // context. One such situation is where gtk_button_construct_child() + // retrieves the style property "image-spacing" during construction of the + // GtkButton, before its parent is set to provide inheritance of ancestor + // properties. More recent GTK versions do not need this, but do not + // re-resolve until required and so invalidation does not trigger + // unnecessary resolution in general. + GtkStyleContext* style = gtk_widget_get_style_context(widget); + gtk_style_context_invalidate(style); + sWidgetStorage[aWidgetType] = widget; } return widget; @@ -725,6 +732,21 @@ CreateCSSNode(const char* aName, GtkStyleContext* aParentStyle, GType aType) gtk_style_context_set_parent(context, aParentStyle); gtk_widget_path_unref(path); + // In GTK 3.4, gtk_render_* functions use |theming_engine| on the style + // context without ensuring any style resolution sets it appropriately + // in style_data_lookup(). e.g. + // https://git.gnome.org/browse/gtk+/tree/gtk/gtkstylecontext.c?h=3.4.4#n3847 + // + // That can result in incorrect drawing on first draw. To work around this, + // force a style look-up to set |theming_engine|. It is sufficient to do + // this only on context creation, instead of after every modification to the + // context, because themes typically (Ambiance and oxygen-gtk, at least) set + // the "engine" property with the '*' selector. + if (GTK_MAJOR_VERSION == 3 && gtk_get_minor_version() < 6) { + GdkRGBA unused; + gtk_style_context_get_color(context, GTK_STATE_FLAG_NORMAL, &unused); + } + return context; } @@ -747,13 +769,38 @@ GetWidgetRootStyle(WidgetNodeType aNodeType) case MOZ_GTK_IMAGEMENUITEM: style = CreateStyleForWidget(gtk_image_menu_item_new(), MOZ_GTK_MENUPOPUP); break; - case MOZ_GTK_CHECKMENUITEM_CONTAINER: + case MOZ_GTK_CHECKMENUITEM: style = CreateStyleForWidget(gtk_check_menu_item_new(), MOZ_GTK_MENUPOPUP); break; - case MOZ_GTK_RADIOMENUITEM_CONTAINER: + case MOZ_GTK_RADIOMENUITEM: style = CreateStyleForWidget(gtk_radio_menu_item_new(nullptr), MOZ_GTK_MENUPOPUP); break; + case MOZ_GTK_TEXT_VIEW: + style = CreateStyleForWidget(gtk_text_view_new(), + MOZ_GTK_SCROLLED_WINDOW); + break; + case MOZ_GTK_TOOLTIP: + if (gtk_check_version(3, 20, 0) != nullptr) { + // The tooltip style class is added first in CreateTooltipWidget() + // and transfered to style in CreateStyleForWidget(). + GtkWidget* tooltipWindow = CreateTooltipWidget(); + style = CreateStyleForWidget(tooltipWindow, nullptr); + gtk_widget_destroy(tooltipWindow); // Release GtkWindow self-reference. + } else { + // We create this from the path because GtkTooltipWindow is not public. + style = CreateCSSNode("tooltip", nullptr, GTK_TYPE_TOOLTIP); + gtk_style_context_add_class(style, GTK_STYLE_CLASS_BACKGROUND); + } + break; + case MOZ_GTK_TOOLTIP_BOX: + style = CreateStyleForWidget(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0), + MOZ_GTK_TOOLTIP); + break; + case MOZ_GTK_TOOLTIP_BOX_LABEL: + style = CreateStyleForWidget(gtk_label_new(nullptr), + MOZ_GTK_TOOLTIP_BOX); + break; default: GtkWidget* widget = GetWidget(aNodeType); MOZ_ASSERT(widget); @@ -827,13 +874,13 @@ GetCssNodeStyleInternal(WidgetNodeType aNodeType) style = CreateChildCSSNode(GTK_STYLE_CLASS_CHECK, MOZ_GTK_CHECKBUTTON_CONTAINER); break; - case MOZ_GTK_RADIOMENUITEM: + case MOZ_GTK_RADIOMENUITEM_INDICATOR: style = CreateChildCSSNode(GTK_STYLE_CLASS_RADIO, - MOZ_GTK_RADIOMENUITEM_CONTAINER); + MOZ_GTK_RADIOMENUITEM); break; - case MOZ_GTK_CHECKMENUITEM: + case MOZ_GTK_CHECKMENUITEM_INDICATOR: style = CreateChildCSSNode(GTK_STYLE_CLASS_CHECK, - MOZ_GTK_CHECKMENUITEM_CONTAINER); + MOZ_GTK_CHECKMENUITEM); break; case MOZ_GTK_PROGRESS_TROUGH: /* Progress bar background (trough) */ @@ -844,11 +891,6 @@ GetCssNodeStyleInternal(WidgetNodeType aNodeType) style = CreateChildCSSNode("progress", MOZ_GTK_PROGRESS_TROUGH); break; - case MOZ_GTK_TOOLTIP: - // We create this from the path because GtkTooltipWindow is not public. - style = CreateCSSNode("tooltip", nullptr, GTK_TYPE_TOOLTIP); - gtk_style_context_add_class(style, GTK_STYLE_CLASS_BACKGROUND); - break; case MOZ_GTK_GRIPPER: // TODO - create from CSS node return GetWidgetStyleWithClass(MOZ_GTK_GRIPPER, @@ -865,10 +907,28 @@ GetCssNodeStyleInternal(WidgetNodeType aNodeType) // TODO - create from CSS node return GetWidgetStyleWithClass(MOZ_GTK_SCROLLED_WINDOW, GTK_STYLE_CLASS_FRAME); - case MOZ_GTK_TEXT_VIEW: - // TODO - create from CSS node - return GetWidgetStyleWithClass(MOZ_GTK_TEXT_VIEW, - GTK_STYLE_CLASS_VIEW); + case MOZ_GTK_TEXT_VIEW_TEXT: + case MOZ_GTK_RESIZER: + style = CreateChildCSSNode("text", MOZ_GTK_TEXT_VIEW); + if (aNodeType == MOZ_GTK_RESIZER) { + // The "grip" class provides the correct builtin icon from + // gtk_render_handle(). The icon is drawn with shaded variants of + // the background color, and so a transparent background would lead to + // a transparent resizer. gtk_render_handle() also uses the + // background color to draw a background, and so this style otherwise + // matches what is used in GtkTextView to match the background with + // textarea elements. + GdkRGBA color; + gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, + &color); + if (color.alpha == 0.0) { + g_object_unref(style); + style = CreateStyleForWidget(gtk_text_view_new(), + MOZ_GTK_SCROLLED_WINDOW); + } + gtk_style_context_add_class(style, GTK_STYLE_CLASS_GRIP); + } + break; case MOZ_GTK_FRAME_BORDER: style = CreateChildCSSNode("border", MOZ_GTK_FRAME); break; @@ -971,27 +1031,20 @@ GetWidgetStyleInternal(WidgetNodeType aNodeType) case MOZ_GTK_CHECKBUTTON: return GetWidgetStyleWithClass(MOZ_GTK_CHECKBUTTON_CONTAINER, GTK_STYLE_CLASS_CHECK); - case MOZ_GTK_RADIOMENUITEM: - return GetWidgetStyleWithClass(MOZ_GTK_RADIOMENUITEM_CONTAINER, + case MOZ_GTK_RADIOMENUITEM_INDICATOR: + return GetWidgetStyleWithClass(MOZ_GTK_RADIOMENUITEM, GTK_STYLE_CLASS_RADIO); - case MOZ_GTK_CHECKMENUITEM: - return GetWidgetStyleWithClass(MOZ_GTK_CHECKMENUITEM_CONTAINER, + case MOZ_GTK_CHECKMENUITEM_INDICATOR: + return GetWidgetStyleWithClass(MOZ_GTK_CHECKMENUITEM, GTK_STYLE_CLASS_CHECK); case MOZ_GTK_PROGRESS_TROUGH: return GetWidgetStyleWithClass(MOZ_GTK_PROGRESSBAR, GTK_STYLE_CLASS_TROUGH); - case MOZ_GTK_TOOLTIP: { - GtkStyleContext* style = sStyleStorage[aNodeType]; - if (style) - return style; - - // The tooltip style class is added first in CreateTooltipWidget() so - // that gtk_widget_path_append_for_widget() in CreateStyleForWidget() - // will find it. - GtkWidget* tooltipWindow = CreateTooltipWidget(); - style = CreateStyleForWidget(tooltipWindow, nullptr); - gtk_widget_destroy(tooltipWindow); // Release GtkWindow self-reference. - sStyleStorage[aNodeType] = style; + case MOZ_GTK_PROGRESS_CHUNK: { + GtkStyleContext* style = + GetWidgetStyleWithClass(MOZ_GTK_PROGRESSBAR, + GTK_STYLE_CLASS_PROGRESSBAR); + gtk_style_context_remove_class(style, GTK_STYLE_CLASS_TROUGH); return style; } case MOZ_GTK_GRIPPER: @@ -1006,9 +1059,25 @@ GetWidgetStyleInternal(WidgetNodeType aNodeType) case MOZ_GTK_SCROLLED_WINDOW: return GetWidgetStyleWithClass(MOZ_GTK_SCROLLED_WINDOW, GTK_STYLE_CLASS_FRAME); - case MOZ_GTK_TEXT_VIEW: - return GetWidgetStyleWithClass(MOZ_GTK_TEXT_VIEW, - GTK_STYLE_CLASS_VIEW); + case MOZ_GTK_TEXT_VIEW_TEXT: + case MOZ_GTK_RESIZER: { + // GTK versions prior to 3.20 do not have the view class on the root + // node, but add this to determine the background for the text window. + GtkStyleContext* style = + GetWidgetStyleWithClass(MOZ_GTK_TEXT_VIEW, GTK_STYLE_CLASS_VIEW); + if (aNodeType == MOZ_GTK_RESIZER) { + // The "grip" class provides the correct builtin icon from + // gtk_render_handle(). The icon is drawn with shaded variants of + // the background color, and so a transparent background would lead to + // a transparent resizer. gtk_render_handle() also uses the + // background color to draw a background, and so this style otherwise + // matches MOZ_GTK_TEXT_VIEW_TEXT to match the background with + // textarea elements. GtkTextView creates a separate text window and + // so the background should not be transparent. + gtk_style_context_add_class(style, GTK_STYLE_CLASS_GRIP); + } + return style; + } case MOZ_GTK_FRAME_BORDER: return GetWidgetRootStyle(MOZ_GTK_FRAME); case MOZ_GTK_TREEVIEW_VIEW: diff --git a/widget/gtk/gtk3drawing.cpp b/widget/gtk/gtk3drawing.cpp index fb95b4cc4..c592fa51c 100644 --- a/widget/gtk/gtk3drawing.cpp +++ b/widget/gtk/gtk3drawing.cpp @@ -36,6 +36,10 @@ static gboolean is_initialized; static gint moz_gtk_get_tab_thickness(GtkStyleContext *style); +static gint +moz_gtk_menu_item_paint(WidgetNodeType widget, cairo_t *cr, GdkRectangle* rect, + GtkWidgetState* state, GtkTextDirection direction); + // GetStateFlagsFromGtkWidgetState() can be safely used for the specific // GtkWidgets that set both prelight and active flags. For other widgets, // either the GtkStateFlags or Gecko's GtkWidgetState need to be carefully @@ -167,7 +171,7 @@ moz_gtk_menuitem_get_horizontal_padding(gint* horizontal_padding) gint moz_gtk_checkmenuitem_get_horizontal_padding(gint* horizontal_padding) { - GtkStyleContext *style = ClaimStyleContext(MOZ_GTK_CHECKMENUITEM_CONTAINER); + GtkStyleContext *style = ClaimStyleContext(MOZ_GTK_CHECKMENUITEM); gtk_style_context_get_style(style, "horizontal-padding", horizontal_padding, nullptr); @@ -463,7 +467,7 @@ moz_gtk_get_widget_min_size(WidgetNodeType aGtkWidgetType, int* width, } static void -moz_gtk_rectangle_inset(GdkRectangle* rect, GtkBorder& aBorder) +Inset(GdkRectangle* rect, GtkBorder& aBorder) { MOZ_ASSERT(rect); rect->x += aBorder.left; @@ -472,17 +476,29 @@ moz_gtk_rectangle_inset(GdkRectangle* rect, GtkBorder& aBorder) rect->height -= aBorder.top + aBorder.bottom; } -/* Subtracting margin is used to inset drawing of element which can have margins, - * like scrollbar, scrollbar's trough, thumb and scrollbar's button */ +// Inset a rectangle by the margins specified in a style context. static void -moz_gtk_subtract_margin(GtkStyleContext* style, GdkRectangle* rect) +InsetByMargin(GdkRectangle* rect, GtkStyleContext* style) { MOZ_ASSERT(rect); GtkBorder margin; gtk_style_context_get_margin(style, gtk_style_context_get_state(style), &margin); - moz_gtk_rectangle_inset(rect, margin); + Inset(rect, margin); +} + +// Inset a rectangle by the border and padding specified in a style context. +static void +InsetByBorderPadding(GdkRectangle* rect, GtkStyleContext* style) +{ + GtkStateFlags state = gtk_style_context_get_state(style); + GtkBorder padding, border; + + gtk_style_context_get_padding(style, state, &padding); + Inset(rect, padding); + gtk_style_context_get_border(style, state, &border); + Inset(rect, border); } static gint @@ -528,7 +544,7 @@ moz_gtk_scrollbar_button_paint(cairo_t *cr, const GdkRectangle* aRect, if (gtk_check_version(3,20,0) == nullptr) { // The "trough-border" is not used since GTK 3.20. The stepper margin // box occupies the full width of the "contents" gadget content box. - moz_gtk_subtract_margin(style, &rect); + InsetByMargin(&rect, style); } else { // Scrollbar button has to be inset by trough_border because its DOM // element is filling width of vertical scrollbar's track (or height @@ -601,7 +617,7 @@ moz_gtk_draw_styled_frame(GtkStyleContext* style, cairo_t *cr, { GdkRectangle rect = *aRect; if (gtk_check_version(3, 6, 0) == nullptr) { - moz_gtk_subtract_margin(style, &rect); + InsetByMargin(&rect, style); } gtk_render_background(style, cr, rect.x, rect.y, rect.width, rect.height); gtk_render_frame(style, cr, rect.x, rect.y, rect.width, rect.height); @@ -656,7 +672,7 @@ moz_gtk_scrollbar_thumb_paint(WidgetNodeType widget, GdkRectangle rect = *aRect; GtkStyleContext* style = ClaimStyleContext(widget, direction, state_flags); - moz_gtk_subtract_margin(style, &rect); + InsetByMargin(&rect, style); gtk_render_slider(style, cr, rect.x, @@ -857,7 +873,7 @@ moz_gtk_entry_paint(cairo_t *cr, GdkRectangle* rect, } static gint -moz_gtk_text_view_paint(cairo_t *cr, GdkRectangle* rect, +moz_gtk_text_view_paint(cairo_t *cr, GdkRectangle* aRect, GtkWidgetState* state, GtkTextDirection direction) { @@ -874,24 +890,24 @@ moz_gtk_text_view_paint(cairo_t *cr, GdkRectangle* rect, GtkStyleContext* style_frame = ClaimStyleContext(MOZ_GTK_SCROLLED_WINDOW, direction, state_flags); - gtk_render_frame(style_frame, cr, rect->x, rect->y, rect->width, rect->height); + gtk_render_frame(style_frame, cr, + aRect->x, aRect->y, aRect->width, aRect->height); + + GdkRectangle rect = *aRect; + InsetByBorderPadding(&rect, style_frame); - GtkBorder border, padding; - gtk_style_context_get_border(style_frame, state_flags, &border); - gtk_style_context_get_padding(style_frame, state_flags, &padding); ReleaseStyleContext(style_frame); GtkStyleContext* style = ClaimStyleContext(MOZ_GTK_TEXT_VIEW, direction, state_flags); - - gint xthickness = border.left + padding.left; - gint ythickness = border.top + padding.top; - - gtk_render_background(style, cr, - rect->x + xthickness, rect->y + ythickness, - rect->width - 2 * xthickness, - rect->height - 2 * ythickness); - + gtk_render_background(style, cr, rect.x, rect.y, rect.width, rect.height); + ReleaseStyleContext(style); + // There is a separate "text" window, which usually provides the + // background behind the text. However, this is transparent in Ambiance + // for GTK 3.20, in which case the MOZ_GTK_TEXT_VIEW background is + // visible. + style = ClaimStyleContext(MOZ_GTK_TEXT_VIEW_TEXT, direction, state_flags); + gtk_render_background(style, cr, rect.x, rect.y, rect.width, rect.height); ReleaseStyleContext(style); return MOZ_GTK_SUCCESS; @@ -1013,8 +1029,7 @@ moz_gtk_treeview_expander_paint(cairo_t *cr, GdkRectangle* rect, return MOZ_GTK_SUCCESS; } -/* See gtk_separator_draw() for reference. -*/ +/* See gtk_separator_draw() for reference. */ static gint moz_gtk_combo_box_paint(cairo_t *cr, GdkRectangle* rect, GtkWidgetState* state, @@ -1283,6 +1298,7 @@ moz_gtk_tooltip_paint(cairo_t *cr, const GdkRectangle* aRect, GdkRectangle rect = *aRect; gtk_render_background(style, cr, rect.x, rect.y, rect.width, rect.height); gtk_render_frame(style, cr, rect.x, rect.y, rect.width, rect.height); + ReleaseStyleContext(style); // Horizontal Box drawing // @@ -1292,33 +1308,26 @@ moz_gtk_tooltip_paint(cairo_t *cr, const GdkRectangle* aRect, // 6px margin. // For drawing Horizontal Box we have to inset drawing area by that 6px // plus its CSS margin. - GtkStyleContext* boxStyle = - CreateStyleForWidget(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0), style); + GtkStyleContext* boxStyle = ClaimStyleContext(MOZ_GTK_TOOLTIP_BOX, direction); rect.x += 6; rect.y += 6; rect.width -= 12; rect.height -= 12; - moz_gtk_subtract_margin(boxStyle, &rect); + InsetByMargin(&rect, boxStyle); gtk_render_background(boxStyle, cr, rect.x, rect.y, rect.width, rect.height); gtk_render_frame(boxStyle, cr, rect.x, rect.y, rect.width, rect.height); // Label drawing - GtkBorder padding, border; - gtk_style_context_get_padding(boxStyle, GTK_STATE_FLAG_NORMAL, &padding); - moz_gtk_rectangle_inset(&rect, padding); - gtk_style_context_get_border(boxStyle, GTK_STATE_FLAG_NORMAL, &border); - moz_gtk_rectangle_inset(&rect, border); + InsetByBorderPadding(&rect, boxStyle); + ReleaseStyleContext(boxStyle); GtkStyleContext* labelStyle = - CreateStyleForWidget(gtk_label_new(nullptr), boxStyle); + ClaimStyleContext(MOZ_GTK_TOOLTIP_BOX_LABEL, direction); moz_gtk_draw_styled_frame(labelStyle, cr, &rect, false); - g_object_unref(labelStyle); - - g_object_unref(boxStyle); + ReleaseStyleContext(labelStyle); - ReleaseStyleContext(style); return MOZ_GTK_SUCCESS; } @@ -1327,17 +1336,9 @@ moz_gtk_resizer_paint(cairo_t *cr, GdkRectangle* rect, GtkWidgetState* state, GtkTextDirection direction) { - GtkStyleContext* style; - - // gtk_render_handle() draws a background, so use GtkTextView and its - // GTK_STYLE_CLASS_VIEW to match the background with textarea elements. - // The resizer is drawn with shaded variants of the background color, and - // so a transparent background would lead to a transparent resizer. - style = ClaimStyleContext(MOZ_GTK_TEXT_VIEW, GTK_TEXT_DIR_LTR, - GetStateFlagsFromGtkWidgetState(state)); - // TODO - we need to save/restore style when gtk 3.20 CSS node path - // is used - gtk_style_context_add_class(style, GTK_STYLE_CLASS_GRIP); + GtkStyleContext* style = + ClaimStyleContext(MOZ_GTK_RESIZER, GTK_TEXT_DIR_LTR, + GetStateFlagsFromGtkWidgetState(state)); // Workaround unico not respecting the text direction for resizers. // See bug 1174248. @@ -1384,17 +1385,8 @@ moz_gtk_progress_chunk_paint(cairo_t *cr, GdkRectangle* rect, GtkTextDirection direction, WidgetNodeType widget) { - GtkStyleContext* style; - - if (gtk_check_version(3, 20, 0) != nullptr) { - /* Ask for MOZ_GTK_PROGRESS_TROUGH instead of MOZ_GTK_PROGRESSBAR - * because ClaimStyleContext() saves/restores that style */ - style = ClaimStyleContext(MOZ_GTK_PROGRESS_TROUGH, direction); - gtk_style_context_remove_class(style, GTK_STYLE_CLASS_TROUGH); - gtk_style_context_add_class(style, GTK_STYLE_CLASS_PROGRESSBAR); - } else { - style = ClaimStyleContext(MOZ_GTK_PROGRESS_CHUNK, direction); - } + GtkStyleContext* style = + ClaimStyleContext(MOZ_GTK_PROGRESS_CHUNK, direction); if (widget == MOZ_GTK_PROGRESS_CHUNK_INDETERMINATE || widget == MOZ_GTK_PROGRESS_CHUNK_VERTICAL_INDETERMINATE) { @@ -1778,6 +1770,13 @@ static gint moz_gtk_menu_separator_paint(cairo_t *cr, GdkRectangle* rect, GtkTextDirection direction) { + GtkWidgetState defaultState = { 0 }; + moz_gtk_menu_item_paint(MOZ_GTK_MENUSEPARATOR, cr, rect, + &defaultState, direction); + + if (gtk_get_minor_version() >= 20) + return MOZ_GTK_SUCCESS; + GtkStyleContext* style; gboolean wide_separators; gint separator_height; @@ -1825,36 +1824,39 @@ moz_gtk_menu_item_paint(WidgetNodeType widget, cairo_t *cr, GdkRectangle* rect, GtkWidgetState* state, GtkTextDirection direction) { gint x, y, w, h; + guint minorVersion = gtk_get_minor_version(); + GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state); - if (state->inHover && !state->disabled) { - GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state); - GtkStyleContext* style = - ClaimStyleContext(widget, direction, state_flags); - - bool pre_3_6 = gtk_check_version(3, 6, 0) != nullptr; - if (pre_3_6) { - // GTK+ 3.4 saves the style context and adds the menubar class to - // menubar children, but does each of these only when drawing, not - // during layout. - gtk_style_context_save(style); - if (widget == MOZ_GTK_MENUBARITEM) { - gtk_style_context_add_class(style, GTK_STYLE_CLASS_MENUBAR); - } + // GTK versions prior to 3.8 render the background and frame only when not + // a separator and in hover prelight. + if (minorVersion < 8 && (widget == MOZ_GTK_MENUSEPARATOR || + !(state_flags & GTK_STATE_FLAG_PRELIGHT))) + return MOZ_GTK_SUCCESS; + + GtkStyleContext* style = ClaimStyleContext(widget, direction, state_flags); + + if (minorVersion < 6) { + // GTK+ 3.4 saves the style context and adds the menubar class to + // menubar children, but does each of these only when drawing, not + // during layout. + gtk_style_context_save(style); + if (widget == MOZ_GTK_MENUBARITEM) { + gtk_style_context_add_class(style, GTK_STYLE_CLASS_MENUBAR); } + } - x = rect->x; - y = rect->y; - w = rect->width; - h = rect->height; + x = rect->x; + y = rect->y; + w = rect->width; + h = rect->height; - gtk_render_background(style, cr, x, y, w, h); - gtk_render_frame(style, cr, x, y, w, h); + gtk_render_background(style, cr, x, y, w, h); + gtk_render_frame(style, cr, x, y, w, h); - if (pre_3_6) { - gtk_style_context_restore(style); - } - ReleaseStyleContext(style); + if (minorVersion < 6) { + gtk_style_context_restore(style); } + ReleaseStyleContext(style); return MOZ_GTK_SUCCESS; } @@ -1874,16 +1876,16 @@ moz_gtk_menu_arrow_paint(cairo_t *cr, GdkRectangle* rect, return MOZ_GTK_SUCCESS; } -// See gtk_real_check_menu_item_draw_indicator() for reference. +// For reference, see gtk_check_menu_item_size_allocate() in GTK versions after +// 3.20 and gtk_real_check_menu_item_draw_indicator() in earlier versions. static gint -moz_gtk_check_menu_item_paint(cairo_t *cr, GdkRectangle* rect, +moz_gtk_check_menu_item_paint(WidgetNodeType widgetType, + cairo_t *cr, GdkRectangle* rect, GtkWidgetState* state, - gboolean checked, gboolean isradio, - GtkTextDirection direction) + gboolean checked, GtkTextDirection direction) { GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state); GtkStyleContext* style; - GtkBorder padding; gint indicator_size, horizontal_padding; gint x, y; @@ -1893,35 +1895,44 @@ moz_gtk_check_menu_item_paint(cairo_t *cr, GdkRectangle* rect, state_flags = static_cast<GtkStateFlags>(state_flags|checkbox_check_state); } - style = ClaimStyleContext(isradio ? MOZ_GTK_RADIOMENUITEM_CONTAINER : - MOZ_GTK_CHECKMENUITEM_CONTAINER, - direction); + bool pre_3_20 = gtk_get_minor_version() < 20; + gint offset; + style = ClaimStyleContext(widgetType, direction); gtk_style_context_get_style(style, "indicator-size", &indicator_size, "horizontal-padding", &horizontal_padding, NULL); + if (pre_3_20) { + GtkBorder padding; + gtk_style_context_get_padding(style, state_flags, &padding); + offset = horizontal_padding + padding.left + 2; + } else { + GdkRectangle r = { 0 }; + InsetByMargin(&r, style); + InsetByBorderPadding(&r, style); + offset = r.x; + } ReleaseStyleContext(style); - style = ClaimStyleContext(isradio ? MOZ_GTK_RADIOMENUITEM : - MOZ_GTK_CHECKMENUITEM, - direction, state_flags); - gtk_style_context_get_padding(style, state_flags, &padding); - gint offset = padding.left + 2; + bool isRadio = (widgetType == MOZ_GTK_RADIOMENUITEM); + WidgetNodeType indicatorType = isRadio ? MOZ_GTK_RADIOMENUITEM_INDICATOR + : MOZ_GTK_CHECKMENUITEM_INDICATOR; + style = ClaimStyleContext(indicatorType, direction, state_flags); if (direction == GTK_TEXT_DIR_RTL) { - x = rect->width - indicator_size - offset - horizontal_padding; + x = rect->width - indicator_size - offset; } else { - x = rect->x + offset + horizontal_padding; + x = rect->x + offset; } y = rect->y + (rect->height - indicator_size) / 2; - if (gtk_check_version(3, 20, 0) == nullptr) { + if (!pre_3_20) { gtk_render_background(style, cr, x, y, indicator_size, indicator_size); gtk_render_frame(style, cr, x, y, indicator_size, indicator_size); } - if (isradio) { + if (isRadio) { gtk_render_option(style, cr, x, y, indicator_size, indicator_size); } else { gtk_render_check(style, cr, x, y, indicator_size, indicator_size); @@ -2166,12 +2177,15 @@ moz_gtk_get_widget_border(WidgetNodeType widget, gint* left, gint* top, { // Bug 1274143 for MOZ_GTK_MENUBARITEM WidgetNodeType type = - widget == MOZ_GTK_MENUBARITEM || widget == MOZ_GTK_MENUITEM ? - MOZ_GTK_MENUITEM : MOZ_GTK_CHECKMENUITEM_CONTAINER; + widget == MOZ_GTK_MENUBARITEM ? MOZ_GTK_MENUITEM : widget; style = ClaimStyleContext(type); - moz_gtk_add_style_padding(style, left, top, right, bottom); - + if (gtk_get_minor_version() < 20) { + moz_gtk_add_style_padding(style, left, top, right, bottom); + } else { + moz_gtk_add_margin_border_padding(style, + left, top, right, bottom); + } ReleaseStyleContext(style); return MOZ_GTK_SUCCESS; } @@ -2180,7 +2194,6 @@ moz_gtk_get_widget_border(WidgetNodeType widget, gint* left, gint* top, break; case MOZ_GTK_TOOLTIP: { - style = ClaimStyleContext(MOZ_GTK_TOOLTIP); // In GTK 3 there are 6 pixels of additional margin around the box. // See details there: // https://github.com/GNOME/gtk/blob/5ea69a136bd7e4970b3a800390e20314665aaed2/gtk/ui/gtktooltipwindow.ui#L11 @@ -2189,21 +2202,16 @@ moz_gtk_get_widget_border(WidgetNodeType widget, gint* left, gint* top, // We also need to add margin/padding/borders from Tooltip content. // Tooltip contains horizontal box, where icon and label is put. // We ignore icon as long as we don't have support for it. - GtkStyleContext* boxStyle = - CreateStyleForWidget(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0), - style); + GtkStyleContext* boxStyle = ClaimStyleContext(MOZ_GTK_TOOLTIP_BOX); moz_gtk_add_margin_border_padding(boxStyle, left, top, right, bottom); + ReleaseStyleContext(boxStyle); - GtkStyleContext* labelStyle = - CreateStyleForWidget(gtk_label_new(nullptr), boxStyle); + GtkStyleContext* labelStyle = ClaimStyleContext(MOZ_GTK_TOOLTIP_BOX_LABEL); moz_gtk_add_margin_border_padding(labelStyle, left, top, right, bottom); + ReleaseStyleContext(labelStyle); - g_object_unref(labelStyle); - g_object_unref(boxStyle); - - ReleaseStyleContext(style); return MOZ_GTK_SUCCESS; } case MOZ_GTK_SCROLLBAR_VERTICAL: @@ -2492,11 +2500,11 @@ void moz_gtk_get_scale_metrics(GtkOrientation orient, gint* scale_width, gint* scale_height) { - WidgetNodeType widget = (orient == GTK_ORIENTATION_HORIZONTAL) ? - MOZ_GTK_SCALE_HORIZONTAL : - MOZ_GTK_SCALE_VERTICAL; - if (gtk_check_version(3, 20, 0) != nullptr) { + WidgetNodeType widget = (orient == GTK_ORIENTATION_HORIZONTAL) ? + MOZ_GTK_SCALE_HORIZONTAL : + MOZ_GTK_SCALE_VERTICAL; + gint thumb_length, thumb_height, trough_border; moz_gtk_get_scalethumb_metrics(orient, &thumb_length, &thumb_height); @@ -2512,12 +2520,10 @@ moz_gtk_get_scale_metrics(GtkOrientation orient, gint* scale_width, } ReleaseStyleContext(style); } else { - GtkStyleContext* style = ClaimStyleContext(widget); - gtk_style_context_get(style, gtk_style_context_get_state(style), - "min-width", scale_width, - "min-height", scale_height, - nullptr); - ReleaseStyleContext(style); + WidgetNodeType widget = (orient == GTK_ORIENTATION_HORIZONTAL) ? + MOZ_GTK_SCALE_TROUGH_HORIZONTAL : + MOZ_GTK_SCALE_TROUGH_VERTICAL; + moz_gtk_get_widget_min_size(widget, scale_width, scale_height); } } @@ -2540,10 +2546,27 @@ moz_gtk_get_scalethumb_metrics(GtkOrientation orient, gint* thumb_length, gint* MOZ_GTK_SCALE_THUMB_HORIZONTAL: MOZ_GTK_SCALE_THUMB_VERTICAL; GtkStyleContext* style = ClaimStyleContext(widget); - gtk_style_context_get(style, gtk_style_context_get_state(style), - "min-width", thumb_length, - "min-height", thumb_height, + gint min_width, min_height; + GtkStateFlags state = gtk_style_context_get_state(style); + gtk_style_context_get(style, state, + "min-width", &min_width, + "min-height", &min_height, nullptr); + GtkBorder margin; + gtk_style_context_get_margin(style, state, &margin); + gint margin_width = margin.left + margin.right; + gint margin_height = margin.top + margin.bottom; + + // Negative margin of slider element also determines its minimal size + // so use bigger of those two values. + if (min_width < -margin_width) + min_width = -margin_width; + if (min_height < -margin_height) + min_height = -margin_height; + + *thumb_length = min_width; + *thumb_height = min_height; + ReleaseStyleContext(style); } @@ -2786,10 +2809,8 @@ moz_gtk_widget_paint(WidgetNodeType widget, cairo_t *cr, break; case MOZ_GTK_CHECKMENUITEM: case MOZ_GTK_RADIOMENUITEM: - return moz_gtk_check_menu_item_paint(cr, rect, state, - (gboolean) flags, - (widget == MOZ_GTK_RADIOMENUITEM), - direction); + return moz_gtk_check_menu_item_paint(widget, cr, rect, state, + (gboolean) flags, direction); break; case MOZ_GTK_SPLITTER_HORIZONTAL: return moz_gtk_vpaned_paint(cr, rect, state); diff --git a/widget/gtk/gtkdrawing.h b/widget/gtk/gtkdrawing.h index 9bbfdefe9..7db5db043 100644 --- a/widget/gtk/gtkdrawing.h +++ b/widget/gtk/gtkdrawing.h @@ -145,8 +145,11 @@ typedef enum { MOZ_GTK_ENTRY, /* Paints a GtkExpander. */ MOZ_GTK_EXPANDER, - /* Paints a GtkTextView. */ + /* Paints a GtkTextView or gets the style context corresponding to the + root node of a GtkTextView. */ MOZ_GTK_TEXT_VIEW, + /* The "text" window or node of a GtkTextView */ + MOZ_GTK_TEXT_VIEW_TEXT, /* Paints a GtkOptionMenu. */ MOZ_GTK_DROPDOWN, /* Paints a dropdown arrow (a GtkButton containing a down GtkArrow). */ @@ -160,11 +163,15 @@ typedef enum { MOZ_GTK_TOOLBAR_SEPARATOR, /* Paints a GtkToolTip */ MOZ_GTK_TOOLTIP, + /* Paints a GtkBox from GtkToolTip */ + MOZ_GTK_TOOLTIP_BOX, + /* Paints a GtkLabel of GtkToolTip */ + MOZ_GTK_TOOLTIP_BOX_LABEL, /* Paints a GtkFrame (e.g. a status bar panel). */ MOZ_GTK_FRAME, /* Paints the border of a GtkFrame */ MOZ_GTK_FRAME_BORDER, - /* Paints a resize grip for a GtkWindow */ + /* Paints a resize grip for a GtkTextView */ MOZ_GTK_RESIZER, /* Paints a GtkProgressBar. */ MOZ_GTK_PROGRESSBAR, @@ -211,10 +218,13 @@ typedef enum { /* Paints items of popup menus. */ MOZ_GTK_MENUITEM, MOZ_GTK_IMAGEMENUITEM, - MOZ_GTK_CHECKMENUITEM_CONTAINER, - MOZ_GTK_RADIOMENUITEM_CONTAINER, + /* Paints a menuitem with check indicator, or the gets the style context for + a menuitem that contains a checkbox. */ MOZ_GTK_CHECKMENUITEM, + /* Gets the style context for a checkbox in a check menuitem. */ + MOZ_GTK_CHECKMENUITEM_INDICATOR, MOZ_GTK_RADIOMENUITEM, + MOZ_GTK_RADIOMENUITEM_INDICATOR, MOZ_GTK_MENUSEPARATOR, /* GtkVPaned base class */ MOZ_GTK_SPLITTER_HORIZONTAL, diff --git a/widget/gtk/nsLookAndFeel.cpp b/widget/gtk/nsLookAndFeel.cpp index 53430dfbb..d2b82e495 100644 --- a/widget/gtk/nsLookAndFeel.cpp +++ b/widget/gtk/nsLookAndFeel.cpp @@ -47,9 +47,6 @@ nsLookAndFeel::nsLookAndFeel() : nsXPLookAndFeel(), #if (MOZ_WIDGET_GTK == 2) mStyle(nullptr), -#else - mBackgroundStyle(nullptr), - mButtonStyle(nullptr), #endif mDefaultFontCached(false), mButtonFontCached(false), mFieldFontCached(false), mMenuFontCached(false) @@ -61,13 +58,27 @@ nsLookAndFeel::~nsLookAndFeel() { #if (MOZ_WIDGET_GTK == 2) g_object_unref(mStyle); -#else - g_object_unref(mBackgroundStyle); - g_object_unref(mButtonStyle); #endif } #if MOZ_WIDGET_GTK != 2 +// Modifies color |*aDest| as if a pattern of color |aSource| was painted with +// CAIRO_OPERATOR_OVER to a surface with color |*aDest|. +static void +ApplyColorOver(const GdkRGBA& aSource, GdkRGBA* aDest) { + gdouble sourceCoef = aSource.alpha; + gdouble destCoef = aDest->alpha * (1.0 - sourceCoef); + gdouble resultAlpha = sourceCoef + destCoef; + if (resultAlpha != 0.0) { // don't divide by zero + destCoef /= resultAlpha; + sourceCoef /= resultAlpha; + aDest->red = sourceCoef * aSource.red + destCoef * aDest->red; + aDest->green = sourceCoef * aSource.green + destCoef * aDest->green; + aDest->blue = sourceCoef * aSource.blue + destCoef * aDest->blue; + aDest->alpha = resultAlpha; + } +} + static void GetLightAndDarkness(const GdkRGBA& aColor, double* aLightness, double* aDarkness) @@ -377,30 +388,39 @@ nsLookAndFeel::NativeGetColor(ColorID aID, nscolor& aColor) break; #else // css2 http://www.w3.org/TR/REC-CSS2/ui.html#system-colors - case eColorID_activeborder: + case eColorID_activeborder: { // active window border - gtk_style_context_get_border_color(mBackgroundStyle, + GtkStyleContext *style = ClaimStyleContext(MOZ_GTK_WINDOW); + gtk_style_context_get_border_color(style, GTK_STATE_FLAG_NORMAL, &gdk_color); aColor = GDK_RGBA_TO_NS_RGBA(gdk_color); + ReleaseStyleContext(style); break; - case eColorID_inactiveborder: + } + case eColorID_inactiveborder: { // inactive window border - gtk_style_context_get_border_color(mBackgroundStyle, - GTK_STATE_FLAG_INSENSITIVE, + GtkStyleContext *style = ClaimStyleContext(MOZ_GTK_WINDOW); + gtk_style_context_get_border_color(style, + GTK_STATE_FLAG_INSENSITIVE, &gdk_color); aColor = GDK_RGBA_TO_NS_RGBA(gdk_color); + ReleaseStyleContext(style); break; + } case eColorID_graytext: // disabled text in windows, menus, etc. case eColorID_inactivecaptiontext: // text in inactive window caption aColor = sMenuTextInactive; break; - case eColorID_inactivecaption: + case eColorID_inactivecaption: { // inactive window caption - gtk_style_context_get_background_color(mBackgroundStyle, + GtkStyleContext *style = ClaimStyleContext(MOZ_GTK_WINDOW); + gtk_style_context_get_background_color(style, GTK_STATE_FLAG_INSENSITIVE, &gdk_color); aColor = GDK_RGBA_TO_NS_RGBA(gdk_color); + ReleaseStyleContext(style); break; + } #endif case eColorID_infobackground: // tooltip background color @@ -521,18 +541,24 @@ nsLookAndFeel::NativeGetColor(ColorID aID, nscolor& aColor) case eColorID__moz_fieldtext: aColor = sMozFieldText; break; - case eColorID__moz_buttondefault: - // default button border color - gtk_style_context_get_border_color(mButtonStyle, + case eColorID__moz_buttondefault: { + // default button border color + GtkStyleContext *style = ClaimStyleContext(MOZ_GTK_BUTTON); + gtk_style_context_get_border_color(style, GTK_STATE_FLAG_NORMAL, &gdk_color); aColor = GDK_RGBA_TO_NS_RGBA(gdk_color); + ReleaseStyleContext(style); break; - case eColorID__moz_buttonhoverface: - gtk_style_context_get_background_color(mButtonStyle, + } + case eColorID__moz_buttonhoverface: { + GtkStyleContext *style = ClaimStyleContext(MOZ_GTK_BUTTON); + gtk_style_context_get_background_color(style, GTK_STATE_FLAG_PRELIGHT, &gdk_color); aColor = GDK_RGBA_TO_NS_RGBA(gdk_color); + ReleaseStyleContext(style); break; + } case eColorID__moz_buttonhovertext: aColor = sButtonHoverText; break; @@ -1029,16 +1055,6 @@ nsLookAndFeel::GetFontImpl(FontID aID, nsString& aFontName, return true; } -#if (MOZ_WIDGET_GTK == 3) -static GtkStyleContext* -create_context(GtkWidgetPath *path) -{ - GtkStyleContext *style = gtk_style_context_new(); - gtk_style_context_set_path(style, path); - return(style); -} -#endif - void nsLookAndFeel::Init() { @@ -1129,78 +1145,55 @@ nsLookAndFeel::Init() g_object_set(settings, dark_setting, FALSE, nullptr); } - GtkWidgetPath *path = gtk_widget_path_new(); - gtk_widget_path_append_type(path, GTK_TYPE_WINDOW); - - mBackgroundStyle = create_context(path); - gtk_style_context_add_class(mBackgroundStyle, GTK_STYLE_CLASS_BACKGROUND); - - mButtonStyle = create_context(path); - gtk_style_context_add_class(mButtonStyle, GTK_STYLE_CLASS_BUTTON); - // Scrollbar colors - style = create_context(path); - gtk_style_context_add_class(style, GTK_STYLE_CLASS_SCROLLBAR); - gtk_style_context_add_class(style, GTK_STYLE_CLASS_TROUGH); + style = ClaimStyleContext(MOZ_GTK_SCROLLBAR_TROUGH_VERTICAL); gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color); sMozScrollbar = GDK_RGBA_TO_NS_RGBA(color); - g_object_unref(style); + ReleaseStyleContext(style); // Window colors - style = create_context(path); - gtk_style_context_save(style); - gtk_style_context_add_class(style, GTK_STYLE_CLASS_BACKGROUND); + style = ClaimStyleContext(MOZ_GTK_WINDOW); gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color); sMozWindowBackground = GDK_RGBA_TO_NS_RGBA(color); gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color); sMozWindowText = GDK_RGBA_TO_NS_RGBA(color); - gtk_style_context_restore(style); - g_object_unref(style); + ReleaseStyleContext(style); // tooltip foreground and background style = ClaimStyleContext(MOZ_GTK_TOOLTIP); gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color); sInfoBackground = GDK_RGBA_TO_NS_RGBA(color); - { - GtkStyleContext* boxStyle = - CreateStyleForWidget(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0), - style); - GtkStyleContext* labelStyle = - CreateStyleForWidget(gtk_label_new(nullptr), boxStyle); - gtk_style_context_get_color(labelStyle, GTK_STATE_FLAG_NORMAL, &color); - g_object_unref(labelStyle); - g_object_unref(boxStyle); - } - sInfoText = GDK_RGBA_TO_NS_RGBA(color); ReleaseStyleContext(style); - // menu foreground & menu background - GtkWidget *accel_label = gtk_accel_label_new("M"); - GtkWidget *menuitem = gtk_menu_item_new(); - GtkWidget *menu = gtk_menu_new(); - - g_object_ref_sink(menu); - - gtk_container_add(GTK_CONTAINER(menuitem), accel_label); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); - - style = gtk_widget_get_style_context(accel_label); + style = ClaimStyleContext(MOZ_GTK_TOOLTIP_BOX_LABEL); gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color); - sMenuText = GDK_RGBA_TO_NS_RGBA(color); - gtk_style_context_get_color(style, GTK_STATE_FLAG_INSENSITIVE, &color); - sMenuTextInactive = GDK_RGBA_TO_NS_RGBA(color); + sInfoText = GDK_RGBA_TO_NS_RGBA(color); + ReleaseStyleContext(style); - style = gtk_widget_get_style_context(menu); + style = ClaimStyleContext(MOZ_GTK_MENUITEM); + { + GtkStyleContext* accelStyle = + CreateStyleForWidget(gtk_accel_label_new("M"), style); + gtk_style_context_get_color(accelStyle, GTK_STATE_FLAG_NORMAL, &color); + sMenuText = GDK_RGBA_TO_NS_RGBA(color); + gtk_style_context_get_color(accelStyle, GTK_STATE_FLAG_INSENSITIVE, &color); + sMenuTextInactive = GDK_RGBA_TO_NS_RGBA(color); + g_object_unref(accelStyle); + } + ReleaseStyleContext(style); + + style = ClaimStyleContext(MOZ_GTK_MENUPOPUP); gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color); sMenuBackground = GDK_RGBA_TO_NS_RGBA(color); + ReleaseStyleContext(style); - style = gtk_widget_get_style_context(menuitem); + style = ClaimStyleContext(MOZ_GTK_MENUITEM); gtk_style_context_get_background_color(style, GTK_STATE_FLAG_PRELIGHT, &color); sMenuHover = GDK_RGBA_TO_NS_RGBA(color); gtk_style_context_get_color(style, GTK_STATE_FLAG_PRELIGHT, &color); sMenuHoverText = GDK_RGBA_TO_NS_RGBA(color); - g_object_unref(menu); + ReleaseStyleContext(style); #endif // button styles @@ -1211,9 +1204,6 @@ nsLookAndFeel::Init() GtkWidget *combobox = gtk_combo_box_new(); GtkWidget *comboboxLabel = gtk_label_new("M"); gtk_container_add(GTK_CONTAINER(combobox), comboboxLabel); -#else - GtkWidget *combobox = gtk_combo_box_new_with_entry(); - GtkWidget *comboboxLabel = gtk_bin_get_child(GTK_BIN(combobox)); #endif GtkWidget *window = gtk_window_new(GTK_WINDOW_POPUP); GtkWidget *treeView = gtk_tree_view_new(); @@ -1227,7 +1217,9 @@ nsLookAndFeel::Init() gtk_container_add(GTK_CONTAINER(parent), button); gtk_container_add(GTK_CONTAINER(parent), treeView); gtk_container_add(GTK_CONTAINER(parent), linkButton); +#if (MOZ_WIDGET_GTK == 2) gtk_container_add(GTK_CONTAINER(parent), combobox); +#endif gtk_container_add(GTK_CONTAINER(parent), menuBar); gtk_menu_shell_append(GTK_MENU_SHELL(menuBar), menuBarItem); gtk_container_add(GTK_CONTAINER(window), parent); @@ -1310,11 +1302,19 @@ nsLookAndFeel::Init() } #else // Text colors - style = gtk_widget_get_style_context(textView); - gtk_style_context_save(style); - gtk_style_context_add_class(style, GTK_STYLE_CLASS_VIEW); - gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color); - sMozFieldBackground = GDK_RGBA_TO_NS_RGBA(color); + GdkRGBA bgColor; + // If the text window background is translucent, then the background of + // the textview root node is visible. + style = ClaimStyleContext(MOZ_GTK_TEXT_VIEW); + gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, + &bgColor); + ReleaseStyleContext(style); + + style = ClaimStyleContext(MOZ_GTK_TEXT_VIEW_TEXT); + gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, + &color); + ApplyColorOver(color, &bgColor); + sMozFieldBackground = GDK_RGBA_TO_NS_RGBA(bgColor); gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color); sMozFieldText = GDK_RGBA_TO_NS_RGBA(color); @@ -1327,26 +1327,34 @@ nsLookAndFeel::Init() static_cast<GtkStateFlags>(GTK_STATE_FLAG_FOCUSED|GTK_STATE_FLAG_SELECTED), &color); sTextSelectedText = GDK_RGBA_TO_NS_RGBA(color); - gtk_style_context_restore(style); + ReleaseStyleContext(style); - // Button text, background, border - style = gtk_widget_get_style_context(label); - gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color); - sButtonText = GDK_RGBA_TO_NS_RGBA(color); - gtk_style_context_get_color(style, GTK_STATE_FLAG_PRELIGHT, &color); - sButtonHoverText = GDK_RGBA_TO_NS_RGBA(color); + // Button text color + style = ClaimStyleContext(MOZ_GTK_BUTTON); + { + GtkStyleContext* labelStyle = + CreateStyleForWidget(gtk_label_new("M"), style); + gtk_style_context_get_color(labelStyle, GTK_STATE_FLAG_NORMAL, &color); + sButtonText = GDK_RGBA_TO_NS_RGBA(color); + gtk_style_context_get_color(labelStyle, GTK_STATE_FLAG_PRELIGHT, &color); + sButtonHoverText = GDK_RGBA_TO_NS_RGBA(color); + g_object_unref(labelStyle); + } + ReleaseStyleContext(style); // Combobox text color - style = gtk_widget_get_style_context(comboboxLabel); + style = ClaimStyleContext(MOZ_GTK_COMBOBOX_ENTRY_TEXTAREA); gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color); sComboBoxText = GDK_RGBA_TO_NS_RGBA(color); + ReleaseStyleContext(style); // Menubar text and hover text colors - style = gtk_widget_get_style_context(menuBarItem); + style = ClaimStyleContext(MOZ_GTK_MENUBARITEM); gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color); sMenuBarText = GDK_RGBA_TO_NS_RGBA(color); gtk_style_context_get_color(style, GTK_STATE_FLAG_PRELIGHT, &color); sMenuBarHoverText = GDK_RGBA_TO_NS_RGBA(color); + ReleaseStyleContext(style); // GTK's guide to fancy odd row background colors: // 1) Check if a theme explicitly defines an odd row color @@ -1354,7 +1362,7 @@ nsLookAndFeel::Init() // slightly by a hardcoded value (gtkstyle.c) // 3) If neither are defined, take the base background color and // darken that by a hardcoded value - style = gtk_widget_get_style_context(treeView); + style = ClaimStyleContext(MOZ_GTK_TREEVIEW); // Get odd row background color gtk_style_context_save(style); @@ -1362,8 +1370,7 @@ nsLookAndFeel::Init() gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color); sOddCellBackground = GDK_RGBA_TO_NS_RGBA(color); gtk_style_context_restore(style); - - gtk_widget_path_free(path); + ReleaseStyleContext(style); // GtkFrame has a "border" subnode on which Adwaita draws the border. // Some themes do not draw on this node but draw a border on the widget @@ -1448,12 +1455,6 @@ nsLookAndFeel::RefreshImpl() #if (MOZ_WIDGET_GTK == 2) g_object_unref(mStyle); mStyle = nullptr; -#else - g_object_unref(mBackgroundStyle); - g_object_unref(mButtonStyle); - - mBackgroundStyle = nullptr; - mButtonStyle = nullptr; #endif Init(); diff --git a/widget/gtk/nsLookAndFeel.h b/widget/gtk/nsLookAndFeel.h index 9058250b9..726859b41 100644 --- a/widget/gtk/nsLookAndFeel.h +++ b/widget/gtk/nsLookAndFeel.h @@ -33,9 +33,6 @@ public: protected: #if (MOZ_WIDGET_GTK == 2) struct _GtkStyle *mStyle; -#else - struct _GtkStyleContext *mBackgroundStyle; - struct _GtkStyleContext *mButtonStyle; #endif // Cached fonts diff --git a/widget/gtk/nsWindow.cpp b/widget/gtk/nsWindow.cpp index d97b35002..e4e69c1b4 100644 --- a/widget/gtk/nsWindow.cpp +++ b/widget/gtk/nsWindow.cpp @@ -6627,6 +6627,22 @@ nsWindow::GetDragInfo(WidgetMouseEvent* aMouseEvent, return false; } + if (mIsX11Display) { + // Workaround for https://bugzilla.gnome.org/show_bug.cgi?id=789054 + // To avoid crashes disable double-click on WM without _NET_WM_MOVERESIZE. + // See _should_perform_ewmh_drag() at gdkwindow-x11.c + GdkScreen* screen = gdk_window_get_screen(gdk_window); + GdkAtom atom = gdk_atom_intern("_NET_WM_MOVERESIZE", FALSE); + if (!gdk_x11_screen_supports_net_wm_hint(screen, atom)) { + static unsigned int lastTimeStamp = 0; + if (lastTimeStamp != aMouseEvent->mTime) { + lastTimeStamp = aMouseEvent->mTime; + } else { + return false; + } + } + } + // FIXME: It would be nice to have the widget position at the time // of the event, but it's relatively unlikely that the widget has // moved since the mousedown. (On the other hand, it's quite likely diff --git a/widget/nsBaseAppShell.cpp b/widget/nsBaseAppShell.cpp index 1557498b7..c6b88cba0 100644 --- a/widget/nsBaseAppShell.cpp +++ b/widget/nsBaseAppShell.cpp @@ -6,9 +6,6 @@ #include "base/message_loop.h" #include "nsBaseAppShell.h" -#if defined(MOZ_CRASHREPORTER) -#include "nsExceptionHandler.h" -#endif #include "nsThreadUtils.h" #include "nsIObserverService.h" #include "nsServiceManagerUtils.h" @@ -317,18 +314,12 @@ void nsBaseAppShell::IncrementEventloopNestingLevel() { ++mEventloopNestingLevel; -#if defined(MOZ_CRASHREPORTER) - CrashReporter::SetEventloopNestingLevel(mEventloopNestingLevel); -#endif } void nsBaseAppShell::DecrementEventloopNestingLevel() { --mEventloopNestingLevel; -#if defined(MOZ_CRASHREPORTER) - CrashReporter::SetEventloopNestingLevel(mEventloopNestingLevel); -#endif } // Called from the main thread diff --git a/widget/windows/GfxInfo.cpp b/widget/windows/GfxInfo.cpp index 0cbd323de..8a429ad32 100644 --- a/widget/windows/GfxInfo.cpp +++ b/widget/windows/GfxInfo.cpp @@ -21,12 +21,6 @@ #include "nsPrintfCString.h" #include "jsapi.h" -#if defined(MOZ_CRASHREPORTER) -#include "nsExceptionHandler.h" -#include "nsICrashReporter.h" -#define NS_CRASHREPORTER_CONTRACTID "@mozilla.org/toolkit/crash-reporter;1" -#endif - using namespace mozilla; using namespace mozilla::gfx; using namespace mozilla::widget; @@ -241,9 +235,6 @@ ParseIDFromDeviceID(const nsAString &key, const char *prefix, int length) // based on http://msdn.microsoft.com/en-us/library/ms724834(VS.85).aspx enum { kWindowsUnknown = 0, - kWindowsXP = 0x50001, - kWindowsServer2003 = 0x50002, - kWindowsVista = 0x60000, kWindows7 = 0x60001, kWindows8 = 0x60002, kWindows8_1 = 0x60003, @@ -724,114 +715,16 @@ GfxInfo::GetIsGPU2Active(bool* aIsGPU2Active) return NS_OK; } -#if defined(MOZ_CRASHREPORTER) -/* Cisco's VPN software can cause corruption of the floating point state. - * Make a note of this in our crash reports so that some weird crashes - * make more sense */ -static void -CheckForCiscoVPN() { - LONG result; - HKEY key; - /* This will give false positives, but hopefully no false negatives */ - result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Cisco Systems\\VPN Client", 0, KEY_QUERY_VALUE, &key); - if (result == ERROR_SUCCESS) { - RegCloseKey(key); - CrashReporter::AppendAppNotesToCrashReport(NS_LITERAL_CSTRING("Cisco VPN\n")); - } -} -#endif - void GfxInfo::AddCrashReportAnnotations() { -#if defined(MOZ_CRASHREPORTER) - CheckForCiscoVPN(); - - if (mHasDriverVersionMismatch) { - CrashReporter::AppendAppNotesToCrashReport(NS_LITERAL_CSTRING("DriverVersionMismatch\n")); - } - - nsString deviceID, vendorID, driverVersion, subsysID; - nsCString narrowDeviceID, narrowVendorID, narrowDriverVersion, narrowSubsysID; - - GetAdapterDeviceID(deviceID); - CopyUTF16toUTF8(deviceID, narrowDeviceID); - GetAdapterVendorID(vendorID); - CopyUTF16toUTF8(vendorID, narrowVendorID); - GetAdapterDriverVersion(driverVersion); - CopyUTF16toUTF8(driverVersion, narrowDriverVersion); - GetAdapterSubsysID(subsysID); - CopyUTF16toUTF8(subsysID, narrowSubsysID); - - CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterVendorID"), - narrowVendorID); - CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterDeviceID"), - narrowDeviceID); - CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterDriverVersion"), - narrowDriverVersion); - CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterSubsysID"), - narrowSubsysID); - - /* Add an App Note for now so that we get the data immediately. These - * can go away after we store the above in the socorro db */ - nsAutoCString note; - /* AppendPrintf only supports 32 character strings, mrghh. */ - note.AppendLiteral("AdapterVendorID: "); - note.Append(narrowVendorID); - note.AppendLiteral(", AdapterDeviceID: "); - note.Append(narrowDeviceID); - note.AppendLiteral(", AdapterSubsysID: "); - note.Append(narrowSubsysID); - note.AppendLiteral(", AdapterDriverVersion: "); - note.Append(NS_LossyConvertUTF16toASCII(driverVersion)); - - if (vendorID == GfxDriverInfo::GetDeviceVendor(VendorAll)) { - /* if we didn't find a valid vendorID lets append the mDeviceID string to try to find out why */ - note.AppendLiteral(", "); - LossyAppendUTF16toASCII(mDeviceID, note); - note.AppendLiteral(", "); - LossyAppendUTF16toASCII(mDeviceKeyDebug, note); - LossyAppendUTF16toASCII(mDeviceKeyDebug, note); - } - note.Append("\n"); - - if (mHasDualGPU) { - nsString deviceID2, vendorID2, subsysID2; - nsAutoString adapterDriverVersionString2; - nsCString narrowDeviceID2, narrowVendorID2, narrowSubsysID2; - - note.AppendLiteral("Has dual GPUs. GPU #2: "); - GetAdapterDeviceID2(deviceID2); - CopyUTF16toUTF8(deviceID2, narrowDeviceID2); - GetAdapterVendorID2(vendorID2); - CopyUTF16toUTF8(vendorID2, narrowVendorID2); - GetAdapterDriverVersion2(adapterDriverVersionString2); - GetAdapterSubsysID(subsysID2); - CopyUTF16toUTF8(subsysID2, narrowSubsysID2); - note.AppendLiteral("AdapterVendorID2: "); - note.Append(narrowVendorID2); - note.AppendLiteral(", AdapterDeviceID2: "); - note.Append(narrowDeviceID2); - note.AppendLiteral(", AdapterSubsysID2: "); - note.Append(narrowSubsysID2); - note.AppendLiteral(", AdapterDriverVersion2: "); - note.Append(NS_LossyConvertUTF16toASCII(adapterDriverVersionString2)); - } - CrashReporter::AppendAppNotesToCrashReport(note); - -#endif + /*** STUB ***/ } static OperatingSystem WindowsVersionToOperatingSystem(int32_t aWindowsVersion) { switch(aWindowsVersion) { - case kWindowsXP: - return OperatingSystem::WindowsXP; - case kWindowsServer2003: - return OperatingSystem::WindowsServer2003; - case kWindowsVista: - return OperatingSystem::WindowsVista; case kWindows7: return OperatingSystem::Windows7; case kWindows8: @@ -860,11 +753,6 @@ GfxInfo::GetGfxDriverInfo() /* * NVIDIA entries */ - APPEND_TO_DRIVER_BLOCKLIST(OperatingSystem::WindowsXP, - (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorNVIDIA), GfxDriverInfo::allDevices, - GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, - DRIVER_LESS_THAN_OR_EQUAL, V(6,14,11,8745), "FEATURE_FAILURE_NV_XP", "nVidia driver > 187.45" ); - /* * The last 5 digit of the NVIDIA driver version maps to the version that * NVIDIA uses. The minor version (15, 16, 17) corresponds roughtly to the @@ -875,33 +763,17 @@ GfxInfo::GetGfxDriverInfo() * 187.45 (late October 2009) and earlier contain a bug which can cause us * to crash on shutdown. */ - APPEND_TO_DRIVER_BLOCKLIST(OperatingSystem::WindowsVista, - (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorNVIDIA), GfxDriverInfo::allDevices, - GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, - DRIVER_LESS_THAN_OR_EQUAL, V(8,15,11,8745), - "FEATURE_FAILURE_NV_VISTA_15", "nVidia driver > 187.45" ); APPEND_TO_DRIVER_BLOCKLIST(OperatingSystem::Windows7, (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorNVIDIA), GfxDriverInfo::allDevices, GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN_OR_EQUAL, V(8,15,11,8745), "FEATURE_FAILURE_NV_W7_15", "nVidia driver > 187.45" ); - APPEND_TO_DRIVER_BLOCKLIST_RANGE(OperatingSystem::WindowsVista, - (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorNVIDIA), GfxDriverInfo::allDevices, - GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, - DRIVER_BETWEEN_INCLUSIVE_START, V(8,16,10,0000), V(8,16,11,8745), - "FEATURE_FAILURE_NV_VISTA_16", "nVidia driver > 187.45" ); APPEND_TO_DRIVER_BLOCKLIST_RANGE(OperatingSystem::Windows7, (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorNVIDIA), GfxDriverInfo::allDevices, GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_BETWEEN_INCLUSIVE_START, V(8,16,10,0000), V(8,16,11,8745), "FEATURE_FAILURE_NV_W7_16", "nVidia driver > 187.45" ); // Telemetry doesn't show any driver in this range so it might not even be required. - APPEND_TO_DRIVER_BLOCKLIST_RANGE(OperatingSystem::WindowsVista, - (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorNVIDIA), GfxDriverInfo::allDevices, - GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, - DRIVER_BETWEEN_INCLUSIVE_START, V(8,17,10,0000), V(8,17,11,8745), - "FEATURE_FAILURE_NV_VISTA_17", "nVidia driver > 187.45" ); - // Telemetry doesn't show any driver in this range so it might not even be required. APPEND_TO_DRIVER_BLOCKLIST_RANGE(OperatingSystem::Windows7, (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorNVIDIA), GfxDriverInfo::allDevices, GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, @@ -999,13 +871,6 @@ GfxInfo::GetGfxDriverInfo() nsIGfxInfo::FEATURE_DIRECT2D, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, \ DRIVER_BUILD_ID_LESS_THAN, driverVer, ruleId ) - IMPLEMENT_INTEL_DRIVER_BLOCKLIST_D2D(OperatingSystem::WindowsVista, IntelGMA500, 1006, "FEATURE_FAILURE_594877_1"); - IMPLEMENT_INTEL_DRIVER_BLOCKLIST_D2D(OperatingSystem::WindowsVista, IntelGMA900, GfxDriverInfo::allDriverVersions, "FEATURE_FAILURE_594877_2"); - IMPLEMENT_INTEL_DRIVER_BLOCKLIST_D2D(OperatingSystem::WindowsVista, IntelGMA950, 1504, "FEATURE_FAILURE_594877_3"); - IMPLEMENT_INTEL_DRIVER_BLOCKLIST_D2D(OperatingSystem::WindowsVista, IntelGMA3150, 2124, "FEATURE_FAILURE_594877_4"); - IMPLEMENT_INTEL_DRIVER_BLOCKLIST_D2D(OperatingSystem::WindowsVista, IntelGMAX3000, 1666, "FEATURE_FAILURE_594877_5"); - IMPLEMENT_INTEL_DRIVER_BLOCKLIST_D2D(OperatingSystem::WindowsVista, IntelHDGraphicsToSandyBridge, 2202, "FEATURE_FAILURE_594877_6"); - IMPLEMENT_INTEL_DRIVER_BLOCKLIST_D2D(OperatingSystem::Windows7, IntelGMA500, 2026, "FEATURE_FAILURE_594877_7"); IMPLEMENT_INTEL_DRIVER_BLOCKLIST_D2D(OperatingSystem::Windows7, IntelGMA900, GfxDriverInfo::allDriverVersions, "FEATURE_FAILURE_594877_8"); IMPLEMENT_INTEL_DRIVER_BLOCKLIST_D2D(OperatingSystem::Windows7, IntelGMA950, 1930, "FEATURE_FAILURE_594877_9"); @@ -1022,31 +887,6 @@ GfxInfo::GetGfxDriverInfo() nsIGfxInfo::FEATURE_DIRECT2D, nsIGfxInfo::FEATURE_BLOCKED_DEVICE, DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions, "FEATURE_FAILURE_1180379"); - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(OperatingSystem::WindowsXP, IntelGMA500, V(3,0,20,3200), "FEATURE_FAILURE_INTEL_1"); - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(OperatingSystem::WindowsXP, IntelGMA900, V(6,14,10,4764), "FEATURE_FAILURE_INTEL_2"); - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(OperatingSystem::WindowsXP, IntelGMA950, V(6,14,10,4926), "FEATURE_FAILURE_INTEL_3"); - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(OperatingSystem::WindowsXP, IntelGMA3150, V(6,14,10,5134), "FEATURE_FAILURE_INTEL_4"); - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(OperatingSystem::WindowsXP, IntelGMAX3000, V(6,14,10,5218), "FEATURE_FAILURE_INTEL_5"); - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(OperatingSystem::WindowsXP, IntelGMAX4500HD, V(6,14,10,4969), "FEATURE_FAILURE_INTEL_6"); - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(OperatingSystem::WindowsXP, IntelHDGraphicsToSandyBridge, V(6,14,10,4969), "FEATURE_FAILURE_INTEL_7"); - - // StrechRect seems to suffer from precision issues which leads to artifacting - // during content drawing starting with at least version 6.14.10.5082 - // and going until 6.14.10.5218. See bug 919454 and bug 949275 for more info. - APPEND_TO_DRIVER_BLOCKLIST_RANGE(OperatingSystem::WindowsXP, - const_cast<nsAString&>(GfxDriverInfo::GetDeviceVendor(VendorIntel)), - const_cast<GfxDeviceFamily*>(GfxDriverInfo::GetDeviceFamily(IntelGMAX4500HD)), - GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, - DRIVER_BETWEEN_EXCLUSIVE, V(6,14,10,5076), V(6,14,10,5218), "FEATURE_FAILURE_INTEL_8", "6.14.10.5218"); - - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(OperatingSystem::WindowsVista, IntelGMA500, V(3,0,20,3200), "FEATURE_FAILURE_INTEL_9"); - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(OperatingSystem::WindowsVista, IntelGMA900, GfxDriverInfo::allDriverVersions, "FEATURE_FAILURE_INTEL_10"); - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(OperatingSystem::WindowsVista, IntelGMA950, V(7,14,10,1504), "FEATURE_FAILURE_INTEL_11"); - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(OperatingSystem::WindowsVista, IntelGMA3150, V(7,14,10,1910), "FEATURE_FAILURE_INTEL_12"); - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(OperatingSystem::WindowsVista, IntelGMAX3000, V(7,15,10,1666), "FEATURE_FAILURE_INTEL_13"); - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(OperatingSystem::WindowsVista, IntelGMAX4500HD, V(7,15,10,1666), "FEATURE_FAILURE_INTEL_14"); - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(OperatingSystem::WindowsVista, IntelHDGraphicsToSandyBridge, V(7,15,10,1666), "FEATURE_FAILURE_INTEL_15"); - IMPLEMENT_INTEL_DRIVER_BLOCKLIST(OperatingSystem::Windows7, IntelGMA500, V(5,0,0,2026), "FEATURE_FAILURE_INTEL_16"); IMPLEMENT_INTEL_DRIVER_BLOCKLIST(OperatingSystem::Windows7, IntelGMA900, GfxDriverInfo::allDriverVersions, "FEATURE_FAILURE_INTEL_17"); IMPLEMENT_INTEL_DRIVER_BLOCKLIST(OperatingSystem::Windows7, IntelGMA950, V(8,15,10,1930), "FEATURE_FAILURE_INTEL_18"); @@ -1300,23 +1140,6 @@ GfxInfo::GetFeatureStatusImpl(int32_t aFeature, return NS_OK; } - // special-case the WinXP test slaves: they have out-of-date drivers, but we still want to - // whitelist them, actually we do know that this combination of device and driver version - // works well. - if (mWindowsVersion == kWindowsXP && - adapterVendorID.Equals(GfxDriverInfo::GetDeviceVendor(VendorNVIDIA), nsCaseInsensitiveStringComparator()) && - adapterDeviceID.LowerCaseEqualsLiteral("0x0861") && // GeForce 9400 - driverVersion == V(6,14,11,7756)) - { - *aStatus = FEATURE_STATUS_OK; - return NS_OK; - } - - // Windows Server 2003 should be just like Windows XP for present purpose, but still has a different version number. - // OTOH Windows Server 2008 R1 and R2 already have the same version numbers as Vista and Seven respectively - if (os == OperatingSystem::WindowsServer2003) - os = OperatingSystem::WindowsXP; - if (mHasDriverVersionMismatch) { *aStatus = nsIGfxInfo::FEATURE_BLOCKED_MISMATCHED_VERSION; return NS_OK; diff --git a/widget/windows/KeyboardLayout.cpp b/widget/windows/KeyboardLayout.cpp index 11f657874..9166d97d7 100644 --- a/widget/windows/KeyboardLayout.cpp +++ b/widget/windows/KeyboardLayout.cpp @@ -13,9 +13,6 @@ #include "mozilla/WindowsVersion.h" #include "nsAlgorithm.h" -#ifdef MOZ_CRASHREPORTER -#include "nsExceptionHandler.h" -#endif #include "nsGkAtoms.h" #include "nsIDOMKeyEvent.h" #include "nsIIdleServiceInternal.h" @@ -1363,34 +1360,6 @@ NativeKey::InitWithKeyChar() break; } - if (!CanComputeVirtualKeyCodeFromScanCode()) { - // The right control key and the right alt key are extended keys. - // Therefore, we never get VK_RCONTRL and VK_RMENU for the result of - // MapVirtualKeyEx() on WinXP or WinServer2003. - // - // If VK_SHIFT, VK_CONTROL or VK_MENU key message is caused by well - // known scan code, we should decide it as Right key. Otherwise, - // decide it as Left key. - switch (mOriginalVirtualKeyCode) { - case VK_CONTROL: - mVirtualKeyCode = - mIsExtended && mScanCode == 0x1D ? VK_RCONTROL : VK_LCONTROL; - break; - case VK_MENU: - mVirtualKeyCode = - mIsExtended && mScanCode == 0x38 ? VK_RMENU : VK_LMENU; - break; - case VK_SHIFT: - // Neither left shift nor right shift is an extended key, - // let's use VK_LSHIFT for unknown mapping. - mVirtualKeyCode = VK_LSHIFT; - break; - default: - MOZ_CRASH("Unsupported mOriginalVirtualKeyCode"); - } - break; - } - NS_ASSERTION(!mVirtualKeyCode, "mVirtualKeyCode has been computed already"); @@ -1447,11 +1416,6 @@ NativeKey::InitWithKeyChar() // scancode, we cannot compute virtual keycode. I.e., with such // applications, we cannot generate proper KeyboardEvent.code value. - // We cannot compute the virtual key code from WM_CHAR message on WinXP - // if it's caused by an extended key. - if (!CanComputeVirtualKeyCodeFromScanCode()) { - break; - } mVirtualKeyCode = mOriginalVirtualKeyCode = ComputeVirtualKeyCodeFromScanCodeEx(); NS_ASSERTION(mVirtualKeyCode, "Failed to compute virtual keycode"); @@ -1869,18 +1833,6 @@ NativeKey::GetKeyLocation() const } } -bool -NativeKey::CanComputeVirtualKeyCodeFromScanCode() const -{ - // Vista or later supports ScanCodeEx. - if (IsVistaOrLater()) { - return true; - } - // Otherwise, MapVirtualKeyEx() can compute virtual keycode only with - // non-extended key. - return !mIsExtended; -} - uint8_t NativeKey::ComputeVirtualKeyCodeFromScanCode() const { @@ -1894,12 +1846,6 @@ NativeKey::ComputeVirtualKeyCodeFromScanCodeEx() const // MapVirtualKeyEx() has been improved for supporting extended keys since // Vista. When we call it for mapping a scancode of an extended key and // a virtual keycode, we need to add 0xE000 to the scancode. - // On the other hand, neither WinXP nor WinServer2003 doesn't support 0xE000. - // Therefore, we have no way to get virtual keycode from scan code of - // extended keys. - if (NS_WARN_IF(!CanComputeVirtualKeyCodeFromScanCode())) { - return 0; - } return static_cast<uint8_t>( ::MapVirtualKeyEx(GetScanCodeWithExtendedFlag(), MAPVK_VSC_TO_VK_EX, mKeyboardLayout)); @@ -1910,8 +1856,7 @@ NativeKey::ComputeScanCodeExFromVirtualKeyCode(UINT aVirtualKeyCode) const { return static_cast<uint16_t>( ::MapVirtualKeyEx(aVirtualKeyCode, - IsVistaOrLater() ? MAPVK_VK_TO_VSC_EX : - MAPVK_VK_TO_VSC, + MAPVK_VK_TO_VSC_EX, mKeyboardLayout)); } @@ -2792,42 +2737,6 @@ NativeKey::NeedsToHandleWithoutFollowingCharMessages() const return mIsPrintableKey; } -#ifdef MOZ_CRASHREPORTER - -static nsCString -GetResultOfInSendMessageEx() -{ - DWORD ret = ::InSendMessageEx(nullptr); - if (!ret) { - return NS_LITERAL_CSTRING("ISMEX_NOSEND"); - } - nsAutoCString result; - if (ret & ISMEX_CALLBACK) { - result = "ISMEX_CALLBACK"; - } - if (ret & ISMEX_NOTIFY) { - if (!result.IsEmpty()) { - result += " | "; - } - result += "ISMEX_NOTIFY"; - } - if (ret & ISMEX_REPLIED) { - if (!result.IsEmpty()) { - result += " | "; - } - result += "ISMEX_REPLIED"; - } - if (ret & ISMEX_SEND) { - if (!result.IsEmpty()) { - result += " | "; - } - result += "ISMEX_SEND"; - } - return result; -} - -#endif // #ifdef MOZ_CRASHREPORTER - bool NativeKey::MayBeSameCharMessage(const MSG& aCharMsg1, const MSG& aCharMsg2) const @@ -3071,33 +2980,6 @@ NativeKey::GetFollowingCharMessage(MSG& aCharMsg) } if (doCrash) { -#ifdef MOZ_CRASHREPORTER - nsPrintfCString info("\nPeekMessage() failed to remove char message! " - "\nActive keyboard layout=0x%08X (%s), " - "\nHandling message: %s, InSendMessageEx()=%s, " - "\nFound message: %s, " - "\nWM_NULL has been removed: %d, " - "\nNext key message in all windows: %s, " - "time=%d, ", - KeyboardLayout::GetActiveLayout(), - KeyboardLayout::GetActiveLayoutName().get(), - ToString(mMsg).get(), - GetResultOfInSendMessageEx().get(), - ToString(kFoundCharMsg).get(), i, - ToString(nextKeyMsgInAllWindows).get(), - nextKeyMsgInAllWindows.time); - CrashReporter::AppendAppNotesToCrashReport(info); - MSG nextMsg; - if (WinUtils::PeekMessage(&nextMsg, 0, 0, 0, - PM_NOREMOVE | PM_NOYIELD)) { - nsPrintfCString info("\nNext message in all windows: %s, time=%d", - ToString(nextMsg).get(), nextMsg.time); - CrashReporter::AppendAppNotesToCrashReport(info); - } else { - CrashReporter::AppendAppNotesToCrashReport( - NS_LITERAL_CSTRING("\nThere is no message in any window")); - } -#endif // #ifdef MOZ_CRASHREPORTER MOZ_CRASH("We lost the following char message"); } @@ -3216,63 +3098,12 @@ NativeKey::GetFollowingCharMessage(MSG& aCharMsg) "nextKeyMsg=%s, kFoundCharMsg=%s", this, ToString(removedMsg).get(), ToString(nextKeyMsg).get(), ToString(kFoundCharMsg).get())); -#ifdef MOZ_CRASHREPORTER - nsPrintfCString info("\nPeekMessage() removed unexpcted char message! " - "\nActive keyboard layout=0x%08X (%s), " - "\nHandling message: %s, InSendMessageEx()=%s, " - "\nFound message: %s, " - "\nRemoved message: %s, ", - KeyboardLayout::GetActiveLayout(), - KeyboardLayout::GetActiveLayoutName().get(), - ToString(mMsg).get(), - GetResultOfInSendMessageEx().get(), - ToString(kFoundCharMsg).get(), - ToString(removedMsg).get()); - CrashReporter::AppendAppNotesToCrashReport(info); - // What's the next key message? - MSG nextKeyMsgAfter; - if (WinUtils::PeekMessage(&nextKeyMsgAfter, mMsg.hwnd, - WM_KEYFIRST, WM_KEYLAST, - PM_NOREMOVE | PM_NOYIELD)) { - nsPrintfCString info("\nNext key message after unexpected char message " - "removed: %s, ", - ToString(nextKeyMsgAfter).get()); - CrashReporter::AppendAppNotesToCrashReport(info); - } else { - CrashReporter::AppendAppNotesToCrashReport( - NS_LITERAL_CSTRING("\nThere is no key message after unexpected char " - "message removed, ")); - } - // Another window has a key message? - if (WinUtils::PeekMessage(&nextKeyMsgInAllWindows, 0, - WM_KEYFIRST, WM_KEYLAST, - PM_NOREMOVE | PM_NOYIELD)) { - nsPrintfCString info("\nNext key message in all windows: %s.", - ToString(nextKeyMsgInAllWindows).get()); - CrashReporter::AppendAppNotesToCrashReport(info); - } else { - CrashReporter::AppendAppNotesToCrashReport( - NS_LITERAL_CSTRING("\nThere is no key message in any windows.")); - } -#endif // #ifdef MOZ_CRASHREPORTER MOZ_CRASH("PeekMessage() removed unexpected message"); } MOZ_LOG(sNativeKeyLogger, LogLevel::Error, ("%p NativeKey::GetFollowingCharMessage(), FAILED, removed messages " "are all WM_NULL, nextKeyMsg=%s", this, ToString(nextKeyMsg).get())); -#ifdef MOZ_CRASHREPORTER - nsPrintfCString info("\nWe lost following char message! " - "\nActive keyboard layout=0x%08X (%s), " - "\nHandling message: %s, InSendMessageEx()=%s, \n" - "Found message: %s, removed a lot of WM_NULL", - KeyboardLayout::GetActiveLayout(), - KeyboardLayout::GetActiveLayoutName().get(), - ToString(mMsg).get(), - GetResultOfInSendMessageEx().get(), - ToString(kFoundCharMsg).get()); - CrashReporter::AppendAppNotesToCrashReport(info); -#endif // #ifdef MOZ_CRASHREPORTER MOZ_CRASH("We lost the following char message"); return false; } @@ -4345,8 +4176,7 @@ KeyboardLayout::LoadLayout(HKL aLayout) if (MOZ_LOG_TEST(sKeyboardLayoutLogger, LogLevel::Verbose)) { static const UINT kExtendedScanCode[] = { 0x0000, 0xE000 }; - static const UINT kMapType = - IsVistaOrLater() ? MAPVK_VSC_TO_VK_EX : MAPVK_VSC_TO_VK; + static const UINT kMapType = MAPVK_VSC_TO_VK_EX; MOZ_LOG(sKeyboardLayoutLogger, LogLevel::Verbose, ("Logging virtual keycode values for scancode (0x%p)...", mKeyboardLayout)); @@ -4358,11 +4188,6 @@ KeyboardLayout::LoadLayout(HKL aLayout) MOZ_LOG(sKeyboardLayoutLogger, LogLevel::Verbose, ("0x%04X, %s", scanCode, kVirtualKeyName[virtualKeyCode])); } - // XP and Server 2003 don't support 0xE0 prefix of the scancode. - // Therefore, we don't need to continue on them. - if (!IsVistaOrLater()) { - break; - } } } } diff --git a/widget/windows/KeyboardLayout.h b/widget/windows/KeyboardLayout.h index dd2ac0bfc..70aacc80e 100644 --- a/widget/windows/KeyboardLayout.h +++ b/widget/windows/KeyboardLayout.h @@ -560,11 +560,6 @@ private: bool GetFollowingCharMessage(MSG& aCharMsg); /** - * Whether the key event can compute virtual keycode from the scancode value. - */ - bool CanComputeVirtualKeyCodeFromScanCode() const; - - /** * Wraps MapVirtualKeyEx() with MAPVK_VSC_TO_VK. */ uint8_t ComputeVirtualKeyCodeFromScanCode() const; diff --git a/widget/windows/LSPAnnotator.cpp b/widget/windows/LSPAnnotator.cpp deleted file mode 100644 index de4a40d2a..000000000 --- a/widget/windows/LSPAnnotator.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/** - * LSPs are evil little bits of code that are allowed to inject into our - * networking stack by Windows. Once they have wormed into our process - * they gnaw at our innards until we crash. Here we force the buggers - * into the light by recording them in our crash information. - * We do the enumeration on a thread because I'm concerned about startup perf - * on machines with several LSPs. - */ - -#if _WIN32_WINNT < 0x0600 -// Redefining _WIN32_WINNT for some Vista APIs that we call -#undef _WIN32_WINNT -#define _WIN32_WINNT 0x0600 -#endif -#include "nsICrashReporter.h" -#include "nsISupportsImpl.h" -#include "nsServiceManagerUtils.h" -#include "nsThreadUtils.h" -#include "nsQueryObject.h" -#include "nsWindowsHelpers.h" -#include <windows.h> -#include <rpc.h> -#include <ws2spi.h> - -namespace mozilla { -namespace crashreporter { - -class LSPAnnotationGatherer : public Runnable -{ - ~LSPAnnotationGatherer() {} - -public: - NS_DECL_THREADSAFE_ISUPPORTS - NS_DECL_NSIRUNNABLE - - void Annotate(); - nsCString mString; - nsCOMPtr<nsIThread> mThread; -}; - -NS_IMPL_ISUPPORTS(LSPAnnotationGatherer, nsIRunnable) - -void -LSPAnnotationGatherer::Annotate() -{ - nsCOMPtr<nsICrashReporter> cr = - do_GetService("@mozilla.org/toolkit/crash-reporter;1"); - bool enabled; - if (cr && NS_SUCCEEDED(cr->GetEnabled(&enabled)) && enabled) { - cr->AnnotateCrashReport(NS_LITERAL_CSTRING("Winsock_LSP"), mString); - } - mThread->AsyncShutdown(); -} - -NS_IMETHODIMP -LSPAnnotationGatherer::Run() -{ - PR_SetCurrentThreadName("LSP Annotator"); - - mThread = NS_GetCurrentThread(); - - DWORD size = 0; - int err; - // Get the size of the buffer we need - if (SOCKET_ERROR != WSCEnumProtocols(nullptr, nullptr, &size, &err) || - err != WSAENOBUFS) { - // Er, what? - NS_NOTREACHED("WSCEnumProtocols suceeded when it should have failed ..."); - return NS_ERROR_FAILURE; - } - - auto byteArray = MakeUnique<char[]>(size); - WSAPROTOCOL_INFOW* providers = - reinterpret_cast<WSAPROTOCOL_INFOW*>(byteArray.get()); - - int n = WSCEnumProtocols(nullptr, providers, &size, &err); - if (n == SOCKET_ERROR) { - // Lame. We provided the right size buffer; we'll just give up now. - NS_WARNING("Could not get LSP list"); - return NS_ERROR_FAILURE; - } - - nsCString str; - for (int i = 0; i < n; i++) { - AppendUTF16toUTF8(nsDependentString(providers[i].szProtocol), str); - str.AppendLiteral(" : "); - str.AppendInt(providers[i].iVersion); - str.AppendLiteral(" : "); - str.AppendInt(providers[i].iAddressFamily); - str.AppendLiteral(" : "); - str.AppendInt(providers[i].iSocketType); - str.AppendLiteral(" : "); - str.AppendInt(providers[i].iProtocol); - str.AppendLiteral(" : "); - str.AppendPrintf("0x%x", providers[i].dwServiceFlags1); - str.AppendLiteral(" : "); - str.AppendPrintf("0x%x", providers[i].dwProviderFlags); - str.AppendLiteral(" : "); - - wchar_t path[MAX_PATH]; - int pathLen = MAX_PATH; - if (!WSCGetProviderPath(&providers[i].ProviderId, path, &pathLen, &err)) { - AppendUTF16toUTF8(nsDependentString(path), str); - } - - str.AppendLiteral(" : "); - // If WSCGetProviderInfo is available, we should call it to obtain the - // category flags for this provider. When present, these flags inform - // Windows as to which order to chain the providers. - nsModuleHandle ws2_32(LoadLibraryW(L"ws2_32.dll")); - if (ws2_32) { - decltype(WSCGetProviderInfo)* pWSCGetProviderInfo = - reinterpret_cast<decltype(WSCGetProviderInfo)*>( - GetProcAddress(ws2_32, "WSCGetProviderInfo")); - if (pWSCGetProviderInfo) { - DWORD categoryInfo; - size_t categoryInfoSize = sizeof(categoryInfo); - if (!pWSCGetProviderInfo(&providers[i].ProviderId, - ProviderInfoLspCategories, - (PBYTE)&categoryInfo, &categoryInfoSize, 0, - &err)) { - str.AppendPrintf("0x%x", categoryInfo); - } - } - } - - str.AppendLiteral(" : "); - if (providers[i].ProtocolChain.ChainLen <= BASE_PROTOCOL) { - // If we're dealing with a catalog entry that identifies an individual - // base or layer provider, log its provider GUID. - RPC_CSTR provIdStr = nullptr; - if (UuidToStringA(&providers[i].ProviderId, &provIdStr) == RPC_S_OK) { - str.Append(reinterpret_cast<char*>(provIdStr)); - RpcStringFreeA(&provIdStr); - } - } - - if (i + 1 != n) { - str.AppendLiteral(" \n "); - } - } - - mString = str; - NS_DispatchToMainThread(NewRunnableMethod(this, &LSPAnnotationGatherer::Annotate)); - return NS_OK; -} - -void LSPAnnotate() -{ - nsCOMPtr<nsIThread> thread; - nsCOMPtr<nsIRunnable> runnable = - do_QueryObject(new LSPAnnotationGatherer()); - NS_NewThread(getter_AddRefs(thread), runnable); -} - -} // namespace crashreporter -} // namespace mozilla diff --git a/widget/windows/TSFTextStore.cpp b/widget/windows/TSFTextStore.cpp index fb0505aa3..7224126b8 100644 --- a/widget/windows/TSFTextStore.cpp +++ b/widget/windows/TSFTextStore.cpp @@ -5762,8 +5762,7 @@ TSFTextStore::Initialize() return; } - bool enableTsf = - IsVistaOrLater() && Preferences::GetBool(kPrefNameEnableTSF, false); + bool enableTsf = Preferences::GetBool(kPrefNameEnableTSF, false); MOZ_LOG(sTextStoreLog, LogLevel::Info, (" TSFTextStore::Initialize(), TSF is %s", enableTsf ? "enabled" : "disabled")); diff --git a/widget/windows/TaskbarPreview.cpp b/widget/windows/TaskbarPreview.cpp index c897af021..6c15df2e0 100644 --- a/widget/windows/TaskbarPreview.cpp +++ b/widget/windows/TaskbarPreview.cpp @@ -28,7 +28,9 @@ #include "mozilla/Telemetry.h" // Defined in dwmapi in a header that needs a higher numbered _WINNT #define +#ifndef DWM_SIT_DISPLAYFRAME #define DWM_SIT_DISPLAYFRAME 0x1 +#endif namespace mozilla { namespace widget { diff --git a/widget/windows/WinMouseScrollHandler.cpp b/widget/windows/WinMouseScrollHandler.cpp index 10937ba51..e157b1be2 100644 --- a/widget/windows/WinMouseScrollHandler.cpp +++ b/widget/windows/WinMouseScrollHandler.cpp @@ -992,10 +992,7 @@ MouseScrollHandler::SystemSettings::InitScrollChars() &mScrollChars, 0)) { MOZ_LOG(gMouseScrollLog, LogLevel::Info, ("MouseScroll::SystemSettings::InitScrollChars(): ::SystemParametersInfo(" - "SPI_GETWHEELSCROLLCHARS) failed, %s", - IsVistaOrLater() ? - "this is unexpected on Vista or later" : - "but on XP or earlier, this is not a problem")); + "SPI_GETWHEELSCROLLCHARS) failed, this is unexpected on Vista or later")); // XXX Should we use DefaultScrollChars()? mScrollChars = 1; } @@ -1081,7 +1078,7 @@ bool MouseScrollHandler::SystemSettings::IsOverridingSystemScrollSpeedAllowed() { return mScrollLines == DefaultScrollLines() && - (!IsVistaOrLater() || mScrollChars == DefaultScrollChars()); + mScrollChars == DefaultScrollChars(); } /****************************************************************************** diff --git a/widget/windows/WinTaskbar.cpp b/widget/windows/WinTaskbar.cpp index 698b7ec0e..530cfd5b9 100644 --- a/widget/windows/WinTaskbar.cpp +++ b/widget/windows/WinTaskbar.cpp @@ -34,8 +34,6 @@ #include <propkey.h> #include <shellapi.h> -const wchar_t kShellLibraryName[] = L"shell32.dll"; - static NS_DEFINE_CID(kJumpListBuilderCID, NS_WIN_JUMPLISTBUILDER_CID); namespace { @@ -77,30 +75,14 @@ SetWindowAppUserModelProp(mozIDOMWindow *aParent, if (!toplevelHWND) return NS_ERROR_INVALID_ARG; - typedef HRESULT (WINAPI * SHGetPropertyStoreForWindowPtr) - (HWND hwnd, REFIID riid, void** ppv); - SHGetPropertyStoreForWindowPtr funcGetProStore = nullptr; - - HMODULE hDLL = ::LoadLibraryW(kShellLibraryName); - funcGetProStore = (SHGetPropertyStoreForWindowPtr) - GetProcAddress(hDLL, "SHGetPropertyStoreForWindow"); - - if (!funcGetProStore) { - FreeLibrary(hDLL); - return NS_ERROR_NO_INTERFACE; - } - - IPropertyStore* pPropStore; - if (FAILED(funcGetProStore(toplevelHWND, - IID_PPV_ARGS(&pPropStore)))) { - FreeLibrary(hDLL); + RefPtr<IPropertyStore> pPropStore; + if (FAILED(SHGetPropertyStoreForWindow(toplevelHWND, IID_IPropertyStore, + getter_AddRefs(pPropStore)))) { return NS_ERROR_INVALID_ARG; } PROPVARIANT pv; if (FAILED(InitPropVariantFromString(aIdentifier.get(), &pv))) { - pPropStore->Release(); - FreeLibrary(hDLL); return NS_ERROR_UNEXPECTED; } @@ -111,8 +93,6 @@ SetWindowAppUserModelProp(mozIDOMWindow *aParent, } PropVariantClear(&pv); - pPropStore->Release(); - FreeLibrary(hDLL); return rv; } @@ -339,40 +319,18 @@ WinTaskbar::GetDefaultGroupId(nsAString & aDefaultGroupId) { // (static) Called from AppShell bool WinTaskbar::RegisterAppUserModelID() { - if (!IsWin7OrLater()) - return false; - - SetCurrentProcessExplicitAppUserModelIDPtr funcAppUserModelID = nullptr; - bool retVal = false; - nsAutoString uid; if (!GetAppUserModelID(uid)) return false; - HMODULE hDLL = ::LoadLibraryW(kShellLibraryName); - - funcAppUserModelID = (SetCurrentProcessExplicitAppUserModelIDPtr) - GetProcAddress(hDLL, "SetCurrentProcessExplicitAppUserModelID"); - - if (!funcAppUserModelID) { - ::FreeLibrary(hDLL); - return false; - } - - if (SUCCEEDED(funcAppUserModelID(uid.get()))) - retVal = true; - - if (hDLL) - ::FreeLibrary(hDLL); - - return retVal; + return SUCCEEDED(SetCurrentProcessExplicitAppUserModelID(uid.get())); } NS_IMETHODIMP WinTaskbar::GetAvailable(bool *aAvailable) { // ITaskbarList4::HrInit() may fail with shell extensions like blackbox // installed. Initialize early to return available=false in those cases. - *aAvailable = IsWin7OrLater() && Initialize(); + *aAvailable = Initialize(); return NS_OK; } diff --git a/widget/windows/WinUtils.cpp b/widget/windows/WinUtils.cpp index 149513b2f..0a57ad439 100644 --- a/widget/windows/WinUtils.cpp +++ b/widget/windows/WinUtils.cpp @@ -462,7 +462,7 @@ static NtTestAlertPtr sNtTestAlert = nullptr; void WinUtils::Initialize() { - if (!sDwmDll && IsVistaOrLater()) { + if (!sDwmDll) { sDwmDll = ::LoadLibraryW(kDwmLibraryName); if (sDwmDll) { @@ -601,7 +601,7 @@ WinUtils::SystemScaleFactor() return systemScale; } -#ifndef WM_DPICHANGED +#if WINVER < 0x603 typedef enum { MDT_EFFECTIVE_DPI = 0, MDT_ANGULAR_DPI = 1, @@ -628,16 +628,14 @@ GETPROCESSDPIAWARENESSPROC sGetProcessDpiAwareness; static bool SlowIsPerMonitorDPIAware() { - if (IsVistaOrLater()) { - // Intentionally leak the handle. - HMODULE shcore = - LoadLibraryEx(L"shcore", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32); - if (shcore) { - sGetDpiForMonitor = - (GETDPIFORMONITORPROC) GetProcAddress(shcore, "GetDpiForMonitor"); - sGetProcessDpiAwareness = - (GETPROCESSDPIAWARENESSPROC) GetProcAddress(shcore, "GetProcessDpiAwareness"); - } + // Intentionally leak the handle. + HMODULE shcore = + LoadLibraryEx(L"shcore", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32); + if (shcore) { + sGetDpiForMonitor = + (GETDPIFORMONITORPROC) GetProcAddress(shcore, "GetDpiForMonitor"); + sGetProcessDpiAwareness = + (GETPROCESSDPIAWARENESSPROC) GetProcAddress(shcore, "GetProcessDpiAwareness"); } PROCESS_DPI_AWARENESS dpiAwareness; return sGetDpiForMonitor && sGetProcessDpiAwareness && @@ -760,7 +758,7 @@ static DWORD GetWaitFlags() { DWORD result = MWMO_INPUTAVAILABLE; - if (IsVistaOrLater() && XRE_IsContentProcess()) { + if (XRE_IsContentProcess()) { result |= MWMO_ALERTABLE; } return result; @@ -1878,7 +1876,7 @@ WinUtils::IsTouchDeviceSupportPresent() uint32_t WinUtils::GetMaxTouchPoints() { - if (IsWin7OrLater() && IsTouchDeviceSupportPresent()) { + if (IsTouchDeviceSupportPresent()) { return GetSystemMetrics(SM_MAXIMUMTOUCHES); } return 0; @@ -1893,11 +1891,6 @@ typedef DWORD (WINAPI * GetFinalPathNameByHandlePtr)(HANDLE hFile, bool WinUtils::ResolveJunctionPointsAndSymLinks(std::wstring& aPath) { - // Users folder was introduced with Vista. - if (!IsVistaOrLater()) { - return true; - } - wchar_t path[MAX_PATH] = { 0 }; nsAutoHandle handle( @@ -2025,21 +2018,19 @@ WinUtils::GetAppInitDLLs(nsAString& aOutput) } nsAutoRegKey key(hkey); LONG status; - if (IsVistaOrLater()) { - const wchar_t kLoadAppInitDLLs[] = L"LoadAppInit_DLLs"; - DWORD loadAppInitDLLs = 0; - DWORD loadAppInitDLLsLen = sizeof(loadAppInitDLLs); - status = RegQueryValueExW(hkey, kLoadAppInitDLLs, nullptr, - nullptr, (LPBYTE)&loadAppInitDLLs, - &loadAppInitDLLsLen); - if (status != ERROR_SUCCESS) { - return false; - } - if (!loadAppInitDLLs) { - // If loadAppInitDLLs is zero then AppInit_DLLs is disabled. - // In this case we'll return true along with an empty output string. - return true; - } + const wchar_t kLoadAppInitDLLs[] = L"LoadAppInit_DLLs"; + DWORD loadAppInitDLLs = 0; + DWORD loadAppInitDLLsLen = sizeof(loadAppInitDLLs); + status = RegQueryValueExW(hkey, kLoadAppInitDLLs, nullptr, + nullptr, (LPBYTE)&loadAppInitDLLs, + &loadAppInitDLLsLen); + if (status != ERROR_SUCCESS) { + return false; + } + if (!loadAppInitDLLs) { + // If loadAppInitDLLs is zero then AppInit_DLLs is disabled. + // In this case we'll return true along with an empty output string. + return true; } DWORD numBytes = 0; const wchar_t kAppInitDLLs[] = L"AppInit_DLLs"; diff --git a/widget/windows/WindowsUIUtils.cpp b/widget/windows/WindowsUIUtils.cpp index 223511859..1c270b5ec 100644 --- a/widget/windows/WindowsUIUtils.cpp +++ b/widget/windows/WindowsUIUtils.cpp @@ -5,7 +5,8 @@ #include <windows.h> #include <winsdkver.h> -#include "mozwrlbase.h" +#include <wrl.h> + #include "nsServiceManagerUtils.h" #include "WindowsUIUtils.h" @@ -179,4 +180,3 @@ WindowsUIUtils::UpdateTabletModeState() return NS_OK; } - diff --git a/widget/windows/moz.build b/widget/windows/moz.build index d4f089eea..1e7fc4b02 100644 --- a/widget/windows/moz.build +++ b/widget/windows/moz.build @@ -79,11 +79,6 @@ SOURCES += [ 'WinMouseScrollHandler.cpp', ] -if CONFIG['MOZ_CRASHREPORTER']: - UNIFIED_SOURCES += [ - 'LSPAnnotator.cpp', - ] - if CONFIG['NS_PRINTING']: UNIFIED_SOURCES += [ 'nsDeviceContextSpecWin.cpp', diff --git a/widget/windows/mozwrlbase.h b/widget/windows/mozwrlbase.h deleted file mode 100644 index d82be8f04..000000000 --- a/widget/windows/mozwrlbase.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#pragma once - -/* - * Includes <wrl.h> and it's children. Defines imports needed by - * corewrappers.h in the case where windows.h has already been - * included w/WINVER < 0x600. Also ups WINVER/_WIN32_WINNT prior - * to including wrl.h. Mozilla's build currently has WINVER set to - * 0x502 for XP support. - */ - -#if _WIN32_WINNT < 0x600 - -#include <windows.h> - -VOID -WINAPI -ReleaseSRWLockExclusive( - _Inout_ PSRWLOCK SRWLock - ); - -VOID -WINAPI -ReleaseSRWLockShared( - _Inout_ PSRWLOCK SRWLock - ); - -BOOL -WINAPI -InitializeCriticalSectionEx( - _Out_ LPCRITICAL_SECTION lpCriticalSection, - _In_ DWORD dwSpinCount, - _In_ DWORD Flags - ); - -VOID -WINAPI -InitializeSRWLock( - _Out_ PSRWLOCK SRWLock - ); - -VOID -WINAPI -AcquireSRWLockExclusive( - _Inout_ PSRWLOCK SRWLock - ); - -BOOLEAN -WINAPI -TryAcquireSRWLockExclusive( - _Inout_ PSRWLOCK SRWLock - ); - -BOOLEAN -WINAPI -TryAcquireSRWLockShared( - _Inout_ PSRWLOCK SRWLock - ); - -VOID -WINAPI -AcquireSRWLockShared( - _Inout_ PSRWLOCK SRWLock - ); - -#undef WINVER -#undef _WIN32_WINNT -#define WINVER 0x600 -#define _WIN32_WINNT 0x600 - -#endif // _WIN32_WINNT < 0x600 - -#include <wrl.h> diff --git a/widget/windows/nsAppShell.cpp b/widget/windows/nsAppShell.cpp index c8820e7d1..c3e99b2d3 100644 --- a/widget/windows/nsAppShell.cpp +++ b/widget/windows/nsAppShell.cpp @@ -213,10 +213,6 @@ nsAppShell::~nsAppShell() nsresult nsAppShell::Init() { -#ifdef MOZ_CRASHREPORTER - LSPAnnotate(); -#endif - mLastNativeEventScheduled = TimeStamp::NowLoRes(); mozilla::ipc::windows::InitUIThread(); diff --git a/widget/windows/nsDataObj.cpp b/widget/windows/nsDataObj.cpp index fc45968ae..02ec3b2fe 100644 --- a/widget/windows/nsDataObj.cpp +++ b/widget/windows/nsDataObj.cpp @@ -1148,8 +1148,7 @@ nsDataObj :: GetFileContentsInternetShortcut ( FORMATETC& aFE, STGMEDIUM& aSTG ) const char *shortcutFormatStr; int totalLen; nsCString path; - if (!Preferences::GetBool(kShellIconPref, true) || - !IsVistaOrLater()) { + if (!Preferences::GetBool(kShellIconPref, true)) { shortcutFormatStr = "[InternetShortcut]\r\nURL=%s\r\n"; const int formatLen = strlen(shortcutFormatStr) - 2; // don't include %s totalLen = formatLen + asciiUrl.Length(); // don't include null character diff --git a/widget/windows/nsFilePicker.cpp b/widget/windows/nsFilePicker.cpp index 53857cf5e..4e942968a 100644 --- a/widget/windows/nsFilePicker.cpp +++ b/widget/windows/nsFilePicker.cpp @@ -28,7 +28,6 @@ #include "nsPIDOMWindow.h" #include "GeckoProfiler.h" -using mozilla::IsVistaOrLater; using mozilla::IsWin8OrLater; using mozilla::MakeUnique; using mozilla::mscom::EnsureMTA; @@ -219,191 +218,6 @@ STDMETHODIMP nsFilePicker::QueryInterface(REFIID refiid, void** ppvResult) return E_NOINTERFACE; } -/* - * XP picker callbacks - */ - -// Show - Display the file dialog -int CALLBACK -BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData) -{ - if (uMsg == BFFM_INITIALIZED) - { - char16_t * filePath = (char16_t *) lpData; - if (filePath) - ::SendMessageW(hwnd, BFFM_SETSELECTIONW, - TRUE /* true because lpData is a path string */, - lpData); - } - return 0; -} - -static void -EnsureWindowVisible(HWND hwnd) -{ - // Obtain the monitor which has the largest area of intersection - // with the window, or nullptr if there is no intersection. - HMONITOR monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONULL); - if (!monitor) { - // The window is not visible, we should reposition it to the same place as its parent - HWND parentHwnd = GetParent(hwnd); - RECT parentRect; - GetWindowRect(parentHwnd, &parentRect); - SetWindowPos(hwnd, nullptr, parentRect.left, parentRect.top, 0, 0, - SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER); - } -} - -// Callback hook which will ensure that the window is visible. Currently -// only in use on os <= XP. -UINT_PTR CALLBACK -nsFilePicker::FilePickerHook(HWND hwnd, - UINT msg, - WPARAM wParam, - LPARAM lParam) -{ - switch(msg) { - case WM_NOTIFY: - { - LPOFNOTIFYW lpofn = (LPOFNOTIFYW) lParam; - if (!lpofn || !lpofn->lpOFN) { - return 0; - } - - if (CDN_INITDONE == lpofn->hdr.code) { - // The Window will be automatically moved to the last position after - // CDN_INITDONE. We post a message to ensure the window will be visible - // so it will be done after the automatic last position window move. - PostMessage(hwnd, MOZ_WM_ENSUREVISIBLE, 0, 0); - } - } - break; - case MOZ_WM_ENSUREVISIBLE: - EnsureWindowVisible(GetParent(hwnd)); - break; - case WM_INITDIALOG: - { - OPENFILENAMEW* pofn = reinterpret_cast<OPENFILENAMEW*>(lParam); - SetProp(hwnd, kDialogPtrProp, (HANDLE)pofn->lCustData); - nsFilePicker* picker = reinterpret_cast<nsFilePicker*>(pofn->lCustData); - if (picker) { - picker->SetDialogHandle(hwnd); - SetTimer(hwnd, kDialogTimerID, kDialogTimerTimeout, nullptr); - } - } - break; - case WM_TIMER: - { - // Check to see if our parent has been torn down, if so, we close too. - if (wParam == kDialogTimerID) { - nsFilePicker* picker = - reinterpret_cast<nsFilePicker*>(GetProp(hwnd, kDialogPtrProp)); - if (picker && picker->ClosePickerIfNeeded(true)) { - KillTimer(hwnd, kDialogTimerID); - } - } - } - break; - } - return 0; -} - - -// Callback hook which will dynamically allocate a buffer large enough -// for the file picker dialog. Currently only in use on os <= XP. -UINT_PTR CALLBACK -nsFilePicker::MultiFilePickerHook(HWND hwnd, - UINT msg, - WPARAM wParam, - LPARAM lParam) -{ - switch (msg) { - case WM_INITDIALOG: - { - // Finds the child drop down of a File Picker dialog and sets the - // maximum amount of text it can hold when typed in manually. - // A wParam of 0 mean 0x7FFFFFFE characters. - HWND comboBox = FindWindowEx(GetParent(hwnd), nullptr, - L"ComboBoxEx32", nullptr ); - if(comboBox) - SendMessage(comboBox, CB_LIMITTEXT, 0, 0); - // Store our nsFilePicker ptr for future use - OPENFILENAMEW* pofn = reinterpret_cast<OPENFILENAMEW*>(lParam); - SetProp(hwnd, kDialogPtrProp, (HANDLE)pofn->lCustData); - nsFilePicker* picker = - reinterpret_cast<nsFilePicker*>(pofn->lCustData); - if (picker) { - picker->SetDialogHandle(hwnd); - SetTimer(hwnd, kDialogTimerID, kDialogTimerTimeout, nullptr); - } - } - break; - case WM_NOTIFY: - { - LPOFNOTIFYW lpofn = (LPOFNOTIFYW) lParam; - if (!lpofn || !lpofn->lpOFN) { - return 0; - } - // CDN_SELCHANGE is sent when the selection in the list box of the file - // selection dialog changes - if (lpofn->hdr.code == CDN_SELCHANGE) { - HWND parentHWND = GetParent(hwnd); - - // Get the required size for the selected files buffer - UINT newBufLength = 0; - int requiredBufLength = CommDlg_OpenSave_GetSpecW(parentHWND, - nullptr, 0); - if(requiredBufLength >= 0) - newBufLength += requiredBufLength; - else - newBufLength += MAX_PATH; - - // If the user selects multiple files, the buffer contains the - // current directory followed by the file names of the selected - // files. So make room for the directory path. If the user - // selects a single file, it is no harm to add extra space. - requiredBufLength = CommDlg_OpenSave_GetFolderPathW(parentHWND, - nullptr, 0); - if(requiredBufLength >= 0) - newBufLength += requiredBufLength; - else - newBufLength += MAX_PATH; - - // Check if lpstrFile and nMaxFile are large enough - if (newBufLength > lpofn->lpOFN->nMaxFile) { - if (lpofn->lpOFN->lpstrFile) - delete[] lpofn->lpOFN->lpstrFile; - - // We allocate FILE_BUFFER_SIZE more bytes than is needed so that - // if the user selects a file and holds down shift and down to - // select additional items, we will not continuously reallocate - newBufLength += FILE_BUFFER_SIZE; - - wchar_t* filesBuffer = new wchar_t[newBufLength]; - ZeroMemory(filesBuffer, newBufLength * sizeof(wchar_t)); - - lpofn->lpOFN->lpstrFile = filesBuffer; - lpofn->lpOFN->nMaxFile = newBufLength; - } - } - } - break; - case WM_TIMER: - { - // Check to see if our parent has been torn down, if so, we close too. - if (wParam == kDialogTimerID) { - nsFilePicker* picker = - reinterpret_cast<nsFilePicker*>(GetProp(hwnd, kDialogPtrProp)); - if (picker && picker->ClosePickerIfNeeded(true)) { - KillTimer(hwnd, kDialogTimerID); - } - } - } - break; - } - - return FilePickerHook(hwnd, msg, wParam, lParam); -} /* * Vista+ callbacks @@ -476,25 +290,18 @@ nsFilePicker::OnOverwrite(IFileDialog *pfd, */ bool -nsFilePicker::ClosePickerIfNeeded(bool aIsXPDialog) +nsFilePicker::ClosePickerIfNeeded() { if (!mParentWidget || !mDlgWnd) return false; nsWindow *win = static_cast<nsWindow *>(mParentWidget.get()); - // Note, the xp callbacks hand us an inner window, so we have to step up - // one to get the actual dialog. - HWND dlgWnd; - if (aIsXPDialog) - dlgWnd = GetParent(mDlgWnd); - else - dlgWnd = mDlgWnd; - if (IsWindow(dlgWnd) && IsWindowVisible(dlgWnd) && win->DestroyCalled()) { + if (IsWindow(mDlgWnd) && IsWindowVisible(mDlgWnd) && win->DestroyCalled()) { wchar_t className[64]; // Make sure we have the right window - if (GetClassNameW(dlgWnd, className, mozilla::ArrayLength(className)) && + if (GetClassNameW(mDlgWnd, className, mozilla::ArrayLength(className)) && !wcscmp(className, L"#32770") && - DestroyWindow(dlgWnd)) { + DestroyWindow(mDlgWnd)) { mDlgWnd = nullptr; return true; } @@ -506,7 +313,7 @@ void nsFilePicker::PickerCallbackTimerFunc(nsITimer *aTimer, void *aCtx) { nsFilePicker* picker = (nsFilePicker*)aCtx; - if (picker->ClosePickerIfNeeded(false)) { + if (picker->ClosePickerIfNeeded()) { aTimer->Cancel(); } } @@ -523,62 +330,15 @@ nsFilePicker::SetDialogHandle(HWND aWnd) * Folder picker invocation */ -// Open the older XP style folder picker dialog. We end up in this call -// on XP systems or when platform is built without the longhorn SDK. -bool -nsFilePicker::ShowXPFolderPicker(const nsString& aInitialDir) -{ - bool result = false; - - auto dirBuffer = MakeUnique<wchar_t[]>(FILE_BUFFER_SIZE); - wcsncpy(dirBuffer.get(), aInitialDir.get(), FILE_BUFFER_SIZE); - dirBuffer[FILE_BUFFER_SIZE-1] = '\0'; - - AutoDestroyTmpWindow adtw((HWND)(mParentWidget.get() ? - mParentWidget->GetNativeData(NS_NATIVE_TMP_WINDOW) : nullptr)); - - BROWSEINFOW browserInfo = {0}; - browserInfo.pidlRoot = nullptr; - browserInfo.pszDisplayName = dirBuffer.get(); - browserInfo.lpszTitle = mTitle.get(); - browserInfo.ulFlags = BIF_USENEWUI | BIF_RETURNONLYFSDIRS; - browserInfo.hwndOwner = adtw.get(); - browserInfo.iImage = 0; - browserInfo.lParam = reinterpret_cast<LPARAM>(this); - - if (!aInitialDir.IsEmpty()) { - // the dialog is modal so that |initialDir.get()| will be valid in - // BrowserCallbackProc. Thus, we don't need to clone it. - browserInfo.lParam = (LPARAM) aInitialDir.get(); - browserInfo.lpfn = &BrowseCallbackProc; - } else { - browserInfo.lParam = 0; - browserInfo.lpfn = nullptr; - } - - LPITEMIDLIST list = ::SHBrowseForFolderW(&browserInfo); - if (list) { - result = ::SHGetPathFromIDListW(list, dirBuffer.get()); - if (result) - mUnicodeFile.Assign(static_cast<const wchar_t*>(dirBuffer.get())); - // free PIDL - CoTaskMemFree(list); - } - - return result; -} - /* - * Show a folder picker post Windows XP - * + * Show a folder picker. + * * @param aInitialDir The initial directory, the last used directory will be * used if left blank. - * @param aWasInitError Out parameter will hold true if there was an error - * before the folder picker is shown. * @return true if a file was selected successfully. */ bool -nsFilePicker::ShowFolderPicker(const nsString& aInitialDir, bool &aWasInitError) +nsFilePicker::ShowFolderPicker(const nsString& aInitialDir) { if (!IsWin8OrLater()) { // Some Windows 7 users are experiencing a race condition when some dlls @@ -593,10 +353,8 @@ nsFilePicker::ShowFolderPicker(const nsString& aInitialDir, bool &aWasInitError) if (FAILED(CoCreateInstance(CLSID_FileOpenDialog, nullptr, CLSCTX_INPROC, IID_IFileOpenDialog, getter_AddRefs(dialog)))) { - aWasInitError = true; return false; } - aWasInitError = false; // hook up event callbacks dialog->Advise(this, &mFDECookie); @@ -658,233 +416,15 @@ nsFilePicker::ShowFolderPicker(const nsString& aInitialDir, bool &aWasInitError) * File open and save picker invocation */ -/* static */ bool -nsFilePicker::GetFileNameWrapper(OPENFILENAMEW* ofn, PickerType aType) -{ - MOZ_SEH_TRY { - if (aType == PICKER_TYPE_OPEN) - return ::GetOpenFileNameW(ofn); - else if (aType == PICKER_TYPE_SAVE) - return ::GetSaveFileNameW(ofn); - } MOZ_SEH_EXCEPT(true) { - NS_ERROR("nsFilePicker GetFileName win32 call generated an exception! This is bad!"); - } - return false; -} - -bool -nsFilePicker::FilePickerWrapper(OPENFILENAMEW* ofn, PickerType aType) -{ - if (!ofn) - return false; - AutoWidgetPickerState awps(mParentWidget); - return GetFileNameWrapper(ofn, aType); -} - -bool -nsFilePicker::ShowXPFilePicker(const nsString& aInitialDir) -{ - OPENFILENAMEW ofn = {0}; - ofn.lStructSize = sizeof(ofn); - nsString filterBuffer = mFilterList; - - auto fileBuffer = MakeUnique<wchar_t[]>(FILE_BUFFER_SIZE); - wcsncpy(fileBuffer.get(), mDefaultFilePath.get(), FILE_BUFFER_SIZE); - fileBuffer[FILE_BUFFER_SIZE-1] = '\0'; // null terminate in case copy truncated - - if (!aInitialDir.IsEmpty()) { - ofn.lpstrInitialDir = aInitialDir.get(); - } - - AutoDestroyTmpWindow adtw((HWND) (mParentWidget.get() ? - mParentWidget->GetNativeData(NS_NATIVE_TMP_WINDOW) : nullptr)); - - ofn.lpstrTitle = (LPCWSTR)mTitle.get(); - ofn.lpstrFilter = (LPCWSTR)filterBuffer.get(); - ofn.nFilterIndex = mSelectedType; - ofn.lpstrFile = fileBuffer.get(); - ofn.nMaxFile = FILE_BUFFER_SIZE; - ofn.hwndOwner = adtw.get(); - ofn.lCustData = reinterpret_cast<LPARAM>(this); - ofn.Flags = OFN_SHAREAWARE | OFN_LONGNAMES | OFN_OVERWRITEPROMPT | - OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_ENABLESIZING | - OFN_EXPLORER; - - // Windows Vista and up won't allow you to use the new looking dialogs with - // a hook procedure. The hook procedure fixes a problem on XP dialogs for - // file picker visibility. Vista and up automatically ensures the file - // picker is always visible. - if (!IsVistaOrLater()) { - ofn.lpfnHook = FilePickerHook; - ofn.Flags |= OFN_ENABLEHOOK; - } - - // Handle add to recent docs settings - if (IsPrivacyModeEnabled() || !mAddToRecentDocs) { - ofn.Flags |= OFN_DONTADDTORECENT; - } - - NS_NAMED_LITERAL_STRING(htmExt, "html"); - - if (!mDefaultExtension.IsEmpty()) { - ofn.lpstrDefExt = mDefaultExtension.get(); - } else if (IsDefaultPathHtml()) { - // Get file extension from suggested filename to detect if we are - // saving an html file. - // This is supposed to append ".htm" if user doesn't supply an - // extension but the behavior is sort of weird: - // - Often appends ".html" even if you have an extension - // - It obeys your extension if you put quotes around name - ofn.lpstrDefExt = htmExt.get(); - } - - // When possible, instead of using OFN_NOCHANGEDIR to ensure the current - // working directory will not change from this call, we will retrieve the - // current working directory before the call and restore it after the - // call. This flag causes problems on Windows XP for paths that are - // selected like C:test.txt where the user is currently at C:\somepath - // In which case expected result should be C:\somepath\test.txt - AutoRestoreWorkingPath restoreWorkingPath; - // If we can't get the current working directory, the best case is to - // use the OFN_NOCHANGEDIR flag - if (!restoreWorkingPath.HasWorkingPath()) { - ofn.Flags |= OFN_NOCHANGEDIR; - } - - bool result = false; - - switch(mMode) { - case modeOpen: - // FILE MUST EXIST! - ofn.Flags |= OFN_FILEMUSTEXIST; - result = FilePickerWrapper(&ofn, PICKER_TYPE_OPEN); - break; - - case modeOpenMultiple: - ofn.Flags |= OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT; - - // The hook set here ensures that the buffer returned will always be - // large enough to hold all selected files. The hook may modify the - // value of ofn.lpstrFile and deallocate the old buffer that it pointed - // to (fileBuffer). The hook assumes that the passed in value is heap - // allocated and that the returned value should be freed by the caller. - // If the hook changes the buffer, it will deallocate the old buffer. - // This fix would be nice to have in Vista and up, but it would force - // the file picker to use the old style dialogs because hooks are not - // allowed in the new file picker UI. We need to eventually move to - // the new Common File Dialogs for Vista and up. - if (!IsVistaOrLater()) { - ofn.lpfnHook = MultiFilePickerHook; - fileBuffer.release(); - result = FilePickerWrapper(&ofn, PICKER_TYPE_OPEN); - fileBuffer.reset(ofn.lpstrFile); - } else { - result = FilePickerWrapper(&ofn, PICKER_TYPE_OPEN); - } - break; - - case modeSave: - { - ofn.Flags |= OFN_NOREADONLYRETURN; - - // Don't follow shortcuts when saving a shortcut, this can be used - // to trick users (bug 271732) - if (IsDefaultPathLink()) - ofn.Flags |= OFN_NODEREFERENCELINKS; - - result = FilePickerWrapper(&ofn, PICKER_TYPE_SAVE); - if (!result) { - // Error, find out what kind. - if (GetLastError() == ERROR_INVALID_PARAMETER || - CommDlgExtendedError() == FNERR_INVALIDFILENAME) { - // Probably the default file name is too long or contains illegal - // characters. Try again, without a starting file name. - ofn.lpstrFile[0] = L'\0'; - result = FilePickerWrapper(&ofn, PICKER_TYPE_SAVE); - } - } - } - break; - - default: - NS_NOTREACHED("unsupported file picker mode"); - return false; - } - - if (!result) - return false; - - // Remember what filter type the user selected - mSelectedType = (int16_t)ofn.nFilterIndex; - - // Single file selection, we're done - if (mMode != modeOpenMultiple) { - GetQualifiedPath(fileBuffer.get(), mUnicodeFile); - return true; - } - - // Set user-selected location of file or directory. From msdn's "Open and - // Save As Dialog Boxes" section: - // If you specify OFN_EXPLORER, the directory and file name strings are '\0' - // separated, with an extra '\0' character after the last file name. This - // format enables the Explorer-style dialog boxes to return long file names - // that include spaces. - wchar_t *current = fileBuffer.get(); - - nsAutoString dirName(current); - // Sometimes dirName contains a trailing slash and sometimes it doesn't: - if (current[dirName.Length() - 1] != '\\') - dirName.Append((char16_t)'\\'); - - while (current && *current && *(current + wcslen(current) + 1)) { - current = current + wcslen(current) + 1; - - nsCOMPtr<nsIFile> file = do_CreateInstance("@mozilla.org/file/local;1"); - NS_ENSURE_TRUE(file, false); - - // Only prepend the directory if the path specified is a relative path - nsAutoString path; - if (PathIsRelativeW(current)) { - path = dirName + nsDependentString(current); - } else { - path = current; - } - - nsAutoString canonicalizedPath; - GetQualifiedPath(path.get(), canonicalizedPath); - if (NS_FAILED(file->InitWithPath(canonicalizedPath)) || - !mFiles.AppendObject(file)) - return false; - } - - // Handle the case where the user selected just one file. From msdn: If you - // specify OFN_ALLOWMULTISELECT and the user selects only one file the - // lpstrFile string does not have a separator between the path and file name. - if (current && *current && (current == fileBuffer.get())) { - nsCOMPtr<nsIFile> file = do_CreateInstance("@mozilla.org/file/local;1"); - NS_ENSURE_TRUE(file, false); - - nsAutoString canonicalizedPath; - GetQualifiedPath(current, canonicalizedPath); - if (NS_FAILED(file->InitWithPath(canonicalizedPath)) || - !mFiles.AppendObject(file)) - return false; - } - - return true; -} - /* - * Show a file picker post Windows XP - * + * Show a file picker. + * * @param aInitialDir The initial directory, the last used directory will be * used if left blank. - * @param aWasInitError Out parameter will hold true if there was an error - * before the file picker is shown. * @return true if a file was selected successfully. */ bool -nsFilePicker::ShowFilePicker(const nsString& aInitialDir, bool &aWasInitError) +nsFilePicker::ShowFilePicker(const nsString& aInitialDir) { PROFILER_LABEL_FUNC(js::ProfileEntry::Category::OTHER); @@ -902,18 +442,15 @@ nsFilePicker::ShowFilePicker(const nsString& aInitialDir, bool &aWasInitError) if (FAILED(CoCreateInstance(CLSID_FileOpenDialog, nullptr, CLSCTX_INPROC, IID_IFileOpenDialog, getter_AddRefs(dialog)))) { - aWasInitError = true; return false; } } else { if (FAILED(CoCreateInstance(CLSID_FileSaveDialog, nullptr, CLSCTX_INPROC, IID_IFileSaveDialog, getter_AddRefs(dialog)))) { - aWasInitError = true; return false; } } - aWasInitError = false; // hook up event callbacks dialog->Advise(this, &mFDECookie); @@ -1080,22 +617,11 @@ nsFilePicker::ShowW(int16_t *aReturnVal) // with our context set temporarily to system-dpi-aware WinUtils::AutoSystemDpiAware dpiAwareness; - // Launch the XP file/folder picker on XP and as a fallback on Vista+. - // The CoCreateInstance call to CLSID_FileOpenDialog fails with "(0x80040111) - // ClassFactory cannot supply requested class" when the checkbox for - // Disable Visual Themes is on in the compatability tab within the shortcut - // properties. - bool result = false, wasInitError = true; + bool result = false; if (mMode == modeGetFolder) { - if (IsVistaOrLater()) - result = ShowFolderPicker(initialDir, wasInitError); - if (!result && wasInitError) - result = ShowXPFolderPicker(initialDir); + result = ShowFolderPicker(initialDir); } else { - if (IsVistaOrLater()) - result = ShowFilePicker(initialDir, wasInitError); - if (!result && wasInitError) - result = ShowXPFilePicker(initialDir); + result = ShowFilePicker(initialDir); } // exit, and return returnCancel in aReturnVal @@ -1247,48 +773,10 @@ nsFilePicker::InitNative(nsIWidget *aParent, mTitle.Assign(aTitle); } -void -nsFilePicker::GetQualifiedPath(const wchar_t *aInPath, nsString &aOutPath) -{ - // Prefer a qualified path over a non qualified path. - // Things like c:file.txt would be accepted in Win XP but would later - // fail to open from the download manager. - wchar_t qualifiedFileBuffer[MAX_PATH]; - if (PathSearchAndQualifyW(aInPath, qualifiedFileBuffer, MAX_PATH)) { - aOutPath.Assign(qualifiedFileBuffer); - } else { - aOutPath.Assign(aInPath); - } -} - -void -nsFilePicker::AppendXPFilter(const nsAString& aTitle, const nsAString& aFilter) -{ - mFilterList.Append(aTitle); - mFilterList.Append(char16_t('\0')); - - if (aFilter.EqualsLiteral("..apps")) - mFilterList.AppendLiteral("*.exe;*.com"); - else - { - nsAutoString filter(aFilter); - filter.StripWhitespace(); - if (filter.EqualsLiteral("*")) - filter.AppendLiteral(".*"); - mFilterList.Append(filter); - } - - mFilterList.Append(char16_t('\0')); -} - NS_IMETHODIMP nsFilePicker::AppendFilter(const nsAString& aTitle, const nsAString& aFilter) { - if (IsVistaOrLater()) { - mComFilterList.Append(aTitle, aFilter); - } else { - AppendXPFilter(aTitle, aFilter); - } + mComFilterList.Append(aTitle, aFilter); return NS_OK; } diff --git a/widget/windows/nsFilePicker.h b/widget/windows/nsFilePicker.h index 90d8c15bc..740f07a7d 100644 --- a/widget/windows/nsFilePicker.h +++ b/widget/windows/nsFilePicker.h @@ -9,17 +9,6 @@ #include <windows.h> -// For Vista IFileDialog interfaces which aren't exposed -// unless _WIN32_WINNT >= _WIN32_WINNT_LONGHORN. -#if _WIN32_WINNT < _WIN32_WINNT_LONGHORN -#define _WIN32_WINNT_bak _WIN32_WINNT -#undef _WIN32_WINNT -#define _WIN32_WINNT _WIN32_WINNT_LONGHORN -#define _WIN32_IE_bak _WIN32_IE -#undef _WIN32_IE -#define _WIN32_IE _WIN32_IE_IE70 -#endif - #include "nsIFile.h" #include "nsITimer.h" #include "nsISimpleEnumerator.h" @@ -87,32 +76,19 @@ public: HRESULT STDMETHODCALLTYPE OnOverwrite(IFileDialog *pfd, IShellItem *psi, FDE_OVERWRITE_RESPONSE *pResponse); protected: - enum PickerType { - PICKER_TYPE_OPEN, - PICKER_TYPE_SAVE, - }; - /* method from nsBaseFilePicker */ virtual void InitNative(nsIWidget *aParent, const nsAString& aTitle); - static void GetQualifiedPath(const wchar_t *aInPath, nsString &aOutPath); void GetFilterListArray(nsString& aFilterList); - static bool GetFileNameWrapper(OPENFILENAMEW* ofn, PickerType aType); - bool FilePickerWrapper(OPENFILENAMEW* ofn, PickerType aType); - bool ShowXPFolderPicker(const nsString& aInitialDir); - bool ShowXPFilePicker(const nsString& aInitialDir); - bool ShowFolderPicker(const nsString& aInitialDir, bool &aWasInitError); - bool ShowFilePicker(const nsString& aInitialDir, bool &aWasInitError); - void AppendXPFilter(const nsAString& aTitle, const nsAString& aFilter); + bool ShowFolderPicker(const nsString& aInitialDir); + bool ShowFilePicker(const nsString& aInitialDir); void RememberLastUsedDirectory(); bool IsPrivacyModeEnabled(); bool IsDefaultPathLink(); bool IsDefaultPathHtml(); void SetDialogHandle(HWND aWnd); - bool ClosePickerIfNeeded(bool aIsXPDialog); + bool ClosePickerIfNeeded(); static void PickerCallbackTimerFunc(nsITimer *aTimer, void *aPicker); - static UINT_PTR CALLBACK MultiFilePickerHook(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); - static UINT_PTR CALLBACK FilePickerHook(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); nsCOMPtr<nsILoadContext> mLoadContext; nsCOMPtr<nsIWidget> mParentWidget; @@ -154,11 +130,4 @@ protected: DWORD mFDECookie; }; -#if defined(_WIN32_WINNT_bak) -#undef _WIN32_WINNT -#define _WIN32_WINNT _WIN32_WINNT_bak -#undef _WIN32_IE -#define _WIN32_IE _WIN32_IE_bak -#endif - #endif // nsFilePicker_h__ diff --git a/widget/windows/nsLookAndFeel.cpp b/widget/windows/nsLookAndFeel.cpp index e649802b1..06eee3771 100644 --- a/widget/windows/nsLookAndFeel.cpp +++ b/widget/windows/nsLookAndFeel.cpp @@ -32,12 +32,8 @@ nsLookAndFeel::GetOperatingSystemVersion() version = eOperatingSystemVersion_Windows10; } else if (IsWin8OrLater()) { version = eOperatingSystemVersion_Windows8; - } else if (IsWin7OrLater()) { - version = eOperatingSystemVersion_Windows7; - } else if (IsVistaOrLater()) { - version = eOperatingSystemVersion_WindowsVista; } else { - version = eOperatingSystemVersion_WindowsXP; + version = eOperatingSystemVersion_Windows7; } return version; @@ -183,8 +179,7 @@ nsLookAndFeel::NativeGetColor(ColorID aID, nscolor &aColor) idx = COLOR_HIGHLIGHT; break; case eColorID__moz_menubarhovertext: - if (!IsVistaOrLater() || !IsAppThemed()) - { + if (!IsAppThemed()) { idx = nsUXThemeData::sFlatMenus ? COLOR_HIGHLIGHTTEXT : COLOR_MENUTEXT; @@ -192,8 +187,7 @@ nsLookAndFeel::NativeGetColor(ColorID aID, nscolor &aColor) } // Fall through case eColorID__moz_menuhovertext: - if (IsVistaOrLater() && IsAppThemed()) - { + if (IsAppThemed()) { res = ::GetColorFromTheme(eUXMenu, MENU_POPUPITEM, MPI_HOT, TMT_TEXTCOLOR, aColor); if (NS_SUCCEEDED(res)) @@ -285,7 +279,7 @@ nsLookAndFeel::NativeGetColor(ColorID aID, nscolor &aColor) aColor = NS_RGB(0, 0, 0); return NS_OK; case eColorID__moz_win_mediatext: - if (IsVistaOrLater() && IsAppThemed()) { + if (IsAppThemed()) { res = ::GetColorFromTheme(eUXMediaToolbar, TP_BUTTON, TS_NORMAL, TMT_TEXTCOLOR, aColor); if (NS_SUCCEEDED(res)) @@ -295,8 +289,7 @@ nsLookAndFeel::NativeGetColor(ColorID aID, nscolor &aColor) idx = COLOR_WINDOWTEXT; break; case eColorID__moz_win_communicationstext: - if (IsVistaOrLater() && IsAppThemed()) - { + if (IsAppThemed()) { res = ::GetColorFromTheme(eUXCommunicationsToolbar, TP_BUTTON, TS_NORMAL, TMT_TEXTCOLOR, aColor); if (NS_SUCCEEDED(res)) diff --git a/widget/windows/nsLookAndFeel.h b/widget/windows/nsLookAndFeel.h index 6200541f5..a77808322 100644 --- a/widget/windows/nsLookAndFeel.h +++ b/widget/windows/nsLookAndFeel.h @@ -5,6 +5,7 @@ #ifndef __nsLookAndFeel #define __nsLookAndFeel + #include "nsXPLookAndFeel.h" #include "nsIWindowsRegKey.h" @@ -28,18 +29,6 @@ #ifndef SM_SYSTEMDOCKED #define SM_CONVERTIBLESLATEMODE 0x00002003 #define SM_SYSTEMDOCKED 0x00002004 -typedef enum _AR_STATE -{ - AR_ENABLED = 0x0, - AR_DISABLED = 0x1, - AR_SUPPRESSED = 0x2, - AR_REMOTESESSION = 0x4, - AR_MULTIMON = 0x8, - AR_NOSENSOR = 0x10, - AR_NOT_SUPPORTED = 0x20, - AR_DOCKED = 0x40, - AR_LAPTOP = 0x80 -} AR_STATE, *PAR_STATE; #endif class nsLookAndFeel: public nsXPLookAndFeel { diff --git a/widget/windows/nsNativeThemeWin.cpp b/widget/windows/nsNativeThemeWin.cpp index 4ff6b0af9..8950dcf90 100644 --- a/widget/windows/nsNativeThemeWin.cpp +++ b/widget/windows/nsNativeThemeWin.cpp @@ -39,7 +39,6 @@ #include "nsUXThemeConstants.h" #include <algorithm> -using mozilla::IsVistaOrLater; using namespace mozilla; using namespace mozilla::widget; @@ -301,10 +300,6 @@ DrawThemeBGRTLAware(HANDLE aTheme, HDC aHdc, int aPart, int aState, * aero basic max 0 2 1 2 * aero basic close 1 2 1 2 * - * xp theme min 0 2 0 2 - * xp theme max 0 2 1 2 - * xp theme close 1 2 2 2 - * * 'cold' button padding - generic button padding, should * be handled in css. * left top right bottom @@ -315,16 +310,11 @@ DrawThemeBGRTLAware(HANDLE aTheme, HDC aHdc, int aPart, int aState, * aero basic min 0 0 1 0 * aero basic max 1 0 0 0 * aero basic close 0 0 0 0 - * - * xp theme min 0 0 1 0 - * xp theme max 1 0 0 0 - * xp theme close 0 0 0 0 */ enum CaptionDesktopTheme { CAPTION_CLASSIC = 0, CAPTION_BASIC, - CAPTION_XPTHEME, }; enum CaptionButton { @@ -358,8 +348,6 @@ AddPaddingRect(LayoutDeviceIntSize* aSize, CaptionButton button) { RECT offset; if (!IsAppThemed()) offset = buttonData[CAPTION_CLASSIC].hotPadding[button]; - else if (!IsVistaOrLater()) - offset = buttonData[CAPTION_XPTHEME].hotPadding[button]; else offset = buttonData[CAPTION_BASIC].hotPadding[button]; aSize->width += offset.left + offset.right; @@ -373,8 +361,6 @@ OffsetBackgroundRect(RECT& rect, CaptionButton button) { RECT offset; if (!IsAppThemed()) offset = buttonData[CAPTION_CLASSIC].hotPadding[button]; - else if (!IsVistaOrLater()) - offset = buttonData[CAPTION_XPTHEME].hotPadding[button]; else offset = buttonData[CAPTION_BASIC].hotPadding[button]; rect.left += offset.left; @@ -419,9 +405,7 @@ OffsetBackgroundRect(RECT& rect, CaptionButton button) { static const double kProgressDeterminateTimeSpan = 3.0; static const double kProgressIndeterminateTimeSpan = 5.0; // The width of the overlay used to animate the horizontal progress bar (Vista and later). -static const int32_t kProgressHorizontalVistaOverlaySize = 120; -// The width of the overlay used for the horizontal indeterminate progress bars on XP. -static const int32_t kProgressHorizontalXPOverlaySize = 55; +static const int32_t kProgressHorizontalOverlaySize = 120; // The height of the overlay used to animate the vertical progress bar (Vista and later). static const int32_t kProgressVerticalOverlaySize = 45; // The height of the overlay used for the vertical indeterminate progress bar (Vista and later). @@ -435,18 +419,8 @@ static const int32_t kProgressClassicOverlaySize = 40; */ static int32_t GetProgressOverlayStyle(bool aIsVertical) -{ - if (aIsVertical) { - if (IsVistaOrLater()) { - return PP_MOVEOVERLAYVERT; - } - return PP_CHUNKVERT; - } else { - if (IsVistaOrLater()) { - return PP_MOVEOVERLAY; - } - return PP_CHUNK; - } +{ + return aIsVertical ? PP_MOVEOVERLAYVERT : PP_MOVEOVERLAY; } /* @@ -457,14 +431,11 @@ GetProgressOverlayStyle(bool aIsVertical) static int32_t GetProgressOverlaySize(bool aIsVertical, bool aIsIndeterminate) { - if (IsVistaOrLater()) { - if (aIsVertical) { - return aIsIndeterminate ? kProgressVerticalIndeterminateOverlaySize - : kProgressVerticalOverlaySize; - } - return kProgressHorizontalVistaOverlaySize; + if (aIsVertical) { + return aIsIndeterminate ? kProgressVerticalIndeterminateOverlaySize + : kProgressVerticalOverlaySize; } - return kProgressHorizontalXPOverlaySize; + return kProgressHorizontalOverlaySize; } /* @@ -554,87 +525,6 @@ nsNativeThemeWin::CalculateProgressOverlayRect(nsIFrame* aFrame, } /* - * DrawChunkProgressMeter - renders an xp style chunked progress meter. Called - * by DrawProgressMeter. - * - * @param aTheme progress theme handle - * @param aHdc hdc returned by gfxWindowsNativeDrawing - * @param aPart the PP_X progress part - * @param aState the theme state - * @param aFrame the elements frame - * @param aWidgetRect bounding rect for the widget - * @param aClipRect dirty rect that needs drawing. - * @param aAppUnits app units per device pixel - * @param aIsIndeterm is an indeterminate progress? - * @param aIsVertical render a vertical progress? - * @param aIsRtl direction is rtl - */ -static void -DrawChunkProgressMeter(HTHEME aTheme, HDC aHdc, int aPart, - int aState, nsIFrame* aFrame, RECT* aWidgetRect, - RECT* aClipRect, gfxFloat aAppUnits, bool aIsIndeterm, - bool aIsVertical, bool aIsRtl) -{ - NS_ASSERTION(aTheme, "Bad theme."); - NS_ASSERTION(aHdc, "Bad hdc."); - NS_ASSERTION(aWidgetRect, "Bad rect."); - NS_ASSERTION(aClipRect, "Bad clip rect."); - NS_ASSERTION(aFrame, "Bad frame."); - - // For horizontal meters, the theme lib paints the right graphic but doesn't - // paint the chunks, so we do that manually. For vertical meters, the theme - // library draws everything correctly. - if (aIsVertical) { - DrawThemeBackground(aTheme, aHdc, aPart, aState, aWidgetRect, aClipRect); - return; - } - - // query for the proper chunk metrics - int chunkSize, spaceSize; - if (FAILED(GetThemeMetric(aTheme, aHdc, aPart, aState, - TMT_PROGRESSCHUNKSIZE, &chunkSize)) || - FAILED(GetThemeMetric(aTheme, aHdc, aPart, aState, - TMT_PROGRESSSPACESIZE, &spaceSize))) { - DrawThemeBackground(aTheme, aHdc, aPart, aState, aWidgetRect, aClipRect); - return; - } - - // render chunks - if (!aIsRtl || aIsIndeterm) { - for (int chunk = aWidgetRect->left; chunk <= aWidgetRect->right; - chunk += (chunkSize+spaceSize)) { - if (!aIsIndeterm && ((chunk + chunkSize) > aWidgetRect->right)) { - // aWidgetRect->right represents the end of the meter. Partial blocks - // don't get rendered with one exception, so exit here if we don't have - // a full chunk to draw. - // The above is true *except* when the meter is at 100% fill, in which - // case Windows renders any remaining partial block. Query the parent - // frame to find out if we're at 100%. - if (!IsProgressMeterFilled(aFrame)) { - break; - } - } - RECT bounds = - { chunk, aWidgetRect->top, chunk + chunkSize, aWidgetRect->bottom }; - DrawThemeBackground(aTheme, aHdc, aPart, aState, &bounds, aClipRect); - } - } else { - // rtl needs to grow in the opposite direction to look right. - for (int chunk = aWidgetRect->right; chunk >= aWidgetRect->left; - chunk -= (chunkSize+spaceSize)) { - if ((chunk - chunkSize) < aWidgetRect->left) { - if (!IsProgressMeterFilled(aFrame)) { - break; - } - } - RECT bounds = - { chunk - chunkSize, aWidgetRect->top, chunk, aWidgetRect->bottom }; - DrawThemeBackground(aTheme, aHdc, aPart, aState, &bounds, aClipRect); - } - } -} - -/* * DrawProgressMeter - render an appropriate progress meter based on progress * meter style, orientation, and os. Note, this does not render the underlying * progress track. @@ -653,8 +543,7 @@ void nsNativeThemeWin::DrawThemedProgressMeter(nsIFrame* aFrame, int aWidgetType, HANDLE aTheme, HDC aHdc, int aPart, int aState, - RECT* aWidgetRect, RECT* aClipRect, - gfxFloat aAppUnits) + RECT* aWidgetRect, RECT* aClipRect) { if (!aFrame || !aTheme || !aHdc) return; @@ -665,12 +554,6 @@ nsNativeThemeWin::DrawThemedProgressMeter(nsIFrame* aFrame, int aWidgetType, RECT adjWidgetRect, adjClipRect; adjWidgetRect = *aWidgetRect; adjClipRect = *aClipRect; - if (!IsVistaOrLater()) { - // Adjust clipping out by one pixel. XP progress meters are inset, - // Vista+ are not. - InflateRect(&adjWidgetRect, 1, 1); - InflateRect(&adjClipRect, 1, 1); - } nsIFrame* parentFrame = aFrame->GetParent(); if (!parentFrame) { @@ -685,20 +568,13 @@ nsNativeThemeWin::DrawThemedProgressMeter(nsIFrame* aFrame, int aWidgetType, bool indeterminate = IsIndeterminateProgress(parentFrame, eventStates); bool animate = indeterminate; - if (IsVistaOrLater()) { - // Vista and up progress meter is fill style, rendered here. We render - // the pulse overlay in the follow up section below. - DrawThemeBackground(aTheme, aHdc, aPart, aState, - &adjWidgetRect, &adjClipRect); - if (!IsProgressMeterFilled(aFrame)) { - animate = true; - } - } else if (!indeterminate) { - // XP progress meters are 'chunk' style. - DrawChunkProgressMeter(aTheme, aHdc, aPart, aState, aFrame, - &adjWidgetRect, &adjClipRect, aAppUnits, - indeterminate, vertical, IsFrameRTL(aFrame)); - } + // Vista and up progress meter is fill style, rendered here. We render + // the pulse overlay in the follow up section below. + DrawThemeBackground(aTheme, aHdc, aPart, aState, + &adjWidgetRect, &adjClipRect); + if (!IsProgressMeterFilled(aFrame)) { + animate = true; + } if (animate) { // Indeterminate rendering @@ -706,14 +582,8 @@ nsNativeThemeWin::DrawThemedProgressMeter(nsIFrame* aFrame, int aWidgetType, RECT overlayRect = CalculateProgressOverlayRect(aFrame, &adjWidgetRect, vertical, indeterminate, false); - if (IsVistaOrLater()) { - DrawThemeBackground(aTheme, aHdc, overlayPart, aState, &overlayRect, - &adjClipRect); - } else { - DrawChunkProgressMeter(aTheme, aHdc, overlayPart, aState, aFrame, - &overlayRect, &adjClipRect, aAppUnits, - indeterminate, vertical, IsFrameRTL(aFrame)); - } + DrawThemeBackground(aTheme, aHdc, overlayPart, aState, &overlayRect, + &adjClipRect); if (!QueueAnimatedContentForRefresh(aFrame->GetContent(), 60)) { NS_WARNING("unable to animate progress widget!"); @@ -724,15 +594,6 @@ nsNativeThemeWin::DrawThemedProgressMeter(nsIFrame* aFrame, int aWidgetType, HANDLE nsNativeThemeWin::GetTheme(uint8_t aWidgetType) { - if (!IsVistaOrLater()) { - // On XP or earlier, render dropdowns as textfields; - // doing it the right way works fine with the MS themes, - // but breaks on a lot of custom themes (presumably because MS - // apps do the textfield border business as well). - if (aWidgetType == NS_THEME_MENULIST) - aWidgetType = NS_THEME_TEXTFIELD; - } - switch (aWidgetType) { case NS_THEME_BUTTON: case NS_THEME_RADIO: @@ -745,9 +606,7 @@ nsNativeThemeWin::GetTheme(uint8_t aWidgetType) case NS_THEME_FOCUS_OUTLINE: return nsUXThemeData::GetTheme(eUXEdit); case NS_THEME_TOOLTIP: - // XP/2K3 should force a classic treatment of tooltips - return !IsVistaOrLater() ? - nullptr : nsUXThemeData::GetTheme(eUXTooltip); + return nsUXThemeData::GetTheme(eUXTooltip); case NS_THEME_TOOLBOX: return nsUXThemeData::GetTheme(eUXRebar); case NS_THEME_WIN_MEDIA_TOOLBOX: @@ -874,12 +733,6 @@ nsresult nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, uint8_t aWidgetType, int32_t& aPart, int32_t& aState) { - if (!IsVistaOrLater()) { - // See GetTheme - if (aWidgetType == NS_THEME_MENULIST) - aWidgetType = NS_THEME_TEXTFIELD; - } - switch (aWidgetType) { case NS_THEME_BUTTON: { aPart = BP_BUTTON; @@ -952,63 +805,43 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, uint8_t aWidgetType, case NS_THEME_TEXTFIELD_MULTILINE: { EventStates eventState = GetContentState(aFrame, aWidgetType); - if (IsVistaOrLater()) { - /* Note: the NOSCROLL type has a rounded corner in each - * corner. The more specific HSCROLL, VSCROLL, HVSCROLL types - * have side and/or top/bottom edges rendered as straight - * horizontal lines with sharp corners to accommodate a - * scrollbar. However, the scrollbar gets rendered on top of - * this for us, so we don't care, and can just use NOSCROLL - * here. - */ - aPart = TFP_EDITBORDER_NOSCROLL; - - if (!aFrame) { - aState = TFS_EDITBORDER_NORMAL; - } else if (IsDisabled(aFrame, eventState)) { - aState = TFS_EDITBORDER_DISABLED; - } else if (IsReadOnly(aFrame)) { - /* no special read-only state */ - aState = TFS_EDITBORDER_NORMAL; - } else { - nsIContent* content = aFrame->GetContent(); + /* Note: the NOSCROLL type has a rounded corner in each corner. The more + * specific HSCROLL, VSCROLL, HVSCROLL types have side and/or top/bottom + * edges rendered as straight horizontal lines with sharp corners to + * accommodate a scrollbar. However, the scrollbar gets rendered on top + * of this for us, so we don't care, and can just use NOSCROLL here. + */ + aPart = TFP_EDITBORDER_NOSCROLL; - /* XUL textboxes don't get focused themselves, because they have child - * html:input.. but we can check the XUL focused attributes on them - */ - if (content && content->IsXULElement() && IsFocused(aFrame)) - aState = TFS_EDITBORDER_FOCUSED; - else if (eventState.HasAtLeastOneOfStates(NS_EVENT_STATE_ACTIVE | NS_EVENT_STATE_FOCUS)) - aState = TFS_EDITBORDER_FOCUSED; - else if (eventState.HasState(NS_EVENT_STATE_HOVER)) - aState = TFS_EDITBORDER_HOVER; - else - aState = TFS_EDITBORDER_NORMAL; - } + if (!aFrame) { + aState = TFS_EDITBORDER_NORMAL; + } else if (IsDisabled(aFrame, eventState)) { + aState = TFS_EDITBORDER_DISABLED; + } else if (IsReadOnly(aFrame)) { + /* no special read-only state */ + aState = TFS_EDITBORDER_NORMAL; } else { - aPart = TFP_TEXTFIELD; - - if (!aFrame) - aState = TS_NORMAL; - else if (IsDisabled(aFrame, eventState)) - aState = TS_DISABLED; - else if (IsReadOnly(aFrame)) - aState = TFS_READONLY; + nsIContent* content = aFrame->GetContent(); + + /* XUL textboxes don't get focused themselves, because they have child + * html:input.. but we can check the XUL focused attributes on them + */ + if (content && content->IsXULElement() && IsFocused(aFrame)) + aState = TFS_EDITBORDER_FOCUSED; + else if (eventState.HasAtLeastOneOfStates(NS_EVENT_STATE_ACTIVE | NS_EVENT_STATE_FOCUS)) + aState = TFS_EDITBORDER_FOCUSED; + else if (eventState.HasState(NS_EVENT_STATE_HOVER)) + aState = TFS_EDITBORDER_HOVER; else - aState = StandardGetState(aFrame, aWidgetType, true); + aState = TFS_EDITBORDER_NORMAL; } return NS_OK; } case NS_THEME_FOCUS_OUTLINE: { - if (IsVistaOrLater()) { - // XXX the EDITBORDER values don't respect DTBG_OMITCONTENT - aPart = TFP_TEXTFIELD; //TFP_EDITBORDER_NOSCROLL; - aState = TS_FOCUSED; //TFS_EDITBORDER_FOCUSED; - } else { - aPart = TFP_TEXTFIELD; - aState = TS_FOCUSED; - } + // XXX the EDITBORDER values don't respect DTBG_OMITCONTENT + aPart = TFP_TEXTFIELD; //TFP_EDITBORDER_NOSCROLL; + aState = TS_FOCUSED; //TFS_EDITBORDER_FOCUSED; return NS_OK; } case NS_THEME_TOOLTIP: { @@ -1032,11 +865,9 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, uint8_t aWidgetType, nsIFrame* parentFrame = aFrame->GetParent(); if (aWidgetType == NS_THEME_PROGRESSCHUNK_VERTICAL || IsVerticalProgress(parentFrame)) { - aPart = IsVistaOrLater() ? - PP_FILLVERT : PP_CHUNKVERT; + aPart = PP_FILLVERT; } else { - aPart = IsVistaOrLater() ? - PP_FILL : PP_CHUNK; + aPart = PP_FILL; } aState = PBBVS_NORMAL; @@ -1100,8 +931,7 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, uint8_t aWidgetType, aState += TS_ACTIVE; else if (eventState.HasState(NS_EVENT_STATE_HOVER)) aState += TS_HOVER; - else if (IsVistaOrLater() && - parentState.HasState(NS_EVENT_STATE_HOVER)) + else if (parentState.HasState(NS_EVENT_STATE_HOVER)) aState = (aWidgetType - NS_THEME_SCROLLBARBUTTON_UP) + SP_BUTTON_IMPLICIT_HOVER_BASE; else aState += TS_NORMAL; @@ -1204,14 +1034,7 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, uint8_t aWidgetType, case NS_THEME_SCROLLBAR: case NS_THEME_SCROLLBAR_SMALL: { aState = 0; - if (IsVistaOrLater()) { - // On vista, they have a part - aPart = RP_BACKGROUND; - } else { - // Otherwise, they don't. (But I bet - // RP_BACKGROUND would work here, too); - aPart = 0; - } + aPart = RP_BACKGROUND; return NS_OK; } case NS_THEME_TOOLBAR: { @@ -1336,8 +1159,7 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, uint8_t aWidgetType, aFrame = parentFrame; EventStates eventState = GetContentState(aFrame, aWidgetType); - aPart = IsVistaOrLater() ? - CBP_DROPMARKER_VISTA : CBP_DROPMARKER; + aPart = CBP_DROPMARKER_VISTA; // For HTML controls with author styling, we should fall // back to the old dropmarker style to avoid clashes with @@ -1357,28 +1179,25 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, uint8_t aWidgetType, else isOpen = IsOpenButton(aFrame); - if (IsVistaOrLater()) { - if (isHTML || IsMenuListEditable(aFrame)) { - if (isOpen) { - /* Hover is propagated, but we need to know whether we're - * hovering just the combobox frame, not the dropdown frame. - * But, we can't get that information, since hover is on the - * content node, and they share the same content node. So, - * instead, we cheat -- if the dropdown is open, we always - * show the hover state. This looks fine in practice. - */ - aState = TS_HOVER; - return NS_OK; - } - } else { - /* On Vista, the dropdown indicator on a menulist button in - * chrome is not given a hover effect. When the frame isn't - * isn't HTML content, we cheat and force the dropdown state - * to be normal. (Bug 430434) + if (isHTML || IsMenuListEditable(aFrame)) { + if (isOpen) { + /* Hover is propagated, but we need to know whether we're hovering + * just the combobox frame, not the dropdown frame. But, we can't get + * that information, since hover is on the content node, and they + * share the same content node. So, instead, we cheat -- if the + * dropdown is open, we always show the hover state. This looks fine + * in practice. */ - aState = TS_NORMAL; + aState = TS_HOVER; return NS_OK; } + } else { + /* The dropdown indicator on a menulist button in chrome is not given a + * hover effect. When the frame isn't isn't HTML content, we cheat and + * force the dropdown state to be normal. (Bug 430434) + */ + aState = TS_NORMAL; + return NS_OK; } aState = TS_NORMAL; @@ -1879,7 +1698,7 @@ RENDER_AGAIN: else if (aWidgetType == NS_THEME_PROGRESSCHUNK || aWidgetType == NS_THEME_PROGRESSCHUNK_VERTICAL) { DrawThemedProgressMeter(aFrame, aWidgetType, theme, hdc, part, state, - &widgetRect, &clipRect, p2a); + &widgetRect, &clipRect); } else if (aWidgetType == NS_THEME_FOCUS_OUTLINE) { // Inflate 'widgetRect' with the focus outline size. @@ -2145,41 +1964,39 @@ nsNativeThemeWin::GetWidgetPadding(nsDeviceContext* aContext, return ok; } - if (IsVistaOrLater()) { - if (aWidgetType == NS_THEME_NUMBER_INPUT || - aWidgetType == NS_THEME_TEXTFIELD || - aWidgetType == NS_THEME_TEXTFIELD_MULTILINE || - aWidgetType == NS_THEME_MENULIST) - { - /* If we have author-specified padding for these elements, don't do the fixups below */ - if (aFrame->PresContext()->HasAuthorSpecifiedRules(aFrame, NS_AUTHOR_SPECIFIED_PADDING)) - return false; - } + if (aWidgetType == NS_THEME_NUMBER_INPUT || + aWidgetType == NS_THEME_TEXTFIELD || + aWidgetType == NS_THEME_TEXTFIELD_MULTILINE || + aWidgetType == NS_THEME_MENULIST) + { + // If we have author-specified padding for these elements, don't do the + // fixups below. + if (aFrame->PresContext()->HasAuthorSpecifiedRules(aFrame, NS_AUTHOR_SPECIFIED_PADDING)) + return false; + } - /* textfields need extra pixels on all sides, otherwise they - * wrap their content too tightly. The actual border is drawn 1px - * inside the specified rectangle, so Gecko will end up making the - * contents look too small. Instead, we add 2px padding for the - * contents and fix this. (Used to be 1px added, see bug 430212) + /* textfields need extra pixels on all sides, otherwise they wrap their + * content too tightly. The actual border is drawn 1px inside the specified + * rectangle, so Gecko will end up making the contents look too small. + * Instead, we add 2px padding for the contents and fix this. (Used to be 1px + * added, see bug 430212) + */ + if (aWidgetType == NS_THEME_NUMBER_INPUT || + aWidgetType == NS_THEME_TEXTFIELD || + aWidgetType == NS_THEME_TEXTFIELD_MULTILINE) { + aResult->top = aResult->bottom = 2; + aResult->left = aResult->right = 2; + ScaleForFrameDPI(aResult, aFrame); + return ok; + } else if (IsHTMLContent(aFrame) && aWidgetType == NS_THEME_MENULIST) { + /* For content menulist controls, we need an extra pixel so that we have + * room to draw our focus rectangle stuff. Otherwise, the focus rect might + * overlap the control's border. */ - if (aWidgetType == NS_THEME_NUMBER_INPUT || - aWidgetType == NS_THEME_TEXTFIELD || - aWidgetType == NS_THEME_TEXTFIELD_MULTILINE) { - aResult->top = aResult->bottom = 2; - aResult->left = aResult->right = 2; - ScaleForFrameDPI(aResult, aFrame); - return ok; - } else if (IsHTMLContent(aFrame) && aWidgetType == NS_THEME_MENULIST) { - /* For content menulist controls, we need an extra pixel so - * that we have room to draw our focus rectangle stuff. - * Otherwise, the focus rect might overlap the control's - * border. - */ - aResult->top = aResult->bottom = 1; - aResult->left = aResult->right = 1; - ScaleForFrameDPI(aResult, aFrame); - return ok; - } + aResult->top = aResult->bottom = 1; + aResult->left = aResult->right = 1; + ScaleForFrameDPI(aResult, aFrame); + return ok; } int32_t right, left, top, bottom; @@ -2244,23 +2061,21 @@ nsNativeThemeWin::GetWidgetOverflow(nsDeviceContext* aContext, * a border only shows up if the widget is being hovered. */ #if 0 - if (IsVistaOrLater()) { - /* We explicitly draw dropdown buttons in HTML content 1px bigger - * up, right, and bottom so that they overlap the dropdown's border - * like they're supposed to. - */ - if (aWidgetType == NS_THEME_MENULIST_BUTTON && - IsHTMLContent(aFrame) && - !IsWidgetStyled(aFrame->GetParent()->PresContext(), - aFrame->GetParent(), - NS_THEME_MENULIST)) - { - int32_t p2a = aContext->AppUnitsPerDevPixel(); - /* Note: no overflow on the left */ - nsMargin m(p2a, p2a, p2a, 0); - aOverflowRect->Inflate (m); - return true; - } + /* We explicitly draw dropdown buttons in HTML content 1px bigger up, right, + * and bottom so that they overlap the dropdown's border like they're + * supposed to. + */ + if (aWidgetType == NS_THEME_MENULIST_BUTTON && + IsHTMLContent(aFrame) && + !IsWidgetStyled(aFrame->GetParent()->PresContext(), + aFrame->GetParent(), + NS_THEME_MENULIST)) + { + int32_t p2a = aContext->AppUnitsPerDevPixel(); + /* Note: no overflow on the left */ + nsMargin m(p2a, p2a, p2a, 0); + aOverflowRect->Inflate (m); + return true; } #endif @@ -2384,22 +2199,18 @@ nsNativeThemeWin::GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aF case NS_THEME_SCALETHUMB_VERTICAL: { *aIsOverridable = false; - // on Vista, GetThemePartAndState returns odd values for + // On Vista, GetThemePartAndState returns odd values for // scale thumbs, so use a hardcoded size instead. - if (IsVistaOrLater()) { - if (aWidgetType == NS_THEME_SCALETHUMB_HORIZONTAL || - (aWidgetType == NS_THEME_RANGE_THUMB && IsRangeHorizontal(aFrame))) { - aResult->width = 12; - aResult->height = 20; - } - else { - aResult->width = 20; - aResult->height = 12; - } - ScaleForFrameDPI(aResult, aFrame); - return rv; + if (aWidgetType == NS_THEME_SCALETHUMB_HORIZONTAL || + (aWidgetType == NS_THEME_RANGE_THUMB && IsRangeHorizontal(aFrame))) { + aResult->width = 12; + aResult->height = 20; + } else { + aResult->width = 20; + aResult->height = 12; } - break; + ScaleForFrameDPI(aResult, aFrame); + return rv; } case NS_THEME_SCROLLBAR: @@ -2438,11 +2249,6 @@ nsNativeThemeWin::GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aF // stores that info in nsUXThemeData. aResult->width = nsUXThemeData::sCommandButtons[CMDBUTTONIDX_RESTORE].cx; aResult->height = nsUXThemeData::sCommandButtons[CMDBUTTONIDX_RESTORE].cy; - // For XP, subtract 4 from system metrics dimensions. - if (!IsVistaOrLater()) { - aResult->width -= 4; - aResult->height -= 4; - } AddPaddingRect(aResult, CAPTIONBUTTON_RESTORE); *aIsOverridable = false; return rv; @@ -2450,10 +2256,6 @@ nsNativeThemeWin::GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aF case NS_THEME_WINDOW_BUTTON_MINIMIZE: aResult->width = nsUXThemeData::sCommandButtons[CMDBUTTONIDX_MINIMIZE].cx; aResult->height = nsUXThemeData::sCommandButtons[CMDBUTTONIDX_MINIMIZE].cy; - if (!IsVistaOrLater()) { - aResult->width -= 4; - aResult->height -= 4; - } AddPaddingRect(aResult, CAPTIONBUTTON_MINIMIZE); *aIsOverridable = false; return rv; @@ -2461,10 +2263,6 @@ nsNativeThemeWin::GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aF case NS_THEME_WINDOW_BUTTON_CLOSE: aResult->width = nsUXThemeData::sCommandButtons[CMDBUTTONIDX_CLOSE].cx; aResult->height = nsUXThemeData::sCommandButtons[CMDBUTTONIDX_CLOSE].cy; - if (!IsVistaOrLater()) { - aResult->width -= 4; - aResult->height -= 4; - } AddPaddingRect(aResult, CAPTIONBUTTON_CLOSE); *aIsOverridable = false; return rv; @@ -2594,18 +2392,9 @@ nsNativeThemeWin::WidgetStateChanged(nsIFrame* aFrame, uint8_t aWidgetType, return NS_OK; } - // On Vista, the scrollbar buttons need to change state when the track has/doesn't have hover - if (!IsVistaOrLater() && - (aWidgetType == NS_THEME_SCROLLBAR_VERTICAL || - aWidgetType == NS_THEME_SCROLLBAR_HORIZONTAL)) { - *aShouldRepaint = false; - return NS_OK; - } - // We need to repaint the dropdown arrow in vista HTML combobox controls when // the control is closed to get rid of the hover effect. - if (IsVistaOrLater() && - (aWidgetType == NS_THEME_MENULIST || aWidgetType == NS_THEME_MENULIST_BUTTON) && + if ((aWidgetType == NS_THEME_MENULIST || aWidgetType == NS_THEME_MENULIST_BUTTON) && IsHTMLContent(aFrame)) { *aShouldRepaint = true; diff --git a/widget/windows/nsNativeThemeWin.h b/widget/windows/nsNativeThemeWin.h index f20649444..32b82b1e1 100644 --- a/widget/windows/nsNativeThemeWin.h +++ b/widget/windows/nsNativeThemeWin.h @@ -117,8 +117,7 @@ protected: void DrawThemedProgressMeter(nsIFrame* aFrame, int aWidgetType, HANDLE aTheme, HDC aHdc, int aPart, int aState, - RECT* aWidgetRect, RECT* aClipRect, - gfxFloat aAppUnits); + RECT* aWidgetRect, RECT* aClipRect); private: TimeStamp mProgressDeterminateTimeStamp; diff --git a/widget/windows/nsUXThemeConstants.h b/widget/windows/nsUXThemeConstants.h index 731dcedf2..ba7afde82 100644 --- a/widget/windows/nsUXThemeConstants.h +++ b/widget/windows/nsUXThemeConstants.h @@ -67,7 +67,7 @@ #define SP_GRIPPERHOR 8 #define SP_GRIPPERVERT 9 -// Vista only; implict hover state. +// Implicit hover state. // BASE + 0 = UP, + 1 = DOWN, etc. #define SP_BUTTON_IMPLICIT_HOVER_BASE 17 diff --git a/widget/windows/nsUXThemeData.cpp b/widget/windows/nsUXThemeData.cpp index bcbd32484..4d9ac9570 100644 --- a/widget/windows/nsUXThemeData.cpp +++ b/widget/windows/nsUXThemeData.cpp @@ -143,10 +143,8 @@ nsUXThemeData::InitTitlebarInfo() sCommandButtons[3].cx = sCommandButtons[0].cx * 3; sCommandButtons[3].cy = sCommandButtons[0].cy; - // Use system metrics for pre-vista, otherwise trigger a - // refresh on the next layout. - sTitlebarInfoPopulatedAero = sTitlebarInfoPopulatedThemed = - !IsVistaOrLater(); + // Trigger a refresh on the next layout. + sTitlebarInfoPopulatedAero = sTitlebarInfoPopulatedThemed = false; } // static @@ -306,7 +304,7 @@ void nsUXThemeData::UpdateNativeThemeInfo() { // Trigger a refresh of themed button metrics if needed - sTitlebarInfoPopulatedThemed = !IsVistaOrLater(); + sTitlebarInfoPopulatedThemed = false; sIsDefaultWindowsTheme = false; sThemeId = LookAndFeel::eWindowsTheme_Generic; diff --git a/widget/windows/nsWinGesture.h b/widget/windows/nsWinGesture.h index 24c1f6b2d..fdd1588b6 100644 --- a/widget/windows/nsWinGesture.h +++ b/widget/windows/nsWinGesture.h @@ -17,155 +17,6 @@ #include "mozilla/EventForwards.h" #include "mozilla/TouchEvents.h" -// Desktop builds target apis for 502. Win8 Metro builds target 602. -#if WINVER < 0x0602 - -DECLARE_HANDLE(HGESTUREINFO); - -/* - * Gesture flags - GESTUREINFO.dwFlags - */ -#define GF_BEGIN 0x00000001 -#define GF_INERTIA 0x00000002 -#define GF_END 0x00000004 - -/* - * Gesture configuration structure - * - Used in SetGestureConfig and GetGestureConfig - * - Note that any setting not included in either GESTURECONFIG.dwWant or - * GESTURECONFIG.dwBlock will use the parent window's preferences or - * system defaults. - */ -typedef struct tagGESTURECONFIG { - DWORD dwID; // gesture ID - DWORD dwWant; // settings related to gesture ID that are to be turned on - DWORD dwBlock; // settings related to gesture ID that are to be turned off -} GESTURECONFIG, *PGESTURECONFIG; - -/* - * Gesture information structure - * - Pass the HGESTUREINFO received in the WM_GESTURE message lParam into the - * GetGestureInfo function to retrieve this information. - * - If cbExtraArgs is non-zero, pass the HGESTUREINFO received in the WM_GESTURE - * message lParam into the GetGestureExtraArgs function to retrieve extended - * argument information. - */ -typedef struct tagGESTUREINFO { - UINT cbSize; // size, in bytes, of this structure (including variable length Args field) - DWORD dwFlags; // see GF_* flags - DWORD dwID; // gesture ID, see GID_* defines - HWND hwndTarget; // handle to window targeted by this gesture - POINTS ptsLocation; // current location of this gesture - DWORD dwInstanceID; // internally used - DWORD dwSequenceID; // internally used - ULONGLONG ullArguments; // arguments for gestures whose arguments fit in 8 BYTES - UINT cbExtraArgs; // size, in bytes, of extra arguments, if any, that accompany this gesture -} GESTUREINFO, *PGESTUREINFO; -typedef GESTUREINFO const * PCGESTUREINFO; - -/* - * Gesture notification structure - * - The WM_GESTURENOTIFY message lParam contains a pointer to this structure. - * - The WM_GESTURENOTIFY message notifies a window that gesture recognition is - * in progress and a gesture will be generated if one is recognized under the - * current gesture settings. - */ -typedef struct tagGESTURENOTIFYSTRUCT { - UINT cbSize; // size, in bytes, of this structure - DWORD dwFlags; // unused - HWND hwndTarget; // handle to window targeted by the gesture - POINTS ptsLocation; // starting location - DWORD dwInstanceID; // internally used -} GESTURENOTIFYSTRUCT, *PGESTURENOTIFYSTRUCT; - - -/* - * Gesture argument helpers - * - Angle should be a double in the range of -2pi to +2pi - * - Argument should be an unsigned 16-bit value - */ -#define GID_ROTATE_ANGLE_TO_ARGUMENT(_arg_) ((USHORT)((((_arg_) + 2.0 * 3.14159265) / (4.0 * 3.14159265)) * 65535.0)) -#define GID_ROTATE_ANGLE_FROM_ARGUMENT(_arg_) ((((double)(_arg_) / 65535.0) * 4.0 * 3.14159265) - 2.0 * 3.14159265) - -/* - * Gesture configuration flags - */ -#define GC_ALLGESTURES 0x00000001 - -#define GC_ZOOM 0x00000001 - -#define GC_PAN 0x00000001 -#define GC_PAN_WITH_SINGLE_FINGER_VERTICALLY 0x00000002 -#define GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY 0x00000004 -#define GC_PAN_WITH_GUTTER 0x00000008 -#define GC_PAN_WITH_INERTIA 0x00000010 - -#define GC_ROTATE 0x00000001 - -#define GC_TWOFINGERTAP 0x00000001 - -#define GC_PRESSANDTAP 0x00000001 - -/* - * Gesture IDs - */ -#define GID_BEGIN 1 -#define GID_END 2 -#define GID_ZOOM 3 -#define GID_PAN 4 -#define GID_ROTATE 5 -#define GID_TWOFINGERTAP 6 -#define GID_PRESSANDTAP 7 - -// Maximum number of gestures that can be included -// in a single call to SetGestureConfig / GetGestureConfig -#define GESTURECONFIGMAXCOUNT 256 - -// If specified, GetGestureConfig returns consolidated configuration -// for the specified window and it's parent window chain -#define GCF_INCLUDE_ANCESTORS 0x00000001 - -// Window events we need to respond to or receive -#define WM_GESTURE 0x0119 -#define WM_GESTURENOTIFY 0x011A - -typedef struct _TOUCHINPUT { - LONG x; - LONG y; - HANDLE hSource; - DWORD dwID; - DWORD dwFlags; - DWORD dwMask; - DWORD dwTime; - ULONG_PTR dwExtraInfo; - DWORD cxContact; - DWORD cyContact; -} TOUCHINPUT, *PTOUCHINPUT; - -typedef HANDLE HTOUCHINPUT; - -#define WM_TOUCH 0x0240 - -#define TOUCHEVENTF_MOVE 0x0001 -#define TOUCHEVENTF_DOWN 0x0002 -#define TOUCHEVENTF_UP 0x0004 -#define TOUCHEVENTF_INRANGE 0x0008 -#define TOUCHEVENTF_PRIMARY 0x0010 -#define TOUCHEVENTF_NOCOALESCE 0x0020 -#define TOUCHEVENTF_PEN 0x0040 -#define TOUCHEVENTF_PALM 0x0080 - -#define TOUCHINPUTMASKF_TIMEFROMSYSTEM 0x0001 -#define TOUCHINPUTMASKF_EXTRAINFO 0x0002 -#define TOUCHINPUTMASKF_CONTACTAREA 0x0004 - -#define TOUCH_COORD_TO_PIXEL(C) (C/100) - -#define TWF_FINETOUCH 0x0001 -#define TWF_WANTPALM 0x0002 - -#endif // WINVER < 0x0602 - // WM_TABLET_QUERYSYSTEMGESTURESTATUS return values #define TABLET_ROTATE_GESTURE_ENABLE 0x02000000 @@ -205,7 +56,7 @@ public: bool GetTouchInputInfo(HTOUCHINPUT hTouchInput, uint32_t cInputs, PTOUCHINPUT pInputs); bool CloseTouchInputHandle(HTOUCHINPUT hTouchInput); bool IsAvailable(); - + // Simple gesture process bool ProcessGestureMessage(HWND hWnd, WPARAM wParam, LPARAM lParam, mozilla::WidgetSimpleGestureEvent& evt); @@ -216,7 +67,7 @@ public: void UpdatePanFeedbackX(HWND hWnd, int32_t scrollOverflow, bool& endFeedback); void UpdatePanFeedbackY(HWND hWnd, int32_t scrollOverflow, bool& endFeedback); void PanFeedbackFinalize(HWND hWnd, bool endFeedback); - + public: // Helpers bool GetGestureInfo(HGESTUREINFO hGestureInfo, PGESTUREINFO pGestureInfo); @@ -284,5 +135,3 @@ private: }; #endif /* WinGesture_h__ */ - - diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index e721267ba..b2bb59bd3 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -266,8 +266,7 @@ LONG nsWindow::sLastMouseDownTime = 0L; LONG nsWindow::sLastClickCount = 0L; BYTE nsWindow::sLastMouseButton = 0; -// Trim heap on minimize. (initialized, but still true.) -int nsWindow::sTrimOnMinimize = 2; +bool nsWindow::sHaveInitializedPrefs = false; TriStateBool nsWindow::sHasBogusPopupsDropShadowOnMultiMonitor = TRI_UNKNOWN; @@ -783,7 +782,7 @@ nsWindow::Create(nsIWidget* aParent, parent = nullptr; } - if (IsVistaOrLater() && !IsWin8OrLater() && + if (!IsWin8OrLater() && HasBogusPopupsDropShadowOnMultiMonitor()) { extendedStyle |= WS_EX_COMPOSITED; } @@ -908,20 +907,13 @@ nsWindow::Create(nsIWidget* aParent, mDefaultIMC.Init(this); IMEHandler::InitInputContext(this, mInputContext); - // If the internal variable set by the config.trim_on_minimize pref has not - // been initialized, and if this is the hidden window (conveniently created - // before any visible windows, and after the profile has been initialized), - // do some initialization work. - if (sTrimOnMinimize == 2 && mWindowType == eWindowType_invisible) { - // Our internal trim prevention logic is effective on 2K/XP at maintaining - // the working set when windows are minimized, but on Vista and up it has - // little to no effect. Since this feature has been the source of numerous - // bugs over the years, disable it (sTrimOnMinimize=1) on Vista and up. - sTrimOnMinimize = - Preferences::GetBool("config.trim_on_minimize", - IsVistaOrLater() ? 1 : 0); + // Do some initialization work, but only if (a) it hasn't already been done, + // and (b) this is the hidden window (which is conveniently created before + // any visible windows but after the profile has been initialized). + if (!sHaveInitializedPrefs && mWindowType == eWindowType_invisible) { sSwitchKeyboardLayout = Preferences::GetBool("intl.keyboard.per_window_layout", false); + sHaveInitializedPrefs = true; } // Query for command button metric data for rendering the titlebar. We @@ -1647,9 +1639,10 @@ bool nsWindow::IsVisible() const // XP and Vista visual styles sometimes require window clipping regions to be applied for proper // transparency. These routines are called on size and move operations. +// XXX this is apparently still needed in Windows 7 and later void nsWindow::ClearThemeRegion() { - if (IsVistaOrLater() && !HasGlass() && + if (!HasGlass() && (mWindowType == eWindowType_popup && !IsPopupWithTitleBar() && (mPopupType == ePopupTypeTooltip || mPopupType == ePopupTypePanel))) { SetWindowRgn(mWnd, nullptr, false); @@ -1663,7 +1656,7 @@ void nsWindow::SetThemeRegion() // so default constants are used for part and state. At some point we might need part and // state values from nsNativeThemeWin's GetThemePartAndState, but currently windows that // change shape based on state haven't come up. - if (IsVistaOrLater() && !HasGlass() && + if (!HasGlass() && (mWindowType == eWindowType_popup && !IsPopupWithTitleBar() && (mPopupType == ePopupTypeTooltip || mPopupType == ePopupTypePanel))) { HRGN hRgn = nullptr; @@ -2080,13 +2073,7 @@ nsWindow::SetSizeMode(nsSizeMode aMode) break; case nsSizeMode_Minimized : - // Using SW_SHOWMINIMIZED prevents the working set from being trimmed but - // keeps the window active in the tray. So after the window is minimized, - // windows will fire WM_WINDOWPOSCHANGED (OnWindowPosChanged) at which point - // we will do some additional processing to get the active window set right. - // If sTrimOnMinimize is set, we let windows handle minimization normally - // using SW_MINIMIZE. - mode = sTrimOnMinimize ? SW_MINIMIZE : SW_SHOWMINIMIZED; + mode = SW_MINIMIZE; break; default : @@ -5828,12 +5815,6 @@ nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam, case WM_SYSCOMMAND: { WPARAM filteredWParam = (wParam &0xFFF0); - // prevent Windows from trimming the working set. bug 76831 - if (!sTrimOnMinimize && filteredWParam == SC_MINIMIZE) { - ::ShowWindow(mWnd, SW_SHOWMINIMIZED); - result = true; - } - if (mSizeMode == nsSizeMode_Fullscreen && filteredWParam == SC_RESTORE && GetCurrentShowCmd(mWnd) != SW_SHOWMINIMIZED) { @@ -6451,14 +6432,6 @@ void nsWindow::OnWindowPosChanged(WINDOWPOS* wp) else mSizeMode = nsSizeMode_Normal; - // If !sTrimOnMinimize, we minimize windows using SW_SHOWMINIMIZED (See - // SetSizeMode for internal calls, and WM_SYSCOMMAND for external). This - // prevents the working set from being trimmed but keeps the window active. - // After the window is minimized, we need to do some touch up work on the - // active window. (bugs 76831 & 499816) - if (!sTrimOnMinimize && nsSizeMode_Minimized == mSizeMode) - ActivateOtherWindowHelper(mWnd); - #ifdef WINSTATE_DEBUG_OUTPUT switch (mSizeMode) { case nsSizeMode_Normal: @@ -6579,31 +6552,6 @@ void nsWindow::OnWindowPosChanged(WINDOWPOS* wp) } } -// static -void nsWindow::ActivateOtherWindowHelper(HWND aWnd) -{ - // Find the next window that is enabled, visible, and not minimized. - HWND hwndBelow = ::GetNextWindow(aWnd, GW_HWNDNEXT); - while (hwndBelow && (!::IsWindowEnabled(hwndBelow) || !::IsWindowVisible(hwndBelow) || - ::IsIconic(hwndBelow))) { - hwndBelow = ::GetNextWindow(hwndBelow, GW_HWNDNEXT); - } - - // Push ourselves to the bottom of the stack, then activate the - // next window. - ::SetWindowPos(aWnd, HWND_BOTTOM, 0, 0, 0, 0, - SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); - if (hwndBelow) - ::SetForegroundWindow(hwndBelow); - - // Play the minimize sound while we're here, since that is also - // forgotten when we use SW_SHOWMINIMIZED. - nsCOMPtr<nsISound> sound(do_CreateInstance("@mozilla.org/sound;1")); - if (sound) { - sound->PlaySystemSound(NS_LITERAL_STRING("Minimize")); - } -} - void nsWindow::OnWindowPosChanging(LPWINDOWPOS& info) { // Update non-client margins if the frame size is changing, and let the @@ -7141,8 +7089,10 @@ nsWindow::OnSysColorChanged() NotifySysColorChanged(); // On Windows 10 only, we trigger a theme change to pick up changed media // queries that are needed for accent color changes. + // We also set a temp pref to notify the FE that the colors have changed. if (IsWin10OrLater()) { NotifyThemeChanged(); + Preferences::SetBool("ui.colorChanged", true); } } } diff --git a/widget/windows/nsWindow.h b/widget/windows/nsWindow.h index 248978bd7..199500e9c 100644 --- a/widget/windows/nsWindow.h +++ b/widget/windows/nsWindow.h @@ -486,7 +486,6 @@ protected: bool aIntersectWithExisting) override; nsIntRegion GetRegionToPaint(bool aForceFullRepaint, PAINTSTRUCT ps, HDC aDC); - static void ActivateOtherWindowHelper(HWND aWnd); void ClearCachedResources(); nsIWidgetListener* GetPaintListener(); @@ -552,7 +551,7 @@ protected: static bool sJustGotDeactivate; static bool sJustGotActivate; static bool sIsInMouseCapture; - static int sTrimOnMinimize; + static bool sHaveInitializedPrefs; // Always use the helper method to read this property. See bug 603793. static TriStateBool sHasBogusPopupsDropShadowOnMultiMonitor; |