Source/WebCore/ChangeLog

 12021-07-01 Megan Gardner <megan_gardner@apple.com>
 2
 3 Add logging for legacy AppHighlight decoding to aid in future debugging.
 4 https://bugs.webkit.org/show_bug.cgi?id=227591
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * Modules/highlight/AppHighlightRangeData.cpp:
 9 (WebCore::AppHighlightRangeData::decode):
 10 * platform/Logging.h:
 11
1122021-07-01 Amir Mark Jr <amir_mark@apple.com>
213
314 Unreviewed, reverting r279452.

Source/WebCore/Modules/highlight/AppHighlightRangeData.cpp

3131#include "Document.h"
3232#include "DocumentMarkerController.h"
3333#include "HTMLBodyElement.h"
 34#include "Logging.h"
3435#include "Node.h"
3536#include "RenderedDocumentMarker.h"
3637#include "SharedBuffer.h"

@@template<class Decoder> std::optional<AppHighlightRangeData> AppHighlightRangeDa
120121 if (!decoder.rewind(sizeof(highlightFileSignature)))
121122 return std::nullopt;
122123 version = 0;
 124 RELEASE_LOG(AppHighlights, "Decoded legacy (v0) highlight.");
123125 }
124126
125127 std::optional<String> identifier;

Source/WebCore/Modules/highlight/AppHighlightStorage.cpp

@@static std::optional<SimpleRange> findRangeByIdentifyingStartAndEndPositions(con
133133
134134static std::optional<SimpleRange> findRangeBySearchingText(const AppHighlightRangeData& range, Document& document)
135135{
 136 RELEASE_LOG(AppHighlights, "Attempting fallback text search for AppHighlightRangeData.");
136137 HashSet<String> identifiersInStartPath;
137138 for (auto& component : range.startContainer()) {
138139 if (!component.identifier.isEmpty())

@@void AppHighlightStorage::storeAppHighlight(Ref<StaticRange>&& range)
239240void AppHighlightStorage::restoreAndScrollToAppHighlight(Ref<SharedBuffer>&& buffer, ScrollToHighlight scroll)
240241{
241242 auto appHighlightRangeData = AppHighlightRangeData::create(buffer);
242  if (!appHighlightRangeData)
 243 if (!appHighlightRangeData) {
 244 RELEASE_LOG(AppHighlights, "AppHighlightRangeData failed to decode.");
243245 return;
 246 }
244247
245248 if (!attemptToRestoreHighlightAndScroll(appHighlightRangeData.value(), scroll)) {
246249 if (scroll == ScrollToHighlight::Yes)

@@bool AppHighlightStorage::attemptToRestoreHighlightAndScroll(AppHighlightRangeDa
261264
262265 auto range = findRange(highlight, *strongDocument);
263266
264  if (!range)
 267 if (!range) {
 268 RELEASE_LOG(AppHighlights, "Failed to find range for AppHighlightRangeData.");
265269 return false;
 270 }
266271
267272 strongDocument->appHighlightRegister().addAppHighlight(StaticRange::create(*range));
268273

Source/WebCore/platform/Logging.h

@@namespace WebCore {
3939#define WEBCORE_LOG_CHANNELS(M) \
4040 M(Accessibility) \
4141 M(Animations) \
 42 M(AppHighlights) \
4243 M(ApplePay) \
4344 M(Archives) \
4445 M(BackForwardCache) \