Title: [271773] trunk/Source/WebCore
- Revision
- 271773
- Author
- [email protected]
- Date
- 2021-01-22 19:55:16 -0800 (Fri, 22 Jan 2021)
Log Message
[LFC][RenderTreeDump] Expand RenderInline 0 height quirk logic to previous/next siblings
https://bugs.webkit.org/show_bug.cgi?id=220884
Reviewed by Simon Fraser.
Check the previous/next siblings to see whether we should apply the zero-height quirk on the current RenderInline.
Note that this does not change the RenderInlines' reported height values on trunk.
However it greatly helps to reduce the required rebaseline when LFC's inline box support is enabled (see webkit.org/b/220148).
* rendering/RenderInline.cpp:
(WebCore::RenderInline::shouldCreateLineBoxes const):
(WebCore::RenderInline::updateAlwaysCreateLineBoxes):
* rendering/RenderInline.h:
* rendering/RenderTreeAsText.cpp:
(WebCore::isRenderInlineEmpty):
(WebCore::hasNonEmptySibling):
(WebCore::RenderTreeAsText::writeRenderObject):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (271772 => 271773)
--- trunk/Source/WebCore/ChangeLog 2021-01-23 02:13:17 UTC (rev 271772)
+++ trunk/Source/WebCore/ChangeLog 2021-01-23 03:55:16 UTC (rev 271773)
@@ -1,3 +1,23 @@
+2021-01-22 Zalan Bujtas <[email protected]>
+
+ [LFC][RenderTreeDump] Expand RenderInline 0 height quirk logic to previous/next siblings
+ https://bugs.webkit.org/show_bug.cgi?id=220884
+
+ Reviewed by Simon Fraser.
+
+ Check the previous/next siblings to see whether we should apply the zero-height quirk on the current RenderInline.
+ Note that this does not change the RenderInlines' reported height values on trunk.
+ However it greatly helps to reduce the required rebaseline when LFC's inline box support is enabled (see webkit.org/b/220148).
+
+ * rendering/RenderInline.cpp:
+ (WebCore::RenderInline::shouldCreateLineBoxes const):
+ (WebCore::RenderInline::updateAlwaysCreateLineBoxes):
+ * rendering/RenderInline.h:
+ * rendering/RenderTreeAsText.cpp:
+ (WebCore::isRenderInlineEmpty):
+ (WebCore::hasNonEmptySibling):
+ (WebCore::RenderTreeAsText::writeRenderObject):
+
2021-01-22 Alex Christensen <[email protected]>
REGRESSION(r266148) Cancelling a navigation in decidePolicyForNavigationAction should not suspend the previous document's font loading timer
Modified: trunk/Source/WebCore/rendering/RenderInline.cpp (271772 => 271773)
--- trunk/Source/WebCore/rendering/RenderInline.cpp 2021-01-23 02:13:17 UTC (rev 271772)
+++ trunk/Source/WebCore/rendering/RenderInline.cpp 2021-01-23 03:55:16 UTC (rev 271773)
@@ -203,18 +203,14 @@
#endif
}
-void RenderInline::updateAlwaysCreateLineBoxes(bool fullLayout)
+bool RenderInline::shouldCreateLineBoxes() const
{
- // Once we have been tainted once, just assume it will happen again. This way effects like hover highlighting that change the
- // background color will only cause a layout on the first rollover.
- if (alwaysCreateLineBoxes())
- return;
-
+ // Test if we can get away with culling.
auto* parentStyle = &parent()->style();
RenderInline* parentRenderInline = is<RenderInline>(*parent()) ? downcast<RenderInline>(parent()) : nullptr;
auto hasHardLineBreakChildOnly = firstChild() && firstChild() == lastChild() && firstChild()->isBR();
bool checkFonts = document().inNoQuirksMode();
- bool alwaysCreateLineBoxes = (parentRenderInline && parentRenderInline->alwaysCreateLineBoxes())
+ auto needsLineBoxes = (parentRenderInline && parentRenderInline->alwaysCreateLineBoxes())
|| (parentRenderInline && parentStyle->verticalAlign() != VerticalAlign::Baseline)
|| style().verticalAlign() != VerticalAlign::Baseline
|| style().textEmphasisMark() != TextEmphasisMark::None
@@ -222,20 +218,27 @@
|| parentStyle->lineHeight() != style().lineHeight()))
|| hasHardLineBreakChildOnly;
- if (!alwaysCreateLineBoxes && checkFonts && view().usesFirstLineRules()) {
+ if (!needsLineBoxes && checkFonts && view().usesFirstLineRules()) {
// Have to check the first line style as well.
parentStyle = &parent()->firstLineStyle();
auto& childStyle = firstLineStyle();
- alwaysCreateLineBoxes = !parentStyle->fontCascade().fontMetrics().hasIdenticalAscentDescentAndLineGap(childStyle.fontCascade().fontMetrics())
+ needsLineBoxes = !parentStyle->fontCascade().fontMetrics().hasIdenticalAscentDescentAndLineGap(childStyle.fontCascade().fontMetrics())
|| childStyle.verticalAlign() != VerticalAlign::Baseline
|| parentStyle->lineHeight() != childStyle.lineHeight();
}
+ return needsLineBoxes;
+}
- if (alwaysCreateLineBoxes) {
- if (!fullLayout)
- dirtyLineBoxes(false);
- setAlwaysCreateLineBoxes();
- }
+void RenderInline::updateAlwaysCreateLineBoxes(bool fullLayout)
+{
+ // Once we have been tainted once, just assume it will happen again. This way effects like hover highlighting that change the
+ // background color will only cause a layout on the first rollover.
+ if (alwaysCreateLineBoxes() || !shouldCreateLineBoxes())
+ return;
+
+ setAlwaysCreateLineBoxes();
+ if (!fullLayout)
+ dirtyLineBoxes(false);
}
void RenderInline::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
Modified: trunk/Source/WebCore/rendering/RenderInline.h (271772 => 271773)
--- trunk/Source/WebCore/rendering/RenderInline.h 2021-01-23 02:13:17 UTC (rev 271772)
+++ trunk/Source/WebCore/rendering/RenderInline.h 2021-01-23 03:55:16 UTC (rev 271773)
@@ -84,6 +84,7 @@
bool alwaysCreateLineBoxes() const { return renderInlineAlwaysCreatesLineBoxes(); }
void setAlwaysCreateLineBoxes() { setRenderInlineAlwaysCreatesLineBoxes(true); }
+ bool shouldCreateLineBoxes() const;
void updateAlwaysCreateLineBoxes(bool fullLayout);
bool hitTestCulledInline(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset);
Modified: trunk/Source/WebCore/rendering/RenderTreeAsText.cpp (271772 => 271773)
--- trunk/Source/WebCore/rendering/RenderTreeAsText.cpp 2021-01-23 02:13:17 UTC (rev 271772)
+++ trunk/Source/WebCore/rendering/RenderTreeAsText.cpp 2021-01-23 03:55:16 UTC (rev 271773)
@@ -35,6 +35,7 @@
#include "HTMLElement.h"
#include "HTMLNames.h"
#include "HTMLSpanElement.h"
+#include "InlineIterator.h"
#include "InlineTextBox.h"
#include "LayoutIntegrationRunIterator.h"
#include "Logging.h"
@@ -172,6 +173,43 @@
return result.toString();
}
+static inline bool isRenderInlineEmpty(const RenderInline& inlineRenderer)
+{
+ if (isEmptyInline(inlineRenderer))
+ return true;
+
+ for (auto& child : childrenOfType<RenderObject>(inlineRenderer)) {
+ if (child.isFloatingOrOutOfFlowPositioned())
+ continue;
+ auto isChildEmpty = false;
+ if (is<RenderInline>(child))
+ isChildEmpty = isRenderInlineEmpty(downcast<RenderInline>(child));
+ else if (is<RenderText>(child))
+ isChildEmpty = !downcast<RenderText>(child).linesBoundingBox().height();
+ if (!isChildEmpty)
+ return false;
+ }
+ return true;
+}
+
+static inline bool hasNonEmptySibling(const RenderInline& inlineRenderer)
+{
+ auto* parent = inlineRenderer.parent();
+ if (!parent)
+ return false;
+
+ for (auto& sibling : childrenOfType<RenderObject>(*parent)) {
+ if (&sibling == &inlineRenderer || sibling.isFloatingOrOutOfFlowPositioned())
+ continue;
+ if (!is<RenderInline>(sibling))
+ return true;
+ auto& siblingRendererInline = downcast<RenderInline>(sibling);
+ if (siblingRendererInline.shouldCreateLineBoxes() || !isRenderInlineEmpty(siblingRendererInline))
+ return true;
+ }
+ return false;
+}
+
void RenderTreeAsText::writeRenderObject(TextStream& ts, const RenderObject& o, OptionSet<RenderAsTextFlag> behavior)
{
ts << o.renderName();
@@ -228,21 +266,11 @@
if (inlineFlow.marginStart() || inlineFlow.marginEnd())
return height;
// This is mostly pre/post continuation content. Also see webkit.org/b/220735
- if (inlineFlow.previousSibling())
+ if (hasNonEmptySibling(inlineFlow))
return height;
- if (inlineFlow.nextSibling() && !inlineFlow.document().inQuirksMode())
- return height;
- if (auto* firstChild = inlineFlow.firstChild()) {
- if (firstChild != inlineFlow.lastChild())
- return height;
- auto childIsEmpty = false;
- if (is<RenderText>(*firstChild))
- childIsEmpty = !downcast<RenderText>(*firstChild).linesBoundingBox().height();
- else if (is<RenderInline>(*firstChild))
- childIsEmpty = !downcast<RenderInline>(*firstChild).linesBoundingBox().height();
- return childIsEmpty ? 0 : height;
- }
- return 0;
+ if (isRenderInlineEmpty(inlineFlow))
+ return 0;
+ return height;
};
r = IntRect(0, 0, width, inlineHeight());
adjustForTableCells = false;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes