Changeset 194362 in webkit
- Timestamp:
- Dec 22, 2015 6:22:03 AM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r194326 r194362 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-20 Jeremy Zerfas <WebKit@JeremyZerfas.com> 2 45 -
trunk/Source/WebCore/platform/gtk/GRefPtrGtk.cpp
r147499 r194362 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
r185502 r194362 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
r192723 r194362 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 unique 169 // GtkStyleContexts for GTK+ >= 3.19. This is crazy and definitely should not be necessary, but I 170 // couldn't find any other way to not break one version or the other. Ideally one of the two 171 // people on the planet who really understand GTK+ styles would fix this. 166 172 class ScrollbarStyleContext { 167 173 WTF_MAKE_NONCOPYABLE(ScrollbarStyleContext); WTF_MAKE_FAST_ALLOCATED; … … 192 198 return styleContext.get().context(); 193 199 } 200 #endif 194 201 195 202 ScrollbarThemeGtk::ScrollbarThemeGtk() … … 200 207 void ScrollbarThemeGtk::themeChanged() 201 208 { 209 #if !GTK_CHECK_VERSION(3, 19, 2) 202 210 gtk_style_context_invalidate(gtkScrollbarStyleContext()); 211 #endif 203 212 updateThemeProperties(); 204 213 } … … 206 215 void ScrollbarThemeGtk::updateThemeProperties() 207 216 { 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 #else 226 GRefPtr<GtkStyleContext> styleContext = gtkScrollbarStyleContext(); 227 #endif 228 208 229 gtk_style_context_get_style( 209 gtkScrollbarStyleContext(),230 styleContext.get(), 210 231 "min-slider-length", &m_minThumbLength, 211 232 "slider-width", &m_thumbFatness, … … 273 294 } 274 295 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) 275 303 static void applyScrollbarStyleContextClasses(GtkStyleContext* context, ScrollbarOrientation orientation) 276 304 { 277 305 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 } 306 gtk_style_context_add_class(context, orientationStyleClass(orientation)); 307 } 308 #endif 280 309 281 310 static void adjustRectAccordingToMargin(GtkStyleContext* context, GtkStateFlags state, IntRect& rect) … … 297 326 fullScrollbarRect = IntRect(scrollbar.x(), scrollbar.y(), scrollbar.width(), scrollbar.height()); 298 327 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); 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 310 355 } 311 356 312 357 void ScrollbarThemeGtk::paintScrollbarBackground(GraphicsContext& context, Scrollbar& scrollbar) 313 358 { 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); 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 322 381 } 323 382 324 383 void ScrollbarThemeGtk::paintThumb(GraphicsContext& context, Scrollbar& scrollbar, const IntRect& rect) 325 384 { 326 GtkStyleContext* styleContext = gtkScrollbarStyleContext(); 327 gtk_style_context_save(styleContext); 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 328 404 329 405 ScrollbarOrientation orientation = scrollbar.orientation(); 330 applyScrollbarStyleContextClasses(styleContext, orientation); 331 gtk_style_context_add_class(styleContext, GTK_STYLE_CLASS_SLIDER); 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 332 410 333 411 guint flags = 0; … … 336 414 if (scrollbar.hoveredPart() == ThumbPart) 337 415 flags |= GTK_STATE_FLAG_PRELIGHT; 338 gtk_style_context_set_state(styleContext , static_cast<GtkStateFlags>(flags));416 gtk_style_context_set_state(styleContext.get(), static_cast<GtkStateFlags>(flags)); 339 417 340 418 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(),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(), 343 421 orientation == VerticalScrollbar ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL); 344 422 345 gtk_style_context_restore(styleContext); 423 #if !GTK_CHECK_VERSION(3, 19, 2) 424 gtk_style_context_restore(styleContext.get()); 425 #endif 346 426 } 347 427 348 428 void ScrollbarThemeGtk::paintButton(GraphicsContext& context, Scrollbar& scrollbar, const IntRect& rect, ScrollbarPart part) 349 429 { 350 GtkStyleContext* styleContext = gtkScrollbarStyleContext(); 351 gtk_style_context_save(styleContext); 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 352 446 353 447 ScrollbarOrientation orientation = scrollbar.orientation(); 354 applyScrollbarStyleContextClasses(styleContext, orientation); 448 #if !GTK_CHECK_VERSION(3, 19, 2) 449 applyScrollbarStyleContextClasses(styleContext.get(), orientation); 450 #endif 355 451 356 452 guint flags = 0; … … 365 461 } else 366 462 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()); 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()); 372 471 373 472 gfloat arrowScaling; 374 gtk_style_context_get_style(styleContext , "arrow-scaling", &arrowScaling, nullptr);473 gtk_style_context_get_style(styleContext.get(), "arrow-scaling", &arrowScaling, nullptr); 375 474 376 475 double arrowSize = std::min(rect.width(), rect.height()) * arrowScaling; … … 381 480 if (flags & GTK_STATE_FLAG_ACTIVE) { 382 481 gint arrowDisplacementX, arrowDisplacementY; 383 gtk_style_context_get_style(styleContext , "arrow-displacement-x", &arrowDisplacementX, "arrow-displacement-y", &arrowDisplacementY, nullptr);482 gtk_style_context_get_style(styleContext.get(), "arrow-displacement-x", &arrowDisplacementX, "arrow-displacement-y", &arrowDisplacementY, nullptr); 384 483 arrowPoint.move(arrowDisplacementX, arrowDisplacementY); 385 484 } … … 391 490 angle = (part == ForwardButtonEndPart || part == ForwardButtonStartPart) ? G_PI / 2 : 3 * (G_PI / 2); 392 491 393 gtk_render_arrow(styleContext, context.platformContext()->cr(), angle, arrowPoint.x(), arrowPoint.y(), arrowSize); 394 395 gtk_style_context_restore(styleContext); 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 396 497 } 397 498 -
trunk/Source/WebCore/rendering/RenderThemeGtk.cpp
r193896 r194362 153 153 } 154 154 155 GtkWidgetPath* path = gtk_widget_path_new(); 156 gtk_widget_path_append_type(path, widgetType); 157 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. 158 161 if (widgetType == GTK_TYPE_ENTRY) 159 gtk_widget_path_iter_ add_class(path, 0, GTK_STYLE_CLASS_ENTRY);162 gtk_widget_path_iter_set_object_name(path.get(), 0, "entry"); 160 163 else if (widgetType == GTK_TYPE_ARROW) 161 gtk_widget_path_iter_ add_class(path, 0, "arrow");164 gtk_widget_path_iter_set_object_name(path.get(), 0, "button"); // Note: not a typo. 162 165 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");166 gtk_widget_path_iter_set_object_name(path.get(), 0, "button"); 167 gtk_widget_path_iter_add_class(path.get(), 0, "text-button"); 165 168 } else if (widgetType == GTK_TYPE_SCALE) 166 gtk_widget_path_iter_ add_class(path, 0, GTK_STYLE_CLASS_SCALE);169 gtk_widget_path_iter_set_object_name(path.get(), 0, "scale"); 167 170 else if (widgetType == GTK_TYPE_SEPARATOR) 168 gtk_widget_path_iter_ add_class(path, 0, GTK_STYLE_CLASS_SEPARATOR);171 gtk_widget_path_iter_set_object_name(path.get(), 0, "separator"); 169 172 else if (widgetType == GTK_TYPE_PROGRESS_BAR) 170 gtk_widget_path_iter_ add_class(path, 0, GTK_STYLE_CLASS_PROGRESSBAR);173 gtk_widget_path_iter_set_object_name(path.get(), 0, "progressbar"); 171 174 else if (widgetType == GTK_TYPE_SPIN_BUTTON) 172 gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_SPINBUTTON); 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"); 181 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); 173 201 else if (widgetType == GTK_TYPE_TREE_VIEW) 174 gtk_widget_path_iter_add_class(path , 0, GTK_STYLE_CLASS_VIEW);202 gtk_widget_path_iter_add_class(path.get(), 0, GTK_STYLE_CLASS_VIEW); 175 203 else if (widgetType == GTK_TYPE_CHECK_BUTTON) 176 gtk_widget_path_iter_add_class(path , 0, GTK_STYLE_CLASS_CHECK);204 gtk_widget_path_iter_add_class(path.get(), 0, GTK_STYLE_CLASS_CHECK); 177 205 else if (widgetType == GTK_TYPE_RADIO_BUTTON) 178 gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_RADIO); 206 gtk_widget_path_iter_add_class(path.get(), 0, GTK_STYLE_CLASS_RADIO); 207 #endif 179 208 180 209 GRefPtr<GtkStyleContext> context = adoptGRef(gtk_style_context_new()); 181 gtk_style_context_set_path(context.get(), path); 182 gtk_widget_path_free(path); 210 gtk_style_context_set_path(context.get(), path.get()); 183 211 184 212 return context; … … 453 481 return; 454 482 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. 483 // Other ports hard-code this to 13. GTK+ users tend to demand the native look. 458 484 gint indicatorSize; 459 485 gtk_style_context_get_style(context.get(), "indicator-size", &indicatorSize, nullptr); … … 469 495 { 470 496 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 #endif 471 528 472 529 // Some themes do not render large toggle buttons properly, so we simply … … 488 545 489 546 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 #else 490 551 gtk_style_context_add_class(context.get(), widgetType == GTK_TYPE_CHECK_BUTTON ? GTK_STYLE_CLASS_CHECK : GTK_STYLE_CLASS_RADIO); 552 #endif 491 553 492 554 guint flags = 0; … … 615 677 616 678 gtk_style_context_set_direction(context.get(), static_cast<GtkTextDirection>(gtkTextDirection(renderObject.style().direction()))); 679 #if !GTK_CHECK_VERSION(3, 19, 2) 617 680 gtk_style_context_add_class(context.get(), GTK_STYLE_CLASS_BUTTON); 681 #endif 618 682 619 683 renderButton(this, context.get(), renderObject, paintInfo, rect); … … 644 708 645 709 GRefPtr<GtkStyleContext> context = createStyleContext(GTK_TYPE_COMBO_BOX); 646 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 647 722 gtk_style_context_add_class(context.get(), GTK_STYLE_CLASS_BUTTON); 723 #endif 648 724 gtk_style_context_set_direction(context.get(), static_cast<GtkTextDirection>(gtkTextDirection(style.direction()))); 649 725 … … 660 736 GtkTextDirection direction = static_cast<GtkTextDirection>(gtkTextDirection(style.direction())); 661 737 gtk_style_context_set_direction(context.get(), direction); 738 #if !GTK_CHECK_VERSION(3, 19, 2) 662 739 gtk_style_context_add_class(context.get(), "separator"); 740 #endif 663 741 664 742 gboolean wideSeparators; … … 722 800 GRefPtr<GtkStyleContext> buttonStyleContext = createStyleContext(GTK_TYPE_BUTTON); 723 801 gtk_style_context_set_direction(buttonStyleContext.get(), direction); 802 #if !GTK_CHECK_VERSION(3, 19, 2) 724 803 gtk_style_context_add_class(buttonStyleContext.get(), GTK_STYLE_CLASS_BUTTON); 804 #endif 725 805 renderButton(this, buttonStyleContext.get(), renderObject, paintInfo, rect); 726 806 … … 759 839 760 840 gtk_style_context_set_direction(arrowStyleContext.get(), direction); 841 #if !GTK_CHECK_VERSION(3, 19, 2) 761 842 gtk_style_context_add_class(arrowStyleContext.get(), "arrow"); 762 843 gtk_style_context_add_class(arrowStyleContext.get(), GTK_STYLE_CLASS_BUTTON); 844 #endif 763 845 764 846 gfloat arrowScaling; … … 780 862 // Paint the separator if needed. 781 863 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 872 gtk_style_context_add_class(separatorStyleContext.get(), "separator"); 873 #endif 782 874 783 875 gtk_style_context_set_direction(separatorStyleContext.get(), direction); 784 gtk_style_context_add_class(separatorStyleContext.get(), "separator");785 876 786 877 gboolean wideSeparators; … … 832 923 833 924 gtk_style_context_set_direction(context.get(), static_cast<GtkTextDirection>(gtkTextDirection(renderObject.style().direction()))); 925 #if !GTK_CHECK_VERSION(3, 19, 2) 834 926 gtk_style_context_add_class(context.get(), GTK_STYLE_CLASS_ENTRY); 927 #endif 835 928 836 929 guint flags = 0; … … 1042 1135 static void applySliderStyleContextClasses(GtkStyleContext* context, ControlPart part) 1043 1136 { 1137 #if !GTK_CHECK_VERSION(3, 19, 2) 1044 1138 gtk_style_context_add_class(context, GTK_STYLE_CLASS_SCALE); 1139 #endif 1045 1140 if (part == SliderHorizontalPart || part == SliderThumbHorizontalPart) 1046 1141 gtk_style_context_add_class(context, GTK_STYLE_CLASS_HORIZONTAL); … … 1055 1150 1056 1151 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 #endif 1057 1163 1058 1164 gtk_style_context_set_direction(context.get(), gtkTextDirection(renderObject.style().direction())); 1059 1165 applySliderStyleContextClasses(context.get(), part); 1166 #if !GTK_CHECK_VERSION(3, 19, 2) 1060 1167 gtk_style_context_add_class(context.get(), GTK_STYLE_CLASS_TROUGH); 1168 #endif 1061 1169 1062 1170 if (!isEnabled(renderObject)) … … 1083 1191 1084 1192 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 #endif 1085 1208 1086 1209 gtk_style_context_set_direction(context.get(), gtkTextDirection(renderObject.style().direction())); 1087 1210 applySliderStyleContextClasses(context.get(), part); 1088 gtk_style_context_add_class(context.get(), GTK_STYLE_CLASS_SLIDER);1089 1211 1090 1212 guint flags = 0; … … 1128 1250 1129 1251 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 #else 1130 1263 gtk_style_context_save(context.get()); 1131 1132 1264 gtk_style_context_add_class(context.get(), GTK_STYLE_CLASS_TROUGH); 1265 #endif 1133 1266 1134 1267 gtk_render_background(context.get(), paintInfo.context().platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height()); 1135 1268 gtk_render_frame(context.get(), paintInfo.context().platformContext()->cr(), rect.x(), rect.y(), rect.width(), rect.height()); 1136 1269 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 #else 1137 1284 gtk_style_context_restore(context.get()); 1138 1139 1285 gtk_style_context_add_class(context.get(), GTK_STYLE_CLASS_PROGRESSBAR); 1286 #endif 1287 1140 1288 gtk_style_context_set_state(context.get(), static_cast<GtkStateFlags>(0)); 1141 1289 … … 1189 1337 1190 1338 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 #else 1191 1352 gtk_style_context_add_class(context, GTK_STYLE_CLASS_BUTTON); 1353 #endif 1192 1354 1193 1355 GtkTextDirection direction = gtk_style_context_get_direction(context); … … 1290 1452 static Color styleColor(GType widgetType, GtkStateFlags state, StyleColorType colorType) 1291 1453 { 1292 1293 1454 GRefPtr<GtkStyleContext> context = createStyleContext(widgetType); 1294 // Recent GTK+ versions (> 3.14) require to explicitly set the state before getting the color. 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 1295 1469 gtk_style_context_set_state(context.get(), state); 1296 1470 1297 1471 GdkRGBA gdkRGBAColor; 1298 1472 if (colorType == StyleColorBackground) 1299 gtk_style_context_get_background_color(context.get(), gtk_style_context_get_state(context.get()), &gdkRGBAColor);1473 gtk_style_context_get_background_color(context.get(), state, &gdkRGBAColor); 1300 1474 else 1301 gtk_style_context_get_color(context.get(), gtk_style_context_get_state(context.get()), &gdkRGBAColor);1475 gtk_style_context_get_color(context.get(), state, &gdkRGBAColor); 1302 1476 return gdkRGBAColor; 1303 1477 }
Note: See TracChangeset
for help on using the changeset viewer.