Skip to content

Instantly share code, notes, and snippets.

@rniwa
Created April 18, 2013 21:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rniwa/5416511 to your computer and use it in GitHub Desktop.
Save rniwa/5416511 to your computer and use it in GitHub Desktop.
Logging of the number of objects that has floats or regions in the ancestor chain in logicalLeftSelectionOffset and logicalRightSelectionOffset
Index: Source/WebCore/rendering/RenderBlock.cpp
===================================================================
--- Source/WebCore/rendering/RenderBlock.cpp (revision 148625)
+++ Source/WebCore/rendering/RenderBlock.cpp (working copy)
@@ -3703,13 +3703,49 @@
(state == RenderObject::SelectionEnd && !ltr);
}
+#define LSO_LOG 1
+
+#if LSO_LOG
+unsigned llso_calls = 0;
+unsigned llso_calls_with_floats_or_regions_count = 0;
+unsigned llso_level = 0;
+unsigned llso_floats_or_regions_count = 0;
+
+unsigned lrso_calls = 0;
+unsigned lrso_calls_with_floats_or_regions_count = 0;
+unsigned lrso_level = 0;
+unsigned lrso_floats_or_regions_count = 0;
+#endif
+
LayoutUnit RenderBlock::logicalLeftSelectionOffset(RenderBlock* rootBlock, LayoutUnit position)
{
+#if LSO_LOG
+ if (!llso_level) {
+ llso_calls++;
+ llso_floats_or_regions_count = 0;
+ } else if (m_floatingObjects || flowThreadContainingBlock())
+ llso_floats_or_regions_count++;
+#endif
+
LayoutUnit logicalLeft = logicalLeftOffsetForLine(position, false);
if (logicalLeft == logicalLeftOffsetForContent()) {
- if (rootBlock != this)
+ if (rootBlock != this) {
+#if LSO_LOG
+ llso_level++;
+#endif
// The border can potentially be further extended by our containingBlock().
- return containingBlock()->logicalLeftSelectionOffset(rootBlock, position + logicalTop());
+ LayoutUnit u = containingBlock()->logicalLeftSelectionOffset(rootBlock, position + logicalTop());
+#if LSO_LOG
+ llso_level--;
+ if (!llso_level) {
+ if (llso_floats_or_regions_count) {
+ llso_calls_with_floats_or_regions_count++;
+ fprintf(stderr, "Recursive LLSO: %u of %u; encountered %u\n", llso_calls_with_floats_or_regions_count, llso_calls, llso_floats_or_regions_count);
+ }
+ }
+#endif
+ return u;
+ }
return logicalLeft;
} else {
RenderBlock* cb = this;
@@ -3723,11 +3759,33 @@
LayoutUnit RenderBlock::logicalRightSelectionOffset(RenderBlock* rootBlock, LayoutUnit position)
{
+#if LSO_LOG
+ if (!lrso_level) {
+ lrso_calls++;
+ lrso_floats_or_regions_count = 0;
+ } else if (m_floatingObjects || flowThreadContainingBlock())
+ lrso_floats_or_regions_count++;
+#endif
+
LayoutUnit logicalRight = logicalRightOffsetForLine(position, false);
if (logicalRight == logicalRightOffsetForContent()) {
- if (rootBlock != this)
+ if (rootBlock != this) {
+#if LSO_LOG
+ lrso_level++;
+#endif
// The border can potentially be further extended by our containingBlock().
- return containingBlock()->logicalRightSelectionOffset(rootBlock, position + logicalTop());
+ LayoutUnit u = containingBlock()->logicalRightSelectionOffset(rootBlock, position + logicalTop());
+#if LSO_LOG
+ lrso_level--;
+ if (!lrso_level) {
+ if (lrso_floats_or_regions_count) {
+ lrso_calls_with_floats_or_regions_count++;
+ fprintf(stderr, "Recursive LRSO: %u of %u; encountered %u\n", lrso_calls_with_floats_or_regions_count, lrso_calls, lrso_floats_or_regions_count);
+ }
+ }
+#endif
+ return u;
+ }
return logicalRight;
} else {
RenderBlock* cb = this;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment