Title: [274501] trunk/Source/WebCore
- Revision
- 274501
- Author
- megan_gard...@apple.com
- Date
- 2021-03-16 11:44:40 -0700 (Tue, 16 Mar 2021)
Log Message
Attempt to restore highlights after paint to account for newly loaded content.
https://bugs.webkit.org/show_bug.cgi?id=223191
rdar://74722200
Reviewed by Tim Horton.
* Modules/highlight/AppHighlightStorage.cpp:
(WebCore::AppHighlightStorage::restoreUnrestoredAppHighlights):
* Modules/highlight/AppHighlightStorage.h:
* page/Page.cpp:
(WebCore::Page::doAfterUpdateRendering):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (274500 => 274501)
--- trunk/Source/WebCore/ChangeLog 2021-03-16 18:39:20 UTC (rev 274500)
+++ trunk/Source/WebCore/ChangeLog 2021-03-16 18:44:40 UTC (rev 274501)
@@ -1,3 +1,17 @@
+2021-03-16 Megan Gardner <megan_gard...@apple.com>
+
+ Attempt to restore highlights after paint to account for newly loaded content.
+ https://bugs.webkit.org/show_bug.cgi?id=223191
+ rdar://74722200
+
+ Reviewed by Tim Horton.
+
+ * Modules/highlight/AppHighlightStorage.cpp:
+ (WebCore::AppHighlightStorage::restoreUnrestoredAppHighlights):
+ * Modules/highlight/AppHighlightStorage.h:
+ * page/Page.cpp:
+ (WebCore::Page::doAfterUpdateRendering):
+
2021-03-16 Martin Robinson <mrobin...@igalia.com>
[Nicosia] Add support for scroll-snap when handling wheel events
Modified: trunk/Source/WebCore/Modules/highlight/AppHighlightStorage.cpp (274500 => 274501)
--- trunk/Source/WebCore/Modules/highlight/AppHighlightStorage.cpp 2021-03-16 18:39:20 UTC (rev 274500)
+++ trunk/Source/WebCore/Modules/highlight/AppHighlightStorage.cpp 2021-03-16 18:44:40 UTC (rev 274501)
@@ -246,6 +246,8 @@
m_unrestoredHighlights.append(appHighlightRangeData.value());
else
strongDocument->appHighlightRegister().addAppHighlight(StaticRange::create(*range));
+
+ m_timeAtLastRangeSearch = MonotonicTime::now();
}
void AppHighlightStorage::restoreUnrestoredAppHighlights()
@@ -265,6 +267,7 @@
else
strongDocument->appHighlightRegister().addAppHighlight(StaticRange::create(*range));
}
+ m_timeAtLastRangeSearch = MonotonicTime::now();
m_unrestoredHighlights = WTFMove(remainingRanges);
}
Modified: trunk/Source/WebCore/Modules/highlight/AppHighlightStorage.h (274500 => 274501)
--- trunk/Source/WebCore/Modules/highlight/AppHighlightStorage.h 2021-03-16 18:39:20 UTC (rev 274500)
+++ trunk/Source/WebCore/Modules/highlight/AppHighlightStorage.h 2021-03-16 18:44:40 UTC (rev 274501)
@@ -26,6 +26,7 @@
#pragma once
#include <wtf/Forward.h>
+#include <wtf/MonotonicTime.h>
#include <wtf/OptionSet.h>
#include <wtf/Optional.h>
#include <wtf/RefCounted.h>
@@ -39,10 +40,13 @@
class AppHighlightRangeData;
class Document;
class SharedBuffer;
+class StaticRange;
class Highlight;
enum class CreateNewGroupForHighlight : bool;
+enum class RestoreWithTextSearch : bool { No, Yes };
+
class AppHighlightStorage final : RefCounted<AppHighlightStorage> {
WTF_MAKE_FAST_ALLOCATED;
public:
@@ -52,9 +56,13 @@
WEBCORE_EXPORT void storeAppHighlight(Ref<StaticRange>&&);
WEBCORE_EXPORT void restoreAppHighlight(Ref<SharedBuffer>&&);
void restoreUnrestoredAppHighlights();
+ MonotonicTime lastRangeSearchTime() const { return m_timeAtLastRangeSearch; }
+ void resetLastRangeSearchTime() { m_timeAtLastRangeSearch = MonotonicTime::now(); }
+ bool hasUnrestoredHighlights() const { return m_unrestoredHighlights.size(); }
private:
WeakPtr<Document> m_document;
+ MonotonicTime m_timeAtLastRangeSearch;
Vector<AppHighlightRangeData> m_unrestoredHighlights;
};
Modified: trunk/Source/WebCore/page/Page.cpp (274500 => 274501)
--- trunk/Source/WebCore/page/Page.cpp 2021-03-16 18:39:20 UTC (rev 274500)
+++ trunk/Source/WebCore/page/Page.cpp 2021-03-16 18:44:40 UTC (rev 274501)
@@ -23,6 +23,7 @@
#include "ActivityStateChangeObserver.h"
#include "AlternativeTextClient.h"
#include "AnimationFrameRate.h"
+#include "AppHighlightStorage.h"
#include "ApplicationCacheStorage.h"
#include "AuthenticatorCoordinator.h"
#include "BackForwardCache.h"
@@ -1608,7 +1609,25 @@
forEachDocument([] (Document& document) {
document.updateHighlightPositions();
});
+#if ENABLE(APP_HIGHLIGHT)
+ forEachDocument([] (Document& document) {
+ if (!auto appHighlightStorage = document.appHighlightStorageIfExists())
+ return;
+
+ if (appHighlightStorage->hasUnrestoredHighlights() && MonotonicTime::now() - appHighlightStorage->lastRangeSearchTime() > 1_s) {
+ appHighlightStorage->resetLastRangeSearchTime();
+ document.eventLoop().queueTask(TaskSource::InternalAsyncTask, [weakDocument = makeWeakPtr(document)] {
+ auto document = makeRefPtr(weakDocument.get());
+ if (!document)
+ return;
+ if (auto* appHighlightStorage = document->appHighlightStorageIfExists())
+ appHighlightStorage->restoreUnrestoredAppHighlights();
+ });
+ }
+ });
+#endif
+
#if ENABLE(VIDEO)
forEachDocument([] (Document& document) {
document.updateTextTrackRepresentationImageIfNeeded();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes