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

Side by Side Diff: Source/core/rendering/InlineFlowBox.cpp

Issue 355843002: Rename style(bool) to styleOrFirstLineStyle(bool) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 6 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
« no previous file with comments | « Source/core/rendering/InlineFlowBox.h ('k') | Source/core/rendering/InlineTextBox.cpp » ('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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 if (child->isText()) { 109 if (child->isText()) {
110 if (child->renderer().parent() == renderer()) 110 if (child->renderer().parent() == renderer())
111 m_hasTextChildren = true; 111 m_hasTextChildren = true;
112 setHasTextDescendantsOnAncestors(this); 112 setHasTextDescendantsOnAncestors(this);
113 } else if (child->isInlineFlowBox()) { 113 } else if (child->isInlineFlowBox()) {
114 if (toInlineFlowBox(child)->hasTextDescendants()) 114 if (toInlineFlowBox(child)->hasTextDescendants())
115 setHasTextDescendantsOnAncestors(this); 115 setHasTextDescendantsOnAncestors(this);
116 } 116 }
117 117
118 if (descendantsHaveSameLineHeightAndBaseline() && !child->renderer().isOutOf FlowPositioned()) { 118 if (descendantsHaveSameLineHeightAndBaseline() && !child->renderer().isOutOf FlowPositioned()) {
119 RenderStyle* parentStyle = renderer().style(isFirstLineStyle()); 119 RenderStyle* parentStyle = renderer().styleOrFirstLineStyle(isFirstLineS tyle());
120 RenderStyle* childStyle = child->renderer().style(isFirstLineStyle()); 120 RenderStyle* childStyle = child->renderer().styleOrFirstLineStyle(isFirs tLineStyle());
121 bool shouldClearDescendantsHaveSameLineHeightAndBaseline = false; 121 bool shouldClearDescendantsHaveSameLineHeightAndBaseline = false;
122 if (child->renderer().isReplaced()) 122 if (child->renderer().isReplaced())
123 shouldClearDescendantsHaveSameLineHeightAndBaseline = true; 123 shouldClearDescendantsHaveSameLineHeightAndBaseline = true;
124 else if (child->isText()) { 124 else if (child->isText()) {
125 if (child->renderer().isBR() || child->renderer().parent() != render er()) { 125 if (child->renderer().isBR() || child->renderer().parent() != render er()) {
126 if (!parentStyle->font().fontMetrics().hasIdenticalAscentDescent AndLineGap(childStyle->font().fontMetrics()) 126 if (!parentStyle->font().fontMetrics().hasIdenticalAscentDescent AndLineGap(childStyle->font().fontMetrics())
127 || parentStyle->lineHeight() != childStyle->lineHeight() 127 || parentStyle->lineHeight() != childStyle->lineHeight()
128 || (parentStyle->verticalAlign() != BASELINE && !isRootInlin eBox()) || childStyle->verticalAlign() != BASELINE) 128 || (parentStyle->verticalAlign() != BASELINE && !isRootInlin eBox()) || childStyle->verticalAlign() != BASELINE)
129 shouldClearDescendantsHaveSameLineHeightAndBaseline = true; 129 shouldClearDescendantsHaveSameLineHeightAndBaseline = true;
130 } 130 }
(...skipping 16 matching lines...) Expand all
147 shouldClearDescendantsHaveSameLineHeightAndBaseline = true; 147 shouldClearDescendantsHaveSameLineHeightAndBaseline = true;
148 } 148 }
149 } 149 }
150 150
151 if (shouldClearDescendantsHaveSameLineHeightAndBaseline) 151 if (shouldClearDescendantsHaveSameLineHeightAndBaseline)
152 clearDescendantsHaveSameLineHeightAndBaseline(); 152 clearDescendantsHaveSameLineHeightAndBaseline();
153 } 153 }
154 154
155 if (!child->renderer().isOutOfFlowPositioned()) { 155 if (!child->renderer().isOutOfFlowPositioned()) {
156 if (child->isText()) { 156 if (child->isText()) {
157 RenderStyle* childStyle = child->renderer().style(isFirstLineStyle() ); 157 RenderStyle* childStyle = child->renderer().styleOrFirstLineStyle(is FirstLineStyle());
158 if (childStyle->letterSpacing() < 0 || childStyle->textShadow() || c hildStyle->textEmphasisMark() != TextEmphasisMarkNone || childStyle->textStrokeW idth()) 158 if (childStyle->letterSpacing() < 0 || childStyle->textShadow() || c hildStyle->textEmphasisMark() != TextEmphasisMarkNone || childStyle->textStrokeW idth())
159 child->clearKnownToHaveNoOverflow(); 159 child->clearKnownToHaveNoOverflow();
160 } else if (child->renderer().isReplaced()) { 160 } else if (child->renderer().isReplaced()) {
161 RenderBox& box = toRenderBox(child->renderer()); 161 RenderBox& box = toRenderBox(child->renderer());
162 if (box.hasRenderOverflow() || box.hasSelfPaintingLayer()) 162 if (box.hasRenderOverflow() || box.hasSelfPaintingLayer())
163 child->clearKnownToHaveNoOverflow(); 163 child->clearKnownToHaveNoOverflow();
164 } else if (!child->renderer().isBR() && (child->renderer().style(isFirst LineStyle())->boxShadow() || child->boxModelObject()->hasSelfPaintingLayer() 164 } else if (!child->renderer().isBR() && (child->renderer().styleOrFirstL ineStyle(isFirstLineStyle())->boxShadow() || child->boxModelObject()->hasSelfPai ntingLayer()
165 || (child->renderer().isListMarker() && !toRenderListMarker(child->r enderer()).isInside()) 165 || (child->renderer().isListMarker() && !toRenderListMarker(child->r enderer()).isInside())
166 || child->renderer().style(isFirstLineStyle())->hasBorderImageOutset s() 166 || child->renderer().styleOrFirstLineStyle(isFirstLineStyle())->hasB orderImageOutsets()
167 || child->renderer().style(isFirstLineStyle())->hasOutline())) { 167 || child->renderer().styleOrFirstLineStyle(isFirstLineStyle())->hasO utline())) {
168 child->clearKnownToHaveNoOverflow(); 168 child->clearKnownToHaveNoOverflow();
169 } 169 }
170 170
171 if (knownToHaveNoOverflow() && child->isInlineFlowBox() && !toInlineFlow Box(child)->knownToHaveNoOverflow()) 171 if (knownToHaveNoOverflow() && child->isInlineFlowBox() && !toInlineFlow Box(child)->knownToHaveNoOverflow())
172 clearKnownToHaveNoOverflow(); 172 clearKnownToHaveNoOverflow();
173 } 173 }
174 174
175 checkConsistency(); 175 checkConsistency();
176 } 176 }
177 177
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 } 375 }
376 376
377 float InlineFlowBox::placeBoxRangeInInlineDirection(InlineBox* firstChild, Inlin eBox* lastChild, float& logicalLeft, float& minLogicalLeft, float& maxLogicalRig ht, bool& needsWordSpacing, GlyphOverflowAndFallbackFontsMap& textBoxDataMap) 377 float InlineFlowBox::placeBoxRangeInInlineDirection(InlineBox* firstChild, Inlin eBox* lastChild, float& logicalLeft, float& minLogicalLeft, float& maxLogicalRig ht, bool& needsWordSpacing, GlyphOverflowAndFallbackFontsMap& textBoxDataMap)
378 { 378 {
379 for (InlineBox* curr = firstChild; curr && curr != lastChild; curr = curr->n extOnLine()) { 379 for (InlineBox* curr = firstChild; curr && curr != lastChild; curr = curr->n extOnLine()) {
380 if (curr->renderer().isText()) { 380 if (curr->renderer().isText()) {
381 InlineTextBox* text = toInlineTextBox(curr); 381 InlineTextBox* text = toInlineTextBox(curr);
382 RenderText& rt = toRenderText(text->renderer()); 382 RenderText& rt = toRenderText(text->renderer());
383 if (rt.textLength()) { 383 if (rt.textLength()) {
384 if (needsWordSpacing && isSpaceOrNewline(rt.characterAt(text->st art()))) 384 if (needsWordSpacing && isSpaceOrNewline(rt.characterAt(text->st art())))
385 logicalLeft += rt.style(isFirstLineStyle())->font().fontDesc ription().wordSpacing(); 385 logicalLeft += rt.styleOrFirstLineStyle(isFirstLineStyle())- >font().fontDescription().wordSpacing();
386 needsWordSpacing = !isSpaceOrNewline(rt.characterAt(text->end()) ); 386 needsWordSpacing = !isSpaceOrNewline(rt.characterAt(text->end()) );
387 } 387 }
388 text->setLogicalLeft(logicalLeft); 388 text->setLogicalLeft(logicalLeft);
389 if (knownToHaveNoOverflow()) 389 if (knownToHaveNoOverflow())
390 minLogicalLeft = std::min(logicalLeft, minLogicalLeft); 390 minLogicalLeft = std::min(logicalLeft, minLogicalLeft);
391 logicalLeft += text->logicalWidth(); 391 logicalLeft += text->logicalWidth();
392 if (knownToHaveNoOverflow()) 392 if (knownToHaveNoOverflow())
393 maxLogicalRight = std::max(logicalLeft, maxLogicalRight); 393 maxLogicalRight = std::max(logicalLeft, maxLogicalRight);
394 } else { 394 } else {
395 if (curr->renderer().isOutOfFlowPositioned()) { 395 if (curr->renderer().isOutOfFlowPositioned()) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 } 432 }
433 } 433 }
434 return logicalLeft; 434 return logicalLeft;
435 } 435 }
436 436
437 bool InlineFlowBox::requiresIdeographicBaseline(const GlyphOverflowAndFallbackFo ntsMap& textBoxDataMap) const 437 bool InlineFlowBox::requiresIdeographicBaseline(const GlyphOverflowAndFallbackFo ntsMap& textBoxDataMap) const
438 { 438 {
439 if (isHorizontal()) 439 if (isHorizontal())
440 return false; 440 return false;
441 441
442 if (renderer().style(isFirstLineStyle())->fontDescription().nonCJKGlyphOrien tation() == NonCJKGlyphOrientationUpright 442 if (renderer().styleOrFirstLineStyle(isFirstLineStyle())->fontDescription(). nonCJKGlyphOrientation() == NonCJKGlyphOrientationUpright
443 || renderer().style(isFirstLineStyle())->font().primaryFont()->hasVertic alGlyphs()) 443 || renderer().styleOrFirstLineStyle(isFirstLineStyle())->font().primaryF ont()->hasVerticalGlyphs())
444 return true; 444 return true;
445 445
446 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { 446 for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
447 if (curr->renderer().isOutOfFlowPositioned()) 447 if (curr->renderer().isOutOfFlowPositioned())
448 continue; // Positioned placeholders don't affect calculations. 448 continue; // Positioned placeholders don't affect calculations.
449 449
450 if (curr->isInlineFlowBox()) { 450 if (curr->isInlineFlowBox()) {
451 if (toInlineFlowBox(curr)->requiresIdeographicBaseline(textBoxDataMa p)) 451 if (toInlineFlowBox(curr)->requiresIdeographicBaseline(textBoxDataMa p))
452 return true; 452 return true;
453 } else { 453 } else {
454 if (curr->renderer().style(isFirstLineStyle())->font().primaryFont() ->hasVerticalGlyphs()) 454 if (curr->renderer().styleOrFirstLineStyle(isFirstLineStyle())->font ().primaryFont()->hasVerticalGlyphs())
455 return true; 455 return true;
456 456
457 const Vector<const SimpleFontData*>* usedFonts = 0; 457 const Vector<const SimpleFontData*>* usedFonts = 0;
458 if (curr->isInlineTextBox()) { 458 if (curr->isInlineTextBox()) {
459 GlyphOverflowAndFallbackFontsMap::const_iterator it = textBoxDat aMap.find(toInlineTextBox(curr)); 459 GlyphOverflowAndFallbackFontsMap::const_iterator it = textBoxDat aMap.find(toInlineTextBox(curr));
460 usedFonts = it == textBoxDataMap.end() ? 0 : &it->value.first; 460 usedFonts = it == textBoxDataMap.end() ? 0 : &it->value.first;
461 } 461 }
462 462
463 if (usedFonts) { 463 if (usedFonts) {
464 for (size_t i = 0; i < usedFonts->size(); ++i) { 464 for (size_t i = 0; i < usedFonts->size(); ++i) {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 setMaxAscent, setMaxDescent, strictMode, textBoxDataMap, 594 setMaxAscent, setMaxDescent, strictMode, textBoxDataMap,
595 baselineType, verticalPositi onCache); 595 baselineType, verticalPositi onCache);
596 } 596 }
597 } 597 }
598 598
599 void InlineFlowBox::placeBoxesInBlockDirection(LayoutUnit top, LayoutUnit maxHei ght, int maxAscent, bool strictMode, LayoutUnit& lineTop, LayoutUnit& lineBottom , LayoutUnit& selectionBottom, bool& setLineTop, 599 void InlineFlowBox::placeBoxesInBlockDirection(LayoutUnit top, LayoutUnit maxHei ght, int maxAscent, bool strictMode, LayoutUnit& lineTop, LayoutUnit& lineBottom , LayoutUnit& selectionBottom, bool& setLineTop,
600 LayoutUnit& lineTopIncludingMargi ns, LayoutUnit& lineBottomIncludingMargins, bool& hasAnnotationsBefore, bool& ha sAnnotationsAfter, FontBaseline baselineType) 600 LayoutUnit& lineTopIncludingMargi ns, LayoutUnit& lineBottomIncludingMargins, bool& hasAnnotationsBefore, bool& ha sAnnotationsAfter, FontBaseline baselineType)
601 { 601 {
602 bool isRootBox = isRootInlineBox(); 602 bool isRootBox = isRootInlineBox();
603 if (isRootBox) { 603 if (isRootBox) {
604 const FontMetrics& fontMetrics = renderer().style(isFirstLineStyle())->f ontMetrics(); 604 const FontMetrics& fontMetrics = renderer().styleOrFirstLineStyle(isFirs tLineStyle())->fontMetrics();
605 // RootInlineBoxes are always placed on at pixel boundaries in their log ical y direction. Not doing 605 // RootInlineBoxes are always placed on at pixel boundaries in their log ical y direction. Not doing
606 // so results in incorrect rendering of text decorations, most notably u nderlines. 606 // so results in incorrect rendering of text decorations, most notably u nderlines.
607 setLogicalTop(roundToInt(top + maxAscent - fontMetrics.ascent(baselineTy pe))); 607 setLogicalTop(roundToInt(top + maxAscent - fontMetrics.ascent(baselineTy pe)));
608 } 608 }
609 609
610 LayoutUnit adjustmentForChildrenWithSameLineHeightAndBaseline = 0; 610 LayoutUnit adjustmentForChildrenWithSameLineHeightAndBaseline = 0;
611 if (descendantsHaveSameLineHeightAndBaseline()) { 611 if (descendantsHaveSameLineHeightAndBaseline()) {
612 adjustmentForChildrenWithSameLineHeightAndBaseline = logicalTop(); 612 adjustmentForChildrenWithSameLineHeightAndBaseline = logicalTop();
613 if (parent()) 613 if (parent())
614 adjustmentForChildrenWithSameLineHeightAndBaseline += (boxModelObjec t()->borderBefore() + boxModelObject()->paddingBefore()); 614 adjustmentForChildrenWithSameLineHeightAndBaseline += (boxModelObjec t()->borderBefore() + boxModelObject()->paddingBefore());
(...skipping 21 matching lines...) Expand all
636 LayoutUnit posAdjust = maxAscent - curr->baselinePosition(baselineTy pe); 636 LayoutUnit posAdjust = maxAscent - curr->baselinePosition(baselineTy pe);
637 curr->setLogicalTop(curr->logicalTop() + top + posAdjust); 637 curr->setLogicalTop(curr->logicalTop() + top + posAdjust);
638 } 638 }
639 639
640 LayoutUnit newLogicalTop = curr->logicalTop(); 640 LayoutUnit newLogicalTop = curr->logicalTop();
641 LayoutUnit newLogicalTopIncludingMargins = newLogicalTop; 641 LayoutUnit newLogicalTopIncludingMargins = newLogicalTop;
642 LayoutUnit boxHeight = curr->logicalHeight(); 642 LayoutUnit boxHeight = curr->logicalHeight();
643 LayoutUnit boxHeightIncludingMargins = boxHeight; 643 LayoutUnit boxHeightIncludingMargins = boxHeight;
644 LayoutUnit borderPaddingHeight = 0; 644 LayoutUnit borderPaddingHeight = 0;
645 if (curr->isText() || curr->isInlineFlowBox()) { 645 if (curr->isText() || curr->isInlineFlowBox()) {
646 const FontMetrics& fontMetrics = curr->renderer().style(isFirstLineS tyle())->fontMetrics(); 646 const FontMetrics& fontMetrics = curr->renderer().styleOrFirstLineSt yle(isFirstLineStyle())->fontMetrics();
647 newLogicalTop += curr->baselinePosition(baselineType) - fontMetrics. ascent(baselineType); 647 newLogicalTop += curr->baselinePosition(baselineType) - fontMetrics. ascent(baselineType);
648 if (curr->isInlineFlowBox()) { 648 if (curr->isInlineFlowBox()) {
649 RenderBoxModelObject& boxObject = toRenderBoxModelObject(curr->r enderer()); 649 RenderBoxModelObject& boxObject = toRenderBoxModelObject(curr->r enderer());
650 newLogicalTop -= boxObject.style(isFirstLineStyle())->isHorizont alWritingMode() ? boxObject.borderTop() + boxObject.paddingTop() : 650 newLogicalTop -= boxObject.styleOrFirstLineStyle(isFirstLineStyl e())->isHorizontalWritingMode() ? boxObject.borderTop() + boxObject.paddingTop() :
651 boxObject.borderRight() + boxObject.paddingRight(); 651 boxObject.borderRight() + boxObject.paddingRight();
652 borderPaddingHeight = boxObject.borderAndPaddingLogicalHeight(); 652 borderPaddingHeight = boxObject.borderAndPaddingLogicalHeight();
653 } 653 }
654 newLogicalTopIncludingMargins = newLogicalTop; 654 newLogicalTopIncludingMargins = newLogicalTop;
655 } else if (!curr->renderer().isBR()) { 655 } else if (!curr->renderer().isBR()) {
656 RenderBox& box = toRenderBox(curr->renderer()); 656 RenderBox& box = toRenderBox(curr->renderer());
657 newLogicalTopIncludingMargins = newLogicalTop; 657 newLogicalTopIncludingMargins = newLogicalTop;
658 LayoutUnit overSideMargin = curr->isHorizontal() ? box.marginTop() : box.marginRight(); 658 LayoutUnit overSideMargin = curr->isHorizontal() ? box.marginTop() : box.marginRight();
659 LayoutUnit underSideMargin = curr->isHorizontal() ? box.marginBottom () : box.marginLeft(); 659 LayoutUnit underSideMargin = curr->isHorizontal() ? box.marginBottom () : box.marginLeft();
660 newLogicalTop += overSideMargin; 660 newLogicalTop += overSideMargin;
(...skipping 15 matching lines...) Expand all
676 RenderRubyRun& rubyRun = toRenderRubyRun(curr->renderer()); 676 RenderRubyRun& rubyRun = toRenderRubyRun(curr->renderer());
677 if (RenderRubyBase* rubyBase = rubyRun.rubyBase()) { 677 if (RenderRubyBase* rubyBase = rubyRun.rubyBase()) {
678 LayoutUnit bottomRubyBaseLeading = (curr->logicalHeight() - rubyBase->logicalBottom()) + rubyBase->logicalHeight() - (rubyBase->lastRootBox( ) ? rubyBase->lastRootBox()->lineBottom() : LayoutUnit()); 678 LayoutUnit bottomRubyBaseLeading = (curr->logicalHeight() - rubyBase->logicalBottom()) + rubyBase->logicalHeight() - (rubyBase->lastRootBox( ) ? rubyBase->lastRootBox()->lineBottom() : LayoutUnit());
679 LayoutUnit topRubyBaseLeading = rubyBase->logicalTop() + (ru byBase->firstRootBox() ? rubyBase->firstRootBox()->lineTop() : LayoutUnit()); 679 LayoutUnit topRubyBaseLeading = rubyBase->logicalTop() + (ru byBase->firstRootBox() ? rubyBase->firstRootBox()->lineTop() : LayoutUnit());
680 newLogicalTop += !renderer().style()->isFlippedLinesWritingM ode() ? topRubyBaseLeading : bottomRubyBaseLeading; 680 newLogicalTop += !renderer().style()->isFlippedLinesWritingM ode() ? topRubyBaseLeading : bottomRubyBaseLeading;
681 boxHeight -= (topRubyBaseLeading + bottomRubyBaseLeading); 681 boxHeight -= (topRubyBaseLeading + bottomRubyBaseLeading);
682 } 682 }
683 } 683 }
684 if (curr->isInlineTextBox()) { 684 if (curr->isInlineTextBox()) {
685 TextEmphasisPosition emphasisMarkPosition; 685 TextEmphasisPosition emphasisMarkPosition;
686 if (toInlineTextBox(curr)->getEmphasisMarkPosition(curr->rendere r().style(isFirstLineStyle()), emphasisMarkPosition)) { 686 if (toInlineTextBox(curr)->getEmphasisMarkPosition(curr->rendere r().styleOrFirstLineStyle(isFirstLineStyle()), emphasisMarkPosition)) {
687 bool emphasisMarkIsOver = emphasisMarkPosition == TextEmphas isPositionOver; 687 bool emphasisMarkIsOver = emphasisMarkPosition == TextEmphas isPositionOver;
688 if (emphasisMarkIsOver != curr->renderer().style(isFirstLine Style())->isFlippedLinesWritingMode()) 688 if (emphasisMarkIsOver != curr->renderer().styleOrFirstLineS tyle(isFirstLineStyle())->isFlippedLinesWritingMode())
689 hasAnnotationsBefore = true; 689 hasAnnotationsBefore = true;
690 else 690 else
691 hasAnnotationsAfter = true; 691 hasAnnotationsAfter = true;
692 } 692 }
693 } 693 }
694 694
695 if (!setLineTop) { 695 if (!setLineTop) {
696 setLineTop = true; 696 setLineTop = true;
697 lineTop = newLogicalTop; 697 lineTop = newLogicalTop;
698 lineTopIncludingMargins = std::min(lineTop, newLogicalTopIncludi ngMargins); 698 lineTopIncludingMargins = std::min(lineTop, newLogicalTopIncludi ngMargins);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 curr->setLogicalTop(lineBottom - (curr->logicalTop() - lineTop) - cu rr->logicalHeight()); 764 curr->setLogicalTop(lineBottom - (curr->logicalTop() - lineTop) - cu rr->logicalHeight());
765 } 765 }
766 } 766 }
767 767
768 inline void InlineFlowBox::addBoxShadowVisualOverflow(LayoutRect& logicalVisualO verflow) 768 inline void InlineFlowBox::addBoxShadowVisualOverflow(LayoutRect& logicalVisualO verflow)
769 { 769 {
770 // box-shadow on root line boxes is applying to the block and not to the lin es. 770 // box-shadow on root line boxes is applying to the block and not to the lin es.
771 if (!parent()) 771 if (!parent())
772 return; 772 return;
773 773
774 RenderStyle* style = renderer().style(isFirstLineStyle()); 774 RenderStyle* style = renderer().styleOrFirstLineStyle(isFirstLineStyle());
775 if (!style->boxShadow()) 775 if (!style->boxShadow())
776 return; 776 return;
777 777
778 LayoutUnit boxShadowLogicalTop; 778 LayoutUnit boxShadowLogicalTop;
779 LayoutUnit boxShadowLogicalBottom; 779 LayoutUnit boxShadowLogicalBottom;
780 style->getBoxShadowBlockDirectionExtent(boxShadowLogicalTop, boxShadowLogica lBottom); 780 style->getBoxShadowBlockDirectionExtent(boxShadowLogicalTop, boxShadowLogica lBottom);
781 781
782 // Similar to how glyph overflow works, if our lines are flipped, then it's actually the opposite shadow that applies, since 782 // Similar to how glyph overflow works, if our lines are flipped, then it's actually the opposite shadow that applies, since
783 // the line is "upside down" in terms of block coordinates. 783 // the line is "upside down" in terms of block coordinates.
784 LayoutUnit shadowLogicalTop = style->isFlippedLinesWritingMode() ? -boxShado wLogicalBottom : boxShadowLogicalTop; 784 LayoutUnit shadowLogicalTop = style->isFlippedLinesWritingMode() ? -boxShado wLogicalBottom : boxShadowLogicalTop;
(...skipping 12 matching lines...) Expand all
797 logicalVisualOverflow = LayoutRect(logicalLeftVisualOverflow, logicalTopVisu alOverflow, 797 logicalVisualOverflow = LayoutRect(logicalLeftVisualOverflow, logicalTopVisu alOverflow,
798 logicalRightVisualOverflow - logicalLeftV isualOverflow, logicalBottomVisualOverflow - logicalTopVisualOverflow); 798 logicalRightVisualOverflow - logicalLeftV isualOverflow, logicalBottomVisualOverflow - logicalTopVisualOverflow);
799 } 799 }
800 800
801 inline void InlineFlowBox::addBorderOutsetVisualOverflow(LayoutRect& logicalVisu alOverflow) 801 inline void InlineFlowBox::addBorderOutsetVisualOverflow(LayoutRect& logicalVisu alOverflow)
802 { 802 {
803 // border-image-outset on root line boxes is applying to the block and not t o the lines. 803 // border-image-outset on root line boxes is applying to the block and not t o the lines.
804 if (!parent()) 804 if (!parent())
805 return; 805 return;
806 806
807 RenderStyle* style = renderer().style(isFirstLineStyle()); 807 RenderStyle* style = renderer().styleOrFirstLineStyle(isFirstLineStyle());
808 if (!style->hasBorderImageOutsets()) 808 if (!style->hasBorderImageOutsets())
809 return; 809 return;
810 810
811 LayoutBoxExtent borderOutsets = style->borderImageOutsets(); 811 LayoutBoxExtent borderOutsets = style->borderImageOutsets();
812 812
813 LayoutUnit borderOutsetLogicalTop = borderOutsets.logicalTop(style->writingM ode()); 813 LayoutUnit borderOutsetLogicalTop = borderOutsets.logicalTop(style->writingM ode());
814 LayoutUnit borderOutsetLogicalBottom = borderOutsets.logicalBottom(style->wr itingMode()); 814 LayoutUnit borderOutsetLogicalBottom = borderOutsets.logicalBottom(style->wr itingMode());
815 LayoutUnit borderOutsetLogicalLeft = borderOutsets.logicalLeft(style->writin gMode()); 815 LayoutUnit borderOutsetLogicalLeft = borderOutsets.logicalLeft(style->writin gMode());
816 LayoutUnit borderOutsetLogicalRight = borderOutsets.logicalRight(style->writ ingMode()); 816 LayoutUnit borderOutsetLogicalRight = borderOutsets.logicalRight(style->writ ingMode());
817 817
(...skipping 14 matching lines...) Expand all
832 logicalVisualOverflow = LayoutRect(logicalLeftVisualOverflow, logicalTopVisu alOverflow, 832 logicalVisualOverflow = LayoutRect(logicalLeftVisualOverflow, logicalTopVisu alOverflow,
833 logicalRightVisualOverflow - logicalLeftV isualOverflow, logicalBottomVisualOverflow - logicalTopVisualOverflow); 833 logicalRightVisualOverflow - logicalLeftV isualOverflow, logicalBottomVisualOverflow - logicalTopVisualOverflow);
834 } 834 }
835 835
836 inline void InlineFlowBox::addOutlineVisualOverflow(LayoutRect& logicalVisualOve rflow) 836 inline void InlineFlowBox::addOutlineVisualOverflow(LayoutRect& logicalVisualOve rflow)
837 { 837 {
838 // Outline on root line boxes is applied to the block and not to the lines. 838 // Outline on root line boxes is applied to the block and not to the lines.
839 if (!parent()) 839 if (!parent())
840 return; 840 return;
841 841
842 RenderStyle* style = renderer().style(isFirstLineStyle()); 842 RenderStyle* style = renderer().styleOrFirstLineStyle(isFirstLineStyle());
843 if (!style->hasOutline()) 843 if (!style->hasOutline())
844 return; 844 return;
845 845
846 logicalVisualOverflow.inflate(style->outlineSize()); 846 logicalVisualOverflow.inflate(style->outlineSize());
847 } 847 }
848 848
849 inline void InlineFlowBox::addTextBoxVisualOverflow(InlineTextBox* textBox, Glyp hOverflowAndFallbackFontsMap& textBoxDataMap, LayoutRect& logicalVisualOverflow) 849 inline void InlineFlowBox::addTextBoxVisualOverflow(InlineTextBox* textBox, Glyp hOverflowAndFallbackFontsMap& textBoxDataMap, LayoutRect& logicalVisualOverflow)
850 { 850 {
851 if (textBox->knownToHaveNoOverflow()) 851 if (textBox->knownToHaveNoOverflow())
852 return; 852 return;
853 853
854 RenderStyle* style = textBox->renderer().style(isFirstLineStyle()); 854 RenderStyle* style = textBox->renderer().styleOrFirstLineStyle(isFirstLineSt yle());
855 855
856 GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.find(textBox) ; 856 GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.find(textBox) ;
857 GlyphOverflow* glyphOverflow = it == textBoxDataMap.end() ? 0 : &it->value.s econd; 857 GlyphOverflow* glyphOverflow = it == textBoxDataMap.end() ? 0 : &it->value.s econd;
858 bool isFlippedLine = style->isFlippedLinesWritingMode(); 858 bool isFlippedLine = style->isFlippedLinesWritingMode();
859 859
860 int topGlyphEdge = glyphOverflow ? (isFlippedLine ? glyphOverflow->bottom : glyphOverflow->top) : 0; 860 int topGlyphEdge = glyphOverflow ? (isFlippedLine ? glyphOverflow->bottom : glyphOverflow->top) : 0;
861 int bottomGlyphEdge = glyphOverflow ? (isFlippedLine ? glyphOverflow->top : glyphOverflow->bottom) : 0; 861 int bottomGlyphEdge = glyphOverflow ? (isFlippedLine ? glyphOverflow->top : glyphOverflow->bottom) : 0;
862 int leftGlyphEdge = glyphOverflow ? glyphOverflow->left : 0; 862 int leftGlyphEdge = glyphOverflow ? glyphOverflow->left : 0;
863 int rightGlyphEdge = glyphOverflow ? glyphOverflow->right : 0; 863 int rightGlyphEdge = glyphOverflow ? glyphOverflow->right : 0;
864 864
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
1291 1291
1292 // Move x/y to our coordinates. 1292 // Move x/y to our coordinates.
1293 LayoutRect localRect(frameRect); 1293 LayoutRect localRect(frameRect);
1294 flipForWritingMode(localRect); 1294 flipForWritingMode(localRect);
1295 LayoutPoint adjustedPaintoffset = paintOffset + localRect.location(); 1295 LayoutPoint adjustedPaintoffset = paintOffset + localRect.location();
1296 1296
1297 GraphicsContext* context = paintInfo.context; 1297 GraphicsContext* context = paintInfo.context;
1298 1298
1299 // You can use p::first-line to specify a background. If so, the root line b oxes for 1299 // You can use p::first-line to specify a background. If so, the root line b oxes for
1300 // a line may actually have to paint a background. 1300 // a line may actually have to paint a background.
1301 RenderStyle* styleToUse = renderer().style(isFirstLineStyle()); 1301 RenderStyle* styleToUse = renderer().styleOrFirstLineStyle(isFirstLineStyle( ));
1302 if ((!parent() && isFirstLineStyle() && styleToUse != renderer().style()) || (parent() && renderer().hasBoxDecorations())) { 1302 if ((!parent() && isFirstLineStyle() && styleToUse != renderer().style()) || (parent() && renderer().hasBoxDecorations())) {
1303 LayoutRect paintRect = LayoutRect(adjustedPaintoffset, frameRect.size()) ; 1303 LayoutRect paintRect = LayoutRect(adjustedPaintoffset, frameRect.size()) ;
1304 // Shadow comes first and is behind the background and border. 1304 // Shadow comes first and is behind the background and border.
1305 if (!boxModelObject()->boxShadowShouldBeAppliedToBackground(BackgroundBl eedNone, this)) 1305 if (!boxModelObject()->boxShadowShouldBeAppliedToBackground(BackgroundBl eedNone, this))
1306 paintBoxShadow(paintInfo, styleToUse, Normal, paintRect); 1306 paintBoxShadow(paintInfo, styleToUse, Normal, paintRect);
1307 1307
1308 Color c = renderer().resolveColor(styleToUse, CSSPropertyBackgroundColor ); 1308 Color c = renderer().resolveColor(styleToUse, CSSPropertyBackgroundColor );
1309 paintFillLayers(paintInfo, c, styleToUse->backgroundLayers(), paintRect) ; 1309 paintFillLayers(paintInfo, c, styleToUse->backgroundLayers(), paintRect) ;
1310 paintBoxShadow(paintInfo, styleToUse, Inset, paintRect); 1310 paintBoxShadow(paintInfo, styleToUse, Inset, paintRect);
1311 1311
1312 // :first-line cannot be used to put borders on a line. Always paint bor ders with our 1312 // :first-line cannot be used to put borders on a line. Always paint bor ders with our
1313 // non-first-line style. 1313 // non-first-line style.
1314 if (parent() && renderer().style()->hasBorder()) { 1314 if (parent() && renderer().style()->hasBorder()) {
1315 const NinePieceImage& borderImage = renderer().style()->borderImage( ); 1315 const NinePieceImage& borderImage = renderer().style()->borderImage( );
1316 StyleImage* borderImageSource = borderImage.image(); 1316 StyleImage* borderImageSource = borderImage.image();
1317 bool hasBorderImage = borderImageSource && borderImageSource->canRen der(renderer(), styleToUse->effectiveZoom()); 1317 bool hasBorderImage = borderImageSource && borderImageSource->canRen der(renderer(), styleToUse->effectiveZoom());
1318 if (hasBorderImage && !borderImageSource->isLoaded()) 1318 if (hasBorderImage && !borderImageSource->isLoaded())
1319 return; // Don't paint anything while we wait for the image to l oad. 1319 return; // Don't paint anything while we wait for the image to l oad.
1320 1320
1321 // The simple case is where we either have no border image or we are the only box for this object. In those 1321 // The simple case is where we either have no border image or we are the only box for this object. In those
1322 // cases only a single call to draw is required. 1322 // cases only a single call to draw is required.
1323 if (!hasBorderImage || (!prevLineBox() && !nextLineBox())) 1323 if (!hasBorderImage || (!prevLineBox() && !nextLineBox()))
1324 boxModelObject()->paintBorder(paintInfo, paintRect, renderer().s tyle(isFirstLineStyle()), BackgroundBleedNone, includeLogicalLeftEdge(), include LogicalRightEdge()); 1324 boxModelObject()->paintBorder(paintInfo, paintRect, renderer().s tyleOrFirstLineStyle(isFirstLineStyle()), BackgroundBleedNone, includeLogicalLef tEdge(), includeLogicalRightEdge());
1325 else { 1325 else {
1326 // We have a border image that spans multiple lines. 1326 // We have a border image that spans multiple lines.
1327 // We need to adjust tx and ty by the width of all previous line s. 1327 // We need to adjust tx and ty by the width of all previous line s.
1328 // Think of border image painting on inlines as though you had o ne long line, a single continuous 1328 // Think of border image painting on inlines as though you had o ne long line, a single continuous
1329 // strip. Even though that strip has been broken up across mult iple lines, you still paint it 1329 // strip. Even though that strip has been broken up across mult iple lines, you still paint it
1330 // as though you had one single line. This means each line has to pick up the image where 1330 // as though you had one single line. This means each line has to pick up the image where
1331 // the previous line left off. 1331 // the previous line left off.
1332 // FIXME: What the heck do we do with RTL here? The math we're u sing is obviously not right, 1332 // FIXME: What the heck do we do with RTL here? The math we're u sing is obviously not right,
1333 // but it isn't even clear how this should work at all. 1333 // but it isn't even clear how this should work at all.
1334 LayoutUnit logicalOffsetOnLine = 0; 1334 LayoutUnit logicalOffsetOnLine = 0;
1335 for (InlineFlowBox* curr = prevLineBox(); curr; curr = curr->pre vLineBox()) 1335 for (InlineFlowBox* curr = prevLineBox(); curr; curr = curr->pre vLineBox())
1336 logicalOffsetOnLine += curr->logicalWidth(); 1336 logicalOffsetOnLine += curr->logicalWidth();
1337 LayoutUnit totalLogicalWidth = logicalOffsetOnLine; 1337 LayoutUnit totalLogicalWidth = logicalOffsetOnLine;
1338 for (InlineFlowBox* curr = this; curr; curr = curr->nextLineBox( )) 1338 for (InlineFlowBox* curr = this; curr; curr = curr->nextLineBox( ))
1339 totalLogicalWidth += curr->logicalWidth(); 1339 totalLogicalWidth += curr->logicalWidth();
1340 LayoutUnit stripX = adjustedPaintoffset.x() - (isHorizontal() ? logicalOffsetOnLine : LayoutUnit()); 1340 LayoutUnit stripX = adjustedPaintoffset.x() - (isHorizontal() ? logicalOffsetOnLine : LayoutUnit());
1341 LayoutUnit stripY = adjustedPaintoffset.y() - (isHorizontal() ? LayoutUnit() : logicalOffsetOnLine); 1341 LayoutUnit stripY = adjustedPaintoffset.y() - (isHorizontal() ? LayoutUnit() : logicalOffsetOnLine);
1342 LayoutUnit stripWidth = isHorizontal() ? totalLogicalWidth : fra meRect.width(); 1342 LayoutUnit stripWidth = isHorizontal() ? totalLogicalWidth : fra meRect.width();
1343 LayoutUnit stripHeight = isHorizontal() ? frameRect.height() : t otalLogicalWidth; 1343 LayoutUnit stripHeight = isHorizontal() ? frameRect.height() : t otalLogicalWidth;
1344 1344
1345 LayoutRect clipRect = clipRectForNinePieceImageStrip(this, borde rImage, paintRect); 1345 LayoutRect clipRect = clipRectForNinePieceImageStrip(this, borde rImage, paintRect);
1346 GraphicsContextStateSaver stateSaver(*context); 1346 GraphicsContextStateSaver stateSaver(*context);
1347 context->clip(clipRect); 1347 context->clip(clipRect);
1348 boxModelObject()->paintBorder(paintInfo, LayoutRect(stripX, stri pY, stripWidth, stripHeight), renderer().style(isFirstLineStyle())); 1348 boxModelObject()->paintBorder(paintInfo, LayoutRect(stripX, stri pY, stripWidth, stripHeight), renderer().styleOrFirstLineStyle(isFirstLineStyle( )));
1349 } 1349 }
1350 } 1350 }
1351 } 1351 }
1352 } 1352 }
1353 1353
1354 void InlineFlowBox::paintMask(PaintInfo& paintInfo, const LayoutPoint& paintOffs et) 1354 void InlineFlowBox::paintMask(PaintInfo& paintInfo, const LayoutPoint& paintOffs et)
1355 { 1355 {
1356 if (!paintInfo.shouldPaintWithinRoot(&renderer()) || renderer().style()->vis ibility() != VISIBLE || paintInfo.phase != PaintPhaseMask) 1356 if (!paintInfo.shouldPaintWithinRoot(&renderer()) || renderer().style()->vis ibility() != VISIBLE || paintInfo.phase != PaintPhaseMask)
1357 return; 1357 return;
1358 1358
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1515 } else { 1515 } else {
1516 LayoutUnit bottomOfLastRubyTextLine = rubyText->logicalTop() + ( rubyText->lastRootBox() ? rubyText->lastRootBox()->lineBottom() : rubyText->logi calHeight()); 1516 LayoutUnit bottomOfLastRubyTextLine = rubyText->logicalTop() + ( rubyText->lastRootBox() ? rubyText->lastRootBox()->lineBottom() : rubyText->logi calHeight());
1517 if (bottomOfLastRubyTextLine <= curr->logicalHeight()) 1517 if (bottomOfLastRubyTextLine <= curr->logicalHeight())
1518 continue; 1518 continue;
1519 bottomOfLastRubyTextLine += curr->logicalTop(); 1519 bottomOfLastRubyTextLine += curr->logicalTop();
1520 result = std::max(result, bottomOfLastRubyTextLine - allowedPosi tion); 1520 result = std::max(result, bottomOfLastRubyTextLine - allowedPosi tion);
1521 } 1521 }
1522 } 1522 }
1523 1523
1524 if (curr->isInlineTextBox()) { 1524 if (curr->isInlineTextBox()) {
1525 RenderStyle* style = curr->renderer().style(isFirstLineStyle()); 1525 RenderStyle* style = curr->renderer().styleOrFirstLineStyle(isFirstL ineStyle());
1526 TextEmphasisPosition emphasisMarkPosition; 1526 TextEmphasisPosition emphasisMarkPosition;
1527 if (style->textEmphasisMark() != TextEmphasisMarkNone && toInlineTex tBox(curr)->getEmphasisMarkPosition(style, emphasisMarkPosition) && emphasisMark Position == TextEmphasisPositionOver) { 1527 if (style->textEmphasisMark() != TextEmphasisMarkNone && toInlineTex tBox(curr)->getEmphasisMarkPosition(style, emphasisMarkPosition) && emphasisMark Position == TextEmphasisPositionOver) {
1528 if (!style->isFlippedLinesWritingMode()) { 1528 if (!style->isFlippedLinesWritingMode()) {
1529 int topOfEmphasisMark = curr->logicalTop() - style->font().e mphasisMarkHeight(style->textEmphasisMarkString()); 1529 int topOfEmphasisMark = curr->logicalTop() - style->font().e mphasisMarkHeight(style->textEmphasisMarkString());
1530 result = std::max(result, allowedPosition - topOfEmphasisMar k); 1530 result = std::max(result, allowedPosition - topOfEmphasisMar k);
1531 } else { 1531 } else {
1532 int bottomOfEmphasisMark = curr->logicalBottom() + style->fo nt().emphasisMarkHeight(style->textEmphasisMarkString()); 1532 int bottomOfEmphasisMark = curr->logicalBottom() + style->fo nt().emphasisMarkHeight(style->textEmphasisMarkString());
1533 result = std::max(result, bottomOfEmphasisMark - allowedPosi tion); 1533 result = std::max(result, bottomOfEmphasisMark - allowedPosi tion);
1534 } 1534 }
1535 } 1535 }
(...skipping 27 matching lines...) Expand all
1563 } else { 1563 } else {
1564 LayoutUnit bottomOfLastRubyTextLine = rubyText->logicalTop() + ( rubyText->lastRootBox() ? rubyText->lastRootBox()->lineBottom() : rubyText->logi calHeight()); 1564 LayoutUnit bottomOfLastRubyTextLine = rubyText->logicalTop() + ( rubyText->lastRootBox() ? rubyText->lastRootBox()->lineBottom() : rubyText->logi calHeight());
1565 if (bottomOfLastRubyTextLine <= curr->logicalHeight()) 1565 if (bottomOfLastRubyTextLine <= curr->logicalHeight())
1566 continue; 1566 continue;
1567 bottomOfLastRubyTextLine += curr->logicalTop(); 1567 bottomOfLastRubyTextLine += curr->logicalTop();
1568 result = std::max(result, bottomOfLastRubyTextLine - allowedPosi tion); 1568 result = std::max(result, bottomOfLastRubyTextLine - allowedPosi tion);
1569 } 1569 }
1570 } 1570 }
1571 1571
1572 if (curr->isInlineTextBox()) { 1572 if (curr->isInlineTextBox()) {
1573 RenderStyle* style = curr->renderer().style(isFirstLineStyle()); 1573 RenderStyle* style = curr->renderer().styleOrFirstLineStyle(isFirstL ineStyle());
1574 if (style->textEmphasisMark() != TextEmphasisMarkNone && style->text EmphasisPosition() == TextEmphasisPositionUnder) { 1574 if (style->textEmphasisMark() != TextEmphasisMarkNone && style->text EmphasisPosition() == TextEmphasisPositionUnder) {
1575 if (!style->isFlippedLinesWritingMode()) { 1575 if (!style->isFlippedLinesWritingMode()) {
1576 LayoutUnit bottomOfEmphasisMark = curr->logicalBottom() + st yle->font().emphasisMarkHeight(style->textEmphasisMarkString()); 1576 LayoutUnit bottomOfEmphasisMark = curr->logicalBottom() + st yle->font().emphasisMarkHeight(style->textEmphasisMarkString());
1577 result = std::max(result, bottomOfEmphasisMark - allowedPosi tion); 1577 result = std::max(result, bottomOfEmphasisMark - allowedPosi tion);
1578 } else { 1578 } else {
1579 LayoutUnit topOfEmphasisMark = curr->logicalTop() - style->f ont().emphasisMarkHeight(style->textEmphasisMarkString()); 1579 LayoutUnit topOfEmphasisMark = curr->logicalTop() - style->f ont().emphasisMarkHeight(style->textEmphasisMarkString());
1580 result = std::max(result, allowedPosition - topOfEmphasisMar k); 1580 result = std::max(result, allowedPosition - topOfEmphasisMar k);
1581 } 1581 }
1582 } 1582 }
1583 } 1583 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1662 ASSERT(child->prevOnLine() == prev); 1662 ASSERT(child->prevOnLine() == prev);
1663 prev = child; 1663 prev = child;
1664 } 1664 }
1665 ASSERT(prev == m_lastChild); 1665 ASSERT(prev == m_lastChild);
1666 #endif 1666 #endif
1667 } 1667 }
1668 1668
1669 #endif 1669 #endif
1670 1670
1671 } // namespace WebCore 1671 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/InlineFlowBox.h ('k') | Source/core/rendering/InlineTextBox.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698