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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutText.cpp

Issue 2871983002: blink: Remove CHECK_CONSISTENCY. (Closed)
Patch Set: . Created 3 years, 7 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 * (C) 1999 Lars Knoll (knoll@kde.org) 2 * (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Dirk Mueller (mueller@kde.org) 3 * (C) 2000 Dirk Mueller (mueller@kde.org)
4 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) 5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net)
6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 void LayoutText::WillBeDestroyed() { 242 void LayoutText::WillBeDestroyed() {
243 if (SecureTextTimer* secure_text_timer = 243 if (SecureTextTimer* secure_text_timer =
244 g_secure_text_timers ? g_secure_text_timers->Take(this) : 0) 244 g_secure_text_timers ? g_secure_text_timers->Take(this) : 0)
245 delete secure_text_timer; 245 delete secure_text_timer;
246 246
247 RemoveAndDestroyTextBoxes(); 247 RemoveAndDestroyTextBoxes();
248 LayoutObject::WillBeDestroyed(); 248 LayoutObject::WillBeDestroyed();
249 } 249 }
250 250
251 void LayoutText::ExtractTextBox(InlineTextBox* box) { 251 void LayoutText::ExtractTextBox(InlineTextBox* box) {
252 CheckConsistency();
253
254 last_text_box_ = box->PrevTextBox(); 252 last_text_box_ = box->PrevTextBox();
255 if (box == first_text_box_) 253 if (box == first_text_box_)
256 first_text_box_ = nullptr; 254 first_text_box_ = nullptr;
257 if (box->PrevTextBox()) 255 if (box->PrevTextBox())
258 box->PrevTextBox()->SetNextTextBox(nullptr); 256 box->PrevTextBox()->SetNextTextBox(nullptr);
259 box->SetPreviousTextBox(nullptr); 257 box->SetPreviousTextBox(nullptr);
260 for (InlineTextBox* curr = box; curr; curr = curr->NextTextBox()) 258 for (InlineTextBox* curr = box; curr; curr = curr->NextTextBox())
261 curr->SetExtracted(); 259 curr->SetExtracted();
262
263 CheckConsistency();
264 } 260 }
265 261
266 void LayoutText::AttachTextBox(InlineTextBox* box) { 262 void LayoutText::AttachTextBox(InlineTextBox* box) {
267 CheckConsistency();
268
269 if (last_text_box_) { 263 if (last_text_box_) {
270 last_text_box_->SetNextTextBox(box); 264 last_text_box_->SetNextTextBox(box);
271 box->SetPreviousTextBox(last_text_box_); 265 box->SetPreviousTextBox(last_text_box_);
272 } else { 266 } else {
273 first_text_box_ = box; 267 first_text_box_ = box;
274 } 268 }
275 InlineTextBox* last = box; 269 InlineTextBox* last = box;
276 for (InlineTextBox* curr = box; curr; curr = curr->NextTextBox()) { 270 for (InlineTextBox* curr = box; curr; curr = curr->NextTextBox()) {
277 curr->SetExtracted(false); 271 curr->SetExtracted(false);
278 last = curr; 272 last = curr;
279 } 273 }
280 last_text_box_ = last; 274 last_text_box_ = last;
281
282 CheckConsistency();
283 } 275 }
284 276
285 void LayoutText::RemoveTextBox(InlineTextBox* box) { 277 void LayoutText::RemoveTextBox(InlineTextBox* box) {
286 CheckConsistency();
287
288 if (box == first_text_box_) 278 if (box == first_text_box_)
289 first_text_box_ = box->NextTextBox(); 279 first_text_box_ = box->NextTextBox();
290 if (box == last_text_box_) 280 if (box == last_text_box_)
291 last_text_box_ = box->PrevTextBox(); 281 last_text_box_ = box->PrevTextBox();
292 if (box->NextTextBox()) 282 if (box->NextTextBox())
293 box->NextTextBox()->SetPreviousTextBox(box->PrevTextBox()); 283 box->NextTextBox()->SetPreviousTextBox(box->PrevTextBox());
294 if (box->PrevTextBox()) 284 if (box->PrevTextBox())
295 box->PrevTextBox()->SetNextTextBox(box->NextTextBox()); 285 box->PrevTextBox()->SetNextTextBox(box->NextTextBox());
296
297 CheckConsistency();
298 } 286 }
299 287
300 void LayoutText::DeleteTextBoxes() { 288 void LayoutText::DeleteTextBoxes() {
301 if (FirstTextBox()) { 289 if (FirstTextBox()) {
302 InlineTextBox* next; 290 InlineTextBox* next;
303 for (InlineTextBox* curr = FirstTextBox(); curr; curr = next) { 291 for (InlineTextBox* curr = FirstTextBox(); curr; curr = next) {
304 next = curr->NextTextBox(); 292 next = curr->NextTextBox();
305 curr->Destroy(); 293 curr->Destroy();
306 } 294 }
307 first_text_box_ = last_text_box_ = nullptr; 295 first_text_box_ = last_text_box_ = nullptr;
(...skipping 1712 matching lines...) Expand 10 before | Expand all | Expand 10 after
2020 return max_offset; 2008 return max_offset;
2021 } 2009 }
2022 2010
2023 unsigned LayoutText::ResolvedTextLength() const { 2011 unsigned LayoutText::ResolvedTextLength() const {
2024 int len = 0; 2012 int len = 0;
2025 for (InlineTextBox* box = FirstTextBox(); box; box = box->NextTextBox()) 2013 for (InlineTextBox* box = FirstTextBox(); box; box = box->NextTextBox())
2026 len += box->Len(); 2014 len += box->Len();
2027 return len; 2015 return len;
2028 } 2016 }
2029 2017
2030 #if DCHECK_IS_ON()
2031
2032 void LayoutText::CheckConsistency() const {
2033 #ifdef CHECK_CONSISTENCY
2034 const InlineTextBox* prev = nullptr;
2035 for (const InlineTextBox* child = m_firstTextBox; child;
2036 child = child->nextTextBox()) {
2037 DCHECK(child->getLineLayoutItem().isEqual(this));
2038 DCHECK_EQ(child->prevTextBox(), prev);
2039 prev = child;
2040 }
2041 DCHECK_EQ(prev, m_lastTextBox);
2042 #endif
2043 }
2044
2045 #endif
2046
2047 void LayoutText::MomentarilyRevealLastTypedCharacter( 2018 void LayoutText::MomentarilyRevealLastTypedCharacter(
2048 unsigned last_typed_character_offset) { 2019 unsigned last_typed_character_offset) {
2049 if (!g_secure_text_timers) 2020 if (!g_secure_text_timers)
2050 g_secure_text_timers = new SecureTextTimerMap; 2021 g_secure_text_timers = new SecureTextTimerMap;
2051 2022
2052 SecureTextTimer* secure_text_timer = g_secure_text_timers->at(this); 2023 SecureTextTimer* secure_text_timer = g_secure_text_timers->at(this);
2053 if (!secure_text_timer) { 2024 if (!secure_text_timer) {
2054 secure_text_timer = new SecureTextTimer(this); 2025 secure_text_timer = new SecureTextTimer(this);
2055 g_secure_text_timers->insert(this, secure_text_timer); 2026 g_secure_text_timers->insert(this, secure_text_timer);
2056 } 2027 }
(...skipping 27 matching lines...) Expand all
2084 LayoutRect rect = LayoutRect( 2055 LayoutRect rect = LayoutRect(
2085 IntRect(FirstRunX(), FirstRunY(), lines_box.Width(), lines_box.Height())); 2056 IntRect(FirstRunX(), FirstRunY(), lines_box.Width(), lines_box.Height()));
2086 LayoutBlock* block = ContainingBlock(); 2057 LayoutBlock* block = ContainingBlock();
2087 if (block && HasTextBoxes()) 2058 if (block && HasTextBoxes())
2088 block->AdjustChildDebugRect(rect); 2059 block->AdjustChildDebugRect(rect);
2089 2060
2090 return rect; 2061 return rect;
2091 } 2062 }
2092 2063
2093 } // namespace blink 2064 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutText.h ('k') | third_party/WebKit/Source/core/layout/line/InlineFlowBox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698