Changeset 244983 in webkit
- Timestamp:
- May 6, 2019 3:33:52 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r244977 r244983 1 2019-05-06 Andres Gonzalez <andresg_22@apple.com> 2 3 Hitpoint for link which spans two lines in web content is incorrect 4 https://bugs.webkit.org/show_bug.cgi?id=197511 5 <rdar://problem/49971483> 6 7 Reviewed by Chris Fleizach. 8 9 - Added LayoutTest. 10 11 * accessibility/ios-simulator/links-activation-expected.txt: Added. 12 * accessibility/ios-simulator/links-activation.html: Added. 13 * accessibility/links-activation-expected.txt: Added. 14 * accessibility/links-activation.html: Added. 15 1 16 2019-05-06 Youenn Fablet <youenn@apple.com> 2 17 -
trunk/Source/WebCore/ChangeLog
r244980 r244983 1 2019-05-06 Andres Gonzalez <andresg_22@apple.com> 2 3 Hitpoint for link which spans two lines in web content is incorrect 4 https://bugs.webkit.org/show_bug.cgi?id=197511 5 <rdar://problem/49971483> 6 7 Reviewed by Chris Fleizach. 8 9 - Special case for links to return first char location as clickPoint instead of middle point of bounding rect. 10 - Modified iOS ActivationPoint to use clickPoint. This way all code paths go through the same function. 11 - Made boundsForRects to return content coordinates in all platforms. Adjusted all callers, directly or indirectly, appropriately. 12 13 Tests: accessibility/ios-simulator/links-activation.html 14 accessibility/links-activation.html 15 16 * accessibility/AccessibilityRenderObject.cpp: 17 (WebCore::AccessibilityRenderObject::clickPoint): 18 (WebCore::AccessibilityRenderObject::boundsForRects): 19 (WebCore::AccessibilityRenderObject::boundsForRects const): Deleted. 20 * accessibility/AccessibilityRenderObject.h: 21 * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm: 22 (-[WebAccessibilityObjectWrapper accessibilityActivationPoint]): 23 * accessibility/mac/WebAccessibilityObjectWrapperMac.mm: 24 (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:forParameter:]): 25 1 26 2019-05-06 Jer Noble <jer.noble@apple.com> 2 27 -
trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp
r244582 r244983 900 900 } 901 901 902 IntPoint AccessibilityRenderObject::linkClickPoint() 903 { 904 ASSERT(isLink()); 905 /* A link bounding rect can contain points that are not part of the link. 906 For instance, a link that starts at the end of a line and finishes at the 907 beginning of the next line will have a bounding rect that includes the 908 entire two lines. In such a case, the middle point of the bounding rect 909 may not belong to the link element and thus may not activate the link. 910 Hence, return the middle point of the first character in the link if exists. 911 */ 912 if (RefPtr<Range> range = elementRange()) { 913 VisiblePosition start = range->startPosition(); 914 VisiblePosition end = nextVisiblePosition(start); 915 if (start.isNull() || !range->contains(end)) 916 return AccessibilityObject::clickPoint(); 917 918 RefPtr<Range> charRange = makeRange(start, end); 919 IntRect rect = boundsForRange(charRange); 920 return { rect.x() + rect.width() / 2, rect.y() + rect.height() / 2 }; 921 } 922 return AccessibilityObject::clickPoint(); 923 } 924 902 925 IntPoint AccessibilityRenderObject::clickPoint() 903 926 { 904 927 // Headings are usually much wider than their textual content. If the mid point is used, often it can be wrong. 905 if (isHeading() && children().size() == 1) 906 return children()[0]->clickPoint(); 928 AccessibilityChildrenVector children = this->children(); 929 if (isHeading() && children.size() == 1) 930 return children[0]->clickPoint(); 931 932 if (isLink()) 933 return linkClickPoint(); 907 934 908 935 // use the default position unless this is an editable web area, in which case we use the selection bounds. … … 913 940 VisiblePositionRange range = VisiblePositionRange(visSelection.visibleStart(), visSelection.visibleEnd()); 914 941 IntRect bounds = boundsForVisiblePositionRange(range); 915 #if PLATFORM(COCOA) 916 bounds.setLocation(m_renderer->view().frameView().screenToContents(bounds.location())); 917 #endif 918 return IntPoint(bounds.x() + (bounds.width() / 2), bounds.y() - (bounds.height() / 2)); 942 return { bounds.x() + (bounds.width() / 2), bounds.y() + (bounds.height() / 2) }; 919 943 } 920 944 … … 2043 2067 } 2044 2068 2045 IntRect AccessibilityRenderObject::boundsForRects(LayoutRect & rect1, LayoutRect& rect2, RefPtr<Range> dataRange) const2069 IntRect AccessibilityRenderObject::boundsForRects(LayoutRect const& rect1, LayoutRect const& rect2, RefPtr<Range> const& dataRange) 2046 2070 { 2047 2071 LayoutRect ourRect = rect1; … … 2055 2079 ourRect = boundingBox; 2056 2080 } 2057 2058 #if PLATFORM(MAC) 2059 return m_renderer->view().frameView().contentsToScreen(snappedIntRect(ourRect)); 2060 #else 2081 2061 2082 return snappedIntRect(ourRect); 2062 #endif2063 2083 } 2064 2084 -
trunk/Source/WebCore/accessibility/AccessibilityRenderObject.h
r244061 r244983 169 169 IntRect boundsForVisiblePositionRange(const VisiblePositionRange&) const override; 170 170 IntRect boundsForRange(const RefPtr<Range>) const override; 171 IntRect boundsForRects(LayoutRect&, LayoutRect&, RefPtr<Range>) const;172 171 void setSelectedVisiblePositionRange(const VisiblePositionRange&) const override; 173 172 bool isVisiblePositionRangeInDifferentDocument(const VisiblePositionRange&) const; … … 293 292 RenderObject* targetElementForActiveDescendant(const QualifiedName&, AccessibilityObject*) const; 294 293 bool canHavePlainText() const; 294 // Special handling of click point for links. 295 IntPoint linkClickPoint(); 296 // Rects utilities. 297 static IntRect boundsForRects(LayoutRect const&, LayoutRect const&, RefPtr<Range> const&); 295 298 }; 296 299 -
trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm
r244691 r244983 1600 1600 if (![self _prepareAccessibilityCall]) 1601 1601 return CGPointZero; 1602 1603 auto rect = FloatRect(snappedIntRect(m_object->boundingBoxRect())); 1604 CGRect cgRect = [self convertRectToSpace:rect space:AccessibilityConversionSpace::Screen]; 1605 return CGPointMake(CGRectGetMidX(cgRect), CGRectGetMidY(cgRect)); 1602 1603 IntPoint point = m_object->clickPoint(); 1604 return [self _accessibilityConvertPointToViewSpace:point]; 1606 1605 } 1607 1606 -
trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm
r244691 r244983 4260 4260 if ([attribute isEqualToString:@"AXBoundsForTextMarkerRange"]) { 4261 4261 RefPtr<Range> range = [self rangeForTextMarkerRange:textMarkerRange]; 4262 NSRect rect = m_object->boundsForRange(range); 4262 auto bounds = FloatRect(m_object->boundsForRange(range)); 4263 NSRect rect = [self convertRectToSpace:bounds space:AccessibilityConversionSpace::Screen]; 4263 4264 return [NSValue valueWithRect:rect]; 4264 4265 } … … 4270 4271 return nil; 4271 4272 RefPtr<Range> range = cache->rangeForUnorderedCharacterOffsets(start, end); 4272 NSRect rect = m_object->boundsForRange(range); 4273 auto bounds = FloatRect(m_object->boundsForRange(range)); 4274 NSRect rect = [self convertRectToSpace:bounds space:AccessibilityConversionSpace::Screen]; 4273 4275 return [NSValue valueWithRect:rect]; 4274 4276 } … … 4505 4507 return nil; 4506 4508 PlainTextRange plainTextRange = PlainTextRange(range.location, range.length); 4507 NSRect rect = m_object->doAXBoundsForRangeUsingCharacterOffset(plainTextRange); 4509 auto bounds = FloatRect(m_object->doAXBoundsForRangeUsingCharacterOffset(plainTextRange)); 4510 NSRect rect = [self convertRectToSpace:bounds space:AccessibilityConversionSpace::Screen]; 4508 4511 return [NSValue valueWithRect:rect]; 4509 4512 }
Note: See TracChangeset
for help on using the changeset viewer.