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

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

Issue 339333002: Removing using declarations that import names in the C++ Standard library. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixing mac error 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2003, 2006, 2008 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 15 matching lines...) Expand all
26 #include "core/rendering/InlineTextBox.h" 26 #include "core/rendering/InlineTextBox.h"
27 #include "core/rendering/PaintInfo.h" 27 #include "core/rendering/PaintInfo.h"
28 #include "core/rendering/RenderBlockFlow.h" 28 #include "core/rendering/RenderBlockFlow.h"
29 #include "core/rendering/RenderFlowThread.h" 29 #include "core/rendering/RenderFlowThread.h"
30 #include "core/rendering/RenderInline.h" 30 #include "core/rendering/RenderInline.h"
31 #include "core/rendering/RenderView.h" 31 #include "core/rendering/RenderView.h"
32 #include "core/rendering/VerticalPositionCache.h" 32 #include "core/rendering/VerticalPositionCache.h"
33 #include "platform/text/BidiResolver.h" 33 #include "platform/text/BidiResolver.h"
34 #include "wtf/unicode/Unicode.h" 34 #include "wtf/unicode/Unicode.h"
35 35
36 using namespace std;
37
38 namespace WebCore { 36 namespace WebCore {
39 37
40 struct SameSizeAsRootInlineBox : public InlineFlowBox { 38 struct SameSizeAsRootInlineBox : public InlineFlowBox {
41 unsigned unsignedVariable; 39 unsigned unsignedVariable;
42 LayoutUnit layoutVariables[5]; 40 LayoutUnit layoutVariables[5];
43 void* pointers[4]; 41 void* pointers[4];
44 }; 42 };
45 43
46 // FIXME(eae): Figure out why this fails on 64bit Windows builds. 44 // FIXME(eae): Figure out why this fails on 64bit Windows builds.
47 #if !OS(WIN) 45 #if !OS(WIN)
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 bool setMaxDescent = false; 227 bool setMaxDescent = false;
230 228
231 // Figure out if we're in no-quirks mode. 229 // Figure out if we're in no-quirks mode.
232 bool noQuirksMode = renderer().document().inNoQuirksMode(); 230 bool noQuirksMode = renderer().document().inNoQuirksMode();
233 231
234 m_baselineType = requiresIdeographicBaseline(textBoxDataMap) ? IdeographicBa seline : AlphabeticBaseline; 232 m_baselineType = requiresIdeographicBaseline(textBoxDataMap) ? IdeographicBa seline : AlphabeticBaseline;
235 233
236 computeLogicalBoxHeights(this, maxPositionTop, maxPositionBottom, maxAscent, maxDescent, setMaxAscent, setMaxDescent, noQuirksMode, 234 computeLogicalBoxHeights(this, maxPositionTop, maxPositionBottom, maxAscent, maxDescent, setMaxAscent, setMaxDescent, noQuirksMode,
237 textBoxDataMap, baselineType(), verticalPositionCac he); 235 textBoxDataMap, baselineType(), verticalPositionCac he);
238 236
239 if (maxAscent + maxDescent < max(maxPositionTop, maxPositionBottom)) 237 if (maxAscent + maxDescent < std::max(maxPositionTop, maxPositionBottom))
240 adjustMaxAscentAndDescent(maxAscent, maxDescent, maxPositionTop, maxPosi tionBottom); 238 adjustMaxAscentAndDescent(maxAscent, maxDescent, maxPositionTop, maxPosi tionBottom);
241 239
242 LayoutUnit maxHeight = maxAscent + maxDescent; 240 LayoutUnit maxHeight = maxAscent + maxDescent;
243 LayoutUnit lineTop = heightOfBlock; 241 LayoutUnit lineTop = heightOfBlock;
244 LayoutUnit lineBottom = heightOfBlock; 242 LayoutUnit lineBottom = heightOfBlock;
245 LayoutUnit lineTopIncludingMargins = heightOfBlock; 243 LayoutUnit lineTopIncludingMargins = heightOfBlock;
246 LayoutUnit lineBottomIncludingMargins = heightOfBlock; 244 LayoutUnit lineBottomIncludingMargins = heightOfBlock;
247 LayoutUnit selectionBottom = heightOfBlock; 245 LayoutUnit selectionBottom = heightOfBlock;
248 bool setLineTop = false; 246 bool setLineTop = false;
249 bool hasAnnotationsBefore = false; 247 bool hasAnnotationsBefore = false;
250 bool hasAnnotationsAfter = false; 248 bool hasAnnotationsAfter = false;
251 placeBoxesInBlockDirection(heightOfBlock, maxHeight, maxAscent, noQuirksMode , lineTop, lineBottom, selectionBottom, setLineTop, 249 placeBoxesInBlockDirection(heightOfBlock, maxHeight, maxAscent, noQuirksMode , lineTop, lineBottom, selectionBottom, setLineTop,
252 lineTopIncludingMargins, lineBottomIncludingMargi ns, hasAnnotationsBefore, hasAnnotationsAfter, baselineType()); 250 lineTopIncludingMargins, lineBottomIncludingMargi ns, hasAnnotationsBefore, hasAnnotationsAfter, baselineType());
253 m_hasAnnotationsBefore = hasAnnotationsBefore; 251 m_hasAnnotationsBefore = hasAnnotationsBefore;
254 m_hasAnnotationsAfter = hasAnnotationsAfter; 252 m_hasAnnotationsAfter = hasAnnotationsAfter;
255 253
256 maxHeight = max<LayoutUnit>(0, maxHeight); // FIXME: Is this really necessar y? 254 maxHeight = std::max<LayoutUnit>(0, maxHeight); // FIXME: Is this really nec essary?
257 255
258 setLineTopBottomPositions(lineTop, lineBottom, heightOfBlock, heightOfBlock + maxHeight, selectionBottom); 256 setLineTopBottomPositions(lineTop, lineBottom, heightOfBlock, heightOfBlock + maxHeight, selectionBottom);
259 if (block().view()->layoutState()->isPaginated()) 257 if (block().view()->layoutState()->isPaginated())
260 setPaginatedLineWidth(block().availableLogicalWidthForContent()); 258 setPaginatedLineWidth(block().availableLogicalWidthForContent());
261 259
262 LayoutUnit annotationsAdjustment = beforeAnnotationsAdjustment(); 260 LayoutUnit annotationsAdjustment = beforeAnnotationsAdjustment();
263 if (annotationsAdjustment) { 261 if (annotationsAdjustment) {
264 // FIXME: Need to handle pagination here. We might have to move to the n ext page/column as a result of the 262 // FIXME: Need to handle pagination here. We might have to move to the n ext page/column as a result of the
265 // ruby expansion. 263 // ruby expansion.
266 adjustBlockDirectionPosition(annotationsAdjustment.toFloat()); 264 adjustBlockDirectionPosition(annotationsAdjustment.toFloat());
(...skipping 16 matching lines...) Expand all
283 281
284 if (!renderer().style()->isFlippedLinesWritingMode()) { 282 if (!renderer().style()->isFlippedLinesWritingMode()) {
285 // Annotations under the previous line may push us down. 283 // Annotations under the previous line may push us down.
286 if (prevRootBox() && prevRootBox()->hasAnnotationsAfter()) 284 if (prevRootBox() && prevRootBox()->hasAnnotationsAfter())
287 result = prevRootBox()->computeUnderAnnotationAdjustment(lineTop()); 285 result = prevRootBox()->computeUnderAnnotationAdjustment(lineTop());
288 286
289 if (!hasAnnotationsBefore()) 287 if (!hasAnnotationsBefore())
290 return result; 288 return result;
291 289
292 // Annotations over this line may push us further down. 290 // Annotations over this line may push us further down.
293 LayoutUnit highestAllowedPosition = prevRootBox() ? min(prevRootBox()->l ineBottom(), lineTop()) + result : static_cast<LayoutUnit>(block().borderBefore( )); 291 LayoutUnit highestAllowedPosition = prevRootBox() ? std::min(prevRootBox ()->lineBottom(), lineTop()) + result : static_cast<LayoutUnit>(block().borderBe fore());
294 result = computeOverAnnotationAdjustment(highestAllowedPosition); 292 result = computeOverAnnotationAdjustment(highestAllowedPosition);
295 } else { 293 } else {
296 // Annotations under this line may push us up. 294 // Annotations under this line may push us up.
297 if (hasAnnotationsBefore()) 295 if (hasAnnotationsBefore())
298 result = computeUnderAnnotationAdjustment(prevRootBox() ? prevRootBo x()->lineBottom() : static_cast<LayoutUnit>(block().borderBefore())); 296 result = computeUnderAnnotationAdjustment(prevRootBox() ? prevRootBo x()->lineBottom() : static_cast<LayoutUnit>(block().borderBefore()));
299 297
300 if (!prevRootBox() || !prevRootBox()->hasAnnotationsAfter()) 298 if (!prevRootBox() || !prevRootBox()->hasAnnotationsAfter())
301 return result; 299 return result;
302 300
303 // We have to compute the expansion for annotations over the previous li ne to see how much we should move. 301 // We have to compute the expansion for annotations over the previous li ne to see how much we should move.
304 LayoutUnit lowestAllowedPosition = max(prevRootBox()->lineBottom(), line Top()) - result; 302 LayoutUnit lowestAllowedPosition = std::max(prevRootBox()->lineBottom(), lineTop()) - result;
305 result = prevRootBox()->computeOverAnnotationAdjustment(lowestAllowedPos ition); 303 result = prevRootBox()->computeOverAnnotationAdjustment(lowestAllowedPos ition);
306 } 304 }
307 305
308 return result; 306 return result;
309 } 307 }
310 308
311 GapRects RootInlineBox::lineSelectionGap(RenderBlock* rootBlock, const LayoutPoi nt& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, 309 GapRects RootInlineBox::lineSelectionGap(RenderBlock* rootBlock, const LayoutPoi nt& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
312 LayoutUnit selTop, LayoutUnit selHeight , const PaintInfo* paintInfo) 310 LayoutUnit selTop, LayoutUnit selHeight , const PaintInfo* paintInfo)
313 { 311 {
314 RenderObject::SelectionState lineState = selectionState(); 312 RenderObject::SelectionState lineState = selectionState();
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 return top; 439 return top;
442 440
443 LayoutSize offsetToBlockBefore; 441 LayoutSize offsetToBlockBefore;
444 if (RenderBlock* block = root().block().blockBeforeWithinSelectionRoot(offse tToBlockBefore)) { 442 if (RenderBlock* block = root().block().blockBeforeWithinSelectionRoot(offse tToBlockBefore)) {
445 if (RootInlineBox* lastLine = block->lastRootBox()) { 443 if (RootInlineBox* lastLine = block->lastRootBox()) {
446 RenderObject::SelectionState lastLineSelectionState = lastLine->sele ctionState(); 444 RenderObject::SelectionState lastLineSelectionState = lastLine->sele ctionState();
447 if (lastLineSelectionState != RenderObject::SelectionInside && lastL ineSelectionState != RenderObject::SelectionStart) 445 if (lastLineSelectionState != RenderObject::SelectionInside && lastL ineSelectionState != RenderObject::SelectionStart)
448 return top; 446 return top;
449 447
450 LayoutUnit lastLineSelectionBottom = lastLine->selectionBottom() + o ffsetToBlockBefore.height(); 448 LayoutUnit lastLineSelectionBottom = lastLine->selectionBottom() + o ffsetToBlockBefore.height();
451 top = max(top, lastLineSelectionBottom); 449 top = std::max(top, lastLineSelectionBottom);
452 } 450 }
453 } 451 }
454 452
455 return top; 453 return top;
456 } 454 }
457 455
458 LayoutUnit RootInlineBox::selectionBottom() const 456 LayoutUnit RootInlineBox::selectionBottom() const
459 { 457 {
460 LayoutUnit selectionBottom = m_selectionBottom; 458 LayoutUnit selectionBottom = m_selectionBottom;
461 459
(...skipping 14 matching lines...) Expand all
476 LayoutUnit newRight = block().logicalRightOffsetForLine(selectionBottom, false); 474 LayoutUnit newRight = block().logicalRightOffsetForLine(selectionBottom, false);
477 if (nextLeft > newLeft || nextRight < newRight) 475 if (nextLeft > newLeft || nextRight < newRight)
478 return selectionBottom; 476 return selectionBottom;
479 } 477 }
480 478
481 return nextTop; 479 return nextTop;
482 } 480 }
483 481
484 int RootInlineBox::blockDirectionPointInLine() const 482 int RootInlineBox::blockDirectionPointInLine() const
485 { 483 {
486 return !block().style()->isFlippedBlocksWritingMode() ? max(lineTop(), selec tionTop()) : min(lineBottom(), selectionBottom()); 484 return !block().style()->isFlippedBlocksWritingMode() ? std::max(lineTop(), selectionTop()) : std::min(lineBottom(), selectionBottom());
487 } 485 }
488 486
489 RenderBlockFlow& RootInlineBox::block() const 487 RenderBlockFlow& RootInlineBox::block() const
490 { 488 {
491 return toRenderBlockFlow(renderer()); 489 return toRenderBlockFlow(renderer());
492 } 490 }
493 491
494 static bool isEditableLeaf(InlineBox* leaf) 492 static bool isEditableLeaf(InlineBox* leaf)
495 { 493 {
496 return leaf && leaf->renderer().node() && leaf->renderer().node()->rendererI sEditable(); 494 return leaf && leaf->renderer().node() && leaf->renderer().node()->rendererI sEditable();
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 } 584 }
587 585
588 LayoutRect RootInlineBox::paddedLayoutOverflowRect(LayoutUnit endPadding) const 586 LayoutRect RootInlineBox::paddedLayoutOverflowRect(LayoutUnit endPadding) const
589 { 587 {
590 LayoutRect lineLayoutOverflow = layoutOverflowRect(lineTop(), lineBottom()); 588 LayoutRect lineLayoutOverflow = layoutOverflowRect(lineTop(), lineBottom());
591 if (!endPadding) 589 if (!endPadding)
592 return lineLayoutOverflow; 590 return lineLayoutOverflow;
593 591
594 if (isHorizontal()) { 592 if (isHorizontal()) {
595 if (isLeftToRightDirection()) 593 if (isLeftToRightDirection())
596 lineLayoutOverflow.shiftMaxXEdgeTo(max<LayoutUnit>(lineLayoutOverflo w.maxX(), logicalRight() + endPadding)); 594 lineLayoutOverflow.shiftMaxXEdgeTo(std::max<LayoutUnit>(lineLayoutOv erflow.maxX(), logicalRight() + endPadding));
597 else 595 else
598 lineLayoutOverflow.shiftXEdgeTo(min<LayoutUnit>(lineLayoutOverflow.x (), logicalLeft() - endPadding)); 596 lineLayoutOverflow.shiftXEdgeTo(std::min<LayoutUnit>(lineLayoutOverf low.x(), logicalLeft() - endPadding));
599 } else { 597 } else {
600 if (isLeftToRightDirection()) 598 if (isLeftToRightDirection())
601 lineLayoutOverflow.shiftMaxYEdgeTo(max<LayoutUnit>(lineLayoutOverflo w.maxY(), logicalRight() + endPadding)); 599 lineLayoutOverflow.shiftMaxYEdgeTo(std::max<LayoutUnit>(lineLayoutOv erflow.maxY(), logicalRight() + endPadding));
602 else 600 else
603 lineLayoutOverflow.shiftYEdgeTo(min<LayoutUnit>(lineLayoutOverflow.y (), logicalLeft() - endPadding)); 601 lineLayoutOverflow.shiftYEdgeTo(std::min<LayoutUnit>(lineLayoutOverf low.y(), logicalLeft() - endPadding));
604 } 602 }
605 603
606 return lineLayoutOverflow; 604 return lineLayoutOverflow;
607 } 605 }
608 606
609 static void setAscentAndDescent(int& ascent, int& descent, int newAscent, int ne wDescent, bool& ascentDescentSet) 607 static void setAscentAndDescent(int& ascent, int& descent, int newAscent, int ne wDescent, bool& ascentDescentSet)
610 { 608 {
611 if (!ascentDescentSet) { 609 if (!ascentDescentSet) {
612 ascentDescentSet = true; 610 ascentDescentSet = true;
613 ascent = newAscent; 611 ascent = newAscent;
614 descent = newDescent; 612 descent = newDescent;
615 } else { 613 } else {
616 ascent = max(ascent, newAscent); 614 ascent = std::max(ascent, newAscent);
617 descent = max(descent, newDescent); 615 descent = std::max(descent, newDescent);
618 } 616 }
619 } 617 }
620 618
621 void RootInlineBox::ascentAndDescentForBox(InlineBox* box, GlyphOverflowAndFallb ackFontsMap& textBoxDataMap, int& ascent, int& descent, 619 void RootInlineBox::ascentAndDescentForBox(InlineBox* box, GlyphOverflowAndFallb ackFontsMap& textBoxDataMap, int& ascent, int& descent,
622 bool& affectsAscent, bool& affectsDes cent) const 620 bool& affectsAscent, bool& affectsDes cent) const
623 { 621 {
624 bool ascentDescentSet = false; 622 bool ascentDescentSet = false;
625 623
626 // Replaced boxes will return 0 for the line-height if line-box-contain says they are 624 // Replaced boxes will return 0 for the line-height if line-box-contain says they are
627 // not to be included. 625 // not to be included.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 int fontDescent = box->renderer().style(isFirstLineStyle())->fontMetrics ().descent(baselineType()); 692 int fontDescent = box->renderer().style(isFirstLineStyle())->fontMetrics ().descent(baselineType());
695 setAscentAndDescent(ascent, descent, fontAscent, fontDescent, ascentDesc entSet); 693 setAscentAndDescent(ascent, descent, fontAscent, fontDescent, ascentDesc entSet);
696 affectsAscent = fontAscent - box->logicalTop() > 0; 694 affectsAscent = fontAscent - box->logicalTop() > 0;
697 affectsDescent = fontDescent + box->logicalTop() > 0; 695 affectsDescent = fontDescent + box->logicalTop() > 0;
698 } 696 }
699 697
700 if (includeGlyphsForBox(box) && glyphOverflow && glyphOverflow->computeBound s) { 698 if (includeGlyphsForBox(box) && glyphOverflow && glyphOverflow->computeBound s) {
701 setAscentAndDescent(ascent, descent, glyphOverflow->top, glyphOverflow-> bottom, ascentDescentSet); 699 setAscentAndDescent(ascent, descent, glyphOverflow->top, glyphOverflow-> bottom, ascentDescentSet);
702 affectsAscent = glyphOverflow->top - box->logicalTop() > 0; 700 affectsAscent = glyphOverflow->top - box->logicalTop() > 0;
703 affectsDescent = glyphOverflow->bottom + box->logicalTop() > 0; 701 affectsDescent = glyphOverflow->bottom + box->logicalTop() > 0;
704 glyphOverflow->top = min(glyphOverflow->top, max(0, glyphOverflow->top - box->renderer().style(isFirstLineStyle())->fontMetrics().ascent(baselineType()) )); 702 glyphOverflow->top = std::min(glyphOverflow->top, std::max(0, glyphOverf low->top - box->renderer().style(isFirstLineStyle())->fontMetrics().ascent(basel ineType())));
705 glyphOverflow->bottom = min(glyphOverflow->bottom, max(0, glyphOverflow- >bottom - box->renderer().style(isFirstLineStyle())->fontMetrics().descent(basel ineType()))); 703 glyphOverflow->bottom = std::min(glyphOverflow->bottom, std::max(0, glyp hOverflow->bottom - box->renderer().style(isFirstLineStyle())->fontMetrics().des cent(baselineType())));
706 } 704 }
707 705
708 if (includeMarginForBox(box)) { 706 if (includeMarginForBox(box)) {
709 LayoutUnit ascentWithMargin = box->renderer().style(isFirstLineStyle())- >fontMetrics().ascent(baselineType()); 707 LayoutUnit ascentWithMargin = box->renderer().style(isFirstLineStyle())- >fontMetrics().ascent(baselineType());
710 LayoutUnit descentWithMargin = box->renderer().style(isFirstLineStyle()) ->fontMetrics().descent(baselineType()); 708 LayoutUnit descentWithMargin = box->renderer().style(isFirstLineStyle()) ->fontMetrics().descent(baselineType());
711 if (box->parent() && !box->renderer().isText()) { 709 if (box->parent() && !box->renderer().isText()) {
712 ascentWithMargin += box->boxModelObject()->borderBefore() + box->box ModelObject()->paddingBefore() + box->boxModelObject()->marginBefore(); 710 ascentWithMargin += box->boxModelObject()->borderBefore() + box->box ModelObject()->paddingBefore() + box->boxModelObject()->marginBefore();
713 descentWithMargin += box->boxModelObject()->borderAfter() + box->box ModelObject()->paddingAfter() + box->boxModelObject()->marginAfter(); 711 descentWithMargin += box->boxModelObject()->borderAfter() + box->box ModelObject()->paddingAfter() + box->boxModelObject()->marginAfter();
714 } 712 }
715 setAscentAndDescent(ascent, descent, ascentWithMargin, descentWithMargin , ascentDescentSet); 713 setAscentAndDescent(ascent, descent, ascentWithMargin, descentWithMargin , ascentDescentSet);
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 } 877 }
880 878
881 #ifndef NDEBUG 879 #ifndef NDEBUG
882 const char* RootInlineBox::boxName() const 880 const char* RootInlineBox::boxName() const
883 { 881 {
884 return "RootInlineBox"; 882 return "RootInlineBox";
885 } 883 }
886 #endif 884 #endif
887 885
888 } // namespace WebCore 886 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderThemeChromiumMac.mm ('k') | Source/core/rendering/compositing/CompositedLayerMapping.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698