Changeset 244642 in webkit
- Timestamp:
- Apr 25, 2019, 2:55:38 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r244641 r244642 1 2019-04-25 Antti Koivisto <antti@apple.com> 2 3 Visited link hash should be computed only once 4 https://bugs.webkit.org/show_bug.cgi?id=197229 5 <rdar://problem/48438924> 6 7 Reviewed by Alex Christensen. 8 9 * fast/history/visited-href-mutation-expected.html: Added. 10 * fast/history/visited-href-mutation.html: Added. 11 1 12 2019-04-25 Philippe Normand <pnormand@igalia.com> 2 13 -
trunk/Source/WebCore/ChangeLog
r244641 r244642 1 2019-04-25 Antti Koivisto <antti@apple.com> 2 3 Visited link hash should be computed only once 4 https://bugs.webkit.org/show_bug.cgi?id=197229 5 <rdar://problem/48438924> 6 7 Reviewed by Alex Christensen. 8 9 Test: fast/history/visited-href-mutation.html 10 11 Visited link style is now based on the first target URL of the link element. Further href mutations don't affect styling. 12 13 * dom/Document.cpp: 14 (WebCore::Document::updateBaseURL): 15 * dom/VisitedLinkState.cpp: 16 (WebCore::linkAttribute): 17 (WebCore::linkHashForElement): 18 19 Visited link support is now limited to HTML and SVG <a> elements. 20 21 (WebCore::VisitedLinkState::invalidateStyleForLink): 22 (WebCore::VisitedLinkState::determineLinkStateSlowCase): 23 * html/HTMLAnchorElement.cpp: 24 (WebCore::HTMLAnchorElement::HTMLAnchorElement): 25 (WebCore::HTMLAnchorElement::parseAttribute): 26 * html/HTMLAnchorElement.h: 27 (WebCore::HTMLAnchorElement::visitedLinkHash const): 28 (WebCore::HTMLAnchorElement::invalidateCachedVisitedLinkHash): Deleted. 29 * svg/SVGAElement.cpp: 30 (WebCore::SVGAElement::visitedLinkHash const): 31 * svg/SVGAElement.h: 32 1 33 2019-04-25 Philippe Normand <pnormand@igalia.com> 2 34 -
trunk/Source/WebCore/dom/Document.cpp
r244573 r244642 3185 3185 if (!m_baseURL.isValid()) 3186 3186 m_baseURL = URL(); 3187 3188 if (!equalIgnoringFragmentIdentifier(oldBaseURL, m_baseURL)) {3189 // Base URL change changes any relative visited links.3190 // FIXME: There are other URLs in the tree that would need to be re-evaluated on dynamic base URL change. Style should be invalidated too.3191 for (auto& anchor : descendantsOfType<HTMLAnchorElement>(*this))3192 anchor.invalidateCachedVisitedLinkHash();3193 }3194 3187 } 3195 3188 -
trunk/Source/WebCore/dom/VisitedLinkState.cpp
r234683 r244642 34 34 #include "HTMLAnchorElement.h" 35 35 #include "Page.h" 36 #include "SVGAElement.h" 36 37 #include "SVGNames.h" 37 38 #include "VisitedLinkStore.h" … … 45 46 { 46 47 if (!element.isLink()) 47 return 0;48 return nullptr; 48 49 if (element.isHTMLElement()) 49 50 return &element.attributeWithoutSynchronization(HTMLNames::hrefAttr); 50 51 if (element.isSVGElement()) 51 52 return &element.getAttribute(SVGNames::hrefAttr, XLinkNames::hrefAttr); 52 return 0;53 return nullptr; 53 54 } 54 55 … … 68 69 } 69 70 70 inline static SharedStringHash linkHashForElement(Document& document,const Element& element)71 inline static Optional<SharedStringHash> linkHashForElement(const Element& element) 71 72 { 72 73 if (is<HTMLAnchorElement>(element)) 73 74 return downcast<HTMLAnchorElement>(element).visitedLinkHash(); 74 if ( const AtomicString* attribute = linkAttribute(element))75 return computeVisitedLinkHash(document.baseURL(), *attribute);76 return 0;75 if (is<SVGAElement>(element)) 76 return downcast<SVGAElement>(element).visitedLinkHash(); 77 return WTF::nullopt; 77 78 } 78 79 … … 82 83 return; 83 84 for (auto& element : descendantsOfType<Element>(m_document)) { 84 if ( linkHashForElement(m_document,element) == linkHash)85 if (element.isLink() && linkHashForElement(element) == linkHash) 85 86 element.invalidateStyleForSubtree(); 86 87 } … … 95 96 return InsideLink::NotInside; 96 97 97 // An empty href refers to the document itself which is always visited. It is useful to check this explicitly so 98 auto hashIfFound = linkHashForElement(element); 99 100 if (!hashIfFound) 101 return attribute->isEmpty() ? InsideLink::InsideVisited : InsideLink::InsideUnvisited; 102 103 auto hash = *hashIfFound; 104 105 // An empty href (hash==0) refers to the document itself which is always visited. It is useful to check this explicitly so 98 106 // that visited links can be tested in platform independent manner, without explicit support in the test harness. 99 if ( attribute->isEmpty())107 if (!hash) 100 108 return InsideLink::InsideVisited; 101 102 SharedStringHash hash;103 if (is<HTMLAnchorElement>(element))104 hash = downcast<HTMLAnchorElement>(element).visitedLinkHash();105 else106 hash = computeVisitedLinkHash(element.document().baseURL(), *attribute);107 108 if (!hash)109 return InsideLink::InsideUnvisited;110 109 111 110 Frame* frame = element.document().frame(); -
trunk/Source/WebCore/html/HTMLAnchorElement.cpp
r244475 r244642 69 69 , m_hasRootEditableElementForSelectionOnMouseDown(false) 70 70 , m_wasShiftKeyDownOnMouseDown(false) 71 , m_cachedVisitedLinkHash(0)72 71 { 73 72 } … … 249 248 } 250 249 } 251 invalidateCachedVisitedLinkHash();252 250 } else if (name == nameAttr || name == titleAttr) { 253 251 // Do nothing. -
trunk/Source/WebCore/html/HTMLAnchorElement.h
r242776 r244642 67 67 68 68 SharedStringHash visitedLinkHash() const; 69 void invalidateCachedVisitedLinkHash() { m_cachedVisitedLinkHash = 0; }70 69 71 70 WEBCORE_EXPORT DOMTokenList& relList() const; … … 116 115 bool m_wasShiftKeyDownOnMouseDown; 117 116 OptionSet<Relation> m_linkRelations; 118 mutable SharedStringHash m_cachedVisitedLinkHash; 117 118 // This is computed only once and must not be affected by subsequent URL changes. 119 mutable Optional<SharedStringHash> m_storedVisitedLinkHash; 119 120 120 121 mutable std::unique_ptr<DOMTokenList> m_relList; … … 123 124 inline SharedStringHash HTMLAnchorElement::visitedLinkHash() const 124 125 { 125 if (!m_cachedVisitedLinkHash) 126 m_cachedVisitedLinkHash = computeVisitedLinkHash(document().baseURL(), attributeWithoutSynchronization(HTMLNames::hrefAttr)); 127 return m_cachedVisitedLinkHash; 126 ASSERT(isLink()); 127 if (!m_storedVisitedLinkHash) 128 m_storedVisitedLinkHash = computeVisitedLinkHash(document().baseURL(), attributeWithoutSynchronization(HTMLNames::hrefAttr)); 129 return *m_storedVisitedLinkHash; 128 130 } 129 131 -
trunk/Source/WebCore/svg/SVGAElement.cpp
r243333 r244642 218 218 } 219 219 220 SharedStringHash SVGAElement::visitedLinkHash() const 221 { 222 ASSERT(isLink()); 223 if (!m_storedVisitedLinkHash) 224 m_storedVisitedLinkHash = computeVisitedLinkHash(document().baseURL(), getAttribute(SVGNames::hrefAttr, XLinkNames::hrefAttr)); 225 return *m_storedVisitedLinkHash; 226 } 227 220 228 } // namespace WebCore -
trunk/Source/WebCore/svg/SVGAElement.h
r243830 r244642 26 26 #include "SVGGraphicsElement.h" 27 27 #include "SVGURIReference.h" 28 #include "SharedStringHash.h" 28 29 29 30 namespace WebCore { … … 36 37 String target() const final { return m_target->currentValue(); } 37 38 Ref<SVGAnimatedString>& targetAnimated() { return m_target; } 39 40 SharedStringHash visitedLinkHash() const; 38 41 39 42 private: … … 64 67 PropertyRegistry m_propertyRegistry { *this }; 65 68 Ref<SVGAnimatedString> m_target { SVGAnimatedString::create(this) }; 69 70 // This is computed only once and must not be affected by subsequent URL changes. 71 mutable Optional<SharedStringHash> m_storedVisitedLinkHash; 66 72 }; 67 73
Note:
See TracChangeset
for help on using the changeset viewer.