Source/WebCore/ChangeLog

 12021-12-22 Megan Gardner <megan_gardner@apple.com>
 2
 3 Remove unneeded webkit specific CSS attribute for Image Control Menu.
 4 https://bugs.webkit.org/show_bug.cgi?id=234405
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Test: fast/images/mac/image-controls-basic.html
 9
 10 * css/CSSPrimitiveValueMappings.h:
 11 (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
 12 * css/CSSProperties.json:
 13 * css/CSSValueKeywords.in:
 14 * css/parser/CSSParserIdioms.cpp:
 15 (WebCore::isValueAllowedInMode):
 16 * dom/mac/ImageControlsMac.cpp:
 17 (WebCore::ImageControlsMac::isInsideImageControls):
 18 * dom/mac/ImageControlsMac.h:
 19 * html/HTMLImageElement.cpp:
 20 (WebCore::HTMLImageElement::parseAttribute):
 21 (WebCore::HTMLImageElement::setAttachmentElement):
 22 (WebCore::HTMLImageElement::updateImageControls):
 23 * html/HTMLImageElement.h:
 24 * html/shadow/mac/imageControlsMac.css:
 25 (div#image-controls button#image-controls-button):
 26 * platform/ThemeTypes.h:
 27 * rendering/HitTestResult.cpp:
 28 (WebCore::HitTestResult::nodeForImageData const):
 29 * rendering/RenderTheme.cpp:
 30 (WebCore::RenderTheme::autoAppearanceForElement const):
 31 * rendering/RenderTheme.h:
 32 (WebCore::RenderTheme::isImageControl const):
 33 * rendering/RenderThemeMac.h:
 34 * rendering/RenderThemeMac.mm:
 35 (WebCore::RenderThemeMac::isImageControl const):
 36 * rendering/style/RenderStyle.h:
 37 (WebCore::RenderStyle::setAppearance):
 38 (WebCore::RenderStyle::setEffectiveAppearance):
 39 * rendering/style/StyleRareNonInheritedData.h:
 40 * testing/Internals.cpp:
 41 (WebCore::Internals::hasImageControls const):
 42 * testing/Internals.h:
 43 * testing/Internals.idl:
 44
1452021-12-20 Wenson Hsieh <wenson_hsieh@apple.com>
246
347 Adopt ChromeClient::classifyModalContainerControls() in ModalContainerObserver

Source/WebCore/css/CSSPrimitiveValueMappings.h

@@template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ControlPart e)
634634#endif
635635#if ENABLE(SERVICE_CONTROLS)
636636 case ImageControlsButtonPart:
637  m_value.valueID = CSSValueInternalImageControlsButton;
 637 ASSERT_NOT_REACHED();
 638 m_value.valueID = CSSValueNone;
638639 break;
639640#endif
640641#if ENABLE(APPLE_PAY)

Source/WebCore/css/CSSProperties.json

51775177 "continuous-capacity-level-indicator",
51785178 "discrete-capacity-level-indicator",
51795179 "rating-level-indicator",
5180  "-internal-image-controls-button",
51815180 "-apple-pay-button",
51825181 "textarea",
51835182 "attachment",

Source/WebCore/css/CSSValueKeywords.in

@@relevancy-level-indicator
890890continuous-capacity-level-indicator
891891discrete-capacity-level-indicator
892892rating-level-indicator
893 #if defined(ENABLE_SERVICE_CONTROLS) && ENABLE_SERVICE_CONTROLS
894 -internal-image-controls-button
895 #endif
896893#if defined(ENABLE_APPLE_PAY) && ENABLE_APPLE_PAY
897894-apple-pay-button
898895#endif

Source/WebCore/css/parser/CSSParserIdioms.cpp

@@bool isValueAllowedInMode(unsigned short id, CSSParserMode mode)
4040 return isUASheetBehavior(mode);
4141 case CSSValueWebkitFocusRingColor:
4242 return isUASheetBehavior(mode) || isQuirksModeBehavior(mode);
43 #if ENABLE(SERVICE_CONTROLS)
44  case CSSValueInternalImageControlsButton:
45  return isUASheetBehavior(mode);
46 #endif
4743 default:
4844 return true;
4945 }

