Changeset 155957 in webkit


Ignore:
Timestamp:
Sep 17, 2013, 8:13:37 AM (11 years ago)
Author:
Antti Koivisto
Message:

RenderBR should not be RenderText
https://bugs.webkit.org/show_bug.cgi?id=121221

Reviewed by Darin Adler.

Source/WebCore:

Stop inheriting RenderBR from RenderText and make it be a RenderBoxModelObject instead. RenderBR was one
of the few cases where Element renderer was a RenderText. This will enable future cleanups.

RenderBR used little of RenderText mechanisms and was already heavily specialized everywhere. Layout code
didn't care about its text content at all. The new RenderText is also significatly more lightweight
than the old. As a line box it uses plain InlineBox instead of InlineTextBox.

The patch tries to avoid changing test results though there are a few changed render tree dumps without
visual effect. There are also two rendering progressions.

  • accessibility/AccessibilityRenderObject.cpp:

(WebCore::AccessibilityRenderObject::textUnderElement):
(WebCore::AccessibilityRenderObject::computeAccessibilityIsIgnored):

  • dom/ContainerNode.cpp:

(WebCore::ContainerNode::getUpperLeftCorner):

  • dom/Document.cpp:

(WebCore::Document::updateHoverActiveState):

  • dom/Position.cpp:

(WebCore::hasInlineBoxWrapper):
(WebCore::nextRenderedEditable):
(WebCore::previousRenderedEditable):
(WebCore::Position::hasRenderedNonAnonymousDescendantsWithHeight):
(WebCore::Position::getInlineBoxAndOffset):

  • dom/Range.cpp:

(WebCore::Range::textRects):
(WebCore::Range::textQuads):

  • editing/ApplyStyleCommand.cpp:

(WebCore::ApplyStyleCommand::applyInlineStyleToPushDown):

  • editing/Editor.cpp:

(WebCore::findFirstMarkable):

  • editing/TextIterator.cpp:

(WebCore::ignoresContainerClip):

  • editing/VisibleUnits.cpp:

(WebCore::CachedLogicallyOrderedLeafBoxes::previousTextOrLineBreakBox):
(WebCore::CachedLogicallyOrderedLeafBoxes::nextTextOrLineBreakBox):
(WebCore::logicallyPreviousBox):
(WebCore::logicallyNextBox):
(WebCore::wordBreakIteratorForMinOffsetBoundary):
(WebCore::wordBreakIteratorForMaxOffsetBoundary):

  • rendering/InlineBox.cpp:

(WebCore::InlineBox::logicalHeight):
(WebCore::InlineBox::baselinePosition):
(WebCore::InlineBox::lineHeight):
(WebCore::InlineBox::deleteLine):
(WebCore::InlineBox::extractLine):
(WebCore::InlineBox::attachLine):
(WebCore::InlineBox::paint):

  • rendering/InlineBox.h:

(WebCore::InlineBox::isLineBreak):

  • rendering/InlineFlowBox.cpp:

(WebCore::InlineFlowBox::computeOverflow):

  • rendering/InlineIterator.h:

(WebCore::isIteratorTarget):

  • rendering/InlineTextBox.cpp:

(WebCore::InlineTextBox::lineHeight):
(WebCore::InlineTextBox::isLineBreak):

  • rendering/RenderBR.cpp:

(WebCore::RenderBR::RenderBR):
(WebCore::RenderBR::~RenderBR):
(WebCore::RenderBR::createAnonymous):
(WebCore::RenderBR::lineHeight):
(WebCore::RenderBR::baselinePosition):
(WebCore::RenderBR::createInlineBox):
(WebCore::RenderBR::setInlineBoxWrapper):
(WebCore::RenderBR::replaceInlineBoxWrapper):
(WebCore::RenderBR::deleteInlineBoxWrapper):
(WebCore::RenderBR::dirtyLineBoxes):
(WebCore::RenderBR::caretMinOffset):
(WebCore::RenderBR::caretMaxOffset):
(WebCore::RenderBR::canBeSelectionLeaf):
(WebCore::RenderBR::setSelectionState):
(WebCore::RenderBR::localCaretRect):
(WebCore::RenderBR::linesBoundingBox):
(WebCore::RenderBR::absoluteRects):
(WebCore::RenderBR::absoluteQuads):
(WebCore::RenderBR::updateFromStyle):
(WebCore::RenderBR::borderBoundingBox):

  • rendering/RenderBR.h:

(WebCore::toRenderBR):

  • rendering/RenderBlock.cpp:

(WebCore::InlineMinMaxIterator::next):
(WebCore::RenderBlock::updateFirstLetter):

  • rendering/RenderBlockLineLayout.cpp:

(WebCore::createInlineBoxForRenderer):
(WebCore::dirtyLineBoxesForRenderer):
(WebCore::reachedEndOfTextRenderer):
(WebCore::RenderBlock::computeBlockDirectionPositionsForLine):
(WebCore::RenderBlockFlow::layoutInlineChildren):
(WebCore::requiresLineBox):
(WebCore::shouldSkipWhitespaceAfterStartObject):
(WebCore::canBreakAtThisPosition):

  • rendering/RenderInline.cpp:

(WebCore::RenderInline::generateCulledLineBoxRects):
(WebCore::RenderInline::culledInlineFirstLineBox):
(WebCore::RenderInline::culledInlineLastLineBox):
(WebCore::RenderInline::dirtyLineBoxes):

  • rendering/RenderLineBoxList.cpp:

(WebCore::RenderLineBoxList::dirtyLinesFromChangedChild):

  • rendering/RenderMenuList.cpp:

(WebCore::RenderMenuList::RenderMenuList):
(WebCore::RenderMenuList::styleDidChange):
(WebCore::RenderMenuList::setText):
(WebCore::RenderMenuList::text):

  • rendering/RenderMenuList.h:
  • rendering/RenderObject.h:

(WebCore::RenderObject::isBeforeContent):
(WebCore::RenderObject::isAfterContent):

  • rendering/RenderObjectChildList.cpp:

(WebCore::RenderObjectChildList::removeChildNode):

  • rendering/RenderText.cpp:

(WebCore::RenderText::removeAndDestroyTextBoxes):
(WebCore::RenderText::computePreferredLogicalWidths):
(WebCore::RenderText::setTextInternal):

  • rendering/RenderTreeAsText.cpp:

(WebCore::RenderTreeAsText::writeRenderObject):

  • rendering/RootInlineBox.cpp:

(WebCore::RootInlineBox::ascentAndDescentForBox):
(WebCore::RootInlineBox::verticalPositionForBox):

LayoutTests:

  • editing/selection/move-by-word-visually-mac-expected.txt:


This is a progression. A previously failing subtest passes.

  • platform/mac/css3/selectors3/html/css3-modsel-179a-expected.txt:
  • platform/mac/css3/selectors3/xhtml/css3-modsel-179a-expected.txt:
  • platform/mac/css3/selectors3/xml/css3-modsel-179a-expected.txt:


Changes in render tree dump that don't affect rendering.

  • platform/mac/fast/css/pseudo-first-line-border-width-expected.txt:


This is a progression. The new rendering matches Firefox.

  • platform/mac/fast/css/word-space-extra-expected.txt:
  • platform/mac/fast/text/whitespace/pre-wrap-spaces-after-newline-expected.txt:


Changes in render tree dump that don't affect rendering.

