Title: [287663] trunk
Revision
287663
Author
megan_gard...@apple.com
Date
2022-01-05 17:39:49 -0800 (Wed, 05 Jan 2022)

Log Message

Remove unneeded webkit specific CSS attribute for Image Control Menu.
https://bugs.webkit.org/show_bug.cgi?id=234405

Reviewed by Darin Adler.

Source/WebCore:

Test: fast/images/mac/image-controls-basic.html

We do not actually need a specific CSS attribute to achieve the image control menu,
so we should remove it to keep WebKit specific clutter out of our CSS implementation
and we should keep track of the presence of the image control menu fully internally.
Doing this also exposed several issues, including the fact that we had already run out
of space for the storing of the ControlPart in RenderStyle. Also added a check to make
sure that will not happen again.

* css/CSSPrimitiveValueMappings.h:
(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
* css/CSSProperties.json:
* css/CSSValueKeywords.in:
* css/parser/CSSParserIdioms.cpp:
(WebCore::isValueAllowedInMode):
* dom/mac/ImageControlsMac.cpp:
(WebCore::ImageControlsMac::isInsideImageControls):
* dom/mac/ImageControlsMac.h:
* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::parseAttribute):
(WebCore::HTMLImageElement::setAttachmentElement):
(WebCore::HTMLImageElement::updateImageControls):
* html/HTMLImageElement.h:
* html/shadow/mac/imageControlsMac.css:
(div#image-controls button#image-controls-button):
* platform/ThemeTypes.h:
* rendering/HitTestResult.cpp:
(WebCore::HitTestResult::nodeForImageData const):
* rendering/RenderTheme.cpp:
(WebCore::RenderTheme::autoAppearanceForElement const):
* rendering/RenderTheme.h:
(WebCore::RenderTheme::isImageControl const):
* rendering/RenderThemeMac.h:
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::isImageControl const):
* rendering/style/RenderStyle.h:
(WebCore::RenderStyle::setAppearance):
(WebCore::RenderStyle::setEffectiveAppearance):
* rendering/style/StyleRareNonInheritedData.h:
* testing/Internals.cpp:
(WebCore::Internals::hasImageControls const):
* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

We need to move this test to be a mac specific one, as it now has mac specific
test harnessing (using hasImageControls) and it is testing a feature that is only on mac.
Also changed the test to be resistent to the async nature of adding
the shadow dom elements, and checking the shadow dom directly rather than the resulting layout,
which is prone to pixel errors.

* TestExpectations:
* fast/images/image-controls-basic-expected.txt:
* fast/images/image-controls-basic.html: Removed.
* fast/images/mac/image-controls-basic-expected.txt: Added.
* fast/images/mac/image-controls-basic.html: Added.
* platform/mac-catalina/fast/images/image-controls-basic-expected.txt: Removed.
* platform/mac/TestExpectations:
* platform/mac/fast/images/image-controls-basic-expected.txt: Removed.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (287662 => 287663)


--- trunk/LayoutTests/ChangeLog	2022-01-06 01:21:20 UTC (rev 287662)
+++ trunk/LayoutTests/ChangeLog	2022-01-06 01:39:49 UTC (rev 287663)
@@ -1,3 +1,25 @@
+2022-01-05  Megan Gardner  <megan_gard...@apple.com>
+
+        Remove unneeded webkit specific CSS attribute for Image Control Menu.
+        https://bugs.webkit.org/show_bug.cgi?id=234405
+
+        Reviewed by Darin Adler.
+
+        We need to move this test to be a mac specific one, as it now has mac specific 
+        test harnessing (using hasImageControls) and it is testing a feature that is only on mac.
+        Also changed the test to be resistent to the async nature of adding
+        the shadow dom elements, and checking the shadow dom directly rather than the resulting layout,
+        which is prone to pixel errors.
+
+        * TestExpectations:
+        * fast/images/image-controls-basic-expected.txt:
+        * fast/images/image-controls-basic.html: Removed.
+        * fast/images/mac/image-controls-basic-expected.txt: Added.
+        * fast/images/mac/image-controls-basic.html: Added.
+        * platform/mac-catalina/fast/images/image-controls-basic-expected.txt: Removed.
+        * platform/mac/TestExpectations:
+        * platform/mac/fast/images/image-controls-basic-expected.txt: Removed.
+
 2022-01-05  Ryan Haddad  <ryanhad...@apple.com>
 
         [selectors] :focus-visible not matching on accessKey focus after focusing something via mouse

