Diff
Modified: trunk/Source/WebCore/ChangeLog (270361 => 270362)
--- trunk/Source/WebCore/ChangeLog 2020-12-02 20:07:40 UTC (rev 270361)
+++ trunk/Source/WebCore/ChangeLog 2020-12-02 20:09:26 UTC (rev 270362)
@@ -1,3 +1,45 @@
+2020-12-02 Megan Gardner <[email protected]>
+
+ Create and draw app highlights
+ https://bugs.webkit.org/show_bug.cgi?id=219365
+
+ Reviewed by Wenson Hsieh.
+
+ Create a separate highlight register for app highlights so that there is a clear separation
+ with no risk of web content accessing the wrong highlights. Extend rendering to include the
+ app highlights with the current default settings.
+
+ * Modules/highlight/Highlight.h:
+ * Modules/highlight/HighlightRegister.cpp:
+ (WebCore::HighlightRegister::appHighlightKey):
+ (WebCore::HighlightRegister::addAppHighlight):
+ * Modules/highlight/HighlightRegister.h:
+ * WebCore.xcodeproj/project.pbxproj:
+ * css/CSSValueKeywords.in:
+ * dom/Document.cpp:
+ (WebCore::Document::appHighlightRegister):
+ (WebCore::Document::collectRageDataFromRegister):
+ (WebCore::Document::updateHighlightPositions):
+ * dom/Document.h:
+ * dom/StaticRange.h:
+ * page/ContextMenuController.cpp:
+ (WebCore::ContextMenuController::contextMenuItemSelected):
+ * rendering/HighlightData.cpp:
+ (WebCore::rendererAfterOffset):
+ * rendering/InlineTextBox.cpp:
+ (WebCore::InlineTextBox::resolveStyleForMarkedText):
+ (WebCore::InlineTextBox::collectMarkedTextsForHighlights const):
+ * rendering/MarkedText.h:
+ * rendering/RenderTheme.cpp:
+ (WebCore::RenderTheme::platformAppHighlightColor const):
+ * rendering/RenderTheme.h:
+ * rendering/RenderThemeIOS.mm:
+ (WebCore::cssValueIDSelectorList):
+ * rendering/RenderThemeMac.h:
+ * rendering/RenderThemeMac.mm:
+ (WebCore::RenderThemeMac::platformAppHighlightColor const):
+ (WebCore::RenderThemeMac::systemColor const):
+
2020-12-02 Julian Gonzalez <[email protected]>
Fix crash with performance.measure() with negative duration
Modified: trunk/Source/WebCore/Headers.cmake (270361 => 270362)
--- trunk/Source/WebCore/Headers.cmake 2020-12-02 20:07:40 UTC (rev 270361)
+++ trunk/Source/WebCore/Headers.cmake 2020-12-02 20:09:26 UTC (rev 270362)
@@ -44,6 +44,9 @@
Modules/geolocation/PositionErrorCallback.h
Modules/geolocation/PositionOptions.h
+ Modules/highlight/Highlight.h
+ Modules/highlight/HighlightRegister.h
+
Modules/indexeddb/IDBActiveDOMObject.h
Modules/indexeddb/IDBDatabaseIdentifier.h
Modules/indexeddb/IDBDatabaseNameAndVersionRequest.h
Modified: trunk/Source/WebCore/Modules/highlight/Highlight.h (270361 => 270362)
--- trunk/Source/WebCore/Modules/highlight/Highlight.h 2020-12-02 20:07:40 UTC (rev 270361)
+++ trunk/Source/WebCore/Modules/highlight/Highlight.h 2020-12-02 20:09:26 UTC (rev 270362)
@@ -54,7 +54,7 @@
class Highlight : public RefCounted<Highlight> {
public:
- static Ref<Highlight> create(StaticRange&);
+ WEBCORE_EXPORT static Ref<Highlight> create(StaticRange&);
void clearFromSetLike();
bool addToSetLike(StaticRange&);
bool removeFromSetLike(const StaticRange&);
Modified: trunk/Source/WebCore/Modules/highlight/HighlightRegister.cpp (270361 => 270362)
--- trunk/Source/WebCore/Modules/highlight/HighlightRegister.cpp 2020-12-02 20:07:40 UTC (rev 270361)
+++ trunk/Source/WebCore/Modules/highlight/HighlightRegister.cpp 2020-12-02 20:09:26 UTC (rev 270362)
@@ -53,4 +53,17 @@
return m_map.remove(key);
}
+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)));
+}
+
+}
Modified: trunk/Source/WebCore/Modules/highlight/HighlightRegister.h (270361 => 270362)
--- trunk/Source/WebCore/Modules/highlight/HighlightRegister.h 2020-12-02 20:07:40 UTC (rev 270361)
+++ trunk/Source/WebCore/Modules/highlight/HighlightRegister.h 2020-12-02 20:09:26 UTC (rev 270362)
@@ -34,6 +34,7 @@
class DOMMapAdapter;
class DOMString;
class Highlight;
+class StaticRange;
class HighlightRegister : public RefCounted<HighlightRegister> {
public:
@@ -43,6 +44,9 @@
void setFromMapLike(String&&, Ref<Highlight>&&);
void clear();
bool remove(const String&);
+
+ WEBCORE_EXPORT void addAppHighlight(Ref<StaticRange>&&);
+ static ASCIILiteral appHighlightKey();
const HashMap<String, Ref<Highlight>>& map() const { return m_map; }
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (270361 => 270362)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2020-12-02 20:07:40 UTC (rev 270361)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2020-12-02 20:09:26 UTC (rev 270362)
@@ -1208,6 +1208,8 @@
43EDD67F1B485DBF00640E75 /* CombinedFiltersAlphabet.h in Headers */ = {isa = PBXBuildFile; fileRef = 43EDD67D1B485DBF00640E75 /* CombinedFiltersAlphabet.h */; settings = {ATTRIBUTES = (Private, ); }; };
440EDBD1255E116C00300BA7 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 446EE4E8255E0D9200454463 /* Localizable.strings */; };
4415292E0E1AE8A000C4A2D0 /* HTMLPlugInImageElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 4415292C0E1AE8A000C4A2D0 /* HTMLPlugInImageElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 4430D00B2575A83E0046D401 /* Highlight.h in Headers */ = {isa = PBXBuildFile; fileRef = 44E88E51236A5C8D009B4847 /* Highlight.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 4430D00D2575A8A50046D401 /* HighlightRegister.h in Headers */ = {isa = PBXBuildFile; fileRef = 44E88E50236A56AC009B4847 /* HighlightRegister.h */; settings = {ATTRIBUTES = (Private, ); }; };
445775E520472F73008DCE5D /* LocalDefaultSystemAppearance.h in Headers */ = {isa = PBXBuildFile; fileRef = 445775E420472F73008DCE5D /* LocalDefaultSystemAppearance.h */; settings = {ATTRIBUTES = (Private, ); }; };
4463CF682212FA68001A8577 /* DataDetectorsCoreSoftLink.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7C7941E21C56C29300A4C58E /* DataDetectorsCoreSoftLink.mm */; };
4465D7BD2536D05E0016666D /* SelectionRangeData.h in Headers */ = {isa = PBXBuildFile; fileRef = 44B38BF42536901A00A4458D /* SelectionRangeData.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -32128,7 +32130,9 @@
515BE19C1D54F6C100DD7C68 /* HIDGamepad.h in Headers */,
510A91DA24CF3D8C00BFD89C /* HIDGamepadElement.h in Headers */,
515BE19E1D54F6C100DD7C68 /* HIDGamepadProvider.h in Headers */,
+ 4430D00B2575A83E0046D401 /* Highlight.h in Headers */,
CDCFABBD18C0AF78006F8450 /* HighlightData.h in Headers */,
+ 4430D00D2575A8A50046D401 /* HighlightRegister.h in Headers */,
BC94D1540C275C8B006BC617 /* History.h in Headers */,
97DCE20210807C750057D394 /* HistoryController.h in Headers */,
51741D110B07259A00ED442C /* HistoryItem.h in Headers */,
Modified: trunk/Source/WebCore/css/CSSValueKeywords.in (270361 => 270362)
--- trunk/Source/WebCore/css/CSSValueKeywords.in 2020-12-02 20:07:40 UTC (rev 270361)
+++ trunk/Source/WebCore/css/CSSValueKeywords.in 2020-12-02 20:09:26 UTC (rev 270362)
@@ -259,6 +259,7 @@
-apple-system-purple
-apple-system-red
-apple-system-yellow
+-apple-system-app-highlight-background
#endif
#if defined(WTF_PLATFORM_MAC) && WTF_PLATFORM_MAC
-apple-system-alternate-selected-text
Modified: trunk/Source/WebCore/dom/Document.cpp (270361 => 270362)
--- trunk/Source/WebCore/dom/Document.cpp 2020-12-02 20:07:40 UTC (rev 270361)
+++ trunk/Source/WebCore/dom/Document.cpp 2020-12-02 20:09:26 UTC (rev 270362)
@@ -795,6 +795,9 @@
if (m_highlightRegister)
m_highlightRegister->clear();
+ if (m_appHighlightRegister)
+ m_appHighlightRegister->clear();
+
m_pendingScrollEventTargetList = nullptr;
if (m_timelinesController)
@@ -2774,21 +2777,34 @@
return *m_highlightRegister;
}
+HighlightRegister& Document::appHighlightRegister()
+{
+ if (!m_appHighlightRegister)
+ m_appHighlightRegister = HighlightRegister::create();
+ return *m_appHighlightRegister;
+}
+
+void Document::collectRangeDataFromRegister(Vector<WeakPtr<HighlightRangeData>>& rangesData, const HighlightRegister& highlightRegister)
+{
+ for (auto& highlight : highlightRegister.map()) {
+ for (auto& rangeData : highlight.value->rangesData()) {
+ if (rangeData->startPosition && rangeData->endPosition)
+ continue;
+ if (&rangeData->range->startContainer().treeScope() != &rangeData->range->endContainer().treeScope())
+ continue;
+ rangesData.append(makeWeakPtr(rangeData.ptr()));
+ }
+ }
+}
+
void Document::updateHighlightPositions()
{
Vector<WeakPtr<HighlightRangeData>> rangesData;
- if (m_highlightRegister) {
- for (auto& highlight : m_highlightRegister->map()) {
- for (auto& rangeData : highlight.value->rangesData()) {
- if (rangeData->startPosition && rangeData->endPosition)
- continue;
- if (&rangeData->range->startContainer().treeScope() != &rangeData->range->endContainer().treeScope())
- continue;
- rangesData.append(makeWeakPtr(rangeData.ptr()));
- }
- }
- }
-
+ if (m_highlightRegister)
+ collectRangeDataFromRegister(rangesData, *m_highlightRegister.get());
+ if (m_appHighlightRegister)
+ collectRangeDataFromRegister(rangesData, *m_appHighlightRegister.get());
+
for (auto& weakRangeData : rangesData) {
if (auto* rangeData = weakRangeData.get()) {
VisibleSelection visibleSelection(rangeData->range);
@@ -2797,7 +2813,7 @@
if (!rangeData->startPosition.hasValue())
startPosition = visibleSelection.visibleStart().deepEquivalent();
if (!rangeData->endPosition.hasValue())
- endPosition = visibleSelection.visibleEnd().deepEquivalent(); // <MMG> switch to END
+ endPosition = visibleSelection.visibleEnd().deepEquivalent();
if (!weakRangeData.get())
continue;
Modified: trunk/Source/WebCore/dom/Document.h (270361 => 270362)
--- trunk/Source/WebCore/dom/Document.h 2020-12-02 20:07:40 UTC (rev 270361)
+++ trunk/Source/WebCore/dom/Document.h 2020-12-02 20:09:26 UTC (rev 270362)
@@ -231,6 +231,7 @@
class XPathResult;
struct BoundaryPoint;
+struct HighlightRangeData;
struct IntersectionObserverData;
template<typename> class ExceptionOr;
@@ -1572,8 +1573,11 @@
WEBCORE_EXPORT TextManipulationController& textManipulationController();
TextManipulationController* textManipulationControllerIfExists() { return m_textManipulationController.get(); }
-
+
+ HighlightRegister* highlightRegisterIfExists() { return m_highlightRegister.get(); }
HighlightRegister& highlightRegister();
+ HighlightRegister* appHighlightRegisterIfExists() { return m_appHighlightRegister.get(); }
+ WEBCORE_EXPORT HighlightRegister& appHighlightRegister();
void updateHighlightPositions();
bool allowsContentJavaScript() const;
@@ -1701,6 +1705,8 @@
void platformSuspendOrStopActiveDOMObjects();
+ void collectRangeDataFromRegister(Vector<WeakPtr<HighlightRangeData>>&, const HighlightRegister&);
+
bool isBodyPotentiallyScrollable(HTMLBodyElement&);
void didLogMessage(const WTFLogChannel&, WTFLogLevel, Vector<JSONLogValue>&&) final;
@@ -1931,6 +1937,7 @@
#endif
RefPtr<HighlightRegister> m_highlightRegister;
+ RefPtr<HighlightRegister> m_appHighlightRegister;
Timer m_visualUpdatesSuppressionTimer;
Modified: trunk/Source/WebCore/dom/StaticRange.h (270361 => 270362)
--- trunk/Source/WebCore/dom/StaticRange.h 2020-12-02 20:07:40 UTC (rev 270361)
+++ trunk/Source/WebCore/dom/StaticRange.h 2020-12-02 20:09:26 UTC (rev 270362)
@@ -43,7 +43,7 @@
};
static ExceptionOr<Ref<StaticRange>> create(Init&&);
- static Ref<StaticRange> create(const SimpleRange&);
+ WEBCORE_EXPORT static Ref<StaticRange> create(const SimpleRange&);
static Ref<StaticRange> create(SimpleRange&&);
Node& startContainer() const final { return SimpleRange::startContainer(); }
Modified: trunk/Source/WebCore/rendering/HighlightData.cpp (270361 => 270362)
--- trunk/Source/WebCore/rendering/HighlightData.cpp 2020-12-02 20:07:40 UTC (rev 270361)
+++ trunk/Source/WebCore/rendering/HighlightData.cpp 2020-12-02 20:09:26 UTC (rev 270362)
@@ -82,7 +82,7 @@
m_current = placeholder.spanner();
}
-static RenderObject* rendererAfterOffset(const RenderObject& renderer, unsigned offset) // <MMG> used in both, might should not be static
+static RenderObject* rendererAfterOffset(const RenderObject& renderer, unsigned offset)
{
auto* child = renderer.childAt(offset);
return child ? child : renderer.nextInPreOrderAfterChildren();
Modified: trunk/Source/WebCore/rendering/InlineTextBox.cpp (270361 => 270362)
--- trunk/Source/WebCore/rendering/InlineTextBox.cpp 2020-12-02 20:07:40 UTC (rev 270361)
+++ trunk/Source/WebCore/rendering/InlineTextBox.cpp 2020-12-02 20:09:26 UTC (rev 270362)
@@ -846,6 +846,13 @@
}
}
break;
+#if ENABLE(APP_HIGHLIGHTS)
+ case MarkedText::AppHighlight: {
+ OptionSet<StyleColor::Options> styleColorOptions = { StyleColor::Options::UseSystemAppearance };
+ style.backgroundColor = renderer().theme().appHighlightColor(styleColorOptions);
+ break;
+ }
+#endif
case MarkedText::DraggedContent:
style.alpha = 0.25;
break;
@@ -1052,21 +1059,37 @@
auto& parentRenderer = parent()->renderer();
auto& parentStyle = parentRenderer.style();
HighlightData highlightData;
- for (auto& highlight : renderer().document().highlightRegister().map()) {
- auto renderStyle = parentRenderer.getUncachedPseudoStyle({ PseudoId::Highlight, highlight.key }, &parentStyle);
- if (!renderStyle)
- continue;
- if (renderStyle->textDecorationsInEffect().isEmpty() && phase == TextPaintPhase::Decoration)
- continue;
- for (auto& rangeData : highlight.value->rangesData()) {
- if (!highlightData.setRenderRange(rangeData))
+ if (auto highlightRegister = renderer().document().highlightRegisterIfExists()) {
+ for (auto& highlight : highlightRegister->map()) {
+ auto renderStyle = parentRenderer.getUncachedPseudoStyle({ PseudoId::Highlight, highlight.key }, &parentStyle);
+ if (!renderStyle)
continue;
-
- auto [highlightStart, highlightEnd] = highlightStartEnd(highlightData);
- if (highlightStart < highlightEnd)
- markedTexts.append({ highlightStart, highlightEnd, MarkedText::Highlight, nullptr, highlight.key });
+ if (renderStyle->textDecorationsInEffect().isEmpty() && phase == TextPaintPhase::Decoration)
+ continue;
+ for (auto& rangeData : highlight.value->rangesData()) {
+ if (!highlightData.setRenderRange(rangeData))
+ continue;
+
+ auto [highlightStart, highlightEnd] = highlightStartEnd(highlightData);
+ if (highlightStart < highlightEnd)
+ markedTexts.append({ highlightStart, highlightEnd, MarkedText::Highlight, nullptr, highlight.key });
+ }
}
}
+#if ENABLE(APP_HIGHLIGHTS)
+ if (auto appHighlightRegister = renderer().document().appHighlightRegisterIfExists()) {
+ for (auto& highlight : appHighlightRegister->map()) {
+ for (auto& rangeData : highlight.value->rangesData()) {
+ if (!highlightData.setRenderRange(rangeData))
+ continue;
+
+ auto [highlightStart, highlightEnd] = highlightStartEnd(highlightData);
+ if (highlightStart < highlightEnd)
+ markedTexts.append({ highlightStart, highlightEnd, MarkedText::AppHighlight });
+ }
+ }
+ }
+#endif
return markedTexts;
}
Modified: trunk/Source/WebCore/rendering/MarkedText.h (270361 => 270362)
--- trunk/Source/WebCore/rendering/MarkedText.h 2020-12-02 20:07:40 UTC (rev 270361)
+++ trunk/Source/WebCore/rendering/MarkedText.h 2020-12-02 20:09:26 UTC (rev 270362)
@@ -42,6 +42,9 @@
TextMatch,
DictationAlternatives,
Highlight,
+#if ENABLE(APP_HIGHLIGHTS)
+ AppHighlight,
+#endif
#if PLATFORM(IOS_FAMILY)
// FIXME: See <rdar://problem/8933352>. Also, remove the PLATFORM(IOS_FAMILY)-guard.
DictationPhraseWithAlternatives,
Modified: trunk/Source/WebCore/rendering/RenderReplaced.cpp (270361 => 270362)
--- trunk/Source/WebCore/rendering/RenderReplaced.cpp 2020-12-02 20:07:40 UTC (rev 270361)
+++ trunk/Source/WebCore/rendering/RenderReplaced.cpp 2020-12-02 20:09:26 UTC (rev 270362)
@@ -142,19 +142,38 @@
Color RenderReplaced::calculateHighlightColor() const
{
HighlightData highlightData;
- for (auto& highlight : document().highlightRegister().map()) {
- for (auto& rangeData : highlight.value->rangesData()) {
- if (!highlightData.setRenderRange(rangeData))
- continue;
-
- auto state = highlightData.highlightStateForRenderer(*this);
- if (!isHighlighted(state, highlightData))
- continue;
+#if ENABLE(APP_HIGHLIGHTS)
+ if (auto appHighlightRegister = document().appHighlightRegisterIfExists()) {
+ for (auto& highlight : appHighlightRegister->map()) {
+ for (auto& rangeData : highlight.value->rangesData()) {
+ if (!highlightData.setRenderRange(rangeData))
+ continue;
- if (auto highlightStyle = getUncachedPseudoStyle({ PseudoId::Highlight, highlight.key }, &style()))
- return highlightStyle->backgroundColor();
+ auto state = highlightData.highlightStateForRenderer(*this);
+ if (!isHighlighted(state, highlightData))
+ continue;
+
+ OptionSet<StyleColor::Options> styleColorOptions = { StyleColor::Options::UseSystemAppearance };
+ return theme().appHighlightColor(styleColorOptions);
+ }
}
}
+#endif
+ if (auto highlightRegister = document().highlightRegisterIfExists()) {
+ 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;
+
+ if (auto highlightStyle = getUncachedPseudoStyle({ PseudoId::Highlight, highlight.key }, &style()))
+ return highlightStyle->backgroundColor();
+ }
+ }
+ }
return Color();
}
Modified: trunk/Source/WebCore/rendering/RenderTheme.cpp (270361 => 270362)
--- trunk/Source/WebCore/rendering/RenderTheme.cpp 2020-12-02 20:07:40 UTC (rev 270361)
+++ trunk/Source/WebCore/rendering/RenderTheme.cpp 2020-12-02 20:09:26 UTC (rev 270362)
@@ -1353,6 +1353,21 @@
return Color::yellow;
}
+#if ENABLE(APP_HIGHLIGHTS)
+Color RenderTheme::appHighlightColor(OptionSet<StyleColor::Options> options) const
+{
+ auto& cache = colorCache(options);
+ if (!cache.appHighlightColor.isValid())
+ cache.appHighlightColor = transformSelectionBackgroundColor(platformAppHighlightColor(options), options);
+ return cache.appHighlightColor;
+}
+
+Color RenderTheme::platformAppHighlightColor(OptionSet<StyleColor::Options>) const
+{
+ return Color::yellow;
+}
+#endif
+
#if ENABLE(TOUCH_EVENTS)
Color RenderTheme::tapHighlightColor()
Modified: trunk/Source/WebCore/rendering/RenderTheme.h (270361 => 270362)
--- trunk/Source/WebCore/rendering/RenderTheme.h 2020-12-02 20:07:40 UTC (rev 270361)
+++ trunk/Source/WebCore/rendering/RenderTheme.h 2020-12-02 20:09:26 UTC (rev 270362)
@@ -158,6 +158,9 @@
// Highlighting color for search matches.
Color textSearchHighlightColor(OptionSet<StyleColor::Options>) const;
+ // Default highlighting color for app highlights.
+ Color appHighlightColor(OptionSet<StyleColor::Options>) const;
+
virtual Color disabledTextColor(const Color& textColor, const Color& backgroundColor) const;
WEBCORE_EXPORT Color focusRingColor(OptionSet<StyleColor::Options>) const;
@@ -276,7 +279,9 @@
virtual Color platformInactiveListBoxSelectionForegroundColor(OptionSet<StyleColor::Options>) const;
virtual Color platformTextSearchHighlightColor(OptionSet<StyleColor::Options>) const;
-
+#if ENABLE(APP_HIGHLIGHTS)
+ virtual Color platformAppHighlightColor(OptionSet<StyleColor::Options>) const;
+#endif
virtual bool supportsSelectionForegroundColors(OptionSet<StyleColor::Options>) const { return true; }
virtual bool supportsListBoxSelectionForegroundColors(OptionSet<StyleColor::Options>) const { return true; }
@@ -427,6 +432,10 @@
Color inactiveListBoxSelectionForegroundColor;
Color textSearchHighlightColor;
+
+#if ENABLE(APP_HIGHLIGHTS)
+ Color appHighlightColor;
+#endif
};
virtual ColorCache& colorCache(OptionSet<StyleColor::Options>) const;
Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.h (270361 => 270362)
--- trunk/Source/WebCore/rendering/RenderThemeIOS.h 2020-12-02 20:07:40 UTC (rev 270361)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.h 2020-12-02 20:09:26 UTC (rev 270362)
@@ -126,6 +126,10 @@
Color platformInactiveSelectionBackgroundColor(OptionSet<StyleColor::Options>) const override;
Color platformFocusRingColor(OptionSet<StyleColor::Options>) const final;
+#if ENABLE(APP_HIGHLIGHTS)
+ Color platformAppHighlightColor(OptionSet<StyleColor::Options>) const final;
+#endif
+
#if ENABLE(TOUCH_EVENTS)
Color platformTapHighlightColor() const override { return SRGBA<uint8_t> { 26, 26, 26, 77 } ; }
#endif
Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.mm (270361 => 270362)
--- trunk/Source/WebCore/rendering/RenderThemeIOS.mm 2020-12-02 20:07:40 UTC (rev 270361)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.mm 2020-12-02 20:09:26 UTC (rev 270362)
@@ -1159,6 +1159,14 @@
return systemFocusRingColor();
}
+#if ENABLE(APP_HIGHLIGHTS)
+Color RenderThemeIOS::platformAppHighlightColor(OptionSet<StyleColor::Options>) const
+{
+ // FIXME: expose the real value from UIKit.
+ return SRGBA<uint8_t> { 255, 238, 190 };
+}
+#endif
+
bool RenderThemeIOS::shouldHaveSpinButton(const HTMLInputElement&) const
{
return false;
Modified: trunk/Source/WebCore/rendering/RenderThemeMac.h (270361 => 270362)
--- trunk/Source/WebCore/rendering/RenderThemeMac.h 2020-12-02 20:07:40 UTC (rev 270361)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.h 2020-12-02 20:09:26 UTC (rev 270362)
@@ -66,6 +66,9 @@
Color platformInactiveListBoxSelectionForegroundColor(OptionSet<StyleColor::Options>) const final;
Color platformFocusRingColor(OptionSet<StyleColor::Options>) const final;
Color platformTextSearchHighlightColor(OptionSet<StyleColor::Options>) const final;
+#if ENABLE(APP_HIGHLIGHTS)
+ Color platformAppHighlightColor(OptionSet<StyleColor::Options>) const final;
+#endif
ScrollbarControlSize scrollbarControlSizeForPart(ControlPart) final { return ScrollbarControlSize::Small; }
Modified: trunk/Source/WebCore/rendering/RenderThemeMac.mm (270361 => 270362)
--- trunk/Source/WebCore/rendering/RenderThemeMac.mm 2020-12-02 20:07:40 UTC (rev 270361)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.mm 2020-12-02 20:09:26 UTC (rev 270362)
@@ -476,6 +476,14 @@
return colorFromNSColor([NSColor findHighlightColor]);
}
+#if ENABLE(APP_HIGHLIGHTS)
+Color RenderThemeMac::platformAppHighlightColor(OptionSet<StyleColor::Options>) const
+{
+ // FIXME: expose the real value from AppKit.
+ return SRGBA<uint8_t> { 255, 238, 190 };
+}
+#endif
+
static SRGBA<uint8_t> menuBackgroundColor()
{
RetainPtr<NSBitmapImageRep> offscreenRep = adoptNS([[NSBitmapImageRep alloc] initWithBitmapDataPlanes:nil pixelsWide:1 pixelsHigh:1
Modified: trunk/Source/WebKit/ChangeLog (270361 => 270362)
--- trunk/Source/WebKit/ChangeLog 2020-12-02 20:07:40 UTC (rev 270361)
+++ trunk/Source/WebKit/ChangeLog 2020-12-02 20:09:26 UTC (rev 270362)
@@ -1,3 +1,29 @@
+2020-12-02 Megan Gardner <[email protected]>
+
+ Create and draw app highlights
+ https://bugs.webkit.org/show_bug.cgi?id=219365
+
+ Reviewed by Wenson Hsieh.
+
+ Handle the creation of App Highlights from selections when the context menu item is selected.
+ This patch will add the highlights to the Document's app Highlight register, and handle drawing
+ them in InlineTextBox. Later patches will handle the persistent storage and repopulation of app
+ highlights on launch or reload of a page.
+
+ * UIProcess/Cocoa/WebPageProxyCocoa.mm:
+ (WebKit::WebPageProxy::createAppHighlightInSelectedRange):
+ * UIProcess/PageClient.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::contextMenuItemSelected):
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView createHighlightInCurrentGroupWithRange:]):
+ (-[WKContentView createHighlightInNewGroupWithRange:]):
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::createAppHighlightInSelectedRange):
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebPage/WebPage.messages.in:
+
2020-12-02 Brent Fulgham <[email protected]>
[iOS] Silence sandbox warning for unneeded sysctl-read of "hw.tbfrequency_compat"
Copied: trunk/Source/WebKit/Shared/CreateNewGroupForHighlight.h (from rev 270361, trunk/Source/WebCore/Modules/highlight/HighlightRegister.cpp) (0 => 270362)
--- trunk/Source/WebKit/Shared/CreateNewGroupForHighlight.h (rev 0)
+++ trunk/Source/WebKit/Shared/CreateNewGroupForHighlight.h 2020-12-02 20:09:26 UTC (rev 270362)
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2020 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
+
+namespace WebKit {
+
+enum class CreateNewGroupForHighlight : bool { No, Yes };
+
+} // namespace WebKit
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm (270361 => 270362)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm 2020-12-02 20:07:40 UTC (rev 270361)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm 2020-12-02 20:09:26 UTC (rev 270362)
@@ -38,6 +38,7 @@
#import "SafeBrowsingSPI.h"
#import "SafeBrowsingWarning.h"
#import "SharedBufferCopy.h"
+#import "WebPage.h"
#import "WebPageMessages.h"
#import "WebPasteboardProxy.h"
#import "WebProcessProxy.h"
@@ -543,6 +544,17 @@
m_activityStateUpdateCallbacks.append(WTFMove(completionHandler));
}
+#if ENABLE(APP_HIGHLIGHTS)
+void WebPageProxy::createAppHighlightInSelectedRange(CreateNewGroupForHighlight createNewGroup)
+{
+ if (!hasRunningProcess())
+ return;
+
+ send(Messages::WebPage::CreateAppHighlightInSelectedRange(createNewGroup));
+}
+
+#endif
+
} // namespace WebKit
#undef MESSAGE_CHECK_COMPLETION
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (270361 => 270362)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2020-12-02 20:07:40 UTC (rev 270361)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2020-12-02 20:09:26 UTC (rev 270362)
@@ -117,6 +117,7 @@
#include "WebNavigationState.h"
#include "WebNotificationManagerProxy.h"
#include "WebOpenPanelResultListenerProxy.h"
+#include "WebPage.h"
#include "WebPageCreationParameters.h"
#include "WebPageDebuggable.h"
#include "WebPageGroup.h"
@@ -6629,6 +6630,16 @@
TextChecker::toggleSpellingUIIsShowing();
return;
}
+#if ENABLE(APP_HIGHLIGHTS)
+ if (item.action() == ContextMenuItemTagAddHighlightToNewGroup) {
+ createAppHighlightInSelectedRange(CreateNewGroupForHighlight::Yes);
+ return;
+ }
+ if (item.action() == ContextMenuItemTagAddHighlightToCurrentGroup) {
+ createAppHighlightInSelectedRange(CreateNewGroupForHighlight::No);
+ return;
+ }
+#endif
if (item.action() == ContextMenuItemTagLearnSpelling || item.action() == ContextMenuItemTagIgnoreSpelling)
++m_pendingLearnOrIgnoreWordMessageCount;
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (270361 => 270362)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2020-12-02 20:07:40 UTC (rev 270361)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2020-12-02 20:09:26 UTC (rev 270362)
@@ -29,6 +29,7 @@
#include "Connection.h"
#include "ContentAsStringIncludesChildFrames.h"
#include "ContextMenuContextData.h"
+#include "CreateNewGroupForHighlight.h"
#include "DownloadID.h"
#include "DragControllerAction.h"
#include "EditingRange.h"
@@ -363,6 +364,7 @@
struct URLSchemeTaskParameters;
struct UserMessage;
+enum class CreateNewGroupForHighlight : bool;
enum class NegotiatedLegacyTLS : bool;
enum class ProcessSwapRequestedByClient : bool;
enum class SpeechRecognitionPermissionDecision : bool;
@@ -1827,6 +1829,10 @@
void syncIfMockDevicesEnabledChanged();
+#if ENABLE(APP_HIGHLIGHTS)
+ void createAppHighlightInSelectedRange(CreateNewGroupForHighlight);
+#endif
+
private:
WebPageProxy(PageClient&, WebProcessProxy&, Ref<API::PageConfiguration>&&);
void platformInitialize();
Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (270361 => 270362)
--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2020-12-02 20:07:40 UTC (rev 270361)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2020-12-02 20:09:26 UTC (rev 270362)
@@ -30,6 +30,7 @@
#import "APIUIClient.h"
#import "CompletionHandlerCallChecker.h"
+#import "CreateNewGroupForHighlight.h"
#import "DocumentEditingContext.h"
#import "InputViewUpdateDeferrer.h"
#import "InsertTextOptions.h"
@@ -8665,12 +8666,12 @@
- (void)createHighlightInCurrentGroupWithRange:(id)sender
{
- // FIXME: Add Highlight logic.
+ _page->createAppHighlightInSelectedRange(WebKit::CreateNewGroupForHighlight::NO);
}
- (void)createHighlightInNewGroupWithRange:(id)sender
{
- // FIXME: Add Highlight logic.
+ _page->createAppHighlightInSelectedRange(WebKit::CreateNewGroupForHighlight::YES);
}
#endif
Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (270361 => 270362)
--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2020-12-02 20:07:40 UTC (rev 270361)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2020-12-02 20:09:26 UTC (rev 270362)
@@ -931,6 +931,7 @@
41FABD2A1F4DE001006A6C97 /* CacheStorageEngineCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 41FABD281F4DDFDC006A6C97 /* CacheStorageEngineCache.h */; };
41FAF5F51E3C0649001AE678 /* WebRTCResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = 41FAF5F41E3C0641001AE678 /* WebRTCResolver.h */; };
41FAF5F81E3C1021001AE678 /* LibWebRTCResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = 41FAF5F61E3C0B47001AE678 /* LibWebRTCResolver.h */; };
+ 4430D0172576D9DD0046D401 /* CreateNewGroupForHighlight.h in Headers */ = {isa = PBXBuildFile; fileRef = 4430D0162576D9DC0046D401 /* CreateNewGroupForHighlight.h */; };
4459984222833E8700E61373 /* SyntheticEditingCommandType.h in Headers */ = {isa = PBXBuildFile; fileRef = 4459984122833E6000E61373 /* SyntheticEditingCommandType.h */; };
446DC64C24A2D8E50061F390 /* PlaybackSessionContextIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 446DC64B24A2D8AD0061F390 /* PlaybackSessionContextIdentifier.h */; };
4482734724528F6000A95493 /* CocoaImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 4482734624528F6000A95493 /* CocoaImage.h */; };
@@ -3659,6 +3660,7 @@
41FCD6BD23CE043F00C62567 /* RemoteSampleBufferDisplayLayerManager.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = RemoteSampleBufferDisplayLayerManager.messages.in; sourceTree = "<group>"; };
41FCD6BE23CE044000C62567 /* RemoteSampleBufferDisplayLayerManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteSampleBufferDisplayLayerManager.cpp; sourceTree = "<group>"; };
41FCD6BF23CE044000C62567 /* RemoteSampleBufferDisplayLayerManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteSampleBufferDisplayLayerManager.h; sourceTree = "<group>"; };
+ 4430D0162576D9DC0046D401 /* CreateNewGroupForHighlight.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CreateNewGroupForHighlight.h; sourceTree = "<group>"; };
4450AEBF1DC3FAE5009943F2 /* SharedMemoryCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SharedMemoryCocoa.cpp; sourceTree = "<group>"; };
4459984122833E6000E61373 /* SyntheticEditingCommandType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SyntheticEditingCommandType.h; sourceTree = "<group>"; };
446DC64B24A2D8AD0061F390 /* PlaybackSessionContextIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlaybackSessionContextIdentifier.h; sourceTree = "<group>"; };
@@ -6278,6 +6280,7 @@
5106D7BF18BDBE73000AB166 /* ContextMenuContextData.cpp */,
5106D7C018BDBE73000AB166 /* ContextMenuContextData.h */,
99F642D21FABE378009621E9 /* CoordinateSystem.h */,
+ 4430D0162576D9DC0046D401 /* CreateNewGroupForHighlight.h */,
99036AE823A970870000B06A /* DebuggableInfoData.cpp */,
99036AE723A970870000B06A /* DebuggableInfoData.h */,
0F189CAB24749F2F00E58D81 /* DisplayLinkObserverID.h */,
@@ -11249,6 +11252,7 @@
5106D7C418BDBE73000AB166 /* ContextMenuContextData.h in Headers */,
37C21CAE1E994C0C0029D5F9 /* CorePredictionSPI.h in Headers */,
B878B615133428DC006888E9 /* CorrectionPanel.h in Headers */,
+ 4430D0172576D9DD0046D401 /* CreateNewGroupForHighlight.h in Headers */,
57597EBD218184900037F924 /* CtapAuthenticator.h in Headers */,
57597EB921811D9A0037F924 /* CtapHidDriver.h in Headers */,
570DAACA230385FD00E8FC04 /* CtapNfcDriver.h in Headers */,
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (270361 => 270362)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2020-12-02 20:07:40 UTC (rev 270361)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2020-12-02 20:09:26 UTC (rev 270362)
@@ -156,6 +156,7 @@
#include <WebCore/DataTransfer.h>
#include <WebCore/DatabaseManager.h>
#include <WebCore/DeprecatedGlobalSettings.h>
+#include <WebCore/Document.h>
#include <WebCore/DocumentFragment.h>
#include <WebCore/DocumentLoader.h>
#include <WebCore/DocumentMarkerController.h>
@@ -186,6 +187,8 @@
#include <WebCore/HTMLPlugInElement.h>
#include <WebCore/HTMLSelectElement.h>
#include <WebCore/HTMLTextFormControlElement.h>
+#include <WebCore/Highlight.h>
+#include <WebCore/HighlightRegister.h>
#include <WebCore/HistoryController.h>
#include <WebCore/HistoryItem.h>
#include <WebCore/HitTestResult.h>
@@ -229,6 +232,7 @@
#include <WebCore/Settings.h>
#include <WebCore/ShadowRoot.h>
#include <WebCore/SharedBuffer.h>
+#include <WebCore/StaticRange.h>
#include <WebCore/StyleProperties.h>
#include <WebCore/SubframeLoader.h>
#include <WebCore/SubstituteData.h>
@@ -7060,6 +7064,26 @@
sandboxExtensions.clear();
}
+#if ENABLE(APP_HIGHLIGHTS)
+bool WebPage::createAppHighlightInSelectedRange(CreateNewGroupForHighlight createNewGroup)
+{
+ auto document = makeRefPtr(m_page->focusController().focusedOrMainFrame().document());
+
+ auto frame = makeRefPtr(document->frame());
+ if (!frame)
+ return false;
+
+ auto selectionRange = frame->selection().selection().toNormalizedRange();
+ if (!selectionRange)
+ return false;
+
+ document->appHighlightRegister().addAppHighlight(StaticRange::create(selectionRange.value()));
+
+ return true;
+}
+#endif
+
+
} // namespace WebKit
#undef RELEASE_LOG_IF_ALLOWED
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (270361 => 270362)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2020-12-02 20:07:40 UTC (rev 270361)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2020-12-02 20:09:26 UTC (rev 270362)
@@ -34,6 +34,7 @@
#include "APIObject.h"
#include "CallbackID.h"
#include "ContentAsStringIncludesChildFrames.h"
+#include "CreateNewGroupForHighlight.h"
#include "DownloadID.h"
#include "DrawingAreaInfo.h"
#include "EditingRange.h"
@@ -1366,6 +1367,10 @@
RemoteRenderingBackendProxy& ensureRemoteRenderingBackendProxy();
#endif
+#if ENABLE(APP_HIGHLIGHTS)
+ bool createAppHighlightInSelectedRange(CreateNewGroupForHighlight);
+#endif
+
private:
WebPage(WebCore::PageIdentifier, WebPageCreationParameters&&);
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (270361 => 270362)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2020-12-02 20:07:40 UTC (rev 270361)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2020-12-02 20:09:26 UTC (rev 270362)
@@ -616,4 +616,9 @@
SetHasResourceLoadClient(bool has)
SetCanUseCredentialStorage(bool canUse)
+
+#if ENABLE(APP_HIGHLIGHTS)
+ CreateAppHighlightInSelectedRange(enum:bool WebKit::CreateNewGroupForHighlight createNewGroup)
+#endif
+
}
Modified: trunk/Tools/ChangeLog (270361 => 270362)
--- trunk/Tools/ChangeLog 2020-12-02 20:07:40 UTC (rev 270361)
+++ trunk/Tools/ChangeLog 2020-12-02 20:09:26 UTC (rev 270362)
@@ -1,3 +1,13 @@
+2020-12-02 Megan Gardner <[email protected]>
+
+ Create and draw app highlights
+ https://bugs.webkit.org/show_bug.cgi?id=219365
+
+ Reviewed by Wenson Hsieh.
+
+ * TestWebKitAPI/Tests/WebCore/MarkedText.cpp:
+ (WebCore::operator<<):
+
2020-12-02 Carlos Alberto Lopez Perez <[email protected]>
Remove unused JSC ARMv7 worker from EWS
Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/MarkedText.cpp (270361 => 270362)
--- trunk/Tools/TestWebKitAPI/Tests/WebCore/MarkedText.cpp 2020-12-02 20:07:40 UTC (rev 270361)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/MarkedText.cpp 2020-12-02 20:09:26 UTC (rev 270362)
@@ -57,6 +57,10 @@
return os << "TextMatch";
case MarkedText::Highlight:
return os << "Highlight";
+#if ENABLE(APP_HIGHLIGHTS)
+ case MarkedText::AppHighlight:
+ return os << "AppHighlight";
+#endif
case MarkedText::Unmarked:
return os << "Unmarked";
}