Changeset 194370 in webkit
- Timestamp:
- Dec 22, 2015, 12:37:33 PM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r194369 r194370 1 2015-12-22 Commit Queue <commit-queue@webkit.org> 2 3 Unreviewed, rolling out r194362. 4 https://bugs.webkit.org/show_bug.cgi?id=152508 5 6 crashes release bot (Requested by mcatanzaro on #webkit). 7 8 Reverted changeset: 9 10 "[GTK] Everything broken in GTK+ 3.19" 11 https://bugs.webkit.org/show_bug.cgi?id=150550 12 http://trac.webkit.org/changeset/194362 13 1 14 2015-12-22 Keith Miller <keith_miller@apple.com> 2 15 -
trunk/Source/WebCore/platform/gtk/GRefPtrGtk.cpp
r194362 r194370 73 73 gdk_cursor_unref(ptr); 74 74 } 75 76 #else77 78 template <> GtkWidgetPath* refGPtr(GtkWidgetPath* ptr)79 {80 if (ptr)81 gtk_widget_path_ref(ptr);82 return ptr;83 }84 85 template <> void derefGPtr(GtkWidgetPath* ptr)86 {87 if (ptr)88 gtk_widget_path_unref(ptr);89 }90 91 75 #endif 92 76 -
trunk/Source/WebCore/platform/gtk/GRefPtrGtk.h
r194362 r194370 24 24 #include <wtf/glib/GRefPtr.h> 25 25 26 typedef struct _GtkWidgetPath GtkWidgetPath;27 26 typedef struct _SecretValue SecretValue; 28 27 … … 40 39 template <> GdkCursor* refGPtr(GdkCursor* ptr); 41 40 template <> void derefGPtr(GdkCursor* ptr); 42 #else43 template <> GtkWidgetPath* refGPtr(GtkWidgetPath* ptr);44 template <> void derefGPtr(GtkWidgetPath* ptr);45 41 #endif 46 42 -
trunk/Source/WebCore/platform/gtk/ScrollbarThemeGtk.cpp
r194362 r194370 164 164 165 165 #ifndef GTK_API_VERSION_2 166 167 #if !GTK_CHECK_VERSION(3, 19, 2)168 // Currently we use a static GtkStyleContext for GTK+ < 3.19, and a bunch of unique169 // GtkStyleContexts for GTK+ >= 3.19. This is crazy and definitely should not be necessary, but I170 // couldn't find any other way to not break one version or the other. Ideally one of the two171 // people on the planet who really understand GTK+ styles would fix this.172 166 class ScrollbarStyleContext { 173 167 WTF_MAKE_NONCOPYABLE(ScrollbarStyleContext); WTF_MAKE_FAST_ALLOCATED; … … 198 192 return styleContext.get().context(); 199 193 } 200 #endif201 194 202 195 ScrollbarThemeGtk::ScrollbarThemeGtk() … … 207 200 void ScrollbarThemeGtk::themeChanged() 208 201 { 209 #if !GTK_CHECK_VERSION(3, 19, 2)210 202 gtk_style_context_invalidate(gtkScrollbarStyleContext()); 211 #endif212 203 updateThemeProperties(); 213 204 } … … 215 206 void ScrollbarThemeGtk::updateThemeProperties() 216 207 { 217 #if GTK_CHECK_VERSION(3, 19, 2)218 GRefPtr<GtkStyleContext> styleContext = adoptGRef(gtk_style_context_new());219 GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new());220 221 gtk_widget_path_append_type(path.get(), GTK_TYPE_SCROLLBAR);222 gtk_widget_path_iter_set_object_name(path.get(), 0, "scrollbar");223 224 gtk_style_context_set_path(styleContext.get(), path.get());225 #else226 GRefPtr<GtkStyleContext> styleContext = gtkScrollbarStyleContext();227 #endif228 229 208 gtk_style_context_get_style( 230 styleContext.get(),209 gtkScrollbarStyleContext(), 231 210 "min-slider-length", &m_minThumbLength, 232 211 "slider-width", &m_thumbFatness, … … 294 273 } 295 274 296 297 static const char* orientationStyleClass(ScrollbarOrientation orientation)298 {299 return orientation == VerticalScrollbar ? "vertical" : "horizontal";300 }301 302 #if !GTK_CHECK_VERSION(3, 19, 2)303 275 static void applyScrollbarStyleContextClasses(GtkStyleContext* context, ScrollbarOrientation orientation) 304 276 { 305 277 gtk_style_context_add_class(context, GTK_STYLE_CLASS_SCROLLBAR); 306 gtk_style_context_add_class(context, orientationStyleClass(orientation)); 307 } 308 #endif 278 gtk_style_context_add_class(context, orientation == VerticalScrollbar ? GTK_STYLE_CLASS_VERTICAL : GTK_STYLE_CLASS_HORIZONTAL); 279 } 309 280 310 281 static void adjustRectAccordingToMargin(GtkStyleContext* context, GtkStateFlags state, IntRect& rect) … … 326 297 fullScrollbarRect = IntRect(scrollbar.x(), scrollbar.y(), scrollbar.width(), scrollbar.height()); 327 298 328 #if GTK_CHECK_VERSION(3, 19, 2) 329 GRefPtr<GtkStyleContext> styleContext = adoptGRef(gtk_style_context_new()); 330 GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new()); 331 332 gtk_widget_path_append_type(path.get(), GTK_TYPE_SCROLLBAR); 333 gtk_widget_path_iter_set_object_name(path.get(), 0, "scrollbar"); 334 gtk_widget_path_iter_add_class(path.get(), 0, orientationStyleClass(scrollbar.orientation())); 335 336 gtk_widget_path_append_type(path.get(), GTK_TYPE_SCROLLBAR); 337 gtk_widget_path_iter_set_object_name(path.get(), 1, "trough"); 338 339 gtk_style_context_set_path(styleContext.get(), path.get()); 340 #else 341 GRefPtr<GtkStyleContext> styleContext = gtkScrollbarStyleContext(); 342 gtk_style_context_save(styleContext.get()); 343 344 applyScrollbarStyleContextClasses(styleContext.get(), scrollbar.orientation()); 345 gtk_style_context_add_class(styleContext.get(), GTK_STYLE_CLASS_TROUGH); 346 #endif 347 348 adjustRectAccordingToMargin(styleContext.get(), static_cast<GtkStateFlags>(0), fullScrollbarRect); 349 gtk_render_background(styleContext.get(), context.platformContext()->cr(), fullScrollbarRect.x(), fullScrollbarRect.y(), fullScrollbarRect.width(), fullScrollbarRect.height()); 350 gtk_render_frame(styleContext.get(), context.platformContext()->cr(), fullScrollbarRect.x(), fullScrollbarRect.y(), fullScrollbarRect.width(), fullScrollbarRect.height()); 351 352 #if !GTK_CHECK_VERSION(3, 19, 2) 353 gtk_style_context_restore(styleContext.get()); 354 #endif 299 GtkStyleContext* styleContext = gtkScrollbarStyleContext(); 300 gtk_style_context_save(styleContext); 301 302 applyScrollbarStyleContextClasses(styleContext, scrollbar.orientation()); 303 gtk_style_context_add_class(styleContext, GTK_STYLE_CLASS_TROUGH); 304 305 adjustRectAccordingToMargin(styleContext, static_cast<GtkStateFlags>(0), fullScrollbarRect); 306 gtk_render_background(styleContext, context.platformContext()->cr(), fullScrollbarRect.x(), fullScrollbarRect.y(), fullScrollbarRect.width(), fullScrollbarRect.height()); 307 gtk_render_frame(styleContext, context.platformContext()->cr(), fullScrollbarRect.x(), fullScrollbarRect.y(), fullScrollbarRect.width(), fullScrollbarRect.height()); 308 309 gtk_style_context_restore(styleContext); 355 310 } 356 311 357 312 void ScrollbarThemeGtk::paintScrollbarBackground(GraphicsContext& context, Scrollbar& scrollbar) 358 313 { 359 #if GTK_CHECK_VERSION(3, 19, 2) 360 GRefPtr<GtkStyleContext> styleContext = adoptGRef(gtk_style_context_new()); 361 GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new()); 362 363 gtk_widget_path_append_type(path.get(), GTK_TYPE_SCROLLBAR); 364 gtk_widget_path_iter_set_object_name(path.get(), 0, "scrollbar"); 365 gtk_widget_path_iter_add_class(path.get(), 0, orientationStyleClass(scrollbar.orientation())); 366 367 gtk_style_context_set_path(styleContext.get(), path.get()); 368 #else 369 GRefPtr<GtkStyleContext> styleContext = gtkScrollbarStyleContext(); 370 gtk_style_context_save(styleContext.get()); 371 372 applyScrollbarStyleContextClasses(styleContext.get(), scrollbar.orientation()); 373 gtk_style_context_add_class(styleContext.get(), "scrolled-window"); 374 #endif 375 376 gtk_render_frame(styleContext.get(), context.platformContext()->cr(), scrollbar.x(), scrollbar.y(), scrollbar.width(), scrollbar.height()); 377 378 #if !GTK_CHECK_VERSION(3, 19, 2) 379 gtk_style_context_restore(styleContext.get()); 380 #endif 314 GtkStyleContext* styleContext = gtkScrollbarStyleContext(); 315 gtk_style_context_save(styleContext); 316 317 applyScrollbarStyleContextClasses(styleContext, scrollbar.orientation()); 318 gtk_style_context_add_class(styleContext, "scrolled-window"); 319 gtk_render_frame(styleContext, context.platformContext()->cr(), scrollbar.x(), scrollbar.y(), scrollbar.width(), scrollbar.height()); 320 321 gtk_style_context_restore(styleContext); 381 322 } 382 323 383 324 void ScrollbarThemeGtk::paintThumb(GraphicsContext& context, Scrollbar& scrollbar, const IntRect& rect) 384 325 { 385 #if GTK_CHECK_VERSION(3, 19, 2) 386 GRefPtr<GtkStyleContext> styleContext = adoptGRef(gtk_style_context_new()); 387 GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new()); 388 389 gtk_widget_path_append_type(path.get(), GTK_TYPE_SCROLLBAR); 390 gtk_widget_path_iter_set_object_name(path.get(), 0, "scrollbar"); 391 gtk_widget_path_iter_add_class(path.get(), 0, orientationStyleClass(scrollbar.orientation())); 392 393 gtk_widget_path_append_type(path.get(), GTK_TYPE_SCROLLBAR); 394 gtk_widget_path_iter_set_object_name(path.get(), 1, "trough"); 395 396 gtk_widget_path_append_type(path.get(), GTK_TYPE_SCROLLBAR); 397 gtk_widget_path_iter_set_object_name(path.get(), 2, "slider"); 398 399 gtk_style_context_set_path(styleContext.get(), path.get()); 400 #else 401 GRefPtr<GtkStyleContext> styleContext = gtkScrollbarStyleContext(); 402 gtk_style_context_save(styleContext.get()); 403 #endif 326 GtkStyleContext* styleContext = gtkScrollbarStyleContext(); 327 gtk_style_context_save(styleContext); 404 328 405 329 ScrollbarOrientation orientation = scrollbar.orientation(); 406 #if !GTK_CHECK_VERSION(3, 19, 2) 407 applyScrollbarStyleContextClasses(styleContext.get(), orientation); 408 gtk_style_context_add_class(styleContext.get(), GTK_STYLE_CLASS_SLIDER); 409 #endif 330 applyScrollbarStyleContextClasses(styleContext, orientation); 331 gtk_style_context_add_class(styleContext, GTK_STYLE_CLASS_SLIDER); 410 332 411 333 guint flags = 0; … … 414 336 if (scrollbar.hoveredPart() == ThumbPart) 415 337 flags |= GTK_STATE_FLAG_PRELIGHT; 416 gtk_style_context_set_state(styleContext .get(), static_cast<GtkStateFlags>(flags));338 gtk_style_context_set_state(styleContext, static_cast<GtkStateFlags>(flags)); 417 339 418 340 IntRect thumbRect(rect); 419 adjustRectAccordingToMargin(styleContext .get(), static_cast<GtkStateFlags>(flags), thumbRect);420 gtk_render_slider(styleContext .get(), context.platformContext()->cr(), thumbRect.x(), thumbRect.y(), thumbRect.width(), thumbRect.height(),341 adjustRectAccordingToMargin(styleContext, static_cast<GtkStateFlags>(flags), thumbRect); 342 gtk_render_slider(styleContext, context.platformContext()->cr(), thumbRect.x(), thumbRect.y(), thumbRect.width(), thumbRect.height(), 421 343 orientation == VerticalScrollbar ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL); 422 344 423 #if !GTK_CHECK_VERSION(3, 19, 2) 424 gtk_style_context_restore(styleContext.get()); 425 #endif 345 gtk_style_context_restore(styleContext); 426 346 } 427 347 428 348 void ScrollbarThemeGtk::paintButton(GraphicsContext& context, Scrollbar& scrollbar, const IntRect& rect, ScrollbarPart part) 429 349 { 430 #if GTK_CHECK_VERSION(3, 19, 2) 431 GRefPtr<GtkStyleContext> styleContext = adoptGRef(gtk_style_context_new()); 432 GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new()); 433 434 gtk_widget_path_append_type(path.get(), GTK_TYPE_SCROLLBAR); 435 gtk_widget_path_iter_set_object_name(path.get(), 0, "scrollbar"); 436 gtk_widget_path_iter_add_class(path.get(), 0, orientationStyleClass(scrollbar.orientation())); 437 438 gtk_widget_path_append_type(path.get(), GTK_TYPE_SCROLLBAR); 439 gtk_widget_path_iter_set_object_name(path.get(), 1, "button"); 440 441 gtk_style_context_set_path(styleContext.get(), path.get()); 442 #else 443 GRefPtr<GtkStyleContext> styleContext = gtkScrollbarStyleContext(); 444 gtk_style_context_save(styleContext.get()); 445 #endif 350 GtkStyleContext* styleContext = gtkScrollbarStyleContext(); 351 gtk_style_context_save(styleContext); 446 352 447 353 ScrollbarOrientation orientation = scrollbar.orientation(); 448 #if !GTK_CHECK_VERSION(3, 19, 2) 449 applyScrollbarStyleContextClasses(styleContext.get(), orientation); 450 #endif 354 applyScrollbarStyleContextClasses(styleContext, orientation); 451 355 452 356 guint flags = 0; … … 461 365 } else 462 366 flags |= GTK_STATE_FLAG_INSENSITIVE; 463 gtk_style_context_set_state(styleContext.get(), static_cast<GtkStateFlags>(flags)); 464 465 #if !GTK_CHECK_VERSION(3, 19, 2) 466 gtk_style_context_add_class(styleContext.get(), GTK_STYLE_CLASS_BUTTON); 467 #endif 468 469 gtk_render_background(styleContext.get(), context.platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height()); 470 gtk_render_frame(styleContext.get(), context.platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height()); 367 gtk_style_context_set_state(styleContext, static_cast<GtkStateFlags>(flags)); 368 369 gtk_style_context_add_class(styleContext, GTK_STYLE_CLASS_BUTTON); 370 gtk_render_background(styleContext, context.platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height()); 371 gtk_render_frame(styleContext, context.platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height()); 471 372 472 373 gfloat arrowScaling; 473 gtk_style_context_get_style(styleContext .get(), "arrow-scaling", &arrowScaling, nullptr);374 gtk_style_context_get_style(styleContext, "arrow-scaling", &arrowScaling, nullptr); 474 375 475 376 double arrowSize = std::min(rect.width(), rect.height()) * arrowScaling; … … 480 381 if (flags & GTK_STATE_FLAG_ACTIVE) { 481 382 gint arrowDisplacementX, arrowDisplacementY; 482 gtk_style_context_get_style(styleContext .get(), "arrow-displacement-x", &arrowDisplacementX, "arrow-displacement-y", &arrowDisplacementY, nullptr);383 gtk_style_context_get_style(styleContext, "arrow-displacement-x", &arrowDisplacementX, "arrow-displacement-y", &arrowDisplacementY, nullptr); 483 384 arrowPoint.move(arrowDisplacementX, arrowDisplacementY); 484 385 } … … 490 391 angle = (part == ForwardButtonEndPart || part == ForwardButtonStartPart) ? G_PI / 2 : 3 * (G_PI / 2); 491 392 492 gtk_render_arrow(styleContext.get(), context.platformContext()->cr(), angle, arrowPoint.x(), arrowPoint.y(), arrowSize); 493 494 #if !GTK_CHECK_VERSION(3, 19, 2) 495 gtk_style_context_restore(styleContext.get()); 496 #endif 393 gtk_render_arrow(styleContext, context.platformContext()->cr(), angle, arrowPoint.x(), arrowPoint.y(), arrowSize); 394 395 gtk_style_context_restore(styleContext); 497 396 } 498 397 -
trunk/Source/WebCore/rendering/RenderThemeGtk.cpp
r194362 r194370 153 153 } 154 154 155 GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new()); 156 gtk_widget_path_append_type(path.get(), widgetType); 157 158 #if GTK_CHECK_VERSION(3, 19, 2) 159 // Pick a good default object path for the style context based on the widget type. This will 160 // usually need to be overridden manually, but it doesn't hurt to have a good default. 155 GtkWidgetPath* path = gtk_widget_path_new(); 156 gtk_widget_path_append_type(path, widgetType); 157 161 158 if (widgetType == GTK_TYPE_ENTRY) 162 gtk_widget_path_iter_ set_object_name(path.get(), 0, "entry");159 gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_ENTRY); 163 160 else if (widgetType == GTK_TYPE_ARROW) 164 gtk_widget_path_iter_ set_object_name(path.get(), 0, "button"); // Note: not a typo.161 gtk_widget_path_iter_add_class(path, 0, "arrow"); 165 162 else if (widgetType == GTK_TYPE_BUTTON) { 166 gtk_widget_path_iter_ set_object_name(path.get(), 0, "button");167 gtk_widget_path_iter_add_class(path .get(), 0, "text-button");163 gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_BUTTON); 164 gtk_widget_path_iter_add_class(path, 0, "text-button"); 168 165 } else if (widgetType == GTK_TYPE_SCALE) 169 gtk_widget_path_iter_ set_object_name(path.get(), 0, "scale");166 gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_SCALE); 170 167 else if (widgetType == GTK_TYPE_SEPARATOR) 171 gtk_widget_path_iter_ set_object_name(path.get(), 0, "separator");168 gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_SEPARATOR); 172 169 else if (widgetType == GTK_TYPE_PROGRESS_BAR) 173 gtk_widget_path_iter_ set_object_name(path.get(), 0, "progressbar");170 gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_PROGRESSBAR); 174 171 else if (widgetType == GTK_TYPE_SPIN_BUTTON) 175 gtk_widget_path_iter_set_object_name(path.get(), 0, "spinbutton"); 176 else if (widgetType == GTK_TYPE_TREE_VIEW) { 177 gtk_widget_path_iter_set_object_name(path.get(), 0, "treeview"); 178 gtk_widget_path_iter_add_class(path.get(), 0, "view"); 179 } else if (widgetType == GTK_TYPE_CHECK_BUTTON) 180 gtk_widget_path_iter_set_object_name(path.get(), 0, "checkbutton"); 172 gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_SPINBUTTON); 173 else if (widgetType == GTK_TYPE_TREE_VIEW) 174 gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_VIEW); 175 else if (widgetType == GTK_TYPE_CHECK_BUTTON) 176 gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_CHECK); 181 177 else if (widgetType == GTK_TYPE_RADIO_BUTTON) 182 gtk_widget_path_iter_set_object_name(path.get(), 0, "radiobutton"); 183 else if (widgetType == GTK_TYPE_COMBO_BOX) 184 gtk_widget_path_iter_set_object_name(path.get(), 0, "combobox"); 185 #else 186 if (widgetType == GTK_TYPE_ENTRY) 187 gtk_widget_path_iter_add_class(path.get(), 0, GTK_STYLE_CLASS_ENTRY); 188 else if (widgetType == GTK_TYPE_ARROW) 189 gtk_widget_path_iter_add_class(path.get(), 0, "arrow"); 190 else if (widgetType == GTK_TYPE_BUTTON) { 191 gtk_widget_path_iter_add_class(path.get(), 0, GTK_STYLE_CLASS_BUTTON); 192 gtk_widget_path_iter_add_class(path.get(), 0, "text-button"); 193 } else if (widgetType == GTK_TYPE_SCALE) 194 gtk_widget_path_iter_add_class(path.get(), 0, GTK_STYLE_CLASS_SCALE); 195 else if (widgetType == GTK_TYPE_SEPARATOR) 196 gtk_widget_path_iter_add_class(path.get(), 0, GTK_STYLE_CLASS_SEPARATOR); 197 else if (widgetType == GTK_TYPE_PROGRESS_BAR) 198 gtk_widget_path_iter_add_class(path.get(), 0, GTK_STYLE_CLASS_PROGRESSBAR); 199 else if (widgetType == GTK_TYPE_SPIN_BUTTON) 200 gtk_widget_path_iter_add_class(path.get(), 0, GTK_STYLE_CLASS_SPINBUTTON); 201 else if (widgetType == GTK_TYPE_TREE_VIEW) 202 gtk_widget_path_iter_add_class(path.get(), 0, GTK_STYLE_CLASS_VIEW); 203 else if (widgetType == GTK_TYPE_CHECK_BUTTON) 204 gtk_widget_path_iter_add_class(path.get(), 0, GTK_STYLE_CLASS_CHECK); 205 else if (widgetType == GTK_TYPE_RADIO_BUTTON) 206 gtk_widget_path_iter_add_class(path.get(), 0, GTK_STYLE_CLASS_RADIO); 207 #endif 178 gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_RADIO); 208 179 209 180 GRefPtr<GtkStyleContext> context = adoptGRef(gtk_style_context_new()); 210 gtk_style_context_set_path(context.get(), path.get()); 181 gtk_style_context_set_path(context.get(), path); 182 gtk_widget_path_free(path); 211 183 212 184 return context; … … 481 453 return; 482 454 483 // Other ports hard-code this to 13. GTK+ users tend to demand the native look. 455 // Other ports hard-code this to 13 which is also the default value defined by GTK+. 456 // GTK+ users tend to demand the native look. 457 // It could be made a configuration option values other than 13 actually break site compatibility. 484 458 gint indicatorSize; 485 459 gtk_style_context_get_style(context.get(), "indicator-size", &indicatorSize, nullptr); … … 495 469 { 496 470 GRefPtr<GtkStyleContext> context = createStyleContext(widgetType); 497 #if GTK_CHECK_VERSION(3, 19, 2)498 GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new());499 500 if (widgetType == GTK_TYPE_CHECK_BUTTON) {501 if (theme->isChecked(renderObject) || theme->isIndeterminate(renderObject)) {502 gtk_widget_path_append_type(path.get(), GTK_TYPE_CHECK_BUTTON);503 gtk_widget_path_iter_set_object_name(path.get(), 0, "checkbutton");504 } else {505 gtk_widget_path_append_type(path.get(), GTK_TYPE_CHECK_BUTTON);506 gtk_widget_path_iter_set_object_name(path.get(), 0, "button");507 gtk_widget_path_iter_add_class(path.get(), 0, "check");508 }509 510 gtk_widget_path_append_type(path.get(), GTK_TYPE_CHECK_BUTTON);511 gtk_widget_path_iter_set_object_name(path.get(), 1, "check");512 } else if (widgetType == GTK_TYPE_RADIO_BUTTON) {513 if (theme->isChecked(renderObject) || theme->isIndeterminate(renderObject)) {514 gtk_widget_path_append_type(path.get(), GTK_TYPE_RADIO_BUTTON);515 gtk_widget_path_iter_set_object_name(path.get(), 0, "radiobutton");516 } else {517 gtk_widget_path_append_type(path.get(), GTK_TYPE_RADIO_BUTTON);518 gtk_widget_path_iter_set_object_name(path.get(), 0, "button");519 gtk_widget_path_iter_add_class(path.get(), 0, "radio");520 }521 522 gtk_widget_path_append_type(path.get(), GTK_TYPE_RADIO_BUTTON);523 gtk_widget_path_iter_set_object_name(path.get(), 1, "radio");524 }525 526 gtk_style_context_set_path(context.get(), path.get());527 #endif528 471 529 472 // Some themes do not render large toggle buttons properly, so we simply … … 545 488 546 489 gtk_style_context_set_direction(context.get(), static_cast<GtkTextDirection>(gtkTextDirection(renderObject.style().direction()))); 547 548 #if GTK_CHECK_VERSION(3, 19, 2)549 gtk_style_context_add_class(context.get(), "toggle");550 #else551 490 gtk_style_context_add_class(context.get(), widgetType == GTK_TYPE_CHECK_BUTTON ? GTK_STYLE_CLASS_CHECK : GTK_STYLE_CLASS_RADIO); 552 #endif553 491 554 492 guint flags = 0; … … 677 615 678 616 gtk_style_context_set_direction(context.get(), static_cast<GtkTextDirection>(gtkTextDirection(renderObject.style().direction()))); 679 #if !GTK_CHECK_VERSION(3, 19, 2)680 617 gtk_style_context_add_class(context.get(), GTK_STYLE_CLASS_BUTTON); 681 #endif682 618 683 619 renderButton(this, context.get(), renderObject, paintInfo, rect); … … 708 644 709 645 GRefPtr<GtkStyleContext> context = createStyleContext(GTK_TYPE_COMBO_BOX); 710 #if GTK_CHECK_VERSION(3, 19, 2) 711 GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new()); 712 713 gtk_widget_path_append_type(path.get(), GTK_TYPE_COMBO_BOX); 714 gtk_widget_path_iter_set_object_name(path.get(), 0, "combobox"); 715 716 gtk_widget_path_append_type(path.get(), GTK_TYPE_COMBO_BOX); 717 gtk_widget_path_iter_set_object_name(path.get(), 1, "button"); 718 gtk_widget_path_iter_add_class(path.get(), 1, "combo"); 719 720 gtk_style_context_set_path(context.get(), path.get()); 721 #else 646 722 647 gtk_style_context_add_class(context.get(), GTK_STYLE_CLASS_BUTTON); 723 #endif724 648 gtk_style_context_set_direction(context.get(), static_cast<GtkTextDirection>(gtkTextDirection(style.direction()))); 725 649 … … 736 660 GtkTextDirection direction = static_cast<GtkTextDirection>(gtkTextDirection(style.direction())); 737 661 gtk_style_context_set_direction(context.get(), direction); 738 #if !GTK_CHECK_VERSION(3, 19, 2)739 662 gtk_style_context_add_class(context.get(), "separator"); 740 #endif741 663 742 664 gboolean wideSeparators; … … 800 722 GRefPtr<GtkStyleContext> buttonStyleContext = createStyleContext(GTK_TYPE_BUTTON); 801 723 gtk_style_context_set_direction(buttonStyleContext.get(), direction); 802 #if !GTK_CHECK_VERSION(3, 19, 2)803 724 gtk_style_context_add_class(buttonStyleContext.get(), GTK_STYLE_CLASS_BUTTON); 804 #endif805 725 renderButton(this, buttonStyleContext.get(), renderObject, paintInfo, rect); 806 726 … … 839 759 840 760 gtk_style_context_set_direction(arrowStyleContext.get(), direction); 841 #if !GTK_CHECK_VERSION(3, 19, 2)842 761 gtk_style_context_add_class(arrowStyleContext.get(), "arrow"); 843 762 gtk_style_context_add_class(arrowStyleContext.get(), GTK_STYLE_CLASS_BUTTON); 844 #endif845 763 846 764 gfloat arrowScaling; … … 862 780 // Paint the separator if needed. 863 781 GRefPtr<GtkStyleContext> separatorStyleContext = createStyleContext(GTK_TYPE_COMBO_BOX); 864 #if GTK_CHECK_VERSION(3, 19, 2) 865 GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new()); 866 867 gtk_widget_path_append_type(path.get(), GTK_TYPE_SEPARATOR); 868 gtk_widget_path_iter_set_object_name(path.get(), 0, "separator"); 869 870 gtk_style_context_set_path(separatorStyleContext.get(), path.get()); 871 #else 782 783 gtk_style_context_set_direction(separatorStyleContext.get(), direction); 872 784 gtk_style_context_add_class(separatorStyleContext.get(), "separator"); 873 #endif874 875 gtk_style_context_set_direction(separatorStyleContext.get(), direction);876 785 877 786 gboolean wideSeparators; … … 923 832 924 833 gtk_style_context_set_direction(context.get(), static_cast<GtkTextDirection>(gtkTextDirection(renderObject.style().direction()))); 925 #if !GTK_CHECK_VERSION(3, 19, 2)926 834 gtk_style_context_add_class(context.get(), GTK_STYLE_CLASS_ENTRY); 927 #endif928 835 929 836 guint flags = 0; … … 1135 1042 static void applySliderStyleContextClasses(GtkStyleContext* context, ControlPart part) 1136 1043 { 1137 #if !GTK_CHECK_VERSION(3, 19, 2)1138 1044 gtk_style_context_add_class(context, GTK_STYLE_CLASS_SCALE); 1139 #endif1140 1045 if (part == SliderHorizontalPart || part == SliderThumbHorizontalPart) 1141 1046 gtk_style_context_add_class(context, GTK_STYLE_CLASS_HORIZONTAL); … … 1150 1055 1151 1056 GRefPtr<GtkStyleContext> context = createStyleContext(GTK_TYPE_SCALE); 1152 #if GTK_CHECK_VERSION(3, 19, 2)1153 GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new());1154 1155 gtk_widget_path_append_type(path.get(), GTK_TYPE_SCALE);1156 gtk_widget_path_iter_set_object_name(path.get(), 0, "scale");1157 1158 gtk_widget_path_append_type(path.get(), GTK_TYPE_SCALE);1159 gtk_widget_path_iter_set_object_name(path.get(), 1, "trough");1160 1161 gtk_style_context_set_path(context.get(), path.get());1162 #endif1163 1057 1164 1058 gtk_style_context_set_direction(context.get(), gtkTextDirection(renderObject.style().direction())); 1165 1059 applySliderStyleContextClasses(context.get(), part); 1166 #if !GTK_CHECK_VERSION(3, 19, 2)1167 1060 gtk_style_context_add_class(context.get(), GTK_STYLE_CLASS_TROUGH); 1168 #endif1169 1061 1170 1062 if (!isEnabled(renderObject)) … … 1191 1083 1192 1084 GRefPtr<GtkStyleContext> context = createStyleContext(GTK_TYPE_SCALE); 1193 #if GTK_CHECK_VERSION(3, 19, 2)1194 // FIXME: The entire slider is too wide, stretching the thumb into an oval rather than a circle.1195 GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new());1196 1197 gtk_widget_path_append_type(path.get(), GTK_TYPE_SCALE);1198 gtk_widget_path_iter_set_object_name(path.get(), 0, "scale");1199 1200 gtk_widget_path_append_type(path.get(), GTK_TYPE_SCALE);1201 gtk_widget_path_iter_set_object_name(path.get(), 1, "trough");1202 1203 gtk_widget_path_append_type(path.get(), GTK_TYPE_SCALE);1204 gtk_widget_path_iter_set_object_name(path.get(), 2, "slider");1205 1206 gtk_style_context_set_path(context.get(), path.get());1207 #endif1208 1085 1209 1086 gtk_style_context_set_direction(context.get(), gtkTextDirection(renderObject.style().direction())); 1210 1087 applySliderStyleContextClasses(context.get(), part); 1088 gtk_style_context_add_class(context.get(), GTK_STYLE_CLASS_SLIDER); 1211 1089 1212 1090 guint flags = 0; … … 1250 1128 1251 1129 GRefPtr<GtkStyleContext> context = createStyleContext(GTK_TYPE_PROGRESS_BAR); 1252 #if GTK_CHECK_VERSION(3, 19, 2)1253 GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new());1254 1255 gtk_widget_path_append_type(path.get(), GTK_TYPE_PROGRESS_BAR);1256 gtk_widget_path_iter_set_object_name(path.get(), 0, "progressbar");1257 1258 gtk_widget_path_append_type(path.get(), GTK_TYPE_PROGRESS_BAR);1259 gtk_widget_path_iter_set_object_name(path.get(), 1, "trough");1260 1261 gtk_style_context_set_path(context.get(), path.get());1262 #else1263 1130 gtk_style_context_save(context.get()); 1131 1264 1132 gtk_style_context_add_class(context.get(), GTK_STYLE_CLASS_TROUGH); 1265 #endif1266 1133 1267 1134 gtk_render_background(context.get(), paintInfo.context().platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height()); 1268 1135 gtk_render_frame(context.get(), paintInfo.context().platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height()); 1269 1136 1270 #if GTK_CHECK_VERSION(3, 19, 2)1271 path = adoptGRef(gtk_widget_path_new());1272 1273 gtk_widget_path_append_type(path.get(), GTK_TYPE_PROGRESS_BAR);1274 gtk_widget_path_iter_set_object_name(path.get(), 0, "progressbar");1275 1276 gtk_widget_path_append_type(path.get(), GTK_TYPE_PROGRESS_BAR);1277 gtk_widget_path_iter_set_object_name(path.get(), 1, "trough");1278 1279 gtk_widget_path_append_type(path.get(), GTK_TYPE_PROGRESS_BAR);1280 gtk_widget_path_iter_set_object_name(path.get(), 2, "progress");1281 1282 gtk_style_context_set_path(context.get(), path.get());1283 #else1284 1137 gtk_style_context_restore(context.get()); 1138 1285 1139 gtk_style_context_add_class(context.get(), GTK_STYLE_CLASS_PROGRESSBAR); 1286 #endif1287 1288 1140 gtk_style_context_set_state(context.get(), static_cast<GtkStateFlags>(0)); 1289 1141 … … 1337 1189 1338 1190 gtk_style_context_save(context); 1339 1340 #if GTK_CHECK_VERSION(3, 19, 2)1341 GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new());1342 1343 gtk_widget_path_append_type(path.get(), GTK_TYPE_SPIN_BUTTON);1344 gtk_widget_path_iter_set_object_name(path.get(), 0, "spinbutton");1345 1346 gtk_widget_path_append_type(path.get(), GTK_TYPE_SPIN_BUTTON);1347 gtk_widget_path_iter_set_object_name(path.get(), 1, "button");1348 gtk_widget_path_iter_add_class(path.get(), 1, arrowType == GTK_ARROW_UP ? "up" : "down");1349 1350 gtk_style_context_set_path(context, path.get());1351 #else1352 1191 gtk_style_context_add_class(context, GTK_STYLE_CLASS_BUTTON); 1353 #endif1354 1192 1355 1193 GtkTextDirection direction = gtk_style_context_get_direction(context); … … 1452 1290 static Color styleColor(GType widgetType, GtkStateFlags state, StyleColorType colorType) 1453 1291 { 1292 1454 1293 GRefPtr<GtkStyleContext> context = createStyleContext(widgetType); 1455 #if GTK_CHECK_VERSION(3, 19, 2) 1456 if (widgetType == GTK_TYPE_ENTRY) { 1457 GRefPtr<GtkWidgetPath> path = adoptGRef(gtk_widget_path_new()); 1458 1459 gtk_widget_path_append_type(path.get(), GTK_TYPE_ENTRY); 1460 gtk_widget_path_iter_set_object_name(path.get(), 0, "entry"); 1461 1462 gtk_widget_path_append_type(path.get(), GTK_TYPE_ENTRY); 1463 gtk_widget_path_iter_set_object_name(path.get(), 1, "selection"); 1464 1465 gtk_style_context_set_path(context.get(), path.get()); 1466 } 1467 #endif 1468 1294 // Recent GTK+ versions (> 3.14) require to explicitly set the state before getting the color. 1469 1295 gtk_style_context_set_state(context.get(), state); 1470 1296 1471 1297 GdkRGBA gdkRGBAColor; 1472 1298 if (colorType == StyleColorBackground) 1473 gtk_style_context_get_background_color(context.get(), state, &gdkRGBAColor);1299 gtk_style_context_get_background_color(context.get(), gtk_style_context_get_state(context.get()), &gdkRGBAColor); 1474 1300 else 1475 gtk_style_context_get_color(context.get(), state, &gdkRGBAColor);1301 gtk_style_context_get_color(context.get(), gtk_style_context_get_state(context.get()), &gdkRGBAColor); 1476 1302 return gdkRGBAColor; 1477 1303 }
Note:
See TracChangeset
for help on using the changeset viewer.