OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 #include "core/rendering/style/RenderStyle.h" | 47 #include "core/rendering/style/RenderStyle.h" |
48 #include "platform/PlatformKeyboardEvent.h" | 48 #include "platform/PlatformKeyboardEvent.h" |
49 #include "public/platform/WebPoint.h" | 49 #include "public/platform/WebPoint.h" |
50 #include "public/platform/WebRect.h" | 50 #include "public/platform/WebRect.h" |
51 #include "public/platform/WebString.h" | 51 #include "public/platform/WebString.h" |
52 #include "public/platform/WebURL.h" | 52 #include "public/platform/WebURL.h" |
53 #include "public/web/WebDocument.h" | 53 #include "public/web/WebDocument.h" |
54 #include "public/web/WebNode.h" | 54 #include "public/web/WebNode.h" |
55 #include "wtf/text/StringBuilder.h" | 55 #include "wtf/text/StringBuilder.h" |
56 | 56 |
| 57 using namespace blink; |
| 58 |
57 namespace blink { | 59 namespace blink { |
58 | 60 |
| 61 #if ENABLE(ASSERT) |
| 62 // It's not safe to call some WebAXObject APIs if a layout is pending. |
| 63 // Clients should call updateLayoutAndCheckValidity first. |
| 64 static bool isLayoutClean(Document* document) |
| 65 { |
| 66 if (!document || !document->view()) |
| 67 return false; |
| 68 return document->lifecycle().state() >= DocumentLifecycle::LayoutClean |
| 69 || (document->lifecycle().state() == DocumentLifecycle::StyleClean && !d
ocument->view()->needsLayout()); |
| 70 } |
| 71 #endif |
| 72 |
59 void WebAXObject::reset() | 73 void WebAXObject::reset() |
60 { | 74 { |
61 m_private.reset(); | 75 m_private.reset(); |
62 } | 76 } |
63 | 77 |
64 void WebAXObject::assign(const WebAXObject& other) | 78 void WebAXObject::assign(const WebAXObject& other) |
65 { | 79 { |
66 m_private = other.m_private; | 80 m_private = other.m_private; |
67 } | 81 } |
68 | 82 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 bool WebAXObject::updateBackingStoreAndCheckValidity() | 135 bool WebAXObject::updateBackingStoreAndCheckValidity() |
122 { | 136 { |
123 return updateLayoutAndCheckValidity(); | 137 return updateLayoutAndCheckValidity(); |
124 } | 138 } |
125 | 139 |
126 WebString WebAXObject::accessibilityDescription() const | 140 WebString WebAXObject::accessibilityDescription() const |
127 { | 141 { |
128 if (isDetached()) | 142 if (isDetached()) |
129 return WebString(); | 143 return WebString(); |
130 | 144 |
| 145 ASSERT(isLayoutClean(m_private->document())); |
| 146 |
131 return m_private->accessibilityDescription(); | 147 return m_private->accessibilityDescription(); |
132 } | 148 } |
133 | 149 |
134 WebString WebAXObject::actionVerb() const | 150 WebString WebAXObject::actionVerb() const |
135 { | 151 { |
136 if (isDetached()) | 152 if (isDetached()) |
137 return WebString(); | 153 return WebString(); |
138 | 154 |
139 return m_private->actionVerb(); | 155 return m_private->actionVerb(); |
140 } | 156 } |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 m_private->ariaOwnsElements(owns); | 551 m_private->ariaOwnsElements(owns); |
536 | 552 |
537 WebVector<WebAXObject> result(owns.size()); | 553 WebVector<WebAXObject> result(owns.size()); |
538 for (size_t i = 0; i < owns.size(); i++) | 554 for (size_t i = 0; i < owns.size(); i++) |
539 result[i] = WebAXObject(owns[i]); | 555 result[i] = WebAXObject(owns[i]); |
540 ownsElements.swap(result); | 556 ownsElements.swap(result); |
541 | 557 |
542 return true; | 558 return true; |
543 } | 559 } |
544 | 560 |
545 #if ENABLE(ASSERT) | |
546 static bool isLayoutClean(Document* document) | |
547 { | |
548 if (!document || !document->view()) | |
549 return false; | |
550 return document->lifecycle().state() >= DocumentLifecycle::LayoutClean | |
551 || (document->lifecycle().state() == DocumentLifecycle::StyleClean && !d
ocument->view()->needsLayout()); | |
552 } | |
553 #endif | |
554 | |
555 WebRect WebAXObject::boundingBoxRect() const | 561 WebRect WebAXObject::boundingBoxRect() const |
556 { | 562 { |
557 if (isDetached()) | 563 if (isDetached()) |
558 return WebRect(); | 564 return WebRect(); |
559 | 565 |
560 // It's not safe to call boundingBoxRect if a layout is pending. | |
561 // Clients should call updateLayoutAndCheckValidity first. | |
562 ASSERT(isLayoutClean(m_private->document())); | 566 ASSERT(isLayoutClean(m_private->document())); |
563 | 567 |
564 return pixelSnappedIntRect(m_private->elementRect()); | 568 return pixelSnappedIntRect(m_private->elementRect()); |
565 } | 569 } |
566 | 570 |
567 bool WebAXObject::canvasHasFallbackContent() const | 571 bool WebAXObject::canvasHasFallbackContent() const |
568 { | 572 { |
569 if (isDetached()) | 573 if (isDetached()) |
570 return false; | 574 return false; |
571 | 575 |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 return WebString(); | 779 return WebString(); |
776 | 780 |
777 return m_private->stringValue(); | 781 return m_private->stringValue(); |
778 } | 782 } |
779 | 783 |
780 WebString WebAXObject::title() const | 784 WebString WebAXObject::title() const |
781 { | 785 { |
782 if (isDetached()) | 786 if (isDetached()) |
783 return WebString(); | 787 return WebString(); |
784 | 788 |
| 789 ASSERT(isLayoutClean(m_private->document())); |
| 790 |
785 return m_private->title(); | 791 return m_private->title(); |
786 } | 792 } |
787 | 793 |
788 WebAXObject WebAXObject::titleUIElement() const | 794 WebAXObject WebAXObject::titleUIElement() const |
789 { | 795 { |
790 if (isDetached()) | 796 if (isDetached()) |
791 return WebAXObject(); | 797 return WebAXObject(); |
792 | 798 |
793 if (!m_private->exposesTitleUIElement()) | 799 if (!m_private->exposesTitleUIElement()) |
794 return WebAXObject(); | 800 return WebAXObject(); |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1169 m_private = object; | 1175 m_private = object; |
1170 return *this; | 1176 return *this; |
1171 } | 1177 } |
1172 | 1178 |
1173 WebAXObject::operator WTF::PassRefPtr<AXObject>() const | 1179 WebAXObject::operator WTF::PassRefPtr<AXObject>() const |
1174 { | 1180 { |
1175 return m_private.get(); | 1181 return m_private.get(); |
1176 } | 1182 } |
1177 | 1183 |
1178 } // namespace blink | 1184 } // namespace blink |
OLD | NEW |