Diff
Modified: trunk/Source/WebCore/ChangeLog (278559 => 278560)
--- trunk/Source/WebCore/ChangeLog 2021-06-07 13:26:39 UTC (rev 278559)
+++ trunk/Source/WebCore/ChangeLog 2021-06-07 13:45:46 UTC (rev 278560)
@@ -1,3 +1,20 @@
+2021-06-07 Wenson Hsieh <[email protected]>
+
+ [Cocoa] Find-in-page should match text inside image overlays
+ https://bugs.webkit.org/show_bug.cgi?id=226704
+
+ Reviewed by Tim Horton.
+
+ Add a new TextIteratorBehavior to allow TextIterator to descend into image overlay content, and use this option
+ when creating TextIterators for find-in-page. See WebKit/ChangeLog for more details.
+
+ Test: WebKit.FindTextInImageOverlay
+
+ * editing/TextIterator.cpp:
+ (WebCore::TextIterator::handleReplacedElement):
+ (WebCore::findIteratorOptions):
+ * editing/TextIteratorBehavior.h:
+
2021-06-07 Alicia Boya GarcĂa <[email protected]>
[GStreamer] Add clang TSA annotations: MainThreadNotifier
Modified: trunk/Source/WebCore/editing/TextIterator.cpp (278559 => 278560)
--- trunk/Source/WebCore/editing/TextIterator.cpp 2021-06-07 13:26:39 UTC (rev 278559)
+++ trunk/Source/WebCore/editing/TextIterator.cpp 2021-06-07 13:45:46 UTC (rev 278560)
@@ -731,6 +731,16 @@
}
}
+ if (m_behaviors.contains(TextIteratorBehavior::EntersImageOverlays) && is<HTMLElement>(m_node) && downcast<HTMLElement>(*m_node).hasImageOverlay()) {
+ if (auto shadowRoot = makeRefPtr(m_node->shadowRoot())) {
+ m_node = shadowRoot.get();
+ pushFullyClippedState(m_fullyClippedStack, *m_node);
+ m_offset = 0;
+ return false;
+ }
+ ASSERT_NOT_REACHED();
+ }
+
m_hasEmitted = true;
if (m_behaviors.contains(TextIteratorBehavior::EmitsObjectReplacementCharacters) && renderer.isReplaced()) {
@@ -2454,9 +2464,9 @@
return plainText(range, defaultBehaviors, isDisplayString).replace(noBreakSpace, ' ');
}
-static TextIteratorBehaviors findIteratorOptions(FindOptions options)
+static constexpr TextIteratorBehaviors findIteratorOptions(FindOptions options)
{
- TextIteratorBehaviors iteratorOptions { TextIteratorBehavior::EntersTextControls, TextIteratorBehavior::ClipsToFrameAncestors };
+ TextIteratorBehaviors iteratorOptions { TextIteratorBehavior::EntersTextControls, TextIteratorBehavior::ClipsToFrameAncestors, TextIteratorBehavior::EntersImageOverlays };
if (!options.contains(DoNotTraverseFlatTree))
iteratorOptions.add(TextIteratorBehavior::TraversesFlatTree);
return iteratorOptions;
Modified: trunk/Source/WebCore/editing/TextIteratorBehavior.h (278559 => 278560)
--- trunk/Source/WebCore/editing/TextIteratorBehavior.h 2021-06-07 13:26:39 UTC (rev 278559)
+++ trunk/Source/WebCore/editing/TextIteratorBehavior.h 2021-06-07 13:45:46 UTC (rev 278560)
@@ -59,6 +59,8 @@
ClipsToFrameAncestors = 1 << 8,
TraversesFlatTree = 1 << 9,
+
+ EntersImageOverlays = 1 << 10,
};
using TextIteratorBehaviors = OptionSet<TextIteratorBehavior>;
Modified: trunk/Source/WebKit/ChangeLog (278559 => 278560)
--- trunk/Source/WebKit/ChangeLog 2021-06-07 13:26:39 UTC (rev 278559)
+++ trunk/Source/WebKit/ChangeLog 2021-06-07 13:45:46 UTC (rev 278560)
@@ -1,3 +1,20 @@
+2021-06-07 Wenson Hsieh <[email protected]>
+
+ [Cocoa] Find-in-page should match text inside image overlays
+ https://bugs.webkit.org/show_bug.cgi?id=226704
+
+ Reviewed by Tim Horton.
+
+ Add the `PaintAllContent` and `PaintBackgrounds` text indicator options when generating a TextIndicator for
+ selected content inside an image overlay. See WebCore/ChangeLog for more details.
+
+ * WebProcess/WebPage/FindController.cpp:
+ (WebKit::FindController::updateFindIndicator):
+ * WebProcess/WebPage/ios/FindControllerIOS.mm:
+ (WebKit::findTextIndicatorOptions):
+ (WebKit::FindIndicatorOverlayClientIOS::drawRect):
+ (WebKit::FindController::updateFindIndicator):
+
2021-06-07 Aditya Keerthi <[email protected]>
[iOS] Unexpected scrolling when switching focus from a text input to a select element
Modified: trunk/Source/WebKit/WebProcess/WebPage/FindController.cpp (278559 => 278560)
--- trunk/Source/WebKit/WebProcess/WebPage/FindController.cpp 2021-06-07 13:26:39 UTC (rev 278559)
+++ trunk/Source/WebKit/WebProcess/WebPage/FindController.cpp 2021-06-07 13:45:46 UTC (rev 278560)
@@ -374,7 +374,11 @@
bool FindController::updateFindIndicator(Frame& selectedFrame, bool isShowingOverlay, bool shouldAnimate)
{
- auto indicator = TextIndicator::createWithSelectionInFrame(selectedFrame, { TextIndicatorOption::IncludeMarginIfRangeMatchesSelection }, shouldAnimate ? TextIndicatorPresentationTransition::Bounce : TextIndicatorPresentationTransition::None);
+ OptionSet<TextIndicatorOption> textIndicatorOptions { TextIndicatorOption::IncludeMarginIfRangeMatchesSelection };
+ if (auto selectedRange = selectedFrame.selection().selection().range(); selectedRange && HTMLElement::isInsideImageOverlay(*selectedRange))
+ textIndicatorOptions.add({ TextIndicatorOption::PaintAllContent, TextIndicatorOption::PaintBackgrounds });
+
+ auto indicator = TextIndicator::createWithSelectionInFrame(selectedFrame, textIndicatorOptions, shouldAnimate ? TextIndicatorPresentationTransition::Bounce : TextIndicatorPresentationTransition::None);
if (!indicator)
return false;
Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/FindControllerIOS.mm (278559 => 278560)
--- trunk/Source/WebKit/WebProcess/WebPage/ios/FindControllerIOS.mm 2021-06-07 13:26:39 UTC (rev 278559)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/FindControllerIOS.mm 2021-06-07 13:45:46 UTC (rev 278560)
@@ -51,7 +51,13 @@
const int totalHorizontalMargin = 1;
const int totalVerticalMargin = 1;
-constexpr OptionSet<TextIndicatorOption> findTextIndicatorOptions { TextIndicatorOption::IncludeMarginIfRangeMatchesSelection, TextIndicatorOption::DoNotClipToVisibleRect };
+static OptionSet<TextIndicatorOption> findTextIndicatorOptions(const Frame& frame)
+{
+ OptionSet<TextIndicatorOption> options { TextIndicatorOption::IncludeMarginIfRangeMatchesSelection, TextIndicatorOption::DoNotClipToVisibleRect };
+ if (auto selectedRange = frame.selection().selection().range(); selectedRange && HTMLElement::isInsideImageOverlay(*selectedRange))
+ options.add({ TextIndicatorOption::PaintAllContent, TextIndicatorOption::PaintBackgrounds });
+ return options;
+};
static constexpr auto highlightColor = SRGBA<uint8_t> { 255, 228, 56 };
@@ -64,7 +70,7 @@
// If the page scale changed, we need to paint a new TextIndicator.
if (m_textIndicator->contentImageScaleFactor() != scaleFactor)
- m_textIndicator = TextIndicator::createWithSelectionInFrame(m_frame, findTextIndicatorOptions, TextIndicatorPresentationTransition::None, FloatSize(totalHorizontalMargin, totalVerticalMargin));
+ m_textIndicator = TextIndicator::createWithSelectionInFrame(m_frame, findTextIndicatorOptions(m_frame), TextIndicatorPresentationTransition::None, FloatSize(totalHorizontalMargin, totalVerticalMargin));
if (!m_textIndicator)
return;
@@ -91,7 +97,7 @@
m_isShowingFindIndicator = false;
}
- auto textIndicator = TextIndicator::createWithSelectionInFrame(selectedFrame, findTextIndicatorOptions, TextIndicatorPresentationTransition::None, FloatSize(totalHorizontalMargin, totalVerticalMargin));
+ auto textIndicator = TextIndicator::createWithSelectionInFrame(selectedFrame, findTextIndicatorOptions(selectedFrame), TextIndicatorPresentationTransition::None, FloatSize(totalHorizontalMargin, totalVerticalMargin));
if (!textIndicator)
return false;
Modified: trunk/Tools/ChangeLog (278559 => 278560)
--- trunk/Tools/ChangeLog 2021-06-07 13:26:39 UTC (rev 278559)
+++ trunk/Tools/ChangeLog 2021-06-07 13:45:46 UTC (rev 278560)
@@ -1,3 +1,14 @@
+2021-06-07 Wenson Hsieh <[email protected]>
+
+ [Cocoa] Find-in-page should match text inside image overlays
+ https://bugs.webkit.org/show_bug.cgi?id=226704
+
+ Reviewed by Tim Horton.
+
+ Add an API test to verify that text inside image overlays is visible to find-in-page.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/FindInPage.mm:
+
2021-06-07 Carlos Garcia Campos <[email protected]>
[GTK][WPE] Signal "window-object-cleared" not emitted unless frame js context is get before
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FindInPage.mm (278559 => 278560)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FindInPage.mm 2021-06-07 13:26:39 UTC (rev 278559)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/FindInPage.mm 2021-06-07 13:45:46 UTC (rev 278560)
@@ -28,6 +28,7 @@
#import "PlatformUtilities.h"
#import "TestNavigationDelegate.h"
#import "TestWKWebView.h"
+#import "WKWebViewConfigurationExtras.h"
#import <WebKit/WKWebViewPrivate.h>
#import <wtf/RetainPtr.h>
@@ -38,10 +39,10 @@
NSTextFinderAsynchronousDocumentFindOptionsWrap = 1 << 1,
} NSTextFinderAsynchronousDocumentFindOptions;
-NSTextFinderAsynchronousDocumentFindOptions noFindOptions = (NSTextFinderAsynchronousDocumentFindOptions)0;
-NSTextFinderAsynchronousDocumentFindOptions backwardsFindOptions =NSTextFinderAsynchronousDocumentFindOptionsBackwards;
-NSTextFinderAsynchronousDocumentFindOptions wrapFindOptions =NSTextFinderAsynchronousDocumentFindOptionsWrap;
-NSTextFinderAsynchronousDocumentFindOptions wrapBackwardsFindOptions = (NSTextFinderAsynchronousDocumentFindOptions)(NSTextFinderAsynchronousDocumentFindOptionsWrap | NSTextFinderAsynchronousDocumentFindOptionsBackwards);
+constexpr auto noFindOptions = (NSTextFinderAsynchronousDocumentFindOptions)0;
+constexpr auto backwardsFindOptions = NSTextFinderAsynchronousDocumentFindOptionsBackwards;
+constexpr auto wrapFindOptions = NSTextFinderAsynchronousDocumentFindOptionsWrap;
+constexpr auto wrapBackwardsFindOptions = (NSTextFinderAsynchronousDocumentFindOptions)(NSTextFinderAsynchronousDocumentFindOptionsWrap | NSTextFinderAsynchronousDocumentFindOptionsBackwards);
@protocol NSTextFinderAsynchronousDocumentFindMatch <NSObject>
@property (retain, nonatomic, readonly) NSArray *textRects;
@@ -57,10 +58,10 @@
@end
-typedef struct {
+struct FindResult {
RetainPtr<NSArray> matches;
- BOOL didWrap;
-} FindResult;
+ BOOL didWrap { NO };
+};
static FindResult findMatches(WKWebView *webView, NSString *findString, NSTextFinderAsynchronousDocumentFindOptions findOptions = noFindOptions, NSUInteger maxResults = NSUIntegerMax)
{
@@ -295,4 +296,28 @@
EXPECT_WK_STREQ("hi hi", [webView stringByEvaluatingJavaScript:@"document.body.textContent"]);
}
+#if ENABLE(IMAGE_EXTRACTION)
+
+TEST(WebKit, FindTextInImageOverlay)
+{
+ auto configuration = retainPtr([WKWebViewConfiguration _test_configurationWithTestPlugInClassName:@"WebProcessPlugInWithInternals" configureJSCForTesting:YES]);
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 400, 400) configuration:configuration.get()]);
+ [webView synchronouslyLoadTestPageNamed:@"simple-image-overlay"];
+ {
+ auto [matches, didWrap] = findMatches(webView.get(), @"foobar");
+ EXPECT_EQ(1U, [matches count]);
+ EXPECT_FALSE(didWrap);
+ }
+
+ [webView evaluateJavaScript:@"document.body.appendChild(document.createTextNode('foobar'))" completionHandler:nil];
+
+ {
+ auto [matches, didWrap] = findMatches(webView.get(), @"foobar");
+ EXPECT_EQ(2U, [matches count]);
+ EXPECT_FALSE(didWrap);
+ }
+}
+
+#endif // ENABLE(IMAGE_EXTRACTION)
+
#endif // !PLATFORM(IOS_FAMILY)