Changeset 155957 in webkit
- Timestamp:
- Sep 17, 2013, 8:13:37 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 36 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r155954 r155957 1 2013-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 1 27 2013-09-17 Eric Carlson <eric.carlson@apple.com> 2 28 -
trunk/LayoutTests/editing/selection/move-by-word-visually-mac-expected.txt
r117392 r155957 88 88 Test 18, RTL: 89 89 Move 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] 93 91 Move right by one word 94 92 "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 5 5 RenderBody {BODY} at (8,16) size 784x92 6 6 RenderBlock {P} at (0,0) size 784x92 [color=#008000] 7 RenderBR {BR} at (0, 0) size 0x747 RenderBR {BR} at (0,44) size 0x18 8 8 RenderText {#text} at (0,74) size 163x18 9 9 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 5 5 RenderBody {body} at (8,16) size 784x92 6 6 RenderBlock {p} at (0,0) size 784x92 [color=#008000] 7 RenderBR {br} at (0, 0) size 0x747 RenderBR {br} at (0,44) size 0x18 8 8 RenderText {#text} at (0,74) size 163x18 9 9 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 4 4 RenderBlock {test} at (0,0) size 800x124 5 5 RenderBlock {p} at (0,16) size 800x92 [color=#008000] 6 RenderBR {br} at (0, 0) size 0x746 RenderBR {br} at (0,44) size 0x18 7 7 RenderText {#text} at (0,74) size 163x18 8 8 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 1 1 layer at (0,0) size 800x600 2 2 RenderView at (0,0) size 800x600 3 layer at (0,0) size 800x 4504 RenderBlock {HTML} at (0,0) size 800x 4505 RenderBody {BODY} at (8,8) size 784x 3423 layer at (0,0) size 800x540 4 RenderBlock {HTML} at (0,0) size 800x540 5 RenderBody {BODY} at (8,8) size 784x432 6 6 RenderBlock {DIV} at (0,0) size 784x32 7 7 RenderText {#text} at (0,0) size 144x16 … … 11 11 text run at (144,0) width 592: "https://bugs.webkit.org/show_bug.cgi?" 12 12 text run at (0,16) width 128: "id=79526" 13 RenderBlock {P} at (0,132) size 784x 21014 RenderText {#text} at (0, 0) size 350x1015 text run at (0, 0) width 350: "A green 10px border on the left of "16 RenderInline {SPAN} at (0,0) size 500x2 10[border: none (100px solid #008000)]17 RenderText {#text} at (360, 0) size 50x1018 text run at (360, 0) width 50: "this,"19 RenderBR {BR} at (410,0) size 0x10 20 RenderText {#text} at (0,10 ) size 500x20021 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 312 312 RenderText {#text} at (369,0) size 107x18 313 313 text run at (369,0) width 107: " elements too." 314 RenderBR {BR} at (4 96,14) size 0x0314 RenderBR {BR} at (476,14) size 0x0 315 315 RenderText {#text} at (0,18) size 177x18 316 316 text run at (0,18) width 60: "Word " … … 334 334 text run at (452,18) width 240: "too. (with comment between" 335 335 text run at (0,36) width 151: "elements and too)" 336 RenderBR {BR} at (1 71,50) size 0x0336 RenderBR {BR} at (151,50) size 0x0 337 337 RenderText {#text} at (0,54) size 177x18 338 338 text run at (0,54) width 60: "Word " … … 356 356 text run at (448,54) width 305: " too. (with comment (no preceeding" 357 357 text run at (0,72) width 292: "space) between elements and too)" 358 RenderBR {BR} at ( 312,86) size 0x0358 RenderBR {BR} at (292,86) size 0x0 359 359 RenderText {#text} at (0,90) size 177x18 360 360 text run at (0,90) width 60: "Word " … … 378 378 text run at (452,90) width 276: "too. (with comment (no trailing" 379 379 text run at (0,108) width 292: "space) between elements and too)" 380 RenderBR {BR} at ( 312,122) size 0x0380 RenderBR {BR} at (292,122) size 0x0 381 381 RenderInline {SPAN} at (0,0) size 320x15 382 382 RenderText {#text} at (0,128) size 204x15 … … 399 399 text run at (412,126) width 308: " elements too. (with monospace font" 400 400 text run at (0,144) width 210: "from Word to elements)" 401 RenderBR {BR} at (2 30,158) size 0x0401 RenderBR {BR} at (210,158) size 0x0 402 402 RenderText {#text} at (0,162) size 177x18 403 403 text run at (0,162) width 60: "Word " … … 420 420 text run at (389,162) width 362: " elements too. (with monospace font from" 421 421 text run at (0,180) width 123: "for to within)" 422 RenderBR {BR} at (1 43,194) size 0x0422 RenderBR {BR} at (123,194) size 0x0 423 423 RenderText {#text} at (0,198) size 177x18 424 424 text run at (0,198) width 60: "Word " … … 1181 1181 text run at (0,0) width 162: "In a span" 1182 1182 RenderBlock (anonymous) at (0,2035) size 769x342 1183 RenderInline {SPAN} at (0,0) size 7 79x3421183 RenderInline {SPAN} at (0,0) size 760x342 1184 1184 RenderText {#text} at (0,0) size 424x18 1185 1185 text run at (0,0) width 242: "Word and letter " … … 1200 1200 RenderText {#text} at (0,18) size 168x18 1201 1201 text run at (0,18) width 168: "elements too." 1202 RenderBR {BR} at (1 88,32) size 0x01202 RenderBR {BR} at (168,32) size 0x0 1203 1203 RenderText {#text} at (0,36) size 424x18 1204 1204 text run at (0,36) width 242: "Word and letter " … … 1221 1221 RenderText {#text} at (124,54) size 635x18 1222 1222 text run at (124,54) width 635: "too. (with comment between elements and too)" 1223 RenderBR {BR} at (7 79,68) size 0x01223 RenderBR {BR} at (759,68) size 0x0 1224 1224 RenderText {#text} at (0,72) size 424x18 1225 1225 text run at (0,72) width 242: "Word and letter " … … 1243 1243 text run at (115,90) width 574: " too. (with comment (no preceeding space)" 1244 1244 text run at (0,108) width 353: "between elements and too)" 1245 RenderBR {BR} at (3 73,122) size 0x01245 RenderBR {BR} at (353,122) size 0x0 1246 1246 RenderText {#text} at (0,126) size 424x18 1247 1247 text run at (0,126) width 242: "Word and letter " … … 1265 1265 text run at (124,144) width 530: "too. (with comment (no trailing space)" 1266 1266 text run at (0,162) width 353: "between elements and too)" 1267 RenderBR {BR} at (3 73,176) size 0x01267 RenderBR {BR} at (353,176) size 0x0 1268 1268 RenderInline {SPAN} at (0,0) size 653x15 1269 1269 RenderText {#text} at (0,182) size 477x15 … … 1286 1286 text run at (0,198) width 689: "elements too. (with monospace font from Word to" 1287 1287 text run at (0,216) width 105: "elements)" 1288 RenderBR {BR} at (1 25,230) size 0x01288 RenderBR {BR} at (105,230) size 0x0 1289 1289 RenderText {#text} at (0,234) size 424x18 1290 1290 text run at (0,234) width 242: "Word and letter " … … 1307 1307 text run at (0,252) width 666: "elements too. (with monospace font from for to" 1308 1308 text run at (0,270) width 80: "within)" 1309 RenderBR {BR} at ( 100,284) size 0x01309 RenderBR {BR} at (80,284) size 0x0 1310 1310 RenderText {#text} at (0,288) size 424x18 1311 1311 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 52 52 text run at (0,30) width 24: "bar" 53 53 RenderBlock {PRE} at (0,242) size 41x45 [bgcolor=#C0C0C0] 54 RenderText {#text} at (0,0) size 56x1555 text run at (0,0) width 40: "foo"56 text run at ( 40,0) width 16: ""57 RenderBR {BR} at ( 56,12) size 0x054 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 58 58 RenderText {#text} at (0,15) size 24x30 59 59 text run at (0,15) width 24: " " -
trunk/Source/WebCore/ChangeLog
r155955 r155957 1 2013-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 1 127 2013-09-17 Andreas Kling <akling@apple.com> 2 128 -
trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp
r155797 r155957 634 634 // Reflect when a content author has explicitly marked a line break. 635 635 if (m_renderer->isBR()) 636 return toRenderBR(*m_renderer).text();636 return ASCIILiteral("\n"); 637 637 638 638 #if ENABLE(MATHML) … … 1155 1155 if (controlObject && !controlObject->exposesTitleUIElement() && controlObject->isCheckboxOrRadio()) 1156 1156 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 1159 1161 if (m_renderer->isText()) { 1160 1162 // static text beneath MenuItems and MenuButtons are just reported along with the menu item, so it's ignored on an individual level … … 1163 1165 return true; 1164 1166 RenderText* renderText = toRenderText(m_renderer); 1165 if ( m_renderer->isBR() ||!renderText->firstTextBox())1167 if (!renderText->firstTextBox()) 1166 1168 return true; 1167 1169 -
trunk/Source/WebCore/dom/ContainerNode.cpp
r155752 r155957 914 914 } 915 915 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()) { 917 917 // 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()) { 919 919 point = FloatPoint(); 920 920 if (o->isText() && toRenderText(o)->firstTextBox()) { -
trunk/Source/WebCore/dom/Document.cpp
r155955 r155957 5825 5825 // will need to reference this chain. 5826 5826 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()) 5828 5828 continue; 5829 5829 m_userActionElements.setInActiveChain(toElement(curr->node()), true); -
trunk/Source/WebCore/dom/Position.cpp
r155408 r155957 34 34 #include "Logging.h" 35 35 #include "PositionIterator.h" 36 #include "RenderBR.h" 36 37 #include "RenderBlock.h" 37 38 #include "RenderInline.h" … … 51 52 using namespace HTMLNames; 52 53 54 static 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 53 65 static Node* nextRenderedEditable(Node* node) 54 66 { … … 59 71 if (!renderer) 60 72 continue; 61 if ( (renderer->isBox() && toRenderBox(renderer)->inlineBoxWrapper()) || (renderer->isText() && toRenderText(renderer)->firstTextBox()))73 if (hasInlineBoxWrapper(*renderer)) 62 74 return node; 63 75 } … … 73 85 if (!renderer) 74 86 continue; 75 if ( (renderer->isBox() && toRenderBox(renderer)->inlineBoxWrapper()) || (renderer->isText() && toRenderText(renderer)->firstTextBox()))87 if (hasInlineBoxWrapper(*renderer)) 76 88 return node; 77 89 } … … 846 858 if (o->nonPseudoNode()) { 847 859 if ((o->isText() && boundingBoxLogicalHeight(o, toRenderText(o)->linesBoundingBox())) 860 || (o->isBR() && boundingBoxLogicalHeight(o, toRenderBR(o)->linesBoundingBox())) 848 861 || (o->isBox() && toRenderBox(o)->pixelSnappedLogicalHeight()) 849 862 || (o->isRenderInline() && isEmptyInline(o) && boundingBoxLogicalHeight(o, toRenderInline(o)->linesBoundingBox()))) … … 1182 1195 RenderObject* renderer = deprecatedNode()->renderer(); 1183 1196 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 { 1185 1231 inlineBox = 0; 1186 1232 if (canHaveChildrenForEditing(deprecatedNode()) && renderer->isRenderBlockFlow() && hasRenderedNonAnonymousDescendantsWithHeight(renderer)) { … … 1203 1249 return; 1204 1250 } 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;1236 1251 } 1237 1252 -
trunk/Source/WebCore/dom/Range.cpp
r155808 r155957 1608 1608 for (Node* node = firstNode(); node != stopNode; node = NodeTraversal::next(node)) { 1609 1609 RenderObject* r = node->renderer(); 1610 if (!r || !r->isText())1610 if (!r) 1611 1611 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();1615 1612 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; 1617 1621 allFixed &= isFixed; 1618 1622 someFixed |= isFixed; … … 1640 1644 for (Node* node = firstNode(); node != stopNode; node = NodeTraversal::next(node)) { 1641 1645 RenderObject* r = node->renderer(); 1642 if (!r || !r->isText())1646 if (!r) 1643 1647 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();1647 1648 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; 1649 1657 allFixed &= isFixed; 1650 1658 someFixed |= isFixed; -
trunk/Source/WebCore/editing/ApplyStyleCommand.cpp
r155211 r155957 1021 1021 if (node->renderer()->isText() && static_cast<RenderText*>(node->renderer())->isAllCollapsibleWhitespace()) 1022 1022 return; 1023 if (node->renderer()->isBR() && !node->renderer()->style()->preserveNewline()) 1024 return; 1023 1025 1024 1026 // 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 3086 3086 if (!node->renderer()) 3087 3087 return 0; 3088 if (node->renderer()->isText() )3088 if (node->renderer()->isText() || node->renderer()->isBR()) 3089 3089 return node; 3090 3090 if (isHTMLTextFormControlElement(node)) -
trunk/Source/WebCore/editing/TextIterator.cpp
r155671 r155957 216 216 { 217 217 RenderObject* renderer = node->renderer(); 218 if (!renderer || renderer->isText() )218 if (!renderer || renderer->isText() || renderer->isBR()) 219 219 return false; 220 220 return renderer->style()->hasOutOfFlowPosition(); -
trunk/Source/WebCore/editing/VisibleUnits.cpp
r155318 r155957 125 125 CachedLogicallyOrderedLeafBoxes(); 126 126 127 const Inline TextBox* previousTextBox(const RootInlineBox*, const InlineTextBox*);128 const Inline TextBox* nextTextBox(const RootInlineBox*, const InlineTextBox*);127 const InlineBox* previousTextOrLineBreakBox(const RootInlineBox*, const InlineTextBox*); 128 const InlineBox* nextTextOrLineBreakBox(const RootInlineBox*, const InlineTextBox*); 129 129 130 130 size_t size() const { return m_leafBoxes.size(); } … … 141 141 CachedLogicallyOrderedLeafBoxes::CachedLogicallyOrderedLeafBoxes() : m_rootInlineBox(0) { }; 142 142 143 const Inline TextBox* CachedLogicallyOrderedLeafBoxes::previousTextBox(const RootInlineBox* root, const InlineTextBox* box)143 const InlineBox* CachedLogicallyOrderedLeafBoxes::previousTextOrLineBreakBox(const RootInlineBox* root, const InlineTextBox* box) 144 144 { 145 145 if (!root) … … 154 154 155 155 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; 158 159 } 159 160 … … 161 162 } 162 163 163 const Inline TextBox* CachedLogicallyOrderedLeafBoxes::nextTextBox(const RootInlineBox* root, const InlineTextBox* box)164 const InlineBox* CachedLogicallyOrderedLeafBoxes::nextTextOrLineBreakBox(const RootInlineBox* root, const InlineTextBox* box) 164 165 { 165 166 if (!root) … … 175 176 176 177 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; 179 181 } 180 182 … … 201 203 } 202 204 203 static const Inline TextBox* logicallyPreviousBox(const VisiblePosition& visiblePosition, const InlineTextBox* textBox,205 static const InlineBox* logicallyPreviousBox(const VisiblePosition& visiblePosition, const InlineTextBox* textBox, 204 206 bool& previousBoxInDifferentBlock, CachedLogicallyOrderedLeafBoxes& leafBoxes) 205 207 { 206 208 const InlineBox* startBox = textBox; 207 209 208 const Inline TextBox* previousBox = leafBoxes.previousTextBox(&startBox->root(), textBox);210 const InlineBox* previousBox = leafBoxes.previousTextOrLineBreakBox(&startBox->root(), textBox); 209 211 if (previousBox) 210 212 return previousBox; 211 213 212 previousBox = leafBoxes.previousText Box(startBox->root().prevRootBox(), 0);214 previousBox = leafBoxes.previousTextOrLineBreakBox(startBox->root().prevRootBox(), 0); 213 215 if (previousBox) 214 216 return previousBox; … … 228 230 break; 229 231 230 previousBox = leafBoxes.previousText Box(previousRoot, 0);232 previousBox = leafBoxes.previousTextOrLineBreakBox(previousRoot, 0); 231 233 if (previousBox) { 232 234 previousBoxInDifferentBlock = true; … … 242 244 243 245 244 static const Inline TextBox* logicallyNextBox(const VisiblePosition& visiblePosition, const InlineTextBox* textBox,246 static const InlineBox* logicallyNextBox(const VisiblePosition& visiblePosition, const InlineTextBox* textBox, 245 247 bool& nextBoxInDifferentBlock, CachedLogicallyOrderedLeafBoxes& leafBoxes) 246 248 { 247 249 const InlineBox* startBox = textBox; 248 250 249 const Inline TextBox* nextBox = leafBoxes.nextTextBox(&startBox->root(), textBox);251 const InlineBox* nextBox = leafBoxes.nextTextOrLineBreakBox(&startBox->root(), textBox); 250 252 if (nextBox) 251 253 return nextBox; 252 254 253 nextBox = leafBoxes.nextText Box(startBox->root().nextRootBox(), 0);255 nextBox = leafBoxes.nextTextOrLineBreakBox(startBox->root().nextRootBox(), 0); 254 256 if (nextBox) 255 257 return nextBox; … … 269 271 break; 270 272 271 nextBox = leafBoxes.nextText Box(nextRoot, 0);273 nextBox = leafBoxes.nextTextOrLineBreakBox(nextRoot, 0); 272 274 if (nextBox) { 273 275 nextBoxInDifferentBlock = true; … … 288 290 289 291 // FIXME: Handle the case when we don't have an inline text box. 290 const Inline TextBox* previousBox = logicallyPreviousBox(visiblePosition, textBox, previousBoxInDifferentBlock, leafBoxes);292 const InlineBox* previousBox = logicallyPreviousBox(visiblePosition, textBox, previousBoxInDifferentBlock, leafBoxes); 291 293 292 294 int len = 0; 293 295 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); 297 300 len += previousBoxLength; 298 301 } … … 309 312 310 313 // FIXME: Handle the case when we don't have an inline text box. 311 const Inline TextBox* nextBox = logicallyNextBox(visiblePosition, textBox, nextBoxInDifferentBlock, leafBoxes);314 const InlineBox* nextBox = logicallyNextBox(visiblePosition, textBox, nextBoxInDifferentBlock, leafBoxes); 312 315 313 316 int len = 0; … … 315 318 string.append(textBox->textRenderer().text()->characters() + textBox->start(), textBox->len()); 316 319 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(); 320 324 } 321 325 -
trunk/Source/WebCore/rendering/InlineBox.cpp
r155944 r155957 28 28 #include "PaintInfo.h" 29 29 #include "RenderArena.h" 30 #include "RenderBR.h" 30 31 #include "RenderBlock.h" 31 32 #include "RootInlineBox.h" … … 141 142 return virtualLogicalHeight(); 142 143 143 if (renderer().isText() )144 if (renderer().isText() || renderer().isBR()) 144 145 return m_bitfields.isText() ? renderer().style(isFirstLineStyle())->fontMetrics().height() : 0; 145 146 if (renderer().isBox() && parent()) … … 157 158 int InlineBox::baselinePosition(FontBaseline baselineType) const 158 159 { 160 if (renderer().isBR() && !isText()) 161 return 0; 159 162 return boxModelObject()->baselinePosition(baselineType, m_bitfields.firstLine(), isHorizontal() ? HorizontalLine : VerticalLine, PositionOnContainingLine); 160 163 } … … 162 165 LayoutUnit InlineBox::lineHeight() const 163 166 { 167 if (renderer().isBR() && !isText()) 168 return 0; 164 169 return boxModelObject()->lineHeight(m_bitfields.firstLine(), isHorizontal() ? HorizontalLine : VerticalLine, PositionOnContainingLine); 165 170 } … … 184 189 void InlineBox::deleteLine(RenderArena& arena) 185 190 { 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 } 188 197 destroy(arena); 189 198 } … … 194 203 if (m_renderer.isBox()) 195 204 toRenderBox(renderer()).setInlineBoxWrapper(0); 205 else if (renderer().isBR()) 206 toRenderBR(renderer()).setInlineBoxWrapper(0); 196 207 } 197 208 … … 201 212 if (m_renderer.isBox()) 202 213 toRenderBox(renderer()).setInlineBoxWrapper(this); 214 else if (renderer().isBR()) 215 toRenderBR(renderer()).setInlineBoxWrapper(this); 203 216 } 204 217 … … 217 230 218 231 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(). 220 233 childPoint = m_renderer.containingBlock()->flipForWritingModeForChild(&toRenderBox(renderer()), childPoint); 221 234 -
trunk/Source/WebCore/rendering/InlineBox.h
r155944 r155957 70 70 virtual void attachLine(); 71 71 72 virtual bool isLineBreak() const { return false; }72 virtual bool isLineBreak() const { return renderer().isBR(); } 73 73 74 74 virtual void adjustPosition(float dx, float dy); -
trunk/Source/WebCore/rendering/InlineFlowBox.cpp
r155944 r155957 950 950 if (curr->renderer().isOutOfFlowPositioned()) 951 951 continue; // Positioned placeholders don't affect calculations. 952 952 953 if (curr->renderer().isBR()) 954 continue; 953 955 if (curr->renderer().isText()) { 954 956 InlineTextBox* text = toInlineTextBox(curr); 955 if (text->renderer().isBR())956 continue;957 957 LayoutRect textBoxOverflow(enclosingLayoutRect(text->logicalFrameRect())); 958 958 addTextBoxVisualOverflow(text, textBoxDataMap, textBoxOverflow); 959 959 logicalVisualOverflow.unite(textBoxOverflow); 960 } else 960 } else if (curr->renderer().isRenderInline()) { 961 961 InlineFlowBox* flow = toInlineFlowBox(curr); 962 962 flow->computeOverflow(lineTop, lineBottom, textBoxDataMap); -
trunk/Source/WebCore/rendering/InlineIterator.h
r155554 r155957 167 167 { 168 168 ASSERT(object); // The iterator will of course return 0, but its not an expected argument to this function. 169 return object->isText() || object->is Floating() || object->isOutOfFlowPositioned() || object->isReplaced();169 return object->isText() || object->isBR() || object->isFloating() || object->isOutOfFlowPositioned() || object->isReplaced(); 170 170 } 171 171 -
trunk/Source/WebCore/rendering/InlineTextBox.cpp
r155944 r155957 110 110 if (!isText() || !renderer().parent()) 111 111 return 0; 112 if (renderer().isBR())113 return toRenderBR(renderer()).lineHeight(isFirstLineStyle());114 112 if (&parent()->renderer() == renderer().parent()) 115 113 return parent()->lineHeight(); … … 368 366 bool InlineTextBox::isLineBreak() const 369 367 { 370 return renderer(). isBR() || (renderer().style()->preserveNewline() && len() == 1 && (*textRenderer().text())[start()] == '\n');368 return renderer().style()->preserveNewline() && len() == 1 && (*textRenderer().text())[start()] == '\n'; 371 369 } 372 370 -
trunk/Source/WebCore/rendering/RenderBR.cpp
r154580 r155957 1 1 /** 2 2 * 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. 4 4 * 5 5 * This library is free software; you can redistribute it and/or … … 24 24 25 25 #include "Document.h" 26 #include "InlineTextBox.h" 26 #include "RenderBlock.h" 27 #include "RootInlineBox.h" 27 28 #include "VisiblePosition.h" 28 29 29 30 namespace WebCore { 30 31 31 static PassRefPtr<StringImpl> newlineString() 32 { 33 DEFINE_STATIC_LOCAL(const String, string, (ASCIILiteral("\n"))); 34 return string.impl(); 35 } 32 static const int invalidLineHeight = -1; 36 33 37 RenderBR::RenderBR(Node* node) 38 : RenderText(node, newlineString()) 39 , m_lineHeight(-1) 34 RenderBR::RenderBR(Element* element) 35 : RenderBoxModelObject(element) 36 , m_inlineBoxWrapper(nullptr) 37 , m_cachedLineHeight(invalidLineHeight) 40 38 { 41 39 } … … 43 41 RenderBR::~RenderBR() 44 42 { 43 if (m_inlineBoxWrapper) 44 m_inlineBoxWrapper->destroy(renderArena()); 45 45 } 46 46 47 int RenderBR::lineHeight(bool firstLine) const 47 RenderBR* RenderBR::createAnonymous(Document& document) 48 { 49 RenderBR* renderer = new (*document.renderArena()) RenderBR(nullptr); 50 renderer->setDocumentForAnonymous(document); 51 return renderer; 52 } 53 54 LayoutUnit RenderBR::lineHeight(bool firstLine, LineDirectionMode /*direction*/, LinePositionMode /*linePositionMode*/) const 48 55 { 49 56 if (firstLine && document().styleSheetCollection()->usesFirstLineRules()) { … … 52 59 return s->computedLineHeight(&view()); 53 60 } 61 62 if (m_cachedLineHeight == invalidLineHeight) 63 m_cachedLineHeight = style()->computedLineHeight(&view()); 54 64 55 if (m_lineHeight == -1) 56 m_lineHeight = style()->computedLineHeight(&view()); 57 58 return m_lineHeight; 65 return m_cachedLineHeight; 59 66 } 60 67 61 void RenderBR::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle) 68 int RenderBR::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const 62 69 { 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; 65 72 } 66 73 67 int RenderBR::caretMinOffset() const 68 { 74 InlineBox* RenderBR::createInlineBox() 75 { 76 return new (renderArena()) InlineBox(*this); 77 } 78 79 void RenderBR::setInlineBoxWrapper(InlineBox* inlineBox) 80 { 81 ASSERT(!inlineBox || !m_inlineBoxWrapper); 82 m_inlineBoxWrapper = inlineBox; 83 } 84 85 void RenderBR::replaceInlineBoxWrapper(InlineBox* inlineBox) 86 { 87 deleteInlineBoxWrapper(); 88 setInlineBoxWrapper(inlineBox); 89 } 90 91 void 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 101 void 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 113 int RenderBR::caretMinOffset() const 114 { 69 115 return 0; 70 116 } 71 117 72 int RenderBR::caretMaxOffset() const 118 int RenderBR::caretMaxOffset() const 73 119 { 74 120 return 1; 121 } 122 123 bool RenderBR::canBeSelectionLeaf() const 124 { 125 return true; 75 126 } 76 127 … … 80 131 } 81 132 133 void RenderBR::setSelectionState(SelectionState state) 134 { 135 RenderBoxModelObject::setSelectionState(state); 136 if (!m_inlineBoxWrapper) 137 return; 138 m_inlineBoxWrapper->root().setHasSelectedChildren(state != SelectionNone); 139 } 140 141 LayoutRect 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 153 IntRect 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 170 void 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 177 void 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 184 void RenderBR::updateFromStyle() 185 { 186 m_cachedLineHeight = invalidLineHeight; 187 } 188 189 IntRect RenderBR::borderBoundingBox() const 190 { 191 return IntRect(IntPoint(), linesBoundingBox().size()); 192 } 193 82 194 } // namespace WebCore -
trunk/Source/WebCore/rendering/RenderBR.h
r154937 r155957 1 1 /* 2 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) 3 * Copyright (C) 2013 Apple Inc. All rights reserved. 3 4 * 4 5 * This library is free software; you can redistribute it and/or … … 22 23 #define RenderBR_h 23 24 24 #include "Render Text.h"25 #include "RenderBoxModelObject.h" 25 26 26 /*27 * The whole class here is a hack to get <br> working, as long as we don't have support for28 * CSS2 :before and :after pseudo elements29 */30 27 namespace WebCore { 31 28 32 29 class Position; 33 30 34 class RenderBR FINAL : public Render Text {31 class RenderBR FINAL : public RenderBoxModelObject { 35 32 public: 36 explicit RenderBR( Node*);33 explicit RenderBR(Element*); 37 34 virtual ~RenderBR(); 38 35 36 static RenderBR* createAnonymous(Document&); 37 39 38 virtual const char* renderName() const { return "RenderBR"; } 40 41 virtual LayoutRect selectionRectForRepaint(const RenderLayerModelObject* /*repaintContainer*/, bool /*clipToVisibleContent*/) OVERRIDE { return LayoutRect(); }42 39 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); 45 46 46 int lineHeight(bool firstLine) const;47 IntRect linesBoundingBox() const; 47 48 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; 58 51 59 52 private: 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; 61 84 }; 62 85 … … 73 96 } 74 97 98 inline RenderBR* toRenderBR(RenderObject* object) 99 { 100 ASSERT_WITH_SECURITY_IMPLICATION(object->isBR()); 101 return static_cast<RenderBR*>(object); 102 } 103 104 inline const RenderBR* toRenderBR(const RenderObject* object) 105 { 106 ASSERT_WITH_SECURITY_IMPLICATION(object->isBR()); 107 return static_cast<const RenderBR*>(object); 108 } 109 75 110 // This will catch anyone doing an unnecessary cast. 76 111 void toRenderBR(const RenderBR&); -
trunk/Source/WebCore/rendering/RenderBlock.cpp
r155944 r155957 5112 5112 break; 5113 5113 5114 if (!result->isOutOfFlowPositioned() && (result->isText() || result->is Floating() || result->isReplaced() || result->isRenderInline()))5114 if (!result->isOutOfFlowPositioned() && (result->isText() || result->isBR() || result->isFloating() || result->isReplaced() || result->isRenderInline())) 5115 5115 break; 5116 5116 … … 5968 5968 } 5969 5969 5970 if (!currChild->isText() || currChild->isBR())5970 if (!currChild->isText()) 5971 5971 return; 5972 5972 -
trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp
r155944 r155957 33 33 #include "Logging.h" 34 34 #include "RenderArena.h" 35 #include "RenderBR.h" 35 36 #include "RenderCombineText.h" 36 37 #include "RenderCounter.h" … … 264 265 return toRenderBlock(obj)->createAndAppendRootInlineBox(); 265 266 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(); 274 269 275 270 if (obj->isBox()) 276 271 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 } 277 280 278 281 return toRenderInline(obj)->createAndAppendInlineFlowBox(); … … 294 297 updateCounterIfNeeded(renderText); 295 298 renderText->dirtyLineBoxes(fullLayout); 296 } else 299 } else if (o->isBR()) 300 toRenderBR(o)->dirtyLineBoxes(fullLayout); 301 else 297 302 toRenderInline(o)->dirtyLineBoxes(fullLayout); 298 303 } … … 389 394 unsigned pos = run->stop(); 390 395 RenderObject* r = run->m_object; 391 if (!r->isText() || r->isBR())396 if (!r->isText()) 392 397 return false; 393 398 RenderText* renderText = toRenderText(r); … … 924 929 else if (r->m_object->isBox()) 925 930 toRenderBox(r->m_object)->positionLineBox(r->m_box); 931 else if (r->m_object->isBR()) 932 toRenderBR(r->m_object)->replaceInlineBoxWrapper(r->m_box); 926 933 } 927 934 // Positioned objects and zero-length text nodes destroy their boxes in … … 1834 1841 o->layoutIfNeeded(); 1835 1842 } 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()) 1838 1845 toRenderInline(o)->updateAlwaysCreateLineBoxes(layoutState.isFullLayout()); 1839 1846 if (layoutState.isFullLayout() || o->selfNeedsLayout()) … … 2200 2207 return false; 2201 2208 2209 if (it.m_obj->isBR()) 2210 return true; 2211 2202 2212 if (it.m_obj->isRenderInline() && !alwaysRequiresLineBox(it.m_obj) && !requiresLineBoxForContent(toRenderInline(it.m_obj), lineInfo)) 2203 2213 return false; 2204 2214 2205 if (!shouldCollapseWhiteSpace(it.m_obj->style(), lineInfo, whitespacePosition) || it.m_obj->isBR())2215 if (!shouldCollapseWhiteSpace(it.m_obj->style(), lineInfo, whitespacePosition)) 2206 2216 return true; 2207 2217 … … 2278 2288 next = bidiNextSkippingEmptyInlines(block, next); 2279 2289 2280 if (next && !next->isBR() &&next->isText() && toRenderText(next)->textLength() > 0) {2290 if (next && next->isText() && toRenderText(next)->textLength() > 0) { 2281 2291 RenderText* nextText = toRenderText(next); 2282 2292 UChar nextChar = nextText->characterAt(0); … … 2555 2565 return true; 2556 2566 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())); 2558 2568 if (!nextIsText) 2559 2569 return autoWrap; -
trunk/Source/WebCore/rendering/RenderInline.cpp
r155944 r155957 31 31 #include "Page.h" 32 32 #include "RenderArena.h" 33 #include "RenderBR.h" 33 34 #include "RenderBlock.h" 34 35 #include "RenderFlowThread.h" … … 606 607 yield(FloatRect(logicalTop, childText->y(), logicalHeight, childText->logicalWidth())); 607 608 } 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 } 608 620 } 609 621 } … … 896 908 if (curr->isBox()) 897 909 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()) { 899 915 RenderInline* currInline = toRenderInline(curr); 900 916 InlineBox* result = currInline->firstLineBoxIncludingCulling(); … … 920 936 if (curr->isBox()) 921 937 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()) { 923 943 RenderInline* currInline = toRenderInline(curr); 924 944 InlineBox* result = currInline->lastLineBoxIncludingCulling(); … … 1295 1315 for (InlineTextBox* childText = currText->firstTextBox(); childText; childText = childText->nextTextBox()) 1296 1316 childText->root().markDirty(); 1317 } else if (curr->isBR()) { 1318 RenderBR* currBR = toRenderBR(curr); 1319 if (currBR->inlineBoxWrapper()) 1320 currBR->inlineBoxWrapper()->root().markDirty(); 1297 1321 } 1298 1322 } -
trunk/Source/WebCore/rendering/RenderLineBoxList.cpp
r155944 r155957 34 34 #include "PaintInfo.h" 35 35 #include "RenderArena.h" 36 #include "RenderBR.h" 36 37 #include "RenderInline.h" 37 38 #include "RenderView.h" … … 342 343 if (wrapper) 343 344 box = &wrapper->root(); 345 } if (curr->isBR()) { 346 InlineBox* wrapper = toRenderBR(curr)->inlineBoxWrapper(); 347 if (wrapper) 348 box = &wrapper->root(); 344 349 } else if (curr->isText()) { 345 350 InlineTextBox* textBox = toRenderText(curr)->lastTextBox(); -
trunk/Source/WebCore/rendering/RenderMenuList.cpp
r155944 r155957 42 42 #include "RenderBR.h" 43 43 #include "RenderScrollbar.h" 44 #include "RenderText.h" 44 45 #include "RenderTheme.h" 45 46 #include "RenderView.h" … … 57 58 RenderMenuList::RenderMenuList(HTMLSelectElement& element) 58 59 : RenderFlexibleBox(&element) 59 , m_buttonText(0) 60 , m_innerBlock(0) 60 , m_buttonText(nullptr) 61 , m_buttonBR(nullptr) 62 , m_innerBlock(nullptr) 61 63 , m_needsOptionsWidthUpdate(true) 62 64 , m_optionsWidth(0) … … 161 163 if (m_buttonText) 162 164 m_buttonText->setStyle(style()); 165 if (m_buttonBR) 166 m_buttonBR->setStyle(style()); 163 167 if (m_innerBlock) // RenderBlock handled updating the anonymous block's style. 164 168 adjustInnerStyle(); … … 241 245 { 242 246 if (s.isEmpty()) { 243 if (!m_button Text || !m_buttonText->isBR()) {244 if (m_buttonText) 247 if (!m_buttonBR) { 248 if (m_buttonText) { 245 249 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); 249 256 } 250 257 } else { 251 if (m_buttonText && !m_buttonText->isBR())258 if (m_buttonText) 252 259 m_buttonText->setText(s.impl(), true); 253 260 else { 254 if (m_buttonText) 255 m_buttonText->destroy(); 261 if (m_buttonBR) { 262 m_buttonBR->destroy(); 263 m_buttonBR = nullptr; 264 } 256 265 m_buttonText = new (renderArena()) RenderText(&document(), s.impl()); 257 266 m_buttonText->setStyle(style()); … … 264 273 String RenderMenuList::text() const 265 274 { 266 return m_buttonText ? m_buttonText->text() : 0;275 return m_buttonText ? m_buttonText->text() : m_buttonBR ? String(ASCIILiteral("\n")) : String(); 267 276 } 268 277 -
trunk/Source/WebCore/rendering/RenderMenuList.h
r155673 r155957 39 39 40 40 class HTMLSelectElement; 41 class RenderBR; 41 42 class RenderText; 42 43 … … 137 138 138 139 RenderText* m_buttonText; 140 RenderBR* m_buttonBR; 139 141 RenderBlock* m_innerBlock; 140 142 -
trunk/Source/WebCore/rendering/RenderObject.h
r155944 r155957 1202 1202 return false; 1203 1203 // Text nodes don't have their own styles, so ignore the style on a text node. 1204 if (isText() && !isBR())1204 if (isText()) 1205 1205 return false; 1206 1206 return true; … … 1212 1212 return false; 1213 1213 // Text nodes don't have their own styles, so ignore the style on a text node. 1214 if (isText() && !isBR())1214 if (isText()) 1215 1215 return false; 1216 1216 return true; -
trunk/Source/WebCore/rendering/RenderObjectChildList.cpp
r155366 r155957 29 29 30 30 #include "AXObjectCache.h" 31 #include "RenderBR.h" 31 32 #include "RenderCounter.h" 32 33 #include "RenderObject.h" … … 76 77 if (oldChild->isBox()) 77 78 toRenderBox(oldChild)->deleteLineBoxWrapper(); 79 else if (oldChild->isBR()) 80 toRenderBR(oldChild)->deleteInlineBoxWrapper(); 78 81 79 82 // If oldChild is the start or end of the selection, then clear the selection to -
trunk/Source/WebCore/rendering/RenderText.cpp
r155949 r155957 232 232 if (!documentBeingDestroyed()) { 233 233 if (firstTextBox()) { 234 if (isBR()) {235 RootInlineBox* next = firstTextBox()->root().nextRootBox();236 if (next)237 next->markDirty();238 }239 234 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) 240 235 box->remove(); … … 889 884 m_maxWidth = 0; 890 885 891 if (isBR())892 return;893 894 886 float currMinWidth = 0; 895 887 float currMaxWidth = 0; … … 1366 1358 1367 1359 ASSERT(m_text); 1368 ASSERT(!isBR() || (textLength() == 1 && m_text[0] == '\n'));1369 1360 1370 1361 m_isAllASCII = m_text.containsOnlyASCII(); -
trunk/Source/WebCore/rendering/RenderTreeAsText.cpp
r155761 r155957 252 252 if (adjustForTableCells && !text.firstTextBox()) 253 253 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; 254 260 } else if (o.isRenderInline()) { 261 const RenderInline& inlineFlow = toRenderInline(o); 255 262 // FIXME: Would be better not to just dump 0, 0 as the x and y here. 256 const RenderInline& inlineFlow = toRenderInline(o);257 263 r = IntRect(0, 0, inlineFlow.linesBoundingBox().width(), inlineFlow.linesBoundingBox().height()); 258 264 adjustForTableCells = false; … … 274 280 ts << " " << enclosingIntRect(r); 275 281 276 if (! (o.isText() && !o.isBR())) {282 if (!o.isText()) { 277 283 if (o.isFileUploadControl()) 278 284 ts << " " << quoteAndEscapeNonPrintables(toRenderFileUploadControl(&o)->fileTextValue()); … … 303 309 } 304 310 305 if (!o.isBoxModelObject() )311 if (!o.isBoxModelObject() || o.isBR()) 306 312 return; 307 313 -
trunk/Source/WebCore/rendering/RootInlineBox.cpp
r155949 r155957 847 847 Vector<const SimpleFontData*>* usedFonts = 0; 848 848 GlyphOverflow* glyphOverflow = 0; 849 if (box->is Text()) {849 if (box->isInlineTextBox()) { 850 850 GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.find(toInlineTextBox(box)); 851 851 usedFonts = it == textBoxDataMap.end() ? 0 : &it->value.first; … … 916 916 LayoutUnit ascentWithMargin = box->renderer().style(isFirstLineStyle())->fontMetrics().ascent(baselineType()); 917 917 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()) { 919 919 ascentWithMargin += box->boxModelObject()->borderAndPaddingBefore() + box->boxModelObject()->marginBefore(); 920 920 descentWithMargin += box->boxModelObject()->borderAndPaddingAfter() + box->boxModelObject()->marginAfter(); … … 930 930 LayoutUnit RootInlineBox::verticalPositionForBox(InlineBox* box, VerticalPositionCache& verticalPositionCache) 931 931 { 932 if (box->renderer().isText() )932 if (box->renderer().isText() || box->renderer().isBR()) 933 933 return box->parent()->logicalTop(); 934 934
Note:
See TracChangeset
for help on using the changeset viewer.