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

Side by Side Diff: third_party/WebKit/Source/core/editing/SelectionEditor.cpp

Issue 2772233002: EXPERIMENT Make toPositionInFlatTree() to return null for DOM position not in flat tree (Closed)
Patch Set: 2017-03-27T18:24:23 Created 3 years, 8 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 | « third_party/WebKit/Source/core/editing/Position.cpp ('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) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2008, 2009, 2010 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 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 if (!needsUpdateVisibleSelection()) 370 if (!needsUpdateVisibleSelection())
371 return; 371 return;
372 372
373 m_styleVersion = document().styleVersion(); 373 m_styleVersion = document().styleVersion();
374 m_cacheIsDirty = false; 374 m_cacheIsDirty = false;
375 m_cachedVisibleSelectionInDOMTree = createVisibleSelection(m_selection); 375 m_cachedVisibleSelectionInDOMTree = createVisibleSelection(m_selection);
376 if (m_cachedVisibleSelectionInDOMTree.isNone()) { 376 if (m_cachedVisibleSelectionInDOMTree.isNone()) {
377 m_cachedVisibleSelectionInFlatTree = VisibleSelectionInFlatTree(); 377 m_cachedVisibleSelectionInFlatTree = VisibleSelectionInFlatTree();
378 return; 378 return;
379 } 379 }
380 m_cachedVisibleSelectionInFlatTree = createVisibleSelection( 380 const PositionInFlatTree& base = toPositionInFlatTree(m_selection.base());
381 SelectionInFlatTree::Builder() 381 const PositionInFlatTree& extent = toPositionInFlatTree(m_selection.extent());
382 .setBaseAndExtent(toPositionInFlatTree(m_selection.base()), 382 SelectionInFlatTree::Builder builder;
383 toPositionInFlatTree(m_selection.extent())) 383 builder.setAffinity(m_selection.affinity())
384 .setAffinity(m_selection.affinity()) 384 .setHasTrailingWhitespace(m_selection.hasTrailingWhitespace())
385 .setHasTrailingWhitespace(m_selection.hasTrailingWhitespace()) 385 .setGranularity(m_selection.granularity())
386 .setGranularity(m_selection.granularity()) 386 .setIsDirectional(m_selection.isDirectional());
387 .setIsDirectional(m_selection.isDirectional()) 387 // TODO(editing-dev): Is it better to adjust base and extent if they are not
388 .build()); 388 // in flat tree?
389 if (base.isNotNull() && extent.isNotNull())
390 builder.setBaseAndExtent(base, extent);
391 else if (base.isNotNull())
392 builder.collapse(base);
393 else if (extent.isNotNull())
394 builder.collapse(extent);
395 m_cachedVisibleSelectionInFlatTree = createVisibleSelection(builder.build());
Xiaocheng 2017/03/27 18:17:45 Is it fine if the cached VS and VSInFlatTree have
yosin_UTC9 2017/03/29 03:20:21 So far, we did adjustment in [1] which removed adj
Xiaocheng 2017/03/29 23:56:40 OK. So the type mismatch currently exists, and wil
389 } 396 }
390 397
391 void SelectionEditor::cacheRangeOfDocument(Range* range) { 398 void SelectionEditor::cacheRangeOfDocument(Range* range) {
392 m_cachedRange = range; 399 m_cachedRange = range;
393 } 400 }
394 401
395 Range* SelectionEditor::documentCachedRange() const { 402 Range* SelectionEditor::documentCachedRange() const {
396 return m_cachedRange; 403 return m_cachedRange;
397 } 404 }
398 405
399 void SelectionEditor::clearDocumentCachedRange() { 406 void SelectionEditor::clearDocumentCachedRange() {
400 m_cachedRange = nullptr; 407 m_cachedRange = nullptr;
401 } 408 }
402 409
403 DEFINE_TRACE(SelectionEditor) { 410 DEFINE_TRACE(SelectionEditor) {
404 visitor->trace(m_frame); 411 visitor->trace(m_frame);
405 visitor->trace(m_selection); 412 visitor->trace(m_selection);
406 visitor->trace(m_cachedVisibleSelectionInDOMTree); 413 visitor->trace(m_cachedVisibleSelectionInDOMTree);
407 visitor->trace(m_cachedVisibleSelectionInFlatTree); 414 visitor->trace(m_cachedVisibleSelectionInFlatTree);
408 visitor->trace(m_cachedRange); 415 visitor->trace(m_cachedRange);
409 SynchronousMutationObserver::trace(visitor); 416 SynchronousMutationObserver::trace(visitor);
410 } 417 }
411 418
412 } // namespace blink 419 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/Position.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698