OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 30 matching lines...) Expand all Loading... |
41 namespace blink { | 41 namespace blink { |
42 | 42 |
43 #if DCHECK_IS_ON() | 43 #if DCHECK_IS_ON() |
44 LineBoxList::~LineBoxList() { | 44 LineBoxList::~LineBoxList() { |
45 DCHECK(!first_line_box_); | 45 DCHECK(!first_line_box_); |
46 DCHECK(!last_line_box_); | 46 DCHECK(!last_line_box_); |
47 } | 47 } |
48 #endif | 48 #endif |
49 | 49 |
50 void LineBoxList::AppendLineBox(InlineFlowBox* box) { | 50 void LineBoxList::AppendLineBox(InlineFlowBox* box) { |
51 CheckConsistency(); | |
52 | |
53 if (!first_line_box_) { | 51 if (!first_line_box_) { |
54 first_line_box_ = last_line_box_ = box; | 52 first_line_box_ = last_line_box_ = box; |
55 } else { | 53 } else { |
56 last_line_box_->SetNextLineBox(box); | 54 last_line_box_->SetNextLineBox(box); |
57 box->SetPreviousLineBox(last_line_box_); | 55 box->SetPreviousLineBox(last_line_box_); |
58 last_line_box_ = box; | 56 last_line_box_ = box; |
59 } | 57 } |
60 | |
61 CheckConsistency(); | |
62 } | 58 } |
63 | 59 |
64 void LineBoxList::DeleteLineBoxTree() { | 60 void LineBoxList::DeleteLineBoxTree() { |
65 InlineFlowBox* line = first_line_box_; | 61 InlineFlowBox* line = first_line_box_; |
66 InlineFlowBox* next_line; | 62 InlineFlowBox* next_line; |
67 while (line) { | 63 while (line) { |
68 next_line = line->NextLineBox(); | 64 next_line = line->NextLineBox(); |
69 line->DeleteLine(); | 65 line->DeleteLine(); |
70 line = next_line; | 66 line = next_line; |
71 } | 67 } |
72 first_line_box_ = last_line_box_ = nullptr; | 68 first_line_box_ = last_line_box_ = nullptr; |
73 } | 69 } |
74 | 70 |
75 void LineBoxList::ExtractLineBox(InlineFlowBox* box) { | 71 void LineBoxList::ExtractLineBox(InlineFlowBox* box) { |
76 CheckConsistency(); | |
77 | |
78 last_line_box_ = box->PrevLineBox(); | 72 last_line_box_ = box->PrevLineBox(); |
79 if (box == first_line_box_) | 73 if (box == first_line_box_) |
80 first_line_box_ = nullptr; | 74 first_line_box_ = nullptr; |
81 if (box->PrevLineBox()) | 75 if (box->PrevLineBox()) |
82 box->PrevLineBox()->SetNextLineBox(nullptr); | 76 box->PrevLineBox()->SetNextLineBox(nullptr); |
83 box->SetPreviousLineBox(nullptr); | 77 box->SetPreviousLineBox(nullptr); |
84 for (InlineFlowBox* curr = box; curr; curr = curr->NextLineBox()) | 78 for (InlineFlowBox* curr = box; curr; curr = curr->NextLineBox()) |
85 curr->SetExtracted(); | 79 curr->SetExtracted(); |
86 | |
87 CheckConsistency(); | |
88 } | 80 } |
89 | 81 |
90 void LineBoxList::AttachLineBox(InlineFlowBox* box) { | 82 void LineBoxList::AttachLineBox(InlineFlowBox* box) { |
91 CheckConsistency(); | |
92 | |
93 if (last_line_box_) { | 83 if (last_line_box_) { |
94 last_line_box_->SetNextLineBox(box); | 84 last_line_box_->SetNextLineBox(box); |
95 box->SetPreviousLineBox(last_line_box_); | 85 box->SetPreviousLineBox(last_line_box_); |
96 } else { | 86 } else { |
97 first_line_box_ = box; | 87 first_line_box_ = box; |
98 } | 88 } |
99 InlineFlowBox* last = box; | 89 InlineFlowBox* last = box; |
100 for (InlineFlowBox* curr = box; curr; curr = curr->NextLineBox()) { | 90 for (InlineFlowBox* curr = box; curr; curr = curr->NextLineBox()) { |
101 curr->SetExtracted(false); | 91 curr->SetExtracted(false); |
102 last = curr; | 92 last = curr; |
103 } | 93 } |
104 last_line_box_ = last; | 94 last_line_box_ = last; |
105 | |
106 CheckConsistency(); | |
107 } | 95 } |
108 | 96 |
109 void LineBoxList::RemoveLineBox(InlineFlowBox* box) { | 97 void LineBoxList::RemoveLineBox(InlineFlowBox* box) { |
110 CheckConsistency(); | |
111 | |
112 if (box == first_line_box_) | 98 if (box == first_line_box_) |
113 first_line_box_ = box->NextLineBox(); | 99 first_line_box_ = box->NextLineBox(); |
114 if (box == last_line_box_) | 100 if (box == last_line_box_) |
115 last_line_box_ = box->PrevLineBox(); | 101 last_line_box_ = box->PrevLineBox(); |
116 if (box->NextLineBox()) | 102 if (box->NextLineBox()) |
117 box->NextLineBox()->SetPreviousLineBox(box->PrevLineBox()); | 103 box->NextLineBox()->SetPreviousLineBox(box->PrevLineBox()); |
118 if (box->PrevLineBox()) | 104 if (box->PrevLineBox()) |
119 box->PrevLineBox()->SetNextLineBox(box->NextLineBox()); | 105 box->PrevLineBox()->SetNextLineBox(box->NextLineBox()); |
120 | |
121 CheckConsistency(); | |
122 } | 106 } |
123 | 107 |
124 void LineBoxList::DeleteLineBoxes() { | 108 void LineBoxList::DeleteLineBoxes() { |
125 if (first_line_box_) { | 109 if (first_line_box_) { |
126 InlineFlowBox* next; | 110 InlineFlowBox* next; |
127 for (InlineFlowBox* curr = first_line_box_; curr; curr = next) { | 111 for (InlineFlowBox* curr = first_line_box_; curr; curr = next) { |
128 next = curr->NextLineBox(); | 112 next = curr->NextLineBox(); |
129 curr->Destroy(); | 113 curr->Destroy(); |
130 } | 114 } |
131 first_line_box_ = nullptr; | 115 first_line_box_ = nullptr; |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 prev_root_box->MarkDirty(); | 346 prev_root_box->MarkDirty(); |
363 // If |child| or any of its immediately previous siblings with culled | 347 // If |child| or any of its immediately previous siblings with culled |
364 // lineboxes is the object after a line-break in |box| or the linebox after | 348 // lineboxes is the object after a line-break in |box| or the linebox after |
365 // it then that means |child| actually sits on the linebox after |box| (or | 349 // it then that means |child| actually sits on the linebox after |box| (or |
366 // is its line-break object) and so we need to dirty it as well. | 350 // is its line-break object) and so we need to dirty it as well. |
367 if (RootInlineBox* next_root_box = box->NextRootBox()) | 351 if (RootInlineBox* next_root_box = box->NextRootBox()) |
368 next_root_box->MarkDirty(); | 352 next_root_box->MarkDirty(); |
369 } | 353 } |
370 } | 354 } |
371 | 355 |
372 #if DCHECK_IS_ON() | |
373 void LineBoxList::CheckConsistency() const { | |
374 #ifdef CHECK_CONSISTENCY | |
375 const InlineFlowBox* prev = nullptr; | |
376 for (const InlineFlowBox* child = m_firstLineBox; child; | |
377 child = child->nextLineBox()) { | |
378 DCHECK_EQ(child->prevLineBox(), prev); | |
379 prev = child; | |
380 } | |
381 DCHECK_EQ(prev, m_lastLineBox); | |
382 #endif | |
383 } | |
384 | |
385 #endif | |
386 | |
387 } // namespace blink | 356 } // namespace blink |
OLD | NEW |