Bug 867047 - remove caret theming support and the Gtk2 implementation r=roc
authorAndreas Gal <gal@mozilla.com>
Tue, 30 Apr 2013 12:17:08 -0700
changeset 141333 fb8ae1b71f3f957873f5f15109adf716a04658e8
parent 141332 52669c3bc4a0e299648a1b37af8ab660d7be86a7
child 141334 fa4d8053055dcd623f54f81a3ec8a78ebe1ed03e
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs867047
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 867047 - remove caret theming support and the Gtk2 implementation r=roc
layout/base/nsCaret.cpp
widget/gtk2/gtk2drawing.c
widget/gtk2/gtk3drawing.c
widget/gtk2/gtkdrawing.h
widget/gtk2/nsNativeThemeGTK.cpp
--- a/layout/base/nsCaret.cpp
+++ b/layout/base/nsCaret.cpp
@@ -27,17 +27,16 @@
 #include "nsBlockFrame.h"
 #include "nsISelectionController.h"
 #include "nsDisplayList.h"
 #include "nsCaret.h"
 #include "nsTextFrame.h"
 #include "nsXULPopupManager.h"
 #include "nsMenuPopupFrame.h"
 #include "nsTextFragment.h"
-#include "nsThemeConstants.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/LookAndFeel.h"
 #include "mozilla/Selection.h"
 #include <algorithm>
 
 // The bidi indicator hangs off the caret to one side, to show which
 // direction the typing is in. It needs to be at least 2x2 to avoid looking like 
 // an insignificant dot
@@ -522,36 +521,16 @@ void nsCaret::PaintCaret(nsDisplayListBu
   if (aForFrame->GetType() == nsGkAtoms::textFrame &&
       (NS_FAILED(aForFrame->GetOffsets(startOffset, endOffset)) ||
       startOffset > contentOffset ||
       endOffset < contentOffset)) {
     return;
   }
   nscolor foregroundColor = aForFrame->GetCaretColorAt(contentOffset);
 
-  // Only draw the native caret if the foreground color matches that of
-  // -moz-fieldtext (the color of the text in a textbox). If it doesn't match
-  // we are likely in contenteditable or a custom widget and we risk being hard to see
-  // against the background. In that case, fall back to the CSS color.
-  nsPresContext* presContext = aForFrame->PresContext();
-
-  if (GetHookRect().IsEmpty() && presContext) {
-    nsITheme *theme = presContext->GetTheme();
-    if (theme && theme->ThemeSupportsWidget(presContext, aForFrame, NS_THEME_TEXTFIELD_CARET)) {
-      nscolor fieldText;
-      nsresult rv = LookAndFeel::GetColor(LookAndFeel::eColorID__moz_fieldtext,
-                                          &fieldText);
-      if (NS_SUCCEEDED(rv) && fieldText == foregroundColor) {
-        theme->DrawWidgetBackground(aCtx, aForFrame, NS_THEME_TEXTFIELD_CARET,
-                                    drawCaretRect, drawCaretRect);
-        return;
-      }
-    }
-  }
-
   aCtx->SetColor(foregroundColor);
   aCtx->FillRect(drawCaretRect);
   if (!GetHookRect().IsEmpty())
     aCtx->FillRect(GetHookRect() + aOffset);
 }
 
 
 //-----------------------------------------------------------------------------
--- a/widget/gtk2/gtk2drawing.c
+++ b/widget/gtk2/gtk2drawing.c
@@ -1539,33 +1539,16 @@ moz_gtk_vpaned_paint(GdkDrawable* drawab
                      GTK_SHADOW_NONE, cliprect, gVPanedWidget, "paned",
                      rect->x, rect->y, rect->width, rect->height,
                      GTK_ORIENTATION_HORIZONTAL);
 
     return MOZ_GTK_SUCCESS;
 }
 
 static gint
