| 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 16 matching lines...) Expand all Loading... |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 #include "modules/accessibility/AXObjectImpl.h" | 29 #include "modules/accessibility/AXObjectImpl.h" |
| 30 | 30 |
| 31 #include "SkMatrix44.h" | 31 #include "SkMatrix44.h" |
| 32 #include "core/InputTypeNames.h" | 32 #include "core/InputTypeNames.h" |
| 33 #include "core/css/resolver/StyleResolver.h" | 33 #include "core/css/resolver/StyleResolver.h" |
| 34 #include "core/dom/AccessibleNode.h" | 34 #include "core/dom/AccessibleNode.h" |
| 35 #include "core/dom/UserGestureIndicator.h" | 35 #include "core/dom/UserGestureIndicator.h" |
| 36 #include "core/editing/EditingUtilities.h" | 36 #include "core/editing/EditingUtilities.h" |
| 37 #include "core/editing/FrameSelection.h" |
| 37 #include "core/editing/VisibleUnits.h" | 38 #include "core/editing/VisibleUnits.h" |
| 38 #include "core/frame/LocalFrame.h" | 39 #include "core/frame/LocalFrame.h" |
| 39 #include "core/frame/LocalFrameView.h" | 40 #include "core/frame/LocalFrameView.h" |
| 40 #include "core/frame/Settings.h" | 41 #include "core/frame/Settings.h" |
| 41 #include "core/html/HTMLDialogElement.h" | 42 #include "core/html/HTMLDialogElement.h" |
| 42 #include "core/html/HTMLFrameOwnerElement.h" | 43 #include "core/html/HTMLFrameOwnerElement.h" |
| 43 #include "core/html/HTMLInputElement.h" | 44 #include "core/html/HTMLInputElement.h" |
| 44 #include "core/html/parser/HTMLParserIdioms.h" | 45 #include "core/html/parser/HTMLParserIdioms.h" |
| 45 #include "core/layout/LayoutBoxModelObject.h" | 46 #include "core/layout/LayoutBoxModelObject.h" |
| 47 #include "core/layout/line/AbstractInlineTextBox.h" |
| 48 #include "core/layout/line/InlineBox.h" |
| 49 #include "core/layout/line/InlineTextBox.h" |
| 50 #include "modules/accessibility/AXInlineTextBox.h" |
| 46 #include "modules/accessibility/AXObjectCacheImpl.h" | 51 #include "modules/accessibility/AXObjectCacheImpl.h" |
| 47 #include "platform/text/PlatformLocale.h" | 52 #include "platform/text/PlatformLocale.h" |
| 48 #include "platform/wtf/HashSet.h" | 53 #include "platform/wtf/HashSet.h" |
| 49 #include "platform/wtf/StdLibExtras.h" | 54 #include "platform/wtf/StdLibExtras.h" |
| 50 #include "platform/wtf/text/WTFString.h" | 55 #include "platform/wtf/text/WTFString.h" |
| 51 | 56 |
| 52 using blink::WebLocalizedString; | 57 using blink::WebLocalizedString; |
| 53 | 58 |
| 54 namespace blink { | 59 namespace blink { |
| 55 | 60 |
| (...skipping 1371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1427 return false; | 1432 return false; |
| 1428 } | 1433 } |
| 1429 | 1434 |
| 1430 const AtomicString& AXObjectImpl::GetAttribute( | 1435 const AtomicString& AXObjectImpl::GetAttribute( |
| 1431 const QualifiedName& attribute) const { | 1436 const QualifiedName& attribute) const { |
| 1432 if (Element* element = GetElement()) | 1437 if (Element* element = GetElement()) |
| 1433 return element->FastGetAttribute(attribute); | 1438 return element->FastGetAttribute(attribute); |
| 1434 return g_null_atom; | 1439 return g_null_atom; |
| 1435 } | 1440 } |
| 1436 | 1441 |
| 1442 AXRange AXObject::Selection() const { |
| 1443 Document* document = GetDocument(); |
| 1444 if (!document) |
| 1445 return AXRange(); |
| 1446 LocalFrame* frame = document->GetFrame(); |
| 1447 if (!frame) |
| 1448 return AXRange(); |
| 1449 |
| 1450 const VisibleSelectionInFlatTree& visible_selection = |
| 1451 frame->Selection().ComputeVisibleSelectionInFlatTree(); |
| 1452 if (visible_selection.IsNone()) |
| 1453 return AXRange(); |
| 1454 |
| 1455 AXObject* anchor_object = nullptr; |
| 1456 int anchor_offset; |
| 1457 ComputeAXObjectAndOffset(visible_selection.VisibleStart(), &anchor_object, |
| 1458 &anchor_offset); |
| 1459 AXObject* focus_object = nullptr; |
| 1460 int focus_offset; |
| 1461 ComputeAXObjectAndOffset(visible_selection.VisibleStart(), &focus_object, |
| 1462 &focus_offset); |
| 1463 |
| 1464 if (!anchor_object || !focus_object) |
| 1465 return AXRange(); |
| 1466 return AXRange(anchor_object, anchor_offset, focus_object, focus_offset, |
| 1467 visible_selection.Affinity()); |
| 1468 } |
| 1469 |
| 1470 void AXObject::ComputeAXObjectAndOffset( |
| 1471 const VisiblePositionInFlatTree& position, |
| 1472 AXObject** ax_object, |
| 1473 int* offset) const { |
| 1474 *ax_object = nullptr; |
| 1475 *offset = 0; |
| 1476 if (position.IsNull()) |
| 1477 return; |
| 1478 |
| 1479 InlineBoxPosition box_position = |
| 1480 ComputeInlineBoxPosition(position.DeepEquivalent(), position.Affinity()); |
| 1481 InlineBox* inline_box = box_position.inline_box; |
| 1482 if (inline_box && inline_box->IsInlineTextBox()) { |
| 1483 InlineTextBox* inline_text_box = ToInlineTextBox(inline_box); |
| 1484 RefPtr<AbstractInlineTextBox> abstract_inline_text_box = |
| 1485 AbstractInlineTextBox::GetOrCreate(inline_text_box->GetLineLayoutItem(), |
| 1486 inline_text_box); |
| 1487 *ax_object = AxObjectCache().GetOrCreate(abstract_inline_text_box); |
| 1488 } else { |
| 1489 Node* anchor_node = position.DeepEquivalent().AnchorNode(); |
| 1490 DCHECK(anchor_node); |
| 1491 switch (position.DeepEquivalent().AnchorType()) { |
| 1492 case PositionAnchorType::kOffsetInAnchor: |
| 1493 case PositionAnchorType::kBeforeAnchor: |
| 1494 case PositionAnchorType::kAfterAnchor: |
| 1495 break; |
| 1496 |
| 1497 case PositionAnchorType::kBeforeChildren: |
| 1498 if (EditingInFlatTreeStrategy::FirstChild(*anchor_node)) |
| 1499 anchor_node = EditingInFlatTreeStrategy::FirstChild(*anchor_node); |
| 1500 break; |
| 1501 case PositionAnchorType::kAfterChildren: |
| 1502 if (EditingInFlatTreeStrategy::LastChild(*anchor_node)) |
| 1503 anchor_node = EditingInFlatTreeStrategy::LastChild(*anchor_node); |
| 1504 break; |
| 1505 } |
| 1506 LayoutObject* layout_object = anchor_node->GetLayoutObject(); |
| 1507 if (layout_object) { |
| 1508 *ax_object = AxObjectCache().GetOrCreate(layout_object); |
| 1509 } else { |
| 1510 *ax_object = AxObjectCache().GetOrCreate(anchor_node); |
| 1511 } |
| 1512 } |
| 1513 *offset = box_position.offset_in_box; |
| 1514 } |
| 1515 |
| 1437 // | 1516 // |
| 1438 // Scrollable containers. | 1517 // Scrollable containers. |
| 1439 // | 1518 // |
| 1440 | 1519 |
| 1441 bool AXObjectImpl::IsScrollableContainer() const { | 1520 bool AXObjectImpl::IsScrollableContainer() const { |
| 1442 return !!GetScrollableAreaIfScrollable(); | 1521 return !!GetScrollableAreaIfScrollable(); |
| 1443 } | 1522 } |
| 1444 | 1523 |
| 1445 IntPoint AXObjectImpl::GetScrollOffset() const { | 1524 IntPoint AXObjectImpl::GetScrollOffset() const { |
| 1446 ScrollableArea* area = GetScrollableAreaIfScrollable(); | 1525 ScrollableArea* area = GetScrollableAreaIfScrollable(); |
| (...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2093 } | 2172 } |
| 2094 | 2173 |
| 2095 DEFINE_TRACE(AXObjectImpl) { | 2174 DEFINE_TRACE(AXObjectImpl) { |
| 2096 visitor->Trace(children_); | 2175 visitor->Trace(children_); |
| 2097 visitor->Trace(parent_); | 2176 visitor->Trace(parent_); |
| 2098 visitor->Trace(cached_live_region_root_); | 2177 visitor->Trace(cached_live_region_root_); |
| 2099 visitor->Trace(ax_object_cache_); | 2178 visitor->Trace(ax_object_cache_); |
| 2100 } | 2179 } |
| 2101 | 2180 |
| 2102 } // namespace blink | 2181 } // namespace blink |
| OLD | NEW |