Commit d4c5f5d3 authored by Gyuyoung Kim's avatar Gyuyoung Kim Committed by Commit Bot

Remove const_casts in SelectionModifier and ScopedFocusNavigation

Member<> now supports const types. This CL removes an unnecessary
const_cast in ScopedFocusNavigation and makes a Member<> const in
SelectionModifier so we can do the same there.

Bug: None.
Change-Id: Ica178eed562e19f9042872d162b6b7f37ed51fe3
Reviewed-on: https://chromium-review.googlesource.com/826843Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Commit-Queue: Gyuyoung Kim <gyuyoung.kim@lge.com>
Cr-Commit-Position: refs/heads/master@{#524322}
parent d5c6ad26
...@@ -62,7 +62,8 @@ LayoutUnit NoXPosForVerticalArrowNavigation() { ...@@ -62,7 +62,8 @@ LayoutUnit NoXPosForVerticalArrowNavigation() {
return LayoutUnit::Min(); return LayoutUnit::Min();
} }
bool SelectionModifier::ShouldAlwaysUseDirectionalSelection(LocalFrame* frame) { bool SelectionModifier::ShouldAlwaysUseDirectionalSelection(
const LocalFrame* frame) {
return !frame || return !frame ||
frame->GetEditor().Behavior().ShouldConsiderSelectionAsDirectional(); frame->GetEditor().Behavior().ShouldConsiderSelectionAsDirectional();
} }
...@@ -71,7 +72,7 @@ SelectionModifier::SelectionModifier( ...@@ -71,7 +72,7 @@ SelectionModifier::SelectionModifier(
const LocalFrame& frame, const LocalFrame& frame,
const SelectionInDOMTree& selection, const SelectionInDOMTree& selection,
LayoutUnit x_pos_for_vertical_arrow_navigation) LayoutUnit x_pos_for_vertical_arrow_navigation)
: frame_(const_cast<LocalFrame*>(&frame)), : frame_(&frame),
current_selection_(selection), current_selection_(selection),
x_pos_for_vertical_arrow_navigation_( x_pos_for_vertical_arrow_navigation_(
x_pos_for_vertical_arrow_navigation) {} x_pos_for_vertical_arrow_navigation) {}
......
...@@ -70,9 +70,9 @@ class SelectionModifier { ...@@ -70,9 +70,9 @@ class SelectionModifier {
private: private:
// TODO(editing-dev): We should make |GetFrame()| to return |LocalFrame&| // TODO(editing-dev): We should make |GetFrame()| to return |LocalFrame&|
// since it can not be |nullptr|. // since it can not be |nullptr|.
LocalFrame* GetFrame() const { return frame_; } const LocalFrame* GetFrame() const { return frame_; }
static bool ShouldAlwaysUseDirectionalSelection(LocalFrame*); static bool ShouldAlwaysUseDirectionalSelection(const LocalFrame*);
TextDirection DirectionOfEnclosingBlock() const; TextDirection DirectionOfEnclosingBlock() const;
TextDirection DirectionOfSelection() const; TextDirection DirectionOfSelection() const;
VisiblePosition PositionForPlatform(bool is_get_start) const; VisiblePosition PositionForPlatform(bool is_get_start) const;
...@@ -103,7 +103,7 @@ class SelectionModifier { ...@@ -103,7 +103,7 @@ class SelectionModifier {
static VisiblePosition RightWordPosition(const VisiblePosition&, static VisiblePosition RightWordPosition(const VisiblePosition&,
bool skips_space_when_moving_right); bool skips_space_when_moving_right);
Member<LocalFrame> frame_; Member<const LocalFrame> frame_;
// TODO(editing-dev): We should get rid of |selection_| once we change // TODO(editing-dev): We should get rid of |selection_| once we change
// all member functions not to use |selection_|. // all member functions not to use |selection_|.
// |selection_| is used as implicit parameter or a cache instead of pass it. // |selection_| is used as implicit parameter or a cache instead of pass it.
......
...@@ -246,7 +246,7 @@ ScopedFocusNavigation::ScopedFocusNavigation( ...@@ -246,7 +246,7 @@ ScopedFocusNavigation::ScopedFocusNavigation(
ContainerNode& scoping_root_node, ContainerNode& scoping_root_node,
const Element* current, const Element* current,
FocusController::OwnerMap& owner_map) FocusController::OwnerMap& owner_map)
: current_(const_cast<Element*>(current)) { : current_(current) {
if (HTMLSlotElement* slot = ToHTMLSlotElementOrNull(scoping_root_node)) { if (HTMLSlotElement* slot = ToHTMLSlotElementOrNull(scoping_root_node)) {
if (slot->AssignedNodes().IsEmpty()) { if (slot->AssignedNodes().IsEmpty()) {
navigation_ = new FocusNavigation(scoping_root_node, *slot, owner_map); navigation_ = new FocusNavigation(scoping_root_node, *slot, owner_map);
......
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