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

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

Issue 331303004: Fix selection rect calculation for inline elements with padding (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Patch for landing 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/RootInlineBox.h ('k') | no next file » | 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, 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 20 matching lines...) Expand all
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; 36 using namespace std;
37 37
38 namespace WebCore { 38 namespace WebCore {
39 39
40 struct SameSizeAsRootInlineBox : public InlineFlowBox { 40 struct SameSizeAsRootInlineBox : public InlineFlowBox {
41 unsigned variables[5]; 41 unsigned variables[6];
42 void* pointers[4]; 42 void* pointers[4];
43 }; 43 };
44 44
45 COMPILE_ASSERT(sizeof(RootInlineBox) == sizeof(SameSizeAsRootInlineBox), RootInl ineBox_should_stay_small); 45 COMPILE_ASSERT(sizeof(RootInlineBox) == sizeof(SameSizeAsRootInlineBox), RootInl ineBox_should_stay_small);
46 46
47 typedef WTF::HashMap<const RootInlineBox*, EllipsisBox*> EllipsisBoxMap; 47 typedef WTF::HashMap<const RootInlineBox*, EllipsisBox*> EllipsisBoxMap;
48 static EllipsisBoxMap* gEllipsisBoxMap = 0; 48 static EllipsisBoxMap* gEllipsisBoxMap = 0;
49 49
50 RootInlineBox::RootInlineBox(RenderBlockFlow& block) 50 RootInlineBox::RootInlineBox(RenderBlockFlow& block)
51 : InlineFlowBox(block) 51 : InlineFlowBox(block)
52 , m_lineBreakPos(0) 52 , m_lineBreakPos(0)
53 , m_lineBreakObj(0) 53 , m_lineBreakObj(0)
54 , m_lineTop(0) 54 , m_lineTop(0)
55 , m_lineBottom(0) 55 , m_lineBottom(0)
56 , m_lineTopWithLeading(0) 56 , m_lineTopWithLeading(0)
57 , m_lineBottomWithLeading(0) 57 , m_lineBottomWithLeading(0)
58 , m_selectionBottom(0)
58 { 59 {
59 setIsHorizontal(block.isHorizontalWritingMode()); 60 setIsHorizontal(block.isHorizontalWritingMode());
60 } 61 }
61 62
62 63
63 void RootInlineBox::destroy() 64 void RootInlineBox::destroy()
64 { 65 {
65 detachEllipsisBox(); 66 detachEllipsisBox();
66 InlineFlowBox::destroy(); 67 InlineFlowBox::destroy();
67 } 68 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 } 188 }
188 189
189 void RootInlineBox::adjustPosition(float dx, float dy) 190 void RootInlineBox::adjustPosition(float dx, float dy)
190 { 191 {
191 InlineFlowBox::adjustPosition(dx, dy); 192 InlineFlowBox::adjustPosition(dx, dy);
192 LayoutUnit blockDirectionDelta = isHorizontal() ? dy : dx; // The block dire ction delta is a LayoutUnit. 193 LayoutUnit blockDirectionDelta = isHorizontal() ? dy : dx; // The block dire ction delta is a LayoutUnit.
193 m_lineTop += blockDirectionDelta; 194 m_lineTop += blockDirectionDelta;
194 m_lineBottom += blockDirectionDelta; 195 m_lineBottom += blockDirectionDelta;
195 m_lineTopWithLeading += blockDirectionDelta; 196 m_lineTopWithLeading += blockDirectionDelta;
196 m_lineBottomWithLeading += blockDirectionDelta; 197 m_lineBottomWithLeading += blockDirectionDelta;
198 m_selectionBottom += blockDirectionDelta;
197 if (hasEllipsisBox()) 199 if (hasEllipsisBox())
198 ellipsisBox()->adjustPosition(dx, dy); 200 ellipsisBox()->adjustPosition(dx, dy);
199 } 201 }
200 202
201 void RootInlineBox::childRemoved(InlineBox* box) 203 void RootInlineBox::childRemoved(InlineBox* box)
202 { 204 {
203 if (&box->renderer() == m_lineBreakObj) 205 if (&box->renderer() == m_lineBreakObj)
204 setLineBreakInfo(0, 0, BidiStatus()); 206 setLineBreakInfo(0, 0, BidiStatus());
205 207
206 for (RootInlineBox* prev = prevRootBox(); prev && prev->lineBreakObj() == &b ox->renderer(); prev = prev->prevRootBox()) { 208 for (RootInlineBox* prev = prevRootBox(); prev && prev->lineBreakObj() == &b ox->renderer(); prev = prev->prevRootBox()) {
(...skipping 24 matching lines...) Expand all
231 textBoxDataMap, baselineType(), verticalPositionCac he); 233 textBoxDataMap, baselineType(), verticalPositionCac he);
232 234
233 if (maxAscent + maxDescent < max(maxPositionTop, maxPositionBottom)) 235 if (maxAscent + maxDescent < max(maxPositionTop, maxPositionBottom))
234 adjustMaxAscentAndDescent(maxAscent, maxDescent, maxPositionTop, maxPosi tionBottom); 236 adjustMaxAscentAndDescent(maxAscent, maxDescent, maxPositionTop, maxPosi tionBottom);
235 237
236 LayoutUnit maxHeight = maxAscent + maxDescent; 238 LayoutUnit maxHeight = maxAscent + maxDescent;
237 LayoutUnit lineTop = heightOfBlock; 239 LayoutUnit lineTop = heightOfBlock;
238 LayoutUnit lineBottom = heightOfBlock; 240 LayoutUnit lineBottom = heightOfBlock;
239 LayoutUnit lineTopIncludingMargins = heightOfBlock; 241 LayoutUnit lineTopIncludingMargins = heightOfBlock;
240 LayoutUnit lineBottomIncludingMargins = heightOfBlock; 242 LayoutUnit lineBottomIncludingMargins = heightOfBlock;
243 LayoutUnit selectionBottom = heightOfBlock;
241 bool setLineTop = false; 244 bool setLineTop = false;
242 bool hasAnnotationsBefore = false; 245 bool hasAnnotationsBefore = false;
243 bool hasAnnotationsAfter = false; 246 bool hasAnnotationsAfter = false;
244 placeBoxesInBlockDirection(heightOfBlock, maxHeight, maxAscent, noQuirksMode , lineTop, lineBottom, setLineTop, 247 placeBoxesInBlockDirection(heightOfBlock, maxHeight, maxAscent, noQuirksMode , lineTop, lineBottom, selectionBottom, setLineTop,
245 lineTopIncludingMargins, lineBottomIncludingMargi ns, hasAnnotationsBefore, hasAnnotationsAfter, baselineType()); 248 lineTopIncludingMargins, lineBottomIncludingMargi ns, hasAnnotationsBefore, hasAnnotationsAfter, baselineType());
246 m_hasAnnotationsBefore = hasAnnotationsBefore; 249 m_hasAnnotationsBefore = hasAnnotationsBefore;
247 m_hasAnnotationsAfter = hasAnnotationsAfter; 250 m_hasAnnotationsAfter = hasAnnotationsAfter;
248 251
249 maxHeight = max<LayoutUnit>(0, maxHeight); // FIXME: Is this really necessar y? 252 maxHeight = max<LayoutUnit>(0, maxHeight); // FIXME: Is this really necessar y?
250 253
251 setLineTopBottomPositions(lineTop, lineBottom, heightOfBlock, heightOfBlock + maxHeight); 254 setLineTopBottomPositions(lineTop, lineBottom, heightOfBlock, heightOfBlock + maxHeight, selectionBottom);
252 if (block().view()->layoutState()->isPaginated()) 255 if (block().view()->layoutState()->isPaginated())
253 setPaginatedLineWidth(block().availableLogicalWidthForContent()); 256 setPaginatedLineWidth(block().availableLogicalWidthForContent());
254 257
255 LayoutUnit annotationsAdjustment = beforeAnnotationsAdjustment(); 258 LayoutUnit annotationsAdjustment = beforeAnnotationsAdjustment();
256 if (annotationsAdjustment) { 259 if (annotationsAdjustment) {
257 // FIXME: Need to handle pagination here. We might have to move to the n ext page/column as a result of the 260 // FIXME: Need to handle pagination here. We might have to move to the n ext page/column as a result of the
258 // ruby expansion. 261 // ruby expansion.
259 adjustBlockDirectionPosition(annotationsAdjustment.toFloat()); 262 adjustBlockDirectionPosition(annotationsAdjustment.toFloat());
260 heightOfBlock += annotationsAdjustment; 263 heightOfBlock += annotationsAdjustment;
261 } 264 }
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 LayoutUnit lastLineSelectionBottom = lastLine->selectionBottom() + o ffsetToBlockBefore.height(); 446 LayoutUnit lastLineSelectionBottom = lastLine->selectionBottom() + o ffsetToBlockBefore.height();
444 top = max(top, lastLineSelectionBottom); 447 top = max(top, lastLineSelectionBottom);
445 } 448 }
446 } 449 }
447 450
448 return top; 451 return top;
449 } 452 }
450 453
451 LayoutUnit RootInlineBox::selectionBottom() const 454 LayoutUnit RootInlineBox::selectionBottom() const
452 { 455 {
453 LayoutUnit selectionBottom = m_lineBottom; 456 LayoutUnit selectionBottom = m_selectionBottom;
454 457
455 if (m_hasAnnotationsAfter) 458 if (m_hasAnnotationsAfter)
456 selectionBottom += !renderer().style()->isFlippedLinesWritingMode() ? co mputeUnderAnnotationAdjustment(m_lineBottom) : computeOverAnnotationAdjustment(m _lineBottom); 459 selectionBottom += !renderer().style()->isFlippedLinesWritingMode() ? co mputeUnderAnnotationAdjustment(m_lineBottom) : computeOverAnnotationAdjustment(m _lineBottom);
457 460
458 if (!renderer().style()->isFlippedLinesWritingMode() || !nextRootBox()) 461 if (!renderer().style()->isFlippedLinesWritingMode() || !nextRootBox())
459 return selectionBottom; 462 return selectionBottom;
460 463
461 LayoutUnit nextTop = nextRootBox()->selectionTop(); 464 LayoutUnit nextTop = nextRootBox()->selectionTop();
462 if (nextTop > selectionBottom && block().containsFloats()) { 465 if (nextTop > selectionBottom && block().containsFloats()) {
463 // The next line has actually been moved further over, probably from a l arge line-height, but possibly because the 466 // The next line has actually been moved further over, probably from a l arge line-height, but possibly because the
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 } 875 }
873 876
874 #ifndef NDEBUG 877 #ifndef NDEBUG
875 const char* RootInlineBox::boxName() const 878 const char* RootInlineBox::boxName() const
876 { 879 {
877 return "RootInlineBox"; 880 return "RootInlineBox";
878 } 881 }
879 #endif 882 #endif
880 883
881 } // namespace WebCore 884 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RootInlineBox.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698