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 @@ ...@@ -41,7 +41,6 @@
#include "third_party/blink/renderer/core/editing/visible_selection.h" #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/editing/visible_units.h"
#include "third_party/blink/renderer/core/html/forms/text_control_element.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/compositing/composited_selection.h"
#include "third_party/blink/renderer/core/paint/paint_layer.h" #include "third_party/blink/renderer/core/paint/paint_layer.h"
...@@ -57,32 +56,24 @@ RenderedPosition::RenderedPosition(const VisiblePositionInFlatTree& position) ...@@ -57,32 +56,24 @@ RenderedPosition::RenderedPosition(const VisiblePositionInFlatTree& position)
RenderedPosition::RenderedPosition(const Position& position, RenderedPosition::RenderedPosition(const Position& position,
TextAffinity affinity) TextAffinity affinity)
: layout_object_(nullptr), inline_box_(nullptr), offset_(0) { : inline_box_(nullptr), offset_(0) {
if (position.IsNull()) if (position.IsNull())
return; return;
InlineBoxPosition box_position = InlineBoxPosition box_position =
ComputeInlineBoxPosition(PositionWithAffinity(position, affinity)); ComputeInlineBoxPosition(PositionWithAffinity(position, affinity));
inline_box_ = box_position.inline_box; inline_box_ = box_position.inline_box;
offset_ = box_position.offset_in_box; offset_ = box_position.offset_in_box;
if (inline_box_) {
layout_object_ =
LineLayoutAPIShim::LayoutObjectFrom(inline_box_->GetLineLayoutItem());
}
} }
RenderedPosition::RenderedPosition(const PositionInFlatTree& position, RenderedPosition::RenderedPosition(const PositionInFlatTree& position,
TextAffinity affinity) TextAffinity affinity)
: layout_object_(nullptr), inline_box_(nullptr), offset_(0) { : inline_box_(nullptr), offset_(0) {
if (position.IsNull()) if (position.IsNull())
return; return;
InlineBoxPosition box_position = ComputeInlineBoxPosition( InlineBoxPosition box_position = ComputeInlineBoxPosition(
PositionInFlatTreeWithAffinity(position, affinity)); PositionInFlatTreeWithAffinity(position, affinity));
inline_box_ = box_position.inline_box; inline_box_ = box_position.inline_box;
offset_ = box_position.offset_in_box; offset_ = box_position.offset_in_box;
if (inline_box_) {
layout_object_ =
LineLayoutAPIShim::LayoutObjectFrom(inline_box_->GetLineLayoutItem());
}
} }
const InlineBox* RenderedPosition::PrevLeafChild() const { const InlineBox* RenderedPosition::PrevLeafChild() const {
...@@ -98,8 +89,7 @@ const InlineBox* RenderedPosition::NextLeafChild() const { ...@@ -98,8 +89,7 @@ const InlineBox* RenderedPosition::NextLeafChild() const {
} }
bool RenderedPosition::IsEquivalent(const RenderedPosition& other) const { bool RenderedPosition::IsEquivalent(const RenderedPosition& other) const {
return (layout_object_ == other.layout_object_ && return (inline_box_ == other.inline_box_ && offset_ == other.offset_) ||
inline_box_ == other.inline_box_ && offset_ == other.offset_) ||
(AtLeftmostOffsetInBox() && other.AtRightmostOffsetInBox() && (AtLeftmostOffsetInBox() && other.AtRightmostOffsetInBox() &&
PrevLeafChild() == other.inline_box_) || PrevLeafChild() == other.inline_box_) ||
(AtRightmostOffsetInBox() && other.AtLeftmostOffsetInBox() && (AtRightmostOffsetInBox() && other.AtLeftmostOffsetInBox() &&
...@@ -126,9 +116,7 @@ RenderedPosition RenderedPosition::LeftBoundaryOfBidiRun( ...@@ -126,9 +116,7 @@ RenderedPosition RenderedPosition::LeftBoundaryOfBidiRun(
const InlineBox* const box = const InlineBox* const box =
InlineBoxTraversal::FindLeftBoundaryOfEntireBidiRunIgnoringLineBreak( InlineBoxTraversal::FindLeftBoundaryOfEntireBidiRunIgnoringLineBreak(
*inline_box_, bidi_level_of_run); *inline_box_, bidi_level_of_run);
return RenderedPosition( return RenderedPosition(box, box->CaretLeftmostOffset());
LineLayoutAPIShim::LayoutObjectFrom(box->GetLineLayoutItem()), box,
box->CaretLeftmostOffset());
} }
RenderedPosition RenderedPosition::RightBoundaryOfBidiRun( RenderedPosition RenderedPosition::RightBoundaryOfBidiRun(
...@@ -139,9 +127,7 @@ RenderedPosition RenderedPosition::RightBoundaryOfBidiRun( ...@@ -139,9 +127,7 @@ RenderedPosition RenderedPosition::RightBoundaryOfBidiRun(
const InlineBox* const box = const InlineBox* const box =
InlineBoxTraversal::FindRightBoundaryOfEntireBidiRunIgnoringLineBreak( InlineBoxTraversal::FindRightBoundaryOfEntireBidiRunIgnoringLineBreak(
*inline_box_, bidi_level_of_run); *inline_box_, bidi_level_of_run);
return RenderedPosition( return RenderedPosition(box, box->CaretRightmostOffset());
LineLayoutAPIShim::LayoutObjectFrom(box->GetLineLayoutItem()), box,
box->CaretRightmostOffset());
} }
bool RenderedPosition::AtLeftBoundaryOfBidiRun( bool RenderedPosition::AtLeftBoundaryOfBidiRun(
...@@ -199,8 +185,10 @@ bool RenderedPosition::AtRightBoundaryOfBidiRun( ...@@ -199,8 +185,10 @@ bool RenderedPosition::AtRightBoundaryOfBidiRun(
Position RenderedPosition::PositionAtLeftBoundaryOfBiDiRun() const { Position RenderedPosition::PositionAtLeftBoundaryOfBiDiRun() const {
DCHECK(AtLeftBoundaryOfBidiRun()); DCHECK(AtLeftBoundaryOfBidiRun());
if (AtLeftmostOffsetInBox()) if (AtLeftmostOffsetInBox()) {
return Position::EditingPositionOf(layout_object_->GetNode(), offset_); return Position::EditingPositionOf(
inline_box_->GetLineLayoutItem().GetNode(), offset_);
}
return Position::EditingPositionOf( return Position::EditingPositionOf(
NextLeafChild()->GetLineLayoutItem().GetNode(), NextLeafChild()->GetLineLayoutItem().GetNode(),
...@@ -210,8 +198,10 @@ Position RenderedPosition::PositionAtLeftBoundaryOfBiDiRun() const { ...@@ -210,8 +198,10 @@ Position RenderedPosition::PositionAtLeftBoundaryOfBiDiRun() const {
Position RenderedPosition::PositionAtRightBoundaryOfBiDiRun() const { Position RenderedPosition::PositionAtRightBoundaryOfBiDiRun() const {
DCHECK(AtRightBoundaryOfBidiRun()); DCHECK(AtRightBoundaryOfBidiRun());
if (AtRightmostOffsetInBox()) if (AtRightmostOffsetInBox()) {
return Position::EditingPositionOf(layout_object_->GetNode(), offset_); return Position::EditingPositionOf(
inline_box_->GetLineLayoutItem().GetNode(), offset_);
}
return Position::EditingPositionOf( return Position::EditingPositionOf(
PrevLeafChild()->GetLineLayoutItem().GetNode(), PrevLeafChild()->GetLineLayoutItem().GetNode(),
......
...@@ -40,7 +40,6 @@ ...@@ -40,7 +40,6 @@
namespace blink { namespace blink {
class FrameSelection; class FrameSelection;
class LayoutObject;
struct CompositedSelection; struct CompositedSelection;
class CORE_EXPORT RenderedPosition { class CORE_EXPORT RenderedPosition {
...@@ -54,7 +53,7 @@ class CORE_EXPORT RenderedPosition { ...@@ -54,7 +53,7 @@ class CORE_EXPORT RenderedPosition {
RenderedPosition(const PositionInFlatTree&, TextAffinity); RenderedPosition(const PositionInFlatTree&, TextAffinity);
bool IsEquivalent(const RenderedPosition&) const; bool IsEquivalent(const RenderedPosition&) const;
bool IsNull() const { return !layout_object_; } bool IsNull() const { return !inline_box_; }
const RootInlineBox* RootBox() const { const RootInlineBox* RootBox() const {
return inline_box_ ? &inline_box_->Root() : nullptr; return inline_box_ ? &inline_box_->Root() : nullptr;
} }
...@@ -89,7 +88,7 @@ class CORE_EXPORT RenderedPosition { ...@@ -89,7 +88,7 @@ class CORE_EXPORT RenderedPosition {
private: private:
bool operator==(const RenderedPosition&) const { return false; } 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* PrevLeafChild() const;
const InlineBox* NextLeafChild() const; const InlineBox* NextLeafChild() const;
...@@ -104,7 +103,6 @@ class CORE_EXPORT RenderedPosition { ...@@ -104,7 +103,6 @@ class CORE_EXPORT RenderedPosition {
bool AtRightBoundaryOfBidiRun(ShouldMatchBidiLevel, bool AtRightBoundaryOfBidiRun(ShouldMatchBidiLevel,
unsigned char bidi_level_of_run) const; unsigned char bidi_level_of_run) const;
const LayoutObject* layout_object_;
const InlineBox* inline_box_; const InlineBox* inline_box_;
int offset_; int offset_;
...@@ -113,12 +111,10 @@ class CORE_EXPORT RenderedPosition { ...@@ -113,12 +111,10 @@ class CORE_EXPORT RenderedPosition {
}; };
inline RenderedPosition::RenderedPosition() inline RenderedPosition::RenderedPosition()
: layout_object_(nullptr), inline_box_(nullptr), offset_(0) {} : inline_box_(nullptr), offset_(0) {}
inline RenderedPosition::RenderedPosition(const LayoutObject* layout_object, inline RenderedPosition::RenderedPosition(const InlineBox* box, int offset)
const InlineBox* box, : inline_box_(box), offset_(offset) {}
int offset)
: layout_object_(layout_object), inline_box_(box), offset_(offset) {}
} // namespace blink } // 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