-moz_gtk_caret_paint(GdkDrawable* drawable, GdkRectangle* rect,
-                    GdkRectangle* cliprect, GtkTextDirection direction)
-{
-    GdkRectangle location = *rect;
-    if (direction == GTK_TEXT_DIR_RTL) {
-        /* gtk_draw_insertion_cursor ignores location.width */
-        location.x = rect->x + rect->width;
-    }
-
-    ensure_entry_widget();
-    gtk_draw_insertion_cursor(gEntryWidget, drawable, cliprect,
-                              &location, TRUE, direction, FALSE);
-
-    return MOZ_GTK_SUCCESS;
-}
-
-static gint
 moz_gtk_entry_paint(GdkDrawable* drawable, GdkRectangle* rect,
                     GdkRectangle* cliprect, GtkWidgetState* state,
                     GtkWidget* widget, GtkTextDirection direction)
 {
     GtkStateType bg_state = state->disabled ?
                                 GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL;
     gint x, y, width = rect->width, height = rect->height;
     GtkStyle* style;
@@ -2995,17 +2978,16 @@ moz_gtk_get_widget_border(GtkThemeWidget
     case MOZ_GTK_TOOLTIP:
     case MOZ_GTK_WINDOW:
     case MOZ_GTK_RESIZER:
     case MOZ_GTK_MENUARROW:
     case MOZ_GTK_TOOLBARBUTTON_ARROW:
     case MOZ_GTK_TOOLBAR:
     case MOZ_GTK_MENUBAR:
     case MOZ_GTK_TAB_SCROLLARROW:
-    case MOZ_GTK_ENTRY_CARET:
         *left = *top = *right = *bottom = 0;
         return MOZ_GTK_SUCCESS;
     default:
         g_warning("Unsupported widget type: %d", widget);
         return MOZ_GTK_UNKNOWN_WIDGET;
     }
 
     *right = *left = XTHICKNESS(w->style);
@@ -3278,19 +3260,16 @@ moz_gtk_widget_paint(GtkThemeWidgetType 
         return moz_gtk_expander_paint(drawable, rect, cliprect, state,
                                       (GtkExpanderStyle) flags, direction);
         break;
     case MOZ_GTK_ENTRY:
         ensure_entry_widget();
         return moz_gtk_entry_paint(drawable, rect, cliprect, state,
                                    gEntryWidget, direction);
         break;
-    case MOZ_GTK_ENTRY_CARET:
-        return moz_gtk_caret_paint(drawable, rect, cliprect, direction);
-        break;
     case MOZ_GTK_DROPDOWN:
         return moz_gtk_combo_box_paint(drawable, rect, cliprect, state,
                                        (gboolean) flags, direction);
         break;
     case MOZ_GTK_DROPDOWN_ARROW:
         return moz_gtk_combo_box_entry_button_paint(drawable, rect, cliprect,
                                                     state, flags, direction);
         break;
--- a/widget/gtk2/gtk3drawing.c
+++ b/widget/gtk2/gtk3drawing.c
@@ -1406,33 +1406,16 @@ moz_gtk_vpaned_paint(cairo_t *cr, GdkRec
     gtk_render_handle(style, cr,
                       rect->x, rect->y, rect->width, rect->height);                     
     gtk_style_context_restore(style);
 
     return MOZ_GTK_SUCCESS;
 }
 
 static gint
-moz_gtk_caret_paint(cairo_t *cr, GdkRectangle* rect,
-                    GtkTextDirection direction)
-{
-    GdkRectangle location = *rect;
-
-    if (direction == GTK_TEXT_DIR_RTL) {
-        /* gtk_draw_insertion_cursor ignores location.width */
-        location.x = rect->x + rect->width;
-    }
-
-    ensure_entry_widget();
-    gtk_draw_insertion_cursor(gEntryWidget, cr,
-                              &location, TRUE, direction, FALSE);
-    return MOZ_GTK_SUCCESS;
-}
-
-static gint
 moz_gtk_entry_paint(cairo_t *cr, GdkRectangle* rect,
                     GtkWidgetState* state,
                     GtkWidget* widget, GtkTextDirection direction)
 {
     gint x = rect->x, y = rect->y, width = rect->width, height = rect->height;
     GtkStyleContext* style;
     gboolean interior_focus;
     gint focus_width;
@@ -2814,17 +2797,16 @@ moz_gtk_get_widget_border(GtkThemeWidget
     case MOZ_GTK_TOOLTIP:
     case MOZ_GTK_WINDOW:
     case MOZ_GTK_RESIZER:
     case MOZ_GTK_MENUARROW:
     case MOZ_GTK_TOOLBARBUTTON_ARROW:
     case MOZ_GTK_TOOLBAR:
     case MOZ_GTK_MENUBAR:
     case MOZ_GTK_TAB_SCROLLARROW:
-    case MOZ_GTK_ENTRY_CARET:
         *left = *top = *right = *bottom = 0;
         return MOZ_GTK_SUCCESS;
     default:
         g_warning("Unsupported widget type: %d", widget);
         return MOZ_GTK_UNKNOWN_WIDGET;
     }
     /* TODO - we're still missing some widget implementations */
     if (!w) {
@@ -3110,19 +3092,16 @@ moz_gtk_widget_paint(GtkThemeWidgetType 
         return moz_gtk_expander_paint(cr, rect, state,
                                       (GtkExpanderStyle) flags, direction);
         break;
     case MOZ_GTK_ENTRY:
         ensure_entry_widget();
         return moz_gtk_entry_paint(cr, rect, state,
                                    gEntryWidget, direction);
         break;
-    case MOZ_GTK_ENTRY_CARET:
-        return moz_gtk_caret_paint(cr, rect, direction);
-        break;
     case MOZ_GTK_DROPDOWN:
         return moz_gtk_combo_box_paint(cr, rect, state,
                                        (gboolean) flags, direction);
         break;
     case MOZ_GTK_DROPDOWN_ARROW:
         return moz_gtk_combo_box_entry_button_paint(cr, rect, cliprect,
                                                     state, flags, direction);
         break;
--- a/widget/gtk2/gtkdrawing.h
+++ b/widget/gtk2/gtkdrawing.h
@@ -110,18 +110,16 @@ typedef enum {
   MOZ_GTK_SPINBUTTON,
   MOZ_GTK_SPINBUTTON_UP,
   MOZ_GTK_SPINBUTTON_DOWN,
   MOZ_GTK_SPINBUTTON_ENTRY,
   /* Paints the gripper of a GtkHandleBox. */
   MOZ_GTK_GRIPPER,
   /* Paints a GtkEntry. */
   MOZ_GTK_ENTRY,
-  /* Paints the native caret (or in GTK-speak: insertion cursor) */
-  MOZ_GTK_ENTRY_CARET,
   /* Paints a GtkOptionMenu. */
   MOZ_GTK_DROPDOWN,
   /* Paints a dropdown arrow (a GtkButton containing a down GtkArrow). */
   MOZ_GTK_DROPDOWN_ARROW,
   /* Paints an entry in an editable option menu */
   MOZ_GTK_DROPDOWN_ENTRY,
   /* Paints the container part of a GtkCheckButton. */
   MOZ_GTK_CHECKBUTTON_CONTAINER,
--- a/widget/gtk2/nsNativeThemeGTK.cpp
+++ b/widget/gtk2/nsNativeThemeGTK.cpp
@@ -440,19 +440,16 @@ nsNativeThemeGTK::GetGtkWidgetAndState(u
     break;
   case NS_THEME_RESIZER:
     aGtkWidgetType = MOZ_GTK_RESIZER;
     break;
   case NS_THEME_TEXTFIELD:
   case NS_THEME_TEXTFIELD_MULTILINE:
     aGtkWidgetType = MOZ_GTK_ENTRY;
     break;
-  case NS_THEME_TEXTFIELD_CARET:
-    aGtkWidgetType = MOZ_GTK_ENTRY_CARET;
-    break;
   case NS_THEME_LISTBOX:
   case NS_THEME_TREEVIEW:
     aGtkWidgetType = MOZ_GTK_TREEVIEW;
     break;
   case NS_THEME_TREEVIEW_HEADER_CELL:
     if (aWidgetFlags) {
       // In this case, the flag denotes whether the header is the sorted one or not
       if (GetTreeSortDirection(aFrame) == eTreeSortDirection_Natural)
@@ -1390,17 +1387,16 @@ nsNativeThemeGTK::ThemeSupportsWidget(ns
   case NS_THEME_SCROLLBAR_BUTTON_LEFT:
   case NS_THEME_SCROLLBAR_BUTTON_RIGHT:
   case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL:
   case NS_THEME_SCROLLBAR_TRACK_VERTICAL:
   case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL:
   case NS_THEME_SCROLLBAR_THUMB_VERTICAL:
   case NS_THEME_TEXTFIELD:
   case NS_THEME_TEXTFIELD_MULTILINE:
-  case NS_THEME_TEXTFIELD_CARET:
   case NS_THEME_DROPDOWN_TEXTFIELD:
   case NS_THEME_RANGE:
   case NS_THEME_RANGE_THUMB:
   case NS_THEME_SCALE_HORIZONTAL:
   case NS_THEME_SCALE_THUMB_HORIZONTAL:
   case NS_THEME_SCALE_VERTICAL:
   case NS_THEME_SCALE_THUMB_VERTICAL:
     // case NS_THEME_SCALE_THUMB_START: