haikuwebkit/Source/WebCore/html/shadow/imageOverlay.css

53 lines
1.9 KiB
CSS
Raw Permalink Normal View History

Introduce image overlays and add UA shadow root support for image extraction https://bugs.webkit.org/show_bug.cgi?id=221236 Reviewed by Ryosuke Niwa. This patch restores some of the logic previously introduced in r164457 (and removed with r272117) to render service button cells over images, and additionally renames and repurposes it for image extraction, a new accessibility feature. See comments below for more details. * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: * html/HTMLElement.cpp: (WebCore::imageOverlayElementIdentifier): (WebCore::HTMLElement::hasImageOverlay const): Add a helper to determine whether or not an element's UA shadow root has an image overlay element. This is consulted in the constructor of `RenderImage`. (WebCore::HTMLElement::updateWithImageExtractionResult): Add a helper method to install image extraction content in the shadow root of an element, given an `ImageExtractionResult`. This consists of an image overlay container (a relatively positioned `div`), which then contains some number of absolutely positioned child `div` elements. Additionally load the image overlay stylesheet as text within a style element when creating the UA shadow root. * html/HTMLElement.h: * html/shadow/imageOverlay.css: Added. (div#image-overlay): (div.image-overlay-text): Add a new UA stylesheet for the image overlay shadow DOM subtree. The overlay contains a number of absolutely positoned `div` elements, which are positioned inside the overlay element using using CSS transforms. * rendering/RenderImage.cpp: (WebCore::RenderImage::RenderImage): (WebCore::RenderImage::canHaveChildren const): Return `true` if we require children in the shadow root (for either media controls, or this new image overlay). (WebCore::RenderImage::layout): (WebCore::RenderImage::layoutShadowContent): (WebCore::RenderImage::layoutShadowControls): Deleted. Rename `layoutShadowControls` to `layoutShadowContent`, and allow it to support both the "shadow controls" case (i.e. `RenderMedia`) and the "image extraction content" case. Additonally, remove the check for `shadowControlsNeedCustomLayoutMetrics()` when setting child renderer width/height. This is currently only used for laying out media controls in `RenderMedia`, but we'll need it now for all `RenderImage`s. * rendering/RenderImage.h: (WebCore::RenderImage::setHasImageOverlay): (WebCore::RenderImage::hasShadowContent const): Add a helper method to return whether or not the `RenderImage` should expect shadow root content. This is true for both media controls (`m_hasShadowControls`) and for the new image overlay content (`m_hasImageOverlay`). (WebCore::RenderImage::shadowControlsNeedCustomLayoutMetrics const): Deleted. * rendering/RenderMedia.h: See `RenderImage::layoutShadowControls` above. Canonical link: https://commits.webkit.org/233781@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@272467 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-02-07 03:28:55 +00:00
/*
* Copyright (C) 2021 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. ``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
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* 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.
*/
div#image-overlay {
display: inline-block;
position: relative;
overflow: hidden;
color: transparent;
text-shadow: none;
Introduce image overlays and add UA shadow root support for image extraction https://bugs.webkit.org/show_bug.cgi?id=221236 Reviewed by Ryosuke Niwa. This patch restores some of the logic previously introduced in r164457 (and removed with r272117) to render service button cells over images, and additionally renames and repurposes it for image extraction, a new accessibility feature. See comments below for more details. * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: * html/HTMLElement.cpp: (WebCore::imageOverlayElementIdentifier): (WebCore::HTMLElement::hasImageOverlay const): Add a helper to determine whether or not an element's UA shadow root has an image overlay element. This is consulted in the constructor of `RenderImage`. (WebCore::HTMLElement::updateWithImageExtractionResult): Add a helper method to install image extraction content in the shadow root of an element, given an `ImageExtractionResult`. This consists of an image overlay container (a relatively positioned `div`), which then contains some number of absolutely positioned child `div` elements. Additionally load the image overlay stylesheet as text within a style element when creating the UA shadow root. * html/HTMLElement.h: * html/shadow/imageOverlay.css: Added. (div#image-overlay): (div.image-overlay-text): Add a new UA stylesheet for the image overlay shadow DOM subtree. The overlay contains a number of absolutely positoned `div` elements, which are positioned inside the overlay element using using CSS transforms. * rendering/RenderImage.cpp: (WebCore::RenderImage::RenderImage): (WebCore::RenderImage::canHaveChildren const): Return `true` if we require children in the shadow root (for either media controls, or this new image overlay). (WebCore::RenderImage::layout): (WebCore::RenderImage::layoutShadowContent): (WebCore::RenderImage::layoutShadowControls): Deleted. Rename `layoutShadowControls` to `layoutShadowContent`, and allow it to support both the "shadow controls" case (i.e. `RenderMedia`) and the "image extraction content" case. Additonally, remove the check for `shadowControlsNeedCustomLayoutMetrics()` when setting child renderer width/height. This is currently only used for laying out media controls in `RenderMedia`, but we'll need it now for all `RenderImage`s. * rendering/RenderImage.h: (WebCore::RenderImage::setHasImageOverlay): (WebCore::RenderImage::hasShadowContent const): Add a helper method to return whether or not the `RenderImage` should expect shadow root content. This is true for both media controls (`m_hasShadowControls`) and for the new image overlay content (`m_hasImageOverlay`). (WebCore::RenderImage::shadowControlsNeedCustomLayoutMetrics const): Deleted. * rendering/RenderMedia.h: See `RenderImage::layoutShadowControls` above. Canonical link: https://commits.webkit.org/233781@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@272467 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-02-07 03:28:55 +00:00
text-align: center;
white-space: nowrap;
line-height: 100%;
font-family: system-ui;
Subdivide image overlay text into one or more elements per line https://bugs.webkit.org/show_bug.cgi?id=225038 rdar://75505043 Reviewed by Tim Horton and Devin Rousso. Source/WebCore: Refactor some image extraction and image overlay code to allow for multiple elements containing text per line. See comments below for more details. Changes covered by augmenting existing layout tests. * html/HTMLElement.cpp: (WebCore::HTMLElement::updateWithImageExtractionResult): The crux of this change is in this method. Currently, an image overlay has one or more `div` elements underneath the root container element, each of which represents a single line (i.e. contains a text node and a line break). Instead, we make each of these line container `div`s contain one or more `div` elements that represent further subdivided text within each line. See the corresponding additions patch for more details. * html/shadow/imageOverlay.css: (div#image-overlay): (div.image-overlay-line, .image-overlay-text): (.image-overlay-text::selection): Adjust UA stylesheet to account for the changes in `updateWithImageExtractionResult`. (div.image-overlay-text): Deleted. (div.image-overlay-text::selection): Deleted. * platform/ImageExtractionResult.h: (WebCore::ImageExtractionTextData::ImageExtractionTextData): (WebCore::ImageExtractionLineData::ImageExtractionLineData): (WebCore::ImageExtractionLineData::encode const): (WebCore::ImageExtractionLineData::decode): Refactor this data structure, by splitting it into `ImageExtractionLineData` and `ImageExtractionTextData`. (WebCore::ImageExtractionResult::isEmpty const): (WebCore::ImageExtractionResult::encode const): (WebCore::ImageExtractionResult::decode): * platform/graphics/FloatPoint.h: (WebCore::FloatPoint::rotate): Add a helper method to rotate a 2D `FloatPoint` by a given angle, about a given point. * platform/graphics/GeometryUtilities.cpp: (WebCore::rotatedBoundingRectWithMinimumAngleOfRotation): (WebCore::rotatedBoundingRect): Deleted. * platform/graphics/GeometryUtilities.h: * testing/Internals.cpp: (WebCore::getQuad): (WebCore::makeDataForLine): (WebCore::Internals::installImageOverlay): * testing/Internals.h: * testing/Internals.idl: Adjust this internal testing hook to accept a list of `ImageOverlayLine` dictionaries, each of which contains a list of `ImageOverlayText` dictionaries. Tools: Adjust several existing layout tests after changing `internals.installImageOverlay`. See WebCore ChangeLog for more details. Additionally, rename a WebCore geometry helper method. * TestWebKitAPI/Tests/WebCore/FloatQuadTests.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WebKit/simple-image-overlay.html: LayoutTests: Adjust several existing layout tests after changing `internals.installImageOverlay`. See WebCore ChangeLog for more details. * fast/images/image-extraction/basic-image-overlay.html: * fast/images/image-extraction/click-link-with-image-overlay.html: * fast/images/image-extraction/image-overlay-creation-is-idempotent.html: * fast/images/image-extraction/image-overlay-in-image-with-zero-font-size.html: * fast/images/image-extraction/image-overlay-with-selection-styles-expected.html: * fast/images/image-extraction/image-overlay-with-selection-styles.html: * fast/images/image-extraction/ios/reselect-word-in-image-overlay.html: * fast/images/image-extraction/ios/select-word-in-image-overlay-inside-link.html: * fast/images/image-extraction/ios/select-word-in-image-overlay.html: * fast/images/image-extraction/ios/selection-rects-in-image-overlay.html: * fast/images/image-extraction/mac/copy-image-overlay-text-with-context-menu.html: * fast/images/image-extraction/mac/select-image-overlay-in-link-with-mouse-drag.html: * fast/images/image-extraction/mac/select-image-overlay-with-mouse-drag-does-not-fire-click.html: * fast/images/image-extraction/mac/select-image-overlay-with-mouse-drag.html: * fast/images/image-extraction/mac/select-word-in-draggable-image-overlay.html: * fast/images/image-extraction/mac/select-word-in-transparent-image-overlay.html: Canonical link: https://commits.webkit.org/237054@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276626 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-27 02:59:18 +00:00
font-size: 1024px; /* This large font size is chosen to minimize gaps when painting selection quads. */
Introduce image overlays and add UA shadow root support for image extraction https://bugs.webkit.org/show_bug.cgi?id=221236 Reviewed by Ryosuke Niwa. This patch restores some of the logic previously introduced in r164457 (and removed with r272117) to render service button cells over images, and additionally renames and repurposes it for image extraction, a new accessibility feature. See comments below for more details. * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: * html/HTMLElement.cpp: (WebCore::imageOverlayElementIdentifier): (WebCore::HTMLElement::hasImageOverlay const): Add a helper to determine whether or not an element's UA shadow root has an image overlay element. This is consulted in the constructor of `RenderImage`. (WebCore::HTMLElement::updateWithImageExtractionResult): Add a helper method to install image extraction content in the shadow root of an element, given an `ImageExtractionResult`. This consists of an image overlay container (a relatively positioned `div`), which then contains some number of absolutely positioned child `div` elements. Additionally load the image overlay stylesheet as text within a style element when creating the UA shadow root. * html/HTMLElement.h: * html/shadow/imageOverlay.css: Added. (div#image-overlay): (div.image-overlay-text): Add a new UA stylesheet for the image overlay shadow DOM subtree. The overlay contains a number of absolutely positoned `div` elements, which are positioned inside the overlay element using using CSS transforms. * rendering/RenderImage.cpp: (WebCore::RenderImage::RenderImage): (WebCore::RenderImage::canHaveChildren const): Return `true` if we require children in the shadow root (for either media controls, or this new image overlay). (WebCore::RenderImage::layout): (WebCore::RenderImage::layoutShadowContent): (WebCore::RenderImage::layoutShadowControls): Deleted. Rename `layoutShadowControls` to `layoutShadowContent`, and allow it to support both the "shadow controls" case (i.e. `RenderMedia`) and the "image extraction content" case. Additonally, remove the check for `shadowControlsNeedCustomLayoutMetrics()` when setting child renderer width/height. This is currently only used for laying out media controls in `RenderMedia`, but we'll need it now for all `RenderImage`s. * rendering/RenderImage.h: (WebCore::RenderImage::setHasImageOverlay): (WebCore::RenderImage::hasShadowContent const): Add a helper method to return whether or not the `RenderImage` should expect shadow root content. This is true for both media controls (`m_hasShadowControls`) and for the new image overlay content (`m_hasImageOverlay`). (WebCore::RenderImage::shadowControlsNeedCustomLayoutMetrics const): Deleted. * rendering/RenderMedia.h: See `RenderImage::layoutShadowControls` above. Canonical link: https://commits.webkit.org/233781@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@272467 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-02-07 03:28:55 +00:00
}
Subdivide image overlay text into one or more elements per line https://bugs.webkit.org/show_bug.cgi?id=225038 rdar://75505043 Reviewed by Tim Horton and Devin Rousso. Source/WebCore: Refactor some image extraction and image overlay code to allow for multiple elements containing text per line. See comments below for more details. Changes covered by augmenting existing layout tests. * html/HTMLElement.cpp: (WebCore::HTMLElement::updateWithImageExtractionResult): The crux of this change is in this method. Currently, an image overlay has one or more `div` elements underneath the root container element, each of which represents a single line (i.e. contains a text node and a line break). Instead, we make each of these line container `div`s contain one or more `div` elements that represent further subdivided text within each line. See the corresponding additions patch for more details. * html/shadow/imageOverlay.css: (div#image-overlay): (div.image-overlay-line, .image-overlay-text): (.image-overlay-text::selection): Adjust UA stylesheet to account for the changes in `updateWithImageExtractionResult`. (div.image-overlay-text): Deleted. (div.image-overlay-text::selection): Deleted. * platform/ImageExtractionResult.h: (WebCore::ImageExtractionTextData::ImageExtractionTextData): (WebCore::ImageExtractionLineData::ImageExtractionLineData): (WebCore::ImageExtractionLineData::encode const): (WebCore::ImageExtractionLineData::decode): Refactor this data structure, by splitting it into `ImageExtractionLineData` and `ImageExtractionTextData`. (WebCore::ImageExtractionResult::isEmpty const): (WebCore::ImageExtractionResult::encode const): (WebCore::ImageExtractionResult::decode): * platform/graphics/FloatPoint.h: (WebCore::FloatPoint::rotate): Add a helper method to rotate a 2D `FloatPoint` by a given angle, about a given point. * platform/graphics/GeometryUtilities.cpp: (WebCore::rotatedBoundingRectWithMinimumAngleOfRotation): (WebCore::rotatedBoundingRect): Deleted. * platform/graphics/GeometryUtilities.h: * testing/Internals.cpp: (WebCore::getQuad): (WebCore::makeDataForLine): (WebCore::Internals::installImageOverlay): * testing/Internals.h: * testing/Internals.idl: Adjust this internal testing hook to accept a list of `ImageOverlayLine` dictionaries, each of which contains a list of `ImageOverlayText` dictionaries. Tools: Adjust several existing layout tests after changing `internals.installImageOverlay`. See WebCore ChangeLog for more details. Additionally, rename a WebCore geometry helper method. * TestWebKitAPI/Tests/WebCore/FloatQuadTests.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WebKit/simple-image-overlay.html: LayoutTests: Adjust several existing layout tests after changing `internals.installImageOverlay`. See WebCore ChangeLog for more details. * fast/images/image-extraction/basic-image-overlay.html: * fast/images/image-extraction/click-link-with-image-overlay.html: * fast/images/image-extraction/image-overlay-creation-is-idempotent.html: * fast/images/image-extraction/image-overlay-in-image-with-zero-font-size.html: * fast/images/image-extraction/image-overlay-with-selection-styles-expected.html: * fast/images/image-extraction/image-overlay-with-selection-styles.html: * fast/images/image-extraction/ios/reselect-word-in-image-overlay.html: * fast/images/image-extraction/ios/select-word-in-image-overlay-inside-link.html: * fast/images/image-extraction/ios/select-word-in-image-overlay.html: * fast/images/image-extraction/ios/selection-rects-in-image-overlay.html: * fast/images/image-extraction/mac/copy-image-overlay-text-with-context-menu.html: * fast/images/image-extraction/mac/select-image-overlay-in-link-with-mouse-drag.html: * fast/images/image-extraction/mac/select-image-overlay-with-mouse-drag-does-not-fire-click.html: * fast/images/image-extraction/mac/select-image-overlay-with-mouse-drag.html: * fast/images/image-extraction/mac/select-word-in-draggable-image-overlay.html: * fast/images/image-extraction/mac/select-word-in-transparent-image-overlay.html: Canonical link: https://commits.webkit.org/237054@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276626 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-27 02:59:18 +00:00
div.image-overlay-line, .image-overlay-text {
Introduce image overlays and add UA shadow root support for image extraction https://bugs.webkit.org/show_bug.cgi?id=221236 Reviewed by Ryosuke Niwa. This patch restores some of the logic previously introduced in r164457 (and removed with r272117) to render service button cells over images, and additionally renames and repurposes it for image extraction, a new accessibility feature. See comments below for more details. * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: * html/HTMLElement.cpp: (WebCore::imageOverlayElementIdentifier): (WebCore::HTMLElement::hasImageOverlay const): Add a helper to determine whether or not an element's UA shadow root has an image overlay element. This is consulted in the constructor of `RenderImage`. (WebCore::HTMLElement::updateWithImageExtractionResult): Add a helper method to install image extraction content in the shadow root of an element, given an `ImageExtractionResult`. This consists of an image overlay container (a relatively positioned `div`), which then contains some number of absolutely positioned child `div` elements. Additionally load the image overlay stylesheet as text within a style element when creating the UA shadow root. * html/HTMLElement.h: * html/shadow/imageOverlay.css: Added. (div#image-overlay): (div.image-overlay-text): Add a new UA stylesheet for the image overlay shadow DOM subtree. The overlay contains a number of absolutely positoned `div` elements, which are positioned inside the overlay element using using CSS transforms. * rendering/RenderImage.cpp: (WebCore::RenderImage::RenderImage): (WebCore::RenderImage::canHaveChildren const): Return `true` if we require children in the shadow root (for either media controls, or this new image overlay). (WebCore::RenderImage::layout): (WebCore::RenderImage::layoutShadowContent): (WebCore::RenderImage::layoutShadowControls): Deleted. Rename `layoutShadowControls` to `layoutShadowContent`, and allow it to support both the "shadow controls" case (i.e. `RenderMedia`) and the "image extraction content" case. Additonally, remove the check for `shadowControlsNeedCustomLayoutMetrics()` when setting child renderer width/height. This is currently only used for laying out media controls in `RenderMedia`, but we'll need it now for all `RenderImage`s. * rendering/RenderImage.h: (WebCore::RenderImage::setHasImageOverlay): (WebCore::RenderImage::hasShadowContent const): Add a helper method to return whether or not the `RenderImage` should expect shadow root content. This is true for both media controls (`m_hasShadowControls`) and for the new image overlay content (`m_hasImageOverlay`). (WebCore::RenderImage::shadowControlsNeedCustomLayoutMetrics const): Deleted. * rendering/RenderMedia.h: See `RenderImage::layoutShadowControls` above. Canonical link: https://commits.webkit.org/233781@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@272467 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-02-07 03:28:55 +00:00
position: absolute;
overflow: hidden;
}
Selected image overlay text should never be visible https://bugs.webkit.org/show_bug.cgi?id=224734 <rdar://problem/76806399> Reviewed by Darin Adler. Source/WebCore: Make a slight adjustment to the UA stylesheet to ensure that image overlay text is never visible. See below for more details. Test: fast/images/image-extraction/image-overlay-with-selection-styles.html * html/shadow/imageOverlay.css: (div.image-overlay-text::selection): Enforce selected text styles for image overlay text. * rendering/RenderElement.cpp: (WebCore::RenderElement::selectionPseudoStyle const): Make an additional adjustment when computing selection pseudo styles for UA shadow root content. Currently, for elements inside a UA shadow root, we always immediately ascend to the shadow host; this means that `::selection` pseudo selectors currently don't work in UA stylesheets, since they're skipped when resolving styles, upon painting selected text. To fix this, we can let the element's own pseudo styles take precedence over the shadow host's renderer in the case where we have a selection pseudo style. While we're here, also replace a few raw pointers with `RefPtr`. LayoutTests: Add a new layout test. * fast/images/image-extraction/image-overlay-with-selection-styles-expected.html: Added. * fast/images/image-extraction/image-overlay-with-selection-styles.html: Added. Canonical link: https://commits.webkit.org/236718@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276236 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-19 06:32:12 +00:00
Subdivide image overlay text into one or more elements per line https://bugs.webkit.org/show_bug.cgi?id=225038 rdar://75505043 Reviewed by Tim Horton and Devin Rousso. Source/WebCore: Refactor some image extraction and image overlay code to allow for multiple elements containing text per line. See comments below for more details. Changes covered by augmenting existing layout tests. * html/HTMLElement.cpp: (WebCore::HTMLElement::updateWithImageExtractionResult): The crux of this change is in this method. Currently, an image overlay has one or more `div` elements underneath the root container element, each of which represents a single line (i.e. contains a text node and a line break). Instead, we make each of these line container `div`s contain one or more `div` elements that represent further subdivided text within each line. See the corresponding additions patch for more details. * html/shadow/imageOverlay.css: (div#image-overlay): (div.image-overlay-line, .image-overlay-text): (.image-overlay-text::selection): Adjust UA stylesheet to account for the changes in `updateWithImageExtractionResult`. (div.image-overlay-text): Deleted. (div.image-overlay-text::selection): Deleted. * platform/ImageExtractionResult.h: (WebCore::ImageExtractionTextData::ImageExtractionTextData): (WebCore::ImageExtractionLineData::ImageExtractionLineData): (WebCore::ImageExtractionLineData::encode const): (WebCore::ImageExtractionLineData::decode): Refactor this data structure, by splitting it into `ImageExtractionLineData` and `ImageExtractionTextData`. (WebCore::ImageExtractionResult::isEmpty const): (WebCore::ImageExtractionResult::encode const): (WebCore::ImageExtractionResult::decode): * platform/graphics/FloatPoint.h: (WebCore::FloatPoint::rotate): Add a helper method to rotate a 2D `FloatPoint` by a given angle, about a given point. * platform/graphics/GeometryUtilities.cpp: (WebCore::rotatedBoundingRectWithMinimumAngleOfRotation): (WebCore::rotatedBoundingRect): Deleted. * platform/graphics/GeometryUtilities.h: * testing/Internals.cpp: (WebCore::getQuad): (WebCore::makeDataForLine): (WebCore::Internals::installImageOverlay): * testing/Internals.h: * testing/Internals.idl: Adjust this internal testing hook to accept a list of `ImageOverlayLine` dictionaries, each of which contains a list of `ImageOverlayText` dictionaries. Tools: Adjust several existing layout tests after changing `internals.installImageOverlay`. See WebCore ChangeLog for more details. Additionally, rename a WebCore geometry helper method. * TestWebKitAPI/Tests/WebCore/FloatQuadTests.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WebKit/simple-image-overlay.html: LayoutTests: Adjust several existing layout tests after changing `internals.installImageOverlay`. See WebCore ChangeLog for more details. * fast/images/image-extraction/basic-image-overlay.html: * fast/images/image-extraction/click-link-with-image-overlay.html: * fast/images/image-extraction/image-overlay-creation-is-idempotent.html: * fast/images/image-extraction/image-overlay-in-image-with-zero-font-size.html: * fast/images/image-extraction/image-overlay-with-selection-styles-expected.html: * fast/images/image-extraction/image-overlay-with-selection-styles.html: * fast/images/image-extraction/ios/reselect-word-in-image-overlay.html: * fast/images/image-extraction/ios/select-word-in-image-overlay-inside-link.html: * fast/images/image-extraction/ios/select-word-in-image-overlay.html: * fast/images/image-extraction/ios/selection-rects-in-image-overlay.html: * fast/images/image-extraction/mac/copy-image-overlay-text-with-context-menu.html: * fast/images/image-extraction/mac/select-image-overlay-in-link-with-mouse-drag.html: * fast/images/image-extraction/mac/select-image-overlay-with-mouse-drag-does-not-fire-click.html: * fast/images/image-extraction/mac/select-image-overlay-with-mouse-drag.html: * fast/images/image-extraction/mac/select-word-in-draggable-image-overlay.html: * fast/images/image-extraction/mac/select-word-in-transparent-image-overlay.html: Canonical link: https://commits.webkit.org/237054@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276626 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-27 02:59:18 +00:00
.image-overlay-text::selection {
Selected image overlay text should never be visible https://bugs.webkit.org/show_bug.cgi?id=224734 <rdar://problem/76806399> Reviewed by Darin Adler. Source/WebCore: Make a slight adjustment to the UA stylesheet to ensure that image overlay text is never visible. See below for more details. Test: fast/images/image-extraction/image-overlay-with-selection-styles.html * html/shadow/imageOverlay.css: (div.image-overlay-text::selection): Enforce selected text styles for image overlay text. * rendering/RenderElement.cpp: (WebCore::RenderElement::selectionPseudoStyle const): Make an additional adjustment when computing selection pseudo styles for UA shadow root content. Currently, for elements inside a UA shadow root, we always immediately ascend to the shadow host; this means that `::selection` pseudo selectors currently don't work in UA stylesheets, since they're skipped when resolving styles, upon painting selected text. To fix this, we can let the element's own pseudo styles take precedence over the shadow host's renderer in the case where we have a selection pseudo style. While we're here, also replace a few raw pointers with `RefPtr`. LayoutTests: Add a new layout test. * fast/images/image-extraction/image-overlay-with-selection-styles-expected.html: Added. * fast/images/image-extraction/image-overlay-with-selection-styles.html: Added. Canonical link: https://commits.webkit.org/236718@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276236 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-19 06:32:12 +00:00
color: transparent;
background-color: highlight;
}
[macOS] Support painting data detector highlights inside image overlays https://bugs.webkit.org/show_bug.cgi?id=226227 Reviewed by Tim Horton. Add support for painting data detector highlights inside image overlays by leveraging `DataDetectorHighlight`. See comments below for more details. * SourcesCocoa.txt: * WebCore.xcodeproj/project.pbxproj: * editing/Editor.cpp: (WebCore::scanForTelephoneNumbers): Avoid painting service-controls-based telephone number highlights for selected text inside image overlays, in order to avoid painting a redundant data detector highlight for telephone numbers in image overlays. * html/HTMLElement.cpp: (WebCore::imageOverlayDataDetectorClassName): (WebCore::HTMLElement::isImageOverlayDataDetectorResult const): (WebCore::HTMLElement::updateWithImageExtractionResult): * html/HTMLElement.h: * html/shadow/imageOverlay.css: (div.image-overlay-data-detector-result): Add support for injecting elements in the DOM that represent data detection results; these are transformed and overlaid on the image in the same way as existing text containers. Note that we lay out these elements on top of text, but make them invisible to hit-testing unless the `IgnoreCSSPointerEventsProperty` option is specified. We'll take advantage of this behavior in a future patch. * page/ImageOverlayController.cpp: (WebCore::ImageOverlayController::selectionQuadsDidChange): (WebCore::ImageOverlayController::uninstallPageOverlayIfNeeded): (WebCore::ImageOverlayController::drawRect): (WebCore::ImageOverlayController::platformHandleMouseEvent): * page/ImageOverlayController.h: Refactor the image overlay controller, such that we install the page overlay if there is any selection inside the image overlay (as opposed to only when we need to use this overlay to paint the text selection for transparent images). If data detectors are present, we'll additionally set up out `DataDetectorHighlight`s (one for each data detection result container). * page/mac/ImageOverlayControllerMac.mm: Added. (WebCore::ImageOverlayController::updateDataDetectorHighlights): Traverse the image overlay's subtree in search of container elements that correspond to data detection results; for each of these elements, we create a new `DataDetectorHighlight` using the element's bounds, and save the pair in `m_dataDetectorContainersAndHighlights`. Note that we hold a weak pointer to the container element, such that there's no risk of leaking any of these data detection result containers (or their documents). (WebCore::ImageOverlayController::platformHandleMouseEvent): (WebCore::ImageOverlayController::handleDataDetectorAction): Add a FIXME referencing the next patch in the sequence. (WebCore::ImageOverlayController::clearDataDetectorHighlights): * platform/mac/DataDetectorHighlight.h: * platform/mac/DataDetectorHighlight.mm: (WebCore::DataDetectorHighlight::createForImageOverlay): Add a helper method to create a `DataDetectorHighlight` for image overlays. Canonical link: https://commits.webkit.org/238171@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278121 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-26 20:06:32 +00:00
div.image-overlay-data-detector-result {
position: absolute;
-webkit-user-select: none;
pointer-events: none;
}