Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Side by Side Diff: Source/core/accessibility/AccessibilityObject.cpp

Issue 14740025: Simplify and add caching for accessible bounding box calculation. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Re-landing with null check fix Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
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() const
574 {
575 for (unsigned i = 0; i < m_children.size(); ++i)
576 m_children[i].get()->markCachedElementRectDirty();
577 }
578
573 IntPoint AccessibilityObject::clickPoint() 579 IntPoint AccessibilityObject::clickPoint()
574 { 580 {
575 LayoutRect rect = elementRect(); 581 LayoutRect rect = elementRect();
576 return roundedIntPoint(LayoutPoint(rect.x() + rect.width() / 2, rect.y() + r ect.height() / 2)); 582 return roundedIntPoint(LayoutPoint(rect.x() + rect.width() / 2, rect.y() + r ect.height() / 2));
577 } 583 }
578 584
579 IntRect AccessibilityObject::boundingBoxForQuads(RenderObject* obj, const Vector <FloatQuad>& quads) 585 IntRect AccessibilityObject::boundingBoxForQuads(RenderObject* obj, const Vector <FloatQuad>& quads)
580 { 586 {
581 ASSERT(obj); 587 ASSERT(obj);
582 if (!obj) 588 if (!obj)
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 if (Frame* f = actionElem->document()->frame()) 786 if (Frame* f = actionElem->document()->frame())
781 f->loader()->resetMultipleFormSubmissionProtection(); 787 f->loader()->resetMultipleFormSubmissionProtection();
782 788
783 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); 789 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture);
784 actionElem->accessKeyAction(true); 790 actionElem->accessKeyAction(true);
785 return true; 791 return true;
786 } 792 }
787 793
788 void AccessibilityObject::scrollToMakeVisible() const 794 void AccessibilityObject::scrollToMakeVisible() const
789 { 795 {
790 IntRect objectRect = pixelSnappedIntRect(boundingBoxRect()); 796 IntRect objectRect = pixelSnappedIntRect(elementRect());
791 objectRect.setLocation(IntPoint()); 797 objectRect.setLocation(IntPoint());
792 scrollToMakeVisibleWithSubFocus(objectRect); 798 scrollToMakeVisibleWithSubFocus(objectRect);
793 } 799 }
794 800
795 // This is a 1-dimensional scroll offset helper function that's applied 801 // This is a 1-dimensional scroll offset helper function that's applied
796 // separately in the horizontal and vertical directions, because the 802 // separately in the horizontal and vertical directions, because the
797 // logic is the same. The goal is to compute the best scroll offset 803 // logic is the same. The goal is to compute the best scroll offset
798 // in order to make an object visible within a viewport. 804 // in order to make an object visible within a viewport.
799 // 805 //
800 // In case the whole object cannot fit, you can specify a 806 // In case the whole object cannot fit, you can specify a
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 { 874 {
869 // Search up the parent chain until we find the first one that's scrollable. 875 // Search up the parent chain until we find the first one that's scrollable.
870 AccessibilityObject* scrollParent = parentObject(); 876 AccessibilityObject* scrollParent = parentObject();
871 ScrollableArea* scrollableArea; 877 ScrollableArea* scrollableArea;
872 for (scrollableArea = 0; 878 for (scrollableArea = 0;
873 scrollParent && !(scrollableArea = scrollParent->getScrollableAreaIfScr ollable()); 879 scrollParent && !(scrollableArea = scrollParent->getScrollableAreaIfScr ollable());
874 scrollParent = scrollParent->parentObject()) { } 880 scrollParent = scrollParent->parentObject()) { }
875 if (!scrollableArea) 881 if (!scrollableArea)
876 return; 882 return;
877 883
878 LayoutRect objectRect = boundingBoxRect(); 884 LayoutRect objectRect = elementRect();
879 IntPoint scrollPosition = scrollableArea->scrollPosition(); 885 IntPoint scrollPosition = scrollableArea->scrollPosition();
880 IntRect scrollVisibleRect = scrollableArea->visibleContentRect(); 886 IntRect scrollVisibleRect = scrollableArea->visibleContentRect();
881 887
882 int desiredX = computeBestScrollOffset( 888 int desiredX = computeBestScrollOffset(
883 scrollPosition.x(), 889 scrollPosition.x(),
884 objectRect.x() + subfocus.x(), objectRect.x() + subfocus.maxX(), 890 objectRect.x() + subfocus.x(), objectRect.x() + subfocus.maxX(),
885 objectRect.x(), objectRect.maxX(), 891 objectRect.x(), objectRect.maxX(),
886 0, scrollVisibleRect.width()); 892 0, scrollVisibleRect.width());
887 int desiredY = computeBestScrollOffset( 893 int desiredY = computeBestScrollOffset(
888 scrollPosition.y(), 894 scrollPosition.y(),
(...skipping 24 matching lines...) Expand all
913 // next innermost object to the given point. 919 // next innermost object to the given point.
914 int offsetX = 0, offsetY = 0; 920 int offsetX = 0, offsetY = 0;
915 IntPoint point = globalPoint; 921 IntPoint point = globalPoint;
916 size_t levels = objects.size() - 1; 922 size_t levels = objects.size() - 1;
917 for (size_t i = 0; i < levels; i++) { 923 for (size_t i = 0; i < levels; i++) {
918 const AccessibilityObject* outer = objects[i]; 924 const AccessibilityObject* outer = objects[i];
919 const AccessibilityObject* inner = objects[i + 1]; 925 const AccessibilityObject* inner = objects[i + 1];
920 926
921 ScrollableArea* scrollableArea = outer->getScrollableAreaIfScrollable(); 927 ScrollableArea* scrollableArea = outer->getScrollableAreaIfScrollable();
922 928
923 LayoutRect innerRect = inner->isAccessibilityScrollView() ? inner->paren tObject()->boundingBoxRect() : inner->boundingBoxRect(); 929 LayoutRect innerRect = inner->isAccessibilityScrollView() ? inner->paren tObject()->elementRect() : inner->elementRect();
924 LayoutRect objectRect = innerRect; 930 LayoutRect objectRect = innerRect;
925 IntPoint scrollPosition = scrollableArea->scrollPosition(); 931 IntPoint scrollPosition = scrollableArea->scrollPosition();
926 932
927 // Convert the object rect into local coordinates. 933 // Convert the object rect into local coordinates.
928 objectRect.move(offsetX, offsetY); 934 objectRect.move(offsetX, offsetY);
929 if (!outer->isAccessibilityScrollView()) 935 if (!outer->isAccessibilityScrollView())
930 objectRect.move(scrollPosition.x(), scrollPosition.y()); 936 objectRect.move(scrollPosition.x(), scrollPosition.y());
931 937
932 int desiredX = computeBestScrollOffset( 938 int desiredX = computeBestScrollOffset(
933 0, 939 0,
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
1315 1321
1316 for (AccessibilityObject* object = parentObject(); object; object = object-> parentObject()) { 1322 for (AccessibilityObject* object = parentObject(); object; object = object-> parentObject()) {
1317 if (equalIgnoringCase(object->getAttribute(aria_hiddenAttr), "true")) 1323 if (equalIgnoringCase(object->getAttribute(aria_hiddenAttr), "true"))
1318 return true; 1324 return true;
1319 } 1325 }
1320 1326
1321 return false; 1327 return false;
1322 } 1328 }
1323 1329
1324 } // namespace WebCore 1330 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/accessibility/AccessibilityObject.h ('k') | Source/core/accessibility/AccessibilityRenderObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698