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

Remove redundant member RenderedPosition::layout_object_

The member is always equal to:

LineLayoutAPIShim::LayoutObjectFrom(inline_box_->GetLineLayoutItem())

Hence, this patch removes it for better code health.

Bug: 822575
Change-Id: Ib9c231daa8658aa2b9212e9754bd50c76b0affbc
Reviewed-on: https://chromium-review.googlesource.com/1026643
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
Reviewed-by: default avatarYoichi Osato <yoichio@chromium.org>
Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553939}
parent 3418a116
......@@ -41,7 +41,6 @@
#include "third_party/blink/renderer/core/editing/visible_selection.h"
#include "third_party/blink/renderer/core/editing/visible_units.h"
#include "third_party/blink/renderer/core/html/forms/text_control_element.h"
#include "third_party/blink/renderer/core/layout/api/line_layout_api_shim.h"
#include "third_party/blink/renderer/core/paint/compositing/composited_selection.h"
#include "third_party/blink/renderer/core/paint/paint_layer.h"
......@@ -57,32 +56,24 @@ RenderedPosition::RenderedPosition(const VisiblePositionInFlatTree& position)
RenderedPosition::RenderedPosition(const Position& position,
TextAffinity affinity)
: layout_object_(nullptr), inline_box_(nullptr), offset_(0) {
: inline_box_(nullptr), offset_(0) {
if (position.IsNull())
return;
InlineBoxPosition box_position =
ComputeInlineBoxPosition(PositionWithAffinity(position, affinity));
inline_box_ = box_position.inline_box;
offset_ = box_position.offset_in_box;
if (inline_box_) {
layout_object_ =
LineLayoutAPIShim::LayoutObjectFrom(inline_box_->GetLineLayoutItem());
}
}
RenderedPosition::RenderedPosition(const PositionInFlatTree& position,
TextAffinity affinity)
: layout_object_(nullptr), inline_box_(nullptr), offset_(0) {
: inline_box_(nullptr), offset_(0) {
if (position.IsNull())
return;
InlineBoxPosition box_position = ComputeInlineBoxPosition(
PositionInFlatTreeWithAffinity(position, affinity));
inline_box_ = box_position.inline_box;
offset_ = box_position.offset_in_box;
if (inline_box_) {
layout_object_ =
LineLayoutAPIShim::LayoutObjectFrom(inline_box_->GetLineLayoutItem());
}
}
const InlineBox* RenderedPosition::PrevLeafChild() const {
......@@ -98,8 +89,7 @@ const InlineBox* RenderedPosition::NextLeafChild() const {
}
bool RenderedPosition::IsEquivalent(const RenderedPosition& other) const {
return (layout_object_ == other.layout_object_ &&
inline_box_ == other.inline_box_ && offset_ == other.offset_) ||
return (inline_box_ == other.inline_box_ && offset_ == other.offset_) ||
(AtLeftmostOffsetInBox() && other.AtRightmostOffsetInBox() &&
PrevLeafChild() == other.inline_box_) ||
(AtRightmostOffsetInBox() && other.AtLeftmostOffsetInBox() &&
......@@ -126,9 +116,7 @@ RenderedPosition RenderedPosition::LeftBoundaryOfBidiRun(
const InlineBox* const box =
InlineBoxTraversal::FindLeftBoundaryOfEntireBidiRunIgnoringLineBreak(
*inline_box_, bidi_level_of_run);
return RenderedPosition(
LineLayoutAPIShim::LayoutObjectFrom(box->GetLineLayoutItem()), box,
box->CaretLeftmostOffset());
return RenderedPosition(box, box->CaretLeftmostOffset());
}
RenderedPosition RenderedPosition::RightBoundaryOfBidiRun(
......@@ -139,9 +127,7 @@ RenderedPosition RenderedPosition::RightBoundaryOfBidiRun(
const InlineBox* const box =
InlineBoxTraversal::FindRightBoundaryOfEntireBidiRunIgnoringLineBreak(
*inline_box_, bidi_level_of_run);
return RenderedPosition(
LineLayoutAPIShim::LayoutObjectFrom(box->GetLineLayoutItem()), box,
box->CaretRightmostOffset());
return RenderedPosition(box, box->CaretRightmostOffset());
}
bool RenderedPosition::AtLeftBoundaryOfBidiRun(
......@@ -199,8 +185,10 @@ bool RenderedPosition::AtRightBoundaryOfBidiRun(
Position RenderedPosition::PositionAtLeftBoundaryOfBiDiRun() const {
DCHECK(AtLeftBoundaryOfBidiRun());
if (AtLeftmostOffsetInBox())
return Position::EditingPositionOf(layout_object_->GetNode(), offset_);
if (AtLeftmostOffsetInBox()) {
return Position::EditingPositionOf(
inline_box_->GetLineLayoutItem().GetNode(), offset_);
}
return Position::EditingPositionOf(
NextLeafChild()->GetLineLayoutItem().GetNode(),
......@@ -210,8 +198,10 @@ Position RenderedPosition::PositionAtLeftBoundaryOfBiDiRun() const {
Position RenderedPosition::PositionAtRightBoundaryOfBiDiRun() const {
DCHECK(AtRightBoundaryOfBidiRun());
if (AtRightmostOffsetInBox())
return Position::EditingPositionOf(layout_object_->GetNode(), offset_);
if (AtRightmostOffsetInBox()) {
return Position::EditingPositionOf(
inline_box_->GetLineLayoutItem().GetNode(), offset_);
}
return Position::EditingPositionOf(
PrevLeafChild()->GetLineLayoutItem().GetNode(),
......
......@@ -40,7 +40,6 @@
namespace blink {
class FrameSelection;
class LayoutObject;
struct CompositedSelection;
class CORE_EXPORT RenderedPosition {
......@@ -54,7 +53,7 @@ class CORE_EXPORT RenderedPosition {
RenderedPosition(const PositionInFlatTree&, TextAffinity);
bool IsEquivalent(const RenderedPosition&) const;
bool IsNull() const { return !layout_object_; }
bool IsNull() const { return !inline_box_; }
const RootInlineBox* RootBox() const {
return inline_box_ ? &inline_box_->Root() : nullptr;
}
......@@ -89,7 +88,7 @@ class CORE_EXPORT RenderedPosition {
private:
bool operator==(const RenderedPosition&) const { return false; }
explicit RenderedPosition(const LayoutObject*, const InlineBox*, int offset);
explicit RenderedPosition(const InlineBox*, int offset);
const InlineBox* PrevLeafChild() const;
const InlineBox* NextLeafChild() const;
......@@ -104,7 +103,6 @@ class CORE_EXPORT RenderedPosition {
bool AtRightBoundaryOfBidiRun(ShouldMatchBidiLevel,
unsigned char bidi_level_of_run) const;
const LayoutObject* layout_object_;
const InlineBox* inline_box_;
int offset_;
......@@ -113,12 +111,10 @@ class CORE_EXPORT RenderedPosition {
};
inline RenderedPosition::RenderedPosition()
: layout_object_(nullptr), inline_box_(nullptr), offset_(0) {}
: inline_box_(nullptr), offset_(0) {}
inline RenderedPosition::RenderedPosition(const LayoutObject* layout_object,
const InlineBox* box,
int offset)
: layout_object_(layout_object), inline_box_(box), offset_(offset) {}
inline RenderedPosition::RenderedPosition(const InlineBox* box, int offset)
: inline_box_(box), offset_(offset) {}
} // namespace blink
......
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