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

Side by Side Diff: third_party/WebKit/WebCore/rendering/InlineFlowBox.cpp

Issue 21184: WebKit merge 40722:40785 (part 1) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 10 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2003, 2004, 2005, 2006, 2007 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 for (InlineBox* child = firstChild(); child; child = child->nextOnLine() ) 48 for (InlineBox* child = firstChild(); child; child = child->nextOnLine() )
49 child->setHasBadParent(); 49 child->setHasBadParent();
50 } 50 }
51 51
52 #endif 52 #endif
53 53
54 int InlineFlowBox::marginLeft() 54 int InlineFlowBox::marginLeft()
55 { 55 {
56 if (!includeLeftEdge()) 56 if (!includeLeftEdge())
57 return 0; 57 return 0;
58 58 return boxModelObject()->marginLeft();
59 Length margin = object()->style()->marginLeft();
60 if (margin.isAuto())
61 return 0;
62 if (margin.isFixed())
63 return margin.value();
64 return renderBox()->marginLeft();
65 } 59 }
66 60
67 int InlineFlowBox::marginRight() 61 int InlineFlowBox::marginRight()
68 { 62 {
69 if (!includeRightEdge()) 63 if (!includeRightEdge())
70 return 0; 64 return 0;
71 65 return boxModelObject()->marginRight();
72 Length margin = object()->style()->marginRight();
73 if (margin.isAuto())
74 return 0;
75 if (margin.isFixed())
76 return margin.value();
77 return renderBox()->marginRight();
78 } 66 }
79 67
80 int InlineFlowBox::marginBorderPaddingLeft() 68 int InlineFlowBox::marginBorderPaddingLeft()
81 { 69 {
82 return marginLeft() + borderLeft() + paddingLeft(); 70 return marginLeft() + borderLeft() + paddingLeft();
83 } 71 }
84 72
85 int InlineFlowBox::marginBorderPaddingRight() 73 int InlineFlowBox::marginBorderPaddingRight()
86 { 74 {
87 return marginRight() + borderRight() + paddingRight(); 75 return marginRight() + borderRight() + paddingRight();
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 311
324 int visualOverflowLeft = leftGlyphOverflow; 312 int visualOverflowLeft = leftGlyphOverflow;
325 int visualOverflowRight = rightGlyphOverflow; 313 int visualOverflowRight = rightGlyphOverflow;
326 for (ShadowData* shadow = rt->style()->textShadow(); shadow; shadow = shadow->next) { 314 for (ShadowData* shadow = rt->style()->textShadow(); shadow; shadow = shadow->next) {
327 visualOverflowLeft = min(visualOverflowLeft, shadow->x - shadow- >blur + leftGlyphOverflow); 315 visualOverflowLeft = min(visualOverflowLeft, shadow->x - shadow- >blur + leftGlyphOverflow);
328 visualOverflowRight = max(visualOverflowRight, shadow->x + shado w->blur + rightGlyphOverflow); 316 visualOverflowRight = max(visualOverflowRight, shadow->x + shado w->blur + rightGlyphOverflow);
329 } 317 }
330 318
331 leftPosition = min(x + visualOverflowLeft, leftPosition); 319 leftPosition = min(x + visualOverflowLeft, leftPosition);
332 rightPosition = max(x + text->width() + visualOverflowRight, rightPo sition); 320 rightPosition = max(x + text->width() + visualOverflowRight, rightPo sition);
333 m_maxHorizontalVisualOverflow = max(max(visualOverflowRight, -visual OverflowLeft), m_maxHorizontalVisualOverflow); 321 m_maxHorizontalVisualOverflow = max(max(visualOverflowRight, -visual OverflowLeft), (int)m_maxHorizontalVisualOverflow);
334 x += text->width(); 322 x += text->width();
335 } else { 323 } else {
336 if (curr->object()->isPositioned()) { 324 if (curr->object()->isPositioned()) {
337 if (curr->object()->parent()->style()->direction() == LTR) 325 if (curr->object()->parent()->style()->direction() == LTR)
338 curr->setXPos(x); 326 curr->setXPos(x);
339 else 327 else
340 // Our offset that we cache needs to be from the edge of the right border box and 328 // Our offset that we cache needs to be from the edge of the right border box and
341 // not the left border box. We have to subtract |x| from th e width of the block 329 // not the left border box. We have to subtract |x| from th e width of the block
342 // (which can be obtained from the root line box). 330 // (which can be obtained from the root line box).
343 curr->setXPos(root()->block()->width()-x); 331 curr->setXPos(root()->block()->width()-x);
344 continue; // The positioned object has no effect on the width. 332 continue; // The positioned object has no effect on the width.
345 } 333 }
346 if (curr->object()->isRenderInline()) { 334 if (curr->object()->isRenderInline()) {
347 InlineFlowBox* flow = static_cast<InlineFlowBox*>(curr); 335 InlineFlowBox* flow = static_cast<InlineFlowBox*>(curr);
348 x += flow->marginLeft(); 336 x += flow->marginLeft();
349 x = flow->placeBoxesHorizontally(x, leftPosition, rightPosition, needsWordSpacing); 337 x = flow->placeBoxesHorizontally(x, leftPosition, rightPosition, needsWordSpacing);
350 x += flow->marginRight(); 338 x += flow->marginRight();
351 } else if (!curr->object()->isListMarker() || static_cast<RenderList Marker*>(curr->object())->isInside()) { 339 } else if (!curr->object()->isListMarker() || static_cast<RenderList Marker*>(curr->object())->isInside()) {
352 x += curr->renderBox()->marginLeft(); 340 x += curr->boxModelObject()->marginLeft();
353 curr->setXPos(x); 341 curr->setXPos(x);
354 leftPosition = min(x + curr->renderBox()->overflowLeft(false), l eftPosition); 342 leftPosition = min(x + toRenderBox(curr->object())->overflowLeft (false), leftPosition);
355 rightPosition = max(x + curr->renderBox()->overflowWidth(false), rightPosition); 343 rightPosition = max(x + toRenderBox(curr->object())->overflowWid th(false), rightPosition);
356 x += curr->width() + curr->renderBox()->marginRight(); 344 x += curr->width() + curr->boxModelObject()->marginRight();
357 } 345 }
358 } 346 }
359 } 347 }
360 348
361 x += borderRight() + paddingRight(); 349 x += borderRight() + paddingRight();
362 setWidth(x - startX); 350 setWidth(x - startX);
363 rightPosition = max(xPos() + width() + boxShadowRight, rightPosition); 351 rightPosition = max(xPos() + width() + boxShadowRight, rightPosition);
364 352
365 return x; 353 return x;
366 } 354 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 maxAscent = ascent; 438 maxAscent = ascent;
451 if (maxDescent < descent) 439 if (maxDescent < descent)
452 maxDescent = descent; 440 maxDescent = descent;
453 } 441 }
454 } 442 }
455 443
456 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { 444 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
457 if (curr->object()->isPositioned()) 445 if (curr->object()->isPositioned())
458 continue; // Positioned placeholders don't affect calculations. 446 continue; // Positioned placeholders don't affect calculations.
459 447
448 bool isInlineFlow = curr->isInlineFlowBox();
449
460 curr->setHeight(curr->object()->lineHeight(m_firstLine)); 450 curr->setHeight(curr->object()->lineHeight(m_firstLine));
461 curr->setBaseline(curr->object()->baselinePosition(m_firstLine)); 451 curr->setBaseline(curr->object()->baselinePosition(m_firstLine));
462 curr->setYPos(curr->object()->verticalPositionHint(m_firstLine)); 452 curr->setYPos(curr->object()->verticalPositionHint(m_firstLine));
463 if (curr->yPos() == PositionTop) { 453 if (curr->yPos() == PositionTop) {
464 if (maxPositionTop < curr->height()) 454 if (maxPositionTop < curr->height())
465 maxPositionTop = curr->height(); 455 maxPositionTop = curr->height();
466 } 456 }
467 else if (curr->yPos() == PositionBottom) { 457 else if (curr->yPos() == PositionBottom) {
468 if (maxPositionBottom < curr->height()) 458 if (maxPositionBottom < curr->height())
469 maxPositionBottom = curr->height(); 459 maxPositionBottom = curr->height();
470 } 460 }
471 else if (curr->hasTextChildren() || curr->renderBox()->hasHorizontalBord ersOrPadding() || strictMode) { 461 else if ((!isInlineFlow || static_cast<InlineFlowBox*>(curr)->hasTextChi ldren()) || curr->boxModelObject()->hasHorizontalBordersOrPadding() || strictMod e) {
472 int ascent = curr->baseline() - curr->yPos(); 462 int ascent = curr->baseline() - curr->yPos();
473 int descent = curr->height() - ascent; 463 int descent = curr->height() - ascent;
474 if (maxAscent < ascent) 464 if (maxAscent < ascent)
475 maxAscent = ascent; 465 maxAscent = ascent;
476 if (maxDescent < descent) 466 if (maxDescent < descent)
477 maxDescent = descent; 467 maxDescent = descent;
478 } 468 }
479 469
480 if (curr->isInlineFlowBox()) 470 if (curr->isInlineFlowBox())
481 static_cast<InlineFlowBox*>(curr)->computeLogicalBoxHeights(maxPosit ionTop, maxPositionBottom, maxAscent, maxDescent, strictMode); 471 static_cast<InlineFlowBox*>(curr)->computeLogicalBoxHeights(maxPosit ionTop, maxPositionBottom, maxAscent, maxDescent, strictMode);
482 } 472 }
483 } 473 }
484 474
485 void InlineFlowBox::placeBoxesVertically(int y, int maxHeight, int maxAscent, bo ol strictMode, 475 void InlineFlowBox::placeBoxesVertically(int y, int maxHeight, int maxAscent, bo ol strictMode,
486 int& topPosition, int& bottomPosition, int& selectionTop, int& selectionBottom) 476 int& topPosition, int& bottomPosition, int& selectionTop, int& selectionBottom)
487 { 477 {
488 if (isRootInlineBox()) 478 if (isRootInlineBox())
489 setYPos(y + maxAscent - baseline());// Place our root box. 479 setYPos(y + maxAscent - baseline());// Place our root box.
490 480
491 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { 481 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
492 if (curr->object()->isPositioned()) 482 if (curr->object()->isPositioned())
493 continue; // Positioned placeholders don't affect calculations. 483 continue; // Positioned placeholders don't affect calculations.
494 484
495 // Adjust boxes to use their real box y/height and not the logical heigh t (as dictated by 485 // Adjust boxes to use their real box y/height and not the logical heigh t (as dictated by
496 // line-height). 486 // line-height).
497 if (curr->isInlineFlowBox()) 487 bool isInlineFlow = curr->isInlineFlowBox();
488 if (isInlineFlow)
498 static_cast<InlineFlowBox*>(curr)->placeBoxesVertically(y, maxHeight , maxAscent, strictMode, topPosition, bottomPosition, selectionTop, selectionBot tom); 489 static_cast<InlineFlowBox*>(curr)->placeBoxesVertically(y, maxHeight , maxAscent, strictMode, topPosition, bottomPosition, selectionTop, selectionBot tom);
499 490
500 bool childAffectsTopBottomPos = true; 491 bool childAffectsTopBottomPos = true;
501 if (curr->yPos() == PositionTop) 492 if (curr->yPos() == PositionTop)
502 curr->setYPos(y); 493 curr->setYPos(y);
503 else if (curr->yPos() == PositionBottom) 494 else if (curr->yPos() == PositionBottom)
504 curr->setYPos(y + maxHeight - curr->height()); 495 curr->setYPos(y + maxHeight - curr->height());
505 else { 496 else {
506 if (!curr->hasTextChildren() && !curr->renderBox()->hasHorizontalBor dersOrPadding() && !strictMode) 497 if ((isInlineFlow && !static_cast<InlineFlowBox*>(curr)->hasTextChil dren()) && !curr->boxModelObject()->hasHorizontalBordersOrPadding() && !strictMo de)
507 childAffectsTopBottomPos = false; 498 childAffectsTopBottomPos = false;
508 curr->setYPos(curr->yPos() + y + maxAscent - curr->baseline()); 499 curr->setYPos(curr->yPos() + y + maxAscent - curr->baseline());
509 } 500 }
510 501
511 int newY = curr->yPos(); 502 int newY = curr->yPos();
512 int newHeight = curr->height(); 503 int newHeight = curr->height();
513 int newBaseline = curr->baseline(); 504 int newBaseline = curr->baseline();
514 int overflowTop = 0; 505 int overflowTop = 0;
515 int overflowBottom = 0; 506 int overflowBottom = 0;
516 if (curr->isText() || curr->isInlineFlowBox()) { 507 if (curr->isText() || curr->isInlineFlowBox()) {
(...skipping 10 matching lines...) Expand all
527 overflowTop = min(overflowTop, boxShadow->y - boxShadow->blur); 518 overflowTop = min(overflowTop, boxShadow->y - boxShadow->blur);
528 overflowBottom = max(overflowBottom, boxShadow->y + boxShadow->b lur); 519 overflowBottom = max(overflowBottom, boxShadow->y + boxShadow->b lur);
529 } 520 }
530 521
531 for (ShadowData* textShadow = curr->object()->style(m_firstLine)->te xtShadow(); textShadow; textShadow = textShadow->next) { 522 for (ShadowData* textShadow = curr->object()->style(m_firstLine)->te xtShadow(); textShadow; textShadow = textShadow->next) {
532 overflowTop = min(overflowTop, textShadow->y - textShadow->blur) ; 523 overflowTop = min(overflowTop, textShadow->y - textShadow->blur) ;
533 overflowBottom = max(overflowBottom, textShadow->y + textShadow- >blur); 524 overflowBottom = max(overflowBottom, textShadow->y + textShadow- >blur);
534 } 525 }
535 526
536 if (curr->object()->hasReflection()) { 527 if (curr->object()->hasReflection()) {
537 overflowTop = min(overflowTop, curr->renderBox()->reflectionBox( ).y()); 528 RenderBox* box = toRenderBox(curr->object());
538 overflowBottom = max(overflowBottom, curr->renderBox()->reflecti onBox().bottom()); 529 overflowTop = min(overflowTop, box->reflectionBox().y());
530 overflowBottom = max(overflowBottom, box->reflectionBox().bottom ());
539 } 531 }
540 532
541 if (curr->isInlineFlowBox()) { 533 if (curr->isInlineFlowBox()) {
542 newHeight += curr->renderBox()->borderTop() + curr->renderBox()- >paddingTop() + 534 newHeight += curr->boxModelObject()->borderTop() + curr->boxMode lObject()->paddingTop() +
543 curr->renderBox()->borderBottom() + curr->renderBox( )->paddingBottom(); 535 curr->boxModelObject()->borderBottom() + curr->boxMo delObject()->paddingBottom();
544 newY -= curr->renderBox()->borderTop() + curr->renderBox()->padd ingTop(); 536 newY -= curr->boxModelObject()->borderTop() + curr->boxModelObje ct()->paddingTop();
545 newBaseline += curr->renderBox()->borderTop() + curr->renderBox( )->paddingTop(); 537 newBaseline += curr->boxModelObject()->borderTop() + curr->boxMo delObject()->paddingTop();
546 } 538 }
547 } else if (!curr->object()->isBR()) { 539 } else if (!curr->object()->isBR()) {
548 newY += curr->renderBox()->marginTop(); 540 RenderBox* box = toRenderBox(curr->object());
549 newHeight = curr->height() - (curr->renderBox()->marginTop() + curr- >renderBox()->marginBottom()); 541 newY += box->marginTop();
550 overflowTop = curr->renderBox()->overflowTop(false); 542 newHeight = curr->height() - (box->marginTop() + box->marginBottom() );
551 overflowBottom = curr->renderBox()->overflowHeight(false) - newHeigh t; 543 overflowTop = box->overflowTop(false);
544 overflowBottom = box->overflowHeight(false) - newHeight;
552 } 545 }
553 546
554 curr->setYPos(newY); 547 curr->setYPos(newY);
555 curr->setHeight(newHeight); 548 curr->setHeight(newHeight);
556 curr->setBaseline(newBaseline); 549 curr->setBaseline(newBaseline);
557 550
558 if (childAffectsTopBottomPos) { 551 if (childAffectsTopBottomPos) {
559 selectionTop = min(selectionTop, newY); 552 selectionTop = min(selectionTop, newY);
560 selectionBottom = max(selectionBottom, newY + newHeight); 553 selectionBottom = max(selectionBottom, newY + newHeight);
561 topPosition = min(topPosition, newY + overflowTop); 554 topPosition = min(topPosition, newY + overflowTop);
(...skipping 18 matching lines...) Expand all
580 // First shrink our kids. 573 // First shrink our kids.
581 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { 574 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
582 if (curr->object()->isPositioned()) 575 if (curr->object()->isPositioned())
583 continue; // Positioned placeholders don't affect calculations. 576 continue; // Positioned placeholders don't affect calculations.
584 577
585 if (curr->isInlineFlowBox()) 578 if (curr->isInlineFlowBox())
586 static_cast<InlineFlowBox*>(curr)->shrinkBoxesWithNoTextChildren(top Pos, bottomPos); 579 static_cast<InlineFlowBox*>(curr)->shrinkBoxesWithNoTextChildren(top Pos, bottomPos);
587 } 580 }
588 581
589 // See if we have text children. If not, then we need to shrink ourselves to fit on the line. 582 // See if we have text children. If not, then we need to shrink ourselves to fit on the line.
590 if (!hasTextChildren() && !renderBox()->hasHorizontalBordersOrPadding()) { 583 if (!hasTextChildren() && !boxModelObject()->hasHorizontalBordersOrPadding() ) {
591 if (yPos() < topPos) 584 if (yPos() < topPos)
592 setYPos(topPos); 585 setYPos(topPos);
593 if (yPos() + height() > bottomPos) 586 if (yPos() + height() > bottomPos)
594 setHeight(bottomPos - yPos()); 587 setHeight(bottomPos - yPos());
595 if (baseline() > height()) 588 if (baseline() > height())
596 setBaseline(height()); 589 setBaseline(height());
597 } 590 }
598 } 591 }
599 592
600 bool InlineFlowBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& re sult, int x, int y, int tx, int ty) 593 bool InlineFlowBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& re sult, int x, int y, int tx, int ty)
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 ASSERT(child->prevOnLine() == prev); 1061 ASSERT(child->prevOnLine() == prev);
1069 prev = child; 1062 prev = child;
1070 } 1063 }
1071 ASSERT(prev == m_lastChild); 1064 ASSERT(prev == m_lastChild);
1072 #endif 1065 #endif
1073 } 1066 }
1074 1067
1075 #endif 1068 #endif
1076 1069
1077 } // namespace WebCore 1070 } // namespace WebCore
OLDNEW
« no previous file with comments | « third_party/WebKit/WebCore/rendering/InlineFlowBox.h ('k') | third_party/WebKit/WebCore/rendering/RenderBlock.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698