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

Unified Diff: sky/engine/core/css/resolver/StyleAdjuster.cpp

Issue 729693003: First step at getting rid of anonymous blocks and continuations. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Address review comments Created 6 years, 1 month 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 | « sky/engine/core/css/resolver/StyleAdjuster.h ('k') | sky/engine/core/rendering/RenderBlock.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/engine/core/css/resolver/StyleAdjuster.cpp
diff --git a/sky/engine/core/css/resolver/StyleAdjuster.cpp b/sky/engine/core/css/resolver/StyleAdjuster.cpp
index 2e21d566937c56f9789b71bb69e250e01f550d1c..0977f9bfcb2168291ca3254eb0ffc70207bc7b64 100644
--- a/sky/engine/core/css/resolver/StyleAdjuster.cpp
+++ b/sky/engine/core/css/resolver/StyleAdjuster.cpp
@@ -41,24 +41,68 @@
namespace blink {
+static bool requiresOnlyBlockChildren(RenderStyle* parentStyle)
+{
+ switch (parentStyle->display()) {
+ case PARAGRAPH:
+ case INLINE:
+ return false;
+
+ case BLOCK:
+ case FLEX:
+ case INLINE_FLEX:
+ case INLINE_BLOCK:
+ return true;
+
+ case NONE:
+ ASSERT_NOT_REACHED();
+ return false;
+ }
+}
+
+static EDisplay equivalentInlineDisplay(EDisplay display)
+{
+ switch (display) {
+ // TODO(ojan): Do we need an INLINE_PARAGRAPH display?
+ case PARAGRAPH:
+ return INLINE;
+
+ case BLOCK:
+ return INLINE_BLOCK;
+
+ case FLEX:
+ return INLINE_FLEX;
+
+ case INLINE:
+ case INLINE_FLEX:
+ case INLINE_BLOCK:
+ return display;
+
+ case NONE:
+ ASSERT_NOT_REACHED();
+ return NONE;
+ }
+}
+
static EDisplay equivalentBlockDisplay(EDisplay display)
{
switch (display) {
+ case PARAGRAPH:
case BLOCK:
case FLEX:
return display;
+
case INLINE_FLEX:
return FLEX;
case INLINE:
case INLINE_BLOCK:
return BLOCK;
+
case NONE:
ASSERT_NOT_REACHED();
return NONE;
}
- ASSERT_NOT_REACHED();
- return BLOCK;
}
// CSS requires text-decoration to be reset at each DOM element for tables,
@@ -108,7 +152,10 @@ void StyleAdjuster::adjustRenderStyle(RenderStyle* style, RenderStyle* parentSty
if (style->hasOutOfFlowPosition() || element.document().documentElement() == element)
style->setDisplay(equivalentBlockDisplay(style->display()));
- adjustStyleForDisplay(style, parentStyle);
+ if (requiresOnlyBlockChildren(parentStyle))
+ style->setDisplay(equivalentBlockDisplay(style->display()));
+ else
+ style->setDisplay(equivalentInlineDisplay(style->display()));
}
// Make sure our z-index value is only applied if the object is positioned.
@@ -226,11 +273,4 @@ void StyleAdjuster::adjustOverflow(RenderStyle* style)
}
}
-void StyleAdjuster::adjustStyleForDisplay(RenderStyle* style, RenderStyle* parentStyle)
-{
- if (parentStyle->isDisplayFlexibleBox()) {
- style->setDisplay(equivalentBlockDisplay(style->display()));
- }
-}
-
}
« no previous file with comments | « sky/engine/core/css/resolver/StyleAdjuster.h ('k') | sky/engine/core/rendering/RenderBlock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698