gtk3.patch 66 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698
  1. diff -up firefox-46.0.1/widget/gtk/gtk3drawing.c.gtk3-20 firefox-46.0.1/widget/gtk/gtk3drawing.c
  2. --- firefox-46.0.1/widget/gtk/gtk3drawing.c.gtk3-20 2016-05-03 07:31:12.000000000 +0200
  3. +++ firefox-46.0.1/widget/gtk/gtk3drawing.c 2016-05-20 15:05:08.750151522 +0200
  4. @@ -17,34 +17,86 @@
  5. #include <math.h>
  6. +#define MOZ_WIDGET_STYLES 4
  7. +
  8. +typedef struct {
  9. + GtkWidget* widget;
  10. +
  11. + union {
  12. + struct {
  13. + GtkStyleContext* style;
  14. + GtkStyleContext* styleSelection;
  15. + } entry;
  16. +
  17. + struct {
  18. + GtkStyleContext* style;
  19. + } button;
  20. +
  21. + struct {
  22. + GtkStyleContext* style;
  23. + GtkStyleContext* styleBackground;
  24. + } tooltip;
  25. +
  26. + struct {
  27. + GtkStyleContext* style;
  28. + GtkStyleContext* styleContents;
  29. + GtkStyleContext* styleTrough;
  30. + GtkStyleContext* styleSlider;
  31. + } scroll;
  32. +
  33. + struct {
  34. + GtkStyleContext* style;
  35. + GtkStyleContext* styleCheck;
  36. + GtkStyleContext* styleLabel;
  37. + } check;
  38. +
  39. + struct {
  40. + GtkStyleContext* style;
  41. + GtkStyleContext* styleTrough;
  42. + GtkStyleContext* styleProgress;
  43. + } progress;
  44. +
  45. + struct {
  46. + GtkStyleContext* style;
  47. + GtkStyleContext* styleEntry;
  48. + GtkStyleContext* styleButtonUp;
  49. + GtkStyleContext* styleButtonDown;
  50. + } spin;
  51. +
  52. + struct {
  53. + GtkStyleContext* style[MOZ_WIDGET_STYLES];
  54. + } all;
  55. + };
  56. +} MozGtkWidget;
  57. +
  58. static GtkWidget* gProtoWindow;
  59. static GtkWidget* gProtoLayout;
  60. -static GtkWidget* gButtonWidget;
  61. +static MozGtkWidget gButton;
  62. static GtkWidget* gToggleButtonWidget;
  63. static GtkWidget* gButtonArrowWidget;
  64. -static GtkWidget* gCheckboxWidget;
  65. -static GtkWidget* gRadiobuttonWidget;
  66. -static GtkWidget* gHorizScrollbarWidget;
  67. -static GtkWidget* gVertScrollbarWidget;
  68. -static GtkWidget* gSpinWidget;
  69. +static MozGtkWidget gCheckbox;
  70. +static MozGtkWidget gRadiobutton;
  71. +static MozGtkWidget gVertScrollbar;
  72. +static MozGtkWidget gHorizScrollbar;
  73. +static MozGtkWidget gSpin;
  74. static GtkWidget* gHScaleWidget;
  75. static GtkWidget* gVScaleWidget;
  76. -static GtkWidget* gEntryWidget;
  77. +static MozGtkWidget gEntry;
  78. static GtkWidget* gComboBoxWidget;
  79. static GtkWidget* gComboBoxButtonWidget;
  80. static GtkWidget* gComboBoxArrowWidget;
  81. static GtkWidget* gComboBoxSeparatorWidget;
  82. static GtkWidget* gComboBoxEntryWidget;
  83. -static GtkWidget* gComboBoxEntryTextareaWidget;
  84. +static MozGtkWidget gComboBoxEntryTextarea;
  85. static GtkWidget* gComboBoxEntryButtonWidget;
  86. static GtkWidget* gComboBoxEntryArrowWidget;
  87. static GtkWidget* gHandleBoxWidget;
  88. static GtkWidget* gToolbarWidget;
  89. static GtkWidget* gFrameWidget;
  90. static GtkWidget* gStatusbarWidget;
  91. -static GtkWidget* gProgressWidget;
  92. +static MozGtkWidget gProgressBar;
  93. static GtkWidget* gTabWidget;
  94. -static GtkWidget* gTooltipWidget;
  95. +static MozGtkWidget gTooltip;
  96. static GtkWidget* gMenuBarWidget;
  97. static GtkWidget* gMenuBarItemWidget;
  98. static GtkWidget* gMenuPopupWidget;
  99. @@ -78,6 +130,37 @@ static gboolean is_initialized;
  100. #define GTK_STATE_FLAG_CHECKED (1 << 11)
  101. #endif
  102. +void moz_gtk_widget_free(MozGtkWidget *aMozWidget)
  103. +{
  104. + // This was removed as a child of gProtoWindow
  105. + if (aMozWidget->widget) {
  106. + aMozWidget->widget = NULL;
  107. + }
  108. +
  109. + for(int i = 0; i < MOZ_WIDGET_STYLES; i++) {
  110. + if (aMozWidget->all.style[i]) {
  111. + g_object_unref(aMozWidget->all.style[i]);
  112. + aMozWidget->all.style[i] = NULL;
  113. + }
  114. + }
  115. +}
  116. +
  117. +// TODO - weak dep!! (dlsym)
  118. +#if GTK_CHECK_VERSION(3, 19, 2)
  119. +#define moz_gtk_path_set_class_name gtk_widget_path_iter_set_object_name
  120. +#else
  121. +#define moz_gtk_path_set_class_name gtk_widget_path_iter_add_class
  122. +#endif
  123. +//gtk_widget_path_iter_get_state
  124. +
  125. +static void
  126. +moz_gtk_get_style_border(GtkStyleContext* style, GtkStateFlags state_flags,
  127. + GtkBorder *border);
  128. +
  129. +static void
  130. +moz_gtk_get_style_padding(GtkStyleContext* style, GtkStateFlags state_flags,
  131. + GtkBorder *padding);
  132. +
  133. static GtkStateFlags
  134. GetStateFlagsFromGtkWidgetState(GtkWidgetState* state)
  135. {
  136. @@ -97,6 +180,41 @@ GetStateFlagsFromGtkWidgetState(GtkWidge
  137. return stateFlags;
  138. }
  139. +GtkStyleContext *
  140. +moz_gtk_style_create(GtkCssNode *node, GtkStyleContext *parent)
  141. +{
  142. + GtkWidgetPath *path;
  143. + GtkStyleContext *context;
  144. +
  145. + if (parent)
  146. + path = gtk_widget_path_copy (gtk_style_context_get_path (parent));
  147. + else
  148. + path = gtk_widget_path_new ();
  149. +
  150. + gtk_widget_path_append_type (path, node->type);
  151. + if (node->name)
  152. + moz_gtk_path_set_class_name(path, -1, node->name);
  153. + if (node->class1)
  154. + gtk_widget_path_iter_add_class(path, -1, node->class1);
  155. + if (node->class2)
  156. + gtk_widget_path_iter_add_class(path, -1, node->class2);
  157. +
  158. + context = gtk_style_context_new ();
  159. + gtk_style_context_set_path (context, path);
  160. + gtk_style_context_set_parent (context, parent);
  161. +
  162. + if(!gtk_check_version(3, 14, 0)) {
  163. + /* Unfortunately, we have to explicitly set the state again here
  164. + * for it to take effect
  165. + */
  166. + gtk_style_context_set_state (context, gtk_widget_path_iter_get_state (path, -1));
  167. + }
  168. +
  169. + gtk_widget_path_unref (path);
  170. +
  171. + return context;
  172. +}
  173. +
  174. /* Because we have such an unconventional way of drawing widgets, signal to the GTK theme engine
  175. that they are drawing for Mozilla instead of a conventional GTK app so they can do any specific
  176. things they may want to do. */
  177. @@ -141,9 +259,16 @@ setup_widget_prototype(GtkWidget* widget
  178. static gint
  179. ensure_button_widget()
  180. {
  181. - if (!gButtonWidget) {
  182. - gButtonWidget = gtk_button_new_with_label("M");
  183. - setup_widget_prototype(gButtonWidget);
  184. + if (!gButton.widget) {
  185. + GtkCssNode path[] = {
  186. + { GTK_TYPE_BUTTON, "button", NULL, NULL }
  187. + };
  188. +
  189. + gButton.widget = gtk_button_new_with_label("M");
  190. + setup_widget_prototype(gButton.widget);
  191. + gtk_widget_show(gButton.widget);
  192. +
  193. + gButton.button.style = moz_gtk_style_create(&path[0], NULL);
  194. }
  195. return MOZ_GTK_SUCCESS;
  196. }
  197. @@ -195,9 +320,21 @@ ensure_button_arrow_widget()
  198. static gint
  199. ensure_checkbox_widget()
  200. {
  201. - if (!gCheckboxWidget) {
  202. - gCheckboxWidget = gtk_check_button_new_with_label("M");
  203. - setup_widget_prototype(gCheckboxWidget);
  204. + if (!gCheckbox.widget) {
  205. + GtkCssNode path[] = {
  206. + { GTK_TYPE_TOGGLE_BUTTON, "checkbutton", NULL, NULL },
  207. + { G_TYPE_NONE, "check", NULL, NULL },
  208. + { G_TYPE_NONE, "label", NULL, NULL }
  209. + };
  210. +
  211. + gCheckbox.widget = gtk_check_button_new_with_label("M");
  212. + setup_widget_prototype(gCheckbox.widget);
  213. +
  214. + gCheckbox.check.style = moz_gtk_style_create(&path[0], NULL);
  215. + gCheckbox.check.styleCheck = moz_gtk_style_create(&path[1],
  216. + gCheckbox.check.style);
  217. + gCheckbox.check.styleLabel = moz_gtk_style_create(&path[2],
  218. + gCheckbox.check.style);
  219. }
  220. return MOZ_GTK_SUCCESS;
  221. }
  222. @@ -205,9 +342,21 @@ ensure_checkbox_widget()
  223. static gint
  224. ensure_radiobutton_widget()
  225. {
  226. - if (!gRadiobuttonWidget) {
  227. - gRadiobuttonWidget = gtk_radio_button_new_with_label(NULL, "M");
  228. - setup_widget_prototype(gRadiobuttonWidget);
  229. + if (!gRadiobutton.widget) {
  230. + GtkCssNode path[] = {
  231. + { GTK_TYPE_TOGGLE_BUTTON, "radiobutton", NULL, NULL },
  232. + { G_TYPE_NONE, "radio", NULL, NULL },
  233. + { G_TYPE_NONE, "label", NULL, NULL }
  234. + };
  235. +
  236. + gRadiobutton.widget = gtk_radio_button_new_with_label(NULL, "M");
  237. + setup_widget_prototype(gRadiobutton.widget);
  238. +
  239. + gRadiobutton.check.style = moz_gtk_style_create(&path[0], NULL);
  240. + gRadiobutton.check.styleCheck = moz_gtk_style_create(&path[1],
  241. + gRadiobutton.check.style);
  242. + gRadiobutton.check.styleLabel = moz_gtk_style_create(&path[2],
  243. + gRadiobutton.check.style);
  244. }
  245. return MOZ_GTK_SUCCESS;
  246. }
  247. @@ -215,25 +364,62 @@ ensure_radiobutton_widget()
  248. static gint
  249. ensure_scrollbar_widget()
  250. {
  251. - if (!gVertScrollbarWidget) {
  252. - gVertScrollbarWidget = gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL, NULL);
  253. - setup_widget_prototype(gVertScrollbarWidget);
  254. - }
  255. - if (!gHorizScrollbarWidget) {
  256. - gHorizScrollbarWidget = gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, NULL);
  257. - setup_widget_prototype(gHorizScrollbarWidget);
  258. - }
  259. + if (!gVertScrollbar.widget && !gHorizScrollbar.widget) {
  260. + GtkCssNode path[] = {
  261. + { GTK_TYPE_SCROLLBAR, "scrollbar", "horizontal", "bottom"},
  262. + { GTK_TYPE_SCROLLBAR, "scrollbar", "vertical", "right" },
  263. + { G_TYPE_NONE, "contents", NULL, NULL },
  264. + { G_TYPE_NONE, "trough", NULL, NULL },
  265. + { G_TYPE_NONE, "slider", NULL, NULL }
  266. + };
  267. +
  268. + gHorizScrollbar.widget = gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, NULL);
  269. + setup_widget_prototype(gHorizScrollbar.widget);
  270. +
  271. + gHorizScrollbar.scroll.style = moz_gtk_style_create(path, NULL);
  272. + gHorizScrollbar.scroll.styleContents = moz_gtk_style_create(path+2,
  273. + gHorizScrollbar.scroll.style);
  274. + gHorizScrollbar.scroll.styleTrough = moz_gtk_style_create(path+3,
  275. + gHorizScrollbar.scroll.styleContents);
  276. + gHorizScrollbar.scroll.styleSlider = moz_gtk_style_create(path+4,
  277. + gHorizScrollbar.scroll.styleTrough);
  278. +
  279. + gVertScrollbar.widget = gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL, NULL);
  280. + setup_widget_prototype(gVertScrollbar.widget);
  281. +
  282. + gVertScrollbar.scroll.style = moz_gtk_style_create(path+1, NULL);
  283. + gVertScrollbar.scroll.styleContents = moz_gtk_style_create(path+2,
  284. + gVertScrollbar.scroll.style);
  285. + gVertScrollbar.scroll.styleTrough = moz_gtk_style_create(path+3,
  286. + gVertScrollbar.scroll.styleContents);
  287. + gVertScrollbar.scroll.styleSlider = moz_gtk_style_create(path+4,
  288. + gVertScrollbar.scroll.styleTrough);
  289. +
  290. + }
  291. return MOZ_GTK_SUCCESS;
  292. }
  293. static gint
  294. ensure_spin_widget()
  295. {
  296. - if (!gSpinWidget) {
  297. - gSpinWidget = gtk_spin_button_new(NULL, 1, 0);
  298. - setup_widget_prototype(gSpinWidget);
  299. - }
  300. - return MOZ_GTK_SUCCESS;
  301. + if (!gSpin.widget) {
  302. + GtkCssNode path[] = {
  303. + { GTK_TYPE_SPIN_BUTTON, "spinbutton", "horizontal", NULL },
  304. + { GTK_TYPE_SPIN_BUTTON, "spinbutton", "vertical", NULL },
  305. + { GTK_TYPE_ENTRY, "entry", NULL, NULL },
  306. + { G_TYPE_NONE, "button", "up", NULL },
  307. + { G_TYPE_NONE, "button", "down", NULL }
  308. + };
  309. +
  310. + gSpin.widget = gtk_spin_button_new(NULL, 1, 0);
  311. + setup_widget_prototype(gSpin.widget);
  312. +
  313. + gSpin.spin.style = moz_gtk_style_create(path, NULL);
  314. + gSpin.spin.styleButtonUp = moz_gtk_style_create(path+3, gSpin.spin.style);
  315. + gSpin.spin.styleButtonDown = moz_gtk_style_create(path+4, gSpin.spin.style);
  316. + gSpin.spin.styleEntry = moz_gtk_style_create(path+2, gSpin.spin.style);
  317. + }
  318. + return MOZ_GTK_SUCCESS;
  319. }
  320. static gint
  321. @@ -253,9 +439,19 @@ ensure_scale_widget()
  322. static gint
  323. ensure_entry_widget()
  324. {
  325. - if (!gEntryWidget) {
  326. - gEntryWidget = gtk_entry_new();
  327. - setup_widget_prototype(gEntryWidget);
  328. + if (!gEntry.widget) {
  329. + GtkCssNode path[] = {
  330. + { GTK_TYPE_ENTRY, "entry", NULL, NULL },
  331. + { G_TYPE_NONE, "selection", NULL, NULL }
  332. + };
  333. +
  334. + gEntry.widget = gtk_entry_new();
  335. + setup_widget_prototype(gEntry.widget);
  336. + gtk_widget_show(gEntry.widget);
  337. +
  338. + gEntry.entry.style = moz_gtk_style_create(&path[0], NULL);
  339. + gEntry.entry.styleSelection = moz_gtk_style_create(&path[1],
  340. + gEntry.entry.style);
  341. }
  342. return MOZ_GTK_SUCCESS;
  343. }
  344. @@ -387,9 +583,9 @@ moz_gtk_get_combo_box_entry_inner_widget
  345. g_object_add_weak_pointer(G_OBJECT(widget),
  346. (gpointer) &gComboBoxEntryButtonWidget);
  347. } else if (GTK_IS_ENTRY(widget)) {
  348. - gComboBoxEntryTextareaWidget = widget;
  349. + gComboBoxEntryTextarea.widget = widget;
  350. g_object_add_weak_pointer(G_OBJECT(widget),
  351. - (gpointer) &gComboBoxEntryTextareaWidget);
  352. + (gpointer) &gComboBoxEntryTextarea.widget);
  353. } else
  354. return;
  355. gtk_widget_realize(widget);
  356. @@ -411,7 +607,7 @@ ensure_combo_box_entry_widgets()
  357. {
  358. GtkWidget* buttonChild;
  359. - if (gComboBoxEntryTextareaWidget &&
  360. + if (gComboBoxEntryTextarea.widget &&
  361. gComboBoxEntryButtonWidget &&
  362. gComboBoxEntryArrowWidget)
  363. return MOZ_GTK_SUCCESS;
  364. @@ -427,9 +623,9 @@ ensure_combo_box_entry_widgets()
  365. moz_gtk_get_combo_box_entry_inner_widgets,
  366. NULL);
  367. - if (!gComboBoxEntryTextareaWidget) {
  368. + if (!gComboBoxEntryTextarea.widget) {
  369. ensure_entry_widget();
  370. - gComboBoxEntryTextareaWidget = gEntryWidget;
  371. + gComboBoxEntryTextarea.widget = gEntry.widget;
  372. }
  373. if (gComboBoxEntryButtonWidget) {
  374. @@ -507,12 +703,18 @@ ensure_toolbar_separator_widget()
  375. static gint
  376. ensure_tooltip_widget()
  377. {
  378. - if (!gTooltipWidget) {
  379. - gTooltipWidget = gtk_window_new(GTK_WINDOW_POPUP);
  380. - GtkStyleContext* style = gtk_widget_get_style_context(gTooltipWidget);
  381. - gtk_style_context_add_class(style, GTK_STYLE_CLASS_TOOLTIP);
  382. - gtk_widget_realize(gTooltipWidget);
  383. - moz_gtk_set_widget_name(gTooltipWidget);
  384. + if (!gTooltip.widget) {
  385. + GtkCssNode path[] = {
  386. + { GTK_TYPE_TOOLTIP, "tooltip", NULL, NULL},
  387. + { GTK_TYPE_TOOLTIP, "tooltip", "background", NULL},
  388. + };
  389. +
  390. + gTooltip.widget = gtk_window_new(GTK_WINDOW_POPUP);
  391. + gtk_widget_realize(gTooltip.widget);
  392. + moz_gtk_set_widget_name(gTooltip.widget);
  393. +
  394. + gTooltip.tooltip.style = moz_gtk_style_create(&path[0], NULL);
  395. + gTooltip.tooltip.styleBackground = moz_gtk_style_create(&path[1], NULL);
  396. }
  397. return MOZ_GTK_SUCCESS;
  398. }
  399. @@ -530,9 +732,21 @@ ensure_tab_widget()
  400. static gint
  401. ensure_progress_widget()
  402. {
  403. - if (!gProgressWidget) {
  404. - gProgressWidget = gtk_progress_bar_new();
  405. - setup_widget_prototype(gProgressWidget);
  406. + if (!gProgressBar.widget) {
  407. + GtkCssNode path[] = {
  408. + { GTK_TYPE_LABEL, "progressbar", NULL, NULL },
  409. + { G_TYPE_NONE, "trough", NULL, NULL },
  410. + { G_TYPE_NONE, "progress", NULL, NULL },
  411. + };
  412. +
  413. + gProgressBar.widget = gtk_progress_bar_new();
  414. + setup_widget_prototype(gProgressBar.widget);
  415. +
  416. + gProgressBar.progress.style = moz_gtk_style_create(&path[0], NULL);
  417. + gProgressBar.progress.styleTrough = moz_gtk_style_create(&path[1],
  418. + gProgressBar.progress.style);
  419. + gProgressBar.progress.styleProgress = moz_gtk_style_create(&path[2],
  420. + gProgressBar.progress.styleTrough);
  421. }
  422. return MOZ_GTK_SUCCESS;
  423. }
  424. @@ -638,6 +852,11 @@ static gint
  425. ensure_check_menu_item_widget()
  426. {
  427. if (!gCheckMenuItemWidget) {
  428. + GtkCssNode path[] = {
  429. + { GTK_TYPE_CHECK_MENU_ITEM, "menuitem", NULL, NULL },
  430. + { G_TYPE_NONE, "check", NULL, NULL }
  431. + };
  432. +
  433. ensure_menu_popup_widget();
  434. gCheckMenuItemWidget = gtk_check_menu_item_new_with_label("M");
  435. gtk_menu_shell_append(GTK_MENU_SHELL(gMenuPopupWidget),
  436. @@ -752,7 +971,7 @@ moz_gtk_checkbox_get_metrics(gint* indic
  437. {
  438. ensure_checkbox_widget();
  439. - gtk_widget_style_get (gCheckboxWidget,
  440. + gtk_widget_style_get (gCheckbox.widget,
  441. "indicator_size", indicator_size,
  442. "indicator_spacing", indicator_spacing,
  443. NULL);
  444. @@ -765,7 +984,7 @@ moz_gtk_radio_get_metrics(gint* indicato
  445. {
  446. ensure_radiobutton_widget();
  447. - gtk_widget_style_get (gRadiobuttonWidget,
  448. + gtk_widget_style_get (gRadiobutton.widget,
  449. "indicator_size", indicator_size,
  450. "indicator_spacing", indicator_spacing,
  451. NULL);
  452. @@ -778,13 +997,13 @@ moz_gtk_get_focus_outline_size(gint* foc
  453. {
  454. GtkBorder border;
  455. GtkBorder padding;
  456. - GtkStyleContext *style;
  457. + GtkStyleContext* style;
  458. ensure_entry_widget();
  459. - style = gtk_widget_get_style_context(gEntryWidget);
  460. - gtk_style_context_get_border(style, 0, &border);
  461. - gtk_style_context_get_padding(style, 0, &padding);
  462. + style = gEntry.entry.style;
  463. + gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
  464. + gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
  465. *focus_h_width = border.left + padding.left;
  466. *focus_v_width = border.top + padding.top;
  467. return MOZ_GTK_SUCCESS;
  468. @@ -821,7 +1040,7 @@ moz_gtk_button_get_default_overflow(gint
  469. GtkBorder* default_outside_border;
  470. ensure_button_widget();
  471. - gtk_widget_style_get(gButtonWidget,
  472. + gtk_widget_style_get(gButton.widget,
  473. "default-outside-border", &default_outside_border,
  474. NULL);
  475. @@ -844,7 +1063,7 @@ moz_gtk_button_get_default_border(gint*
  476. GtkBorder* default_border;
  477. ensure_button_widget();
  478. - gtk_widget_style_get(gButtonWidget,
  479. + gtk_widget_style_get(gButton.widget,
  480. "default-border", &default_border,
  481. NULL);
  482. @@ -935,7 +1154,7 @@ moz_gtk_button_paint(cairo_t *cr, GdkRec
  483. if (state->focused) {
  484. GtkBorder border;
  485. - gtk_style_context_get_border(style, state_flags, &border);
  486. + moz_gtk_get_style_border(style, state_flags, &border);
  487. x += border.left;
  488. y += border.top;
  489. width -= (border.left + border.right);
  490. @@ -956,15 +1175,14 @@ moz_gtk_toggle_paint(cairo_t *cr, GdkRec
  491. gint indicator_size, indicator_spacing;
  492. gint x, y, width, height;
  493. gint focus_x, focus_y, focus_width, focus_height;
  494. - GtkWidget *w;
  495. - GtkStyleContext *style;
  496. + MozGtkWidget *w;
  497. if (isradio) {
  498. moz_gtk_radio_get_metrics(&indicator_size, &indicator_spacing);
  499. - w = gRadiobuttonWidget;
  500. + w = &gRadiobutton;
  501. } else {
  502. moz_gtk_checkbox_get_metrics(&indicator_size, &indicator_spacing);
  503. - w = gCheckboxWidget;
  504. + w = &gCheckbox;
  505. }
  506. // XXX we should assert rect->height >= indicator_size too
  507. @@ -983,11 +1201,9 @@ moz_gtk_toggle_paint(cairo_t *cr, GdkRec
  508. focus_width = width + 2 * indicator_spacing;
  509. focus_height = height + 2 * indicator_spacing;
  510. - style = gtk_widget_get_style_context(w);
  511. -
  512. - gtk_widget_set_sensitive(w, !state->disabled);
  513. - gtk_widget_set_direction(w, direction);
  514. - gtk_style_context_save(style);
  515. + gtk_widget_set_sensitive(w->widget, !state->disabled);
  516. + gtk_widget_set_direction(w->widget, direction);
  517. + gtk_style_context_save(w->check.styleCheck);
  518. if (selected)
  519. state_flags |= checkbox_check_state;
  520. @@ -995,13 +1211,15 @@ moz_gtk_toggle_paint(cairo_t *cr, GdkRec
  521. if (inconsistent)
  522. state_flags |= GTK_STATE_FLAG_INCONSISTENT;
  523. - gtk_style_context_set_state(style, state_flags);
  524. + gtk_style_context_set_state(w->check.styleCheck, state_flags);
  525. +
  526. + gtk_render_background(w->check.styleCheck, cr, x, y, width, height);
  527. + gtk_render_frame(w->check.styleCheck, cr, x, y, width, height);
  528. if (isradio) {
  529. - gtk_style_context_add_class(style, GTK_STYLE_CLASS_RADIO);
  530. - gtk_render_option(style, cr, x, y, width, height);
  531. + gtk_render_option(w->check.styleCheck, cr, x, y, width, height);
  532. if (state->focused) {
  533. - gtk_render_focus(style, cr, focus_x, focus_y,
  534. + gtk_render_focus(w->check.styleCheck, cr, focus_x, focus_y,
  535. focus_width, focus_height);
  536. }
  537. }
  538. @@ -1010,15 +1228,14 @@ moz_gtk_toggle_paint(cairo_t *cr, GdkRec
  539. * 'indeterminate' type on checkboxes. In GTK, the shadow type
  540. * must also be changed for the state to be drawn.
  541. */
  542. - gtk_style_context_add_class(style, GTK_STYLE_CLASS_CHECK);
  543. - gtk_toggle_button_set_inconsistent(GTK_TOGGLE_BUTTON(gCheckboxWidget), inconsistent);
  544. - gtk_render_check(style, cr, x, y, width, height);
  545. + gtk_toggle_button_set_inconsistent(GTK_TOGGLE_BUTTON(w->widget), inconsistent);
  546. + gtk_render_check(w->check.styleCheck, cr, x, y, width, height);
  547. if (state->focused) {
  548. - gtk_render_focus(style, cr,
  549. + gtk_render_focus(w->check.styleCheck, cr,
  550. focus_x, focus_y, focus_width, focus_height);
  551. }
  552. }
  553. - gtk_style_context_restore(style);
  554. + gtk_style_context_restore(w->check.styleCheck);
  555. return MOZ_GTK_SUCCESS;
  556. }
  557. @@ -1035,8 +1252,8 @@ calculate_button_inner_rect(GtkWidget* b
  558. style = gtk_widget_get_style_context(button);
  559. /* This mirrors gtkbutton's child positioning */
  560. - gtk_style_context_get_border(style, 0, &border);
  561. - gtk_style_context_get_padding(style, 0, &padding);
  562. + gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
  563. + gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
  564. inner_rect->x = rect->x + border.left + padding.left;
  565. inner_rect->y = rect->y + padding.top + border.top;
  566. @@ -1099,9 +1316,9 @@ moz_gtk_scrollbar_button_paint(cairo_t *
  567. ensure_scrollbar_widget();
  568. if (flags & MOZ_GTK_STEPPER_VERTICAL)
  569. - scrollbar = gVertScrollbarWidget;
  570. + scrollbar = gVertScrollbar.widget;
  571. else
  572. - scrollbar = gHorizScrollbarWidget;
  573. + scrollbar = gHorizScrollbar.widget;
  574. gtk_widget_set_direction(scrollbar, direction);
  575. @@ -1181,25 +1398,22 @@ moz_gtk_scrollbar_trough_paint(GtkThemeW
  576. GtkTextDirection direction)
  577. {
  578. GtkStyleContext* style;
  579. - GtkScrollbar *scrollbar;
  580. ensure_scrollbar_widget();
  581. - if (widget == MOZ_GTK_SCROLLBAR_HORIZONTAL)
  582. - scrollbar = GTK_SCROLLBAR(gHorizScrollbarWidget);
  583. - else
  584. - scrollbar = GTK_SCROLLBAR(gVertScrollbarWidget);
  585. -
  586. - gtk_widget_set_direction(GTK_WIDGET(scrollbar), direction);
  587. -
  588. if (flags & MOZ_GTK_TRACK_OPAQUE) {
  589. style = gtk_widget_get_style_context(GTK_WIDGET(gProtoWindow));
  590. gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height);
  591. }
  592. - style = gtk_widget_get_style_context(GTK_WIDGET(scrollbar));
  593. - gtk_style_context_save(style);
  594. - gtk_style_context_add_class(style, GTK_STYLE_CLASS_TROUGH);
  595. + if (widget == MOZ_GTK_SCROLLBAR_HORIZONTAL) {
  596. + gtk_widget_set_direction(GTK_WIDGET(gHorizScrollbar.widget), direction);
  597. + style = gHorizScrollbar.scroll.style;
  598. + }
  599. + else {
  600. + gtk_widget_set_direction(GTK_WIDGET(gVertScrollbar.widget), direction);
  601. + style = gVertScrollbar.scroll.style;
  602. + }
  603. gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height);
  604. gtk_render_frame(style, cr, rect->x, rect->y, rect->width, rect->height);
  605. @@ -1208,7 +1422,6 @@ moz_gtk_scrollbar_trough_paint(GtkThemeW
  606. gtk_render_focus(style, cr,
  607. rect->x, rect->y, rect->width, rect->height);
  608. }
  609. - gtk_style_context_restore(style);
  610. return MOZ_GTK_SUCCESS;
  611. }
  612. @@ -1220,24 +1433,20 @@ moz_gtk_scrollbar_thumb_paint(GtkThemeWi
  613. {
  614. GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state);
  615. GtkStyleContext* style;
  616. - GtkScrollbar *scrollbar;
  617. GtkBorder margin;
  618. ensure_scrollbar_widget();
  619. - if (widget == MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL)
  620. - scrollbar = GTK_SCROLLBAR(gHorizScrollbarWidget);
  621. - else
  622. - scrollbar = GTK_SCROLLBAR(gVertScrollbarWidget);
  623. -
  624. - gtk_widget_set_direction(GTK_WIDGET(scrollbar), direction);
  625. -
  626. - style = gtk_widget_get_style_context(GTK_WIDGET(scrollbar));
  627. - gtk_style_context_save(style);
  628. + if (widget == MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL) {
  629. + style = gHorizScrollbar.scroll.styleSlider;
  630. + gtk_widget_set_direction(GTK_WIDGET(gHorizScrollbar.widget), direction);
  631. + }
  632. + else {
  633. + style = gVertScrollbar.scroll.styleSlider;
  634. + gtk_widget_set_direction(GTK_WIDGET(gVertScrollbar.widget), direction);
  635. + }
  636. - gtk_style_context_add_class(style, GTK_STYLE_CLASS_SLIDER);
  637. gtk_style_context_set_state(style, state_flags);
  638. -
  639. gtk_style_context_get_margin (style, state_flags, &margin);
  640. gtk_render_slider(style, cr,
  641. @@ -1248,8 +1457,6 @@ moz_gtk_scrollbar_thumb_paint(GtkThemeWi
  642. (widget == MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL) ?
  643. GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL);
  644. - gtk_style_context_restore(style);
  645. -
  646. return MOZ_GTK_SUCCESS;
  647. }
  648. @@ -1260,8 +1467,8 @@ moz_gtk_spin_paint(cairo_t *cr, GdkRecta
  649. GtkStyleContext* style;
  650. ensure_spin_widget();
  651. - gtk_widget_set_direction(gSpinWidget, direction);
  652. - style = gtk_widget_get_style_context(gSpinWidget);
  653. + gtk_widget_set_direction(gSpin.widget, direction);
  654. + style = gSpin.spin.style;
  655. gtk_style_context_save(style);
  656. gtk_style_context_add_class(style, GTK_STYLE_CLASS_SPINBUTTON);
  657. gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height);
  658. @@ -1280,11 +1487,10 @@ moz_gtk_spin_updown_paint(cairo_t *cr, G
  659. GtkStyleContext* style;
  660. ensure_spin_widget();
  661. - style = gtk_widget_get_style_context(gSpinWidget);
  662. + style = gSpin.spin.style;
  663. gtk_style_context_save(style);
  664. - gtk_style_context_add_class(style, GTK_STYLE_CLASS_SPINBUTTON);
  665. gtk_style_context_set_state(style, GetStateFlagsFromGtkWidgetState(state));
  666. - gtk_widget_set_direction(gSpinWidget, direction);
  667. + gtk_widget_set_direction(gSpin.widget, direction);
  668. gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height);
  669. gtk_render_frame(style, cr, rect->x, rect->y, rect->width, rect->height);
  670. @@ -1450,15 +1656,13 @@ moz_gtk_vpaned_paint(cairo_t *cr, GdkRec
  671. static gint
  672. moz_gtk_entry_paint(cairo_t *cr, GdkRectangle* rect,
  673. GtkWidgetState* state,
  674. - GtkWidget* widget, GtkTextDirection direction)
  675. + MozGtkWidget* w, GtkTextDirection direction)
  676. {
  677. gint x = rect->x, y = rect->y, width = rect->width, height = rect->height;
  678. - GtkStyleContext* style;
  679. int draw_focus_outline_only = state->depressed; // NS_THEME_FOCUS_OUTLINE
  680. + GtkStyleContext* style = w->entry.style;
  681. - gtk_widget_set_direction(widget, direction);
  682. -
  683. - style = gtk_widget_get_style_context(widget);
  684. + gtk_widget_set_direction(w->widget, direction);
  685. if (draw_focus_outline_only) {
  686. // Inflate the given 'rect' with the focus outline size.
  687. @@ -1478,10 +1682,9 @@ moz_gtk_entry_paint(cairo_t *cr, GdkRect
  688. * textarea window uses gtk_paint_flat_box when exposed */
  689. /* This gets us a lovely greyish disabledish look */
  690. - gtk_widget_set_sensitive(widget, !state->disabled);
  691. + gtk_widget_set_sensitive(w->widget, !state->disabled);
  692. gtk_style_context_save(style);
  693. - gtk_style_context_add_class(style, GTK_STYLE_CLASS_ENTRY);
  694. /* Now paint the shadow and focus border.
  695. * We do like in gtk_entry_draw_frame, we first draw the shadow, a tad
  696. @@ -1531,7 +1734,7 @@ moz_gtk_treeview_paint(cairo_t *cr, GdkR
  697. style = gtk_widget_get_style_context(gScrolledWindowWidget);
  698. gtk_style_context_save(style);
  699. gtk_style_context_add_class(style, GTK_STYLE_CLASS_FRAME);
  700. - gtk_style_context_get_border(style, state_flags, &border);
  701. + moz_gtk_get_style_border(style, state_flags, &border);
  702. xthickness = border.left;
  703. ythickness = border.top;
  704. @@ -1702,7 +1905,7 @@ moz_gtk_combo_box_paint(cairo_t *cr, Gdk
  705. if (direction == GTK_TEXT_DIR_LTR) {
  706. GtkBorder padding;
  707. GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state);
  708. - gtk_style_context_get_padding(style, state_flags, &padding);
  709. + moz_gtk_get_style_padding(style, state_flags, &padding);
  710. arrow_rect.x -= padding.left;
  711. }
  712. else
  713. @@ -1804,29 +2007,27 @@ moz_gtk_container_paint(cairo_t *cr, Gdk
  714. gboolean isradio, GtkTextDirection direction)
  715. {
  716. GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state);
  717. - GtkStyleContext* style;
  718. - GtkWidget *widget;
  719. + MozGtkWidget *widget;
  720. if (isradio) {
  721. ensure_radiobutton_widget();
  722. - widget = gRadiobuttonWidget;
  723. + widget = &gRadiobutton;
  724. } else {
  725. ensure_checkbox_widget();
  726. - widget = gCheckboxWidget;
  727. + widget = &gCheckbox;
  728. }
  729. - gtk_widget_set_direction(widget, direction);
  730. + gtk_widget_set_direction(widget->widget, direction);
  731. - style = gtk_widget_get_style_context(widget);
  732. - gtk_style_context_save(style);
  733. - gtk_style_context_set_state(style, state_flags);
  734. + gtk_style_context_save(widget->check.style);
  735. + gtk_style_context_set_state(widget->check.style, state_flags);
  736. /* this is for drawing a prelight box */
  737. if (state_flags & GTK_STATE_FLAG_PRELIGHT) {
  738. - gtk_render_background(style, cr,
  739. + gtk_render_background(widget->check.style, cr,
  740. rect->x, rect->y, rect->width, rect->height);
  741. }
  742. - gtk_style_context_restore(style);
  743. + gtk_style_context_restore(widget->check.style);
  744. return MOZ_GTK_SUCCESS;
  745. }
  746. @@ -1836,32 +2037,26 @@ moz_gtk_toggle_label_paint(cairo_t *cr,
  747. GtkWidgetState* state,
  748. gboolean isradio, GtkTextDirection direction)
  749. {
  750. - GtkStyleContext *style;
  751. - GtkWidget *widget;
  752. + MozGtkWidget *widget;
  753. if (!state->focused)
  754. return MOZ_GTK_SUCCESS;
  755. if (isradio) {
  756. ensure_radiobutton_widget();
  757. - widget = gRadiobuttonWidget;
  758. + widget = &gRadiobutton;
  759. } else {
  760. ensure_checkbox_widget();
  761. - widget = gCheckboxWidget;
  762. - }
  763. - style = gtk_widget_get_style_context(widget);
  764. - gtk_style_context_save(style);
  765. - if (isradio) {
  766. - gtk_style_context_add_class(style, GTK_STYLE_CLASS_RADIO);
  767. - } else {
  768. - gtk_style_context_add_class(style, GTK_STYLE_CLASS_CHECK);
  769. + widget = &gCheckbox;
  770. }
  771. - gtk_widget_set_direction(widget, direction);
  772. + gtk_style_context_save(widget->check.styleLabel);
  773. + gtk_widget_set_direction(widget->widget, direction);
  774. - gtk_style_context_set_state(style, GetStateFlagsFromGtkWidgetState(state));
  775. - gtk_render_focus(style, cr,
  776. + gtk_style_context_set_state(widget->check.styleLabel,
  777. + GetStateFlagsFromGtkWidgetState(state));
  778. + gtk_render_focus(widget->check.styleLabel, cr,
  779. rect->x, rect->y, rect->width, rect->height);
  780. - gtk_style_context_restore(style);
  781. + gtk_style_context_restore(widget->check.styleLabel);
  782. return MOZ_GTK_SUCCESS;
  783. }
  784. @@ -1922,7 +2117,7 @@ moz_gtk_toolbar_separator_paint(cairo_t
  785. rect->height * (end_fraction - start_fraction));
  786. } else {
  787. GtkBorder padding;
  788. - gtk_style_context_get_padding(style, 0, &padding);
  789. + gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
  790. paint_width = padding.left;
  791. if (paint_width > rect->width)
  792. @@ -1945,9 +2140,9 @@ moz_gtk_tooltip_paint(cairo_t *cr, GdkRe
  793. GtkStyleContext* style;
  794. ensure_tooltip_widget();
  795. - gtk_widget_set_direction(gTooltipWidget, direction);
  796. + gtk_widget_set_direction(gTooltip.widget, direction);
  797. - style = gtk_widget_get_style_context(gTooltipWidget);
  798. + style = gTooltip.tooltip.styleBackground;
  799. gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height);
  800. gtk_render_frame(style, cr, rect->x, rect->y, rect->width, rect->height);
  801. return MOZ_GTK_SUCCESS;
  802. @@ -2006,18 +2201,13 @@ static gint
  803. moz_gtk_progressbar_paint(cairo_t *cr, GdkRectangle* rect,
  804. GtkTextDirection direction)
  805. {
  806. - GtkStyleContext* style;
  807. -
  808. ensure_progress_widget();
  809. - gtk_widget_set_direction(gProgressWidget, direction);
  810. + gtk_widget_set_direction(gProgressBar.widget, direction);
  811. - style = gtk_widget_get_style_context(gProgressWidget);
  812. - gtk_style_context_save(style);
  813. - gtk_style_context_add_class(style, GTK_STYLE_CLASS_TROUGH);
  814. -
  815. - gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height);
  816. - gtk_render_frame(style, cr, rect->x, rect->y, rect->width, rect->height);
  817. - gtk_style_context_restore(style);
  818. + gtk_render_background(gProgressBar.progress.styleTrough, cr,
  819. + rect->x, rect->y, rect->width, rect->height);
  820. + gtk_render_frame(gProgressBar.progress.styleTrough, cr,
  821. + rect->x, rect->y, rect->width, rect->height);
  822. return MOZ_GTK_SUCCESS;
  823. }
  824. @@ -2027,15 +2217,8 @@ moz_gtk_progress_chunk_paint(cairo_t *cr
  825. GtkTextDirection direction,
  826. GtkThemeWidgetType widget)
  827. {
  828. - GtkStyleContext* style;
  829. -
  830. ensure_progress_widget();
  831. - gtk_widget_set_direction(gProgressWidget, direction);
  832. -
  833. - style = gtk_widget_get_style_context(gProgressWidget);
  834. - gtk_style_context_save(style);
  835. - gtk_style_context_remove_class(style, GTK_STYLE_CLASS_TROUGH);
  836. - gtk_style_context_add_class(style, GTK_STYLE_CLASS_PROGRESSBAR);
  837. + gtk_widget_set_direction(gProgressBar.widget, direction);
  838. if (widget == MOZ_GTK_PROGRESS_CHUNK_INDETERMINATE ||
  839. widget == MOZ_GTK_PROGRESS_CHUNK_VERTICAL_INDETERMINATE) {
  840. @@ -2074,12 +2257,14 @@ moz_gtk_progress_chunk_paint(cairo_t *cr
  841. // gtk_render_activity was used to render progress chunks on GTK versions
  842. // before 3.13.7, see bug 1173907.
  843. if (!gtk_check_version(3, 13, 7)) {
  844. - gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height);
  845. - gtk_render_frame(style, cr, rect->x, rect->y, rect->width, rect->height);
  846. + gtk_render_background(gProgressBar.progress.styleProgress, cr,
  847. + rect->x, rect->y, rect->width, rect->height);
  848. + gtk_render_frame(gProgressBar.progress.styleProgress, cr,
  849. + rect->x, rect->y, rect->width, rect->height);
  850. } else {
  851. - gtk_render_activity(style, cr, rect->x, rect->y, rect->width, rect->height);
  852. + gtk_render_activity(gProgressBar.progress.styleProgress, cr,
  853. + rect->x, rect->y, rect->width, rect->height);
  854. }
  855. - gtk_style_context_restore(style);
  856. return MOZ_GTK_SUCCESS;
  857. }
  858. @@ -2096,7 +2281,7 @@ moz_gtk_get_tab_thickness(void)
  859. style = gtk_widget_get_style_context(gTabWidget);
  860. gtk_style_context_add_class(style, GTK_STYLE_CLASS_NOTEBOOK);
  861. - gtk_style_context_get_border(style, 0, &border);
  862. + gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
  863. if (border.top < 2)
  864. return 2; /* some themes don't set ythickness correctly */
  865. @@ -2292,7 +2477,7 @@ moz_gtk_tab_paint(cairo_t *cr, GdkRectan
  866. gtk_style_context_save(style);
  867. moz_gtk_tab_prepare_style_context(style, flags);
  868. - gtk_style_context_get_padding(style, GetStateFlagsFromGtkWidgetState(state), &padding);
  869. + moz_gtk_get_style_padding(style, GetStateFlagsFromGtkWidgetState(state), &padding);
  870. focusRect.x += padding.left;
  871. focusRect.width -= (padding.left + padding.right);
  872. @@ -2408,7 +2593,7 @@ moz_gtk_tab_scroll_arrow_paint(cairo_t *
  873. }
  874. static gint
  875. -moz_gtk_menu_bar_paint(cairo_t *cr, GdkRectangle* rect,
  876. +moz_gtk_menu_bar_paint(cairo_t *cr, GdkRectangle* rect, GtkWidgetState* state,
  877. GtkTextDirection direction)
  878. {
  879. GtkStyleContext* style;
  880. @@ -2468,7 +2653,7 @@ moz_gtk_menu_separator_paint(cairo_t *cr
  881. border_width = gtk_container_get_border_width(GTK_CONTAINER(gMenuSeparatorWidget));
  882. style = gtk_widget_get_style_context(gMenuSeparatorWidget);
  883. - gtk_style_context_get_padding(style, 0, &padding);
  884. + gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
  885. x = rect->x + border_width;
  886. y = rect->y + border_width;
  887. @@ -2521,7 +2706,8 @@ moz_gtk_menu_item_paint(cairo_t *cr, Gdk
  888. item_widget = gMenuItemWidget;
  889. }
  890. style = gtk_widget_get_style_context(item_widget);
  891. - gtk_style_context_save(style);
  892. +// TODO - FIX!
  893. +// gtk_style_context_save(style);
  894. if (flags & MOZ_TOPLEVEL_MENU_ITEM) {
  895. gtk_style_context_add_class(style, GTK_STYLE_CLASS_MENUBAR);
  896. @@ -2540,7 +2726,7 @@ moz_gtk_menu_item_paint(cairo_t *cr, Gdk
  897. gtk_render_background(style, cr, x, y, w, h);
  898. gtk_render_frame(style, cr, x, y, w, h);
  899. - gtk_style_context_restore(style);
  900. +// gtk_style_context_restore(style);
  901. }
  902. return MOZ_GTK_SUCCESS;
  903. @@ -2556,7 +2742,10 @@ moz_gtk_menu_arrow_paint(cairo_t *cr, Gd
  904. ensure_menu_item_widget();
  905. gtk_widget_set_direction(gMenuItemWidget, direction);
  906. -
  907. +/*
  908. + state_flags |= (direction == GTK_TEXT_DIR_LTR) ? GTK_STATE_FLAG_DIR_LTR :
  909. + GTK_STATE_FLAG_DIR_RTL;
  910. +*/
  911. style = gtk_widget_get_style_context(gMenuItemWidget);
  912. gtk_style_context_save(style);
  913. gtk_style_context_add_class(style, GTK_STYLE_CLASS_MENUITEM);
  914. @@ -2606,7 +2795,7 @@ moz_gtk_check_menu_item_paint(cairo_t *c
  915. }
  916. gtk_style_context_set_state(style, state_flags);
  917. - gtk_style_context_get_padding(style, state_flags, &padding);
  918. + moz_gtk_get_style_padding(style, state_flags, &padding);
  919. offset = gtk_container_get_border_width(GTK_CONTAINER(gCheckMenuItemWidget)) +
  920. padding.left + 2;
  921. @@ -2658,7 +2847,7 @@ moz_gtk_add_style_border(GtkStyleContext
  922. {
  923. GtkBorder border;
  924. - gtk_style_context_get_border(style, 0, &border);
  925. + gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
  926. *left += border.left;
  927. *right += border.right;
  928. @@ -2667,12 +2856,22 @@ moz_gtk_add_style_border(GtkStyleContext
  929. }
  930. static void
  931. +moz_gtk_get_style_border(GtkStyleContext* style, GtkStateFlags state_flags,
  932. + GtkBorder *border)
  933. +{
  934. + gtk_style_context_save(style);
  935. + gtk_style_context_set_state(style, state_flags);
  936. + gtk_style_context_get_border(style, gtk_style_context_get_state(style), border);
  937. + gtk_style_context_restore(style);
  938. +}
  939. +
  940. +static void
  941. moz_gtk_add_style_padding(GtkStyleContext* style,
  942. gint* left, gint* top, gint* right, gint* bottom)
  943. {
  944. GtkBorder padding;
  945. - gtk_style_context_get_padding(style, 0, &padding);
  946. + gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
  947. *left += padding.left;
  948. *right += padding.right;
  949. @@ -2680,6 +2879,16 @@ moz_gtk_add_style_padding(GtkStyleContex
  950. *bottom += padding.bottom;
  951. }
  952. +static void
  953. +moz_gtk_get_style_padding(GtkStyleContext* style, GtkStateFlags state_flags,
  954. + GtkBorder *padding)
  955. +{
  956. + gtk_style_context_save(style);
  957. + gtk_style_context_set_state(style, state_flags);
  958. + gtk_style_context_get_padding(style, gtk_style_context_get_state(style), padding);
  959. + gtk_style_context_restore(style);
  960. +}
  961. +
  962. gint
  963. moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top,
  964. gint* right, gint* bottom, GtkTextDirection direction,
  965. @@ -2694,37 +2903,35 @@ moz_gtk_get_widget_border(GtkThemeWidget
  966. case MOZ_GTK_TOOLBAR_BUTTON:
  967. {
  968. ensure_button_widget();
  969. - style = gtk_widget_get_style_context(gButtonWidget);
  970. -
  971. - *left = *top = *right = *bottom = gtk_container_get_border_width(GTK_CONTAINER(gButtonWidget));
  972. - if (widget == MOZ_GTK_TOOLBAR_BUTTON) {
  973. - gtk_style_context_save(style);
  974. - gtk_style_context_add_class(style, "image-button");
  975. - }
  976. -
  977. - moz_gtk_add_style_padding(style, left, top, right, bottom);
  978. -
  979. - if (widget == MOZ_GTK_TOOLBAR_BUTTON)
  980. - gtk_style_context_restore(style);
  981. + *left = *top = *right = *bottom = gtk_container_get_border_width(GTK_CONTAINER(gButton.widget));
  982. + moz_gtk_add_style_padding(gButton.button.style, left, top, right, bottom);
  983. // XXX: Subtract 1 pixel from the border to account for the added
  984. // -moz-focus-inner border (Bug 1228281).
  985. *left -= 1; *top -= 1; *right -= 1; *bottom -= 1;
  986. - moz_gtk_add_style_border(style, left, top, right, bottom);
  987. + moz_gtk_add_style_border(gButton.button.style, left, top, right, bottom);
  988. +
  989. return MOZ_GTK_SUCCESS;
  990. }
  991. case MOZ_GTK_ENTRY:
  992. {
  993. ensure_entry_widget();
  994. - style = gtk_widget_get_style_context(gEntryWidget);
  995. // XXX: Subtract 1 pixel from the padding to account for the default
  996. // padding in forms.css. See bug 1187385.
  997. *left = *top = *right = *bottom = -1;
  998. - moz_gtk_add_style_padding(style, left, top, right, bottom);
  999. - moz_gtk_add_style_border(style, left, top, right, bottom);
  1000. + moz_gtk_add_style_padding(gEntry.entry.style, left, top, right, bottom);
  1001. + moz_gtk_add_style_border(gEntry.entry.style, left, top, right, bottom);
  1002. +
  1003. + return MOZ_GTK_SUCCESS;
  1004. + }
  1005. + case MOZ_GTK_TOOLTIP:
  1006. + {
  1007. + ensure_tooltip_widget();
  1008. + moz_gtk_add_style_padding(gTooltip.tooltip.styleBackground, left, top, right, bottom);
  1009. + moz_gtk_add_style_border(gTooltip.tooltip.styleBackground, left, top, right, bottom);
  1010. return MOZ_GTK_SUCCESS;
  1011. }
  1012. case MOZ_GTK_TREEVIEW:
  1013. @@ -2759,7 +2966,7 @@ moz_gtk_get_widget_border(GtkThemeWidget
  1014. break;
  1015. case MOZ_GTK_DROPDOWN_ENTRY:
  1016. ensure_combo_box_entry_widgets();
  1017. - w = gComboBoxEntryTextareaWidget;
  1018. + w = gComboBoxEntryTextarea.widget;
  1019. break;
  1020. case MOZ_GTK_DROPDOWN_ARROW:
  1021. ensure_combo_box_entry_widgets();
  1022. @@ -2795,7 +3002,7 @@ moz_gtk_get_widget_border(GtkThemeWidget
  1023. if (!wide_separators) {
  1024. style = gtk_widget_get_style_context(gComboBoxSeparatorWidget);
  1025. - gtk_style_context_get_border(style, 0, &border);
  1026. + gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
  1027. separator_width = border.left;
  1028. }
  1029. }
  1030. @@ -2814,14 +3021,17 @@ moz_gtk_get_widget_border(GtkThemeWidget
  1031. w = gTabWidget;
  1032. break;
  1033. case MOZ_GTK_PROGRESSBAR:
  1034. - ensure_progress_widget();
  1035. - w = gProgressWidget;
  1036. - break;
  1037. + {
  1038. + ensure_progress_widget();
  1039. + moz_gtk_add_style_border(gProgressBar.progress.styleTrough,
  1040. + left, top, right, bottom);
  1041. + return MOZ_GTK_SUCCESS;
  1042. + }
  1043. case MOZ_GTK_SPINBUTTON_ENTRY:
  1044. case MOZ_GTK_SPINBUTTON_UP:
  1045. case MOZ_GTK_SPINBUTTON_DOWN:
  1046. ensure_spin_widget();
  1047. - w = gSpinWidget;
  1048. + w = gSpin.widget;
  1049. break;
  1050. case MOZ_GTK_SCALE_HORIZONTAL:
  1051. ensure_scale_widget();
  1052. @@ -2840,12 +3050,13 @@ moz_gtk_get_widget_border(GtkThemeWidget
  1053. {
  1054. if (widget == MOZ_GTK_CHECKBUTTON_CONTAINER) {
  1055. ensure_checkbox_widget();
  1056. - w = gCheckboxWidget;
  1057. + w = gCheckbox.widget;
  1058. + style = gCheckbox.check.styleCheck;
  1059. } else {
  1060. ensure_radiobutton_widget();
  1061. - w = gRadiobuttonWidget;
  1062. + w = gRadiobutton.widget;
  1063. + style = gRadiobutton.check.styleCheck;
  1064. }
  1065. - style = gtk_widget_get_style_context(w);
  1066. *left = *top = *right = *bottom = gtk_container_get_border_width(GTK_CONTAINER(w));
  1067. moz_gtk_add_style_border(style,
  1068. @@ -2904,7 +3115,6 @@ moz_gtk_get_widget_border(GtkThemeWidget
  1069. case MOZ_GTK_MENUSEPARATOR:
  1070. /* These widgets have no borders.*/
  1071. case MOZ_GTK_SPINBUTTON:
  1072. - case MOZ_GTK_TOOLTIP:
  1073. case MOZ_GTK_WINDOW:
  1074. case MOZ_GTK_RESIZER:
  1075. case MOZ_GTK_MENUARROW:
  1076. @@ -2978,6 +3188,32 @@ moz_gtk_get_combo_box_entry_button_size(
  1077. }
  1078. gint
  1079. +moz_gtk_get_entry_height(gint* height)
  1080. +{
  1081. + GtkRequisition requisition;
  1082. + ensure_entry_widget();
  1083. +
  1084. + gtk_widget_get_preferred_size(gEntry.widget, NULL, &requisition);
  1085. + *height = requisition.height;
  1086. +
  1087. + return MOZ_GTK_SUCCESS;
  1088. +}
  1089. +
  1090. +
  1091. +gint
  1092. +moz_gtk_get_button_height(gint* height)
  1093. +{
  1094. + GtkRequisition requisition;
  1095. + ensure_entry_widget();
  1096. +
  1097. + gtk_widget_get_preferred_size(gButton.widget, NULL, &requisition);
  1098. + *height = requisition.height;
  1099. +
  1100. + return MOZ_GTK_SUCCESS;
  1101. +}
  1102. +
  1103. +
  1104. +gint
  1105. moz_gtk_get_tab_scroll_arrow_size(gint* width, gint* height)
  1106. {
  1107. gint arrow_size;
  1108. @@ -3030,7 +3266,7 @@ moz_gtk_get_toolbar_separator_width(gint
  1109. "separator-width", &separator_width,
  1110. NULL);
  1111. /* Just in case... */
  1112. - gtk_style_context_get_border(style, 0, &border);
  1113. + gtk_style_context_get_border(style, gtk_style_context_get_state(style), &border);
  1114. *size = MAX(*size, (wide_separators ? separator_width : border.left));
  1115. return MOZ_GTK_SUCCESS;
  1116. }
  1117. @@ -3072,7 +3308,7 @@ moz_gtk_get_menu_separator_height(gint *
  1118. border_width = gtk_container_get_border_width(GTK_CONTAINER(gMenuSeparatorWidget));
  1119. style = gtk_widget_get_style_context(gMenuSeparatorWidget);
  1120. - gtk_style_context_get_padding(style, 0, &padding);
  1121. + gtk_style_context_get_padding(style, gtk_style_context_get_state(style), &padding);
  1122. gtk_style_context_save(style);
  1123. gtk_style_context_add_class(style, GTK_STYLE_CLASS_SEPARATOR);
  1124. @@ -3130,15 +3366,21 @@ moz_gtk_get_scrollbar_metrics(MozGtkScro
  1125. {
  1126. ensure_scrollbar_widget();
  1127. - gtk_widget_style_get (gHorizScrollbarWidget,
  1128. + gtk_widget_style_get (gHorizScrollbar.widget,
  1129. "slider_width", &metrics->slider_width,
  1130. "trough_border", &metrics->trough_border,
  1131. "stepper_size", &metrics->stepper_size,
  1132. "stepper_spacing", &metrics->stepper_spacing,
  1133. NULL);
  1134. - metrics->min_slider_size =
  1135. - gtk_range_get_min_slider_size(GTK_RANGE(gHorizScrollbarWidget));
  1136. + if (!gtk_check_version(3,19,7)) {
  1137. + gtk_style_context_get(gVertScrollbar.scroll.styleSlider,
  1138. + gtk_style_context_get_state(gVertScrollbar.scroll.styleSlider),
  1139. + "min-height", &metrics->min_slider_size, NULL);
  1140. + } else {
  1141. + metrics->min_slider_size =
  1142. + gtk_range_get_min_slider_size(GTK_RANGE(gVertScrollbar.widget));
  1143. + }
  1144. return MOZ_GTK_SUCCESS;
  1145. }
  1146. @@ -3163,7 +3405,7 @@ moz_gtk_images_in_buttons()
  1147. GtkSettings* settings;
  1148. ensure_button_widget();
  1149. - settings = gtk_widget_get_settings(gButtonWidget);
  1150. + settings = gtk_widget_get_settings(gButton.widget);
  1151. g_object_get(settings, "gtk-button-images", &result, NULL);
  1152. return result;
  1153. @@ -3191,7 +3433,7 @@ moz_gtk_widget_paint(GtkThemeWidgetType
  1154. }
  1155. ensure_button_widget();
  1156. return moz_gtk_button_paint(cr, rect, state,
  1157. - (GtkReliefStyle) flags, gButtonWidget,
  1158. + (GtkReliefStyle) flags, gButton.widget,
  1159. direction);
  1160. break;
  1161. case MOZ_GTK_CHECKBUTTON:
  1162. @@ -3241,7 +3483,7 @@ moz_gtk_widget_paint(GtkThemeWidgetType
  1163. case MOZ_GTK_SPINBUTTON_ENTRY:
  1164. ensure_spin_widget();
  1165. return moz_gtk_entry_paint(cr, rect, state,
  1166. - gSpinWidget, direction);
  1167. + &gSpin, direction);
  1168. break;
  1169. case MOZ_GTK_GRIPPER:
  1170. return moz_gtk_gripper_paint(cr, rect, state,
  1171. @@ -3268,7 +3510,7 @@ moz_gtk_widget_paint(GtkThemeWidgetType
  1172. case MOZ_GTK_ENTRY:
  1173. ensure_entry_widget();
  1174. return moz_gtk_entry_paint(cr, rect, state,
  1175. - gEntryWidget, direction);
  1176. + &gEntry, direction);
  1177. break;
  1178. case MOZ_GTK_DROPDOWN:
  1179. return moz_gtk_combo_box_paint(cr, rect, state, direction);
  1180. @@ -3280,7 +3522,7 @@ moz_gtk_widget_paint(GtkThemeWidgetType
  1181. case MOZ_GTK_DROPDOWN_ENTRY:
  1182. ensure_combo_box_entry_widgets();
  1183. return moz_gtk_entry_paint(cr, rect, state,
  1184. - gComboBoxEntryTextareaWidget, direction);
  1185. + &gComboBoxEntryTextarea, direction);
  1186. break;
  1187. case MOZ_GTK_CHECKBUTTON_CONTAINER:
  1188. case MOZ_GTK_RADIOBUTTON_CONTAINER:
  1189. @@ -3332,7 +3574,7 @@ moz_gtk_widget_paint(GtkThemeWidgetType
  1190. (GtkArrowType) flags, direction);
  1191. break;
  1192. case MOZ_GTK_MENUBAR:
  1193. - return moz_gtk_menu_bar_paint(cr, rect, direction);
  1194. + return moz_gtk_menu_bar_paint(cr, rect, state, direction);
  1195. break;
  1196. case MOZ_GTK_MENUPOPUP:
  1197. return moz_gtk_menu_popup_paint(cr, rect, direction);
  1198. @@ -3383,7 +3625,7 @@ GtkWidget* moz_gtk_get_scrollbar_widget(
  1199. {
  1200. MOZ_ASSERT(is_initialized, "Forgot to call moz_gtk_init()");
  1201. ensure_scrollbar_widget();
  1202. - return gHorizScrollbarWidget;
  1203. + return gVertScrollbar.widget;
  1204. }
  1205. gboolean moz_gtk_has_scrollbar_buttons(void)
  1206. @@ -3391,7 +3633,7 @@ gboolean moz_gtk_has_scrollbar_buttons(v
  1207. gboolean backward, forward, secondary_backward, secondary_forward;
  1208. MOZ_ASSERT(is_initialized, "Forgot to call moz_gtk_init()");
  1209. ensure_scrollbar_widget();
  1210. - gtk_widget_style_get (gHorizScrollbarWidget,
  1211. + gtk_widget_style_get (gHorizScrollbar.widget,
  1212. "has-backward-stepper", &backward,
  1213. "has-forward-stepper", &forward,
  1214. "has-secondary-backward-stepper", &secondary_backward,
  1215. @@ -3403,8 +3645,8 @@ gboolean moz_gtk_has_scrollbar_buttons(v
  1216. gint
  1217. moz_gtk_shutdown()
  1218. {
  1219. - if (gTooltipWidget)
  1220. - gtk_widget_destroy(gTooltipWidget);
  1221. + moz_gtk_widget_free(&gTooltip);
  1222. +
  1223. /* This will destroy all of our widgets */
  1224. if (gProtoWindow)
  1225. gtk_widget_destroy(gProtoWindow);
  1226. @@ -3415,17 +3657,19 @@ moz_gtk_shutdown()
  1227. gProtoWindow = NULL;
  1228. gProtoLayout = NULL;
  1229. - gButtonWidget = NULL;
  1230. +
  1231. + // MozWidgets
  1232. + moz_gtk_widget_free(&gButton);
  1233. gToggleButtonWidget = NULL;
  1234. gButtonArrowWidget = NULL;
  1235. - gCheckboxWidget = NULL;
  1236. - gRadiobuttonWidget = NULL;
  1237. - gHorizScrollbarWidget = NULL;
  1238. - gVertScrollbarWidget = NULL;
  1239. - gSpinWidget = NULL;
  1240. + moz_gtk_widget_free(&gCheckbox);
  1241. + moz_gtk_widget_free(&gRadiobutton);
  1242. + moz_gtk_widget_free(&gHorizScrollbar);
  1243. + moz_gtk_widget_free(&gVertScrollbar);
  1244. + moz_gtk_widget_free(&gSpin);
  1245. gHScaleWidget = NULL;
  1246. gVScaleWidget = NULL;
  1247. - gEntryWidget = NULL;
  1248. + moz_gtk_widget_free(&gEntry);
  1249. gComboBoxWidget = NULL;
  1250. gComboBoxButtonWidget = NULL;
  1251. gComboBoxSeparatorWidget = NULL;
  1252. @@ -3433,14 +3677,13 @@ moz_gtk_shutdown()
  1253. gComboBoxEntryWidget = NULL;
  1254. gComboBoxEntryButtonWidget = NULL;
  1255. gComboBoxEntryArrowWidget = NULL;
  1256. - gComboBoxEntryTextareaWidget = NULL;
  1257. + moz_gtk_widget_free(&gComboBoxEntryTextarea);
  1258. gHandleBoxWidget = NULL;
  1259. gToolbarWidget = NULL;
  1260. gStatusbarWidget = NULL;
  1261. gFrameWidget = NULL;
  1262. - gProgressWidget = NULL;
  1263. + moz_gtk_widget_free(&gProgressBar);
  1264. gTabWidget = NULL;
  1265. - gTooltipWidget = NULL;
  1266. gMenuBarWidget = NULL;
  1267. gMenuBarItemWidget = NULL;
  1268. gMenuPopupWidget = NULL;
  1269. diff -up firefox-46.0.1/widget/gtk/gtkdrawing.h.gtk3-20 firefox-46.0.1/widget/gtk/gtkdrawing.h
  1270. --- firefox-46.0.1/widget/gtk/gtkdrawing.h.gtk3-20 2016-05-03 07:31:12.000000000 +0200
  1271. +++ firefox-46.0.1/widget/gtk/gtkdrawing.h 2016-05-19 15:20:11.656519199 +0200
  1272. @@ -67,6 +67,13 @@ typedef enum {
  1273. MOZ_GTK_TAB_SELECTED = 1 << 10
  1274. } GtkTabFlags;
  1275. +typedef struct {
  1276. + GType type;
  1277. + const gchar *name;
  1278. + const gchar *class1;
  1279. + const gchar *class2;
  1280. +} GtkCssNode;
  1281. +
  1282. /** flags for menuitems **/
  1283. typedef enum {
  1284. /* menuitem is part of the menubar */
  1285. @@ -396,6 +403,9 @@ void
  1286. moz_gtk_get_arrow_size(GtkThemeWidgetType widgetType,
  1287. gint* width, gint* height);
  1288. +gint moz_gtk_get_entry_height(gint* height);
  1289. +gint moz_gtk_get_button_height(gint* height);
  1290. +
  1291. /**
  1292. * Get the desired size of a toolbar separator
  1293. * size: [OUT] the desired width
  1294. @@ -466,6 +476,12 @@ gboolean moz_gtk_images_in_buttons(void)
  1295. */
  1296. gboolean moz_gtk_has_scrollbar_buttons(void);
  1297. +
  1298. +GtkStyleContext *
  1299. +moz_gtk_style_create(GtkCssNode *node, GtkStyleContext *parent);
  1300. +
  1301. +
  1302. +
  1303. #ifdef __cplusplus
  1304. }
  1305. #endif /* __cplusplus */
  1306. diff -up firefox-46.0.1/widget/gtk/mozgtk/mozgtk.c.gtk3-20 firefox-46.0.1/widget/gtk/mozgtk/mozgtk.c
  1307. --- firefox-46.0.1/widget/gtk/mozgtk/mozgtk.c.gtk3-20 2016-05-03 07:31:12.000000000 +0200
  1308. +++ firefox-46.0.1/widget/gtk/mozgtk/mozgtk.c 2016-05-20 10:40:19.442320669 +0200
  1309. @@ -504,6 +504,11 @@ STUB(gtk_window_set_type_hint)
  1310. STUB(gtk_window_set_wmclass)
  1311. STUB(gtk_window_unfullscreen)
  1312. STUB(gtk_window_unmaximize)
  1313. +STUB(gtk_widget_get_preferred_height_and_baseline_for_width)
  1314. +STUB(gtk_entry_get_text_area)
  1315. +STUB(gtk_check_menu_item_get_type)
  1316. +STUB(gtk_spin_button_get_type)
  1317. +STUB(gtk_button_get_type)
  1318. #endif
  1319. #ifdef GTK3_SYMBOLS
  1320. @@ -581,6 +586,14 @@ STUB(gtk_color_chooser_get_type)
  1321. STUB(gtk_color_chooser_set_rgba)
  1322. STUB(gtk_color_chooser_get_rgba)
  1323. STUB(gtk_color_chooser_set_use_alpha)
  1324. +STUB(gtk_style_context_get_path)
  1325. +STUB(gtk_widget_path_copy)
  1326. +STUB(gtk_widget_path_iter_set_object_name)
  1327. +STUB(gtk_widget_path_iter_add_class)
  1328. +STUB(gtk_widget_path_iter_get_state)
  1329. +STUB(gtk_style_context_set_parent)
  1330. +STUB(gtk_widget_path_unref)
  1331. +STUB(gtk_tooltip_get_type)
  1332. #endif
  1333. #ifdef GTK2_SYMBOLS
  1334. diff -up firefox-46.0.1/widget/gtk/nsLookAndFeel.cpp.gtk3-20 firefox-46.0.1/widget/gtk/nsLookAndFeel.cpp
  1335. --- firefox-46.0.1/widget/gtk/nsLookAndFeel.cpp.gtk3-20 2016-05-03 07:31:12.000000000 +0200
  1336. +++ firefox-46.0.1/widget/gtk/nsLookAndFeel.cpp 2016-05-20 13:53:54.085049707 +0200
  1337. @@ -353,14 +353,18 @@ nsLookAndFeel::NativeGetColor(ColorID aI
  1338. case eColorID_activeborder:
  1339. // active window border
  1340. gtk_style_context_get_border_color(mBackgroundStyle,
  1341. - GTK_STATE_FLAG_NORMAL, &gdk_color);
  1342. + gtk_style_context_get_state(mBackgroundStyle),
  1343. + &gdk_color);
  1344. aColor = GDK_RGBA_TO_NS_RGBA(gdk_color);
  1345. break;
  1346. case eColorID_inactiveborder:
  1347. // inactive window border
  1348. + gtk_style_context_save(mBackgroundStyle);
  1349. + gtk_style_context_set_state(mBackgroundStyle, GTK_STATE_FLAG_INSENSITIVE);
  1350. gtk_style_context_get_border_color(mBackgroundStyle,
  1351. - GTK_STATE_FLAG_INSENSITIVE,
  1352. + gtk_style_context_get_state(mBackgroundStyle),
  1353. &gdk_color);
  1354. + gtk_style_context_restore(mBackgroundStyle);
  1355. aColor = GDK_RGBA_TO_NS_RGBA(gdk_color);
  1356. break;
  1357. case eColorID_graytext: // disabled text in windows, menus, etc.
  1358. @@ -369,9 +373,12 @@ nsLookAndFeel::NativeGetColor(ColorID aI
  1359. break;
  1360. case eColorID_inactivecaption:
  1361. // inactive window caption
  1362. + gtk_style_context_save(mBackgroundStyle);
  1363. + gtk_style_context_set_state(mBackgroundStyle, GTK_STATE_FLAG_INSENSITIVE);
  1364. gtk_style_context_get_background_color(mBackgroundStyle,
  1365. - GTK_STATE_FLAG_INSENSITIVE,
  1366. + gtk_style_context_get_state(mBackgroundStyle),
  1367. &gdk_color);
  1368. + gtk_style_context_restore(mBackgroundStyle);
  1369. aColor = GDK_RGBA_TO_NS_RGBA(gdk_color);
  1370. break;
  1371. #endif
  1372. @@ -497,13 +504,17 @@ nsLookAndFeel::NativeGetColor(ColorID aI
  1373. case eColorID__moz_buttondefault:
  1374. // default button border color
  1375. gtk_style_context_get_border_color(mButtonStyle,
  1376. - GTK_STATE_FLAG_NORMAL, &gdk_color);
  1377. + gtk_style_context_get_state(mButtonStyle),
  1378. + &gdk_color);
  1379. aColor = GDK_RGBA_TO_NS_RGBA(gdk_color);
  1380. break;
  1381. case eColorID__moz_buttonhoverface:
  1382. + gtk_style_context_save(mButtonStyle);
  1383. + gtk_style_context_set_state(mButtonStyle, GTK_STATE_FLAG_PRELIGHT);
  1384. gtk_style_context_get_background_color(mButtonStyle,
  1385. - GTK_STATE_FLAG_PRELIGHT,
  1386. + gtk_style_context_get_state(mButtonStyle),
  1387. &gdk_color);
  1388. + gtk_style_context_restore(mButtonStyle);
  1389. aColor = GDK_RGBA_TO_NS_RGBA(gdk_color);
  1390. break;
  1391. case eColorID__moz_buttonhovertext:
  1392. @@ -1110,27 +1126,29 @@ nsLookAndFeel::Init()
  1393. style = create_context(path);
  1394. gtk_style_context_add_class(style, GTK_STYLE_CLASS_SCROLLBAR);
  1395. gtk_style_context_add_class(style, GTK_STYLE_CLASS_TROUGH);
  1396. - gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
  1397. + gtk_style_context_get_background_color(style, gtk_style_context_get_state(style), &color);
  1398. sMozScrollbar = GDK_RGBA_TO_NS_RGBA(color);
  1399. g_object_unref(style);
  1400. // Window colors
  1401. style = create_context(path);
  1402. - gtk_style_context_save(style);
  1403. gtk_style_context_add_class(style, GTK_STYLE_CLASS_BACKGROUND);
  1404. - gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
  1405. + gtk_style_context_get_background_color(style, gtk_style_context_get_state(style), &color);
  1406. sMozWindowBackground = GDK_RGBA_TO_NS_RGBA(color);
  1407. - gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
  1408. + gtk_style_context_get_color(style, gtk_style_context_get_state(style), &color);
  1409. sMozWindowText = GDK_RGBA_TO_NS_RGBA(color);
  1410. - gtk_style_context_restore(style);
  1411. + g_object_unref(style);
  1412. // tooltip foreground and background
  1413. - gtk_style_context_add_class(style, GTK_STYLE_CLASS_TOOLTIP);
  1414. + GtkCssNode tooltipPath[] = {
  1415. + { GTK_TYPE_TOOLTIP, "tooltip", NULL, NULL},
  1416. + };
  1417. + style = moz_gtk_style_create(tooltipPath, NULL);
  1418. + gtk_style_context_get_color(style, gtk_style_context_get_state(style), &color);
  1419. + sInfoText = GDK_RGBA_TO_NS_RGBA(color);
  1420. gtk_style_context_add_class(style, GTK_STYLE_CLASS_BACKGROUND);
  1421. - gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
  1422. + gtk_style_context_get_background_color(style, gtk_style_context_get_state(style), &color);
  1423. sInfoBackground = GDK_RGBA_TO_NS_RGBA(color);
  1424. - gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
  1425. - sInfoText = GDK_RGBA_TO_NS_RGBA(color);
  1426. g_object_unref(style);
  1427. // menu foreground & menu background
  1428. @@ -1144,20 +1162,26 @@ nsLookAndFeel::Init()
  1429. gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
  1430. style = gtk_widget_get_style_context(accel_label);
  1431. - gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
  1432. + gtk_style_context_get_color(style, gtk_style_context_get_state(style), &color);
  1433. sMenuText = GDK_RGBA_TO_NS_RGBA(color);
  1434. - gtk_style_context_get_color(style, GTK_STATE_FLAG_INSENSITIVE, &color);
  1435. + gtk_style_context_save(style);
  1436. + gtk_style_context_set_state(style, GTK_STATE_FLAG_INSENSITIVE);
  1437. + gtk_style_context_get_color(style, gtk_style_context_get_state(style), &color);
  1438. sMenuTextInactive = GDK_RGBA_TO_NS_RGBA(color);
  1439. + gtk_style_context_restore(style);
  1440. style = gtk_widget_get_style_context(menu);
  1441. - gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
  1442. + gtk_style_context_get_background_color(style, gtk_style_context_get_state(style), &color);
  1443. sMenuBackground = GDK_RGBA_TO_NS_RGBA(color);
  1444. style = gtk_widget_get_style_context(menuitem);
  1445. - gtk_style_context_get_background_color(style, GTK_STATE_FLAG_PRELIGHT, &color);
  1446. + gtk_style_context_save(style);
  1447. + gtk_style_context_set_state(style, GTK_STATE_FLAG_PRELIGHT);
  1448. + gtk_style_context_get_background_color(style, gtk_style_context_get_state(style), &color);
  1449. sMenuHover = GDK_RGBA_TO_NS_RGBA(color);
  1450. - gtk_style_context_get_color(style, GTK_STATE_FLAG_PRELIGHT, &color);
  1451. + gtk_style_context_get_color(style, gtk_style_context_get_state(style), &color);
  1452. sMenuHoverText = GDK_RGBA_TO_NS_RGBA(color);
  1453. + gtk_style_context_restore(style);
  1454. g_object_unref(menu);
  1455. #endif
  1456. @@ -1266,44 +1290,54 @@ nsLookAndFeel::Init()
  1457. GDK_COLOR_TO_NS_RGB(style->dark[GTK_STATE_NORMAL]);
  1458. }
  1459. #else
  1460. + GtkCssNode labelPath[] = {
  1461. + { GTK_TYPE_LABEL, "label", "view", NULL },
  1462. + { G_TYPE_NONE, "selection", NULL, NULL }
  1463. + };
  1464. +
  1465. + GtkStyleContext *styleLabel;
  1466. + GtkStyleContext *styleSelection;
  1467. + GtkBorder padding;
  1468. +
  1469. // Text colors
  1470. - style = gtk_widget_get_style_context(textView);
  1471. - gtk_style_context_save(style);
  1472. - gtk_style_context_add_class(style, GTK_STYLE_CLASS_VIEW);
  1473. - gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
  1474. + styleLabel = moz_gtk_style_create(labelPath, NULL);
  1475. + styleSelection = moz_gtk_style_create(labelPath+1, styleLabel);
  1476. +
  1477. + gtk_style_context_get_background_color(styleLabel, gtk_style_context_get_state(styleLabel), &color);
  1478. sMozFieldBackground = GDK_RGBA_TO_NS_RGBA(color);
  1479. - gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
  1480. + gtk_style_context_get_color(styleLabel, gtk_style_context_get_state(styleLabel), &color);
  1481. sMozFieldText = GDK_RGBA_TO_NS_RGBA(color);
  1482. // Selected text and background
  1483. - gtk_style_context_get_background_color(style,
  1484. - static_cast<GtkStateFlags>(GTK_STATE_FLAG_FOCUSED|GTK_STATE_FLAG_SELECTED),
  1485. - &color);
  1486. + gtk_style_context_get_background_color(styleSelection, gtk_style_context_get_state(styleSelection), &color);
  1487. sTextSelectedBackground = GDK_RGBA_TO_NS_RGBA(color);
  1488. - gtk_style_context_get_color(style,
  1489. - static_cast<GtkStateFlags>(GTK_STATE_FLAG_FOCUSED|GTK_STATE_FLAG_SELECTED),
  1490. - &color);
  1491. + gtk_style_context_get_color(styleSelection, gtk_style_context_get_state(styleSelection), &color);
  1492. sTextSelectedText = GDK_RGBA_TO_NS_RGBA(color);
  1493. - gtk_style_context_restore(style);
  1494. // Button text, background, border
  1495. style = gtk_widget_get_style_context(label);
  1496. - gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
  1497. + gtk_style_context_get_color(style, gtk_style_context_get_state(style), &color);
  1498. sButtonText = GDK_RGBA_TO_NS_RGBA(color);
  1499. - gtk_style_context_get_color(style, GTK_STATE_FLAG_PRELIGHT, &color);
  1500. + gtk_style_context_save(style);
  1501. + gtk_style_context_set_state(style, GTK_STATE_FLAG_PRELIGHT);
  1502. + gtk_style_context_get_color(style, gtk_style_context_get_state(style), &color);
  1503. sButtonHoverText = GDK_RGBA_TO_NS_RGBA(color);
  1504. + gtk_style_context_restore(style);
  1505. // Combobox text color
  1506. style = gtk_widget_get_style_context(comboboxLabel);
  1507. - gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
  1508. + gtk_style_context_get_color(style, gtk_style_context_get_state(style), &color);
  1509. sComboBoxText = GDK_RGBA_TO_NS_RGBA(color);
  1510. // Menubar text and hover text colors
  1511. style = gtk_widget_get_style_context(menuBar);
  1512. - gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
  1513. + gtk_style_context_get_color(style, gtk_style_context_get_state(style), &color);
  1514. sMenuBarText = GDK_RGBA_TO_NS_RGBA(color);
  1515. - gtk_style_context_get_color(style, GTK_STATE_FLAG_PRELIGHT, &color);
  1516. + gtk_style_context_save(style);
  1517. + gtk_style_context_set_state(style, GTK_STATE_FLAG_PRELIGHT);
  1518. + gtk_style_context_get_color(style, gtk_style_context_get_state(style), &color);
  1519. sMenuBarHoverText = GDK_RGBA_TO_NS_RGBA(color);
  1520. + gtk_style_context_restore(style);
  1521. // GTK's guide to fancy odd row background colors:
  1522. // 1) Check if a theme explicitly defines an odd row color
  1523. @@ -1316,7 +1350,7 @@ nsLookAndFeel::Init()
  1524. // Get odd row background color
  1525. gtk_style_context_save(style);
  1526. gtk_style_context_add_region(style, GTK_STYLE_REGION_ROW, GTK_REGION_ODD);
  1527. - gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
  1528. + gtk_style_context_get_background_color(style, gtk_style_context_get_state(style), &color);
  1529. sOddCellBackground = GDK_RGBA_TO_NS_RGBA(color);
  1530. gtk_style_context_restore(style);
  1531. @@ -1334,9 +1368,11 @@ nsLookAndFeel::Init()
  1532. gtk_container_add(GTK_CONTAINER(parent), infoBar);
  1533. gtk_container_add(GTK_CONTAINER(infoBarContent), infoBarLabel);
  1534. style = gtk_widget_get_style_context(infoBarLabel);
  1535. + gtk_style_context_save(style);
  1536. gtk_style_context_add_class(style, GTK_STYLE_CLASS_INFO);
  1537. - gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
  1538. + gtk_style_context_get_color(style, gtk_style_context_get_state(style), &color);
  1539. sInfoBarText = GDK_RGBA_TO_NS_RGBA(color);
  1540. + gtk_style_context_restore(style);
  1541. #endif
  1542. // Some themes have a unified menu bar, and support window dragging on it
  1543. gboolean supports_menubar_drag = FALSE;
  1544. diff -up firefox-46.0.1/widget/gtk/nsNativeThemeGTK.cpp.gtk3-20 firefox-46.0.1/widget/gtk/nsNativeThemeGTK.cpp
  1545. --- firefox-46.0.1/widget/gtk/nsNativeThemeGTK.cpp.gtk3-20 2016-05-03 07:31:12.000000000 +0200
  1546. +++ firefox-46.0.1/widget/gtk/nsNativeThemeGTK.cpp 2016-05-19 15:20:11.658519202 +0200
  1547. @@ -1567,9 +1567,6 @@ nsNativeThemeGTK::GetMinimumWidgetSize(n
  1548. case NS_THEME_RADIO_CONTAINER:
  1549. case NS_THEME_CHECKBOX_LABEL:
  1550. case NS_THEME_RADIO_LABEL:
  1551. - case NS_THEME_BUTTON:
  1552. - case NS_THEME_DROPDOWN:
  1553. - case NS_THEME_TOOLBAR_BUTTON:
  1554. case NS_THEME_TREEVIEW_HEADER_CELL:
  1555. {
  1556. if (aWidgetType == NS_THEME_DROPDOWN) {
  1557. @@ -1588,6 +1585,21 @@ nsNativeThemeGTK::GetMinimumWidgetSize(n
  1558. aResult->height += border.top + border.bottom;
  1559. }
  1560. break;
  1561. + case NS_THEME_BUTTON:
  1562. + case NS_THEME_DROPDOWN:
  1563. + case NS_THEME_TOOLBAR_BUTTON:
  1564. + {
  1565. + moz_gtk_get_button_height(&aResult->height);
  1566. + }
  1567. + break;
  1568. + case NS_THEME_FOCUS_OUTLINE:
  1569. + case NS_THEME_NUMBER_INPUT:
  1570. + case NS_THEME_TEXTFIELD:
  1571. + case NS_THEME_TEXTFIELD_MULTILINE:
  1572. + {
  1573. + moz_gtk_get_entry_height(&aResult->height);
  1574. + }
  1575. + break;
  1576. case NS_THEME_TOOLBAR_SEPARATOR:
  1577. {
  1578. gint separator_width;