Modified: trunk/LayoutTests/TestExpectations (287662 => 287663)


--- trunk/LayoutTests/TestExpectations	2022-01-06 01:21:20 UTC (rev 287662)
+++ trunk/LayoutTests/TestExpectations	2022-01-06 01:39:49 UTC (rev 287663)
@@ -40,6 +40,7 @@
 fast/forms/textarea/ios [ Skip ]
 fast/forms/watchos [ Skip ]
 fast/images/text-recognition [ Skip ]
+fast/images/mac [ Skip ]
 fast/sandbox/ios [ Skip ]
 fast/sandbox/mac [ Skip ]
 fast/viewport/watchos [ Skip ]

Deleted: trunk/LayoutTests/fast/images/image-controls-basic-expected.txt (287662 => 287663)


--- trunk/LayoutTests/fast/images/image-controls-basic-expected.txt	2022-01-06 01:21:20 UTC (rev 287662)
+++ trunk/LayoutTests/fast/images/image-controls-basic-expected.txt	2022-01-06 01:39:49 UTC (rev 287663)
@@ -1,7 +0,0 @@
-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderBlock {HTML} at (0,0) size 800x600
-    RenderBody {BODY} at (8,8) size 784x584
-      RenderImage {IMG} at (0,0) size 256x256
-      RenderText {#text} at (0,0) size 0x0

Deleted: trunk/LayoutTests/fast/images/image-controls-basic.html (287662 => 287663)


--- trunk/LayoutTests/fast/images/image-controls-basic.html	2022-01-06 01:21:20 UTC (rev 287662)
+++ trunk/LayoutTests/fast/images/image-controls-basic.html	2022-01-06 01:39:49 UTC (rev 287663)
@@ -1,8 +0,0 @@
- <script>
-if (window.internals)
-	internals.settings.setImageControlsEnabled(true);
-
-</script>
-<body>
-<img src="" x-webkit-imagemenu>
-</body>
\ No newline at end of file

Added: trunk/LayoutTests/fast/images/mac/image-controls-basic-expected.txt (0 => 287663)


--- trunk/LayoutTests/fast/images/mac/image-controls-basic-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/images/mac/image-controls-basic-expected.txt	2022-01-06 01:39:49 UTC (rev 287663)
@@ -0,0 +1,2 @@
+
+PASS: image controls exist in shadowDom

Added: trunk/LayoutTests/fast/images/mac/image-controls-basic.html (0 => 287663)


--- trunk/LayoutTests/fast/images/mac/image-controls-basic.html	                        (rev 0)
+++ trunk/LayoutTests/fast/images/mac/image-controls-basic.html	2022-01-06 01:39:49 UTC (rev 287663)
@@ -0,0 +1,46 @@
+<!DOCTYPE html><!-- webkit-test-runner [ AttachmentElementEnabled=true ] -->
+<html>
+<head>
+<script>
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+if (window.internals) {
+   internals.settings.setImageControlsEnabled(true);
+}
+</script>
+</head>
+<body>
+<img id="target" src=""
+<div id="log">
+<script>
+   function hasImageControls(elem)
+   {
+       if (window.internals)
+           return internals.hasImageControls(elem);
+       return false;
+   }
+
+   function checkForShadowDom(elem)
+   {
+        var output = '';
+        if (internals.shadowRoot(elem) && internals.shadowRoot(elem).getElementById('image-controls') && internals.shadowRoot(elem).getElementById('image-controls-button')) 
+            output += 'PASS: image controls exist in shadowDom';
+        else
+            output += 'FAIL: no image controls found in shadowDom';
+        document.getElementById('log').innerHTML = output;
+   }
+
+   var elem = document.getElementById("target");
+   var ID = HTMLAttachmentElement.getAttachmentIdentifier(elem);
+
+   setInterval(() => {
+    if (hasImageControls(elem)) {
+        checkForShadowDom(elem);
+        testRunner.notifyDone();
+    }
+   }, 200);
+</script>
+</body>
+</html>
\ No newline at end of file

Modified: trunk/LayoutTests/platform/mac/TestExpectations (287662 => 287663)


--- trunk/LayoutTests/platform/mac/TestExpectations	2022-01-06 01:21:20 UTC (rev 287662)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2022-01-06 01:39:49 UTC (rev 287663)
@@ -16,6 +16,7 @@
 fast/dom/Range/mac [ Pass ]
 fast/scrolling/latching [ Pass ]
 model-element [ Pass ]
+fast/images/mac [ Pass ]
 
 # Disable plug-in tests on Apple Silicon
 [ arm64 ] compositing/plugins [ Skip ]

Deleted: trunk/LayoutTests/platform/mac/fast/images/image-controls-basic-expected.txt (287662 => 287663)


--- trunk/LayoutTests/platform/mac/fast/images/image-controls-basic-expected.txt	2022-01-06 01:21:20 UTC (rev 287662)
+++ trunk/LayoutTests/platform/mac/fast/images/image-controls-basic-expected.txt	2022-01-06 01:39:49 UTC (rev 287663)
@@ -1,11 +0,0 @@
-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderBlock {HTML} at (0,0) size 800x600
-    RenderBody {BODY} at (8,8) size 784x584
-      RenderImage {IMG} at (0,0) size 256x256
-      RenderText {#text} at (0,0) size 0x0
-layer at (8,8) size 256x256
-  RenderBlock (relative positioned) {DIV} at (0,0) size 256x256 [color=#00000000]
-layer at (214,30) size 28x26
-  RenderButton {BUTTON} at (206,22) size 28x26 [color=#000000D8] [bgcolor=#C0C0C0] [border: (2px outset #C0C0C0)]

Modified: trunk/Source/WebCore/ChangeLog (287662 => 287663)


--- trunk/Source/WebCore/ChangeLog	2022-01-06 01:21:20 UTC (rev 287662)
+++ trunk/Source/WebCore/ChangeLog	2022-01-06 01:39:49 UTC (rev 287663)
@@ -1,3 +1,54 @@
+2022-01-05  Megan Gardner  <megan_gard...@apple.com>
+
+        Remove unneeded webkit specific CSS attribute for Image Control Menu.
+        https://bugs.webkit.org/show_bug.cgi?id=234405
+
+        Reviewed by Darin Adler.
+
+        Test: fast/images/mac/image-controls-basic.html
+
+        We do not actually need a specific CSS attribute to achieve the image control menu,
+        so we should remove it to keep WebKit specific clutter out of our CSS implementation
+        and we should keep track of the presence of the image control menu fully internally.
+        Doing this also exposed several issues, including the fact that we had already run out
+        of space for the storing of the ControlPart in RenderStyle. Also added a check to make
+        sure that will not happen again.
+
+        * css/CSSPrimitiveValueMappings.h:
+        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+        * css/CSSProperties.json:
+        * css/CSSValueKeywords.in:
+        * css/parser/CSSParserIdioms.cpp:
+        (WebCore::isValueAllowedInMode):
+        * dom/mac/ImageControlsMac.cpp:
+        (WebCore::ImageControlsMac::isInsideImageControls):
+        * dom/mac/ImageControlsMac.h:
+        * html/HTMLImageElement.cpp:
+        (WebCore::HTMLImageElement::parseAttribute):
+        (WebCore::HTMLImageElement::setAttachmentElement):
+        (WebCore::HTMLImageElement::updateImageControls):
+        * html/HTMLImageElement.h:
+        * html/shadow/mac/imageControlsMac.css:
+        (div#image-controls button#image-controls-button):
+        * platform/ThemeTypes.h:
+        * rendering/HitTestResult.cpp:
+        (WebCore::HitTestResult::nodeForImageData const):
+        * rendering/RenderTheme.cpp:
+        (WebCore::RenderTheme::autoAppearanceForElement const):
+        * rendering/RenderTheme.h:
+        (WebCore::RenderTheme::isImageControl const):
+        * rendering/RenderThemeMac.h:
+        * rendering/RenderThemeMac.mm:
+        (WebCore::RenderThemeMac::isImageControl const):
+        * rendering/style/RenderStyle.h:
+        (WebCore::RenderStyle::setAppearance):
+        (WebCore::RenderStyle::setEffectiveAppearance):
+        * rendering/style/StyleRareNonInheritedData.h:
+        * testing/Internals.cpp:
+        (WebCore::Internals::hasImageControls const):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2022-01-05  Tim Horton  <timothy_hor...@apple.com>
 
         Move more SDK checks to linkedOnOrAfter()

Modified: trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h (287662 => 287663)


--- trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h	2022-01-06 01:21:20 UTC (rev 287662)
+++ trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h	2022-01-06 01:39:49 UTC (rev 287663)
@@ -634,7 +634,8 @@
 #endif
 #if ENABLE(SERVICE_CONTROLS)
     case ImageControlsButtonPart:
-        m_value.valueID = CSSValueInternalImageControlsButton;
+        ASSERT_NOT_REACHED();
+        m_value.valueID = CSSValueNone;
         break;
 #endif
 #if ENABLE(APPLE_PAY)

Modified: trunk/Source/WebCore/css/CSSProperties.json (287662 => 287663)


--- trunk/Source/WebCore/css/CSSProperties.json	2022-01-06 01:21:20 UTC (rev 287662)
+++ trunk/Source/WebCore/css/CSSProperties.json	2022-01-06 01:39:49 UTC (rev 287663)
@@ -5159,7 +5159,6 @@
                 "continuous-capacity-level-indicator",
                 "discrete-capacity-level-indicator",
                 "rating-level-indicator",
-                "-internal-image-controls-button",
                 "-apple-pay-button",
                 "textarea",
                 "attachment",

Modified: trunk/Source/WebCore/css/CSSValueKeywords.in (287662 => 287663)


--- trunk/Source/WebCore/css/CSSValueKeywords.in	2022-01-06 01:21:20 UTC (rev 287662)
+++ trunk/Source/WebCore/css/CSSValueKeywords.in	2022-01-06 01:39:49 UTC (rev 287663)
@@ -890,9 +890,6 @@
 continuous-capacity-level-indicator
 discrete-capacity-level-indicator
 rating-level-indicator
-#if defined(ENABLE_SERVICE_CONTROLS) && ENABLE_SERVICE_CONTROLS
--internal-image-controls-button
-#endif
 #if defined(ENABLE_APPLE_PAY) && ENABLE_APPLE_PAY
 -apple-pay-button
 #endif

Modified: trunk/Source/WebCore/css/parser/CSSParserIdioms.cpp (287662 => 287663)


--- trunk/Source/WebCore/css/parser/CSSParserIdioms.cpp	2022-01-06 01:21:20 UTC (rev 287662)
+++ trunk/Source/WebCore/css/parser/CSSParserIdioms.cpp	2022-01-06 01:39:49 UTC (rev 287663)
@@ -40,10 +40,6 @@
         return isUASheetBehavior(mode);
     case CSSValueWebkitFocusRingColor:
         return isUASheetBehavior(mode) || isQuirksModeBehavior(mode);
-#if ENABLE(SERVICE_CONTROLS)
-    case CSSValueInternalImageControlsButton:
-        return isUASheetBehavior(mode);
-#endif
     default:
         return true;
     }

Modified: trunk/Source/WebCore/dom/mac/ImageControlsMac.cpp (287662 => 287663)


--- trunk/Source/WebCore/dom/mac/ImageControlsMac.cpp	2022-01-06 01:21:20 UTC (rev 287662)
+++ trunk/Source/WebCore/dom/mac/ImageControlsMac.cpp	2022-01-06 01:39:49 UTC (rev 287663)
@@ -73,6 +73,14 @@
     return is<Element>(node) && downcast<Element>(node).getIdAttribute() == imageControlsButtonIdentifier();
 }
 
+bool isInsideImageControls(const Node& node)
+{
+    RefPtr host = node.shadowHost();
+    if (!is<HTMLElement>(host.get()) || !hasControls(downcast<HTMLElement>(*host)))
+        return false;
+    return is<Element>(node) && downcast<Element>(node).getIdAttribute() == imageControlsElementIdentifier();
+}
+
 void createImageControls(HTMLElement& element)
 {
     Ref document = element.document();

Modified: trunk/Source/WebCore/dom/mac/ImageControlsMac.h (287662 => 287663)


--- trunk/Source/WebCore/dom/mac/ImageControlsMac.h	2022-01-06 01:21:20 UTC (rev 287662)
+++ trunk/Source/WebCore/dom/mac/ImageControlsMac.h	2022-01-06 01:39:49 UTC (rev 287663)
@@ -38,6 +38,7 @@
 
 bool hasControls(const HTMLElement&);
 bool isImageControlsButtonElement(const Node&);
+bool isInsideImageControls(const Node&);
 void createImageControls(HTMLElement&);
 bool handleEvent(HTMLElement&, Event&);
 

Modified: trunk/Source/WebCore/html/HTMLImageElement.cpp (287662 => 287663)


--- trunk/Source/WebCore/html/HTMLImageElement.cpp	2022-01-06 01:21:20 UTC (rev 287662)
+++ trunk/Source/WebCore/html/HTMLImageElement.cpp	2022-01-06 01:39:49 UTC (rev 287663)
@@ -30,6 +30,7 @@
 #include "ChromeClient.h"
 #include "Editor.h"
 #include "ElementIterator.h"
+#include "EventLoop.h"
 #include "EventNames.h"
 #include "FrameView.h"
 #include "HTMLAnchorElement.h"
@@ -313,8 +314,7 @@
         if (!parseCompositeAndBlendOperator(value, m_compositeOperator, blendOp))
             m_compositeOperator = CompositeOperator::SourceOver;
 #if ENABLE(SERVICE_CONTROLS)
-    } else if (name == webkitimagemenuAttr) {
-        m_imageMenuEnabled = !value.isNull();
+    } else if (m_imageMenuEnabled) {
         updateImageControls();
 #endif
     } else if (name == loadingAttr) {
@@ -743,7 +743,9 @@
 
     attachment->setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone, true);
     ensureUserAgentShadowRoot().appendChild(WTFMove(attachment));
-    setAttributeWithoutSynchronization(webkitimagemenuAttr, emptyString());
+#if ENABLE(SERVICE_CONTROLS)
+    m_imageMenuEnabled = true;
+#endif
 }
 
 RefPtr<HTMLAttachmentElement> HTMLImageElement::attachmentElement() const
@@ -775,11 +777,13 @@
         return;
     if (!document().settings().imageControlsEnabled())
         return;
-    bool hasControls = hasImageControls();
-    if (!m_imageMenuEnabled && hasControls)
-        destroyImageControls();
-    else if (m_imageMenuEnabled && !hasControls)
-        tryCreateImageControls();
+    document().eventLoop().queueTask(TaskSource::InternalAsyncTask, [this, protectedThis = Ref { *this }] {
+        bool hasControls = hasImageControls();
+        if (!m_imageMenuEnabled && hasControls)
+            destroyImageControls();
+        else if (m_imageMenuEnabled && !hasControls)
+            tryCreateImageControls();
+    });
 }
 
 void HTMLImageElement::tryCreateImageControls()

Modified: trunk/Source/WebCore/html/HTMLImageElement.h (287662 => 287663)


--- trunk/Source/WebCore/html/HTMLImageElement.h	2022-01-06 01:21:20 UTC (rev 287662)
+++ trunk/Source/WebCore/html/HTMLImageElement.h	2022-01-06 01:39:49 UTC (rev 287663)
@@ -147,6 +147,10 @@
     ReferrerPolicy referrerPolicy() const;
 
     bool allowsOrientationOverride() const;
+    
+#if ENABLE(SERVICE_CONTROLS)
+    WEBCORE_EXPORT bool hasImageControls() const;
+#endif
 
 protected:
     HTMLImageElement(const QualifiedName&, Document&, HTMLFormElement* = nullptr);
@@ -197,7 +201,6 @@
     void updateImageControls();
     void tryCreateImageControls();
     void destroyImageControls();
-    bool hasImageControls() const;
     bool childShouldCreateRenderer(const Node&) const override;
 #endif
 

Modified: trunk/Source/WebCore/html/shadow/mac/imageControlsMac.css (287662 => 287663)


--- trunk/Source/WebCore/html/shadow/mac/imageControlsMac.css	2022-01-06 01:21:20 UTC (rev 287662)
+++ trunk/Source/WebCore/html/shadow/mac/imageControlsMac.css	2022-01-06 01:39:49 UTC (rev 287663)
@@ -39,7 +39,7 @@
     
     display: block;
 
-    appearance: -internal-image-controls-button;
+    appearance: auto;
 
     transition: opacity 0.25s;
     opacity: 0.0;

Modified: trunk/Source/WebCore/platform/ThemeTypes.h (287662 => 287663)


--- trunk/Source/WebCore/platform/ThemeTypes.h	2022-01-06 01:21:20 UTC (rev 287662)
+++ trunk/Source/WebCore/platform/ThemeTypes.h	2022-01-06 01:39:49 UTC (rev 287663)
@@ -91,9 +91,6 @@
     ContinuousCapacityLevelIndicatorPart,
     DiscreteCapacityLevelIndicatorPart,
     RatingLevelIndicatorPart,
-#if ENABLE(SERVICE_CONTROLS)
-    ImageControlsButtonPart,
-#endif
 #if ENABLE(APPLE_PAY)
     ApplePayButtonPart,
 #endif
@@ -108,9 +105,21 @@
     AttachmentPart,
     BorderlessAttachmentPart,
 #endif
-    CapsLockIndicatorPart
+    CapsLockIndicatorPart,
+    // Internal-only Values
+#if ENABLE(SERVICE_CONTROLS)
+    ImageControlsButtonPart
+#endif
+    
 };
 
