Changeset 83038 in webkit


Ignore:
Timestamp:
Apr 6, 2011 5:12:58 AM (13 years ago)
Author:
leviw@chromium.org
Message:

2011-04-06 Levi Weintraub <leviw@chromium.org>

Reviewed by Ryosuke Niwa.

Add member functions for determining line/paragraph separation to InlineIterator
https://bugs.webkit.org/show_bug.cgi?id=57938

Adding atTextParagraphSeparator and atParagraphSeparator inline convenience functions to
InlineIterator, where it makes far more sense for them to be. Also moving
shouldPreserveNewline to RenderObject and renaming it preservesNewline.

No new tests as this provides no new functionality.

  • rendering/InlineIterator.h: (WebCore::InlineIterator::atTextParagraphSeparator): (WebCore::InlineIterator::atParagraphSeparator):
  • rendering/RenderBlockLineLayout.cpp: (WebCore::RenderBlock::requiresLineBox): (WebCore::RenderBlock::findNextLineBreak):
  • rendering/RenderObject.h: (WebCore::RenderObject::preservesNewline):
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r83037 r83038  
     12011-04-06  Levi Weintraub  <leviw@chromium.org>
     2
     3        Reviewed by Ryosuke Niwa.
     4
     5        Add member functions for determining line/paragraph separation to InlineIterator
     6        https://bugs.webkit.org/show_bug.cgi?id=57938
     7
     8        Adding atTextParagraphSeparator and atParagraphSeparator inline convenience functions to
     9        InlineIterator, where it makes far more sense for them to be. Also moving
     10        shouldPreserveNewline to RenderObject and renaming it preservesNewline.
     11
     12        No new tests as this provides no new functionality.
     13
     14        * rendering/InlineIterator.h:
     15        (WebCore::InlineIterator::atTextParagraphSeparator):
     16        (WebCore::InlineIterator::atParagraphSeparator):
     17        * rendering/RenderBlockLineLayout.cpp:
     18        (WebCore::RenderBlock::requiresLineBox):
     19        (WebCore::RenderBlock::findNextLineBreak):
     20        * rendering/RenderObject.h:
     21        (WebCore::RenderObject::preservesNewline):
     22
    1232011-04-05  Alexander Pavlov  <apavlov@chromium.org>
    224
  • trunk/Source/WebCore/rendering/InlineIterator.h

    r82793 r83038  
    6868    void increment(InlineBidiResolver* = 0);
    6969    bool atEnd() const;
     70
     71    inline bool atTextParagraphSeparator()
     72    {
     73        return m_obj && m_obj->preservesNewline() && m_obj->isText() && toRenderText(m_obj)->textLength()
     74            && !toRenderText(m_obj)->isWordBreak() && toRenderText(m_obj)->characters()[m_pos] == '\n';
     75    }
     76   
     77    inline bool atParagraphSeparator()
     78    {
     79        return (m_obj && m_obj->isBR()) || atTextParagraphSeparator();
     80    }
    7081
    7182    UChar current() const;
  • trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp

    r82947 r83038  
    13891389}
    13901390
    1391 static inline bool shouldPreserveNewline(RenderObject* object)
    1392 {
    1393 #if ENABLE(SVG)
    1394     if (object->isSVGInlineText())
    1395         return false;
    1396 #endif
    1397 
    1398     return object->style()->preserveNewline();
    1399 }
    1400 
    14011391static bool inlineFlowRequiresLineBox(RenderInline* flow)
    14021392{
     
    14191409
    14201410    UChar current = it.current();
    1421     return current != ' ' && current != '\t' && current != softHyphen && (current != '\n' || shouldPreserveNewline(it.m_obj))
     1411    return current != ' ' && current != '\t' && current != softHyphen && (current != '\n' || it.m_obj->preservesNewline())
    14221412            && !skipNonBreakingSpace(it, isLineEmpty, previousLineBrokeCleanly);
    14231413}
     
    19151905                                    goto end;
    19161906                            }
    1917                             if (lBreak.m_obj && shouldPreserveNewline(lBreak.m_obj) && lBreak.m_obj->isText() && toRenderText(lBreak.m_obj)->textLength() && !toRenderText(lBreak.m_obj)->isWordBreak() && toRenderText(lBreak.m_obj)->characters()[lBreak.m_pos] == '\n') {
     1907                            if (lBreak.atTextParagraphSeparator()) {
    19181908                                if (!stoppedIgnoringSpaces && pos > 0) {
    19191909                                    // We need to stop right before the newline and then start up again.
     
    20562046                    if (nextText->textLength()) {
    20572047                        UChar c = nextText->characters()[0];
    2058                         if (c == ' ' || c == '\t' || (c == '\n' && !shouldPreserveNewline(next)))
     2048                        if (c == ' ' || c == '\t' || (c == '\n' && !next->preservesNewline()))
    20592049                            // If the next item on the line is text, and if we did not end with
    20602050                            // a space, then the next text run continues our word (and so it needs to
  • trunk/Source/WebCore/rendering/RenderObject.h

    r82778 r83038  
    434434    bool hasMask() const { return style() && style()->hasMask(); }
    435435
     436    inline bool preservesNewline() const;
    436437    void drawLineForBoxSide(GraphicsContext*, int x1, int y1, int x2, int y2, BoxSide,
    437438                            Color, EBorderStyle, int adjbw1, int adjbw2);
     
    10381039}
    10391040
     1041inline bool RenderObject::preservesNewline() const
     1042{
     1043#if ENABLE(SVG)
     1044    if (isSVGInlineText())
     1045        return false;
     1046#endif
     1047       
     1048    return style()->preserveNewline();
     1049}
     1050
    10401051inline void makeMatrixRenderable(TransformationMatrix& matrix, bool has3DRendering)
    10411052{
Note: See TracChangeset for help on using the changeset viewer.