-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[UnifiedPDF] Clean up the coordinate system code #24698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[UnifiedPDF] Clean up the coordinate system code #24698
Conversation
|
EWS run on previous version of this PR (hash f5e676d) Details
|
hortont424
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yayyyy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! Some minor comments
(LGTM)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smfr guessing this was not intentional
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, but there is something funky about the project settings for wgslfuzz.xcscheme, which always gets touched on my filesystem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh thanks, I will file a bug Monday to investigate that issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could pack a little tighter.
| enum class CoordinateSpace : uint16_t { | |
| enum class CoordinateSpace : uint8_t { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| T convertDown(CoordinateSpace sourceSpace, CoordinateSpace destinationSpace, T, std::optional<PDFDocumentLayout::PageIndex> = { }) const; | |
| T convertDown(CoordinateSpace sourceSpace, CoordinateSpace destinationSpace, T sourceValue, std::optional<PDFDocumentLayout::PageIndex> = { }) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can also add another assertion here, to ensure the conversion direction makes sense?
static_assert(enumToUnderlyingType(sourceSpace) < enumToUnderlyingType(destinationSpace), <some sensible message about moving up>);
static_assert(std::is_same<T, FloatPoint>::value || std::is_same<T, FloatRect>::value, "Coordinate conversion should use float types");There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried this but got static assertion expression is not an integral constant expression.
f5e676d to
51d7f3e
Compare
|
EWS run on previous version of this PR (hash 51d7f3e) Details
|
51d7f3e to
da75b60
Compare
|
EWS run on current version of this PR (hash da75b60) Details
|
https://bugs.webkit.org/show_bug.cgi?id=269657 rdar://123173348 Reviewed by Tim Horton. Replace the panoply of coordinate conversion functions with two template functions, capable of converting FloatPoints and FloatRects. These are `convertUp()` and `convertDown()`, where the former converts to enclosing coordinate systems, and the latter to inner coordinate systems. An enum describes the available coordinate systems. It was a purposeful choice to have convertUp() and convertDown() only do conversions within the Plugin; outside the Plugin boundary (e.g. to/from RootView), functions on PDFPluginBase can be used, albeit with the minor annoyance that conversions between integer and float types are necessary. Generally, staying in FloatPoint/FloatRect are preferred to converting using integer types Minor other cleanups. The only thing I can find that doesn't seem to use the correct conversions is painting the yellow Find highlight, which continues to give incorrect results. * Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDocumentLayout.h: * Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDocumentLayout.mm: (WebKit::PDFDocumentLayout::nearestPageIndexForDocumentPoint const): (WebKit::PDFDocumentLayout::layoutBoundsForPageAtIndex const): (WebKit::PDFDocumentLayout::scaledContentsSize const): (WebKit::PDFDocumentLayout::documentToPDFPage const): (WebKit::PDFDocumentLayout::pdfPageToDocument const): (WebKit::PDFDocumentLayout::documentPointToPDFPagePoint const): Deleted. (WebKit::PDFDocumentLayout::pdfPagePointToDocumentPoint const): Deleted. (WebKit::PDFDocumentLayout::pdfPageRectToDocumentRect const): Deleted. * Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h: * Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm: (WebKit::UnifiedPDFPlugin::setNeedsRepaintInDocumentRect): (WebKit::UnifiedPDFPlugin::paintHoveredAnnotationOnPage): (WebKit::UnifiedPDFPlugin::updateScrollingExtents): (WebKit::UnifiedPDFPlugin::pageIndexForDocumentPoint const): (WebKit::UnifiedPDFPlugin::indexForCurrentPageInView const): (WebKit::UnifiedPDFPlugin::annotationForRootViewPoint const): (WebKit::UnifiedPDFPlugin::convertUp const): (WebKit::UnifiedPDFPlugin::convertDown const): (WebKit::UnifiedPDFPlugin::pdfElementTypesForPluginPoint const): (WebKit::UnifiedPDFPlugin::handleMouseEvent): (WebKit::UnifiedPDFPlugin::documentRectForAnnotation const): (WebKit::UnifiedPDFPlugin::scrollToPDFDestination): (WebKit::UnifiedPDFPlugin::scrollToPointInPage): (WebKit::UnifiedPDFPlugin::scrollToPage): (WebKit::UnifiedPDFPlugin::beginTrackingSelection): (WebKit::UnifiedPDFPlugin::updateCurrentSelectionForContextMenuEventIfNeeded): (WebKit::computeMarqueeSelectionRect): (WebKit::UnifiedPDFPlugin::continueTrackingSelection): (WebKit::UnifiedPDFPlugin::existingSelectionContainsPoint const): (WebKit::UnifiedPDFPlugin::rectForSelectionInRootView const): (WebKit::UnifiedPDFPlugin::countFindMatches): (WebKit::UnifiedPDFPlugin::findString): (WebKit::UnifiedPDFPlugin::collectFindMatchRects): (WebKit::UnifiedPDFPlugin::rectsForTextMatchesInRect const): (WebKit::UnifiedPDFPlugin::textIndicatorForSelection): (WebKit::UnifiedPDFPlugin::performDictionaryLookupAtLocation): (WebKit::UnifiedPDFPlugin::selectionBoundsForFirstPageInDocumentSpace const): (WebKit::UnifiedPDFPlugin::showDefinitionForAttributedString): (WebKit::UnifiedPDFPlugin::lookupTextAtLocation): (WebKit::UnifiedPDFPlugin::pluginBoundsForAnnotation const): (WebKit::UnifiedPDFPlugin::convertFromRootViewToDocument const): Deleted. (WebKit::UnifiedPDFPlugin::convertFromPluginToDocument const): Deleted. (WebKit::UnifiedPDFPlugin::convertFromDocumentToPlugin const): Deleted. (WebKit::UnifiedPDFPlugin::convertFromPageToRootView const): Deleted. (WebKit::UnifiedPDFPlugin::convertFromDocumentToPage const): Deleted. (WebKit::UnifiedPDFPlugin::convertFromPageToDocument const): Deleted. (WebKit::UnifiedPDFPlugin::convertFromPageToContents const): Deleted. (WebKit::UnifiedPDFPlugin::convertFromDocumentToContents const): Deleted. (WebKit::UnifiedPDFPlugin::offsetContentsSpacePointByPageMargins const): Deleted. Canonical link: https://commits.webkit.org/274950@main
da75b60 to
625cdc0
Compare
|
Committed 274950@main (625cdc0): https://commits.webkit.org/274950@main Reviewed commits have been landed. Closing PR #24698 and removing active labels. |
625cdc0
da75b60
🧪 wpe-wk2