Commit 99d9042a authored by Oriol Brufau's avatar Oriol Brufau Committed by Commit Bot

[css-pseudo] Remove LayoutListMarker::list_item_

LayoutListMarker used to have a list_item_ member that was a pointer to
the LayoutListItem that originated the marker.

Now that markers are tree-abiding psedudo-elements, we can just get the
pseudo-element node of the LayoutListMarker, retrieve its parent node,
and obtain is associated LayoutObject.

So this patch removes the no longer needed list_item_.
This should have no effect in practice.

BUG=457718

Change-Id: Ic4c4b1262feae32474fb279f2da7017ab081eeb2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2079112
Commit-Queue: Oriol Brufau <obrufau@igalia.com>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#745434}
parent 385d1322
......@@ -42,9 +42,7 @@ const int kCMarkerPaddingPx = 7;
const int kCUAMarkerMarginEm = 1;
LayoutListMarker::LayoutListMarker(Element* element) : LayoutBox(element) {
LayoutObject* list_item = element->parentNode()->GetLayoutObject();
DCHECK(list_item->IsListItem());
list_item_ = ToLayoutListItem(list_item);
DCHECK(ListItem());
SetInline(true);
SetIsAtomicInlineLevel(true);
}
......@@ -57,6 +55,13 @@ void LayoutListMarker::WillBeDestroyed() {
LayoutBox::WillBeDestroyed();
}
const LayoutListItem* LayoutListMarker::ListItem() const {
LayoutObject* list_item = GetNode()->parentNode()->GetLayoutObject();
DCHECK(list_item);
DCHECK(list_item->IsListItem());
return ToLayoutListItem(list_item);
}
LayoutSize LayoutListMarker::ImageBulletSize() const {
DCHECK(IsImage());
const SimpleFontData* font_data = StyleRef().GetFont().PrimaryFont();
......@@ -123,14 +128,15 @@ void LayoutListMarker::UpdateLayout() {
LayoutAnalyzer::Scope analyzer(*this);
LayoutUnit block_offset = LogicalTop();
for (LayoutBox* o = ParentBox(); o && o != ListItem(); o = o->ParentBox()) {
const LayoutListItem* list_item = ListItem();
for (LayoutBox* o = ParentBox(); o && o != list_item; o = o->ParentBox()) {
block_offset += o->LogicalTop();
}
if (ListItem()->StyleRef().IsLeftToRightDirection()) {
line_offset_ = ListItem()->LogicalLeftOffsetForLine(
if (list_item->StyleRef().IsLeftToRightDirection()) {
line_offset_ = list_item->LogicalLeftOffsetForLine(
block_offset, kDoNotIndentText, LayoutUnit());
} else {
line_offset_ = ListItem()->LogicalRightOffsetForLine(
line_offset_ = list_item->LogicalRightOffsetForLine(
block_offset, kDoNotIndentText, LayoutUnit());
}
if (IsImage()) {
......@@ -188,7 +194,7 @@ void LayoutListMarker::UpdateContent() {
break;
case ListStyleCategory::kLanguage:
text_ = list_marker_text::GetText(StyleRef().ListStyleType(),
list_item_->Value());
ListItem()->Value());
break;
case ListStyleCategory::kStaticString:
text_ = StyleRef().ListStyleStringValue();
......@@ -200,7 +206,7 @@ String LayoutListMarker::TextAlternative() const {
if (GetListStyleCategory() == ListStyleCategory::kStaticString)
return text_;
UChar suffix =
list_marker_text::Suffix(StyleRef().ListStyleType(), list_item_->Value());
list_marker_text::Suffix(StyleRef().ListStyleType(), ListItem()->Value());
// Return suffix after the marker text, even in RTL, reflecting speech order.
return text_ + suffix + ' ';
}
......@@ -218,7 +224,7 @@ LayoutUnit LayoutListMarker::GetWidthOfText(ListStyleCategory category) const {
// TODO(wkorman): Look into constructing a text run for both text and suffix
// and painting them together.
UChar suffix[2] = {
list_marker_text::Suffix(StyleRef().ListStyleType(), list_item_->Value()),
list_marker_text::Suffix(StyleRef().ListStyleType(), ListItem()->Value()),
' '};
TextRun run =
ConstructTextRun(font, suffix, 2, StyleRef(), StyleRef().Direction());
......@@ -343,7 +349,7 @@ LayoutUnit LayoutListMarker::LineHeight(
LineDirectionMode direction,
LinePositionMode line_position_mode) const {
if (!IsImage())
return list_item_->LineHeight(first_line, direction,
return ListItem()->LineHeight(first_line, direction,
kPositionOfInteriorLineBoxes);
return LayoutBox::LineHeight(first_line, direction, line_position_mode);
}
......@@ -355,7 +361,7 @@ LayoutUnit LayoutListMarker::BaselinePosition(
LinePositionMode line_position_mode) const {
DCHECK_EQ(line_position_mode, kPositionOnContainingLine);
if (!IsImage())
return list_item_->BaselinePosition(baseline_type, first_line, direction,
return ListItem()->BaselinePosition(baseline_type, first_line, direction,
kPositionOfInteriorLineBoxes);
return LayoutBox::BaselinePosition(baseline_type, first_line, direction,
line_position_mode);
......@@ -437,9 +443,10 @@ LayoutListMarker::ListStyleCategory LayoutListMarker::GetListStyleCategory(
}
bool LayoutListMarker::IsInside() const {
const ComputedStyle& parent_style = list_item_->StyleRef();
const LayoutListItem* list_item = ListItem();
const ComputedStyle& parent_style = list_item->StyleRef();
return parent_style.ListStylePosition() == EListStylePosition::kInside ||
(IsA<HTMLLIElement>(list_item_->GetNode()) &&
(IsA<HTMLLIElement>(list_item->GetNode()) &&
!parent_style.IsInsideListElement());
}
......
......@@ -72,7 +72,7 @@ class CORE_EXPORT LayoutListMarker final : public LayoutBox {
bool IsImage() const override;
const StyleImage* GetImage() const { return image_.Get(); }
const LayoutListItem* ListItem() const { return list_item_; }
const LayoutListItem* ListItem() const;
LayoutSize ImageBulletSize() const;
const char* GetName() const override { return "LayoutListMarker"; }
......@@ -120,7 +120,6 @@ class CORE_EXPORT LayoutListMarker final : public LayoutBox {
String text_;
Persistent<StyleImage> image_;
LayoutListItem* list_item_;
LayoutUnit line_offset_;
};
......
......@@ -110,8 +110,7 @@ void ListMarkerPainter::Paint(const PaintInfo& paint_info) {
Color color(layout_list_marker_.ResolveColor(GetCSSPropertyColor()));
if (BoxModelObjectPainter::ShouldForceWhiteBackgroundForPrintEconomy(
layout_list_marker_.ListItem()->GetDocument(),
layout_list_marker_.StyleRef()))
layout_list_marker_.GetDocument(), layout_list_marker_.StyleRef()))
color = TextPainter::TextColorForWhiteBackground(color);
// Apply the color to the list marker text.
......
......@@ -65,7 +65,6 @@
#include "third_party/blink/renderer/core/layout/layout_html_canvas.h"
#include "third_party/blink/renderer/core/layout/layout_image.h"
#include "third_party/blink/renderer/core/layout/layout_inline.h"
#include "third_party/blink/renderer/core/layout/layout_list_item.h"
#include "third_party/blink/renderer/core/layout/layout_list_marker.h"
#include "third_party/blink/renderer/core/layout/layout_replaced.h"
#include "third_party/blink/renderer/core/layout/layout_table.h"
......@@ -263,8 +262,10 @@ Node* AXLayoutObject::GetNodeOrContainingBlockNode() const {
if (IsDetached())
return nullptr;
if (layout_object_->IsListMarker())
return ToLayoutListMarker(layout_object_)->ListItem()->GetNode();
if (layout_object_->IsListMarker()) {
// Return the originating list item node.
return layout_object_->GetNode()->parentNode();
}
if (layout_object_->IsAnonymous()) {
if (LayoutBlock* layout_block =
......
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