1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627
|
/*
* Copyright (C) 2022 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "InteractionRegion.h"
#include "AccessibilityObject.h"
#include "BorderShape.h"
#include "Document.h"
#include "ElementAncestorIteratorInlines.h"
#include "ElementInlines.h"
#include "ElementRuleCollector.h"
#include "FrameSnapshotting.h"
#include "GeometryUtilities.h"
#include "HTMLAnchorElement.h"
#include "HTMLAttachmentElement.h"
#include "HTMLButtonElement.h"
#include "HTMLFieldSetElement.h"
#include "HTMLFormControlElement.h"
#include "HTMLInputElement.h"
#include "HTMLLabelElement.h"
#include "HitTestResult.h"
#include "LayoutShape.h"
#include "LegacyRenderSVGShape.h"
#include "LegacyRenderSVGShapeInlines.h"
#include "LocalFrame.h"
#include "LocalFrameView.h"
#include "Page.h"
#include "PlatformMouseEvent.h"
#include "PseudoClassChangeInvalidation.h"
#include "RenderAncestorIterator.h"
#include "RenderBoxInlines.h"
#include "RenderImage.h"
#include "RenderLayer.h"
#include "RenderLayerBacking.h"
#include "RenderVideo.h"
#include "SVGSVGElement.h"
#include "SimpleRange.h"
#include "SliderThumbElement.h"
#include "StyleResolver.h"
#include "TextIterator.h"
#include <wtf/NeverDestroyed.h>
#include <wtf/text/MakeString.h>
namespace WebCore {
InteractionRegion::~InteractionRegion() = default;
static bool hasInteractiveCursorType(Element& element)
{
auto* renderer = element.renderer();
auto* style = renderer ? &renderer->style() : nullptr;
auto cursorType = style ? style->cursor() : CursorType::Auto;
if (cursorType == CursorType::Auto && element.enclosingLinkEventParentOrSelf())
cursorType = CursorType::Pointer;
return cursorType == CursorType::Move
|| cursorType == CursorType::Pointer
|| cursorType == CursorType::Text
|| cursorType == CursorType::VerticalText;
}
static bool shouldAllowElement(const Element& element)
{
if (is<HTMLFieldSetElement>(element))
return false;
if (auto* input = dynamicDowncast<HTMLInputElement>(element)) {
if (input->isDisabledFormControl())
return false;
// Do not allow regions for the <input type='range'>, because we make one for the thumb.
if (input->isRangeControl())
return false;
// Do not allow regions for the <input type='file'>, because we make one for the button.
if (input->isFileUpload())
return false;
}
return true;
}
static bool shouldAllowAccessibilityRoleAsPointerCursorReplacement(const Element& element)
{
switch (AccessibilityObject::ariaRoleToWebCoreRole(element.attributeWithoutSynchronization(HTMLNames::roleAttr))) {
case AccessibilityRole::Button:
case AccessibilityRole::Checkbox:
case AccessibilityRole::ImageMapLink:
case AccessibilityRole::Link:
case AccessibilityRole::WebCoreLink:
case AccessibilityRole::ListBoxOption:
case AccessibilityRole::MenuItem:
case AccessibilityRole::MenuItemCheckbox:
case AccessibilityRole::MenuItemRadio:
case AccessibilityRole::PopUpButton:
case AccessibilityRole::RadioButton:
case AccessibilityRole::Switch:
case AccessibilityRole::TextField:
case AccessibilityRole::ToggleButton:
return true;
default:
return false;
}
}
static bool elementMatchesHoverRules(Element& element)
{
bool foundHoverRules = false;
bool initialValue = element.isUserActionElement() && element.document().userActionElements().isHovered(element);
for (auto key : Style::makePseudoClassInvalidationKeys(CSSSelector::PseudoClass::Hover, element)) {
auto& ruleSets = element.styleResolver().ruleSets();
auto* invalidationRuleSets = ruleSets.pseudoClassInvalidationRuleSets(key);
if (!invalidationRuleSets)
continue;
for (auto& invalidationRuleSet : *invalidationRuleSets) {
element.document().userActionElements().setHovered(element, invalidationRuleSet.isNegation == Style::IsNegation::No);
Style::ElementRuleCollector ruleCollector(element, *invalidationRuleSet.ruleSet, nullptr);
ruleCollector.setMode(SelectorChecker::Mode::CollectingRulesIgnoringVirtualPseudoElements);
if (ruleCollector.matchesAnyAuthorRules()) {
foundHoverRules = true;
break;
}
}
if (foundHoverRules)
break;
}
element.document().userActionElements().setHovered(element, initialValue);
return foundHoverRules;
}
static bool shouldAllowNonInteractiveCursorForElement(const Element& element)
{
#if ENABLE(ATTACHMENT_ELEMENT)
if (is<HTMLAttachmentElement>(element))
return true;
#endif
if (RefPtr textElement = dynamicDowncast<HTMLTextFormControlElement>(element))
return !textElement->focused() || !textElement->lastChangeWasUserEdit() || textElement->value().isEmpty();
if (is<HTMLFormControlElement>(element))
return true;
if (is<SliderThumbElement>(element))
return true;
if (is<HTMLAnchorElement>(element))
return true;
if (shouldAllowAccessibilityRoleAsPointerCursorReplacement(element))
return true;
return false;
}
static bool shouldGetOcclusion(const RenderElement& renderer)
{
if (auto* renderLayerModelObject = dynamicDowncast<RenderBox>(renderer)) {
if (renderLayerModelObject->hasLayer() && renderLayerModelObject->layer()->isComposited())
return false;
}
if (renderer.style().specifiedZIndex() > 0)
return true;
if (renderer.isFixedPositioned())
return true;
return false;
}
static bool hasTransparentContainerStyle(const RenderStyle& style)
{
return !style.hasBackground()
&& !style.hasOutline()
&& !style.boxShadow()
&& !style.clipPath()
&& !style.hasExplicitlySetBorderRadius()
// No visible borders or borders that do not create a complete box.
&& (!style.hasVisibleBorder()
|| !(style.borderTopWidth() && style.borderRightWidth() && style.borderBottomWidth() && style.borderLeftWidth()));
}
static bool colorIsChallengingToHighlight(const Color& color)
{
constexpr double luminanceThreshold = 0.01;
return color.isValid()
&& ((color.luminance() < luminanceThreshold || std::abs(color.luminance() - 1) < luminanceThreshold));
}
static bool styleIsChallengingToHighlight(const RenderStyle& style)
{
auto fillPaintType = style.fillPaintType();
if (fillPaintType == SVGPaintType::None) {
auto strokePaintType = style.strokePaintType();
if (strokePaintType != SVGPaintType::RGBColor && strokePaintType != SVGPaintType::CurrentColor)
return false;
return colorIsChallengingToHighlight(style.colorResolvingCurrentColor(style.strokePaintColor()));
}
if (fillPaintType != SVGPaintType::RGBColor && fillPaintType != SVGPaintType::CurrentColor)
return false;
return colorIsChallengingToHighlight(style.colorResolvingCurrentColor(style.fillPaintColor()));
}
static bool isGuardContainer(const Element& element)
{
bool isButton = is<HTMLButtonElement>(element);
bool isLink = element.isLink();
if (!isButton && !isLink)
return false;
if (!element.firstElementChild()
|| element.firstElementChild() != element.lastElementChild())
return false;
if (!element.renderer())
return false;
auto& renderer = *element.renderer();
return hasTransparentContainerStyle(renderer.style());
}
static FloatSize boundingSize(const RenderObject& renderer, const std::optional<AffineTransform>& transform)
{
Vector<LayoutRect> rects;
renderer.boundingRects(rects, LayoutPoint());
if (!rects.size())
return FloatSize();
FloatSize size = unionRect(rects).size();
if (transform)
size.scale(transform->xScale(), transform->yScale());
return size;
}
static bool cachedImageIsPhoto(const CachedImage& cachedImage)
{
if (cachedImage.errorOccurred())
return false;
auto* image = cachedImage.image();
if (!image || !image->isBitmapImage())
return false;
if (image->nativeImage() && image->nativeImage()->hasAlpha())
return false;
return true;
}
static RefPtr<Image> findIconImage(const RenderObject& renderer)
{
if (const auto& renderImage = dynamicDowncast<RenderImage>(renderer)) {
if (!renderImage->cachedImage() || renderImage->cachedImage()->errorOccurred())
return nullptr;
auto* image = renderImage->cachedImage()->imageForRenderer(renderImage);
if (!image)
return nullptr;
if (image->isSVGImageForContainer()
|| (image->isBitmapImage() && image->nativeImage() && image->nativeImage()->hasAlpha()))
return image;
}
return nullptr;
}
static std::optional<std::pair<Ref<SVGSVGElement>, Ref<SVGGraphicsElement>>> findSVGClipElements(const RenderObject& renderer)
{
if (const auto& renderShape = dynamicDowncast<LegacyRenderSVGShape>(renderer)) {
Ref shapeElement = renderShape->protectedGraphicsElement();
if (auto* owner = shapeElement->ownerSVGElement()) {
Ref svgSVGElement = *owner;
return std::make_pair(svgSVGElement, shapeElement);
}
}
return std::nullopt;
}
#if ENABLE(INTERACTION_REGION_TEXT_CONTENT)
static String interactionRegionTextContentForNode(Node& node)
{
if (auto nodeRange = makeRangeSelectingNode(node))
return plainText(*nodeRange);
return { };
}
#endif
std::optional<InteractionRegion> interactionRegionForRenderedRegion(RenderObject& regionRenderer, const FloatRect& bounds, const FloatSize& clipOffset, const std::optional<AffineTransform>& transform)
{
if (bounds.isEmpty())
return std::nullopt;
if (!regionRenderer.node())
return std::nullopt;
auto originalElement = dynamicDowncast<Element>(regionRenderer.node());
if (originalElement && originalElement->isPseudoElement())
return std::nullopt;
auto matchedElement = originalElement;
if (!matchedElement)
matchedElement = regionRenderer.node()->parentElement();
if (!matchedElement)
return std::nullopt;
bool isLabelable = [&] {
auto* htmlElement = dynamicDowncast<HTMLElement>(matchedElement);
return htmlElement && htmlElement->isLabelable();
}();
for (Node* node = matchedElement; node; node = node->parentInComposedTree()) {
auto* element = dynamicDowncast<Element>(node);
if (!element)
continue;
bool matchedButton = is<HTMLButtonElement>(*element);
bool matchedLabel = isLabelable && is<HTMLLabelElement>(*element);
bool matchedLink = element->isLink();
if (matchedButton || matchedLabel || matchedLink) {
matchedElement = element;
break;
}
}
if (!shouldAllowElement(*matchedElement))
return std::nullopt;
if (!matchedElement->renderer())
return std::nullopt;
auto& renderer = *matchedElement->renderer();
if (renderer.usedPointerEvents() == PointerEvents::None)
return std::nullopt;
bool isOriginalMatch = matchedElement == originalElement;
// FIXME: Consider also allowing elements that only receive touch events.
bool hasListener = renderer.style().eventListenerRegionTypes().contains(EventListenerRegionType::MouseClick);
bool hasPointer = hasInteractiveCursorType(*matchedElement) || shouldAllowNonInteractiveCursorForElement(*matchedElement);
RefPtr localMainFrame = dynamicDowncast<LocalFrame>(regionRenderer.document().frame()->mainFrame());
if (!localMainFrame) {
ASSERT_NOT_REACHED();
return std::nullopt;
}
RefPtr pageView = localMainFrame->view();
if (!pageView) {
ASSERT_NOT_REACHED();
return std::nullopt;
}
auto viewportSize = FloatSize(pageView->baseLayoutViewportSize());
auto viewportArea = viewportSize.area();
bool isTooBigForInteraction = bounds.area() > viewportArea / 3;
bool isTooBigForOcclusion = bounds.area() > viewportArea * 3;
auto elementIdentifier = matchedElement->identifier();
if (!hasPointer) {
if (auto* labelElement = dynamicDowncast<HTMLLabelElement>(matchedElement)) {
// Could be a `<label for="...">` or a label with a descendant.
// In cases where both elements get a region we want to group them by the same `elementIdentifier`.
auto associatedElement = labelElement->control();
if (associatedElement && !associatedElement->isDisabledFormControl()) {
hasPointer = true;
elementIdentifier = associatedElement->identifier();
}
}
}
bool detectedHoverRules = false;
if (!hasPointer) {
// The hover check can be expensive (it may end up doing selector matching), so we only run it on some elements.
bool hasVisibleBoxDecorations = renderer.hasVisibleBoxDecorations();
bool nonScrollable = [&] {
auto* box = dynamicDowncast<RenderBox>(renderer);
return !box || (!box->hasScrollableOverflowX() && !box->hasScrollableOverflowY());
}();
if (hasVisibleBoxDecorations && nonScrollable)
detectedHoverRules = elementMatchesHoverRules(*matchedElement);
}
if (!hasListener || !(hasPointer || detectedHoverRules) || isTooBigForInteraction) {
if (isOriginalMatch && shouldGetOcclusion(renderer) && !isTooBigForOcclusion) {
return { {
InteractionRegion::Type::Occlusion,
elementIdentifier,
bounds
} };
}
return std::nullopt;
}
bool isInlineNonBlock = renderer.isInline() && !renderer.isReplacedOrAtomicInline();
bool isPhoto = false;
float minimumContentHintArea = 200 * 200;
bool needsContentHint = bounds.area() > minimumContentHintArea;
if (needsContentHint) {
if (auto* renderImage = dynamicDowncast<RenderImage>(regionRenderer)) {
isPhoto = [&]() -> bool {
#if ENABLE(VIDEO)
if (is<RenderVideo>(renderImage))
return true;
#endif
if (!renderImage->cachedImage())
return false;
return cachedImageIsPhoto(*renderImage->cachedImage());
}();
} else if (regionRenderer.style().hasBackgroundImage()) {
isPhoto = [&]() -> bool {
auto* backgroundImage = regionRenderer.style().backgroundLayers().image();
if (!backgroundImage || !backgroundImage->cachedImage())
return false;
return cachedImageIsPhoto(*backgroundImage->cachedImage());
}();
}
}
bool matchedElementIsGuardContainer = isGuardContainer(*matchedElement);
if (isOriginalMatch && matchedElementIsGuardContainer) {
return { {
InteractionRegion::Type::Guard,
elementIdentifier,
bounds
} };
}
// The parent will get its own InteractionRegion.
if (!isOriginalMatch && !matchedElementIsGuardContainer && !isPhoto && !isInlineNonBlock && !renderer.style().isDisplayTableOrTablePart())
return std::nullopt;
// FIXME: Consider allowing rotation / skew - rdar://127499446.
bool hasRotationOrShear = false;
if (transform)
hasRotationOrShear = transform->isRotateOrShear();
RefPtr<Image> iconImage;
std::optional<std::pair<Ref<SVGSVGElement>, Ref<SVGGraphicsElement>>> svgClipElements;
if (!hasRotationOrShear && !needsContentHint)
iconImage = findIconImage(regionRenderer);
if (!hasRotationOrShear && !iconImage)
svgClipElements = findSVGClipElements(regionRenderer);
auto rect = bounds;
float cornerRadius = 0;
OptionSet<InteractionRegion::CornerMask> maskedCorners { };
std::optional<Path> clipPath = std::nullopt;
auto& style = regionRenderer.style();
RefPtr styleClipPath = style.clipPath();
if (!hasRotationOrShear && styleClipPath && styleClipPath->type() == PathOperation::Type::Shape && originalElement) {
auto size = boundingSize(regionRenderer, transform);
auto path = styleClipPath->getPath(TransformOperationData(FloatRect(FloatPoint(), size)));
if (path && !clipOffset.isZero())
path->translate(clipOffset);
clipPath = path;
} else if (iconImage && originalElement) {
auto size = boundingSize(regionRenderer, transform);
LayoutRect imageRect(FloatPoint(), size);
Ref shape = LayoutShape::createRasterShape(iconImage.get(), 0, imageRect, imageRect, WritingMode(), 0);
LayoutShape::DisplayPaths paths;
shape->buildDisplayPaths(paths);
auto path = paths.shape;
if (!clipOffset.isZero())
path.translate(clipOffset);
clipPath = path;
} else if (svgClipElements) {
auto& [svgSVGElement, shapeElement] = *svgClipElements;
auto path = shapeElement->toClipPath();
FloatSize size = svgSVGElement->currentViewportSizeExcludingZoom();
auto viewBoxTransform = svgSVGElement->viewBoxToViewTransform(size.width(), size.height());
auto shapeBoundingBox = shapeElement->getBBox(SVGLocatable::DisallowStyleUpdate);
path.transform(viewBoxTransform);
shapeBoundingBox = viewBoxTransform.mapRect(shapeBoundingBox);
constexpr float smallShapeDimension = 30;
bool shouldFallbackToContainerRegion = shapeBoundingBox.size().minDimension() < smallShapeDimension
&& styleIsChallengingToHighlight(style)
&& matchedElementIsGuardContainer;
// Bail out, we'll convert the guard container to Interaction.
if (shouldFallbackToContainerRegion)
return std::nullopt;
path.translate(FloatSize(-shapeBoundingBox.x(), -shapeBoundingBox.y()));
if (!clipOffset.isZero())
path.translate(clipOffset);
clipPath = path;
} else if (const auto& renderBox = dynamicDowncast<RenderBox>(regionRenderer)) {
auto borderShape = BorderShape::shapeForBorderRect(renderBox->style(), renderBox->borderBoxRect());
auto borderRadii = borderShape.radii();
auto minRadius = borderRadii.minimumRadius();
auto maxRadius = borderRadii.maximumRadius();
bool needsClipPath = false;
auto checkIfClipPathNeeded = [&](auto radius) {
if (radius != minRadius && radius != maxRadius)
needsClipPath = true;
};
checkIfClipPathNeeded(borderRadii.topLeft().minDimension());
checkIfClipPathNeeded(borderRadii.topRight().minDimension());
checkIfClipPathNeeded(borderRadii.bottomLeft().minDimension());
checkIfClipPathNeeded(borderRadii.bottomRight().minDimension());
if (minRadius == maxRadius)
cornerRadius = minRadius;
else if (!minRadius && !needsClipPath) {
cornerRadius = maxRadius;
if (borderRadii.topLeft().minDimension() == maxRadius)
maskedCorners.add(InteractionRegion::CornerMask::MinXMinYCorner);
if (borderRadii.topRight().minDimension() == maxRadius)
maskedCorners.add(InteractionRegion::CornerMask::MaxXMinYCorner);
if (borderRadii.bottomLeft().minDimension() == maxRadius)
maskedCorners.add(InteractionRegion::CornerMask::MinXMaxYCorner);
if (borderRadii.bottomRight().minDimension() == maxRadius)
maskedCorners.add(InteractionRegion::CornerMask::MaxXMaxYCorner);
} else
clipPath = borderShape.pathForOuterShape(renderBox->document().deviceScaleFactor());
}
bool canTweakShape = !isPhoto
&& !clipPath
&& hasTransparentContainerStyle(style);
if (canTweakShape) {
// We can safely tweak the bounds and radius without causing visual mismatch.
cornerRadius = std::max<float>(cornerRadius, regionRenderer.document().settings().interactionRegionMinimumCornerRadius());
if (isInlineNonBlock)
rect.inflate(regionRenderer.document().settings().interactionRegionInlinePadding());
}
return { {
InteractionRegion::Type::Interaction,
elementIdentifier,
rect,
cornerRadius,
maskedCorners,
isPhoto ? InteractionRegion::ContentHint::Photo : InteractionRegion::ContentHint::Default,
clipPath,
#if ENABLE(INTERACTION_REGION_TEXT_CONTENT)
interactionRegionTextContentForNode(*regionRenderer.node())
#endif
} };
}
TextStream& operator<<(TextStream& ts, const InteractionRegion& interactionRegion)
{
auto regionName = interactionRegion.type == InteractionRegion::Type::Interaction
? "interaction"
: (interactionRegion.type == InteractionRegion::Type::Occlusion ? "occlusion" : "guard");
ts.dumpProperty(regionName, interactionRegion.rectInLayerCoordinates);
if (interactionRegion.contentHint != InteractionRegion::ContentHint::Default)
ts.dumpProperty("content hint", "photo");
auto radius = interactionRegion.cornerRadius;
if (radius > 0) {
if (interactionRegion.maskedCorners.isEmpty())
ts.dumpProperty("cornerRadius", radius);
else {
auto mask = interactionRegion.maskedCorners;
ts.dumpProperty("cornerRadius", makeString(
mask.contains(InteractionRegion::CornerMask::MinXMinYCorner) ? radius : 0, ' ',
mask.contains(InteractionRegion::CornerMask::MaxXMinYCorner) ? radius : 0, ' ',
mask.contains(InteractionRegion::CornerMask::MaxXMaxYCorner) ? radius : 0, ' ',
mask.contains(InteractionRegion::CornerMask::MinXMaxYCorner) ? radius : 0
));
}
}
if (interactionRegion.clipPath)
ts.dumpProperty("clipPath", interactionRegion.clipPath.value());
#if ENABLE(INTERACTION_REGION_TEXT_CONTENT)
if (!interactionRegion.text.isEmpty())
ts.dumpProperty("text", interactionRegion.text);
#endif
return ts;
}
}
|