Commit bbd7a3cd authored by Xiaocheng Hu's avatar Xiaocheng Hu Committed by Commit Bot

Stop including rendered_position.h in accessibility code

ax_layout_object.cc includes rendered_position.h to use some hacky
utility functions there.

As editing code no longer uses those functions, this patch moves the
functions to AX, and stops AX from including rendered_position.h to
improve code health.

Change-Id: I85a50fbd81f05eded792721e8fd99eac0373b6c3
Reviewed-on: https://chromium-review.googlesource.com/1024734Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: default avatarYoichi Osato <yoichio@chromium.org>
Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553823}
parent c4a580df
...@@ -47,34 +47,6 @@ ...@@ -47,34 +47,6 @@
namespace blink { namespace blink {
template <typename Strategy>
static inline LayoutObject* LayoutObjectFromPosition(
const PositionTemplate<Strategy>& position) {
DCHECK(position.IsNotNull());
Node* layout_object_node = nullptr;
switch (position.AnchorType()) {
case PositionAnchorType::kOffsetInAnchor:
layout_object_node = position.ComputeNodeAfterPosition();
if (!layout_object_node || !layout_object_node->GetLayoutObject())
layout_object_node = position.AnchorNode()->lastChild();
break;
case PositionAnchorType::kBeforeAnchor:
case PositionAnchorType::kAfterAnchor:
break;
case PositionAnchorType::kBeforeChildren:
layout_object_node = Strategy::FirstChild(*position.AnchorNode());
break;
case PositionAnchorType::kAfterChildren:
layout_object_node = Strategy::LastChild(*position.AnchorNode());
break;
}
if (!layout_object_node || !layout_object_node->GetLayoutObject())
layout_object_node = position.AnchorNode();
return layout_object_node->GetLayoutObject();
}
RenderedPosition::RenderedPosition(const VisiblePosition& position) RenderedPosition::RenderedPosition(const VisiblePosition& position)
: RenderedPosition(position.DeepEquivalent(), position.Affinity()) {} : RenderedPosition(position.DeepEquivalent(), position.Affinity()) {}
...@@ -403,17 +375,6 @@ static CompositedSelectionBound EndPositionInGraphicsLayerBacking( ...@@ -403,17 +375,6 @@ static CompositedSelectionBound EndPositionInGraphicsLayerBacking(
edge_bottom_in_layer); edge_bottom_in_layer);
} }
bool LayoutObjectContainsPosition(LayoutObject* target,
const Position& position) {
for (LayoutObject* layout_object = LayoutObjectFromPosition(position);
layout_object && layout_object->GetNode();
layout_object = layout_object->Parent()) {
if (layout_object == target)
return true;
}
return false;
}
CompositedSelection RenderedPosition::ComputeCompositedSelection( CompositedSelection RenderedPosition::ComputeCompositedSelection(
const FrameSelection& frame_selection) { const FrameSelection& frame_selection) {
if (!frame_selection.IsHandleVisible() || frame_selection.IsHidden()) if (!frame_selection.IsHandleVisible() || frame_selection.IsHidden())
......
...@@ -120,8 +120,6 @@ inline RenderedPosition::RenderedPosition(const LayoutObject* layout_object, ...@@ -120,8 +120,6 @@ inline RenderedPosition::RenderedPosition(const LayoutObject* layout_object,
int offset) int offset)
: layout_object_(layout_object), inline_box_(box), offset_(offset) {} : layout_object_(layout_object), inline_box_(box), offset_(offset) {}
CORE_EXPORT bool LayoutObjectContainsPosition(LayoutObject*, const Position&);
} // namespace blink } // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_EDITING_RENDERED_POSITION_H_ #endif // THIRD_PARTY_BLINK_RENDERER_CORE_EDITING_RENDERED_POSITION_H_
...@@ -39,7 +39,6 @@ ...@@ -39,7 +39,6 @@
#include "third_party/blink/renderer/core/editing/frame_selection.h" #include "third_party/blink/renderer/core/editing/frame_selection.h"
#include "third_party/blink/renderer/core/editing/iterators/character_iterator.h" #include "third_party/blink/renderer/core/editing/iterators/character_iterator.h"
#include "third_party/blink/renderer/core/editing/iterators/text_iterator.h" #include "third_party/blink/renderer/core/editing/iterators/text_iterator.h"
#include "third_party/blink/renderer/core/editing/rendered_position.h"
#include "third_party/blink/renderer/core/editing/selection_template.h" #include "third_party/blink/renderer/core/editing/selection_template.h"
#include "third_party/blink/renderer/core/editing/text_affinity.h" #include "third_party/blink/renderer/core/editing/text_affinity.h"
#include "third_party/blink/renderer/core/editing/visible_position.h" #include "third_party/blink/renderer/core/editing/visible_position.h"
...@@ -2227,6 +2226,43 @@ void AXLayoutObject::TextChanged() { ...@@ -2227,6 +2226,43 @@ void AXLayoutObject::TextChanged() {
// Text metrics. Most of these should be deprecated, needs major cleanup. // Text metrics. Most of these should be deprecated, needs major cleanup.
// //
static LayoutObject* LayoutObjectFromPosition(const Position& position) {
DCHECK(position.IsNotNull());
Node* layout_object_node = nullptr;
switch (position.AnchorType()) {
case PositionAnchorType::kOffsetInAnchor:
layout_object_node = position.ComputeNodeAfterPosition();
if (!layout_object_node || !layout_object_node->GetLayoutObject())
layout_object_node = position.AnchorNode()->lastChild();
break;
case PositionAnchorType::kBeforeAnchor:
case PositionAnchorType::kAfterAnchor:
break;
case PositionAnchorType::kBeforeChildren:
layout_object_node = position.AnchorNode()->firstChild();
break;
case PositionAnchorType::kAfterChildren:
layout_object_node = position.AnchorNode()->lastChild();
break;
}
if (!layout_object_node || !layout_object_node->GetLayoutObject())
layout_object_node = position.AnchorNode();
return layout_object_node->GetLayoutObject();
}
static bool LayoutObjectContainsPosition(LayoutObject* target,
const Position& position) {
for (LayoutObject* layout_object = LayoutObjectFromPosition(position);
layout_object && layout_object->GetNode();
layout_object = layout_object->Parent()) {
if (layout_object == target)
return true;
}
return false;
}
// NOTE: Consider providing this utility method as AX API // NOTE: Consider providing this utility method as AX API
int AXLayoutObject::Index(const VisiblePosition& position) const { int AXLayoutObject::Index(const VisiblePosition& position) const {
if (position.IsNull() || !IsTextControl()) if (position.IsNull() || !IsTextControl())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment