Bug 60044

Summary: Extract LineInfo class
Product: WebKit Reporter: Levi Weintraub <leviw>
Component: Layout and RenderingAssignee: Levi Weintraub <leviw>
Status: RESOLVED FIXED    
Severity: Normal CC: eric, hyatt, jamesr, mitz, rniwa, simon.fraser
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 57779    
Attachments:
Description Flags
First patch
none
Patch none

Description Levi Weintraub 2011-05-03 11:29:51 PDT
isFirstLine, isLastLine, isEmpty, and previousLineBrokeCleanly are identifiers used repeatedly through RenderBlock/RenderBlockLineLayout to track identifying line information. This could be packaged into a class that represents relevant information about a line.
Comment 1 Ryosuke Niwa 2011-05-03 11:32:05 PDT
Like!
Comment 2 Levi Weintraub 2011-05-03 11:37:27 PDT
Created attachment 92096 [details]
First patch

Removing some unused arguments that leak references to these boolean values to external code.
Comment 3 Eric Seidel (no email) 2011-05-03 12:04:56 PDT
Comment on attachment 92096 [details]
First patch

View in context: https://bugs.webkit.org/attachment.cgi?id=92096&action=review

> Source/WebCore/rendering/RenderBlock.h:492
> +    static bool requiresLineBox(const InlineIterator&, bool isLineEmpty = true, bool previousLineBrokeCleanly = true);

I take it this is called other places with isLineEmpty and previousLineBrokeCleanly?  This patch is just removing some unused plumbing?
Comment 4 Ryosuke Niwa 2011-05-03 12:07:58 PDT
(In reply to comment #3)
> (From update of attachment 92096 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=92096&action=review
> 
> > Source/WebCore/rendering/RenderBlock.h:492
> > +    static bool requiresLineBox(const InlineIterator&, bool isLineEmpty = true, bool previousLineBrokeCleanly = true);
> 
> I take it this is called other places with isLineEmpty and previousLineBrokeCleanly?  This patch is just removing some unused plumbing?

Yes, this patch only removes unused arguments from generatesLineBoxesForInlineChild.
Comment 5 Levi Weintraub 2011-05-03 13:40:10 PDT
Created attachment 92117 [details]
Patch
Comment 6 Eric Seidel (no email) 2011-05-03 13:44:45 PDT
Comment on attachment 92117 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=92117&action=review

LGTM.

> Source/WebCore/rendering/RenderBlockLineLayout.cpp:80
> +    void setPreviousLineBrokeCleanly(bool previousLineBrokeCleanly) { m_previousLineBrokeCleanly = previousLineBrokeCleanly; }

I used to think we normally put a \n before private.  But since thsi is the 3rd time I've made ethis comment today, I think my sense may be off. :)
Comment 7 Levi Weintraub 2011-05-03 13:45:55 PDT
(In reply to comment #6)
> (From update of attachment 92117 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=92117&action=review
> 
> LGTM.
> 
> > Source/WebCore/rendering/RenderBlockLineLayout.cpp:80
> > +    void setPreviousLineBrokeCleanly(bool previousLineBrokeCleanly) { m_previousLineBrokeCleanly = previousLineBrokeCleanly; }
> 
> I used to think we normally put a \n before private.  But since thsi is the 3rd time I've made ethis comment today, I think my sense may be off. :)

Thanks for the reviews!
Comment 8 Levi Weintraub 2011-05-03 13:49:23 PDT
Committed r85652: <http://trac.webkit.org/changeset/85652>
Comment 9 Ryosuke Niwa 2011-05-03 13:50:37 PDT
Comment on attachment 92117 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=92117&action=review

> Source/WebCore/rendering/RenderBlock.h:46
> +class LineInfo;

Nit: you should declare this right above LineWidth.

> Source/WebCore/rendering/RenderBlockLineLayout.cpp:69
> +        : m_isFirstLine(true)
> +        , m_isLastLine(false)
> +        , m_isEmpty(true)
> +        , m_previousLineBrokeCleanly(true)

I feel like some of these member variables being true by default is arbitrary.  Can we add an enum flags that the constructor takes?

> Source/WebCore/rendering/RenderBlockLineLayout.cpp:1445
> -bool RenderBlock::requiresLineBox(const InlineIterator& it, bool isLineEmpty, bool previousLineBrokeCleanly)
> +static bool requiresLineBox(const InlineIterator& it, const LineInfo& lineInfo = LineInfo())

Nice!

> Source/WebCore/rendering/RenderBlockLineLayout.cpp:1458
> +    && !skipNonBreakingSpace(it, lineInfo);

Nit: You need one more indentation here.

> Source/WebCore/rendering/RenderBlockLineLayout.cpp:1725
> +    bool startingNewParagraph = lineInfo.previousLineBrokeCleanly();

Maybe previousLineBrokeCleanly is a bad name for the member function?
Comment 10 Ryosuke Niwa 2011-05-03 13:51:06 PDT
Oops, I cleared eric's r+.
Comment 11 Daniel Bates 2011-05-03 16:58:13 PDT
Comment on attachment 92117 [details]
Patch

Clearing review flag to remove this patch from the review queue since it was already committed as per comment 8.