OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008, 2009, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009, 2011 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 int level = 0; | 346 int level = 0; |
347 for (Node* elementNode = node(); elementNode; elementNode = elementNode->par
entNode()) { | 347 for (Node* elementNode = node(); elementNode; elementNode = elementNode->par
entNode()) { |
348 if (elementNode->hasTagName(blockquoteTag)) | 348 if (elementNode->hasTagName(blockquoteTag)) |
349 ++level; | 349 ++level; |
350 } | 350 } |
351 | 351 |
352 return level; | 352 return level; |
353 } | 353 } |
354 | 354 |
355 // Lacking concrete evidence of orientation, horizontal means width > height. ve
rtical is height > width; | 355 // Lacking concrete evidence of orientation, horizontal means width > height. ve
rtical is height > width; |
356 AccessibilityOrientation AccessibilityObject::orientation() const | 356 AccessibilityOrientation AccessibilityObject::orientation() |
357 { | 357 { |
358 LayoutRect bounds = elementRect(); | 358 LayoutRect bounds = elementRect(); |
359 if (bounds.size().width() > bounds.size().height()) | 359 if (bounds.size().width() > bounds.size().height()) |
360 return AccessibilityOrientationHorizontal; | 360 return AccessibilityOrientationHorizontal; |
361 if (bounds.size().height() > bounds.size().width()) | 361 if (bounds.size().height() > bounds.size().width()) |
362 return AccessibilityOrientationVertical; | 362 return AccessibilityOrientationVertical; |
363 | 363 |
364 // A tie goes to horizontal. | 364 // A tie goes to horizontal. |
365 return AccessibilityOrientationHorizontal; | 365 return AccessibilityOrientationHorizontal; |
366 } | 366 } |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 return true; | 563 return true; |
564 | 564 |
565 for (AccessibilityObject* axParent = parentObject(); axParent; axParent = ax
Parent->parentObject()) { | 565 for (AccessibilityObject* axParent = parentObject(); axParent; axParent = ax
Parent->parentObject()) { |
566 if (axParent->supportsARIALiveRegion()) | 566 if (axParent->supportsARIALiveRegion()) |
567 return true; | 567 return true; |
568 } | 568 } |
569 | 569 |
570 return false; | 570 return false; |
571 } | 571 } |
572 | 572 |
| 573 void AccessibilityObject::markCachedElementRectDirty() |
| 574 { |
| 575 AccessibilityChildrenVector axChildren = children(); |
| 576 for (unsigned i = 0; i < axChildren.size(); ++i) { |
| 577 axChildren[i].get()->markCachedElementRectDirty(); |
| 578 } |
| 579 } |
| 580 |
573 IntPoint AccessibilityObject::clickPoint() | 581 IntPoint AccessibilityObject::clickPoint() |
574 { | 582 { |
575 LayoutRect rect = elementRect(); | 583 LayoutRect rect = elementRect(); |
576 return roundedIntPoint(LayoutPoint(rect.x() + rect.width() / 2, rect.y() + r
ect.height() / 2)); | 584 return roundedIntPoint(LayoutPoint(rect.x() + rect.width() / 2, rect.y() + r
ect.height() / 2)); |
577 } | 585 } |
578 | 586 |
579 IntRect AccessibilityObject::boundingBoxForQuads(RenderObject* obj, const Vector
<FloatQuad>& quads) | 587 IntRect AccessibilityObject::boundingBoxForQuads(RenderObject* obj, const Vector
<FloatQuad>& quads) |
580 { | 588 { |
581 ASSERT(obj); | 589 ASSERT(obj); |
582 if (!obj) | 590 if (!obj) |
583 return IntRect(); | 591 return IntRect(); |
584 | 592 |
585 size_t count = quads.size(); | 593 size_t count = quads.size(); |
586 if (!count) | 594 if (!count) |
587 return IntRect(); | 595 return IntRect(); |
588 | 596 |
589 IntRect result; | 597 IntRect result; |
590 for (size_t i = 0; i < count; ++i) { | 598 for (size_t i = 0; i < count; ++i) { |
591 IntRect r = quads[i].enclosingBoundingBox(); | 599 IntRect r = quads[i].enclosingBoundingBox(); |
592 if (!r.isEmpty()) { | 600 if (!r.isEmpty()) { |
593 if (obj->style()->hasAppearance()) | 601 if (obj->style()->hasAppearance()) |
594 obj->theme()->adjustRepaintRect(obj, r); | 602 obj->theme()->adjustRepaintRect(obj, r); |
595 result.unite(r); | 603 result.unite(r); |
596 } | 604 } |
597 } | 605 } |
598 return result; | 606 return result; |
599 } | 607 } |
600 | 608 |
601 AccessibilityObject* AccessibilityObject::elementAccessibilityHitTest(const IntP
oint& point) const | 609 AccessibilityObject* AccessibilityObject::elementAccessibilityHitTest(const IntP
oint& point) |
602 { | 610 { |
603 // Send the hit test back into the sub-frame if necessary. | 611 // Send the hit test back into the sub-frame if necessary. |
604 if (isAttachment()) { | 612 if (isAttachment()) { |
605 Widget* widget = widgetForAttachmentView(); | 613 Widget* widget = widgetForAttachmentView(); |
606 // Normalize the point for the widget's bounds. | 614 // Normalize the point for the widget's bounds. |
607 if (widget && widget->isFrameView()) | 615 if (widget && widget->isFrameView()) |
608 return axObjectCache()->getOrCreate(widget)->accessibilityHitTest(In
tPoint(point - widget->frameRect().location())); | 616 return axObjectCache()->getOrCreate(widget)->accessibilityHitTest(In
tPoint(point - widget->frameRect().location())); |
609 } | 617 } |
610 | 618 |
611 // Check if there are any mock elements that need to be handled. | 619 // Check if there are any mock elements that need to be handled. |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
778 if (!actionElem) | 786 if (!actionElem) |
779 return false; | 787 return false; |
780 if (Frame* f = actionElem->document()->frame()) | 788 if (Frame* f = actionElem->document()->frame()) |
781 f->loader()->resetMultipleFormSubmissionProtection(); | 789 f->loader()->resetMultipleFormSubmissionProtection(); |
782 | 790 |
783 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); | 791 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); |
784 actionElem->accessKeyAction(true); | 792 actionElem->accessKeyAction(true); |
785 return true; | 793 return true; |
786 } | 794 } |
787 | 795 |
788 void AccessibilityObject::scrollToMakeVisible() const | 796 void AccessibilityObject::scrollToMakeVisible() |
789 { | 797 { |
790 IntRect objectRect = pixelSnappedIntRect(boundingBoxRect()); | 798 IntRect objectRect = pixelSnappedIntRect(elementRect()); |
791 objectRect.setLocation(IntPoint()); | 799 objectRect.setLocation(IntPoint()); |
792 scrollToMakeVisibleWithSubFocus(objectRect); | 800 scrollToMakeVisibleWithSubFocus(objectRect); |
793 } | 801 } |
794 | 802 |
795 // This is a 1-dimensional scroll offset helper function that's applied | 803 // This is a 1-dimensional scroll offset helper function that's applied |
796 // separately in the horizontal and vertical directions, because the | 804 // separately in the horizontal and vertical directions, because the |
797 // logic is the same. The goal is to compute the best scroll offset | 805 // logic is the same. The goal is to compute the best scroll offset |
798 // in order to make an object visible within a viewport. | 806 // in order to make an object visible within a viewport. |
799 // | 807 // |
800 // In case the whole object cannot fit, you can specify a | 808 // In case the whole object cannot fit, you can specify a |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 // Scroll right if we're too far to the left. | 865 // Scroll right if we're too far to the left. |
858 if (objectMin - currentScrollOffset < viewportMin) | 866 if (objectMin - currentScrollOffset < viewportMin) |
859 return objectMin - viewportMin; | 867 return objectMin - viewportMin; |
860 | 868 |
861 ASSERT_NOT_REACHED(); | 869 ASSERT_NOT_REACHED(); |
862 | 870 |
863 // This shouldn't happen. | 871 // This shouldn't happen. |
864 return currentScrollOffset; | 872 return currentScrollOffset; |
865 } | 873 } |
866 | 874 |
867 void AccessibilityObject::scrollToMakeVisibleWithSubFocus(const IntRect& subfocu
s) const | 875 void AccessibilityObject::scrollToMakeVisibleWithSubFocus(const IntRect& subfocu
s) |
868 { | 876 { |
869 // Search up the parent chain until we find the first one that's scrollable. | 877 // Search up the parent chain until we find the first one that's scrollable. |
870 AccessibilityObject* scrollParent = parentObject(); | 878 AccessibilityObject* scrollParent = parentObject(); |
871 ScrollableArea* scrollableArea; | 879 ScrollableArea* scrollableArea; |
872 for (scrollableArea = 0; | 880 for (scrollableArea = 0; |
873 scrollParent && !(scrollableArea = scrollParent->getScrollableAreaIfScr
ollable()); | 881 scrollParent && !(scrollableArea = scrollParent->getScrollableAreaIfScr
ollable()); |
874 scrollParent = scrollParent->parentObject()) { } | 882 scrollParent = scrollParent->parentObject()) { } |
875 if (!scrollableArea) | 883 if (!scrollableArea) |
876 return; | 884 return; |
877 | 885 |
878 LayoutRect objectRect = boundingBoxRect(); | 886 LayoutRect objectRect = elementRect(); |
879 IntPoint scrollPosition = scrollableArea->scrollPosition(); | 887 IntPoint scrollPosition = scrollableArea->scrollPosition(); |
880 IntRect scrollVisibleRect = scrollableArea->visibleContentRect(); | 888 IntRect scrollVisibleRect = scrollableArea->visibleContentRect(); |
881 | 889 |
882 int desiredX = computeBestScrollOffset( | 890 int desiredX = computeBestScrollOffset( |
883 scrollPosition.x(), | 891 scrollPosition.x(), |
884 objectRect.x() + subfocus.x(), objectRect.x() + subfocus.maxX(), | 892 objectRect.x() + subfocus.x(), objectRect.x() + subfocus.maxX(), |
885 objectRect.x(), objectRect.maxX(), | 893 objectRect.x(), objectRect.maxX(), |
886 0, scrollVisibleRect.width()); | 894 0, scrollVisibleRect.width()); |
887 int desiredY = computeBestScrollOffset( | 895 int desiredY = computeBestScrollOffset( |
888 scrollPosition.y(), | 896 scrollPosition.y(), |
889 objectRect.y() + subfocus.y(), objectRect.y() + subfocus.maxY(), | 897 objectRect.y() + subfocus.y(), objectRect.y() + subfocus.maxY(), |
890 objectRect.y(), objectRect.maxY(), | 898 objectRect.y(), objectRect.maxY(), |
891 0, scrollVisibleRect.height()); | 899 0, scrollVisibleRect.height()); |
892 | 900 |
893 scrollParent->scrollTo(IntPoint(desiredX, desiredY)); | 901 scrollParent->scrollTo(IntPoint(desiredX, desiredY)); |
894 | 902 |
895 // Recursively make sure the scroll parent itself is visible. | 903 // Recursively make sure the scroll parent itself is visible. |
896 if (scrollParent->parentObject()) | 904 if (scrollParent->parentObject()) |
897 scrollParent->scrollToMakeVisible(); | 905 scrollParent->scrollToMakeVisible(); |
898 } | 906 } |
899 | 907 |
900 void AccessibilityObject::scrollToGlobalPoint(const IntPoint& globalPoint) const | 908 void AccessibilityObject::scrollToGlobalPoint(const IntPoint& globalPoint) |
901 { | 909 { |
902 // Search up the parent chain and create a vector of all scrollable parent o
bjects | 910 // Search up the parent chain and create a vector of all scrollable parent o
bjects |
903 // and ending with this object itself. | 911 // and ending with this object itself. |
904 Vector<const AccessibilityObject*> objects; | 912 Vector<AccessibilityObject*> objects; |
905 AccessibilityObject* parentObject; | 913 AccessibilityObject* parentObject; |
906 for (parentObject = this->parentObject(); parentObject; parentObject = paren
tObject->parentObject()) { | 914 for (parentObject = this->parentObject(); parentObject; parentObject = paren
tObject->parentObject()) { |
907 if (parentObject->getScrollableAreaIfScrollable()) | 915 if (parentObject->getScrollableAreaIfScrollable()) |
908 objects.prepend(parentObject); | 916 objects.prepend(parentObject); |
909 } | 917 } |
910 objects.append(this); | 918 objects.append(this); |
911 | 919 |
912 // Start with the outermost scrollable (the main window) and try to scroll t
he | 920 // Start with the outermost scrollable (the main window) and try to scroll t
he |
913 // next innermost object to the given point. | 921 // next innermost object to the given point. |
914 int offsetX = 0, offsetY = 0; | 922 int offsetX = 0, offsetY = 0; |
915 IntPoint point = globalPoint; | 923 IntPoint point = globalPoint; |
916 size_t levels = objects.size() - 1; | 924 size_t levels = objects.size() - 1; |
917 for (size_t i = 0; i < levels; i++) { | 925 for (size_t i = 0; i < levels; i++) { |
918 const AccessibilityObject* outer = objects[i]; | 926 AccessibilityObject* outer = objects[i]; |
919 const AccessibilityObject* inner = objects[i + 1]; | 927 AccessibilityObject* inner = objects[i + 1]; |
920 | 928 |
921 ScrollableArea* scrollableArea = outer->getScrollableAreaIfScrollable(); | 929 ScrollableArea* scrollableArea = outer->getScrollableAreaIfScrollable(); |
922 | 930 |
923 LayoutRect innerRect = inner->isAccessibilityScrollView() ? inner->paren
tObject()->boundingBoxRect() : inner->boundingBoxRect(); | 931 LayoutRect innerRect = inner->isAccessibilityScrollView() ? inner->paren
tObject()->elementRect() : inner->elementRect(); |
924 LayoutRect objectRect = innerRect; | 932 LayoutRect objectRect = innerRect; |
925 IntPoint scrollPosition = scrollableArea->scrollPosition(); | 933 IntPoint scrollPosition = scrollableArea->scrollPosition(); |
926 | 934 |
927 // Convert the object rect into local coordinates. | 935 // Convert the object rect into local coordinates. |
928 objectRect.move(offsetX, offsetY); | 936 objectRect.move(offsetX, offsetY); |
929 if (!outer->isAccessibilityScrollView()) | 937 if (!outer->isAccessibilityScrollView()) |
930 objectRect.move(scrollPosition.x(), scrollPosition.y()); | 938 objectRect.move(scrollPosition.x(), scrollPosition.y()); |
931 | 939 |
932 int desiredX = computeBestScrollOffset( | 940 int desiredX = computeBestScrollOffset( |
933 0, | 941 0, |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1315 | 1323 |
1316 for (AccessibilityObject* object = parentObject(); object; object = object->
parentObject()) { | 1324 for (AccessibilityObject* object = parentObject(); object; object = object->
parentObject()) { |
1317 if (equalIgnoringCase(object->getAttribute(aria_hiddenAttr), "true")) | 1325 if (equalIgnoringCase(object->getAttribute(aria_hiddenAttr), "true")) |
1318 return true; | 1326 return true; |
1319 } | 1327 } |
1320 | 1328 |
1321 return false; | 1329 return false; |
1322 } | 1330 } |
1323 | 1331 |
1324 } // namespace WebCore | 1332 } // namespace WebCore |
OLD | NEW |