Diff
Modified: trunk/LayoutTests/ChangeLog (290454 => 290455)
--- trunk/LayoutTests/ChangeLog 2022-02-24 21:10:45 UTC (rev 290454)
+++ trunk/LayoutTests/ChangeLog 2022-02-24 21:14:34 UTC (rev 290455)
@@ -1,3 +1,17 @@
+2022-02-24 Megan Gardner <[email protected]>
+
+ Add percent decoding to Scroll to Text Fragment parsing.
+ https://bugs.webkit.org/show_bug.cgi?id=236818
+
+ Reviewed by Chris Dumez.
+
+ * http/wpt/html/dom/scroll-to-text-fragment/scroll-to-text-fragment-start-emoji-expected.html: Added.
+ * http/wpt/html/dom/scroll-to-text-fragment/scroll-to-text-fragment-start-emoji.html: Added.
+ * http/wpt/html/dom/scroll-to-text-fragment/scroll-to-text-fragment-start-expected.html: Added.
+ * http/wpt/html/dom/scroll-to-text-fragment/scroll-to-text-fragment-start-sentence-expected.html: Added.
+ * http/wpt/html/dom/scroll-to-text-fragment/scroll-to-text-fragment-start-sentence.html: Added.
+ * http/wpt/html/dom/scroll-to-text-fragment/scroll-to-text-fragment-start.html: Added.
+
2022-02-24 Alan Bujtas <[email protected]>
[IFC][Integration] Enable non-paginated vertical-rl writing mode
Added: trunk/LayoutTests/http/wpt/html/dom/scroll-to-text-fragment/scroll-to-text-fragment-start-emoji-expected.html (0 => 290455)
--- trunk/LayoutTests/http/wpt/html/dom/scroll-to-text-fragment/scroll-to-text-fragment-start-emoji-expected.html (rev 0)
+++ trunk/LayoutTests/http/wpt/html/dom/scroll-to-text-fragment/scroll-to-text-fragment-start-emoji-expected.html 2022-02-24 21:14:34 UTC (rev 290455)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en">
+<meta charset="utf-8" />
+<title>Scroll to text fragment - highlight simple start reference</title>
+<style>
+ span {
+ background-color: rgb(255, 238, 190);
+ }
+</style>
+
+<p>The test passes if the following word has a yellow background.</p>
+<div><span>😊</span></div>
Added: trunk/LayoutTests/http/wpt/html/dom/scroll-to-text-fragment/scroll-to-text-fragment-start-emoji.html (0 => 290455)
--- trunk/LayoutTests/http/wpt/html/dom/scroll-to-text-fragment/scroll-to-text-fragment-start-emoji.html (rev 0)
+++ trunk/LayoutTests/http/wpt/html/dom/scroll-to-text-fragment/scroll-to-text-fragment-start-emoji.html 2022-02-24 21:14:34 UTC (rev 290455)
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<meta charset="utf-8" />
+<title>Scroll to text fragment - highlight simple start text</title>
+<link rel="help" href=""
+<meta name="assert" content="This test checks that a fragment directive with start text is correctly highlighted.">
+<link rel="match" href=""
+
+<p>The test passes if the following word has a yellow background.</p>
+<div><span>😊</span></div>
+
+<script>
+ location.href = ""
+</script>
+</html>
Added: trunk/LayoutTests/http/wpt/html/dom/scroll-to-text-fragment/scroll-to-text-fragment-start-expected.html (0 => 290455)
--- trunk/LayoutTests/http/wpt/html/dom/scroll-to-text-fragment/scroll-to-text-fragment-start-expected.html (rev 0)
+++ trunk/LayoutTests/http/wpt/html/dom/scroll-to-text-fragment/scroll-to-text-fragment-start-expected.html 2022-02-24 21:14:34 UTC (rev 290455)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en">
+<meta charset="utf-8" />
+<title>Scroll to text fragment - highlight simple start reference</title>
+<style>
+ span {
+ background-color: rgb(255, 238, 190);
+ }
+</style>
+
+<p>The test passes if the following word has a yellow background.</p>
+<div><span>Example</span></div>
Added: trunk/LayoutTests/http/wpt/html/dom/scroll-to-text-fragment/scroll-to-text-fragment-start-sentence-expected.html (0 => 290455)
--- trunk/LayoutTests/http/wpt/html/dom/scroll-to-text-fragment/scroll-to-text-fragment-start-sentence-expected.html (rev 0)
+++ trunk/LayoutTests/http/wpt/html/dom/scroll-to-text-fragment/scroll-to-text-fragment-start-sentence-expected.html 2022-02-24 21:14:34 UTC (rev 290455)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en">
+<meta charset="utf-8" />
+<title>Scroll to text fragment - highlight simple start reference</title>
+<style>
+ span {
+ background-color: rgb(255, 238, 190);
+ }
+</style>
+
+<p>The test passes if the following word has a yellow background.</p>
+<div><span>Example Sentence</span></div>
Added: trunk/LayoutTests/http/wpt/html/dom/scroll-to-text-fragment/scroll-to-text-fragment-start-sentence.html (0 => 290455)
--- trunk/LayoutTests/http/wpt/html/dom/scroll-to-text-fragment/scroll-to-text-fragment-start-sentence.html (rev 0)
+++ trunk/LayoutTests/http/wpt/html/dom/scroll-to-text-fragment/scroll-to-text-fragment-start-sentence.html 2022-02-24 21:14:34 UTC (rev 290455)
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<meta charset="utf-8" />
+<title>Scroll to text fragment - highlight simple start text</title>
+<link rel="help" href=""
+<meta name="assert" content="This test checks that a fragment directive with start text is correctly highlighted.">
+<link rel="match" href=""
+
+<p>The test passes if the following word has a yellow background.</p>
+<div><span>Example Sentence</span></div>
+
+<script>
+ location.href = ""
+</script>
+</html>
Added: trunk/LayoutTests/http/wpt/html/dom/scroll-to-text-fragment/scroll-to-text-fragment-start.html (0 => 290455)
--- trunk/LayoutTests/http/wpt/html/dom/scroll-to-text-fragment/scroll-to-text-fragment-start.html (rev 0)
+++ trunk/LayoutTests/http/wpt/html/dom/scroll-to-text-fragment/scroll-to-text-fragment-start.html 2022-02-24 21:14:34 UTC (rev 290455)
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<meta charset="utf-8" />
+<title>Scroll to text fragment - highlight simple start text</title>
+<link rel="help" href=""
+<meta name="assert" content="This test checks that a fragment directive with start text is correctly highlighted.">
+<link rel="match" href=""
+
+<p>The test passes if the following word has a yellow background.</p>
+<div><span>Example</span></div>
+
+<script>
+ location.href = ""
+</script>
+</html>
Added: trunk/LayoutTests/platform/gtk/http/wpt/html/dom/scroll-to-text-fragment/scroll-to-text-fragment-start-emoji-expected.html (0 => 290455)
--- trunk/LayoutTests/platform/gtk/http/wpt/html/dom/scroll-to-text-fragment/scroll-to-text-fragment-start-emoji-expected.html (rev 0)
+++ trunk/LayoutTests/platform/gtk/http/wpt/html/dom/scroll-to-text-fragment/scroll-to-text-fragment-start-emoji-expected.html 2022-02-24 21:14:34 UTC (rev 290455)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en">
+<meta charset="utf-8" />
+<title>Scroll to text fragment - highlight simple start reference</title>
+<style>
+ span {
+ background-color: yellow;
+ }
+</style>
+
+<p>The test passes if the following word has a yellow background.</p>
+<div><span>😊</span></div>
Added: trunk/LayoutTests/platform/gtk/http/wpt/html/dom/scroll-to-text-fragment/scroll-to-text-fragment-start-expected.html (0 => 290455)
--- trunk/LayoutTests/platform/gtk/http/wpt/html/dom/scroll-to-text-fragment/scroll-to-text-fragment-start-expected.html (rev 0)
+++ trunk/LayoutTests/platform/gtk/http/wpt/html/dom/scroll-to-text-fragment/scroll-to-text-fragment-start-expected.html 2022-02-24 21:14:34 UTC (rev 290455)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en">
+<meta charset="utf-8" />
+<title>Scroll to text fragment - highlight simple start reference</title>
+<style>
+ span {
+ background-color: yellow;
+ }
+</style>
+
+<p>The test passes if the following word has a yellow background.</p>
+<div><span>Example</span></div>
Added: trunk/LayoutTests/platform/gtk/http/wpt/html/dom/scroll-to-text-fragment/scroll-to-text-fragment-start-sentence-expected.html (0 => 290455)
--- trunk/LayoutTests/platform/gtk/http/wpt/html/dom/scroll-to-text-fragment/scroll-to-text-fragment-start-sentence-expected.html (rev 0)
+++ trunk/LayoutTests/platform/gtk/http/wpt/html/dom/scroll-to-text-fragment/scroll-to-text-fragment-start-sentence-expected.html 2022-02-24 21:14:34 UTC (rev 290455)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en">
+<meta charset="utf-8" />
+<title>Scroll to text fragment - highlight simple start reference</title>
+<style>
+ span {
+ background-color: yellow;
+ }
+</style>
+
+<p>The test passes if the following word has a yellow background.</p>
+<div><span>Example Sentence</span></div>
Modified: trunk/LayoutTests/platform/win/TestExpectations (290454 => 290455)
--- trunk/LayoutTests/platform/win/TestExpectations 2022-02-24 21:10:45 UTC (rev 290454)
+++ trunk/LayoutTests/platform/win/TestExpectations 2022-02-24 21:14:34 UTC (rev 290455)
@@ -645,6 +645,9 @@
highlight/ [ Skip ]
http/wpt/css/css-highlight-api/ [ Skip ]
+# Scroll to Text Fragment
+http/wpt/html/dom/scroll-to-text-fragment/ [ Skip ]
+
# Pre-HMTL5 parser quirks only apply to the mac port for now.
fast/parser/pre-html5-parser-quirks.html [ Skip ]
Modified: trunk/Source/WTF/ChangeLog (290454 => 290455)
--- trunk/Source/WTF/ChangeLog 2022-02-24 21:10:45 UTC (rev 290454)
+++ trunk/Source/WTF/ChangeLog 2022-02-24 21:14:34 UTC (rev 290455)
@@ -1,3 +1,14 @@
+2022-02-24 Megan Gardner <[email protected]>
+
+ Add percent decoding to Scroll to Text Fragment parsing.
+ https://bugs.webkit.org/show_bug.cgi?id=236818
+
+ Reviewed by Chris Dumez.
+
+ Expose bits of URL parser to allow percent decoding elsewhere.
+
+ * wtf/URLParser.h:
+
2022-02-24 Elliott Williams <[email protected]>
[XCBuild] WTF's SPI dependencies are copied via a folder reference and do not emit task outputs
Modified: trunk/Source/WTF/wtf/URLParser.h (290454 => 290455)
--- trunk/Source/WTF/wtf/URLParser.h 2022-02-24 21:10:45 UTC (rev 290454)
+++ trunk/Source/WTF/wtf/URLParser.h 2022-02-24 21:14:34 UTC (rev 290455)
@@ -67,6 +67,7 @@
static bool isInUserInfoEncodeSet(UChar);
static std::optional<uint16_t> defaultPortForProtocol(StringView);
+ WTF_EXPORT_PRIVATE static std::optional<String> formURLDecode(StringView input);
private:
URLParser(String&&, const URL& = { }, const URLTextEncoding* = nullptr);
@@ -118,7 +119,6 @@
template<typename CharacterType> std::optional<LCharBuffer> domainToASCII(StringImpl&, const CodePointIterator<CharacterType>& iteratorForSyntaxViolationPosition);
template<typename CharacterType> LCharBuffer percentDecode(const LChar*, size_t, const CodePointIterator<CharacterType>& iteratorForSyntaxViolationPosition);
static LCharBuffer percentDecode(const LChar*, size_t);
- static std::optional<String> formURLDecode(StringView input);
static bool hasForbiddenHostCodePoint(const LCharBuffer&);
void percentEncodeByte(uint8_t);
void appendToASCIIBuffer(UChar32);
Modified: trunk/Source/WebCore/ChangeLog (290454 => 290455)
--- trunk/Source/WebCore/ChangeLog 2022-02-24 21:10:45 UTC (rev 290454)
+++ trunk/Source/WebCore/ChangeLog 2022-02-24 21:14:34 UTC (rev 290455)
@@ -1,3 +1,20 @@
+2022-02-24 Megan Gardner <[email protected]>
+
+ Add percent decoding to Scroll to Text Fragment parsing.
+ https://bugs.webkit.org/show_bug.cgi?id=236818
+
+ Reviewed by Chris Dumez.
+
+ Leverage URL parser to percent decode parsed text directives in
+ scroll to text fragment implementation.
+
+ Tests: http/wpt/html/dom/scroll-to-text-fragment/scroll-to-text-fragment-start-emoji.html
+ http/wpt/html/dom/scroll-to-text-fragment/scroll-to-text-fragment-start-sentence.html
+ http/wpt/html/dom/scroll-to-text-fragment/scroll-to-text-fragment-start.html
+
+ * dom/FragmentDirectiveParser.cpp:
+ (WebCore::FragmentDirectiveParser::parseFragmentDirective):
+
2022-02-24 Alan Bujtas <[email protected]>
[IFC][Integration] Enable non-paginated vertical-rl writing mode
Modified: trunk/Source/WebCore/dom/FragmentDirectiveParser.cpp (290454 => 290455)
--- trunk/Source/WebCore/dom/FragmentDirectiveParser.cpp 2022-02-24 21:10:45 UTC (rev 290454)
+++ trunk/Source/WebCore/dom/FragmentDirectiveParser.cpp 2022-02-24 21:14:34 UTC (rev 290455)
@@ -29,6 +29,7 @@
#include "Logging.h"
#include <wtf/Deque.h>
#include <wtf/URL.h>
+#include <wtf/URLParser.h>
#include <wtf/text/TextStream.h>
@@ -91,7 +92,6 @@
}
if (containsEmptyToken)
continue;
- // FIXME: add decoding for % encoded strings.
if (tokens.size() > 4 || tokens.size() < 1) {
LOG_WITH_STREAM(TextFragment, stream << " wrong number of tokens ");
continue;
@@ -101,13 +101,20 @@
if (tokens.first().endsWith('-') && tokens.first().length() > 1) {
tokens.first().truncate(tokens.first().length() - 2);
- parsedTextDirective.prefix = tokens.first();
- tokens.removeFirst();
+
+ if (auto prefix = WTF::URLParser::formURLDecode(tokens.takeFirst()))
+ parsedTextDirective.prefix = WTFMove(*prefix);
+ else
+ LOG_WITH_STREAM(TextFragment, stream << " could not decode prefix ");
}
if (tokens.last().startsWith('-') && tokens.last().length() > 1) {
tokens.last().remove(0);
- parsedTextDirective.suffix = tokens.takeLast();
+
+ if (auto suffix = WTF::URLParser::formURLDecode(tokens.takeLast()))
+ parsedTextDirective.suffix = WTFMove(*suffix);
+ else
+ LOG_WITH_STREAM(TextFragment, stream << " could not decode suffix ");
}
if (tokens.size() != 1 && tokens.size() != 2) {
@@ -115,10 +122,17 @@
continue;
}
- parsedTextDirective.textStart = tokens.first();
+ if (auto start = WTF::URLParser::formURLDecode(tokens.first()))
+ parsedTextDirective.textStart = WTFMove(*start);
+ else
+ LOG_WITH_STREAM(TextFragment, stream << " could not decode start ");
- if (tokens.size() == 2)
- parsedTextDirective.textEnd = tokens.last();
+ if (tokens.size() == 2) {
+ if (auto end = WTF::URLParser::formURLDecode(tokens.last()))
+ parsedTextDirective.textEnd = WTFMove(*end);
+ else
+ LOG_WITH_STREAM(TextFragment, stream << " could not decode end ");
+ }
parsedTextDirectives.append(parsedTextDirective);
}