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