Location:
trunk
Files:
36 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r155954 r155957  
     12013-09-17  Antti Koivisto  <antti@apple.com>
     2
     3        RenderBR should not be RenderText
     4        https://bugs.webkit.org/show_bug.cgi?id=121221
     5
     6        Reviewed by Darin Adler.
     7
     8        * editing/selection/move-by-word-visually-mac-expected.txt:
     9       
     10            This is a progression. A previously failing subtest passes.
     11
     12        * platform/mac/css3/selectors3/html/css3-modsel-179a-expected.txt:
     13        * platform/mac/css3/selectors3/xhtml/css3-modsel-179a-expected.txt:
     14        * platform/mac/css3/selectors3/xml/css3-modsel-179a-expected.txt:
     15       
     16            Changes in render tree dump that don't affect rendering.
     17
     18        * platform/mac/fast/css/pseudo-first-line-border-width-expected.txt:
     19       
     20            This is a progression. The new rendering matches Firefox.
     21
     22        * platform/mac/fast/css/word-space-extra-expected.txt:
     23        * platform/mac/fast/text/whitespace/pre-wrap-spaces-after-newline-expected.txt:
     24       
     25            Changes in render tree dump that don't affect rendering.
     26
    1272013-09-17  Eric Carlson  <eric.carlson@apple.com>
    228
  • trunk/LayoutTests/editing/selection/move-by-word-visually-mac-expected.txt

    r117392 r155957  
    8888Test 18, RTL:
    8989Move left by one word
    90 " abc def AAA AAA hij AAA AAA uvw xyz "[1, 5, 8, 12, 16, 20, 24, 28, 32, 36], <DIV>[0], <DIV>[0], "AAA kj AAA mn opq AAA AAA"[3, 6, 10, 13, 17, 21, 25]    FAIL expected: [" abc def AAA AAA hij AAA AAA uvw xyz "[ 1,  5,  8,  12,  16,  20,  24,  28,  32,  36, ]"AAA kj AAA mn opq AAA AAA"[ 3,  6,  10,  13,  17,  21,  25]
    91 " abc def AAA AAA hij AAA AAA uvw xyz "[36], <DIV>[0]   FAIL expected "AAA kj AAA mn opq AAA AAA"[ 3]
    92 <DIV>[0], <DIV>[0]   FAIL expected "AAA kj AAA mn opq AAA AAA"[ 3]
     90" abc def AAA AAA hij AAA AAA uvw xyz "[1, 5, 8, 12, 16, 20, 24, 28, 32, 36], "AAA kj AAA mn opq AAA AAA"[3, 6, 10, 13, 17, 21, 25]
    9391Move right by one word
    9492"AAA kj AAA mn opq AAA AAA"[25, 22, 18, 14, 11, 7, 4, 0], " abc def AAA AAA hij AAA AAA uvw xyz "[33, 29, 25, 21, 17, 13, 9, 4, 1]
  • trunk/LayoutTests/platform/mac/css3/selectors3/html/css3-modsel-179a-expected.txt

    r91104 r155957  
    55    RenderBody {BODY} at (8,16) size 784x92
    66      RenderBlock {P} at (0,0) size 784x92 [color=#008000]
    7         RenderBR {BR} at (0,0) size 0x74
     7        RenderBR {BR} at (0,44) size 0x18
    88        RenderText {#text} at (0,74) size 163x18
    99          text run at (0,74) width 163: "This line should be green."
  • trunk/LayoutTests/platform/mac/css3/selectors3/xhtml/css3-modsel-179a-expected.txt

    r91104 r155957  
    55    RenderBody {body} at (8,16) size 784x92
    66      RenderBlock {p} at (0,0) size 784x92 [color=#008000]
    7         RenderBR {br} at (0,0) size 0x74
     7        RenderBR {br} at (0,44) size 0x18
    88        RenderText {#text} at (0,74) size 163x18
    99          text run at (0,74) width 163: "This line should be green."
  • trunk/LayoutTests/platform/mac/css3/selectors3/xml/css3-modsel-179a-expected.txt

    r91104 r155957  
    44  RenderBlock {test} at (0,0) size 800x124
    55    RenderBlock {p} at (0,16) size 800x92 [color=#008000]
    6       RenderBR {br} at (0,0) size 0x74
     6      RenderBR {br} at (0,44) size 0x18
    77      RenderText {#text} at (0,74) size 163x18
    88        text run at (0,74) width 163: "This line should be green."
  • trunk/LayoutTests/platform/mac/fast/css/pseudo-first-line-border-width-expected.txt

    r126704 r155957  
    11layer at (0,0) size 800x600
    22  RenderView at (0,0) size 800x600
    3 layer at (0,0) size 800x450
    4   RenderBlock {HTML} at (0,0) size 800x450
    5     RenderBody {BODY} at (8,8) size 784x342
     3layer at (0,0) size 800x540
     4  RenderBlock {HTML} at (0,0) size 800x540
     5    RenderBody {BODY} at (8,8) size 784x432
    66      RenderBlock {DIV} at (0,0) size 784x32
    77        RenderText {#text} at (0,0) size 144x16
     
    1111            text run at (144,0) width 592: "https://bugs.webkit.org/show_bug.cgi?"
    1212            text run at (0,16) width 128: "id=79526"
    13       RenderBlock {P} at (0,132) size 784x210
    14         RenderText {#text} at (0,0) size 350x10
    15           text run at (0,0) width 350: "A green 10px border on the left of "
    16         RenderInline {SPAN} at (0,0) size 500x210 [border: none (100px solid #008000)]
    17           RenderText {#text} at (360,0) size 50x10
    18             text run at (360,0) width 50: "this,"
    19           RenderBR {BR} at (410,0) size 0x10
    20           RenderText {#text} at (0,10) size 500x200
    21             text run at (0,10) width 400: "is a"
    22             text run at (0,110) width 500: "pass."
     13      RenderBlock {P} at (0,132) size 784x300
     14        RenderText {#text} at (0,72) size 350x10
     15          text run at (0,72) width 350: "A green 10px border on the left of "
     16        RenderInline {SPAN} at (0,0) size 500x228 [border: none (100px solid #008000)]
     17          RenderText {#text} at (360,72) size 50x10
     18            text run at (360,72) width 50: "this,"
     19          RenderBR {BR} at (410,0) size 0x100
     20          RenderText {#text} at (0,100) size 500x200
     21            text run at (0,100) width 400: "is a"
     22            text run at (0,200) width 500: "pass."
  • trunk/LayoutTests/platform/mac/fast/css/word-space-extra-expected.txt

    r151737 r155957  
    312312          RenderText {#text} at (369,0) size 107x18
    313313            text run at (369,0) width 107: " elements too."
    314           RenderBR {BR} at (496,14) size 0x0
     314          RenderBR {BR} at (476,14) size 0x0
    315315          RenderText {#text} at (0,18) size 177x18
    316316            text run at (0,18) width 60: "Word "
     
    334334            text run at (452,18) width 240: "too. (with comment between"
    335335            text run at (0,36) width 151: "elements and too)"
    336           RenderBR {BR} at (171,50) size 0x0
     336          RenderBR {BR} at (151,50) size 0x0
    337337          RenderText {#text} at (0,54) size 177x18
    338338            text run at (0,54) width 60: "Word "
     
    356356            text run at (448,54) width 305: " too. (with comment (no preceeding"
    357357            text run at (0,72) width 292: "space) between elements and too)"
    358           RenderBR {BR} at (312,86) size 0x0
     358          RenderBR {BR} at (292,86) size 0x0
    359359          RenderText {#text} at (0,90) size 177x18
    360360            text run at (0,90) width 60: "Word "
     
    378378            text run at (452,90) width 276: "too. (with comment (no trailing"
    379379            text run at (0,108) width 292: "space) between elements and too)"
    380           RenderBR {BR} at (312,122) size 0x0
     380          RenderBR {BR} at (292,122) size 0x0
    381381          RenderInline {SPAN} at (0,0) size 320x15
    382382            RenderText {#text} at (0,128) size 204x15
     
    399399            text run at (412,126) width 308: " elements too. (with monospace font"
    400400            text run at (0,144) width 210: "from Word to elements)"
    401           RenderBR {BR} at (230,158) size 0x0
     401          RenderBR {BR} at (210,158) size 0x0
    402402          RenderText {#text} at (0,162) size 177x18
    403403            text run at (0,162) width 60: "Word "
     
    420420            text run at (389,162) width 362: " elements too. (with monospace font from"
    421421            text run at (0,180) width 123: "for to within)"
    422           RenderBR {BR} at (143,194) size 0x0
     422          RenderBR {BR} at (123,194) size 0x0
    423423          RenderText {#text} at (0,198) size 177x18
    424424            text run at (0,198) width 60: "Word "
     
    11811181            text run at (0,0) width 162: "In a span"
    11821182      RenderBlock (anonymous) at (0,2035) size 769x342
    1183         RenderInline {SPAN} at (0,0) size 779x342
     1183        RenderInline {SPAN} at (0,0) size 760x342
    11841184          RenderText {#text} at (0,0) size 424x18
    11851185            text run at (0,0) width 242: "Word and letter "
     
    12001200          RenderText {#text} at (0,18) size 168x18
    12011201            text run at (0,18) width 168: "elements too."
    1202           RenderBR {BR} at (188,32) size 0x0
     1202          RenderBR {BR} at (168,32) size 0x0
    12031203          RenderText {#text} at (0,36) size 424x18
    12041204            text run at (0,36) width 242: "Word and letter "
     
    12211221          RenderText {#text} at (124,54) size 635x18
    12221222            text run at (124,54) width 635: "too. (with comment between elements and too)"
    1223           RenderBR {BR} at (779,68) size 0x0
     1223          RenderBR {BR} at (759,68) size 0x0
    12241224          RenderText {#text} at (0,72) size 424x18
    12251225            text run at (0,72) width 242: "Word and letter "
     
    12431243            text run at (115,90) width 574: " too. (with comment (no preceeding space)"
    12441244            text run at (0,108) width 353: "between elements and too)"
    1245           RenderBR {BR} at (373,122) size 0x0
     1245          RenderBR {BR} at (353,122) size 0x0
    12461246          RenderText {#text} at (0,126) size 424x18
    12471247            text run at (0,126) width 242: "Word and letter "
     
    12651265            text run at (124,144) width 530: "too. (with comment (no trailing space)"
    12661266            text run at (0,162) width 353: "between elements and too)"
    1267           RenderBR {BR} at (373,176) size 0x0
     1267          RenderBR {BR} at (353,176) size 0x0
    12681268          RenderInline {SPAN} at (0,0) size 653x15
    12691269            RenderText {#text} at (0,182) size 477x15
     
    12861286            text run at (0,198) width 689: "elements too. (with monospace font from Word to"
    12871287            text run at (0,216) width 105: "elements)"
    1288           RenderBR {BR} at (125,230) size 0x0
     1288          RenderBR {BR} at (105,230) size 0x0
    12891289          RenderText {#text} at (0,234) size 424x18
    12901290            text run at (0,234) width 242: "Word and letter "
     
    13071307            text run at (0,252) width 666: "elements too. (with monospace font from for to"
    13081308            text run at (0,270) width 80: "within)"
    1309           RenderBR {BR} at (100,284) size 0x0
     1309          RenderBR {BR} at (80,284) size 0x0
    13101310          RenderText {#text} at (0,288) size 424x18
    13111311            text run at (0,288) width 242: "Word and letter "
  • trunk/LayoutTests/platform/mac/fast/text/whitespace/pre-wrap-spaces-after-newline-expected.txt

    r149210 r155957  
    5252          text run at (0,30) width 24: "bar"
    5353      RenderBlock {PRE} at (0,242) size 41x45 [bgcolor=#C0C0C0]
    54         RenderText {#text} at (0,0) size 56x15
    55           text run at (0,0) width 40: "foo  "
    56           text run at (40,0) width 16: "  "
    57         RenderBR {BR} at (56,12) size 0x0
     54        RenderText {#text} at (0,0) size 41x15
     55          text run at (0,0) width 24: "foo"
     56          text run at (24,0) width 17: "    "
     57        RenderBR {BR} at (0,0) size 0x0
    5858        RenderText {#text} at (0,15) size 24x30
    5959          text run at (0,15) width 24: "   "
  • trunk/Source/WebCore/ChangeLog

    r155955 r155957  
     12013-09-17  Antti Koivisto  <antti@apple.com>
     2
     3        RenderBR should not be RenderText
     4        https://bugs.webkit.org/show_bug.cgi?id=121221
     5
     6        Reviewed by Darin Adler.
     7
     8        Stop inheriting RenderBR from RenderText and make it be a RenderBoxModelObject instead. RenderBR was one
     9        of the few cases where Element renderer was a RenderText. This will enable future cleanups.
     10       
     11        RenderBR used little of RenderText mechanisms and was already heavily specialized everywhere. Layout code
     12        didn't care about its text content at all. The new RenderText is also significatly more lightweight
     13        than the old. As a line box it uses plain InlineBox instead of InlineTextBox.
     14       
     15        The patch tries to avoid changing test results though there are a few changed render tree dumps without
     16        visual effect. There are also two rendering progressions.
     17
     18        * accessibility/AccessibilityRenderObject.cpp:
     19        (WebCore::AccessibilityRenderObject::textUnderElement):
     20        (WebCore::AccessibilityRenderObject::computeAccessibilityIsIgnored):
     21        * dom/ContainerNode.cpp:
     22        (WebCore::ContainerNode::getUpperLeftCorner):
     23        * dom/Document.cpp:
     24        (WebCore::Document::updateHoverActiveState):
     25        * dom/Position.cpp:
     26        (WebCore::hasInlineBoxWrapper):
     27        (WebCore::nextRenderedEditable):
     28        (WebCore::previousRenderedEditable):
     29        (WebCore::Position::hasRenderedNonAnonymousDescendantsWithHeight):
     30        (WebCore::Position::getInlineBoxAndOffset):
     31        * dom/Range.cpp:
     32        (WebCore::Range::textRects):
     33        (WebCore::Range::textQuads):
     34        * editing/ApplyStyleCommand.cpp:
     35        (WebCore::ApplyStyleCommand::applyInlineStyleToPushDown):
     36        * editing/Editor.cpp:
     37        (WebCore::findFirstMarkable):
     38        * editing/TextIterator.cpp:
     39        (WebCore::ignoresContainerClip):
     40        * editing/VisibleUnits.cpp:
     41        (WebCore::CachedLogicallyOrderedLeafBoxes::previousTextOrLineBreakBox):
     42        (WebCore::CachedLogicallyOrderedLeafBoxes::nextTextOrLineBreakBox):
     43        (WebCore::logicallyPreviousBox):
     44        (WebCore::logicallyNextBox):
     45        (WebCore::wordBreakIteratorForMinOffsetBoundary):
     46        (WebCore::wordBreakIteratorForMaxOffsetBoundary):
     47        * rendering/InlineBox.cpp:
     48        (WebCore::InlineBox::logicalHeight):
     49        (WebCore::InlineBox::baselinePosition):
     50        (WebCore::InlineBox::lineHeight):
     51        (WebCore::InlineBox::deleteLine):
     52        (WebCore::InlineBox::extractLine):
     53        (WebCore::InlineBox::attachLine):
     54        (WebCore::InlineBox::paint):
     55        * rendering/InlineBox.h:
     56        (WebCore::InlineBox::isLineBreak):
     57        * rendering/InlineFlowBox.cpp:
     58        (WebCore::InlineFlowBox::computeOverflow):
     59        * rendering/InlineIterator.h:
     60        (WebCore::isIteratorTarget):
     61        * rendering/InlineTextBox.cpp:
     62        (WebCore::InlineTextBox::lineHeight):
     63        (WebCore::InlineTextBox::isLineBreak):
     64        * rendering/RenderBR.cpp:
     65        (WebCore::RenderBR::RenderBR):
     66        (WebCore::RenderBR::~RenderBR):
     67        (WebCore::RenderBR::createAnonymous):
     68        (WebCore::RenderBR::lineHeight):
     69        (WebCore::RenderBR::baselinePosition):
     70        (WebCore::RenderBR::createInlineBox):
     71        (WebCore::RenderBR::setInlineBoxWrapper):
     72        (WebCore::RenderBR::replaceInlineBoxWrapper):
     73        (WebCore::RenderBR::deleteInlineBoxWrapper):
     74        (WebCore::RenderBR::dirtyLineBoxes):
     75        (WebCore::RenderBR::caretMinOffset):
     76        (WebCore::RenderBR::caretMaxOffset):
     77        (WebCore::RenderBR::canBeSelectionLeaf):
     78        (WebCore::RenderBR::setSelectionState):
     79        (WebCore::RenderBR::localCaretRect):
     80        (WebCore::RenderBR::linesBoundingBox):
     81        (WebCore::RenderBR::absoluteRects):
     82        (WebCore::RenderBR::absoluteQuads):
     83        (WebCore::RenderBR::updateFromStyle):
     84        (WebCore::RenderBR::borderBoundingBox):
     85        * rendering/RenderBR.h:
     86        (WebCore::toRenderBR):
     87        * rendering/RenderBlock.cpp:
     88        (WebCore::InlineMinMaxIterator::next):
     89        (WebCore::RenderBlock::updateFirstLetter):
     90        * rendering/RenderBlockLineLayout.cpp:
     91        (WebCore::createInlineBoxForRenderer):
     92        (WebCore::dirtyLineBoxesForRenderer):
     93        (WebCore::reachedEndOfTextRenderer):
     94        (WebCore::RenderBlock::computeBlockDirectionPositionsForLine):
     95        (WebCore::RenderBlockFlow::layoutInlineChildren):
     96        (WebCore::requiresLineBox):
     97        (WebCore::shouldSkipWhitespaceAfterStartObject):
     98        (WebCore::canBreakAtThisPosition):
     99        * rendering/RenderInline.cpp:
     100        (WebCore::RenderInline::generateCulledLineBoxRects):
     101        (WebCore::RenderInline::culledInlineFirstLineBox):
     102        (WebCore::RenderInline::culledInlineLastLineBox):
     103        (WebCore::RenderInline::dirtyLineBoxes):
     104        * rendering/RenderLineBoxList.cpp:
     105        (WebCore::RenderLineBoxList::dirtyLinesFromChangedChild):
     106        * rendering/RenderMenuList.cpp:
     107        (WebCore::RenderMenuList::RenderMenuList):
     108        (WebCore::RenderMenuList::styleDidChange):
     109        (WebCore::RenderMenuList::setText):
     110        (WebCore::RenderMenuList::text):
     111        * rendering/RenderMenuList.h:
     112        * rendering/RenderObject.h:
     113        (WebCore::RenderObject::isBeforeContent):
     114        (WebCore::RenderObject::isAfterContent):
     115        * rendering/RenderObjectChildList.cpp:
     116        (WebCore::RenderObjectChildList::removeChildNode):
     117        * rendering/RenderText.cpp:
     118        (WebCore::RenderText::removeAndDestroyTextBoxes):
     119        (WebCore::RenderText::computePreferredLogicalWidths):
     120        (WebCore::RenderText::setTextInternal):
     121        * rendering/RenderTreeAsText.cpp:
     122        (WebCore::RenderTreeAsText::writeRenderObject):
     123        * rendering/RootInlineBox.cpp:
     124        (WebCore::RootInlineBox::ascentAndDescentForBox):
     125        (WebCore::RootInlineBox::verticalPositionForBox):
     126
    11272013-09-17  Andreas Kling  <akling@apple.com>
    2128
  • trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp

    r155797 r155957  
    634634    // Reflect when a content author has explicitly marked a line break.
    635635    if (m_renderer->isBR())
    636         return toRenderBR(*m_renderer).text();
     636        return ASCIILiteral("\n");
    637637
    638638#if ENABLE(MATHML)
     
    11551155    if (controlObject && !controlObject->exposesTitleUIElement() && controlObject->isCheckboxOrRadio())
    11561156        return true;
    1157        
    1158     // NOTE: BRs always have text boxes now, so the text box check here can be removed
     1157
     1158    if (m_renderer->isBR())
     1159        return true;
     1160
    11591161    if (m_renderer->isText()) {
    11601162        // static text beneath MenuItems and MenuButtons are just reported along with the menu item, so it's ignored on an individual level
     
    11631165            return true;
    11641166        RenderText* renderText = toRenderText(m_renderer);
    1165         if (m_renderer->isBR() || !renderText->firstTextBox())
     1167        if (!renderText->firstTextBox())
    11661168            return true;
    11671169
  • trunk/Source/WebCore/dom/ContainerNode.cpp

    r155752 r155957  
    914914        }
    915915
    916         if (p->node() && p->node() == this && o->isText() && !o->isBR() && !toRenderText(o)->firstTextBox()) {
     916        if (p->node() && p->node() == this && o->isText() && !toRenderText(o)->firstTextBox()) {
    917917            // do nothing - skip unrendered whitespace that is a child or next sibling of the anchor
    918         } else if ((o->isText() && !o->isBR()) || o->isReplaced()) {
     918        } else if (o->isText() || o->isReplaced()) {
    919919            point = FloatPoint();
    920920            if (o->isText() && toRenderText(o)->firstTextBox()) {
  • trunk/Source/WebCore/dom/Document.cpp

    r155955 r155957  
    58255825            // will need to reference this chain.
    58265826            for (RenderObject* curr = newActiveElement->renderer(); curr; curr = curr->parent()) {
    5827                 if (!curr->node() || !curr->node()->isElementNode() || curr->isText())
     5827                if (!curr->node() || !curr->node()->isElementNode() || curr->isText() || curr->isBR())
    58285828                    continue;
    58295829                m_userActionElements.setInActiveChain(toElement(curr->node()), true);
  • trunk/Source/WebCore/dom/Position.cpp

    r155408 r155957  
    3434#include "Logging.h"
    3535#include "PositionIterator.h"
     36#include "RenderBR.h"
    3637#include "RenderBlock.h"
    3738#include "RenderInline.h"
     
    5152using namespace HTMLNames;
    5253
     54static bool hasInlineBoxWrapper(RenderObject& renderer)
     55{
     56    if (renderer.isBox() && toRenderBox(renderer).inlineBoxWrapper())
     57        return true;
     58    if (renderer.isText() && toRenderText(renderer).firstTextBox())
     59        return true;
     60    if (renderer.isBR() && toRenderBR(renderer).inlineBoxWrapper())
     61        return true;
     62    return false;
     63}
     64
    5365static Node* nextRenderedEditable(Node* node)
    5466{
     
    5971        if (!renderer)
    6072            continue;
    61         if ((renderer->isBox() && toRenderBox(renderer)->inlineBoxWrapper()) || (renderer->isText() && toRenderText(renderer)->firstTextBox()))
     73        if (hasInlineBoxWrapper(*renderer))
    6274            return node;
    6375    }
     
    7385        if (!renderer)
    7486            continue;
    75         if ((renderer->isBox() && toRenderBox(renderer)->inlineBoxWrapper()) || (renderer->isText() && toRenderText(renderer)->firstTextBox()))
     87        if (hasInlineBoxWrapper(*renderer))
    7688            return node;
    7789    }
     
    846858        if (o->nonPseudoNode()) {
    847859            if ((o->isText() && boundingBoxLogicalHeight(o, toRenderText(o)->linesBoundingBox()))
     860                || (o->isBR() && boundingBoxLogicalHeight(o, toRenderBR(o)->linesBoundingBox()))
    848861                || (o->isBox() && toRenderBox(o)->pixelSnappedLogicalHeight())
    849862                || (o->isRenderInline() && isEmptyInline(o) && boundingBoxLogicalHeight(o, toRenderInline(o)->linesBoundingBox())))
     
    11821195    RenderObject* renderer = deprecatedNode()->renderer();
    11831196
    1184     if (!renderer->isText()) {
     1197    if (renderer->isBR())
     1198        inlineBox = !caretOffset ? toRenderBR(renderer)->inlineBoxWrapper() : nullptr;
     1199    else if (renderer->isText()) {
     1200        RenderText* textRenderer = toRenderText(renderer);
     1201
     1202        InlineTextBox* box;
     1203        InlineTextBox* candidate = 0;
     1204
     1205        for (box = textRenderer->firstTextBox(); box; box = box->nextTextBox()) {
     1206            int caretMinOffset = box->caretMinOffset();
     1207            int caretMaxOffset = box->caretMaxOffset();
     1208
     1209            if (caretOffset < caretMinOffset || caretOffset > caretMaxOffset || (caretOffset == caretMaxOffset && box->isLineBreak()))
     1210                continue;
     1211
     1212            if (caretOffset > caretMinOffset && caretOffset < caretMaxOffset) {
     1213                inlineBox = box;
     1214                return;
     1215            }
     1216
     1217            if (((caretOffset == caretMaxOffset) ^ (affinity == DOWNSTREAM))
     1218                || ((caretOffset == caretMinOffset) ^ (affinity == UPSTREAM))
     1219                || (caretOffset == caretMaxOffset && box->nextLeafChild() && box->nextLeafChild()->isLineBreak()))
     1220                break;
     1221
     1222            candidate = box;
     1223        }
     1224        if (candidate && candidate == textRenderer->lastTextBox() && affinity == DOWNSTREAM) {
     1225            box = searchAheadForBetterMatch(textRenderer);
     1226            if (box)
     1227                caretOffset = box->caretMinOffset();
     1228        }
     1229        inlineBox = box ? box : candidate;
     1230    } else {
    11851231        inlineBox = 0;
    11861232        if (canHaveChildrenForEditing(deprecatedNode()) && renderer->isRenderBlockFlow() && hasRenderedNonAnonymousDescendantsWithHeight(renderer)) {
     
    12031249                return;
    12041250        }
    1205     } else {
    1206         RenderText* textRenderer = toRenderText(renderer);
    1207 
    1208         InlineTextBox* box;
    1209         InlineTextBox* candidate = 0;
    1210 
    1211         for (box = textRenderer->firstTextBox(); box; box = box->nextTextBox()) {
    1212             int caretMinOffset = box->caretMinOffset();
    1213             int caretMaxOffset = box->caretMaxOffset();
    1214 
    1215             if (caretOffset < caretMinOffset || caretOffset > caretMaxOffset || (caretOffset == caretMaxOffset && box->isLineBreak()))
    1216                 continue;
    1217 
    1218             if (caretOffset > caretMinOffset && caretOffset < caretMaxOffset) {
    1219                 inlineBox = box;
    1220                 return;
    1221             }
    1222 
    1223             if (((caretOffset == caretMaxOffset) ^ (affinity == DOWNSTREAM))
    1224                 || ((caretOffset == caretMinOffset) ^ (affinity == UPSTREAM))
    1225                 || (caretOffset == caretMaxOffset && box->nextLeafChild() && box->nextLeafChild()->isLineBreak()))
    1226                 break;
    1227 
    1228             candidate = box;
    1229         }
    1230         if (candidate && candidate == textRenderer->lastTextBox() && affinity == DOWNSTREAM) {
    1231             box = searchAheadForBetterMatch(textRenderer);
    1232             if (box)
    1233                 caretOffset = box->caretMinOffset();
    1234         }
    1235         inlineBox = box ? box : candidate;
    12361251    }
    12371252
  • trunk/Source/WebCore/dom/Range.cpp

    r155808 r155957  
    16081608    for (Node* node = firstNode(); node != stopNode; node = NodeTraversal::next(node)) {
    16091609        RenderObject* r = node->renderer();
    1610         if (!r || !r->isText())
     1610        if (!r)
    16111611            continue;
    1612         RenderText* renderText = toRenderText(r);
    1613         int startOffset = node == startContainer ? m_start.offset() : 0;
    1614         int endOffset = node == endContainer ? m_end.offset() : numeric_limits<int>::max();
    16151612        bool isFixed = false;
    1616         renderText->absoluteRectsForRange(rects, startOffset, endOffset, useSelectionHeight, &isFixed);
     1613        if (r->isBR())
     1614            r->absoluteRects(rects, flooredLayoutPoint(r->localToAbsolute()));
     1615        else if (r->isText()) {
     1616            int startOffset = node == startContainer ? m_start.offset() : 0;
     1617            int endOffset = node == endContainer ? m_end.offset() : numeric_limits<int>::max();
     1618            toRenderText(r)->absoluteRectsForRange(rects, startOffset, endOffset, useSelectionHeight, &isFixed);
     1619        } else
     1620            continue;
    16171621        allFixed &= isFixed;
    16181622        someFixed |= isFixed;
     
    16401644    for (Node* node = firstNode(); node != stopNode; node = NodeTraversal::next(node)) {
    16411645        RenderObject* r = node->renderer();
    1642         if (!r || !r->isText())
     1646        if (!r)
    16431647            continue;
    1644         RenderText* renderText = toRenderText(r);
    1645         int startOffset = node == startContainer ? m_start.offset() : 0;
    1646         int endOffset = node == endContainer ? m_end.offset() : numeric_limits<int>::max();
    16471648        bool isFixed = false;
    1648         renderText->absoluteQuadsForRange(quads, startOffset, endOffset, useSelectionHeight, &isFixed);
     1649        if (r->isBR())
     1650            r->absoluteQuads(quads, &isFixed);
     1651        else if (r->isText()) {
     1652            int startOffset = node == startContainer ? m_start.offset() : 0;
     1653            int endOffset = node == endContainer ? m_end.offset() : numeric_limits<int>::max();
     1654            toRenderText(r)->absoluteQuadsForRange(quads, startOffset, endOffset, useSelectionHeight, &isFixed);
     1655        } else
     1656            continue;
    16491657        allFixed &= isFixed;
    16501658        someFixed |= isFixed;
  • trunk/Source/WebCore/editing/ApplyStyleCommand.cpp

    r155211 r155957  
    10211021    if (node->renderer()->isText() && static_cast<RenderText*>(node->renderer())->isAllCollapsibleWhitespace())
    10221022        return;
     1023    if (node->renderer()->isBR() && !node->renderer()->style()->preserveNewline())
     1024        return;
    10231025
    10241026    // We can't wrap node with the styled element here because new styled element will never be removed if we did.
  • trunk/Source/WebCore/editing/Editor.cpp

    r155907 r155957  
    30863086        if (!node->renderer())
    30873087            return 0;
    3088         if (node->renderer()->isText())
     3088        if (node->renderer()->isText() || node->renderer()->isBR())
    30893089            return node;
    30903090        if (isHTMLTextFormControlElement(node))
  • trunk/Source/WebCore/editing/TextIterator.cpp

    r155671 r155957  
    216216{
    217217    RenderObject* renderer = node->renderer();
    218     if (!renderer || renderer->isText())
     218    if (!renderer || renderer->isText() || renderer->isBR())
    219219        return false;
    220220    return renderer->style()->hasOutOfFlowPosition();
  • trunk/Source/WebCore/editing/VisibleUnits.cpp

    r155318 r155957  
    125125    CachedLogicallyOrderedLeafBoxes();
    126126
    127     const InlineTextBox* previousTextBox(const RootInlineBox*, const InlineTextBox*);
    128     const InlineTextBox* nextTextBox(const RootInlineBox*, const InlineTextBox*);
     127    const InlineBox* previousTextOrLineBreakBox(const RootInlineBox*, const InlineTextBox*);
     128    const InlineBox* nextTextOrLineBreakBox(const RootInlineBox*, const InlineTextBox*);
    129129
    130130    size_t size() const { return m_leafBoxes.size(); }
     
    141141CachedLogicallyOrderedLeafBoxes::CachedLogicallyOrderedLeafBoxes() : m_rootInlineBox(0) { };
    142142
    143 const InlineTextBox* CachedLogicallyOrderedLeafBoxes::previousTextBox(const RootInlineBox* root, const InlineTextBox* box)
     143const InlineBox* CachedLogicallyOrderedLeafBoxes::previousTextOrLineBreakBox(const RootInlineBox* root, const InlineTextBox* box)
    144144{
    145145    if (!root)
     
    154154
    155155    for (int i = boxIndex; i >= 0; --i) {
    156         if (m_leafBoxes[i]->isInlineTextBox())
    157             return toInlineTextBox(m_leafBoxes[i]);
     156        InlineBox* box = m_leafBoxes[i];
     157        if (box->isInlineTextBox() || box->renderer().isBR())
     158            return box;
    158159    }
    159160
     
    161162}
    162163
    163 const InlineTextBox* CachedLogicallyOrderedLeafBoxes::nextTextBox(const RootInlineBox* root, const InlineTextBox* box)
     164const InlineBox* CachedLogicallyOrderedLeafBoxes::nextTextOrLineBreakBox(const RootInlineBox* root, const InlineTextBox* box)
    164165{
    165166    if (!root)
     
    175176
    176177    for (size_t i = nextBoxIndex; i < m_leafBoxes.size(); ++i) {
    177         if (m_leafBoxes[i]->isInlineTextBox())
    178             return toInlineTextBox(m_leafBoxes[i]);
     178        InlineBox* box = m_leafBoxes[i];
     179        if (box->isInlineTextBox() || box->renderer().isBR())
     180            return box;
    179181    }
    180182
     
    201203}
    202204
    203 static const InlineTextBox* logicallyPreviousBox(const VisiblePosition& visiblePosition, const InlineTextBox* textBox,
     205static const InlineBox* logicallyPreviousBox(const VisiblePosition& visiblePosition, const InlineTextBox* textBox,
    204206    bool& previousBoxInDifferentBlock, CachedLogicallyOrderedLeafBoxes& leafBoxes)
    205207{
    206208    const InlineBox* startBox = textBox;
    207209
    208     const InlineTextBox* previousBox = leafBoxes.previousTextBox(&startBox->root(), textBox);
     210    const InlineBox* previousBox = leafBoxes.previousTextOrLineBreakBox(&startBox->root(), textBox);
    209211    if (previousBox)
    210212        return previousBox;
    211213
    212     previousBox = leafBoxes.previousTextBox(startBox->root().prevRootBox(), 0);
     214    previousBox = leafBoxes.previousTextOrLineBreakBox(startBox->root().prevRootBox(), 0);
    213215    if (previousBox)
    214216        return previousBox;
     
    228230            break;
    229231
    230         previousBox = leafBoxes.previousTextBox(previousRoot, 0);
     232        previousBox = leafBoxes.previousTextOrLineBreakBox(previousRoot, 0);
    231233        if (previousBox) {
    232234            previousBoxInDifferentBlock = true;
     
    242244
    243245
    244 static const InlineTextBox* logicallyNextBox(const VisiblePosition& visiblePosition, const InlineTextBox* textBox,
     246static const InlineBox* logicallyNextBox(const VisiblePosition& visiblePosition, const InlineTextBox* textBox,
    245247    bool& nextBoxInDifferentBlock, CachedLogicallyOrderedLeafBoxes& leafBoxes)
    246248{
    247249    const InlineBox* startBox = textBox;
    248250
    249     const InlineTextBox* nextBox = leafBoxes.nextTextBox(&startBox->root(), textBox);
     251    const InlineBox* nextBox = leafBoxes.nextTextOrLineBreakBox(&startBox->root(), textBox);
    250252    if (nextBox)
    251253        return nextBox;
    252254
    253     nextBox = leafBoxes.nextTextBox(startBox->root().nextRootBox(), 0);
     255    nextBox = leafBoxes.nextTextOrLineBreakBox(startBox->root().nextRootBox(), 0);
    254256    if (nextBox)
    255257        return nextBox;
     
    269271            break;
    270272
    271         nextBox = leafBoxes.nextTextBox(nextRoot, 0);
     273        nextBox = leafBoxes.nextTextOrLineBreakBox(nextRoot, 0);
    272274        if (nextBox) {
    273275            nextBoxInDifferentBlock = true;
     
    288290
    289291    // FIXME: Handle the case when we don't have an inline text box.
    290     const InlineTextBox* previousBox = logicallyPreviousBox(visiblePosition, textBox, previousBoxInDifferentBlock, leafBoxes);
     292    const InlineBox* previousBox = logicallyPreviousBox(visiblePosition, textBox, previousBoxInDifferentBlock, leafBoxes);
    291293
    292294    int len = 0;
    293295    string.clear();
    294     if (previousBox) {
    295         previousBoxLength = previousBox->len();
    296         string.append(previousBox->textRenderer().text()->characters() + previousBox->start(), previousBoxLength);
     296    if (previousBox && previousBox->isInlineTextBox()) {
     297        const InlineTextBox* previousTextBox = toInlineTextBox(previousBox);
     298        previousBoxLength = previousTextBox->len();
     299        string.append(previousTextBox->textRenderer().text()->characters() + previousTextBox->start(), previousBoxLength);
    297300        len += previousBoxLength;
    298301    }
     
    309312
    310313    // FIXME: Handle the case when we don't have an inline text box.
    311     const InlineTextBox* nextBox = logicallyNextBox(visiblePosition, textBox, nextBoxInDifferentBlock, leafBoxes);
     314    const InlineBox* nextBox = logicallyNextBox(visiblePosition, textBox, nextBoxInDifferentBlock, leafBoxes);
    312315
    313316    int len = 0;
     
    315318    string.append(textBox->textRenderer().text()->characters() + textBox->start(), textBox->len());
    316319    len += textBox->len();
    317     if (nextBox) {
    318         string.append(nextBox->textRenderer().text()->characters() + nextBox->start(), nextBox->len());
    319         len += nextBox->len();
     320    if (nextBox && nextBox->isInlineTextBox()) {
     321        const InlineTextBox* nextTextBox = toInlineTextBox(nextBox);
     322        string.append(nextTextBox->textRenderer().text()->characters() + nextTextBox->start(), nextTextBox->len());
     323        len += nextTextBox->len();
    320324    }
    321325
  • trunk/Source/WebCore/rendering/InlineBox.cpp

    r155944 r155957  
    2828#include "PaintInfo.h"
    2929#include "RenderArena.h"
     30#include "RenderBR.h"
    3031#include "RenderBlock.h"
    3132#include "RootInlineBox.h"
     
    141142        return virtualLogicalHeight();
    142143   
    143     if (renderer().isText())
     144    if (renderer().isText() || renderer().isBR())
    144145        return m_bitfields.isText() ? renderer().style(isFirstLineStyle())->fontMetrics().height() : 0;
    145146    if (renderer().isBox() && parent())
     
    157158int InlineBox::baselinePosition(FontBaseline baselineType) const
    158159{
     160    if (renderer().isBR() && !isText())
     161        return 0;
    159162    return boxModelObject()->baselinePosition(baselineType, m_bitfields.firstLine(), isHorizontal() ? HorizontalLine : VerticalLine, PositionOnContainingLine);
    160163}
     
    162165LayoutUnit InlineBox::lineHeight() const
    163166{
     167    if (renderer().isBR() && !isText())
     168        return 0;
    164169    return boxModelObject()->lineHeight(m_bitfields.firstLine(), isHorizontal() ? HorizontalLine : VerticalLine, PositionOnContainingLine);
    165170}
     
    184189void InlineBox::deleteLine(RenderArena& arena)
    185190{
    186     if (!m_bitfields.extracted() && m_renderer.isBox())
    187         toRenderBox(renderer()).setInlineBoxWrapper(0);
     191    if (!m_bitfields.extracted()) {
     192        if (m_renderer.isBox())
     193            toRenderBox(renderer()).setInlineBoxWrapper(0);
     194        else if (renderer().isBR())
     195            toRenderBR(renderer()).setInlineBoxWrapper(0);
     196    }
    188197    destroy(arena);
    189198}
     
    194203    if (m_renderer.isBox())
    195204        toRenderBox(renderer()).setInlineBoxWrapper(0);
     205    else if (renderer().isBR())
     206        toRenderBR(renderer()).setInlineBoxWrapper(0);
    196207}
    197208
     
    201212    if (m_renderer.isBox())
    202213        toRenderBox(renderer()).setInlineBoxWrapper(this);
     214    else if (renderer().isBR())
     215        toRenderBR(renderer()).setInlineBoxWrapper(this);
    203216}
    204217
     
    217230
    218231    LayoutPoint childPoint = paintOffset;
    219     if (parent()->renderer().style()->isFlippedBlocksWritingMode()) // Faster than calling containingBlock().
     232    if (parent()->renderer().style()->isFlippedBlocksWritingMode() && renderer().isBox()) // Faster than calling containingBlock().
    220233        childPoint = m_renderer.containingBlock()->flipForWritingModeForChild(&toRenderBox(renderer()), childPoint);
    221234   
  • trunk/Source/WebCore/rendering/InlineBox.h

    r155944 r155957  
    7070    virtual void attachLine();
    7171
    72     virtual bool isLineBreak() const { return false; }
     72    virtual bool isLineBreak() const { return renderer().isBR(); }
    7373
    7474    virtual void adjustPosition(float dx, float dy);
  • trunk/Source/WebCore/rendering/InlineFlowBox.cpp

    r155944 r155957  
    950950        if (curr->renderer().isOutOfFlowPositioned())
    951951            continue; // Positioned placeholders don't affect calculations.
    952        
     952
     953        if (curr->renderer().isBR())
     954            continue;
    953955        if (curr->renderer().isText()) {
    954956            InlineTextBox* text = toInlineTextBox(curr);
    955             if (text->renderer().isBR())
    956                 continue;
    957957            LayoutRect textBoxOverflow(enclosingLayoutRect(text->logicalFrameRect()));
    958958            addTextBoxVisualOverflow(text, textBoxDataMap, textBoxOverflow);
    959959            logicalVisualOverflow.unite(textBoxOverflow);
    960         } else  if (curr->renderer().isRenderInline()) {
     960        } else if (curr->renderer().isRenderInline()) {
    961961            InlineFlowBox* flow = toInlineFlowBox(curr);
    962962            flow->computeOverflow(lineTop, lineBottom, textBoxDataMap);
  • trunk/Source/WebCore/rendering/InlineIterator.h

    r155554 r155957  
    167167{
    168168    ASSERT(object); // The iterator will of course return 0, but its not an expected argument to this function.
    169     return object->isText() || object->isFloating() || object->isOutOfFlowPositioned() || object->isReplaced();
     169    return object->isText() || object->isBR() || object->isFloating() || object->isOutOfFlowPositioned() || object->isReplaced();
    170170}
    171171
  • trunk/Source/WebCore/rendering/InlineTextBox.cpp

    r155944 r155957  
    110110    if (!isText() || !renderer().parent())
    111111        return 0;
    112     if (renderer().isBR())
    113         return toRenderBR(renderer()).lineHeight(isFirstLineStyle());
    114112    if (&parent()->renderer() == renderer().parent())
    115113        return parent()->lineHeight();
     
    368366bool InlineTextBox::isLineBreak() const
    369367{
    370     return renderer().isBR() || (renderer().style()->preserveNewline() && len() == 1 && (*textRenderer().text())[start()] == '\n');
     368    return renderer().style()->preserveNewline() && len() == 1 && (*textRenderer().text())[start()] == '\n';
    371369}
    372370
  • trunk/Source/WebCore/rendering/RenderBR.cpp

    r154580 r155957  
    11/**
    22 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
    3  * Copyright (C) 2006 Apple Computer, Inc.
     3 * Copyright (C) 2006, 2013 Apple Inc. All rights reserved.
    44 *
    55 * This library is free software; you can redistribute it and/or
     
    2424
    2525#include "Document.h"
    26 #include "InlineTextBox.h"
     26#include "RenderBlock.h"
     27#include "RootInlineBox.h"
    2728#include "VisiblePosition.h"
    2829
    2930namespace WebCore {
    3031
    31 static PassRefPtr<StringImpl> newlineString()
    32 {
    33     DEFINE_STATIC_LOCAL(const String, string, (ASCIILiteral("\n")));
    34     return string.impl();
    35 }
     32static const int invalidLineHeight = -1;
    3633
    37 RenderBR::RenderBR(Node* node)
    38     : RenderText(node, newlineString())
    39     , m_lineHeight(-1)
     34RenderBR::RenderBR(Element* element)
     35    : RenderBoxModelObject(element)
     36    , m_inlineBoxWrapper(nullptr)
     37    , m_cachedLineHeight(invalidLineHeight)
    4038{
    4139}
     
    4341RenderBR::~RenderBR()
    4442{
     43    if (m_inlineBoxWrapper)
     44        m_inlineBoxWrapper->destroy(renderArena());
    4545}
    4646
    47 int RenderBR::lineHeight(bool firstLine) const
     47RenderBR* RenderBR::createAnonymous(Document& document)
     48{
     49    RenderBR* renderer = new (*document.renderArena()) RenderBR(nullptr);
     50    renderer->setDocumentForAnonymous(document);
     51    return renderer;
     52}
     53
     54LayoutUnit RenderBR::lineHeight(bool firstLine, LineDirectionMode /*direction*/, LinePositionMode /*linePositionMode*/) const
    4855{
    4956    if (firstLine && document().styleSheetCollection()->usesFirstLineRules()) {
     
    5259            return s->computedLineHeight(&view());
    5360    }
     61
     62    if (m_cachedLineHeight == invalidLineHeight)
     63        m_cachedLineHeight = style()->computedLineHeight(&view());
    5464   
    55     if (m_lineHeight == -1)
    56         m_lineHeight = style()->computedLineHeight(&view());
    57    
    58     return m_lineHeight;
     65    return m_cachedLineHeight;
    5966}
    6067
    61 void RenderBR::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
     68int RenderBR::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const
    6269{
    63     RenderText::styleDidChange(diff, oldStyle);
    64     m_lineHeight = -1;
     70    const FontMetrics& fontMetrics = style(firstLine)->fontMetrics();
     71    return fontMetrics.ascent(baselineType) + (lineHeight(firstLine, direction, linePositionMode) - fontMetrics.height()) / 2;
    6572}
    6673
    67 int RenderBR::caretMinOffset() const
    68 {
     74InlineBox* RenderBR::createInlineBox()
     75{
     76    return new (renderArena()) InlineBox(*this);
     77}
     78
     79void RenderBR::setInlineBoxWrapper(InlineBox* inlineBox)
     80{
     81    ASSERT(!inlineBox || !m_inlineBoxWrapper);
     82    m_inlineBoxWrapper = inlineBox;
     83}
     84
     85void RenderBR::replaceInlineBoxWrapper(InlineBox* inlineBox)
     86{
     87    deleteInlineBoxWrapper();
     88    setInlineBoxWrapper(inlineBox);
     89}
     90
     91void RenderBR::deleteInlineBoxWrapper()
     92{
     93    if (!m_inlineBoxWrapper)
     94        return;
     95    if (!documentBeingDestroyed())
     96        m_inlineBoxWrapper->remove();
     97    m_inlineBoxWrapper->destroy(renderArena());
     98    m_inlineBoxWrapper = nullptr;
     99}
     100
     101void RenderBR::dirtyLineBoxes(bool fullLayout)
     102{
     103    if (!m_inlineBoxWrapper)
     104        return;
     105    if (fullLayout) {
     106        m_inlineBoxWrapper->destroy(renderArena());
     107        m_inlineBoxWrapper = nullptr;
     108        return;
     109    }
     110    m_inlineBoxWrapper->dirtyLineBoxes();
     111}
     112
     113int RenderBR::caretMinOffset() const
     114{
    69115    return 0;
    70116}
    71117
    72 int RenderBR::caretMaxOffset() const 
     118int RenderBR::caretMaxOffset() const
    73119{
    74120    return 1;
     121}
     122
     123bool RenderBR::canBeSelectionLeaf() const
     124{
     125    return true;
    75126}
    76127
     
    80131}
    81132
     133void RenderBR::setSelectionState(SelectionState state)
     134{
     135    RenderBoxModelObject::setSelectionState(state);
     136    if (!m_inlineBoxWrapper)
     137        return;
     138    m_inlineBoxWrapper->root().setHasSelectedChildren(state != SelectionNone);
     139}
     140
     141LayoutRect RenderBR::localCaretRect(InlineBox* inlineBox, int caretOffset, LayoutUnit* extraWidthToEndOfLine)
     142{
     143    ASSERT_UNUSED(caretOffset, !caretOffset);
     144    ASSERT_UNUSED(inlineBox, inlineBox == m_inlineBoxWrapper);
     145    if (!inlineBox)
     146        return LayoutRect();
     147
     148    static const unsigned caretWidth = 1;
     149    const RootInlineBox& rootBox = inlineBox->root();
     150    return rootBox.computeCaretRect(inlineBox->logicalLeft(), caretWidth, extraWidthToEndOfLine);
     151}
     152
     153IntRect RenderBR::linesBoundingBox() const
     154{
     155    if (!m_inlineBoxWrapper)
     156        return IntRect();
     157
     158    float logicalLeftSide = m_inlineBoxWrapper->logicalLeft();
     159    float logicalRightSide = m_inlineBoxWrapper->logicalRight();
     160
     161    bool isHorizontal = style()->isHorizontalWritingMode();
     162
     163    float x = isHorizontal ? logicalLeftSide : m_inlineBoxWrapper->x();
     164    float y = isHorizontal ? m_inlineBoxWrapper->y() : logicalLeftSide;
     165    float width = isHorizontal ? logicalRightSide - logicalLeftSide : m_inlineBoxWrapper->logicalBottom() - x;
     166    float height = isHorizontal ? m_inlineBoxWrapper->logicalBottom() - y : logicalRightSide - logicalLeftSide;
     167    return enclosingIntRect(FloatRect(x, y, width, height));
     168}
     169
     170void RenderBR::absoluteRects(Vector<IntRect>& rects, const LayoutPoint& accumulatedOffset) const
     171{
     172    if (!m_inlineBoxWrapper)
     173        return;
     174    rects.append(enclosingIntRect(FloatRect(accumulatedOffset + m_inlineBoxWrapper->topLeft(), m_inlineBoxWrapper->size())));
     175}
     176
     177void RenderBR::absoluteQuads(Vector<FloatQuad>& quads, bool* wasFixed) const
     178{
     179    if (!m_inlineBoxWrapper)
     180        return;
     181    quads.append(localToAbsoluteQuad(FloatRect(m_inlineBoxWrapper->topLeft(), m_inlineBoxWrapper->size()), 0 /* mode */, wasFixed));
     182}
     183
     184void RenderBR::updateFromStyle()
     185{
     186    m_cachedLineHeight = invalidLineHeight;
     187}
     188
     189IntRect RenderBR::borderBoundingBox() const
     190{
     191    return IntRect(IntPoint(), linesBoundingBox().size());
     192}
     193
    82194} // namespace WebCore
  • trunk/Source/WebCore/rendering/RenderBR.h

    r154937 r155957  
    11/*
    22 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
     3 * Copyright (C) 2013 Apple Inc. All rights reserved.
    34 *
    45 * This library is free software; you can redistribute it and/or
     
    2223#define RenderBR_h
    2324
    24 #include "RenderText.h"
     25#include "RenderBoxModelObject.h"
    2526
    26 /*
    27  * The whole class here is a hack to get <br> working, as long as we don't have support for
    28  * CSS2 :before and :after pseudo elements
    29  */
    3027namespace WebCore {
    3128
    3229class Position;
    3330
    34 class RenderBR FINAL : public RenderText {
     31class RenderBR FINAL : public RenderBoxModelObject {
    3532public:
    36     explicit RenderBR(Node*);
     33    explicit RenderBR(Element*);
    3734    virtual ~RenderBR();
    3835
     36    static RenderBR* createAnonymous(Document&);
     37
    3938    virtual const char* renderName() const { return "RenderBR"; }
    40  
    41     virtual LayoutRect selectionRectForRepaint(const RenderLayerModelObject* /*repaintContainer*/, bool /*clipToVisibleContent*/) OVERRIDE { return LayoutRect(); }
    4239
    43     virtual float width(unsigned /*from*/, unsigned /*len*/, const Font&, float /*xPos*/, HashSet<const SimpleFontData*>* = 0 /*fallbackFonts*/ , GlyphOverflow* = 0) const { return 0; }
    44     virtual float width(unsigned /*from*/, unsigned /*len*/, float /*xpos*/, bool = false /*firstLine*/, HashSet<const SimpleFontData*>* = 0 /*fallbackFonts*/, GlyphOverflow* = 0) const { return 0; }
     40    InlineBox* createInlineBox();
     41    InlineBox* inlineBoxWrapper() const { return m_inlineBoxWrapper; }
     42    void setInlineBoxWrapper(InlineBox*);
     43    void deleteInlineBoxWrapper();
     44    void replaceInlineBoxWrapper(InlineBox*);
     45    void dirtyLineBoxes(bool fullLayout);
    4546
    46     int lineHeight(bool firstLine) const;
     47    IntRect linesBoundingBox() const;
    4748
    48     // overrides
    49     virtual bool isBR() const { return true; }
    50 
    51     virtual int caretMinOffset() const;
    52     virtual int caretMaxOffset() const;
    53 
    54     virtual VisiblePosition positionForPoint(const LayoutPoint&);
    55 
    56 protected:
    57     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
     49    virtual void absoluteRects(Vector<IntRect>&, const LayoutPoint& accumulatedOffset) const OVERRIDE;
     50    virtual void absoluteQuads(Vector<FloatQuad>&, bool* wasFixed) const OVERRIDE;
    5851
    5952private:
    60     mutable int m_lineHeight;
     53    virtual bool isBR() const OVERRIDE { return true; }
     54
     55    virtual VisiblePosition positionForPoint(const LayoutPoint&) OVERRIDE;
     56    virtual int caretMinOffset() const OVERRIDE;
     57    virtual int caretMaxOffset() const OVERRIDE;
     58    virtual bool canBeSelectionLeaf() const OVERRIDE;
     59    virtual LayoutRect localCaretRect(InlineBox*, int caretOffset, LayoutUnit* extraWidthToEndOfLine) OVERRIDE;
     60    virtual void setSelectionState(SelectionState) OVERRIDE;
     61
     62    virtual LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositionMode) const OVERRIDE;
     63    virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode) const OVERRIDE;
     64
     65    virtual LayoutUnit marginTop() const OVERRIDE { return 0; }
     66    virtual LayoutUnit marginBottom() const OVERRIDE { return 0; }
     67    virtual LayoutUnit marginLeft() const OVERRIDE { return 0; }
     68    virtual LayoutUnit marginRight() const OVERRIDE { return 0; }
     69    virtual LayoutUnit marginBefore(const RenderStyle*) const OVERRIDE { return 0; }
     70    virtual LayoutUnit marginAfter(const RenderStyle*) const OVERRIDE { return 0; }
     71    virtual LayoutUnit marginStart(const RenderStyle*) const OVERRIDE { return 0; }
     72    virtual LayoutUnit marginEnd(const RenderStyle*) const OVERRIDE { return 0; }
     73    virtual LayoutUnit offsetWidth() const OVERRIDE { return linesBoundingBox().width(); }
     74    virtual LayoutUnit offsetHeight() const OVERRIDE { return linesBoundingBox().height(); }
     75    virtual IntRect borderBoundingBox() const OVERRIDE;
     76    virtual LayoutRect frameRectForStickyPositioning() const OVERRIDE { ASSERT_NOT_REACHED(); return LayoutRect(); }
     77    virtual LayoutRect clippedOverflowRectForRepaint(const RenderLayerModelObject*) const OVERRIDE { return LayoutRect(); }
     78
     79    virtual void updateFromStyle() OVERRIDE;
     80    virtual bool requiresLayer() const OVERRIDE { return false; }
     81
     82    InlineBox* m_inlineBoxWrapper;
     83    mutable int m_cachedLineHeight;
    6184};
    6285
     
    7396}
    7497
     98inline RenderBR* toRenderBR(RenderObject* object)
     99{
     100    ASSERT_WITH_SECURITY_IMPLICATION(object->isBR());
     101    return static_cast<RenderBR*>(object);
     102}
     103
     104inline const RenderBR* toRenderBR(const RenderObject* object)
     105{
     106    ASSERT_WITH_SECURITY_IMPLICATION(object->isBR());
     107    return static_cast<const RenderBR*>(object);
     108}
     109
    75110// This will catch anyone doing an unnecessary cast.
    76111void toRenderBR(const RenderBR&);
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r155944 r155957  
    51125112            break;
    51135113
    5114         if (!result->isOutOfFlowPositioned() && (result->isText() || result->isFloating() || result->isReplaced() || result->isRenderInline()))
     5114        if (!result->isOutOfFlowPositioned() && (result->isText() || result->isBR() || result->isFloating() || result->isReplaced() || result->isRenderInline()))
    51155115             break;
    51165116       
     
    59685968    }
    59695969
    5970     if (!currChild->isText() || currChild->isBR())
     5970    if (!currChild->isText())
    59715971        return;
    59725972
  • trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp

    r155944 r155957  
    3333#include "Logging.h"
    3434#include "RenderArena.h"
     35#include "RenderBR.h"
    3536#include "RenderCombineText.h"
    3637#include "RenderCounter.h"
     
    264265        return toRenderBlock(obj)->createAndAppendRootInlineBox();
    265266
    266     if (obj->isText()) {
    267         InlineTextBox* textBox = toRenderText(obj)->createInlineTextBox();
    268         // We only treat a box as text for a <br> if we are on a line by ourself or in strict mode
    269         // (Note the use of strict mode.  In "almost strict" mode, we don't treat the box for <br> as text.)
    270         if (obj->isBR())
    271             textBox->setIsText(isOnlyRun || obj->document().inNoQuirksMode());
    272         return textBox;
    273     }
     267    if (obj->isText())
     268        return toRenderText(obj)->createInlineTextBox();
    274269
    275270    if (obj->isBox())
    276271        return toRenderBox(obj)->createInlineBox();
     272
     273    if (obj->isBR()) {
     274        InlineBox* inlineBox = toRenderBR(obj)->createInlineBox();
     275        // We only treat a box as text for a <br> if we are on a line by ourself or in strict mode
     276        // (Note the use of strict mode. In "almost strict" mode, we don't treat the box for <br> as text.)
     277        inlineBox->setIsText(isOnlyRun || obj->document().inNoQuirksMode());
     278        return inlineBox;
     279    }
    277280
    278281    return toRenderInline(obj)->createAndAppendInlineFlowBox();
     
    294297        updateCounterIfNeeded(renderText);
    295298        renderText->dirtyLineBoxes(fullLayout);
    296     } else
     299    } else if (o->isBR())
     300        toRenderBR(o)->dirtyLineBoxes(fullLayout);
     301    else
    297302        toRenderInline(o)->dirtyLineBoxes(fullLayout);
    298303}
     
    389394    unsigned pos = run->stop();
    390395    RenderObject* r = run->m_object;
    391     if (!r->isText() || r->isBR())
     396    if (!r->isText())
    392397        return false;
    393398    RenderText* renderText = toRenderText(r);
     
    924929        else if (r->m_object->isBox())
    925930            toRenderBox(r->m_object)->positionLineBox(r->m_box);
     931        else if (r->m_object->isBR())
     932            toRenderBR(r->m_object)->replaceInlineBoxWrapper(r->m_box);
    926933    }
    927934    // Positioned objects and zero-length text nodes destroy their boxes in
     
    18341841                        o->layoutIfNeeded();
    18351842                }
    1836             } else if (o->isText() || (o->isRenderInline() && !walker.atEndOfInline())) {
    1837                 if (!o->isText())
     1843            } else if (o->isText() || o->isBR() || (o->isRenderInline() && !walker.atEndOfInline())) {
     1844                if (o->isRenderInline())
    18381845                    toRenderInline(o)->updateAlwaysCreateLineBoxes(layoutState.isFullLayout());
    18391846                if (layoutState.isFullLayout() || o->selfNeedsLayout())
     
    22002207        return false;
    22012208
     2209    if (it.m_obj->isBR())
     2210        return true;
     2211
    22022212    if (it.m_obj->isRenderInline() && !alwaysRequiresLineBox(it.m_obj) && !requiresLineBoxForContent(toRenderInline(it.m_obj), lineInfo))
    22032213        return false;
    22042214
    2205     if (!shouldCollapseWhiteSpace(it.m_obj->style(), lineInfo, whitespacePosition) || it.m_obj->isBR())
     2215    if (!shouldCollapseWhiteSpace(it.m_obj->style(), lineInfo, whitespacePosition))
    22062216        return true;
    22072217
     
    22782288        next = bidiNextSkippingEmptyInlines(block, next);
    22792289
    2280     if (next && !next->isBR() && next->isText() && toRenderText(next)->textLength() > 0) {
     2290    if (next && next->isText() && toRenderText(next)->textLength() > 0) {
    22812291        RenderText* nextText = toRenderText(next);
    22822292        UChar nextChar = nextText->characterAt(0);
     
    25552565        return true;
    25562566
    2557     bool nextIsText = (next && (current.m_obj->isText() || isEmptyInline(current.m_obj)) && next->isText() && !next->isBR() && (autoWrap || next->style()->autoWrap()));
     2567    bool nextIsText = (next && (current.m_obj->isText() || isEmptyInline(current.m_obj)) && next->isText() && (autoWrap || next->style()->autoWrap()));
    25582568    if (!nextIsText)
    25592569        return autoWrap;
  • trunk/Source/WebCore/rendering/RenderInline.cpp

    r155944 r155957  
    3131#include "Page.h"
    3232#include "RenderArena.h"
     33#include "RenderBR.h"
    3334#include "RenderBlock.h"
    3435#include "RenderFlowThread.h"
     
    606607                    yield(FloatRect(logicalTop, childText->y(), logicalHeight, childText->logicalWidth()));
    607608            }
     609        } else if (curr->isBR()) {
     610            if (InlineBox* inlineBox = toRenderBR(curr)->inlineBoxWrapper()) {
     611                // FIXME: This could use a helper to share these with text path.
     612                const RootInlineBox& rootBox = inlineBox->root();
     613                int logicalTop = rootBox.logicalTop() + (rootBox.renderer().style(rootBox.isFirstLineStyle())->font().fontMetrics().ascent() - container->style(rootBox.isFirstLineStyle())->font().fontMetrics().ascent());
     614                int logicalHeight = container->style(rootBox.isFirstLineStyle())->font().fontMetrics().height();
     615                if (isHorizontal)
     616                    yield(FloatRect(inlineBox->x(), logicalTop, inlineBox->logicalWidth(), logicalHeight));
     617                else
     618                    yield(FloatRect(logicalTop, inlineBox->y(), logicalHeight, inlineBox->logicalWidth()));
     619            }
    608620        }
    609621    }
     
    896908        if (curr->isBox())
    897909            return toRenderBox(curr)->inlineBoxWrapper();
    898         if (curr->isRenderInline()) {
     910        if (curr->isBR()) {
     911            RenderBR* renderBR = toRenderBR(curr);
     912            if (renderBR->inlineBoxWrapper())
     913                return renderBR->inlineBoxWrapper();
     914        } else if (curr->isRenderInline()) {
    899915            RenderInline* currInline = toRenderInline(curr);
    900916            InlineBox* result = currInline->firstLineBoxIncludingCulling();
     
    920936        if (curr->isBox())
    921937            return toRenderBox(curr)->inlineBoxWrapper();
    922         if (curr->isRenderInline()) {
     938        if (curr->isBR()) {
     939            RenderBR* renderBR = toRenderBR(curr);
     940            if (renderBR->inlineBoxWrapper())
     941                return renderBR->inlineBoxWrapper();
     942        } else if (curr->isRenderInline()) {
    923943            RenderInline* currInline = toRenderInline(curr);
    924944            InlineBox* result = currInline->lastLineBoxIncludingCulling();
     
    12951315                    for (InlineTextBox* childText = currText->firstTextBox(); childText; childText = childText->nextTextBox())
    12961316                        childText->root().markDirty();
     1317                } else if (curr->isBR()) {
     1318                    RenderBR* currBR = toRenderBR(curr);
     1319                    if (currBR->inlineBoxWrapper())
     1320                        currBR->inlineBoxWrapper()->root().markDirty();
    12971321                }
    12981322            }
  • trunk/Source/WebCore/rendering/RenderLineBoxList.cpp

    r155944 r155957  
    3434#include "PaintInfo.h"
    3535#include "RenderArena.h"
     36#include "RenderBR.h"
    3637#include "RenderInline.h"
    3738#include "RenderView.h"
     
    342343            if (wrapper)
    343344                box = &wrapper->root();
     345        } if (curr->isBR()) {
     346            InlineBox* wrapper = toRenderBR(curr)->inlineBoxWrapper();
     347            if (wrapper)
     348                box = &wrapper->root();
    344349        } else if (curr->isText()) {
    345350            InlineTextBox* textBox = toRenderText(curr)->lastTextBox();
  • trunk/Source/WebCore/rendering/RenderMenuList.cpp

    r155944 r155957  
    4242#include "RenderBR.h"
    4343#include "RenderScrollbar.h"
     44#include "RenderText.h"
    4445#include "RenderTheme.h"
    4546#include "RenderView.h"
     
    5758RenderMenuList::RenderMenuList(HTMLSelectElement& element)
    5859    : RenderFlexibleBox(&element)
    59     , m_buttonText(0)
    60     , m_innerBlock(0)
     60    , m_buttonText(nullptr)
     61    , m_buttonBR(nullptr)
     62    , m_innerBlock(nullptr)
    6163    , m_needsOptionsWidthUpdate(true)
    6264    , m_optionsWidth(0)
     
    161163    if (m_buttonText)
    162164        m_buttonText->setStyle(style());
     165    if (m_buttonBR)
     166        m_buttonBR->setStyle(style());
    163167    if (m_innerBlock) // RenderBlock handled updating the anonymous block's style.
    164168        adjustInnerStyle();
     
    241245{
    242246    if (s.isEmpty()) {
    243         if (!m_buttonText || !m_buttonText->isBR()) {
    244             if (m_buttonText)
     247        if (!m_buttonBR) {
     248            if (m_buttonText) {
    245249                m_buttonText->destroy();
    246             m_buttonText = new (renderArena()) RenderBR(&document());
    247             m_buttonText->setStyle(style());
    248             addChild(m_buttonText);
     250                m_buttonText = nullptr;
     251            }
     252            // FIXME: This could probably just be a text node.
     253            m_buttonBR = RenderBR::createAnonymous(document());
     254            m_buttonBR->setStyle(style());
     255            addChild(m_buttonBR);
    249256        }
    250257    } else {
    251         if (m_buttonText && !m_buttonText->isBR())
     258        if (m_buttonText)
    252259            m_buttonText->setText(s.impl(), true);
    253260        else {
    254             if (m_buttonText)
    255                 m_buttonText->destroy();
     261            if (m_buttonBR) {
     262                m_buttonBR->destroy();
     263                m_buttonBR = nullptr;
     264            }
    256265            m_buttonText = new (renderArena()) RenderText(&document(), s.impl());
    257266            m_buttonText->setStyle(style());
     
    264273String RenderMenuList::text() const
    265274{
    266     return m_buttonText ? m_buttonText->text() : 0;
     275    return m_buttonText ? m_buttonText->text() : m_buttonBR ? String(ASCIILiteral("\n")) : String();
    267276}
    268277
  • trunk/Source/WebCore/rendering/RenderMenuList.h

    r155673 r155957  
    3939
    4040class HTMLSelectElement;
     41class RenderBR;
    4142class RenderText;
    4243
     
    137138
    138139    RenderText* m_buttonText;
     140    RenderBR* m_buttonBR;
    139141    RenderBlock* m_innerBlock;
    140142
  • trunk/Source/WebCore/rendering/RenderObject.h

    r155944 r155957  
    12021202        return false;
    12031203    // Text nodes don't have their own styles, so ignore the style on a text node.
    1204     if (isText() && !isBR())
     1204    if (isText())
    12051205        return false;
    12061206    return true;
     
    12121212        return false;
    12131213    // Text nodes don't have their own styles, so ignore the style on a text node.
    1214     if (isText() && !isBR())
     1214    if (isText())
    12151215        return false;
    12161216    return true;
  • trunk/Source/WebCore/rendering/RenderObjectChildList.cpp

    r155366 r155957  
    2929
    3030#include "AXObjectCache.h"
     31#include "RenderBR.h"
    3132#include "RenderCounter.h"
    3233#include "RenderObject.h"
     
    7677    if (oldChild->isBox())
    7778        toRenderBox(oldChild)->deleteLineBoxWrapper();
     79    else if (oldChild->isBR())
     80        toRenderBR(oldChild)->deleteInlineBoxWrapper();
    7881
    7982    // If oldChild is the start or end of the selection, then clear the selection to
  • trunk/Source/WebCore/rendering/RenderText.cpp

    r155949 r155957  
    232232    if (!documentBeingDestroyed()) {
    233233        if (firstTextBox()) {
    234             if (isBR()) {
    235                 RootInlineBox* next = firstTextBox()->root().nextRootBox();
    236                 if (next)
    237                     next->markDirty();
    238             }
    239234            for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox())
    240235                box->remove();
     
    889884    m_maxWidth = 0;
    890885
    891     if (isBR())
    892         return;
    893 
    894886    float currMinWidth = 0;
    895887    float currMaxWidth = 0;
     
    13661358
    13671359    ASSERT(m_text);
    1368     ASSERT(!isBR() || (textLength() == 1 && m_text[0] == '\n'));
    13691360
    13701361    m_isAllASCII = m_text.containsOnlyASCII();
  • trunk/Source/WebCore/rendering/RenderTreeAsText.cpp

    r155761 r155957  
    252252        if (adjustForTableCells && !text.firstTextBox())
    253253            adjustForTableCells = false;
     254    } else if (o.isBR()) {
     255        const RenderBR& br = toRenderBR(o);
     256        IntRect linesBox = br.linesBoundingBox();
     257        r = IntRect(linesBox.x(), linesBox.y(), linesBox.width(), linesBox.height());
     258        if (!br.inlineBoxWrapper())
     259            adjustForTableCells = false;
    254260    } else if (o.isRenderInline()) {
     261        const RenderInline& inlineFlow = toRenderInline(o);
    255262        // FIXME: Would be better not to just dump 0, 0 as the x and y here.
    256         const RenderInline& inlineFlow = toRenderInline(o);
    257263        r = IntRect(0, 0, inlineFlow.linesBoundingBox().width(), inlineFlow.linesBoundingBox().height());
    258264        adjustForTableCells = false;
     
    274280    ts << " " << enclosingIntRect(r);
    275281
    276     if (!(o.isText() && !o.isBR())) {
     282    if (!o.isText()) {
    277283        if (o.isFileUploadControl())
    278284            ts << " " << quoteAndEscapeNonPrintables(toRenderFileUploadControl(&o)->fileTextValue());
     
    303309        }
    304310
    305         if (!o.isBoxModelObject())
     311        if (!o.isBoxModelObject() || o.isBR())
    306312            return;
    307313
  • trunk/Source/WebCore/rendering/RootInlineBox.cpp

    r155949 r155957  
    847847    Vector<const SimpleFontData*>* usedFonts = 0;
    848848    GlyphOverflow* glyphOverflow = 0;
    849     if (box->isText()) {
     849    if (box->isInlineTextBox()) {
    850850        GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.find(toInlineTextBox(box));
    851851        usedFonts = it == textBoxDataMap.end() ? 0 : &it->value.first;
     
    916916        LayoutUnit ascentWithMargin = box->renderer().style(isFirstLineStyle())->fontMetrics().ascent(baselineType());
    917917        LayoutUnit descentWithMargin = box->renderer().style(isFirstLineStyle())->fontMetrics().descent(baselineType());
    918         if (box->parent() && !box->renderer().isText()) {
     918        if (box->parent() && !box->renderer().isText() && !box->renderer().isBR()) {
    919919            ascentWithMargin += box->boxModelObject()->borderAndPaddingBefore() + box->boxModelObject()->marginBefore();
    920920            descentWithMargin += box->boxModelObject()->borderAndPaddingAfter() + box->boxModelObject()->marginAfter();
     
    930930LayoutUnit RootInlineBox::verticalPositionForBox(InlineBox* box, VerticalPositionCache& verticalPositionCache)
    931931{
    932     if (box->renderer().isText())
     932    if (box->renderer().isText() || box->renderer().isBR())
    933933        return box->parent()->logicalTop();
    934934   
Note: See TracChangeset for help on using the changeset viewer.