Source/WebCore/dom/mac/ImageControlsMac.cpp

@@bool isImageControlsButtonElement(const Node& node)
7373 return is<Element>(node) && downcast<Element>(node).getIdAttribute() == imageControlsButtonIdentifier();
7474}
7575
 76bool isInsideImageControls(const Node& node)
 77{
 78 RefPtr host = node.shadowHost();
 79 if (!is<HTMLElement>(host.get()) || !hasControls(downcast<HTMLElement>(*host)))
 80 return false;
 81 return is<Element>(node) && downcast<Element>(node).getIdAttribute() == imageControlsElementIdentifier();
 82}
 83
7684void createImageControls(HTMLElement& element)
7785{
7886 Ref document = element.document();

Source/WebCore/dom/mac/ImageControlsMac.h

@@namespace ImageControlsMac {
3838
3939bool hasControls(const HTMLElement&);
4040bool isImageControlsButtonElement(const Node&);
 41bool isInsideImageControls(const Node&);
4142void createImageControls(HTMLElement&);
4243bool handleEvent(HTMLElement&, Event&);
4344

Source/WebCore/html/HTMLImageElement.cpp

3030#include "ChromeClient.h"
3131#include "Editor.h"
3232#include "ElementIterator.h"
 33#include "EventLoop.h"
3334#include "EventNames.h"
3435#include "FrameView.h"
3536#include "HTMLAnchorElement.h"

@@void HTMLImageElement::parseAttribute(const QualifiedName& name, const AtomStrin
313314 if (!parseCompositeAndBlendOperator(value, m_compositeOperator, blendOp))
314315 m_compositeOperator = CompositeOperator::SourceOver;
315316#if ENABLE(SERVICE_CONTROLS)
316  } else if (name == webkitimagemenuAttr) {
317  m_imageMenuEnabled = !value.isNull();
 317 } else if (m_imageMenuEnabled) {
318318 updateImageControls();
319319#endif
320320 } else if (name == loadingAttr) {

@@void HTMLImageElement::setAttachmentElement(Ref<HTMLAttachmentElement>&& attachm
743743
744744 attachment->setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone, true);
745745 ensureUserAgentShadowRoot().appendChild(WTFMove(attachment));
746  setAttributeWithoutSynchronization(webkitimagemenuAttr, emptyString());
 746#if ENABLE(SERVICE_CONTROLS)
 747 m_imageMenuEnabled = true;
 748#endif // ENABLE(SERVICE_CONTROLS)
747749}
748750
749751RefPtr<HTMLAttachmentElement> HTMLImageElement::attachmentElement() const

@@void HTMLImageElement::updateImageControls()
775777 return;
776778 if (!document().settings().imageControlsEnabled())
777779 return;
778  bool hasControls = hasImageControls();
779  if (!m_imageMenuEnabled && hasControls)
780  destroyImageControls();
781  else if (m_imageMenuEnabled && !hasControls)
782  tryCreateImageControls();
 780 document().eventLoop().queueTask(TaskSource::InternalAsyncTask, [this, protectedThis = Ref { *this }] {
 781 bool hasControls = hasImageControls();
 782 if (!m_imageMenuEnabled && hasControls)
 783 destroyImageControls();
 784 else if (m_imageMenuEnabled && !hasControls)
 785 tryCreateImageControls();
 786 });
783787}
784788
785789void HTMLImageElement::tryCreateImageControls()

Source/WebCore/html/HTMLImageElement.h

@@public:
147147 ReferrerPolicy referrerPolicy() const;
148148
149149 bool allowsOrientationOverride() const;
 150
 151#if ENABLE(SERVICE_CONTROLS)
 152 WEBCORE_EXPORT bool hasImageControls() const;
 153#endif
150154
151155protected:
152156 HTMLImageElement(const QualifiedName&, Document&, HTMLFormElement* = nullptr);

@@private:
197201 void updateImageControls();
198202 void tryCreateImageControls();
199203 void destroyImageControls();
200  bool hasImageControls() const;
201204 bool childShouldCreateRenderer(const Node&) const override;
202205#endif
203206

Source/WebCore/html/shadow/mac/imageControlsMac.css

@@div#image-controls button#image-controls-button {
3939
4040 display: block;
4141
42  appearance: -internal-image-controls-button;
 42 appearance: auto;
4343
4444 transition: opacity 0.25s;
4545 opacity: 0.0;

Source/WebCore/platform/ThemeTypes.h

@@enum ControlPart {
9191 ContinuousCapacityLevelIndicatorPart,
9292 DiscreteCapacityLevelIndicatorPart,
9393 RatingLevelIndicatorPart,
94 #if ENABLE(SERVICE_CONTROLS)
95  ImageControlsButtonPart,
96 #endif
9794#if ENABLE(APPLE_PAY)
9895 ApplePayButtonPart,
9996#endif

@@enum ControlPart {
108105 AttachmentPart,
109106 BorderlessAttachmentPart,
110107#endif
111  CapsLockIndicatorPart
 108 CapsLockIndicatorPart,
 109 // Internal-only Values
 110#if ENABLE(SERVICE_CONTROLS)
 111 ImageControlsButtonPart,
 112 LargestControlPart = ImageControlsButtonPart
 113#else
 114 LargestControlPart = CapsLockIndicatorPart
 115#endif
 116
112117};
113118
114119enum SelectionPart {

Source/WebCore/rendering/HitTestResult.cpp

5454#include "VisibleUnits.h"
5555#include "XLinkNames.h"
5656
 57#if ENABLE(SERVICE_CONTROLS)
 58#include "ImageControlsMac.h"
 59#endif
 60
5761namespace WebCore {
5862
5963using namespace HTMLNames;

@@RefPtr<Node> HitTestResult::nodeForImageData() const
335339
336340 if (ImageOverlay::isInsideOverlay(*m_innerNonSharedNode))
337341 return m_innerNonSharedNode->shadowHost();
 342
 343#if ENABLE(SERVICE_CONTROLS)
 344 if (ImageControlsMac::isInsideImageControls(*m_innerNonSharedNode))
 345 return m_innerNonSharedNode->shadowHost();
 346#endif
338347
339348 return m_innerNonSharedNode;
340349}

Source/WebCore/rendering/RenderTheme.cpp

5757#include <wtf/NeverDestroyed.h>
5858#include <wtf/text/StringConcatenateNumbers.h>
5959
 60#if ENABLE(SERVICE_CONTROLS)
 61#include "ImageControlsMac.h"
 62#endif
6063
6164#if ENABLE(DATALIST_ELEMENT)
6265#include "HTMLDataListElement.h"

@@ControlPart RenderTheme::autoAppearanceForElement(const Element* elementPtr) con
296299 if (!elementPtr)
297300 return NoControlPart;
298301
 302#if ENABLE(SERVICE_CONTROLS)
 303 if (isImageControl(elementPtr))
 304 return ImageControlsButtonPart;
 305#endif
299306 Ref element = *elementPtr;
300307
301308 if (is<HTMLInputElement>(element)) {

Source/WebCore/rendering/RenderTheme.h

@@protected:
367367#if ENABLE(SERVICE_CONTROLS)
368368 virtual void adjustImageControlsButtonStyle(RenderStyle&, const Element*) const;
369369 virtual bool paintImageControlsButton(const RenderObject&, const PaintInfo&, const IntRect&) { return true; }
 370 virtual bool isImageControl(const Element*) const { return false; }
370371#endif
371372
372373 virtual void adjustProgressBarStyle(RenderStyle&, const Element*) const;

Source/WebCore/rendering/RenderThemeMac.h

@@private:
216216#if ENABLE(SERVICE_CONTROLS)
217217 bool paintImageControlsButton(const RenderObject&, const PaintInfo&, const IntRect&) final;
218218 IntSize imageControlsButtonSize() const final;
 219 bool isImageControl(const Element*) const final;
219220
220221 NSServicesRolloverButtonCell *servicesRolloverButtonCell() const;
221222#endif

Source/WebCore/rendering/RenderThemeMac.mm

8383#import <wtf/StdLibExtras.h>
8484#import <wtf/text/StringBuilder.h>
8585
 86#if ENABLE(SERVICE_CONTROLS)
 87#include "ImageControlsMac.h"
 88#endif
 89
8690// FIXME: This should go into an SPI.h file in the spi directory.
8791@interface NSTextFieldCell ()
8892- (CFDictionaryRef)_coreUIDrawOptionsWithFrame:(NSRect)cellFrame inView:(NSView *)controlView includeFocus:(BOOL)includeFocus;

@@IntSize RenderThemeMac::imageControlsButtonSize() const
23092313{
23102314 return IntSize(servicesRolloverButtonCell().cellSize);
23112315}
 2316
 2317bool RenderThemeMac::isImageControl(const Element* elementPtr) const
 2318{
 2319 if (ImageControlsMac::isImageControlsButtonElement(*elementPtr))
 2320 return true;
 2321 return false;
 2322}
23122323#endif
23132324
23142325#if ENABLE(ATTACHMENT_ELEMENT)

Source/WebCore/rendering/style/RenderStyle.h

@@public:
11411141 void setAccentColor(const Color& c) { SET_VAR(m_rareInheritedData, accentColor, c); SET_VAR(m_rareInheritedData, hasAutoAccentColor, false); }
11421142 void setHasAutoAccentColor() { SET_VAR(m_rareInheritedData, hasAutoAccentColor, true); SET_VAR(m_rareInheritedData, accentColor, currentColor()); }
11431143 void setOpacity(float f) { float v = clampTo<float>(f, 0.f, 1.f); SET_VAR(m_rareNonInheritedData, opacity, v); }
1144  void setAppearance(ControlPart a) { SET_VAR(m_rareNonInheritedData, appearance, a); SET_VAR(m_rareNonInheritedData, effectiveAppearance, a); }
1145  void setEffectiveAppearance(ControlPart a) { SET_VAR(m_rareNonInheritedData, effectiveAppearance, a); }
 1144 void setAppearance(ControlPart a)
 1145 {
 1146 static_assert(LargestControlPart < 1 << APPEARANCE_BIT_WIDTH, "Control part must fit in storage bits");
 1147 SET_VAR(m_rareNonInheritedData, appearance, a);
 1148 SET_VAR(m_rareNonInheritedData, effectiveAppearance, a);
 1149 }
 1150 void setEffectiveAppearance(ControlPart a)
 1151 {
 1152 static_assert(LargestControlPart < 1 << APPEARANCE_BIT_WIDTH, "Control part must fit in storage bits");
 1153 SET_VAR(m_rareNonInheritedData, effectiveAppearance, a);
 1154 }
11461155 // For valid values of box-align see http://www.w3.org/TR/2009/WD-css3-flexbox-20090723/#alignment
11471156 void setBoxAlign(BoxAlignment a) { SET_NESTED_VAR(m_rareNonInheritedData, deprecatedFlexibleBox, align, static_cast<unsigned>(a)); }
11481157 void setBoxDirection(BoxDirection d) { m_inheritedFlags.boxDirection = static_cast<unsigned>(d); }

Source/WebCore/rendering/style/StyleRareNonInheritedData.h

@@class StyleTransformData;
6666
6767struct LengthSize;
6868
 69#define APPEARANCE_BIT_WIDTH 7
 70
6971// Page size type.
7072// StyleRareNonInheritedData::pageSize is meaningful only when
7173// StyleRareNonInheritedData::pageSizeType is PAGE_SIZE_RESOLVED.

@@public:
202204 unsigned useSmoothScrolling : 1; // ScrollBehavior
203205 unsigned marginBeforeCollapse : 2; // MarginCollapse
204206 unsigned marginAfterCollapse : 2; // MarginCollapse
205  unsigned appearance : 6; // EAppearance
206  unsigned effectiveAppearance : 6; // EAppearance
 207 unsigned appearance : APPEARANCE_BIT_WIDTH; // EAppearance
 208 unsigned effectiveAppearance : APPEARANCE_BIT_WIDTH; // EAppearance
207209 unsigned borderFit : 1; // BorderFit
208210 unsigned textCombine : 1; // CSS3 text-combine properties
209211

Source/WebCore/testing/Internals.cpp

@@ExceptionOr<Internals::AttachmentThumbnailInfo> Internals::attachmentThumbnailIn
63976397#endif
63986398}
63996399
6400 #endif
 6400#if ENABLE(SERVICE_CONTROLS)
 6401bool Internals::hasImageControls(const HTMLImageElement& element) const
 6402{
 6403 return element.hasImageControls();
 6404}
 6405#endif // ENABLE(SERVICE_CONTROLS)
 6406
 6407#endif // ENABLE(ATTACHMENT_ELEMENT)
64016408
64026409#if ENABLE(MEDIA_SESSION)
64036410ExceptionOr<double> Internals::currentMediaSessionPosition(const MediaSession& session)

Source/WebCore/testing/Internals.h

@@public:
11841184 };
11851185
11861186 ExceptionOr<AttachmentThumbnailInfo> attachmentThumbnailInfo(const HTMLAttachmentElement&);
1187 #endif
 1187#if ENABLE(SERVICE_CONTROLS)
 1188 bool hasImageControls(const HTMLImageElement&) const;
 1189#endif // ENABLE(SERVICE_CONTROLS)
 1190#endif // ENABLE(ATTACHMENT_ELEMENT)
11881191
11891192#if ENABLE(MEDIA_SESSION)
11901193 ExceptionOr<double> currentMediaSessionPosition(const MediaSession&);

Source/WebCore/testing/Internals.idl

@@enum HEVCParameterCodec {
10711071 undefined setContentSizeCategory(ContentSizeCategory category);
10721072
10731073 [Conditional=ATTACHMENT_ELEMENT] AttachmentThumbnailInfo attachmentThumbnailInfo(HTMLAttachmentElement element);
 1074 [Conditional=ATTACHMENT_ELEMENT, Conditional=SERVICE_CONTROLS] boolean hasImageControls(HTMLImageElement element);
10741075
10751076 [Conditional=MEDIA_SESSION] double currentMediaSessionPosition(MediaSession session);
10761077 [Conditional=MEDIA_SESSION] undefined sendMediaSessionAction(MediaSession session, MediaSessionActionDetails actionDetails);

LayoutTests/ChangeLog

 12021-12-22 Megan Gardner <megan_gardner@apple.com>
 2
 3 Remove unneeded webkit specific CSS attribute for Image Control Menu.
 4 https://bugs.webkit.org/show_bug.cgi?id=234405
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 We need to move this test to be a mac specific one, as it now has mac specific
 9 test harnessing.
 10
 11 * TestExpectations:
 12 * fast/images/image-controls-basic-expected.txt: Removed.
 13 * fast/images/image-controls-basic.html: Removed.
 14 * fast/images/mac/image-controls-basic-expected.txt: Renamed from LayoutTests/platform/mac/fast/images/image-controls-basic-expected.txt.
 15 * fast/images/mac/image-controls-basic.html: Added.
 16 * platform/mac-catalina/fast/images/image-controls-basic-expected.txt: Removed.
 17 * platform/mac/TestExpectations:
 18 * platform/win/TestExpectations:
 19
1202021-12-20 Arcady Goldmints-Orlov <agoldmints@igalia.com>
221
322 [GLIB] Update test expectations for some fast/box-shadow tests.

LayoutTests/TestExpectations

@@fast/forms/select/mac-wk2 [ Skip ]
4040fast/forms/textarea/ios [ Skip ]
4141fast/forms/watchos [ Skip ]
4242fast/images/text-recognition [ Skip ]
 43fast/images/mac [ Skip ]
4344fast/sandbox/ios [ Skip ]
4445fast/sandbox/mac [ Skip ]
4546fast/viewport/watchos [ Skip ]

LayoutTests/fast/images/image-controls-basic-expected.txt

1 layer at (0,0) size 800x600
2  RenderView at (0,0) size 800x600
3 layer at (0,0) size 800x600
4  RenderBlock {HTML} at (0,0) size 800x600
5  RenderBody {BODY} at (8,8) size 784x584
6  RenderImage {IMG} at (0,0) size 256x256
7  RenderText {#text} at (0,0) size 0x0

LayoutTests/fast/images/image-controls-basic.html

1  <script>
2 if (window.internals)
3  internals.settings.setImageControlsEnabled(true);
4 
5 </script>
6 <body>
7 <img src="resources/green-256x256.jpg" x-webkit-imagemenu>
8 </body>

LayoutTests/fast/images/mac/image-controls-basic-expected.txt

 1layer at (0,0) size 800x600
 2 RenderView at (0,0) size 800x600
 3layer at (0,0) size 800x276
 4 RenderBlock {HTML} at (0,0) size 800x276
 5 RenderBody {BODY} at (8,8) size 784x260
 6 RenderImage {IMG} at (0,0) size 256x256
 7 RenderText {#text} at (0,0) size 0x0
 8 RenderText {#text} at (0,0) size 0x0
 9layer at (8,8) size 256x256
 10 RenderBlock (relative positioned) {DIV} at (0,0) size 256x256 [color=#00000000]
 11layer at (215,30) size 27x26
 12 RenderButton {BUTTON} at (207,22) size 27x26 [color=#000000D8] [bgcolor=#C0C0C0] [border: (2px outset #C0C0C0)]

LayoutTests/fast/images/mac/image-controls-basic.html

 1<!DOCTYPE html><!-- webkit-test-runner [ AttachmentElementEnabled=true ] -->
 2<html>
 3<head>
 4<script>
 5if (window.testRunner) {
 6 testRunner.waitUntilDone();
 7}
 8if (window.internals) {
 9 internals.settings.setImageControlsEnabled(true);
 10}
 11</script>
 12</head>
 13<body>
 14<img id="target" src="../resources/green-256x256.jpg">
 15<script>
 16 function hasImageControls(elem)
 17 {
 18 if (window.internals)
 19 return internals.hasImageControls(elem);
 20 return false;
 21 }
 22
 23 jsTestIsAsync = true;
 24
 25 var elem = document.getElementById("target");
 26 var ID = HTMLAttachmentElement.getAttachmentIdentifier(elem);
 27
 28 setInterval(() => {
 29 if (hasImageControls(elem))
 30 testRunner.notifyDone();
 31 }, 200);
 32</script>
 33</body>
 34</html>

LayoutTests/platform/mac-catalina/fast/images/image-controls-basic-expected.txt

1 layer at (0,0) size 800x600
2  RenderView at (0,0) size 800x600
3 layer at (0,0) size 800x600
4  RenderBlock {HTML} at (0,0) size 800x600
5  RenderBody {BODY} at (8,8) size 784x584
6  RenderImage {IMG} at (0,0) size 256x256
7  RenderText {#text} at (0,0) size 0x0
8 layer at (8,8) size 256x256
9  RenderBlock (relative positioned) {DIV} at (0,0) size 256x256 [color=#00000000]
10 layer at (215,30) size 27x26
11  RenderButton {BUTTON} at (207,22) size 27x26 [color=#000000D8] [bgcolor=#C0C0C0] [border: (2px outset #C0C0C0)]

LayoutTests/platform/mac/TestExpectations

@@editing/pasteboard/mac [ Pass ]
1616fast/dom/Range/mac [ Pass ]
1717fast/scrolling/latching [ Pass ]
1818model-element [ Pass ]
 19fast/images/mac [ Pass ]
1920
2021# Disable plug-in tests on Apple Silicon
2122[ arm64 ] compositing/plugins [ Skip ]

LayoutTests/platform/mac/fast/images/image-controls-basic-expected.txt

1 layer at (0,0) size 800x600
2  RenderView at (0,0) size 800x600
3 layer at (0,0) size 800x600
4  RenderBlock {HTML} at (0,0) size 800x600
5  RenderBody {BODY} at (8,8) size 784x584
6  RenderImage {IMG} at (0,0) size 256x256
7  RenderText {#text} at (0,0) size 0x0
8 layer at (8,8) size 256x256
9  RenderBlock (relative positioned) {DIV} at (0,0) size 256x256 [color=#00000000]
10 layer at (214,30) size 28x26
11  RenderButton {BUTTON} at (206,22) size 28x26 [color=#000000D8] [bgcolor=#C0C0C0] [border: (2px outset #C0C0C0)]