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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutListItem.cpp

Issue 2328623003: Fix incorrectly positioned block element inside list-style-position:inside item (Closed)
Patch Set: fix test expectations Created 4 years, 3 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
« no previous file with comments | « third_party/WebKit/LayoutTests/editing/pasteboard/drag-drop-list-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/LayoutListItem.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutListItem.cpp b/third_party/WebKit/Source/core/layout/LayoutListItem.cpp
index badb3a06f52091495cb3760cd7c472f975a045fc..6c6c9f320e1e03a2107b59d0cfb4a24107d859fe 100644
--- a/third_party/WebKit/Source/core/layout/LayoutListItem.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutListItem.cpp
@@ -23,7 +23,6 @@
#include "core/layout/LayoutListItem.h"
-#include "core/HTMLNames.h"
#include "core/dom/shadow/FlatTreeTraversal.h"
#include "core/html/HTMLOListElement.h"
#include "core/layout/LayoutListMarker.h"
@@ -33,7 +32,39 @@
namespace blink {
-using namespace HTMLNames;
+namespace {
+LayoutObject* getParentOfFirstLineBox(LayoutBlockFlow* curr, LayoutListMarker* marker)
eae 2016/09/09 08:55:56 Why not make it a static inline instead?
Gleb Lanbin 2016/09/09 16:06:53 'inline' is recommended for function that are smal
+{
+ LayoutObject* firstChild = curr->firstChild();
+ if (!firstChild)
+ return nullptr;
+
+ bool inQuirksMode = curr->document().inQuirksMode();
+ for (LayoutObject* currChild = firstChild; currChild; currChild = currChild->nextSibling()) {
+ if (currChild == marker)
+ continue;
+
+ if (currChild->isInline() && (!currChild->isLayoutInline() || curr->generatesLineBoxesForInlineChild(currChild)))
+ return curr;
+
+ if (currChild->isFloating() || currChild->isOutOfFlowPositioned())
+ continue;
+
+ if (!currChild->isLayoutBlockFlow() || (currChild->isBox() && toLayoutBox(currChild)->isWritingModeRoot()))
+ break;
+
+ if (curr->isListItem() && inQuirksMode && currChild->node()
+ && (isHTMLUListElement(*currChild->node()) || isHTMLOListElement(*currChild->node())))
+ break;
+
+ LayoutObject* lineBox = getParentOfFirstLineBox(toLayoutBlockFlow(currChild), marker);
+ if (lineBox)
+ return lineBox;
+ }
+
+ return nullptr;
+}
+} // namespace
LayoutListItem::LayoutListItem(Element* element)
: LayoutBlockFlow(element)
@@ -245,38 +276,6 @@ bool LayoutListItem::isEmpty() const
return lastChild() == m_marker;
}
-static LayoutObject* getParentOfFirstLineBox(LayoutBlockFlow* curr, LayoutObject* marker)
-{
- LayoutObject* firstChild = curr->firstChild();
- if (!firstChild)
- return nullptr;
-
- bool inQuirksMode = curr->document().inQuirksMode();
- for (LayoutObject* currChild = firstChild; currChild; currChild = currChild->nextSibling()) {
- if (currChild == marker)
- continue;
-
- if (currChild->isInline() && (!currChild->isLayoutInline() || curr->generatesLineBoxesForInlineChild(currChild)))
- return curr;
-
- if (currChild->isFloating() || currChild->isOutOfFlowPositioned())
- continue;
-
- if (!currChild->isLayoutBlockFlow() || (currChild->isBox() && toLayoutBox(currChild)->isWritingModeRoot()))
- break;
-
- if (curr->isListItem() && inQuirksMode && currChild->node()
- && (isHTMLUListElement(*currChild->node()) || isHTMLOListElement(*currChild->node())))
- break;
-
- LayoutObject* lineBox = getParentOfFirstLineBox(toLayoutBlockFlow(currChild), marker);
- if (lineBox)
- return lineBox;
- }
-
- return nullptr;
-}
-
void LayoutListItem::updateValue()
{
if (!m_hasExplicitValue) {
@@ -299,7 +298,8 @@ bool LayoutListItem::updateMarkerLocation()
ASSERT(m_marker);
LayoutObject* markerParent = m_marker->parent();
- LayoutObject* lineBoxParent = getParentOfFirstLineBox(this, m_marker);
+ // list-style-position:inside makes the ::marker pseudo an ordinary position:static element that should be attached to LayoutListItem block.
+ LayoutObject* lineBoxParent = m_marker->isInside() ? this : getParentOfFirstLineBox(this, m_marker);
if (!lineBoxParent) {
// If the marker is currently contained inside an anonymous box, then we
// are the only item in that anonymous box (since no line box parent was
« no previous file with comments | « third_party/WebKit/LayoutTests/editing/pasteboard/drag-drop-list-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698