Diff
Modified: trunk/LayoutTests/TestExpectations (290115 => 290116)
--- trunk/LayoutTests/TestExpectations 2022-02-18 07:45:54 UTC (rev 290115)
+++ trunk/LayoutTests/TestExpectations 2022-02-18 07:55:32 UTC (rev 290116)
@@ -2960,6 +2960,7 @@
imported/w3c/web-platform-tests/css/css-pseudo/highlight-paired-cascade-004.tentative.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-pseudo/highlight-paired-cascade-006.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-pseudo/highlight-styling-002.html [ ImageOnlyFailure ]
+# WPT support ::target-text (webkit.org/b/236817)
imported/w3c/web-platform-tests/css/css-pseudo/target-text-001.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-pseudo/target-text-002.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-pseudo/target-text-003.html [ ImageOnlyFailure ]
@@ -2968,7 +2969,9 @@
imported/w3c/web-platform-tests/css/css-pseudo/target-text-006.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-pseudo/target-text-dynamic-001.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-pseudo/target-text-dynamic-002.html [ ImageOnlyFailure ]
+imported/w3c/web-platform-tests/css/css-pseudo/target-text-dynamic-003.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-pseudo/target-text-dynamic-004.html [ ImageOnlyFailure ]
+imported/w3c/web-platform-tests/css/css-pseudo/target-text-text-decoration-001.html [ ImageOnlyFailure ]
webkit.org/b/177799 accessibility/table-detection.html [ Pass Failure ]
Modified: trunk/Source/WebCore/ChangeLog (290115 => 290116)
--- trunk/Source/WebCore/ChangeLog 2022-02-18 07:45:54 UTC (rev 290115)
+++ trunk/Source/WebCore/ChangeLog 2022-02-18 07:55:32 UTC (rev 290116)
@@ -1,3 +1,32 @@
+2022-02-17 Megan Gardner <[email protected]>
+
+ Draw highlights for Scroll To Text Fragment
+ https://bugs.webkit.org/show_bug.cgi?id=236693
+
+ Reviewed by Tim Horton.
+
+ Implement a very basic search for text fragments (this will be properly implemented later)
+ and leverage our Highlight and AppHighlight infrastructures to draw the found ranges for
+ Scroll to Text Fragment and scroll so they are guaranteed to be in view.
+
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * dom/Document.cpp:
+ (WebCore::Document::commonTeardown):
+ (WebCore::Document::fragmentHighlightRegister):
+ (WebCore::Document::updateHighlightPositions):
+ * dom/Document.h:
+ (WebCore::Document::fragmentHighlightRegisterIfExists):
+ * page/FrameView.cpp:
+ (WebCore::FrameView::scrollToFragment):
+ * rendering/MarkedText.cpp:
+ (WebCore::MarkedText::collectForHighlights):
+ * rendering/MarkedText.h:
+ * rendering/RenderReplaced.cpp:
+ (WebCore::RenderReplaced::calculateHighlightColor const):
+ * rendering/StyledMarkedText.cpp:
+ (WebCore::resolveStyleForMarkedText):
+
2022-02-17 Patrick Angle <[email protected]>
Web Inspector: [Flexbox] Add indicators for layout context in element tooltips
Modified: trunk/Source/WebCore/Modules/highlight/AppHighlightStorage.cpp (290115 => 290116)
--- trunk/Source/WebCore/Modules/highlight/AppHighlightStorage.cpp 2022-02-18 07:45:54 UTC (rev 290115)
+++ trunk/Source/WebCore/Modules/highlight/AppHighlightStorage.cpp 2022-02-18 07:55:32 UTC (rev 290116)
@@ -265,7 +265,7 @@
if (!range)
return false;
- strongDocument->appHighlightRegister().addAppHighlight(StaticRange::create(*range));
+ strongDocument->appHighlightRegister().addAnnotationHighlightWithRange(StaticRange::create(*range));
if (scroll == ScrollToHighlight::Yes) {
auto textIndicator = TextIndicator::createWithRange(range.value(), { TextIndicatorOption::DoNotClipToVisibleRect }, WebCore::TextIndicatorPresentationTransition::Bounce);
Modified: trunk/Source/WebCore/Modules/highlight/HighlightRegister.cpp (290115 => 290116)
--- trunk/Source/WebCore/Modules/highlight/HighlightRegister.cpp 2022-02-18 07:45:54 UTC (rev 290115)
+++ trunk/Source/WebCore/Modules/highlight/HighlightRegister.cpp 2022-02-18 07:55:32 UTC (rev 290116)
@@ -53,19 +53,6 @@
return m_map.remove(key);
}
#if ENABLE(APP_HIGHLIGHTS)
-ASCIILiteral HighlightRegister::appHighlightKey()
-{
- return "appHighlightKey"_s;
-}
-
-void HighlightRegister::addAppHighlight(Ref<StaticRange>&& value)
-{
- if (m_map.contains(appHighlightKey()))
- m_map.get(appHighlightKey())->addToSetLike(value);
- else
- setFromMapLike(appHighlightKey(), Highlight::create(WTFMove(value)));
-}
-
void HighlightRegister::setHighlightVisibility(HighlightVisibility highlightVisibility)
{
if (m_highlightVisibility == highlightVisibility)
@@ -76,6 +63,18 @@
for (auto& highlight : m_map)
highlight.value->repaint();
}
-
#endif
+static ASCIILiteral annotationHighlightKey()
+{
+ return "annotationHighlightKey"_s;
}
+
+void HighlightRegister::addAnnotationHighlightWithRange(Ref<StaticRange>&& value)
+{
+ if (m_map.contains(annotationHighlightKey()))
+ m_map.get(annotationHighlightKey())->addToSetLike(value);
+ else
+ setFromMapLike(annotationHighlightKey(), Highlight::create(WTFMove(value)));
+}
+
+}
Modified: trunk/Source/WebCore/Modules/highlight/HighlightRegister.h (290115 => 290116)
--- trunk/Source/WebCore/Modules/highlight/HighlightRegister.h 2022-02-18 07:45:54 UTC (rev 290115)
+++ trunk/Source/WebCore/Modules/highlight/HighlightRegister.h 2022-02-18 07:55:32 UTC (rev 290116)
@@ -46,13 +46,13 @@
void clear();
bool remove(const String&);
+
HighlightVisibility highlightsVisibility() const { return m_highlightVisibility; }
+#if ENABLE(APP_HIGHLIGHTS)
WEBCORE_EXPORT void setHighlightVisibility(HighlightVisibility);
+#endif
-#if ENABLE(APP_HIGHLIGHTS)
- WEBCORE_EXPORT void addAppHighlight(Ref<StaticRange>&&);
- static ASCIILiteral appHighlightKey();
-#endif
+ WEBCORE_EXPORT void addAnnotationHighlightWithRange(Ref<StaticRange>&&);
const HashMap<String, Ref<Highlight>>& map() const { return m_map; }
private:
Modified: trunk/Source/WebCore/Sources.txt (290115 => 290116)
--- trunk/Source/WebCore/Sources.txt 2022-02-18 07:45:54 UTC (rev 290115)
+++ trunk/Source/WebCore/Sources.txt 2022-02-18 07:55:32 UTC (rev 290116)
@@ -975,6 +975,7 @@
dom/ExtensionStyleSheets.cpp
dom/FocusEvent.cpp
dom/FormDataEvent.cpp
+dom/FragmentDirectiveRangeFinder.cpp
dom/FragmentDirectiveParser.cpp
dom/FullscreenManager.cpp
dom/GCReachableRef.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (290115 => 290116)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2022-02-18 07:45:54 UTC (rev 290115)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2022-02-18 07:55:32 UTC (rev 290116)
@@ -9144,6 +9144,8 @@
4425070625829A1400C09368 /* AppHighlightStorage.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AppHighlightStorage.cpp; sourceTree = "<group>"; };
4425070725829A1400C09368 /* AppHighlightStorage.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppHighlightStorage.h; sourceTree = "<group>"; };
442956CA218A6D300080DB54 /* DictionaryLookupLegacy.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = DictionaryLookupLegacy.mm; sourceTree = "<group>"; };
+ 442E7BED27BC56EC00C69AC1 /* FragmentDirectiveRangeFinder.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FragmentDirectiveRangeFinder.cpp; sourceTree = "<group>"; };
+ 442E7BEE27BC56EC00C69AC1 /* FragmentDirectiveRangeFinder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FragmentDirectiveRangeFinder.h; sourceTree = "<group>"; };
4437C4A724E2AE5F00095128 /* LazyLoadFrameObserver.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LazyLoadFrameObserver.h; sourceTree = "<group>"; };
4437C4A924E2AE5F00095128 /* LazyLoadFrameObserver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LazyLoadFrameObserver.cpp; sourceTree = "<group>"; };
443877E3271681F600FD3E33 /* CaptionUserPreferencesMediaAFCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CaptionUserPreferencesMediaAFCocoa.mm; sourceTree = "<group>"; };
@@ -32533,6 +32535,8 @@
2A66438E26A006AE00C147A1 /* FormDataEvent.idl */,
445612AA270F6F3700758C97 /* FragmentDirectiveParser.cpp */,
445612AB270F6F3800758C97 /* FragmentDirectiveParser.h */,
+ 442E7BED27BC56EC00C69AC1 /* FragmentDirectiveRangeFinder.cpp */,
+ 442E7BEE27BC56EC00C69AC1 /* FragmentDirectiveRangeFinder.h */,
A853123C11D0471B00D4D077 /* FragmentScriptingPermission.h */,
CD92F5172261038200F87BB3 /* FullscreenManager.cpp */,
CD92F5162261038200F87BB3 /* FullscreenManager.h */,
Modified: trunk/Source/WebCore/dom/Document.cpp (290115 => 290116)
--- trunk/Source/WebCore/dom/Document.cpp 2022-02-18 07:45:54 UTC (rev 290115)
+++ trunk/Source/WebCore/dom/Document.cpp 2022-02-18 07:55:32 UTC (rev 290116)
@@ -819,6 +819,8 @@
if (m_highlightRegister)
m_highlightRegister->clear();
+ if (m_fragmentHighlightRegister)
+ m_fragmentHighlightRegister->clear();
#if ENABLE(APP_HIGHLIGHTS)
if (m_appHighlightRegister)
m_appHighlightRegister->clear();
@@ -2822,6 +2824,14 @@
m_highlightRegister = HighlightRegister::create();
return *m_highlightRegister;
}
+
+HighlightRegister& Document::fragmentHighlightRegister()
+{
+ if (!m_fragmentHighlightRegister)
+ m_fragmentHighlightRegister = HighlightRegister::create();
+ return *m_fragmentHighlightRegister;
+}
+
#if ENABLE(APP_HIGHLIGHTS)
HighlightRegister& Document::appHighlightRegister()
{
@@ -2858,6 +2868,8 @@
Vector<WeakPtr<HighlightRangeData>> rangesData;
if (m_highlightRegister)
collectRangeDataFromRegister(rangesData, *m_highlightRegister.get());
+ if (m_fragmentHighlightRegister)
+ collectRangeDataFromRegister(rangesData, *m_fragmentHighlightRegister.get());
#if ENABLE(APP_HIGHLIGHTS)
if (m_appHighlightRegister)
collectRangeDataFromRegister(rangesData, *m_appHighlightRegister.get());
Modified: trunk/Source/WebCore/dom/Document.h (290115 => 290116)
--- trunk/Source/WebCore/dom/Document.h 2022-02-18 07:45:54 UTC (rev 290115)
+++ trunk/Source/WebCore/dom/Document.h 2022-02-18 07:55:32 UTC (rev 290116)
@@ -1624,7 +1624,11 @@
HighlightRegister* highlightRegisterIfExists() { return m_highlightRegister.get(); }
HighlightRegister& highlightRegister();
- void updateHighlightPositions();
+ void updateHighlightPositions();
+
+ HighlightRegister* fragmentHighlightRegisterIfExists() { return m_fragmentHighlightRegister.get(); }
+ HighlightRegister& fragmentHighlightRegister();
+
#if ENABLE(APP_HIGHLIGHTS)
HighlightRegister* appHighlightRegisterIfExists() { return m_appHighlightRegister.get(); }
WEBCORE_EXPORT HighlightRegister& appHighlightRegister();
@@ -2018,6 +2022,7 @@
#endif
RefPtr<HighlightRegister> m_highlightRegister;
+ RefPtr<HighlightRegister> m_fragmentHighlightRegister;
#if ENABLE(APP_HIGHLIGHTS)
RefPtr<HighlightRegister> m_appHighlightRegister;
std::unique_ptr<AppHighlightStorage> m_appHighlightStorage;
Added: trunk/Source/WebCore/dom/FragmentDirectiveRangeFinder.cpp (0 => 290116)
--- trunk/Source/WebCore/dom/FragmentDirectiveRangeFinder.cpp (rev 0)
+++ trunk/Source/WebCore/dom/FragmentDirectiveRangeFinder.cpp 2022-02-18 07:55:32 UTC (rev 290116)
@@ -0,0 +1,76 @@
+/*
+ * 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 "FragmentDirectiveRangeFinder.h"
+
+#include "Chrome.h"
+#include "ChromeClient.h"
+#include "Document.h"
+#include "Editor.h"
+#include "FindOptions.h"
+#include "SimpleRange.h"
+#include "TextIterator.h"
+
+namespace WebCore {
+namespace FragmentDirectiveRangeFinder {
+
+static SimpleRange collapseIfRootsDiffer(SimpleRange&& range)
+{
+ return &range.start.container->rootNode() == &range.end.container->rootNode()
+ ? WTFMove(range) : SimpleRange { range.start, range.start };
+}
+
+static std::optional<SimpleRange> rangeOfString(const String& target, Document& document)
+{
+ if (target.isEmpty())
+ return std::nullopt;
+
+ auto searchRange = makeRangeSelectingNodeContents(document);
+
+ FindOptions findOptions { DoNotRevealSelection };
+
+ auto resultRange = collapseIfRootsDiffer(findPlainText(searchRange, target, findOptions));
+
+ return resultRange.collapsed() ? std::nullopt : std::make_optional(resultRange);
+}
+
+const Vector<SimpleRange> rangesForFragments(Vector<ParsedTextDirective>& parsedTextDirectives, Document& document)
+{
+ Vector<SimpleRange> ranges;
+
+ for (auto directive : parsedTextDirectives) {
+ // FIXME: do full algorithm to find the exact text phrase, rather than just searching for the first place that the text is
+ auto range = rangeOfString(directive.textStart, document);
+ if (range && !range->collapsed())
+ ranges.append(range.value());
+ }
+
+ return ranges;
+}
+
+}
+
+} // WebCore
Copied: trunk/Source/WebCore/dom/FragmentDirectiveRangeFinder.h (from rev 290115, trunk/Source/WebCore/Modules/highlight/HighlightRegister.h) (0 => 290116)
--- trunk/Source/WebCore/dom/FragmentDirectiveRangeFinder.h (rev 0)
+++ trunk/Source/WebCore/dom/FragmentDirectiveRangeFinder.h 2022-02-18 07:55:32 UTC (rev 290116)
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#include "FragmentDirectiveParser.h"
+#include "SimpleRange.h"
+#include <wtf/Forward.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+namespace FragmentDirectiveRangeFinder {
+
+const Vector<SimpleRange> rangesForFragments(Vector<ParsedTextDirective>& parsedTextDirectives, Document&);
+
+}
+
+} // namespace WebCore
Modified: trunk/Source/WebCore/page/FrameView.cpp (290115 => 290116)
--- trunk/Source/WebCore/page/FrameView.cpp 2022-02-18 07:45:54 UTC (rev 290115)
+++ trunk/Source/WebCore/page/FrameView.cpp 2022-02-18 07:55:32 UTC (rev 290116)
@@ -48,6 +48,7 @@
#include "FloatRect.h"
#include "FocusController.h"
#include "FragmentDirectiveParser.h"
+#include "FragmentDirectiveRangeFinder.h"
#include "Frame.h"
#include "FrameFlattening.h"
#include "FrameLoader.h"
@@ -65,6 +66,7 @@
#include "HTMLObjectElement.h"
#include "HTMLParserIdioms.h"
#include "HTMLPlugInImageElement.h"
+#include "HighlightRegister.h"
#include "ImageDocument.h"
#include "InspectorClient.h"
#include "InspectorController.h"
@@ -2243,8 +2245,16 @@
document->setFragmentDirective(fragmentDirective);
auto parsedTextDirectives = fragmentDirectiveParser.parsedTextDirectives();
- // FIXME: Scroll to the range specified by the directive.
+ auto highlightRanges = FragmentDirectiveRangeFinder::rangesForFragments(parsedTextDirectives, document);
+ for (auto range : highlightRanges)
+ document->fragmentHighlightRegister().addAnnotationHighlightWithRange(StaticRange::create(range));
+
+ if (highlightRanges.size()) {
+ TemporarySelectionChange selectionChange(document, { highlightRanges.first() }, { TemporarySelectionOption::DelegateMainFrameScroll, TemporarySelectionOption::SmoothScroll, TemporarySelectionOption::RevealSelectionBounds });
+ // FIXME: add a textIndicator after the scroll has completed.
+ }
+
} else
fragmentIdentifier = fragmentDirectiveParser.remainingURLFragment();
}
Modified: trunk/Source/WebCore/rendering/MarkedText.cpp (290115 => 290116)
--- trunk/Source/WebCore/rendering/MarkedText.cpp 2022-02-18 07:45:54 UTC (rev 290115)
+++ trunk/Source/WebCore/rendering/MarkedText.cpp 2022-02-18 07:55:32 UTC (rev 290116)
@@ -129,6 +129,22 @@
}
}
}
+
+ if (renderer.document().settings().scrollToTextFragmentEnabled()) {
+ if (auto fragmentHighlightRegister = renderer.document().fragmentHighlightRegisterIfExists()) {
+ for (auto& highlight : fragmentHighlightRegister->map()) {
+ for (auto& rangeData : highlight.value->rangesData()) {
+ if (!highlightData.setRenderRange(rangeData))
+ continue;
+
+ auto [highlightStart, highlightEnd] = highlightData.rangeForTextBox(renderer, selectableRange);
+ if (highlightStart < highlightEnd)
+ markedTexts.append({ highlightStart, highlightEnd, MarkedText::FragmentHighlight });
+ }
+ }
+ }
+ }
+
#if ENABLE(APP_HIGHLIGHTS)
if (auto appHighlightRegister = renderer.document().appHighlightRegisterIfExists()) {
if (appHighlightRegister->highlightsVisibility() == HighlightVisibility::Visible) {
Modified: trunk/Source/WebCore/rendering/MarkedText.h (290115 => 290116)
--- trunk/Source/WebCore/rendering/MarkedText.h 2022-02-18 07:45:54 UTC (rev 290115)
+++ trunk/Source/WebCore/rendering/MarkedText.h 2022-02-18 07:55:32 UTC (rev 290116)
@@ -45,6 +45,7 @@
TextMatch,
DictationAlternatives,
Highlight,
+ FragmentHighlight,
#if ENABLE(APP_HIGHLIGHTS)
AppHighlight,
#endif
Modified: trunk/Source/WebCore/rendering/RenderReplaced.cpp (290115 => 290116)
--- trunk/Source/WebCore/rendering/RenderReplaced.cpp 2022-02-18 07:45:54 UTC (rev 290115)
+++ trunk/Source/WebCore/rendering/RenderReplaced.cpp 2022-02-18 07:55:32 UTC (rev 290116)
@@ -160,7 +160,7 @@
continue;
OptionSet<StyleColorOptions> styleColorOptions = { StyleColorOptions::UseSystemAppearance };
- return theme().appHighlightColor(styleColorOptions);
+ return theme().annotationHighlightColor(styleColorOptions);
}
}
}
@@ -183,6 +183,23 @@
}
}
}
+ if (document().settings().scrollToTextFragmentEnabled()) {
+ if (auto highlightRegister = document().fragmentHighlightRegisterIfExists()) {
+ for (auto& highlight : highlightRegister->map()) {
+ for (auto& rangeData : highlight.value->rangesData()) {
+ if (!highlightData.setRenderRange(rangeData))
+ continue;
+
+ auto state = highlightData.highlightStateForRenderer(*this);
+ if (!isHighlighted(state, highlightData))
+ continue;
+
+ OptionSet<StyleColorOptions> styleColorOptions = { StyleColorOptions::UseSystemAppearance };
+ return theme().annotationHighlightColor(styleColorOptions);
+ }
+ }
+ }
+ }
return Color();
}
Modified: trunk/Source/WebCore/rendering/RenderTheme.cpp (290115 => 290116)
--- trunk/Source/WebCore/rendering/RenderTheme.cpp 2022-02-18 07:45:54 UTC (rev 290115)
+++ trunk/Source/WebCore/rendering/RenderTheme.cpp 2022-02-18 07:55:32 UTC (rev 290116)
@@ -1555,20 +1555,18 @@
return Color::yellow;
}
-#if ENABLE(APP_HIGHLIGHTS)
-Color RenderTheme::appHighlightColor(OptionSet<StyleColorOptions> options) const
+Color RenderTheme::annotationHighlightColor(OptionSet<StyleColorOptions> options) const
{
auto& cache = colorCache(options);
- if (!cache.appHighlightColor.isValid())
- cache.appHighlightColor = transformSelectionBackgroundColor(platformAppHighlightColor(options), options);
- return cache.appHighlightColor;
+ if (!cache.annotationHighlightColor.isValid())
+ cache.annotationHighlightColor = transformSelectionBackgroundColor(platformAnnotationHighlightColor(options), options);
+ return cache.annotationHighlightColor;
}
-Color RenderTheme::platformAppHighlightColor(OptionSet<StyleColorOptions>) const
+Color RenderTheme::platformAnnotationHighlightColor(OptionSet<StyleColorOptions>) const
{
return Color::yellow;
}
-#endif
Color RenderTheme::defaultButtonTextColor(OptionSet<StyleColorOptions> options) const
{
Modified: trunk/Source/WebCore/rendering/RenderTheme.h (290115 => 290116)
--- trunk/Source/WebCore/rendering/RenderTheme.h 2022-02-18 07:45:54 UTC (rev 290115)
+++ trunk/Source/WebCore/rendering/RenderTheme.h 2022-02-18 07:55:32 UTC (rev 290116)
@@ -161,10 +161,8 @@
// Highlighting color for search matches.
Color textSearchHighlightColor(OptionSet<StyleColorOptions>) const;
-#if ENABLE(APP_HIGHLIGHTS)
// Default highlighting color for app highlights.
- Color appHighlightColor(OptionSet<StyleColorOptions>) const;
-#endif
+ Color annotationHighlightColor(OptionSet<StyleColorOptions>) const;
Color defaultButtonTextColor(OptionSet<StyleColorOptions>) const;
@@ -287,9 +285,7 @@
virtual Color platformInactiveListBoxSelectionForegroundColor(OptionSet<StyleColorOptions>) const;
virtual Color platformTextSearchHighlightColor(OptionSet<StyleColorOptions>) const;
-#if ENABLE(APP_HIGHLIGHTS)
- virtual Color platformAppHighlightColor(OptionSet<StyleColorOptions>) const;
-#endif
+ virtual Color platformAnnotationHighlightColor(OptionSet<StyleColorOptions>) const;
virtual Color platformDefaultButtonTextColor(OptionSet<StyleColorOptions>) const;
@@ -454,11 +450,8 @@
Color inactiveListBoxSelectionForegroundColor;
Color textSearchHighlightColor;
+ Color annotationHighlightColor;
-#if ENABLE(APP_HIGHLIGHTS)
- Color appHighlightColor;
-#endif
-
Color defaultButtonTextColor;
};
Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.h (290115 => 290116)
--- trunk/Source/WebCore/rendering/RenderThemeIOS.h 2022-02-18 07:45:54 UTC (rev 290115)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.h 2022-02-18 07:55:32 UTC (rev 290116)
@@ -173,9 +173,7 @@
Color platformInactiveSelectionBackgroundColor(OptionSet<StyleColorOptions>) const override;
Color platformFocusRingColor(OptionSet<StyleColorOptions>) const final;
-#if ENABLE(APP_HIGHLIGHTS)
- Color platformAppHighlightColor(OptionSet<StyleColorOptions>) const final;
-#endif
+ Color platformAnnotationHighlightColor(OptionSet<StyleColorOptions>) const final;
#if ENABLE(TOUCH_EVENTS)
Color platformTapHighlightColor() const override { return SRGBA<uint8_t> { 26, 26, 26, 77 } ; }
Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.mm (290115 => 290116)
--- trunk/Source/WebCore/rendering/RenderThemeIOS.mm 2022-02-18 07:45:54 UTC (rev 290115)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.mm 2022-02-18 07:55:32 UTC (rev 290116)
@@ -1411,13 +1411,11 @@
return systemFocusRingColor();
}
-#if ENABLE(APP_HIGHLIGHTS)
-Color RenderThemeIOS::platformAppHighlightColor(OptionSet<StyleColorOptions>) const
+Color RenderThemeIOS::platformAnnotationHighlightColor(OptionSet<StyleColorOptions>) const
{
// FIXME: expose the real value from UIKit.
return SRGBA<uint8_t> { 255, 238, 190 };
}
-#endif
bool RenderThemeIOS::shouldHaveSpinButton(const HTMLInputElement&) const
{
Modified: trunk/Source/WebCore/rendering/RenderThemeMac.h (290115 => 290116)
--- trunk/Source/WebCore/rendering/RenderThemeMac.h 2022-02-18 07:45:54 UTC (rev 290115)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.h 2022-02-18 07:55:32 UTC (rev 290116)
@@ -66,9 +66,7 @@
Color platformInactiveListBoxSelectionForegroundColor(OptionSet<StyleColorOptions>) const final;
Color platformFocusRingColor(OptionSet<StyleColorOptions>) const final;
Color platformTextSearchHighlightColor(OptionSet<StyleColorOptions>) const final;
-#if ENABLE(APP_HIGHLIGHTS)
- Color platformAppHighlightColor(OptionSet<StyleColorOptions>) const final;
-#endif
+ Color platformAnnotationHighlightColor(OptionSet<StyleColorOptions>) const final;
Color platformDefaultButtonTextColor(OptionSet<StyleColorOptions>) const final;
ScrollbarControlSize scrollbarControlSizeForPart(ControlPart) final { return ScrollbarControlSize::Small; }
Modified: trunk/Source/WebCore/rendering/RenderThemeMac.mm (290115 => 290116)
--- trunk/Source/WebCore/rendering/RenderThemeMac.mm 2022-02-18 07:45:54 UTC (rev 290115)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.mm 2022-02-18 07:55:32 UTC (rev 290116)
@@ -390,13 +390,11 @@
return colorFromCocoaColor([NSColor findHighlightColor]);
}
-#if ENABLE(APP_HIGHLIGHTS)
-Color RenderThemeMac::platformAppHighlightColor(OptionSet<StyleColorOptions>) const
+Color RenderThemeMac::platformAnnotationHighlightColor(OptionSet<StyleColorOptions>) const
{
// FIXME: expose the real value from AppKit.
return SRGBA<uint8_t> { 255, 238, 190 };
}
-#endif
Color RenderThemeMac::platformDefaultButtonTextColor(OptionSet<StyleColorOptions> options) const
{
Modified: trunk/Source/WebCore/rendering/StyledMarkedText.cpp (290115 => 290116)
--- trunk/Source/WebCore/rendering/StyledMarkedText.cpp 2022-02-18 07:45:54 UTC (rev 290115)
+++ trunk/Source/WebCore/rendering/StyledMarkedText.cpp 2022-02-18 07:55:32 UTC (rev 290116)
@@ -71,10 +71,15 @@
}
}
break;
+ case MarkedText::FragmentHighlight: {
+ OptionSet<StyleColorOptions> styleColorOptions = { StyleColorOptions::UseSystemAppearance };
+ style.backgroundColor = renderer.theme().annotationHighlightColor(styleColorOptions);
+ break;
+ }
#if ENABLE(APP_HIGHLIGHTS)
case MarkedText::AppHighlight: {
OptionSet<StyleColorOptions> styleColorOptions = { StyleColorOptions::UseSystemAppearance };
- style.backgroundColor = renderer.theme().appHighlightColor(styleColorOptions);
+ style.backgroundColor = renderer.theme().annotationHighlightColor(styleColorOptions);
break;
}
#endif
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (290115 => 290116)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2022-02-18 07:45:54 UTC (rev 290115)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2022-02-18 07:55:32 UTC (rev 290116)
@@ -7874,7 +7874,7 @@
if (!selectionRange)
return false;
- document->appHighlightRegister().addAppHighlight(StaticRange::create(selectionRange.value()));
+ document->appHighlightRegister().addAnnotationHighlightWithRange(StaticRange::create(selectionRange.value()));
document->appHighlightStorage().storeAppHighlight(StaticRange::create(selectionRange.value()));
return true;
Modified: trunk/Tools/ChangeLog (290115 => 290116)
--- trunk/Tools/ChangeLog 2022-02-18 07:45:54 UTC (rev 290115)
+++ trunk/Tools/ChangeLog 2022-02-18 07:55:32 UTC (rev 290116)
@@ -1,3 +1,13 @@
+2022-02-17 Megan Gardner <[email protected]>
+
+ Draw highlights for Scroll To Text Fragment
+ https://bugs.webkit.org/show_bug.cgi?id=236693
+
+ Reviewed by Tim Horton.
+
+ * TestWebKitAPI/Tests/WebCore/MarkedText.cpp:
+ (WebCore::operator<<):
+
2022-02-17 Aditya Keerthi <[email protected]>
'-webkit-user-select: all' is not respected in editable views
Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/MarkedText.cpp (290115 => 290116)
--- trunk/Tools/TestWebKitAPI/Tests/WebCore/MarkedText.cpp 2022-02-18 07:45:54 UTC (rev 290115)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/MarkedText.cpp 2022-02-18 07:55:32 UTC (rev 290116)
@@ -57,6 +57,8 @@
return os << "TextMatch";
case MarkedText::Highlight:
return os << "Highlight";
+ case MarkedText::FragmentHighlight:
+ return os << "FragmentHighlight";
#if ENABLE(APP_HIGHLIGHTS)
case MarkedText::AppHighlight:
return os << "AppHighlight";