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

Unified Diff: Source/web/WebAXObject.cpp

Issue 465143003: Assert if we try to access another AX attribute while a layout is pending. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/accessibility/calling-accessibility-methods-with-pending-layout-causes-crash-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/WebAXObject.cpp
diff --git a/Source/web/WebAXObject.cpp b/Source/web/WebAXObject.cpp
index cf1fbebf9ddc50233f96b797d12841fe70dbde23..cb9314e21937b19f2158b8ccd8294dbcda0b2395 100644
--- a/Source/web/WebAXObject.cpp
+++ b/Source/web/WebAXObject.cpp
@@ -54,8 +54,22 @@
#include "public/web/WebNode.h"
#include "wtf/text/StringBuilder.h"
+using namespace blink;
+
namespace blink {
+#if ENABLE(ASSERT)
+// It's not safe to call some WebAXObject APIs if a layout is pending.
+// Clients should call updateLayoutAndCheckValidity first.
+static bool isLayoutClean(Document* document)
+{
+ if (!document || !document->view())
+ return false;
+ return document->lifecycle().state() >= DocumentLifecycle::LayoutClean
+ || (document->lifecycle().state() == DocumentLifecycle::StyleClean && !document->view()->needsLayout());
+}
+#endif
+
void WebAXObject::reset()
{
m_private.reset();
@@ -128,6 +142,8 @@ WebString WebAXObject::accessibilityDescription() const
if (isDetached())
return WebString();
+ ASSERT(isLayoutClean(m_private->document()));
+
return m_private->accessibilityDescription();
}
@@ -542,23 +558,11 @@ bool WebAXObject::ariaOwns(WebVector<WebAXObject>& ownsElements) const
return true;
}
-#if ENABLE(ASSERT)
-static bool isLayoutClean(Document* document)
-{
- if (!document || !document->view())
- return false;
- return document->lifecycle().state() >= DocumentLifecycle::LayoutClean
- || (document->lifecycle().state() == DocumentLifecycle::StyleClean && !document->view()->needsLayout());
-}
-#endif
-
WebRect WebAXObject::boundingBoxRect() const
{
if (isDetached())
return WebRect();
- // It's not safe to call boundingBoxRect if a layout is pending.
- // Clients should call updateLayoutAndCheckValidity first.
ASSERT(isLayoutClean(m_private->document()));
return pixelSnappedIntRect(m_private->elementRect());
@@ -782,6 +786,8 @@ WebString WebAXObject::title() const
if (isDetached())
return WebString();
+ ASSERT(isLayoutClean(m_private->document()));
+
return m_private->title();
}
« no previous file with comments | « LayoutTests/accessibility/calling-accessibility-methods-with-pending-layout-causes-crash-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698