Title: [260609] trunk
- Revision
- 260609
- Author
- [email protected]
- Date
- 2020-04-23 17:07:25 -0700 (Thu, 23 Apr 2020)
Log Message
Text manipulation does not account for text in fully clipped containers
https://bugs.webkit.org/show_bug.cgi?id=210940
<rdar://problem/61137648>
Reviewed by Tim Horton.
Source/WebCore:
Allow text manipulation to find both text in `visibility: hidden;` containers, as well as text in fully clipped
overflow containers. In both cases, renderers exist for these nodes, but TextIterator ignores them by default.
If these containers become visible in the future, we don't want to skip out on performing text manipulation on
them.
An alternative would be to detect when any element that has not undergone text manipulation has become visible
(i.e. no longer clipped by an ancestor), but this is likely more complicated (and possibly less performant) than
just eagerly extracting text from hidden containers, once they gain renderers.
TextManipulation.StartTextManipulationIncludesFullyClippedText
* editing/TextManipulationController.cpp:
(WebCore::ParagraphContentIterator::ParagraphContentIterator):
(WebCore::TextManipulationController::didCreateRendererForElement):
(WebCore::TextManipulationController::scheduleObservationUpdate):
(WebCore::TextManipulationController::scheduleObservartionUpdate): Deleted.
While I'm here, also rename scheduleObservartionUpdate to scheduleObservationUpdate.
* editing/TextManipulationController.h:
Tools:
Add a new text manipulation API test.
* TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm:
(TestWebKitAPI::TEST):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (260608 => 260609)
--- trunk/Source/WebCore/ChangeLog 2020-04-23 23:59:30 UTC (rev 260608)
+++ trunk/Source/WebCore/ChangeLog 2020-04-24 00:07:25 UTC (rev 260609)
@@ -1,3 +1,32 @@
+2020-04-23 Wenson Hsieh <[email protected]>
+
+ Text manipulation does not account for text in fully clipped containers
+ https://bugs.webkit.org/show_bug.cgi?id=210940
+ <rdar://problem/61137648>
+
+ Reviewed by Tim Horton.
+
+ Allow text manipulation to find both text in `visibility: hidden;` containers, as well as text in fully clipped
+ overflow containers. In both cases, renderers exist for these nodes, but TextIterator ignores them by default.
+ If these containers become visible in the future, we don't want to skip out on performing text manipulation on
+ them.
+
+ An alternative would be to detect when any element that has not undergone text manipulation has become visible
+ (i.e. no longer clipped by an ancestor), but this is likely more complicated (and possibly less performant) than
+ just eagerly extracting text from hidden containers, once they gain renderers.
+
+ TextManipulation.StartTextManipulationIncludesFullyClippedText
+
+ * editing/TextManipulationController.cpp:
+ (WebCore::ParagraphContentIterator::ParagraphContentIterator):
+ (WebCore::TextManipulationController::didCreateRendererForElement):
+ (WebCore::TextManipulationController::scheduleObservationUpdate):
+ (WebCore::TextManipulationController::scheduleObservartionUpdate): Deleted.
+
+ While I'm here, also rename scheduleObservartionUpdate to scheduleObservationUpdate.
+
+ * editing/TextManipulationController.h:
+
2020-04-23 Alex Christensen <[email protected]>
Allow credentials for same-origin css mask images
Modified: trunk/Source/WebCore/editing/TextManipulationController.cpp (260608 => 260609)
--- trunk/Source/WebCore/editing/TextManipulationController.cpp 2020-04-23 23:59:30 UTC (rev 260608)
+++ trunk/Source/WebCore/editing/TextManipulationController.cpp 2020-04-24 00:07:25 UTC (rev 260609)
@@ -143,7 +143,7 @@
class ParagraphContentIterator {
public:
ParagraphContentIterator(const Position& start, const Position& end)
- : m_iterator({ *makeBoundaryPoint(start), *makeBoundaryPoint(end) })
+ : m_iterator({ *makeBoundaryPoint(start), *makeBoundaryPoint(end) }, TextIteratorIgnoresStyleVisibility)
, m_iteratorNode(m_iterator.atEnd() ? nullptr : createLiveRange(m_iterator.range())->firstNode())
, m_currentNodeForFindingInvisibleContent(start.firstNode())
, m_pastEndNode(end.firstNode())
@@ -379,7 +379,7 @@
return;
if (m_elementsWithNewRenderer.computesEmpty())
- scheduleObservartionUpdate();
+ scheduleObservationUpdate();
if (is<PseudoElement>(element)) {
if (auto* host = downcast<PseudoElement>(element).hostElement())
@@ -399,7 +399,7 @@
return { makePositionTuple(start.deepEquivalent()), makePositionTuple(end.deepEquivalent()) };
}
-void TextManipulationController::scheduleObservartionUpdate()
+void TextManipulationController::scheduleObservationUpdate()
{
if (!m_document)
return;
Modified: trunk/Source/WebCore/editing/TextManipulationController.h (260608 => 260609)
--- trunk/Source/WebCore/editing/TextManipulationController.h 2020-04-23 23:59:30 UTC (rev 260608)
+++ trunk/Source/WebCore/editing/TextManipulationController.h 2020-04-24 00:07:25 UTC (rev 260609)
@@ -128,7 +128,7 @@
private:
bool isInManipulatedElement(Element&);
void observeParagraphs(const Position& start, const Position& end);
- void scheduleObservartionUpdate();
+ void scheduleObservationUpdate();
struct ManipulationItemData {
Position start;
Modified: trunk/Tools/ChangeLog (260608 => 260609)
--- trunk/Tools/ChangeLog 2020-04-23 23:59:30 UTC (rev 260608)
+++ trunk/Tools/ChangeLog 2020-04-24 00:07:25 UTC (rev 260609)
@@ -1,3 +1,16 @@
+2020-04-23 Wenson Hsieh <[email protected]>
+
+ Text manipulation does not account for text in fully clipped containers
+ https://bugs.webkit.org/show_bug.cgi?id=210940
+ <rdar://problem/61137648>
+
+ Reviewed by Tim Horton.
+
+ Add a new text manipulation API test.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm:
+ (TestWebKitAPI::TEST):
+
2020-04-23 Jer Noble <[email protected]>
REGRESSION (r260278): TestWebKitAPI.Fullscreen.Delegate is timing out on macOS bots
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm (260608 => 260609)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm 2020-04-23 23:59:30 UTC (rev 260608)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/TextManipulation.mm 2020-04-24 00:07:25 UTC (rev 260609)
@@ -582,6 +582,40 @@
EXPECT_WK_STREQ("Ten", items[6].tokens[0].content);
}
+TEST(TextManipulation, StartTextManipulationIncludesFullyClippedText)
+{
+ auto delegate = adoptNS([[TextManipulationDelegate alloc] init]);
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 400, 400)]);
+ [webView _setTextManipulationDelegate:delegate.get()];
+
+ [webView synchronouslyLoadHTMLString:@"<!DOCTYPE html>"
+ "<head>"
+ " <style>"
+ " div { overflow: hidden; width: 200px; height: 0; }"
+ " p { visibility: hidden; }"
+ " </style>"
+ "</head>"
+ "<body>"
+ " <div><span>Hello</span> world</div>"
+ " <br>"
+ " <p>More text</p>"
+ "</body>"];
+
+ done = false;
+ [webView _startTextManipulationsWithConfiguration:nil completion:^{
+ done = true;
+ }];
+ TestWebKitAPI::Util::run(&done);
+
+ NSArray<_WKTextManipulationItem *> *items = [delegate items];
+ EXPECT_EQ(items.count, 2UL);
+ EXPECT_EQ(items[0].tokens.count, 2UL);
+ EXPECT_WK_STREQ("Hello", items[0].tokens[0].content);
+ EXPECT_WK_STREQ(" world", items[0].tokens[1].content);
+ EXPECT_EQ(items[1].tokens.count, 1UL);
+ EXPECT_WK_STREQ("More text", items[1].tokens[0].content);
+}
+
struct Token {
NSString *identifier;
NSString *content;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes