← All reports

findStringMatches is only sent to the main frame's process.

Component: WebKit Site Isolation | b2c0cb3

Source/WebKit/UIProcess/WebPageProxy.cpp

+ void didFindStringMatches(Vector<std::pair<FrameIdentifier, Vector<Vector<IntRect>>>>&& matches, std::optional<FindSelectionInFrame> selectionInFrame)
+ {
+ uint32_t indexInProcess = 0;
+ for (auto& [frameID, frameMatches] : matches) {
+ auto matchCount = frameMatches.size();
+ m_frameMatches.set(frameID, FrameMatches { WTF::move(frameMatches), indexInProcess });
+ indexInProcess += matchCount;
+ }
+ if (selectionInFrame)
+ m_selectionIndices.set(selectionInFrame->frame, selectionInFrame->indexInFrame);
+ }
...
+const WebPageProxy::FindMatchLocation* WebPageProxy::findMatchLocation(int32_t matchIndex) const
+{
+ if (matchIndex < 0 || static_cast<size_t>(matchIndex) >= m_findMatchLocations.size())
+ return nullptr;
+ return &m_findMatchLocations[matchIndex];
+}

Site isolation 환경에서 main frame의 process는 cross-origin iframe을 remote-frame proxy로만 인식합니다. 그래서 페이지 전체를 대상으로 하는 find 동작은 신뢰할 수 있는 UIProcess(WebPageProxy)가 조율해야 합니다. 한편 select, indicate, snapshot, replace 같은 후속 동작은 정수 index로 match를 지정합니다. 이제 UIProcess는 이 index를 (frame, process-local index) 쌍으로 변환해야 합니다. 문제는 이 쌍이 신뢰할 수 없는 WebContent process가 보고한 데이터로 구성된다는 점입니다.

WebPageProxy::findStringMatches는 이제 모든 WebContent process로 요청을 분산하도록 변경되었습니다. 각 process는 frame별로 묶은 match 목록을 반환합니다. 여기에 selection이 위치한 frame과 그 frame 안에서의 selection index(FindSelectionInFrame)가 함께 전달됩니다. UIProcess는 이 결과를 frame tree 순서대로 병합하고, maxMatchCount로 상한을 적용합니다. 이후 global index를 (frameID, local index)로 매핑하는 table을 유지하게 됩니다. selectFindMatch, indicateFindMatch, getImageForFindMatch, replaceMatches는 이 table을 기준으로 routing을 수행합니다. 또한 모든 결과가 도착한 뒤 find UI를 갱신하는 UpdateFindUIAfterFindingAllMatches IPC가 새로 추가되었습니다.

per-WCP reply { [(frameID, rects)], selectionInFrame{frameID, idx} }
  └─► walk UI frame tree in order ─► cap at maxMatchCount
  └─► m_findMatchLocations: globalIdx -> (frameID, indexInProcess)
follow-up: globalIdx ─► bounds-checked lookup ─► frameID
  ─► process resolved from UI frame tree at send time ─► send indexInProcess

기존에는 site isolation 환경에서 find-in-page가 cross-origin iframe 내부의 match를 찾지 못했습니다. 이제 UIProcess는 신뢰할 수 없는 WebContent process가 전달한 frame ID와 index를 바탕으로 process 간 routing 상태를 구성합니다. 다만 범위를 벗어난 selection index와 global index에는 이미 bounds check가 적용되어 있습니다(firstIndexAfterSelection, findMatchLocation).