RESOLVED FIXED Bug 176577
SVG scrolling anchor should be reset if the fragmentIdentifier does not exist or is not provided
https://bugs.webkit.org/show_bug.cgi?id=176577
Summary SVG scrolling anchor should be reset if the fragmentIdentifier does not exist...
Said Abou-Hallawa
Reported 2017-09-07 18:42:12 PDT
If an SVG image is referenced multiple times and the URL of one of the referencing elements does not provide a fragmentIdentifier or provides a fragmentIdentifier but this fragmentIdentifier doesn't exist in the SVG, the scrolling anchor of the SVGImage should be reset. This should behave as if the image is displayed only once in the page and the URL of the SVGImage does not have a fragmentIdentifier.
Attachments
Patch (40.68 KB, patch)
2017-09-08 12:28 PDT, Said Abou-Hallawa
no flags
Archive of layout-test-results from ews102 for mac-elcapitan (1.32 MB, application/zip)
2017-09-08 13:41 PDT, Build Bot
no flags
Archive of layout-test-results from ews104 for mac-elcapitan-wk2 (1.45 MB, application/zip)
2017-09-08 13:44 PDT, Build Bot
no flags
Archive of layout-test-results from ews116 for mac-elcapitan (2.13 MB, application/zip)
2017-09-08 13:58 PDT, Build Bot
no flags
Archive of layout-test-results from ews121 for ios-simulator-wk2 (1.27 MB, application/zip)
2017-09-08 14:10 PDT, Build Bot
no flags
Patch (41.02 KB, patch)
2017-09-08 22:45 PDT, Said Abou-Hallawa
no flags
Patch (43.11 KB, patch)
2017-09-11 10:19 PDT, Said Abou-Hallawa
no flags
Patch (15.38 KB, patch)
2017-09-18 11:16 PDT, Said Abou-Hallawa
no flags
Patch (16.51 KB, patch)
2017-11-16 16:16 PST, Said Abou-Hallawa
no flags
Patch (16.51 KB, patch)
2017-11-16 17:19 PST, Said Abou-Hallawa
no flags
Patch (16.68 KB, patch)
2017-11-16 20:42 PST, Said Abou-Hallawa
no flags
Archive of layout-test-results from ews107 for mac-elcapitan-wk2 (2.61 MB, application/zip)
2017-11-16 21:56 PST, EWS Watchlist
no flags
Patch (16.68 KB, patch)
2017-11-17 08:10 PST, Said Abou-Hallawa
no flags
Archive of layout-test-results from ews107 for mac-elcapitan-wk2 (3.22 MB, application/zip)
2017-11-17 09:14 PST, EWS Watchlist
no flags
Said Abou-Hallawa
Comment 1 2017-09-08 12:28:23 PDT
Build Bot
Comment 2 2017-09-08 13:41:12 PDT
Comment on attachment 320288 [details] Patch Attachment 320288 [details] did not pass mac-ews (mac): Output: http://webkit-queues.webkit.org/results/4489937 New failing tests: fast/html/empty-fragment-id-goto-top.html
Build Bot
Comment 3 2017-09-08 13:41:13 PDT
Created attachment 320293 [details] Archive of layout-test-results from ews102 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews102 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Build Bot
Comment 4 2017-09-08 13:44:58 PDT
Comment on attachment 320288 [details] Patch Attachment 320288 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.webkit.org/results/4489941 New failing tests: fast/html/empty-fragment-id-goto-top.html
Build Bot
Comment 5 2017-09-08 13:44:59 PDT
Created attachment 320296 [details] Archive of layout-test-results from ews104 for mac-elcapitan-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews104 Port: mac-elcapitan-wk2 Platform: Mac OS X 10.11.6
Build Bot
Comment 6 2017-09-08 13:58:31 PDT
Comment on attachment 320288 [details] Patch Attachment 320288 [details] did not pass mac-debug-ews (mac): Output: http://webkit-queues.webkit.org/results/4489947 New failing tests: fast/html/empty-fragment-id-goto-top.html
Build Bot
Comment 7 2017-09-08 13:58:33 PDT
Created attachment 320298 [details] Archive of layout-test-results from ews116 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews116 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Build Bot
Comment 8 2017-09-08 14:10:18 PDT
Comment on attachment 320288 [details] Patch Attachment 320288 [details] did not pass ios-sim-ews (ios-simulator-wk2): Output: http://webkit-queues.webkit.org/results/4489963 New failing tests: fast/html/empty-fragment-id-goto-top.html
Build Bot
Comment 9 2017-09-08 14:10:20 PDT
Created attachment 320300 [details] Archive of layout-test-results from ews121 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews121 Port: ios-simulator-wk2 Platform: Mac OS X 10.12.5
Said Abou-Hallawa
Comment 10 2017-09-08 22:45:47 PDT
Darin Adler
Comment 11 2017-09-10 15:04:11 PDT
Comment on attachment 320288 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=320288&action=review > Source/WebCore/page/FrameView.cpp:2401 > - if (!url.hasFragmentIdentifier()) { > - frame().document()->setCSSTarget(nullptr); > + if (fragmentIdentifier.isEmpty()) { > + resetScrollAnchor(); > return false; > } These aren’t the same thing. - URL::hasFragmentIdentifier returns true for URLs that end in "#", and the fragment identifier is the empty string. - The new code treats that the same as URLs that have no "#" in them at all. I would expect this would change behavior. To express this distinction we need a value that means "lack of a fragment identifier". One approach would be to use the null string for lack of a fragment identifier, and the empty string for URLs that end in "#", an empty fragment identifier. Another programmer might choose to use std::optional<String> in a case like this.
Said Abou-Hallawa
Comment 12 2017-09-11 10:19:45 PDT
Radar WebKit Bug Importer
Comment 13 2017-09-11 11:07:09 PDT
Said Abou-Hallawa
Comment 14 2017-09-18 11:16:13 PDT
Simon Fraser (smfr)
Comment 15 2017-11-13 11:36:24 PST
Comment on attachment 321113 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=321113&action=review > Source/WebCore/page/FrameView.cpp:2517 > + document.updateStyleIfNeeded(); This is a new call. Is it necessary? > Source/WebCore/svg/SVGSVGElement.cpp:495 > + if (svgRootParent.m_scrollRootElement == this) > + svgRootParent.m_scrollRootElement = nullptr; Seems a bit weird to access m_scrollRootElement directly. Can this be hidden inside a member function? > Source/WebCore/svg/SVGSVGElement.cpp:663 > + m_scrollRootElement = &downcast<SVGSVGElement>(*viewportElement); Pretty sure that you can downcast pointers too: m_scrollRootElement = downcast<SVGSVGElement>(viewportElement); > Source/WebCore/svg/SVGSVGElement.h:164 > + SVGSVGElement* m_scrollRootElement { nullptr }; This goes against our desire to not have raw pointers. Please talk to rniwa about the best way to do something like this.
Said Abou-Hallawa
Comment 16 2017-11-16 16:16:40 PST
Said Abou-Hallawa
Comment 17 2017-11-16 16:26:45 PST
Comment on attachment 321113 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=321113&action=review >> Source/WebCore/page/FrameView.cpp:2517 >> + document.updateStyleIfNeeded(); > > This is a new call. Is it necessary? Yes it is necessary to force layout after reseting the SVGViewElement anchor attributes. >> Source/WebCore/svg/SVGSVGElement.cpp:495 >> + svgRootParent.m_scrollRootElement = nullptr; > > Seems a bit weird to access m_scrollRootElement directly. Can this be hidden inside a member function? I changed that code. Instead of storing the nearest root to the SVGViewElement anchor, I am storing the fragmentIdentifier. >> Source/WebCore/svg/SVGSVGElement.cpp:663 >> + m_scrollRootElement = &downcast<SVGSVGElement>(*viewportElement); > > Pretty sure that you can downcast pointers too: m_scrollRootElement = downcast<SVGSVGElement>(viewportElement); Done but in the new functions SVGSVGElement::findViewAnchor() and SVGSVGElement::findRootAnchor(). >> Source/WebCore/svg/SVGSVGElement.h:164 >> + SVGSVGElement* m_scrollRootElement { nullptr }; > > This goes against our desire to not have raw pointers. Please talk to rniwa about the best way to do something like this. Instead of storing the nearest root to the SVGViewElement anchor, I am storing the fragmentIdentifier. To get the nearest SVGSVGElement to the SVGViewElement anchor, I added the new functions SVGSVGElement::findViewAnchor() and SVGSVGElement::findRootAnchor().
Simon Fraser (smfr)
Comment 18 2017-11-16 16:31:17 PST
(In reply to Said Abou-Hallawa from comment #17) > Comment on attachment 321113 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=321113&action=review > > >> Source/WebCore/page/FrameView.cpp:2517 > >> + document.updateStyleIfNeeded(); > > > > This is a new call. Is it necessary? > > Yes it is necessary to force layout after reseting the SVGViewElement anchor > attributes. But won't document.setCSSTarget() trigger a later style update? Why does it have to synchronous here?
Said Abou-Hallawa
Comment 19 2017-11-16 17:18:58 PST
Comment on attachment 321113 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=321113&action=review >>>> Source/WebCore/page/FrameView.cpp:2517 >>>> + document.updateStyleIfNeeded(); >>> >>> This is a new call. Is it necessary? >> >> Yes it is necessary to force layout after reseting the SVGViewElement anchor attributes. > > But won't document.setCSSTarget() trigger a later style update? Why does it have to synchronous here? Because FrameView::resetScrollAnchor() is called FrameView::scrollToFragment() which can be called from SVGImage::drawForContainer() so it has to be synchronous in this case. But since this is only needed for SVG, I moved this call in the if (is<SVGDocument>(document)) statement.
Said Abou-Hallawa
Comment 20 2017-11-16 17:19:11 PST
Simon Fraser (smfr)
Comment 21 2017-11-16 17:26:23 PST
Comment on attachment 327134 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=327134&action=review > Source/WebCore/page/FrameView.cpp:2211 > + document.updateStyleIfNeeded(); Please add a comment saying why this eager style update is necessary. Ideally, you'd put it before the thing that needs it, not after something that may change style.
Said Abou-Hallawa
Comment 22 2017-11-16 20:42:01 PST
EWS Watchlist
Comment 23 2017-11-16 21:56:50 PST
Comment on attachment 327148 [details] Patch Attachment 327148 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.webkit.org/results/5269133 New failing tests: http/tests/appcache/resource-redirect-2.html
EWS Watchlist
Comment 24 2017-11-16 21:56:52 PST
Created attachment 327149 [details] Archive of layout-test-results from ews107 for mac-elcapitan-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews107 Port: mac-elcapitan-wk2 Platform: Mac OS X 10.11.6
Said Abou-Hallawa
Comment 25 2017-11-17 08:10:22 PST
EWS Watchlist
Comment 26 2017-11-17 09:14:29 PST
Comment on attachment 327172 [details] Patch Attachment 327172 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.webkit.org/results/5275264 New failing tests: http/tests/appcache/resource-redirect-2.html
EWS Watchlist
Comment 27 2017-11-17 09:14:30 PST
Created attachment 327182 [details] Archive of layout-test-results from ews107 for mac-elcapitan-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews107 Port: mac-elcapitan-wk2 Platform: Mac OS X 10.11.6
WebKit Commit Bot
Comment 28 2017-11-17 10:40:13 PST
Comment on attachment 327172 [details] Patch Clearing flags on attachment: 327172 Committed r224973: <https://trac.webkit.org/changeset/224973>
WebKit Commit Bot
Comment 29 2017-11-17 10:40:15 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.