Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Unified Diff: Source/core/layout/LayoutListMarker.cpp

Issue 778003003: List marker pseudo elements. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/layout/LayoutListMarker.cpp
diff --git a/Source/core/layout/LayoutListMarker.cpp b/Source/core/layout/LayoutListMarker.cpp
index 01a02be83af6053ee2a2df3d0b530a56b31ed374..59ecd761379bc5d34ebcc180b30997ca5728473c 100644
--- a/Source/core/layout/LayoutListMarker.cpp
+++ b/Source/core/layout/LayoutListMarker.cpp
@@ -25,6 +25,7 @@
#include "config.h"
#include "core/layout/LayoutListMarker.h"
+#include "core/dom/MarkerPseudoElement.h"
#include "core/fetch/ImageResource.h"
#include "core/layout/LayoutAnalyzer.h"
#include "core/layout/LayoutListItem.h"
@@ -1048,6 +1049,15 @@ String listMarkerText(EListStyleType type, int value)
return "";
}
+LayoutListMarker::LayoutListMarker(Element* node, LayoutListItem* item)
+ : LayoutBox(node)
+ , m_listItem(item)
+{
+ // init LayoutObject attributes
+ setInline(true); // our object is Inline
+ setReplaced(true); // pretend to be replaced
esprehn 2015/04/20 16:04:08 Link to the spec?
dsinclair 2015/04/21 20:23:10 This is from the constructor below. I needed to ad
+}
+
LayoutListMarker::LayoutListMarker(LayoutListItem* item)
: LayoutBox(0)
, m_listItem(item)
@@ -1071,9 +1081,9 @@ void LayoutListMarker::destroy()
LayoutListMarker* LayoutListMarker::createAnonymous(LayoutListItem* item)
{
Document& document = item->document();
- LayoutListMarker* renderer = new LayoutListMarker(item);
- renderer->setDocumentForAnonymous(&document);
- return renderer;
+ LayoutListMarker* layoutObject = new LayoutListMarker(item);
+ layoutObject->setDocumentForAnonymous(&document);
+ return layoutObject;
}
void LayoutListMarker::styleWillChange(StyleDifference diff, const ComputedStyle& newStyle)
@@ -1088,6 +1098,13 @@ void LayoutListMarker::styleDidChange(StyleDifference diff, const ComputedStyle*
{
LayoutBox::styleDidChange(diff, oldStyle);
+ if (RuntimeEnabledFeatures::listMarkerPseudoElementEnabled()) {
+ updateMarginsAndContent();
+
+ if (isInside())
+ node()->parentElement()->layoutObject()->containingBlock()->updateLogicalWidth();
esprehn 2015/04/20 16:04:08 You can't update logical widths from inside a styl
dsinclair 2015/04/21 20:23:10 Done. If I remove the updateMarginsAndContent() th
esprehn 2015/04/22 07:45:44 You should do this in layout, we already do for th
+ }
+
if (m_image != style()->listStyleImage()) {
if (m_image)
m_image->removeClient(this);
@@ -1636,16 +1653,8 @@ LayoutRect LayoutListMarker::selectionRectForPaintInvalidation(const LayoutBoxMo
void LayoutListMarker::listItemStyleDidChange()
{
- RefPtr<ComputedStyle> newStyle = ComputedStyle::create();
- // The marker always inherits from the list item, regardless of where it might end
- // up (e.g., in some deeply nested line box). See CSS3 spec.
- newStyle->inheritFrom(m_listItem->styleRef());
- if (style()) {
- // Reuse the current margins. Otherwise resetting the margins to initial values
- // would trigger unnecessary layout.
- newStyle->setMarginStart(style()->marginStart());
- newStyle->setMarginEnd(style()->marginRight());
- }
+ ASSERT(!RuntimeEnabledFeatures::listMarkerPseudoElementEnabled());
+ RefPtr<ComputedStyle> newStyle = MarkerPseudoElement::styleForListMarkerLayoutObject(*m_listItem, style());
setStyle(newStyle.release());
}

Powered by Google App Engine
This is Rietveld 408576698