+#if ENABLE(SERVICE_CONTROLS)
+constexpr ControlPart largestControlPart = ImageControlsButtonPart;
+#else
+constexpr ControlPart largestControlPart = CapsLockIndicatorPart
+#endif
+
+
 enum SelectionPart {
     SelectionBackground,
     SelectionForeground

Modified: trunk/Source/WebCore/rendering/HitTestResult.cpp (287662 => 287663)


--- trunk/Source/WebCore/rendering/HitTestResult.cpp	2022-01-06 01:21:20 UTC (rev 287662)
+++ trunk/Source/WebCore/rendering/HitTestResult.cpp	2022-01-06 01:39:49 UTC (rev 287663)
@@ -54,6 +54,10 @@
 #include "VisibleUnits.h"
 #include "XLinkNames.h"
 
+#if ENABLE(SERVICE_CONTROLS)
+#include "ImageControlsMac.h"
+#endif
+
 namespace WebCore {
 
 using namespace HTMLNames;
@@ -335,6 +339,11 @@
 
     if (ImageOverlay::isInsideOverlay(*m_innerNonSharedNode))
         return m_innerNonSharedNode->shadowHost();
+    
+#if ENABLE(SERVICE_CONTROLS)
+    if (ImageControlsMac::isInsideImageControls(*m_innerNonSharedNode))
+        return m_innerNonSharedNode->shadowHost();
+#endif
 
     return m_innerNonSharedNode;
 }

Modified: trunk/Source/WebCore/rendering/RenderTheme.cpp (287662 => 287663)


--- trunk/Source/WebCore/rendering/RenderTheme.cpp	2022-01-06 01:21:20 UTC (rev 287662)
+++ trunk/Source/WebCore/rendering/RenderTheme.cpp	2022-01-06 01:39:49 UTC (rev 287663)
@@ -57,6 +57,9 @@
 #include <wtf/NeverDestroyed.h>
 #include <wtf/text/StringConcatenateNumbers.h>
 
+#if ENABLE(SERVICE_CONTROLS)
+#include "ImageControlsMac.h"
+#endif
 
 #if ENABLE(DATALIST_ELEMENT)
 #include "HTMLDataListElement.h"
@@ -296,6 +299,11 @@
     if (!elementPtr)
         return NoControlPart;
 
+#if ENABLE(SERVICE_CONTROLS)
+    if (isImageControl(*elementPtr))
+        return ImageControlsButtonPart;
+#endif
+    
     Ref element = *elementPtr;
 
     if (is<HTMLInputElement>(element)) {

Modified: trunk/Source/WebCore/rendering/RenderTheme.h (287662 => 287663)


--- trunk/Source/WebCore/rendering/RenderTheme.h	2022-01-06 01:21:20 UTC (rev 287662)
+++ trunk/Source/WebCore/rendering/RenderTheme.h	2022-01-06 01:39:49 UTC (rev 287663)
@@ -367,6 +367,7 @@
 #if ENABLE(SERVICE_CONTROLS)
     virtual void adjustImageControlsButtonStyle(RenderStyle&, const Element*) const;
     virtual bool paintImageControlsButton(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
+    virtual bool isImageControl(const Element&) const { return false; }
 #endif
 
     virtual void adjustProgressBarStyle(RenderStyle&, const Element*) const;

Modified: trunk/Source/WebCore/rendering/RenderThemeMac.h (287662 => 287663)


--- trunk/Source/WebCore/rendering/RenderThemeMac.h	2022-01-06 01:21:20 UTC (rev 287662)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.h	2022-01-06 01:39:49 UTC (rev 287663)
@@ -216,6 +216,7 @@
 #if ENABLE(SERVICE_CONTROLS)
     bool paintImageControlsButton(const RenderObject&, const PaintInfo&, const IntRect&) final;
     IntSize imageControlsButtonSize() const final;
+    bool isImageControl(const Element&) const final;
 
     NSServicesRolloverButtonCell *servicesRolloverButtonCell() const;
 #endif

Modified: trunk/Source/WebCore/rendering/RenderThemeMac.mm (287662 => 287663)


--- trunk/Source/WebCore/rendering/RenderThemeMac.mm	2022-01-06 01:21:20 UTC (rev 287662)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.mm	2022-01-06 01:39:49 UTC (rev 287663)
@@ -83,6 +83,10 @@
 #import <wtf/StdLibExtras.h>
 #import <wtf/text/StringBuilder.h>
 
+#if ENABLE(SERVICE_CONTROLS)
+#include "ImageControlsMac.h"
+#endif
+
 // FIXME: This should go into an SPI.h file in the spi directory.
 @interface NSTextFieldCell ()
 - (CFDictionaryRef)_coreUIDrawOptionsWithFrame:(NSRect)cellFrame inView:(NSView *)controlView includeFocus:(BOOL)includeFocus;
@@ -2309,6 +2313,11 @@
 {
     return IntSize(servicesRolloverButtonCell().cellSize);
 }
+
+bool RenderThemeMac::isImageControl(const Element& elementPtr) const
+{
+    return ImageControlsMac::isImageControlsButtonElement(elementPtr);
+}
 #endif
 
 #if ENABLE(ATTACHMENT_ELEMENT)

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (287662 => 287663)


--- trunk/Source/WebCore/rendering/style/RenderStyle.h	2022-01-06 01:21:20 UTC (rev 287662)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h	2022-01-06 01:39:49 UTC (rev 287663)
@@ -1135,6 +1135,7 @@
     void setAccentColor(const Color& c) { SET_VAR(m_rareInheritedData, accentColor, c); SET_VAR(m_rareInheritedData, hasAutoAccentColor, false);  }
     void setHasAutoAccentColor() { SET_VAR(m_rareInheritedData, hasAutoAccentColor, true); SET_VAR(m_rareInheritedData, accentColor, currentColor()); }
     void setOpacity(float f) { float v = clampTo<float>(f, 0.f, 1.f); SET_VAR(m_rareNonInheritedData, opacity, v); }
+    static_assert(largestControlPart < 1 << appearanceBitWidth, "Control part must fit in storage bits");
     void setAppearance(ControlPart a) { SET_VAR(m_rareNonInheritedData, appearance, a); SET_VAR(m_rareNonInheritedData, effectiveAppearance, a); }
     void setEffectiveAppearance(ControlPart a) { SET_VAR(m_rareNonInheritedData, effectiveAppearance, a); }
     // For valid values of box-align see http://www.w3.org/TR/2009/WD-css3-flexbox-20090723/#alignment

Modified: trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h (287662 => 287663)


--- trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h	2022-01-06 01:21:20 UTC (rev 287662)
+++ trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h	2022-01-06 01:39:49 UTC (rev 287663)
@@ -66,6 +66,8 @@
 
 struct LengthSize;
 
+constexpr int appearanceBitWidth = 7;
+
 // Page size type.
 // StyleRareNonInheritedData::pageSize is meaningful only when
 // StyleRareNonInheritedData::pageSizeType is PAGE_SIZE_RESOLVED.
@@ -200,8 +202,8 @@
     unsigned userDrag : 2; // UserDrag
     unsigned textOverflow : 1; // Whether or not lines that spill out should be truncated with "..."
     unsigned useSmoothScrolling : 1; // ScrollBehavior
-    unsigned appearance : 6; // EAppearance
-    unsigned effectiveAppearance : 6; // EAppearance
+    unsigned appearance : appearanceBitWidth; // EAppearance
+    unsigned effectiveAppearance : appearanceBitWidth; // EAppearance
 
     unsigned textDecorationStyle : 3; // TextDecorationStyle
 

Modified: trunk/Source/WebCore/testing/Internals.cpp (287662 => 287663)


--- trunk/Source/WebCore/testing/Internals.cpp	2022-01-06 01:21:20 UTC (rev 287662)
+++ trunk/Source/WebCore/testing/Internals.cpp	2022-01-06 01:39:49 UTC (rev 287663)
@@ -6389,8 +6389,15 @@
 #endif
 }
 
+#if ENABLE(SERVICE_CONTROLS)
+bool Internals::hasImageControls(const HTMLImageElement& element) const
+{
+    return element.hasImageControls();
+}
 #endif
 
+#endif // ENABLE(ATTACHMENT_ELEMENT)
+
 #if ENABLE(MEDIA_SESSION)
 ExceptionOr<double> Internals::currentMediaSessionPosition(const MediaSession& session)
 {

Modified: trunk/Source/WebCore/testing/Internals.h (287662 => 287663)


--- trunk/Source/WebCore/testing/Internals.h	2022-01-06 01:21:20 UTC (rev 287662)
+++ trunk/Source/WebCore/testing/Internals.h	2022-01-06 01:39:49 UTC (rev 287663)
@@ -1189,7 +1189,10 @@
     };
 
     ExceptionOr<AttachmentThumbnailInfo> attachmentThumbnailInfo(const HTMLAttachmentElement&);
+#if ENABLE(SERVICE_CONTROLS)
+    bool hasImageControls(const HTMLImageElement&) const;
 #endif
+#endif // ENABLE(ATTACHMENT_ELEMENT)
 
 #if ENABLE(MEDIA_SESSION)
     ExceptionOr<double> currentMediaSessionPosition(const MediaSession&);

Modified: trunk/Source/WebCore/testing/Internals.idl (287662 => 287663)


--- trunk/Source/WebCore/testing/Internals.idl	2022-01-06 01:21:20 UTC (rev 287662)
+++ trunk/Source/WebCore/testing/Internals.idl	2022-01-06 01:39:49 UTC (rev 287663)
@@ -1075,6 +1075,7 @@
     undefined setContentSizeCategory(ContentSizeCategory category);
 
     [Conditional=ATTACHMENT_ELEMENT] AttachmentThumbnailInfo attachmentThumbnailInfo(HTMLAttachmentElement element);
+    [Conditional=ATTACHMENT_ELEMENT, Conditional=SERVICE_CONTROLS] boolean hasImageControls(HTMLImageElement element);
 
     [Conditional=MEDIA_SESSION] double currentMediaSessionPosition(MediaSession session);
     [Conditional=MEDIA_SESSION] undefined sendMediaSessionAction(MediaSession session, MediaSessionActionDetails actionDetails);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to