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

Side by Side Diff: fpdfsdk/fxedit/fxet_edit.cpp

Issue 2148353002: Remove CFX_Edit_Refresh::Analyse (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@ifx_cleanup_4
Patch Set: Rebase to master Created 4 years, 5 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 | « no previous file | fpdfsdk/fxedit/include/fxet_edit.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "fpdfsdk/fxedit/include/fxet_edit.h" 7 #include "fpdfsdk/fxedit/include/fxet_edit.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 m_RefreshRects.Add(pOldRect->m_rcLine); 342 m_RefreshRects.Add(pOldRect->m_rcLine);
343 } 343 }
344 344
345 { 345 {
346 for (int32_t i = 0, sz = m_NewLineRects.GetSize(); i < sz; i++) 346 for (int32_t i = 0, sz = m_NewLineRects.GetSize(); i < sz; i++)
347 if (CFX_Edit_LineRect* pNewRect = m_NewLineRects.GetAt(i)) 347 if (CFX_Edit_LineRect* pNewRect = m_NewLineRects.GetAt(i))
348 m_RefreshRects.Add(pNewRect->m_rcLine); 348 m_RefreshRects.Add(pNewRect->m_rcLine);
349 } 349 }
350 } 350 }
351 351
352 void CFX_Edit_Refresh::Analyse(int32_t nAlignment) {
353 FX_BOOL bLineTopChanged = FALSE;
354 CFX_FloatRect rcResult;
355 FX_FLOAT fWidthDiff;
356
357 int32_t szMax = std::max(m_OldLineRects.GetSize(), m_NewLineRects.GetSize());
358 int32_t i = 0;
359
360 while (i < szMax) {
361 CFX_Edit_LineRect* pOldRect = m_OldLineRects.GetAt(i);
362 CFX_Edit_LineRect* pNewRect = m_NewLineRects.GetAt(i);
363
364 if (pOldRect) {
365 if (pNewRect) {
366 if (bLineTopChanged) {
367 rcResult = pOldRect->m_rcLine;
368 rcResult.Union(pNewRect->m_rcLine);
369 m_RefreshRects.Add(rcResult);
370 } else {
371 if (*pNewRect != *pOldRect) {
372 if (!pNewRect->IsSameTop(*pOldRect) ||
373 !pNewRect->IsSameHeight(*pOldRect)) {
374 bLineTopChanged = TRUE;
375 continue;
376 }
377
378 if (nAlignment == 0) {
379 if (pNewRect->m_wrLine.BeginPos != pOldRect->m_wrLine.BeginPos) {
380 rcResult = pOldRect->m_rcLine;
381 rcResult.Union(pNewRect->m_rcLine);
382 m_RefreshRects.Add(rcResult);
383 } else {
384 if (!pNewRect->IsSameLeft(*pOldRect)) {
385 rcResult = pOldRect->m_rcLine;
386 rcResult.Union(pNewRect->m_rcLine);
387 } else {
388 fWidthDiff =
389 pNewRect->m_rcLine.Width() - pOldRect->m_rcLine.Width();
390 rcResult = pNewRect->m_rcLine;
391 if (fWidthDiff > 0.0f) {
392 rcResult.left = rcResult.right - fWidthDiff;
393 } else {
394 rcResult.left = rcResult.right;
395 rcResult.right -= fWidthDiff;
396 }
397 }
398 m_RefreshRects.Add(rcResult);
399 }
400 } else {
401 rcResult = pOldRect->m_rcLine;
402 rcResult.Union(pNewRect->m_rcLine);
403 m_RefreshRects.Add(rcResult);
404 }
405 }
406 }
407 } else {
408 m_RefreshRects.Add(pOldRect->m_rcLine);
409 }
410 } else {
411 if (pNewRect) {
412 m_RefreshRects.Add(pNewRect->m_rcLine);
413 }
414 }
415 i++;
416 }
417 }
418
419 void CFX_Edit_Refresh::AddRefresh(const CFX_FloatRect& rect) { 352 void CFX_Edit_Refresh::AddRefresh(const CFX_FloatRect& rect) {
420 m_RefreshRects.Add(rect); 353 m_RefreshRects.Add(rect);
421 } 354 }
422 355
423 const CFX_Edit_RectArray* CFX_Edit_Refresh::GetRefreshRects() const { 356 const CFX_Edit_RectArray* CFX_Edit_Refresh::GetRefreshRects() const {
424 return &m_RefreshRects; 357 return &m_RefreshRects;
425 } 358 }
426 359
427 void CFX_Edit_Refresh::EndRefresh() { 360 void CFX_Edit_Refresh::EndRefresh() {
428 m_RefreshRects.Empty(); 361 m_RefreshRects.Empty();
(...skipping 2790 matching lines...) Expand 10 before | Expand all | Expand 10 after
3219 int32_t CFX_Edit_RectArray::GetSize() const { 3152 int32_t CFX_Edit_RectArray::GetSize() const {
3220 return m_Rects.GetSize(); 3153 return m_Rects.GetSize();
3221 } 3154 }
3222 3155
3223 CFX_FloatRect* CFX_Edit_RectArray::GetAt(int32_t nIndex) const { 3156 CFX_FloatRect* CFX_Edit_RectArray::GetAt(int32_t nIndex) const {
3224 if (nIndex < 0 || nIndex >= m_Rects.GetSize()) 3157 if (nIndex < 0 || nIndex >= m_Rects.GetSize())
3225 return nullptr; 3158 return nullptr;
3226 3159
3227 return m_Rects.GetAt(nIndex); 3160 return m_Rects.GetAt(nIndex);
3228 } 3161 }
OLDNEW
« no previous file with comments | « no previous file | fpdfsdk/fxedit/include/fxet_edit.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698