Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Side by Side Diff: Source/core/layout/line/InlineFlowBox.cpp

Issue 977113003: Rename renderer() to layoutObject(). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/layout/line/InlineFlowBox.h ('k') | Source/core/layout/line/InlineTextBox.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 m_firstChild = child; 104 m_firstChild = child;
105 m_lastChild = child; 105 m_lastChild = child;
106 } else { 106 } else {
107 m_lastChild->setNextOnLine(child); 107 m_lastChild->setNextOnLine(child);
108 child->setPrevOnLine(m_lastChild); 108 child->setPrevOnLine(m_lastChild);
109 m_lastChild = child; 109 m_lastChild = child;
110 } 110 }
111 child->setFirstLineStyleBit(isFirstLineStyle()); 111 child->setFirstLineStyleBit(isFirstLineStyle());
112 child->setIsHorizontal(isHorizontal()); 112 child->setIsHorizontal(isHorizontal());
113 if (child->isText()) { 113 if (child->isText()) {
114 if (child->renderer().parent() == renderer()) 114 if (child->layoutObject().parent() == layoutObject())
115 m_hasTextChildren = true; 115 m_hasTextChildren = true;
116 setHasTextDescendantsOnAncestors(this); 116 setHasTextDescendantsOnAncestors(this);
117 } else if (child->isInlineFlowBox()) { 117 } else if (child->isInlineFlowBox()) {
118 if (toInlineFlowBox(child)->hasTextDescendants()) 118 if (toInlineFlowBox(child)->hasTextDescendants())
119 setHasTextDescendantsOnAncestors(this); 119 setHasTextDescendantsOnAncestors(this);
120 } 120 }
121 121
122 if (descendantsHaveSameLineHeightAndBaseline() && !child->renderer().isOutOf FlowPositioned()) { 122 if (descendantsHaveSameLineHeightAndBaseline() && !child->layoutObject().isO utOfFlowPositioned()) {
123 const LayoutStyle& parentStyle = renderer().styleRef(isFirstLineStyle()) ; 123 const LayoutStyle& parentStyle = layoutObject().styleRef(isFirstLineStyl e());
124 const LayoutStyle& childStyle = child->renderer().styleRef(isFirstLineSt yle()); 124 const LayoutStyle& childStyle = child->layoutObject().styleRef(isFirstLi neStyle());
125 bool shouldClearDescendantsHaveSameLineHeightAndBaseline = false; 125 bool shouldClearDescendantsHaveSameLineHeightAndBaseline = false;
126 if (child->renderer().isReplaced()) { 126 if (child->layoutObject().isReplaced()) {
127 shouldClearDescendantsHaveSameLineHeightAndBaseline = true; 127 shouldClearDescendantsHaveSameLineHeightAndBaseline = true;
128 } else if (child->isText()) { 128 } else if (child->isText()) {
129 if (child->renderer().isBR() || child->renderer().parent() != render er()) { 129 if (child->layoutObject().isBR() || child->layoutObject().parent() ! = layoutObject()) {
130 if (!parentStyle.font().fontMetrics().hasIdenticalAscentDescentA ndLineGap(childStyle.font().fontMetrics()) 130 if (!parentStyle.font().fontMetrics().hasIdenticalAscentDescentA ndLineGap(childStyle.font().fontMetrics())
131 || parentStyle.lineHeight() != childStyle.lineHeight() 131 || parentStyle.lineHeight() != childStyle.lineHeight()
132 || (parentStyle.verticalAlign() != BASELINE && !isRootInline Box()) || childStyle.verticalAlign() != BASELINE) 132 || (parentStyle.verticalAlign() != BASELINE && !isRootInline Box()) || childStyle.verticalAlign() != BASELINE)
133 shouldClearDescendantsHaveSameLineHeightAndBaseline = true; 133 shouldClearDescendantsHaveSameLineHeightAndBaseline = true;
134 } 134 }
135 if (childStyle.hasTextCombine() || childStyle.textEmphasisMark() != TextEmphasisMarkNone) 135 if (childStyle.hasTextCombine() || childStyle.textEmphasisMark() != TextEmphasisMarkNone)
136 shouldClearDescendantsHaveSameLineHeightAndBaseline = true; 136 shouldClearDescendantsHaveSameLineHeightAndBaseline = true;
137 } else { 137 } else {
138 if (child->renderer().isBR()) { 138 if (child->layoutObject().isBR()) {
139 // FIXME: This is dumb. We only turn off because current layout test results expect the <br> to be 0-height on the baseline. 139 // FIXME: This is dumb. We only turn off because current layout test results expect the <br> to be 0-height on the baseline.
140 // Other than making a zillion tests have to regenerate results, there's no reason to ditch the optimization here. 140 // Other than making a zillion tests have to regenerate results, there's no reason to ditch the optimization here.
141 shouldClearDescendantsHaveSameLineHeightAndBaseline = true; 141 shouldClearDescendantsHaveSameLineHeightAndBaseline = true;
142 } else { 142 } else {
143 ASSERT(isInlineFlowBox()); 143 ASSERT(isInlineFlowBox());
144 InlineFlowBox* childFlowBox = toInlineFlowBox(child); 144 InlineFlowBox* childFlowBox = toInlineFlowBox(child);
145 // Check the child's bit, and then also check for differences in font, line-height, vertical-align 145 // Check the child's bit, and then also check for differences in font, line-height, vertical-align
146 if (!childFlowBox->descendantsHaveSameLineHeightAndBaseline() 146 if (!childFlowBox->descendantsHaveSameLineHeightAndBaseline()
147 || !parentStyle.font().fontMetrics().hasIdenticalAscentDesce ntAndLineGap(childStyle.font().fontMetrics()) 147 || !parentStyle.font().fontMetrics().hasIdenticalAscentDesce ntAndLineGap(childStyle.font().fontMetrics())
148 || parentStyle.lineHeight() != childStyle.lineHeight() 148 || parentStyle.lineHeight() != childStyle.lineHeight()
149 || (parentStyle.verticalAlign() != BASELINE && !isRootInline Box()) || childStyle.verticalAlign() != BASELINE 149 || (parentStyle.verticalAlign() != BASELINE && !isRootInline Box()) || childStyle.verticalAlign() != BASELINE
150 || childStyle.hasBorder() || childStyle.hasPadding() || chil dStyle.hasTextCombine()) 150 || childStyle.hasBorder() || childStyle.hasPadding() || chil dStyle.hasTextCombine())
151 shouldClearDescendantsHaveSameLineHeightAndBaseline = true; 151 shouldClearDescendantsHaveSameLineHeightAndBaseline = true;
152 } 152 }
153 } 153 }
154 154
155 if (shouldClearDescendantsHaveSameLineHeightAndBaseline) 155 if (shouldClearDescendantsHaveSameLineHeightAndBaseline)
156 clearDescendantsHaveSameLineHeightAndBaseline(); 156 clearDescendantsHaveSameLineHeightAndBaseline();
157 } 157 }
158 158
159 if (!child->renderer().isOutOfFlowPositioned()) { 159 if (!child->layoutObject().isOutOfFlowPositioned()) {
160 if (child->isText()) { 160 if (child->isText()) {
161 const LayoutStyle& childStyle = child->renderer().styleRef(isFirstLi neStyle()); 161 const LayoutStyle& childStyle = child->layoutObject().styleRef(isFir stLineStyle());
162 if (childStyle.letterSpacing() < 0 || childStyle.textShadow() || chi ldStyle.textEmphasisMark() != TextEmphasisMarkNone || childStyle.textStrokeWidth ()) 162 if (childStyle.letterSpacing() < 0 || childStyle.textShadow() || chi ldStyle.textEmphasisMark() != TextEmphasisMarkNone || childStyle.textStrokeWidth ())
163 child->clearKnownToHaveNoOverflow(); 163 child->clearKnownToHaveNoOverflow();
164 } else if (child->renderer().isReplaced()) { 164 } else if (child->layoutObject().isReplaced()) {
165 LayoutBox& box = toLayoutBox(child->renderer()); 165 LayoutBox& box = toLayoutBox(child->layoutObject());
166 if (box.hasOverflowModel() || box.hasSelfPaintingLayer()) 166 if (box.hasOverflowModel() || box.hasSelfPaintingLayer())
167 child->clearKnownToHaveNoOverflow(); 167 child->clearKnownToHaveNoOverflow();
168 } else if (!child->renderer().isBR() && (child->renderer().style(isFirst LineStyle())->boxShadow() || child->boxModelObject()->hasSelfPaintingLayer() 168 } else if (!child->layoutObject().isBR() && (child->layoutObject().style (isFirstLineStyle())->boxShadow() || child->boxModelObject()->hasSelfPaintingLay er()
169 || (child->renderer().isListMarker() && !toLayoutListMarker(child->r enderer()).isInside()) 169 || (child->layoutObject().isListMarker() && !toLayoutListMarker(chil d->layoutObject()).isInside())
170 || child->renderer().style(isFirstLineStyle())->hasBorderImageOutset s() 170 || child->layoutObject().style(isFirstLineStyle())->hasBorderImageOu tsets()
171 || child->renderer().style(isFirstLineStyle())->hasOutline())) { 171 || child->layoutObject().style(isFirstLineStyle())->hasOutline())) {
172 child->clearKnownToHaveNoOverflow(); 172 child->clearKnownToHaveNoOverflow();
173 } 173 }
174 174
175 if (knownToHaveNoOverflow() && child->isInlineFlowBox() && !toInlineFlow Box(child)->knownToHaveNoOverflow()) 175 if (knownToHaveNoOverflow() && child->isInlineFlowBox() && !toInlineFlow Box(child)->knownToHaveNoOverflow())
176 clearKnownToHaveNoOverflow(); 176 clearKnownToHaveNoOverflow();
177 } 177 }
178 178
179 checkConsistency(); 179 checkConsistency();
180 } 180 }
181 181
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 { 259 {
260 InlineBox::adjustPosition(dx, dy); 260 InlineBox::adjustPosition(dx, dy);
261 for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) 261 for (InlineBox* child = firstChild(); child; child = child->nextOnLine())
262 child->adjustPosition(dx, dy); 262 child->adjustPosition(dx, dy);
263 if (m_overflow) 263 if (m_overflow)
264 m_overflow->move(dx, dy); // FIXME: Rounding error here since overflow w as pixel snapped, but nobody other than list markers passes non-integral values here. 264 m_overflow->move(dx, dy); // FIXME: Rounding error here since overflow w as pixel snapped, but nobody other than list markers passes non-integral values here.
265 } 265 }
266 266
267 LineBoxList* InlineFlowBox::lineBoxes() const 267 LineBoxList* InlineFlowBox::lineBoxes() const
268 { 268 {
269 return toLayoutInline(renderer()).lineBoxes(); 269 return toLayoutInline(layoutObject()).lineBoxes();
270 } 270 }
271 271
272 static inline bool isLastChildForRenderer(LayoutObject* ancestor, LayoutObject* child) 272 static inline bool isLastChildForRenderer(LayoutObject* ancestor, LayoutObject* child)
273 { 273 {
274 if (!child) 274 if (!child)
275 return false; 275 return false;
276 276
277 if (child == ancestor) 277 if (child == ancestor)
278 return true; 278 return true;
279 279
(...skipping 25 matching lines...) Expand all
305 305
306 void InlineFlowBox::determineSpacingForFlowBoxes(bool lastLine, bool isLogically LastRunWrapped, LayoutObject* logicallyLastRunRenderer) 306 void InlineFlowBox::determineSpacingForFlowBoxes(bool lastLine, bool isLogically LastRunWrapped, LayoutObject* logicallyLastRunRenderer)
307 { 307 {
308 // All boxes start off open. They will not apply any margins/border/padding on 308 // All boxes start off open. They will not apply any margins/border/padding on
309 // any side. 309 // any side.
310 bool includeLeftEdge = false; 310 bool includeLeftEdge = false;
311 bool includeRightEdge = false; 311 bool includeRightEdge = false;
312 312
313 // The root inline box never has borders/margins/padding. 313 // The root inline box never has borders/margins/padding.
314 if (parent()) { 314 if (parent()) {
315 bool ltr = renderer().style()->isLeftToRightDirection(); 315 bool ltr = layoutObject().style()->isLeftToRightDirection();
316 316
317 // Check to see if all initial lines are unconstructed. If so, then 317 // Check to see if all initial lines are unconstructed. If so, then
318 // we know the inline began on this line (unless we are a continuation). 318 // we know the inline began on this line (unless we are a continuation).
319 LineBoxList* lineBoxList = lineBoxes(); 319 LineBoxList* lineBoxList = lineBoxes();
320 if (!lineBoxList->firstLineBox()->isConstructed() && !renderer().isInlin eElementContinuation()) { 320 if (!lineBoxList->firstLineBox()->isConstructed() && !layoutObject().isI nlineElementContinuation()) {
321 if (renderer().style()->boxDecorationBreak() == DCLONE) 321 if (layoutObject().style()->boxDecorationBreak() == DCLONE)
322 includeLeftEdge = includeRightEdge = true; 322 includeLeftEdge = includeRightEdge = true;
323 else if (ltr && lineBoxList->firstLineBox() == this) 323 else if (ltr && lineBoxList->firstLineBox() == this)
324 includeLeftEdge = true; 324 includeLeftEdge = true;
325 else if (!ltr && lineBoxList->lastLineBox() == this) 325 else if (!ltr && lineBoxList->lastLineBox() == this)
326 includeRightEdge = true; 326 includeRightEdge = true;
327 } 327 }
328 328
329 if (!lineBoxList->lastLineBox()->isConstructed()) { 329 if (!lineBoxList->lastLineBox()->isConstructed()) {
330 LayoutInline& inlineFlow = toLayoutInline(renderer()); 330 LayoutInline& inlineFlow = toLayoutInline(layoutObject());
331 bool isLastObjectOnLine = !isAnsectorAndWithinBlock(&renderer(), log icallyLastRunRenderer) || (isLastChildForRenderer(&renderer(), logicallyLastRunR enderer) && !isLogicallyLastRunWrapped); 331 bool isLastObjectOnLine = !isAnsectorAndWithinBlock(&layoutObject(), logicallyLastRunRenderer) || (isLastChildForRenderer(&layoutObject(), logically LastRunRenderer) && !isLogicallyLastRunWrapped);
332 332
333 // We include the border under these conditions: 333 // We include the border under these conditions:
334 // (1) The next line was not created, or it is constructed. We check the previous line for rtl. 334 // (1) The next line was not created, or it is constructed. We check the previous line for rtl.
335 // (2) The logicallyLastRun is not a descendant of this renderer. 335 // (2) The logicallyLastRun is not a descendant of this renderer.
336 // (3) The logicallyLastRun is a descendant of this renderer, but it is the last child of this renderer and it does not wrap to the next line. 336 // (3) The logicallyLastRun is a descendant of this renderer, but it is the last child of this renderer and it does not wrap to the next line.
337 // (4) The decoration break is set to clone therefore there will be borders on every sides. 337 // (4) The decoration break is set to clone therefore there will be borders on every sides.
338 if (renderer().style()->boxDecorationBreak() == DCLONE) { 338 if (layoutObject().style()->boxDecorationBreak() == DCLONE) {
339 includeLeftEdge = includeRightEdge = true; 339 includeLeftEdge = includeRightEdge = true;
340 } else if (ltr) { 340 } else if (ltr) {
341 if (!nextLineBox() 341 if (!nextLineBox()
342 && ((lastLine || isLastObjectOnLine) && !inlineFlow.continua tion())) 342 && ((lastLine || isLastObjectOnLine) && !inlineFlow.continua tion()))
343 includeRightEdge = true; 343 includeRightEdge = true;
344 } else { 344 } else {
345 if ((!prevLineBox() || prevLineBox()->isConstructed()) 345 if ((!prevLineBox() || prevLineBox()->isConstructed())
346 && ((lastLine || isLastObjectOnLine) && !inlineFlow.continua tion())) 346 && ((lastLine || isLastObjectOnLine) && !inlineFlow.continua tion()))
347 includeLeftEdge = true; 347 includeLeftEdge = true;
348 } 348 }
(...skipping 26 matching lines...) Expand all
375 375
376 logicalLeft += borderLogicalRight() + paddingLogicalRight(); 376 logicalLeft += borderLogicalRight() + paddingLogicalRight();
377 endPlacingBoxRangesInInlineDirection(startLogicalLeft, logicalLeft, minLogic alLeft, maxLogicalRight); 377 endPlacingBoxRangesInInlineDirection(startLogicalLeft, logicalLeft, minLogic alLeft, maxLogicalRight);
378 return logicalLeft; 378 return logicalLeft;
379 } 379 }
380 380
381 FloatWillBeLayoutUnit InlineFlowBox::placeBoxRangeInInlineDirection(InlineBox* f irstChild, InlineBox* lastChild, 381 FloatWillBeLayoutUnit InlineFlowBox::placeBoxRangeInInlineDirection(InlineBox* f irstChild, InlineBox* lastChild,
382 FloatWillBeLayoutUnit& logicalLeft, FloatWillBeLayoutUnit& minLogicalLeft, F loatWillBeLayoutUnit& maxLogicalRight, bool& needsWordSpacing) 382 FloatWillBeLayoutUnit& logicalLeft, FloatWillBeLayoutUnit& minLogicalLeft, F loatWillBeLayoutUnit& maxLogicalRight, bool& needsWordSpacing)
383 { 383 {
384 for (InlineBox* curr = firstChild; curr && curr != lastChild; curr = curr->n extOnLine()) { 384 for (InlineBox* curr = firstChild; curr && curr != lastChild; curr = curr->n extOnLine()) {
385 if (curr->renderer().isText()) { 385 if (curr->layoutObject().isText()) {
386 InlineTextBox* text = toInlineTextBox(curr); 386 InlineTextBox* text = toInlineTextBox(curr);
387 LayoutText& rt = text->renderer(); 387 LayoutText& rt = text->layoutObject();
388 FloatWillBeLayoutUnit space; 388 FloatWillBeLayoutUnit space;
389 if (rt.textLength()) { 389 if (rt.textLength()) {
390 if (needsWordSpacing && isSpaceOrNewline(rt.characterAt(text->st art()))) 390 if (needsWordSpacing && isSpaceOrNewline(rt.characterAt(text->st art())))
391 space = rt.style(isFirstLineStyle())->font().fontDescription ().wordSpacing(); 391 space = rt.style(isFirstLineStyle())->font().fontDescription ().wordSpacing();
392 needsWordSpacing = !isSpaceOrNewline(rt.characterAt(text->end()) ); 392 needsWordSpacing = !isSpaceOrNewline(rt.characterAt(text->end()) );
393 } 393 }
394 if (isLeftToRightDirection()) { 394 if (isLeftToRightDirection()) {
395 logicalLeft += space; 395 logicalLeft += space;
396 text->setLogicalLeft(logicalLeft); 396 text->setLogicalLeft(logicalLeft);
397 } else { 397 } else {
398 text->setLogicalLeft(logicalLeft); 398 text->setLogicalLeft(logicalLeft);
399 logicalLeft += space; 399 logicalLeft += space;
400 } 400 }
401 if (knownToHaveNoOverflow()) 401 if (knownToHaveNoOverflow())
402 minLogicalLeft = std::min(logicalLeft, minLogicalLeft); 402 minLogicalLeft = std::min(logicalLeft, minLogicalLeft);
403 logicalLeft += text->logicalWidth(); 403 logicalLeft += text->logicalWidth();
404 if (knownToHaveNoOverflow()) 404 if (knownToHaveNoOverflow())
405 maxLogicalRight = std::max(logicalLeft, maxLogicalRight); 405 maxLogicalRight = std::max(logicalLeft, maxLogicalRight);
406 } else { 406 } else {
407 if (curr->renderer().isOutOfFlowPositioned()) { 407 if (curr->layoutObject().isOutOfFlowPositioned()) {
408 if (curr->renderer().parent()->style()->isLeftToRightDirection() ) { 408 if (curr->layoutObject().parent()->style()->isLeftToRightDirecti on()) {
409 curr->setLogicalLeft(logicalLeft); 409 curr->setLogicalLeft(logicalLeft);
410 } else { 410 } else {
411 // Our offset that we cache needs to be from the edge of the right border box and 411 // Our offset that we cache needs to be from the edge of the right border box and
412 // not the left border box. We have to subtract |x| from th e width of the block 412 // not the left border box. We have to subtract |x| from th e width of the block
413 // (which can be obtained from the root line box). 413 // (which can be obtained from the root line box).
414 curr->setLogicalLeft(root().block().logicalWidth() - logical Left); 414 curr->setLogicalLeft(root().block().logicalWidth() - logical Left);
415 } 415 }
416 continue; // The positioned object has no effect on the width. 416 continue; // The positioned object has no effect on the width.
417 } 417 }
418 if (curr->renderer().isLayoutInline()) { 418 if (curr->layoutObject().isLayoutInline()) {
419 InlineFlowBox* flow = toInlineFlowBox(curr); 419 InlineFlowBox* flow = toInlineFlowBox(curr);
420 logicalLeft += flow->marginLogicalLeft(); 420 logicalLeft += flow->marginLogicalLeft();
421 if (knownToHaveNoOverflow()) 421 if (knownToHaveNoOverflow())
422 minLogicalLeft = std::min(logicalLeft, minLogicalLeft); 422 minLogicalLeft = std::min(logicalLeft, minLogicalLeft);
423 logicalLeft = flow->placeBoxesInInlineDirection(logicalLeft, nee dsWordSpacing); 423 logicalLeft = flow->placeBoxesInInlineDirection(logicalLeft, nee dsWordSpacing);
424 if (knownToHaveNoOverflow()) 424 if (knownToHaveNoOverflow())
425 maxLogicalRight = std::max(logicalLeft, maxLogicalRight); 425 maxLogicalRight = std::max(logicalLeft, maxLogicalRight);
426 logicalLeft += flow->marginLogicalRight(); 426 logicalLeft += flow->marginLogicalRight();
427 } else if (!curr->renderer().isListMarker() || toLayoutListMarker(cu rr->renderer()).isInside()) { 427 } else if (!curr->layoutObject().isListMarker() || toLayoutListMarke r(curr->layoutObject()).isInside()) {
428 // The box can have a different writing-mode than the overall li ne, so this is a bit complicated. 428 // The box can have a different writing-mode than the overall li ne, so this is a bit complicated.
429 // Just get all the physical margin and overflow values by hand based off |isVertical|. 429 // Just get all the physical margin and overflow values by hand based off |isVertical|.
430 LayoutUnit logicalLeftMargin = isHorizontal() ? curr->boxModelOb ject()->marginLeft() : curr->boxModelObject()->marginTop(); 430 LayoutUnit logicalLeftMargin = isHorizontal() ? curr->boxModelOb ject()->marginLeft() : curr->boxModelObject()->marginTop();
431 LayoutUnit logicalRightMargin = isHorizontal() ? curr->boxModelO bject()->marginRight() : curr->boxModelObject()->marginBottom(); 431 LayoutUnit logicalRightMargin = isHorizontal() ? curr->boxModelO bject()->marginRight() : curr->boxModelObject()->marginBottom();
432 432
433 logicalLeft += logicalLeftMargin; 433 logicalLeft += logicalLeftMargin;
434 curr->setLogicalLeft(logicalLeft); 434 curr->setLogicalLeft(logicalLeft);
435 if (knownToHaveNoOverflow()) 435 if (knownToHaveNoOverflow())
436 minLogicalLeft = std::min(logicalLeft, minLogicalLeft); 436 minLogicalLeft = std::min(logicalLeft, minLogicalLeft);
437 logicalLeft += curr->logicalWidth(); 437 logicalLeft += curr->logicalWidth();
438 if (knownToHaveNoOverflow()) 438 if (knownToHaveNoOverflow())
439 maxLogicalRight = std::max(logicalLeft, maxLogicalRight); 439 maxLogicalRight = std::max(logicalLeft, maxLogicalRight);
440 logicalLeft += logicalRightMargin; 440 logicalLeft += logicalRightMargin;
441 // If we encounter any space after this inline block then ensure it is treated as the space between two words. 441 // If we encounter any space after this inline block then ensure it is treated as the space between two words.
442 needsWordSpacing = true; 442 needsWordSpacing = true;
443 } 443 }
444 } 444 }
445 } 445 }
446 return logicalLeft; 446 return logicalLeft;
447 } 447 }
448 448
449 bool InlineFlowBox::requiresIdeographicBaseline(const GlyphOverflowAndFallbackFo ntsMap& textBoxDataMap) const 449 bool InlineFlowBox::requiresIdeographicBaseline(const GlyphOverflowAndFallbackFo ntsMap& textBoxDataMap) const
450 { 450 {
451 if (isHorizontal()) 451 if (isHorizontal())
452 return false; 452 return false;
453 453
454 // FIXME: primaryFont should never be 0 here but can be in some 454 // FIXME: primaryFont should never be 0 here but can be in some
455 // cases. crbug.com/445450 455 // cases. crbug.com/445450
456 RELEASE_ASSERT(renderer().style(isFirstLineStyle())->font().primaryFont()); 456 RELEASE_ASSERT(layoutObject().style(isFirstLineStyle())->font().primaryFont( ));
457 457
458 if (renderer().style(isFirstLineStyle())->fontDescription().nonCJKGlyphOrien tation() == NonCJKGlyphOrientationUpright 458 if (layoutObject().style(isFirstLineStyle())->fontDescription().nonCJKGlyphO rientation() == NonCJKGlyphOrientationUpright
459 || renderer().style(isFirstLineStyle())->font().primaryFont()->hasVertic alGlyphs()) 459 || layoutObject().style(isFirstLineStyle())->font().primaryFont()->hasVe rticalGlyphs())
460 return true; 460 return true;
461 461
462 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { 462 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
463 if (curr->renderer().isOutOfFlowPositioned()) 463 if (curr->layoutObject().isOutOfFlowPositioned())
464 continue; // Positioned placeholders don't affect calculations. 464 continue; // Positioned placeholders don't affect calculations.
465 465
466 if (curr->isInlineFlowBox()) { 466 if (curr->isInlineFlowBox()) {
467 if (toInlineFlowBox(curr)->requiresIdeographicBaseline(textBoxDataMa p)) 467 if (toInlineFlowBox(curr)->requiresIdeographicBaseline(textBoxDataMa p))
468 return true; 468 return true;
469 } else { 469 } else {
470 if (curr->renderer().style(isFirstLineStyle())->font().primaryFont() ->hasVerticalGlyphs()) 470 if (curr->layoutObject().style(isFirstLineStyle())->font().primaryFo nt()->hasVerticalGlyphs())
471 return true; 471 return true;
472 472
473 const Vector<const SimpleFontData*>* usedFonts = 0; 473 const Vector<const SimpleFontData*>* usedFonts = 0;
474 if (curr->isInlineTextBox()) { 474 if (curr->isInlineTextBox()) {
475 GlyphOverflowAndFallbackFontsMap::const_iterator it = textBoxDat aMap.find(toInlineTextBox(curr)); 475 GlyphOverflowAndFallbackFontsMap::const_iterator it = textBoxDat aMap.find(toInlineTextBox(curr));
476 usedFonts = it == textBoxDataMap.end() ? 0 : &it->value.first; 476 usedFonts = it == textBoxDataMap.end() ? 0 : &it->value.first;
477 } 477 }
478 478
479 if (usedFonts) { 479 if (usedFonts) {
480 for (size_t i = 0; i < usedFonts->size(); ++i) { 480 for (size_t i = 0; i < usedFonts->size(); ++i) {
481 if (usedFonts->at(i)->hasVerticalGlyphs()) 481 if (usedFonts->at(i)->hasVerticalGlyphs())
482 return true; 482 return true;
483 } 483 }
484 } 484 }
485 } 485 }
486 } 486 }
487 487
488 return false; 488 return false;
489 } 489 }
490 490
491 void InlineFlowBox::adjustMaxAscentAndDescent(int& maxAscent, int& maxDescent, i nt maxPositionTop, int maxPositionBottom) 491 void InlineFlowBox::adjustMaxAscentAndDescent(int& maxAscent, int& maxDescent, i nt maxPositionTop, int maxPositionBottom)
492 { 492 {
493 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { 493 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
494 // The computed lineheight needs to be extended for the 494 // The computed lineheight needs to be extended for the
495 // positioned elements 495 // positioned elements
496 if (curr->renderer().isOutOfFlowPositioned()) 496 if (curr->layoutObject().isOutOfFlowPositioned())
497 continue; // Positioned placeholders don't affect calculations. 497 continue; // Positioned placeholders don't affect calculations.
498 if (curr->verticalAlign() == TOP || curr->verticalAlign() == BOTTOM) { 498 if (curr->verticalAlign() == TOP || curr->verticalAlign() == BOTTOM) {
499 int lineHeight = curr->lineHeight(); 499 int lineHeight = curr->lineHeight();
500 if (curr->verticalAlign() == TOP) { 500 if (curr->verticalAlign() == TOP) {
501 if (maxAscent + maxDescent < lineHeight) 501 if (maxAscent + maxDescent < lineHeight)
502 maxDescent = lineHeight - maxAscent; 502 maxDescent = lineHeight - maxAscent;
503 } else { 503 } else {
504 if (maxAscent + maxDescent < lineHeight) 504 if (maxAscent + maxDescent < lineHeight)
505 maxAscent = lineHeight - maxDescent; 505 maxAscent = lineHeight - maxDescent;
506 } 506 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 maxDescent = descent; 549 maxDescent = descent;
550 setMaxDescent = true; 550 setMaxDescent = true;
551 } 551 }
552 } 552 }
553 } 553 }
554 554
555 if (!checkChildren) 555 if (!checkChildren)
556 return; 556 return;
557 557
558 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { 558 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
559 if (curr->renderer().isOutOfFlowPositioned()) 559 if (curr->layoutObject().isOutOfFlowPositioned())
560 continue; // Positioned placeholders don't affect calculations. 560 continue; // Positioned placeholders don't affect calculations.
561 561
562 InlineFlowBox* inlineFlowBox = curr->isInlineFlowBox() ? toInlineFlowBox (curr) : 0; 562 InlineFlowBox* inlineFlowBox = curr->isInlineFlowBox() ? toInlineFlowBox (curr) : 0;
563 563
564 bool affectsAscent = false; 564 bool affectsAscent = false;
565 bool affectsDescent = false; 565 bool affectsDescent = false;
566 566
567 // The verticalPositionForBox function returns the distance between the child box's baseline 567 // The verticalPositionForBox function returns the distance between the child box's baseline
568 // and the root box's baseline. The value is negative if the child box' s baseline is above the 568 // and the root box's baseline. The value is negative if the child box' s baseline is above the
569 // root box's baseline, and it is positive if the child box's baseline i s below the root box's baseline. 569 // root box's baseline, and it is positive if the child box's baseline i s below the root box's baseline.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 602
603 if (inlineFlowBox) 603 if (inlineFlowBox)
604 inlineFlowBox->computeLogicalBoxHeights(rootBox, maxPositionTop, max PositionBottom, maxAscent, maxDescent, setMaxAscent, setMaxDescent, strictMode, textBoxDataMap, baselineType, verticalPositionCache); 604 inlineFlowBox->computeLogicalBoxHeights(rootBox, maxPositionTop, max PositionBottom, maxAscent, maxDescent, setMaxAscent, setMaxDescent, strictMode, textBoxDataMap, baselineType, verticalPositionCache);
605 } 605 }
606 } 606 }
607 607
608 void InlineFlowBox::placeBoxesInBlockDirection(LayoutUnit top, LayoutUnit maxHei ght, int maxAscent, bool strictMode, LayoutUnit& lineTop, LayoutUnit& lineBottom , LayoutUnit& selectionBottom, bool& setLineTop, LayoutUnit& lineTopIncludingMar gins, LayoutUnit& lineBottomIncludingMargins, bool& hasAnnotationsBefore, bool& hasAnnotationsAfter, FontBaseline baselineType) 608 void InlineFlowBox::placeBoxesInBlockDirection(LayoutUnit top, LayoutUnit maxHei ght, int maxAscent, bool strictMode, LayoutUnit& lineTop, LayoutUnit& lineBottom , LayoutUnit& selectionBottom, bool& setLineTop, LayoutUnit& lineTopIncludingMar gins, LayoutUnit& lineBottomIncludingMargins, bool& hasAnnotationsBefore, bool& hasAnnotationsAfter, FontBaseline baselineType)
609 { 609 {
610 bool isRootBox = isRootInlineBox(); 610 bool isRootBox = isRootInlineBox();
611 if (isRootBox) { 611 if (isRootBox) {
612 const FontMetrics& fontMetrics = renderer().style(isFirstLineStyle())->f ontMetrics(); 612 const FontMetrics& fontMetrics = layoutObject().style(isFirstLineStyle() )->fontMetrics();
613 // RootInlineBoxes are always placed on at pixel boundaries in their log ical y direction. Not doing 613 // RootInlineBoxes are always placed on at pixel boundaries in their log ical y direction. Not doing
614 // so results in incorrect rendering of text decorations, most notably u nderlines. 614 // so results in incorrect rendering of text decorations, most notably u nderlines.
615 setLogicalTop(roundToInt(top + maxAscent - fontMetrics.ascent(baselineTy pe))); 615 setLogicalTop(roundToInt(top + maxAscent - fontMetrics.ascent(baselineTy pe)));
616 } 616 }
617 617
618 LayoutUnit adjustmentForChildrenWithSameLineHeightAndBaseline = 0; 618 LayoutUnit adjustmentForChildrenWithSameLineHeightAndBaseline = 0;
619 if (descendantsHaveSameLineHeightAndBaseline()) { 619 if (descendantsHaveSameLineHeightAndBaseline()) {
620 adjustmentForChildrenWithSameLineHeightAndBaseline = logicalTop(); 620 adjustmentForChildrenWithSameLineHeightAndBaseline = logicalTop();
621 if (parent()) 621 if (parent())
622 adjustmentForChildrenWithSameLineHeightAndBaseline += (boxModelObjec t()->borderBefore() + boxModelObject()->paddingBefore()); 622 adjustmentForChildrenWithSameLineHeightAndBaseline += (boxModelObjec t()->borderBefore() + boxModelObject()->paddingBefore());
623 } 623 }
624 624
625 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { 625 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
626 if (curr->renderer().isOutOfFlowPositioned()) 626 if (curr->layoutObject().isOutOfFlowPositioned())
627 continue; // Positioned placeholders don't affect calculations. 627 continue; // Positioned placeholders don't affect calculations.
628 628
629 if (descendantsHaveSameLineHeightAndBaseline()) { 629 if (descendantsHaveSameLineHeightAndBaseline()) {
630 curr->adjustBlockDirectionPosition(adjustmentForChildrenWithSameLine HeightAndBaseline.toFloat()); 630 curr->adjustBlockDirectionPosition(adjustmentForChildrenWithSameLine HeightAndBaseline.toFloat());
631 continue; 631 continue;
632 } 632 }
633 633
634 InlineFlowBox* inlineFlowBox = curr->isInlineFlowBox() ? toInlineFlowBox (curr) : 0; 634 InlineFlowBox* inlineFlowBox = curr->isInlineFlowBox() ? toInlineFlowBox (curr) : 0;
635 bool childAffectsTopBottomPos = true; 635 bool childAffectsTopBottomPos = true;
636 if (curr->verticalAlign() == TOP) { 636 if (curr->verticalAlign() == TOP) {
637 curr->setLogicalTop(top.toFloat()); 637 curr->setLogicalTop(top.toFloat());
638 } else if (curr->verticalAlign() == BOTTOM) { 638 } else if (curr->verticalAlign() == BOTTOM) {
639 curr->setLogicalTop((top + maxHeight - curr->lineHeight()).toFloat() ); 639 curr->setLogicalTop((top + maxHeight - curr->lineHeight()).toFloat() );
640 } else { 640 } else {
641 if (!strictMode && inlineFlowBox && !inlineFlowBox->hasTextChildren( ) && !curr->boxModelObject()->hasInlineDirectionBordersOrPadding() 641 if (!strictMode && inlineFlowBox && !inlineFlowBox->hasTextChildren( ) && !curr->boxModelObject()->hasInlineDirectionBordersOrPadding()
642 && !(inlineFlowBox->descendantsHaveSameLineHeightAndBaseline() & & inlineFlowBox->hasTextDescendants())) 642 && !(inlineFlowBox->descendantsHaveSameLineHeightAndBaseline() & & inlineFlowBox->hasTextDescendants()))
643 childAffectsTopBottomPos = false; 643 childAffectsTopBottomPos = false;
644 LayoutUnit posAdjust = maxAscent - curr->baselinePosition(baselineTy pe); 644 LayoutUnit posAdjust = maxAscent - curr->baselinePosition(baselineTy pe);
645 curr->setLogicalTop(curr->logicalTop() + top + posAdjust); 645 curr->setLogicalTop(curr->logicalTop() + top + posAdjust);
646 } 646 }
647 647
648 LayoutUnit newLogicalTop = curr->logicalTop(); 648 LayoutUnit newLogicalTop = curr->logicalTop();
649 LayoutUnit newLogicalTopIncludingMargins = newLogicalTop; 649 LayoutUnit newLogicalTopIncludingMargins = newLogicalTop;
650 LayoutUnit boxHeight = curr->logicalHeight(); 650 LayoutUnit boxHeight = curr->logicalHeight();
651 LayoutUnit boxHeightIncludingMargins = boxHeight; 651 LayoutUnit boxHeightIncludingMargins = boxHeight;
652 LayoutUnit borderPaddingHeight = 0; 652 LayoutUnit borderPaddingHeight = 0;
653 if (curr->isText() || curr->isInlineFlowBox()) { 653 if (curr->isText() || curr->isInlineFlowBox()) {
654 const FontMetrics& fontMetrics = curr->renderer().style(isFirstLineS tyle())->fontMetrics(); 654 const FontMetrics& fontMetrics = curr->layoutObject().style(isFirstL ineStyle())->fontMetrics();
655 newLogicalTop += curr->baselinePosition(baselineType) - fontMetrics. ascent(baselineType); 655 newLogicalTop += curr->baselinePosition(baselineType) - fontMetrics. ascent(baselineType);
656 if (curr->isInlineFlowBox()) { 656 if (curr->isInlineFlowBox()) {
657 LayoutBoxModelObject& boxObject = toLayoutBoxModelObject(curr->r enderer()); 657 LayoutBoxModelObject& boxObject = toLayoutBoxModelObject(curr->l ayoutObject());
658 newLogicalTop -= boxObject.style(isFirstLineStyle())->isHorizont alWritingMode() ? boxObject.borderTop() + boxObject.paddingTop() : 658 newLogicalTop -= boxObject.style(isFirstLineStyle())->isHorizont alWritingMode() ? boxObject.borderTop() + boxObject.paddingTop() :
659 boxObject.borderRight() + boxObject.paddingRight(); 659 boxObject.borderRight() + boxObject.paddingRight();
660 borderPaddingHeight = boxObject.borderAndPaddingLogicalHeight(); 660 borderPaddingHeight = boxObject.borderAndPaddingLogicalHeight();
661 } 661 }
662 newLogicalTopIncludingMargins = newLogicalTop; 662 newLogicalTopIncludingMargins = newLogicalTop;
663 } else if (!curr->renderer().isBR()) { 663 } else if (!curr->layoutObject().isBR()) {
664 LayoutBox& box = toLayoutBox(curr->renderer()); 664 LayoutBox& box = toLayoutBox(curr->layoutObject());
665 newLogicalTopIncludingMargins = newLogicalTop; 665 newLogicalTopIncludingMargins = newLogicalTop;
666 LayoutUnit overSideMargin = curr->isHorizontal() ? box.marginTop() : box.marginRight(); 666 LayoutUnit overSideMargin = curr->isHorizontal() ? box.marginTop() : box.marginRight();
667 LayoutUnit underSideMargin = curr->isHorizontal() ? box.marginBottom () : box.marginLeft(); 667 LayoutUnit underSideMargin = curr->isHorizontal() ? box.marginBottom () : box.marginLeft();
668 newLogicalTop += overSideMargin; 668 newLogicalTop += overSideMargin;
669 boxHeightIncludingMargins += overSideMargin + underSideMargin; 669 boxHeightIncludingMargins += overSideMargin + underSideMargin;
670 } 670 }
671 671
672 curr->setLogicalTop(newLogicalTop.toFloat()); 672 curr->setLogicalTop(newLogicalTop.toFloat());
673 673
674 if (childAffectsTopBottomPos) { 674 if (childAffectsTopBottomPos) {
675 if (curr->renderer().isRubyRun()) { 675 if (curr->layoutObject().isRubyRun()) {
676 // Treat the leading on the first and last lines of ruby runs as not being part of the overall lineTop/lineBottom. 676 // Treat the leading on the first and last lines of ruby runs as not being part of the overall lineTop/lineBottom.
677 // Really this is a workaround hack for the fact that ruby shoul d have been done as line layout and not done using 677 // Really this is a workaround hack for the fact that ruby shoul d have been done as line layout and not done using
678 // inline-block. 678 // inline-block.
679 if (renderer().style()->isFlippedLinesWritingMode() == (curr->re nderer().style()->rubyPosition() == RubyPositionAfter)) 679 if (layoutObject().style()->isFlippedLinesWritingMode() == (curr ->layoutObject().style()->rubyPosition() == RubyPositionAfter))
680 hasAnnotationsBefore = true; 680 hasAnnotationsBefore = true;
681 else 681 else
682 hasAnnotationsAfter = true; 682 hasAnnotationsAfter = true;
683 683
684 LayoutRubyRun& rubyRun = toLayoutRubyRun(curr->renderer()); 684 LayoutRubyRun& rubyRun = toLayoutRubyRun(curr->layoutObject());
685 if (LayoutRubyBase* rubyBase = rubyRun.rubyBase()) { 685 if (LayoutRubyBase* rubyBase = rubyRun.rubyBase()) {
686 LayoutUnit bottomRubyBaseLeading = (curr->logicalHeight() - rubyBase->logicalBottom()) + rubyBase->logicalHeight() - (rubyBase->lastRootBox( ) ? rubyBase->lastRootBox()->lineBottom() : LayoutUnit()); 686 LayoutUnit bottomRubyBaseLeading = (curr->logicalHeight() - rubyBase->logicalBottom()) + rubyBase->logicalHeight() - (rubyBase->lastRootBox( ) ? rubyBase->lastRootBox()->lineBottom() : LayoutUnit());
687 LayoutUnit topRubyBaseLeading = rubyBase->logicalTop() + (ru byBase->firstRootBox() ? rubyBase->firstRootBox()->lineTop() : LayoutUnit()); 687 LayoutUnit topRubyBaseLeading = rubyBase->logicalTop() + (ru byBase->firstRootBox() ? rubyBase->firstRootBox()->lineTop() : LayoutUnit());
688 newLogicalTop += !renderer().style()->isFlippedLinesWritingM ode() ? topRubyBaseLeading : bottomRubyBaseLeading; 688 newLogicalTop += !layoutObject().style()->isFlippedLinesWrit ingMode() ? topRubyBaseLeading : bottomRubyBaseLeading;
689 boxHeight -= (topRubyBaseLeading + bottomRubyBaseLeading); 689 boxHeight -= (topRubyBaseLeading + bottomRubyBaseLeading);
690 } 690 }
691 } 691 }
692 if (curr->isInlineTextBox()) { 692 if (curr->isInlineTextBox()) {
693 TextEmphasisPosition emphasisMarkPosition; 693 TextEmphasisPosition emphasisMarkPosition;
694 if (toInlineTextBox(curr)->getEmphasisMarkPosition(curr->rendere r().styleRef(isFirstLineStyle()), emphasisMarkPosition)) { 694 if (toInlineTextBox(curr)->getEmphasisMarkPosition(curr->layoutO bject().styleRef(isFirstLineStyle()), emphasisMarkPosition)) {
695 bool emphasisMarkIsOver = emphasisMarkPosition == TextEmphas isPositionOver; 695 bool emphasisMarkIsOver = emphasisMarkPosition == TextEmphas isPositionOver;
696 if (emphasisMarkIsOver != curr->renderer().style(isFirstLine Style())->isFlippedLinesWritingMode()) 696 if (emphasisMarkIsOver != curr->layoutObject().style(isFirst LineStyle())->isFlippedLinesWritingMode())
697 hasAnnotationsBefore = true; 697 hasAnnotationsBefore = true;
698 else 698 else
699 hasAnnotationsAfter = true; 699 hasAnnotationsAfter = true;
700 } 700 }
701 } 701 }
702 702
703 if (!setLineTop) { 703 if (!setLineTop) {
704 setLineTop = true; 704 setLineTop = true;
705 lineTop = newLogicalTop; 705 lineTop = newLogicalTop;
706 lineTopIncludingMargins = std::min(lineTop, newLogicalTopIncludi ngMargins); 706 lineTopIncludingMargins = std::min(lineTop, newLogicalTopIncludi ngMargins);
(...skipping 20 matching lines...) Expand all
727 lineTopIncludingMargins = lineTop; 727 lineTopIncludingMargins = lineTop;
728 } else { 728 } else {
729 lineTop = std::min<LayoutUnit>(lineTop, pixelSnappedLogicalTop() ); 729 lineTop = std::min<LayoutUnit>(lineTop, pixelSnappedLogicalTop() );
730 lineTopIncludingMargins = std::min(lineTop, lineTopIncludingMarg ins); 730 lineTopIncludingMargins = std::min(lineTop, lineTopIncludingMarg ins);
731 } 731 }
732 selectionBottom = std::max<LayoutUnit>(selectionBottom, pixelSnapped LogicalBottom()); 732 selectionBottom = std::max<LayoutUnit>(selectionBottom, pixelSnapped LogicalBottom());
733 lineBottom = std::max<LayoutUnit>(lineBottom, pixelSnappedLogicalBot tom()); 733 lineBottom = std::max<LayoutUnit>(lineBottom, pixelSnappedLogicalBot tom());
734 lineBottomIncludingMargins = std::max(lineBottom, lineBottomIncludin gMargins); 734 lineBottomIncludingMargins = std::max(lineBottom, lineBottomIncludin gMargins);
735 } 735 }
736 736
737 if (renderer().style()->isFlippedLinesWritingMode()) 737 if (layoutObject().style()->isFlippedLinesWritingMode())
738 flipLinesInBlockDirection(lineTopIncludingMargins, lineBottomIncludi ngMargins); 738 flipLinesInBlockDirection(lineTopIncludingMargins, lineBottomIncludi ngMargins);
739 } 739 }
740 } 740 }
741 741
742 void InlineFlowBox::computeMaxLogicalTop(FloatWillBeLayoutUnit& maxLogicalTop) c onst 742 void InlineFlowBox::computeMaxLogicalTop(FloatWillBeLayoutUnit& maxLogicalTop) c onst
743 { 743 {
744 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { 744 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
745 if (curr->renderer().isOutOfFlowPositioned()) 745 if (curr->layoutObject().isOutOfFlowPositioned())
746 continue; // Positioned placeholders don't affect calculations. 746 continue; // Positioned placeholders don't affect calculations.
747 747
748 if (descendantsHaveSameLineHeightAndBaseline()) 748 if (descendantsHaveSameLineHeightAndBaseline())
749 continue; 749 continue;
750 750
751 maxLogicalTop = std::max<FloatWillBeLayoutUnit>(maxLogicalTop, curr->y() ); 751 maxLogicalTop = std::max<FloatWillBeLayoutUnit>(maxLogicalTop, curr->y() );
752 FloatWillBeLayoutUnit localMaxLogicalTop; 752 FloatWillBeLayoutUnit localMaxLogicalTop;
753 if (curr->isInlineFlowBox()) 753 if (curr->isInlineFlowBox())
754 toInlineFlowBox(curr)->computeMaxLogicalTop(localMaxLogicalTop); 754 toInlineFlowBox(curr)->computeMaxLogicalTop(localMaxLogicalTop);
755 maxLogicalTop = std::max<FloatWillBeLayoutUnit>(maxLogicalTop, localMaxL ogicalTop); 755 maxLogicalTop = std::max<FloatWillBeLayoutUnit>(maxLogicalTop, localMaxL ogicalTop);
756 } 756 }
757 } 757 }
758 758
759 void InlineFlowBox::flipLinesInBlockDirection(LayoutUnit lineTop, LayoutUnit lin eBottom) 759 void InlineFlowBox::flipLinesInBlockDirection(LayoutUnit lineTop, LayoutUnit lin eBottom)
760 { 760 {
761 // Flip the box on the line such that the top is now relative to the lineBot tom instead of the lineTop. 761 // Flip the box on the line such that the top is now relative to the lineBot tom instead of the lineTop.
762 setLogicalTop(lineBottom - (logicalTop() - lineTop) - logicalHeight()); 762 setLogicalTop(lineBottom - (logicalTop() - lineTop) - logicalHeight());
763 763
764 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { 764 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
765 if (curr->renderer().isOutOfFlowPositioned()) 765 if (curr->layoutObject().isOutOfFlowPositioned())
766 continue; // Positioned placeholders aren't affected here. 766 continue; // Positioned placeholders aren't affected here.
767 767
768 if (curr->isInlineFlowBox()) 768 if (curr->isInlineFlowBox())
769 toInlineFlowBox(curr)->flipLinesInBlockDirection(lineTop, lineBottom ); 769 toInlineFlowBox(curr)->flipLinesInBlockDirection(lineTop, lineBottom );
770 else 770 else
771 curr->setLogicalTop(lineBottom - (curr->logicalTop() - lineTop) - cu rr->logicalHeight()); 771 curr->setLogicalTop(lineBottom - (curr->logicalTop() - lineTop) - cu rr->logicalHeight());
772 } 772 }
773 } 773 }
774 774
775 inline void InlineFlowBox::addBoxShadowVisualOverflow(LayoutRect& logicalVisualO verflow) 775 inline void InlineFlowBox::addBoxShadowVisualOverflow(LayoutRect& logicalVisualO verflow)
776 { 776 {
777 // box-shadow on root line boxes is applying to the block and not to the lin es. 777 // box-shadow on root line boxes is applying to the block and not to the lin es.
778 if (!parent()) 778 if (!parent())
779 return; 779 return;
780 780
781 const LayoutStyle& style = renderer().styleRef(isFirstLineStyle()); 781 const LayoutStyle& style = layoutObject().styleRef(isFirstLineStyle());
782 WritingMode writingMode = style.writingMode(); 782 WritingMode writingMode = style.writingMode();
783 ShadowList* boxShadow = style.boxShadow(); 783 ShadowList* boxShadow = style.boxShadow();
784 if (!boxShadow) 784 if (!boxShadow)
785 return; 785 return;
786 786
787 LayoutRectOutsets outsets(boxShadow->rectOutsetsIncludingOriginal()); 787 LayoutRectOutsets outsets(boxShadow->rectOutsetsIncludingOriginal());
788 // Similar to how glyph overflow works, if our lines are flipped, then it's actually the opposite shadow that applies, since 788 // Similar to how glyph overflow works, if our lines are flipped, then it's actually the opposite shadow that applies, since
789 // the line is "upside down" in terms of block coordinates. 789 // the line is "upside down" in terms of block coordinates.
790 LayoutRectOutsets logicalOutsets(outsets.logicalOutsetsWithFlippedLines(writ ingMode)); 790 LayoutRectOutsets logicalOutsets(outsets.logicalOutsetsWithFlippedLines(writ ingMode));
791 791
792 LayoutRect shadowBounds(logicalFrameRect().toLayoutRect()); 792 LayoutRect shadowBounds(logicalFrameRect().toLayoutRect());
793 shadowBounds.expand(logicalOutsets); 793 shadowBounds.expand(logicalOutsets);
794 logicalVisualOverflow.unite(shadowBounds); 794 logicalVisualOverflow.unite(shadowBounds);
795 } 795 }
796 796
797 inline void InlineFlowBox::addBorderOutsetVisualOverflow(LayoutRect& logicalVisu alOverflow) 797 inline void InlineFlowBox::addBorderOutsetVisualOverflow(LayoutRect& logicalVisu alOverflow)
798 { 798 {
799 // border-image-outset on root line boxes is applying to the block and not t o the lines. 799 // border-image-outset on root line boxes is applying to the block and not t o the lines.
800 if (!parent()) 800 if (!parent())
801 return; 801 return;
802 802
803 const LayoutStyle& style = renderer().styleRef(isFirstLineStyle()); 803 const LayoutStyle& style = layoutObject().styleRef(isFirstLineStyle());
804 if (!style.hasBorderImageOutsets()) 804 if (!style.hasBorderImageOutsets())
805 return; 805 return;
806 806
807 // Similar to how glyph overflow works, if our lines are flipped, then it's actually the opposite border that applies, since 807 // Similar to how glyph overflow works, if our lines are flipped, then it's actually the opposite border that applies, since
808 // the line is "upside down" in terms of block coordinates. vertical-rl and horizontal-bt are the flipped line modes. 808 // the line is "upside down" in terms of block coordinates. vertical-rl and horizontal-bt are the flipped line modes.
809 LayoutRectOutsets logicalOutsets = style.borderImageOutsets().logicalOutsets WithFlippedLines(style.writingMode()); 809 LayoutRectOutsets logicalOutsets = style.borderImageOutsets().logicalOutsets WithFlippedLines(style.writingMode());
810 810
811 if (!includeLogicalLeftEdge()) 811 if (!includeLogicalLeftEdge())
812 logicalOutsets.setLeft(LayoutUnit()); 812 logicalOutsets.setLeft(LayoutUnit());
813 if (!includeLogicalRightEdge()) 813 if (!includeLogicalRightEdge())
814 logicalOutsets.setRight(LayoutUnit()); 814 logicalOutsets.setRight(LayoutUnit());
815 815
816 LayoutRect borderOutsetBounds(logicalFrameRect().toLayoutRect()); 816 LayoutRect borderOutsetBounds(logicalFrameRect().toLayoutRect());
817 borderOutsetBounds.expand(logicalOutsets); 817 borderOutsetBounds.expand(logicalOutsets);
818 logicalVisualOverflow.unite(borderOutsetBounds); 818 logicalVisualOverflow.unite(borderOutsetBounds);
819 } 819 }
820 820
821 inline void InlineFlowBox::addOutlineVisualOverflow(LayoutRect& logicalVisualOve rflow) 821 inline void InlineFlowBox::addOutlineVisualOverflow(LayoutRect& logicalVisualOve rflow)
822 { 822 {
823 // Outline on root line boxes is applied to the block and not to the lines. 823 // Outline on root line boxes is applied to the block and not to the lines.
824 if (!parent()) 824 if (!parent())
825 return; 825 return;
826 826
827 const LayoutStyle& style = renderer().styleRef(isFirstLineStyle()); 827 const LayoutStyle& style = layoutObject().styleRef(isFirstLineStyle());
828 if (!style.hasOutline()) 828 if (!style.hasOutline())
829 return; 829 return;
830 830
831 logicalVisualOverflow.inflate(style.outlineSize()); 831 logicalVisualOverflow.inflate(style.outlineSize());
832 } 832 }
833 833
834 inline void InlineFlowBox::addTextBoxVisualOverflow(InlineTextBox* textBox, Glyp hOverflowAndFallbackFontsMap& textBoxDataMap, LayoutRect& logicalVisualOverflow) 834 inline void InlineFlowBox::addTextBoxVisualOverflow(InlineTextBox* textBox, Glyp hOverflowAndFallbackFontsMap& textBoxDataMap, LayoutRect& logicalVisualOverflow)
835 { 835 {
836 if (textBox->knownToHaveNoOverflow()) 836 if (textBox->knownToHaveNoOverflow())
837 return; 837 return;
838 838
839 const LayoutStyle& style = textBox->renderer().styleRef(isFirstLineStyle()); 839 const LayoutStyle& style = textBox->layoutObject().styleRef(isFirstLineStyle ());
840 840
841 GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.find(textBox) ; 841 GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.find(textBox) ;
842 GlyphOverflow* glyphOverflow = it == textBoxDataMap.end() ? 0 : &it->value.s econd; 842 GlyphOverflow* glyphOverflow = it == textBoxDataMap.end() ? 0 : &it->value.s econd;
843 bool isFlippedLine = style.isFlippedLinesWritingMode(); 843 bool isFlippedLine = style.isFlippedLinesWritingMode();
844 844
845 int topGlyphEdge = glyphOverflow ? (isFlippedLine ? glyphOverflow->bottom : glyphOverflow->top) : 0; 845 int topGlyphEdge = glyphOverflow ? (isFlippedLine ? glyphOverflow->bottom : glyphOverflow->top) : 0;
846 int bottomGlyphEdge = glyphOverflow ? (isFlippedLine ? glyphOverflow->top : glyphOverflow->bottom) : 0; 846 int bottomGlyphEdge = glyphOverflow ? (isFlippedLine ? glyphOverflow->top : glyphOverflow->bottom) : 0;
847 int leftGlyphEdge = glyphOverflow ? glyphOverflow->left : 0; 847 int leftGlyphEdge = glyphOverflow ? glyphOverflow->left : 0;
848 int rightGlyphEdge = glyphOverflow ? glyphOverflow->right : 0; 848 int rightGlyphEdge = glyphOverflow ? glyphOverflow->right : 0;
849 849
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 LayoutUnit logicalLeftVisualOverflow = std::min(textBox->pixelSnappedLogical Left() + childOverflowLogicalLeft, logicalVisualOverflow.x()); 887 LayoutUnit logicalLeftVisualOverflow = std::min(textBox->pixelSnappedLogical Left() + childOverflowLogicalLeft, logicalVisualOverflow.x());
888 LayoutUnit logicalRightVisualOverflow = std::max(textBox->pixelSnappedLogica lRight() + childOverflowLogicalRight, logicalVisualOverflow.maxX()); 888 LayoutUnit logicalRightVisualOverflow = std::max(textBox->pixelSnappedLogica lRight() + childOverflowLogicalRight, logicalVisualOverflow.maxX());
889 889
890 logicalVisualOverflow = LayoutRect(logicalLeftVisualOverflow, logicalTopVisu alOverflow, logicalRightVisualOverflow - logicalLeftVisualOverflow, logicalBotto mVisualOverflow - logicalTopVisualOverflow); 890 logicalVisualOverflow = LayoutRect(logicalLeftVisualOverflow, logicalTopVisu alOverflow, logicalRightVisualOverflow - logicalLeftVisualOverflow, logicalBotto mVisualOverflow - logicalTopVisualOverflow);
891 891
892 textBox->setLogicalOverflowRect(logicalVisualOverflow); 892 textBox->setLogicalOverflowRect(logicalVisualOverflow);
893 } 893 }
894 894
895 inline void InlineFlowBox::addReplacedChildOverflow(const InlineBox* inlineBox, LayoutRect& logicalLayoutOverflow, LayoutRect& logicalVisualOverflow) 895 inline void InlineFlowBox::addReplacedChildOverflow(const InlineBox* inlineBox, LayoutRect& logicalLayoutOverflow, LayoutRect& logicalVisualOverflow)
896 { 896 {
897 LayoutBox& box = toLayoutBox(inlineBox->renderer()); 897 LayoutBox& box = toLayoutBox(inlineBox->layoutObject());
898 898
899 // Visual overflow only propagates if the box doesn't have a self-painting l ayer. This rectangle does not include 899 // Visual overflow only propagates if the box doesn't have a self-painting l ayer. This rectangle does not include
900 // transforms or relative positioning (since those objects always have self- painting layers), but it does need to be adjusted 900 // transforms or relative positioning (since those objects always have self- painting layers), but it does need to be adjusted
901 // for writing-mode differences. 901 // for writing-mode differences.
902 if (!box.hasSelfPaintingLayer()) { 902 if (!box.hasSelfPaintingLayer()) {
903 LayoutRect childLogicalVisualOverflow = box.logicalVisualOverflowRectFor Propagation(renderer().styleRef()); 903 LayoutRect childLogicalVisualOverflow = box.logicalVisualOverflowRectFor Propagation(layoutObject().styleRef());
904 childLogicalVisualOverflow.move(inlineBox->logicalLeft(), inlineBox->log icalTop()); 904 childLogicalVisualOverflow.move(inlineBox->logicalLeft(), inlineBox->log icalTop());
905 logicalVisualOverflow.unite(childLogicalVisualOverflow); 905 logicalVisualOverflow.unite(childLogicalVisualOverflow);
906 } 906 }
907 907
908 // Layout overflow internal to the child box only propagates if the child bo x doesn't have overflow clip set. 908 // Layout overflow internal to the child box only propagates if the child bo x doesn't have overflow clip set.
909 // Otherwise the child border box propagates as layout overflow. This recta ngle must include transforms and relative positioning 909 // Otherwise the child border box propagates as layout overflow. This recta ngle must include transforms and relative positioning
910 // and be adjusted for writing-mode differences. 910 // and be adjusted for writing-mode differences.
911 LayoutRect childLogicalLayoutOverflow = box.logicalLayoutOverflowRectForProp agation(renderer().styleRef()); 911 LayoutRect childLogicalLayoutOverflow = box.logicalLayoutOverflowRectForProp agation(layoutObject().styleRef());
912 childLogicalLayoutOverflow.move(inlineBox->logicalLeft(), inlineBox->logical Top()); 912 childLogicalLayoutOverflow.move(inlineBox->logicalLeft(), inlineBox->logical Top());
913 logicalLayoutOverflow.unite(childLogicalLayoutOverflow); 913 logicalLayoutOverflow.unite(childLogicalLayoutOverflow);
914 } 914 }
915 915
916 void InlineFlowBox::computeOverflow(LayoutUnit lineTop, LayoutUnit lineBottom, G lyphOverflowAndFallbackFontsMap& textBoxDataMap) 916 void InlineFlowBox::computeOverflow(LayoutUnit lineTop, LayoutUnit lineBottom, G lyphOverflowAndFallbackFontsMap& textBoxDataMap)
917 { 917 {
918 // If we know we have no overflow, we can just bail. 918 // If we know we have no overflow, we can just bail.
919 if (knownToHaveNoOverflow()) { 919 if (knownToHaveNoOverflow()) {
920 ASSERT(!m_overflow); 920 ASSERT(!m_overflow);
921 return; 921 return;
922 } 922 }
923 923
924 if (m_overflow) 924 if (m_overflow)
925 m_overflow.clear(); 925 m_overflow.clear();
926 926
927 // Visual overflow just includes overflow for stuff we need to issues paint invalidations for ourselves. Self-painting layers are ignored. 927 // Visual overflow just includes overflow for stuff we need to issues paint invalidations for ourselves. Self-painting layers are ignored.
928 // Layout overflow is used to determine scrolling extent, so it still includ es child layers and also factors in 928 // Layout overflow is used to determine scrolling extent, so it still includ es child layers and also factors in
929 // transforms, relative positioning, etc. 929 // transforms, relative positioning, etc.
930 // FIXME: the call to enclosingLayoutRect() below is temporary and should be removed once 930 // FIXME: the call to enclosingLayoutRect() below is temporary and should be removed once
931 // the transition to LayoutUnit-based types is complete (crbug.com/321237) 931 // the transition to LayoutUnit-based types is complete (crbug.com/321237)
932 LayoutRect logicalLayoutOverflow(logicalFrameRectIncludingLineHeight(lineTop , lineBottom).enclosingLayoutRect()); 932 LayoutRect logicalLayoutOverflow(logicalFrameRectIncludingLineHeight(lineTop , lineBottom).enclosingLayoutRect());
933 LayoutRect logicalVisualOverflow(logicalLayoutOverflow); 933 LayoutRect logicalVisualOverflow(logicalLayoutOverflow);
934 934
935 addBoxShadowVisualOverflow(logicalVisualOverflow); 935 addBoxShadowVisualOverflow(logicalVisualOverflow);
936 addBorderOutsetVisualOverflow(logicalVisualOverflow); 936 addBorderOutsetVisualOverflow(logicalVisualOverflow);
937 addOutlineVisualOverflow(logicalVisualOverflow); 937 addOutlineVisualOverflow(logicalVisualOverflow);
938 938
939 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { 939 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
940 if (curr->renderer().isOutOfFlowPositioned()) 940 if (curr->layoutObject().isOutOfFlowPositioned())
941 continue; // Positioned placeholders don't affect calculations. 941 continue; // Positioned placeholders don't affect calculations.
942 942
943 if (curr->renderer().isText()) { 943 if (curr->layoutObject().isText()) {
944 InlineTextBox* text = toInlineTextBox(curr); 944 InlineTextBox* text = toInlineTextBox(curr);
945 LayoutText& rt = text->renderer(); 945 LayoutText& rt = text->layoutObject();
946 if (rt.isBR()) 946 if (rt.isBR())
947 continue; 947 continue;
948 // FIXME: the call to enclosingLayoutRect() below is temporary and s hould be removed once 948 // FIXME: the call to enclosingLayoutRect() below is temporary and s hould be removed once
949 // the transition to LayoutUnit-based types is complete (crbug.com/3 21237) 949 // the transition to LayoutUnit-based types is complete (crbug.com/3 21237)
950 LayoutRect textBoxOverflow(text->logicalFrameRect().enclosingLayoutR ect()); 950 LayoutRect textBoxOverflow(text->logicalFrameRect().enclosingLayoutR ect());
951 addTextBoxVisualOverflow(text, textBoxDataMap, textBoxOverflow); 951 addTextBoxVisualOverflow(text, textBoxDataMap, textBoxOverflow);
952 logicalVisualOverflow.unite(textBoxOverflow); 952 logicalVisualOverflow.unite(textBoxOverflow);
953 } else if (curr->renderer().isLayoutInline()) { 953 } else if (curr->layoutObject().isLayoutInline()) {
954 InlineFlowBox* flow = toInlineFlowBox(curr); 954 InlineFlowBox* flow = toInlineFlowBox(curr);
955 flow->computeOverflow(lineTop, lineBottom, textBoxDataMap); 955 flow->computeOverflow(lineTop, lineBottom, textBoxDataMap);
956 if (!flow->boxModelObject()->hasSelfPaintingLayer()) 956 if (!flow->boxModelObject()->hasSelfPaintingLayer())
957 logicalVisualOverflow.unite(flow->logicalVisualOverflowRect(line Top, lineBottom)); 957 logicalVisualOverflow.unite(flow->logicalVisualOverflowRect(line Top, lineBottom));
958 LayoutRect childLayoutOverflow = flow->logicalLayoutOverflowRect(lin eTop, lineBottom); 958 LayoutRect childLayoutOverflow = flow->logicalLayoutOverflowRect(lin eTop, lineBottom);
959 childLayoutOverflow.move(flow->boxModelObject()->relativePositionLog icalOffset()); 959 childLayoutOverflow.move(flow->boxModelObject()->relativePositionLog icalOffset());
960 logicalLayoutOverflow.unite(childLayoutOverflow); 960 logicalLayoutOverflow.unite(childLayoutOverflow);
961 } else { 961 } else {
962 addReplacedChildOverflow(curr, logicalLayoutOverflow, logicalVisualO verflow); 962 addReplacedChildOverflow(curr, logicalLayoutOverflow, logicalVisualO verflow);
963 } 963 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 LayoutRect overflowRect(visualOverflowRect(lineTop, lineBottom)); 1006 LayoutRect overflowRect(visualOverflowRect(lineTop, lineBottom));
1007 flipForWritingMode(overflowRect); 1007 flipForWritingMode(overflowRect);
1008 overflowRect.moveBy(accumulatedOffset); 1008 overflowRect.moveBy(accumulatedOffset);
1009 if (!locationInContainer.intersects(overflowRect)) 1009 if (!locationInContainer.intersects(overflowRect))
1010 return false; 1010 return false;
1011 1011
1012 // Check children first. 1012 // Check children first.
1013 // We need to account for culled inline parents of the hit-tested nodes, so that they may also get included in area-based hit-tests. 1013 // We need to account for culled inline parents of the hit-tested nodes, so that they may also get included in area-based hit-tests.
1014 LayoutObject* culledParent = 0; 1014 LayoutObject* culledParent = 0;
1015 for (InlineBox* curr = lastChild(); curr; curr = curr->prevOnLine()) { 1015 for (InlineBox* curr = lastChild(); curr; curr = curr->prevOnLine()) {
1016 if (curr->renderer().isText() || !curr->boxModelObject()->hasSelfPaintin gLayer()) { 1016 if (curr->layoutObject().isText() || !curr->boxModelObject()->hasSelfPai ntingLayer()) {
1017 LayoutObject* newParent = 0; 1017 LayoutObject* newParent = 0;
1018 // Culled parents are only relevant for area-based hit-tests, so ign ore it in point-based ones. 1018 // Culled parents are only relevant for area-based hit-tests, so ign ore it in point-based ones.
1019 if (locationInContainer.isRectBasedTest()) { 1019 if (locationInContainer.isRectBasedTest()) {
1020 newParent = curr->renderer().parent(); 1020 newParent = curr->layoutObject().parent();
1021 if (newParent == renderer()) 1021 if (newParent == layoutObject())
1022 newParent = 0; 1022 newParent = 0;
1023 } 1023 }
1024 // Check the culled parent after all its children have been checked, to do this we wait until 1024 // Check the culled parent after all its children have been checked, to do this we wait until
1025 // we are about to test an element with a different parent. 1025 // we are about to test an element with a different parent.
1026 if (newParent != culledParent) { 1026 if (newParent != culledParent) {
1027 if (!newParent || !newParent->isDescendantOf(culledParent)) { 1027 if (!newParent || !newParent->isDescendantOf(culledParent)) {
1028 while (culledParent && culledParent != renderer() && culledP arent != newParent) { 1028 while (culledParent && culledParent != layoutObject() && cul ledParent != newParent) {
1029 if (culledParent->isLayoutInline() && toLayoutInline(cul ledParent)->hitTestCulledInline(request, result, locationInContainer, accumulate dOffset)) 1029 if (culledParent->isLayoutInline() && toLayoutInline(cul ledParent)->hitTestCulledInline(request, result, locationInContainer, accumulate dOffset))
1030 return true; 1030 return true;
1031 culledParent = culledParent->parent(); 1031 culledParent = culledParent->parent();
1032 } 1032 }
1033 } 1033 }
1034 culledParent = newParent; 1034 culledParent = newParent;
1035 } 1035 }
1036 if (curr->nodeAtPoint(request, result, locationInContainer, accumula tedOffset, lineTop, lineBottom)) { 1036 if (curr->nodeAtPoint(request, result, locationInContainer, accumula tedOffset, lineTop, lineBottom)) {
1037 renderer().updateHitTestResult(result, locationInContainer.point () - toLayoutSize(accumulatedOffset)); 1037 layoutObject().updateHitTestResult(result, locationInContainer.p oint() - toLayoutSize(accumulatedOffset));
1038 return true; 1038 return true;
1039 } 1039 }
1040 } 1040 }
1041 } 1041 }
1042 // Check any culled ancestor of the final children tested. 1042 // Check any culled ancestor of the final children tested.
1043 while (culledParent && culledParent != renderer()) { 1043 while (culledParent && culledParent != layoutObject()) {
1044 if (culledParent->isLayoutInline() && toLayoutInline(culledParent)->hitT estCulledInline(request, result, locationInContainer, accumulatedOffset)) 1044 if (culledParent->isLayoutInline() && toLayoutInline(culledParent)->hitT estCulledInline(request, result, locationInContainer, accumulatedOffset))
1045 return true; 1045 return true;
1046 culledParent = culledParent->parent(); 1046 culledParent = culledParent->parent();
1047 } 1047 }
1048 1048
1049 // Now check ourselves. Pixel snap hit testing. 1049 // Now check ourselves. Pixel snap hit testing.
1050 LayoutRect frameRect(roundedFrameRect()); 1050 LayoutRect frameRect(roundedFrameRect());
1051 LayoutUnit minX = frameRect.x(); 1051 LayoutUnit minX = frameRect.x();
1052 LayoutUnit minY = frameRect.y(); 1052 LayoutUnit minY = frameRect.y();
1053 LayoutUnit width = frameRect.width(); 1053 LayoutUnit width = frameRect.width();
1054 LayoutUnit height = frameRect.height(); 1054 LayoutUnit height = frameRect.height();
1055 1055
1056 // Constrain our hit testing to the line top and bottom if necessary. 1056 // Constrain our hit testing to the line top and bottom if necessary.
1057 bool noQuirksMode = renderer().document().inNoQuirksMode(); 1057 bool noQuirksMode = layoutObject().document().inNoQuirksMode();
1058 if (!noQuirksMode && !hasTextChildren() && !(descendantsHaveSameLineHeightAn dBaseline() && hasTextDescendants())) { 1058 if (!noQuirksMode && !hasTextChildren() && !(descendantsHaveSameLineHeightAn dBaseline() && hasTextDescendants())) {
1059 RootInlineBox& rootBox = root(); 1059 RootInlineBox& rootBox = root();
1060 LayoutUnit& top = isHorizontal() ? minY : minX; 1060 LayoutUnit& top = isHorizontal() ? minY : minX;
1061 LayoutUnit& logicalHeight = isHorizontal() ? height : width; 1061 LayoutUnit& logicalHeight = isHorizontal() ? height : width;
1062 LayoutUnit bottom = std::min(rootBox.lineBottom(), top + logicalHeight); 1062 LayoutUnit bottom = std::min(rootBox.lineBottom(), top + logicalHeight);
1063 top = std::max(rootBox.lineTop(), top); 1063 top = std::max(rootBox.lineTop(), top);
1064 logicalHeight = bottom - top; 1064 logicalHeight = bottom - top;
1065 } 1065 }
1066 1066
1067 // Move x/y to our coordinates. 1067 // Move x/y to our coordinates.
1068 LayoutRect rect(minX, minY, width, height); 1068 LayoutRect rect(minX, minY, width, height);
1069 flipForWritingMode(rect); 1069 flipForWritingMode(rect);
1070 rect.moveBy(accumulatedOffset); 1070 rect.moveBy(accumulatedOffset);
1071 1071
1072 if (visibleToHitTestRequest(request) && locationInContainer.intersects(rect) ) { 1072 if (visibleToHitTestRequest(request) && locationInContainer.intersects(rect) ) {
1073 renderer().updateHitTestResult(result, flipForWritingMode(locationInCont ainer.point() - toLayoutSize(accumulatedOffset))); // Don't add in m_x or m_y he re, we want coords in the containing block's space. 1073 layoutObject().updateHitTestResult(result, flipForWritingMode(locationIn Container.point() - toLayoutSize(accumulatedOffset))); // Don't add in m_x or m_ y here, we want coords in the containing block's space.
1074 if (!result.addNodeToListBasedTestResult(renderer().node(), request, loc ationInContainer, rect)) 1074 if (!result.addNodeToListBasedTestResult(layoutObject().node(), request, locationInContainer, rect))
1075 return true; 1075 return true;
1076 } 1076 }
1077 1077
1078 return false; 1078 return false;
1079 } 1079 }
1080 1080
1081 void InlineFlowBox::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOf fset, LayoutUnit lineTop, LayoutUnit lineBottom) 1081 void InlineFlowBox::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOf fset, LayoutUnit lineTop, LayoutUnit lineBottom)
1082 { 1082 {
1083 InlineFlowBoxPainter(*this).paint(paintInfo, paintOffset, lineTop, lineBotto m); 1083 InlineFlowBoxPainter(*this).paint(paintInfo, paintOffset, lineTop, lineBotto m);
1084 } 1084 }
1085 1085
1086 bool InlineFlowBox::boxShadowCanBeAppliedToBackground(const FillLayer& lastBackg roundLayer) const 1086 bool InlineFlowBox::boxShadowCanBeAppliedToBackground(const FillLayer& lastBackg roundLayer) const
1087 { 1087 {
1088 // The checks here match how paintFillLayer() decides whether to clip (if it does, the shadow 1088 // The checks here match how paintFillLayer() decides whether to clip (if it does, the shadow
1089 // would be clipped out, so it has to be drawn separately). 1089 // would be clipped out, so it has to be drawn separately).
1090 StyleImage* image = lastBackgroundLayer.image(); 1090 StyleImage* image = lastBackgroundLayer.image();
1091 bool hasFillImage = image && image->canRender(renderer(), renderer().style() ->effectiveZoom()); 1091 bool hasFillImage = image && image->canRender(layoutObject(), layoutObject() .style()->effectiveZoom());
1092 return (!hasFillImage && !renderer().style()->hasBorderRadius()) || (!prevLi neBox() && !nextLineBox()) || !parent(); 1092 return (!hasFillImage && !layoutObject().style()->hasBorderRadius()) || (!pr evLineBox() && !nextLineBox()) || !parent();
1093 } 1093 }
1094 1094
1095 InlineBox* InlineFlowBox::firstLeafChild() const 1095 InlineBox* InlineFlowBox::firstLeafChild() const
1096 { 1096 {
1097 InlineBox* leaf = 0; 1097 InlineBox* leaf = 0;
1098 for (InlineBox* child = firstChild(); child && !leaf; child = child->nextOnL ine()) 1098 for (InlineBox* child = firstChild(); child && !leaf; child = child->nextOnL ine())
1099 leaf = child->isLeaf() ? child : toInlineFlowBox(child)->firstLeafChild( ); 1099 leaf = child->isLeaf() ? child : toInlineFlowBox(child)->firstLeafChild( );
1100 return leaf; 1100 return leaf;
1101 } 1101 }
1102 1102
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1154 void InlineFlowBox::clearTruncation() 1154 void InlineFlowBox::clearTruncation()
1155 { 1155 {
1156 for (InlineBox *box = firstChild(); box; box = box->nextOnLine()) 1156 for (InlineBox *box = firstChild(); box; box = box->nextOnLine())
1157 box->clearTruncation(); 1157 box->clearTruncation();
1158 } 1158 }
1159 1159
1160 LayoutUnit InlineFlowBox::computeOverAnnotationAdjustment(LayoutUnit allowedPosi tion) const 1160 LayoutUnit InlineFlowBox::computeOverAnnotationAdjustment(LayoutUnit allowedPosi tion) const
1161 { 1161 {
1162 LayoutUnit result = 0; 1162 LayoutUnit result = 0;
1163 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { 1163 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
1164 if (curr->renderer().isOutOfFlowPositioned()) 1164 if (curr->layoutObject().isOutOfFlowPositioned())
1165 continue; // Positioned placeholders don't affect calculations. 1165 continue; // Positioned placeholders don't affect calculations.
1166 1166
1167 if (curr->isInlineFlowBox()) 1167 if (curr->isInlineFlowBox())
1168 result = std::max(result, toInlineFlowBox(curr)->computeOverAnnotati onAdjustment(allowedPosition)); 1168 result = std::max(result, toInlineFlowBox(curr)->computeOverAnnotati onAdjustment(allowedPosition));
1169 1169
1170 if (curr->renderer().isReplaced() && curr->renderer().isRubyRun() && cur r->renderer().style()->rubyPosition() == RubyPositionBefore) { 1170 if (curr->layoutObject().isReplaced() && curr->layoutObject().isRubyRun( ) && curr->layoutObject().style()->rubyPosition() == RubyPositionBefore) {
1171 LayoutRubyRun& rubyRun = toLayoutRubyRun(curr->renderer()); 1171 LayoutRubyRun& rubyRun = toLayoutRubyRun(curr->layoutObject());
1172 LayoutRubyText* rubyText = rubyRun.rubyText(); 1172 LayoutRubyText* rubyText = rubyRun.rubyText();
1173 if (!rubyText) 1173 if (!rubyText)
1174 continue; 1174 continue;
1175 1175
1176 if (!rubyRun.style()->isFlippedLinesWritingMode()) { 1176 if (!rubyRun.style()->isFlippedLinesWritingMode()) {
1177 LayoutUnit topOfFirstRubyTextLine = rubyText->logicalTop() + (ru byText->firstRootBox() ? rubyText->firstRootBox()->lineTop() : LayoutUnit()); 1177 LayoutUnit topOfFirstRubyTextLine = rubyText->logicalTop() + (ru byText->firstRootBox() ? rubyText->firstRootBox()->lineTop() : LayoutUnit());
1178 if (topOfFirstRubyTextLine >= 0) 1178 if (topOfFirstRubyTextLine >= 0)
1179 continue; 1179 continue;
1180 topOfFirstRubyTextLine += curr->logicalTop(); 1180 topOfFirstRubyTextLine += curr->logicalTop();
1181 result = std::max(result, allowedPosition - topOfFirstRubyTextLi ne); 1181 result = std::max(result, allowedPosition - topOfFirstRubyTextLi ne);
1182 } else { 1182 } else {
1183 LayoutUnit bottomOfLastRubyTextLine = rubyText->logicalTop() + ( rubyText->lastRootBox() ? rubyText->lastRootBox()->lineBottom() : rubyText->logi calHeight()); 1183 LayoutUnit bottomOfLastRubyTextLine = rubyText->logicalTop() + ( rubyText->lastRootBox() ? rubyText->lastRootBox()->lineBottom() : rubyText->logi calHeight());
1184 if (bottomOfLastRubyTextLine <= curr->logicalHeight()) 1184 if (bottomOfLastRubyTextLine <= curr->logicalHeight())
1185 continue; 1185 continue;
1186 bottomOfLastRubyTextLine += curr->logicalTop(); 1186 bottomOfLastRubyTextLine += curr->logicalTop();
1187 result = std::max(result, bottomOfLastRubyTextLine - allowedPosi tion); 1187 result = std::max(result, bottomOfLastRubyTextLine - allowedPosi tion);
1188 } 1188 }
1189 } 1189 }
1190 1190
1191 if (curr->isInlineTextBox()) { 1191 if (curr->isInlineTextBox()) {
1192 const LayoutStyle& style = curr->renderer().styleRef(isFirstLineStyl e()); 1192 const LayoutStyle& style = curr->layoutObject().styleRef(isFirstLine Style());
1193 TextEmphasisPosition emphasisMarkPosition; 1193 TextEmphasisPosition emphasisMarkPosition;
1194 if (style.textEmphasisMark() != TextEmphasisMarkNone && toInlineText Box(curr)->getEmphasisMarkPosition(style, emphasisMarkPosition) && emphasisMarkP osition == TextEmphasisPositionOver) { 1194 if (style.textEmphasisMark() != TextEmphasisMarkNone && toInlineText Box(curr)->getEmphasisMarkPosition(style, emphasisMarkPosition) && emphasisMarkP osition == TextEmphasisPositionOver) {
1195 if (!style.isFlippedLinesWritingMode()) { 1195 if (!style.isFlippedLinesWritingMode()) {
1196 int topOfEmphasisMark = curr->logicalTop() - style.font().em phasisMarkHeight(style.textEmphasisMarkString()); 1196 int topOfEmphasisMark = curr->logicalTop() - style.font().em phasisMarkHeight(style.textEmphasisMarkString());
1197 result = std::max(result, allowedPosition - topOfEmphasisMar k); 1197 result = std::max(result, allowedPosition - topOfEmphasisMar k);
1198 } else { 1198 } else {
1199 int bottomOfEmphasisMark = curr->logicalBottom() + style.fon t().emphasisMarkHeight(style.textEmphasisMarkString()); 1199 int bottomOfEmphasisMark = curr->logicalBottom() + style.fon t().emphasisMarkHeight(style.textEmphasisMarkString());
1200 result = std::max(result, bottomOfEmphasisMark - allowedPosi tion); 1200 result = std::max(result, bottomOfEmphasisMark - allowedPosi tion);
1201 } 1201 }
1202 } 1202 }
1203 } 1203 }
1204 } 1204 }
1205 return result; 1205 return result;
1206 } 1206 }
1207 1207
1208 LayoutUnit InlineFlowBox::computeUnderAnnotationAdjustment(LayoutUnit allowedPos ition) const 1208 LayoutUnit InlineFlowBox::computeUnderAnnotationAdjustment(LayoutUnit allowedPos ition) const
1209 { 1209 {
1210 LayoutUnit result = 0; 1210 LayoutUnit result = 0;
1211 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { 1211 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
1212 if (curr->renderer().isOutOfFlowPositioned()) 1212 if (curr->layoutObject().isOutOfFlowPositioned())
1213 continue; // Positioned placeholders don't affect calculations. 1213 continue; // Positioned placeholders don't affect calculations.
1214 1214
1215 if (curr->isInlineFlowBox()) 1215 if (curr->isInlineFlowBox())
1216 result = std::max(result, toInlineFlowBox(curr)->computeUnderAnnotat ionAdjustment(allowedPosition)); 1216 result = std::max(result, toInlineFlowBox(curr)->computeUnderAnnotat ionAdjustment(allowedPosition));
1217 1217
1218 if (curr->renderer().isReplaced() && curr->renderer().isRubyRun() && cur r->renderer().style()->rubyPosition() == RubyPositionAfter) { 1218 if (curr->layoutObject().isReplaced() && curr->layoutObject().isRubyRun( ) && curr->layoutObject().style()->rubyPosition() == RubyPositionAfter) {
1219 LayoutRubyRun& rubyRun = toLayoutRubyRun(curr->renderer()); 1219 LayoutRubyRun& rubyRun = toLayoutRubyRun(curr->layoutObject());
1220 LayoutRubyText* rubyText = rubyRun.rubyText(); 1220 LayoutRubyText* rubyText = rubyRun.rubyText();
1221 if (!rubyText) 1221 if (!rubyText)
1222 continue; 1222 continue;
1223 1223
1224 if (rubyRun.style()->isFlippedLinesWritingMode()) { 1224 if (rubyRun.style()->isFlippedLinesWritingMode()) {
1225 LayoutUnit topOfFirstRubyTextLine = rubyText->logicalTop() + (ru byText->firstRootBox() ? rubyText->firstRootBox()->lineTop() : LayoutUnit()); 1225 LayoutUnit topOfFirstRubyTextLine = rubyText->logicalTop() + (ru byText->firstRootBox() ? rubyText->firstRootBox()->lineTop() : LayoutUnit());
1226 if (topOfFirstRubyTextLine >= 0) 1226 if (topOfFirstRubyTextLine >= 0)
1227 continue; 1227 continue;
1228 topOfFirstRubyTextLine += curr->logicalTop(); 1228 topOfFirstRubyTextLine += curr->logicalTop();
1229 result = std::max(result, allowedPosition - topOfFirstRubyTextLi ne); 1229 result = std::max(result, allowedPosition - topOfFirstRubyTextLi ne);
1230 } else { 1230 } else {
1231 LayoutUnit bottomOfLastRubyTextLine = rubyText->logicalTop() + ( rubyText->lastRootBox() ? rubyText->lastRootBox()->lineBottom() : rubyText->logi calHeight()); 1231 LayoutUnit bottomOfLastRubyTextLine = rubyText->logicalTop() + ( rubyText->lastRootBox() ? rubyText->lastRootBox()->lineBottom() : rubyText->logi calHeight());
1232 if (bottomOfLastRubyTextLine <= curr->logicalHeight()) 1232 if (bottomOfLastRubyTextLine <= curr->logicalHeight())
1233 continue; 1233 continue;
1234 bottomOfLastRubyTextLine += curr->logicalTop(); 1234 bottomOfLastRubyTextLine += curr->logicalTop();
1235 result = std::max(result, bottomOfLastRubyTextLine - allowedPosi tion); 1235 result = std::max(result, bottomOfLastRubyTextLine - allowedPosi tion);
1236 } 1236 }
1237 } 1237 }
1238 1238
1239 if (curr->isInlineTextBox()) { 1239 if (curr->isInlineTextBox()) {
1240 const LayoutStyle& style = curr->renderer().styleRef(isFirstLineStyl e()); 1240 const LayoutStyle& style = curr->layoutObject().styleRef(isFirstLine Style());
1241 if (style.textEmphasisMark() != TextEmphasisMarkNone && style.textEm phasisPosition() == TextEmphasisPositionUnder) { 1241 if (style.textEmphasisMark() != TextEmphasisMarkNone && style.textEm phasisPosition() == TextEmphasisPositionUnder) {
1242 if (!style.isFlippedLinesWritingMode()) { 1242 if (!style.isFlippedLinesWritingMode()) {
1243 LayoutUnit bottomOfEmphasisMark = curr->logicalBottom() + st yle.font().emphasisMarkHeight(style.textEmphasisMarkString()); 1243 LayoutUnit bottomOfEmphasisMark = curr->logicalBottom() + st yle.font().emphasisMarkHeight(style.textEmphasisMarkString());
1244 result = std::max(result, bottomOfEmphasisMark - allowedPosi tion); 1244 result = std::max(result, bottomOfEmphasisMark - allowedPosi tion);
1245 } else { 1245 } else {
1246 LayoutUnit topOfEmphasisMark = curr->logicalTop() - style.fo nt().emphasisMarkHeight(style.textEmphasisMarkString()); 1246 LayoutUnit topOfEmphasisMark = curr->logicalTop() - style.fo nt().emphasisMarkHeight(style.textEmphasisMarkString());
1247 result = std::max(result, allowedPosition - topOfEmphasisMar k); 1247 result = std::max(result, allowedPosition - topOfEmphasisMar k);
1248 } 1248 }
1249 } 1249 }
1250 } 1250 }
(...skipping 10 matching lines...) Expand all
1261 unsigned char minLevel = 128; 1261 unsigned char minLevel = 128;
1262 unsigned char maxLevel = 0; 1262 unsigned char maxLevel = 0;
1263 1263
1264 // First find highest and lowest levels, and initialize leafBoxesInLogicalOr der with the leaf boxes in visual order. 1264 // First find highest and lowest levels, and initialize leafBoxesInLogicalOr der with the leaf boxes in visual order.
1265 for (; leaf; leaf = leaf->nextLeafChild()) { 1265 for (; leaf; leaf = leaf->nextLeafChild()) {
1266 minLevel = std::min(minLevel, leaf->bidiLevel()); 1266 minLevel = std::min(minLevel, leaf->bidiLevel());
1267 maxLevel = std::max(maxLevel, leaf->bidiLevel()); 1267 maxLevel = std::max(maxLevel, leaf->bidiLevel());
1268 leafBoxesInLogicalOrder.append(leaf); 1268 leafBoxesInLogicalOrder.append(leaf);
1269 } 1269 }
1270 1270
1271 if (renderer().style()->rtlOrdering() == VisualOrder) 1271 if (layoutObject().style()->rtlOrdering() == VisualOrder)
1272 return; 1272 return;
1273 1273
1274 // Reverse of reordering of the line (L2 according to Bidi spec): 1274 // Reverse of reordering of the line (L2 according to Bidi spec):
1275 // L2. From the highest level found in the text to the lowest odd level on e ach line, 1275 // L2. From the highest level found in the text to the lowest odd level on e ach line,
1276 // reverse any contiguous sequence of characters that are at that level or h igher. 1276 // reverse any contiguous sequence of characters that are at that level or h igher.
1277 1277
1278 // Reversing the reordering of the line is only done up to the lowest odd le vel. 1278 // Reversing the reordering of the line is only done up to the lowest odd le vel.
1279 if (!(minLevel % 2)) 1279 if (!(minLevel % 2))
1280 ++minLevel; 1280 ++minLevel;
1281 1281
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1333 ASSERT(child->prevOnLine() == prev); 1333 ASSERT(child->prevOnLine() == prev);
1334 prev = child; 1334 prev = child;
1335 } 1335 }
1336 ASSERT(prev == m_lastChild); 1336 ASSERT(prev == m_lastChild);
1337 #endif 1337 #endif
1338 } 1338 }
1339 1339
1340 #endif 1340 #endif
1341 1341
1342 } // namespace blink 1342 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/line/InlineFlowBox.h ('k') | Source/core/layout/line/InlineTextBox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698