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