Title: [275809] trunk/Source/WebCore
Revision
275809
Author
da...@apple.com
Date
2021-04-11 12:33:41 -0700 (Sun, 11 Apr 2021)

Log Message

[Mac] Add a missing null check to slider thumb focus rendering
https://bugs.webkit.org/show_bug.cgi?id=224418
rdar://76450584

Reviewed by Sam Weinig.

* rendering/RenderThemeMac.h: Changed updateFocusedState to take a pointer.
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::updateFocusedState): Check pointer for null. This was the
missing null check.
(WebCore::RenderThemeMac::paintSliderThumb): Pass delegate pointer instead of reference.
Also made sure we always update the focused state. Old code took the approach of just not
updating focus state when it encountered null for the focus delegate, but that's not a
good strategy. In future we may also want to change the focusDelegate function signature
to make it clear it will never return null, but that's not critical right now.
(WebCore::RenderThemeMac::setSearchCellState): Update since updateFocusedState now
takes a pointer.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (275808 => 275809)


--- trunk/Source/WebCore/ChangeLog	2021-04-11 17:06:47 UTC (rev 275808)
+++ trunk/Source/WebCore/ChangeLog	2021-04-11 19:33:41 UTC (rev 275809)
@@ -1,3 +1,23 @@
+2021-04-11  Darin Adler  <da...@apple.com>
+
+        [Mac] Add a missing null check to slider thumb focus rendering
+        https://bugs.webkit.org/show_bug.cgi?id=224418
+        rdar://76450584
+
+        Reviewed by Sam Weinig.
+
+        * rendering/RenderThemeMac.h: Changed updateFocusedState to take a pointer.
+        * rendering/RenderThemeMac.mm:
+        (WebCore::RenderThemeMac::updateFocusedState): Check pointer for null. This was the
+        missing null check.
+        (WebCore::RenderThemeMac::paintSliderThumb): Pass delegate pointer instead of reference.
+        Also made sure we always update the focused state. Old code took the approach of just not
+        updating focus state when it encountered null for the focus delegate, but that's not a
+        good strategy. In future we may also want to change the focusDelegate function signature
+        to make it clear it will never return null, but that's not critical right now.
+        (WebCore::RenderThemeMac::setSearchCellState): Update since updateFocusedState now
+        takes a pointer.
+
 2021-04-11  Sam Weinig  <wei...@apple.com>
 
         Reduce compile time and binary size cost of enabling proper CSSStyleDeclaration property access behavior

Modified: trunk/Source/WebCore/rendering/RenderThemeMac.h (275808 => 275809)


--- trunk/Source/WebCore/rendering/RenderThemeMac.h	2021-04-11 17:06:47 UTC (rev 275808)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.h	2021-04-11 19:33:41 UTC (rev 275809)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2005-2021 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -172,7 +172,7 @@
 
     void updateCheckedState(NSCell*, const RenderObject&);
     void updateEnabledState(NSCell*, const RenderObject&);
-    void updateFocusedState(NSCell*, const RenderObject&);
+    void updateFocusedState(NSCell *, const RenderObject*);
     void updatePressedState(NSCell*, const RenderObject&);
 
     // Helpers for adjusting appearance and for painting

Modified: trunk/Source/WebCore/rendering/RenderThemeMac.mm (275808 => 275809)


--- trunk/Source/WebCore/rendering/RenderThemeMac.mm	2021-04-11 17:06:47 UTC (rev 275808)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.mm	2021-04-11 19:33:41 UTC (rev 275809)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2005-2021 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -824,10 +824,10 @@
         [cell setEnabled:enabled];
 }
 
-void RenderThemeMac::updateFocusedState(NSCell* cell, const RenderObject& o)
+void RenderThemeMac::updateFocusedState(NSCell *cell, const RenderObject* o)
 {
     bool oldFocused = [cell showsFirstResponder];
-    bool focused = isFocused(o) && o.style().outlineStyleIsAuto() == OutlineIsAuto::On;
+    bool focused = o && isFocused(*o) && o->style().outlineStyleIsAuto() == OutlineIsAuto::On;
     if (focused != oldFocused)
         [cell setShowsFirstResponder:focused];
 }
@@ -1726,8 +1726,7 @@
     // Update the various states we respond to.
     updateEnabledState(sliderThumbCell, o);
     auto focusDelegate = is<Element>(o.node()) ? downcast<Element>(*o.node()).focusDelegate() : nullptr;
-    if (focusDelegate)
-        updateFocusedState(sliderThumbCell, *focusDelegate->renderer());
+    updateFocusedState(sliderThumbCell, focusDelegate ? focusDelegate->renderer() : nullptr);
 
     // Update the pressed state using the NSCell tracking methods, since that's how NSSliderCell keeps track of it.
     bool oldPressed;
@@ -1824,7 +1823,7 @@
 
     // Update the various states we respond to.
     updateEnabledState(search, o);
-    updateFocusedState(search, o);
+    updateFocusedState(search, &o);
 }
 
 const IntSize* RenderThemeMac::searchFieldSizes() const
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to