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

Side by Side Diff: Source/core/html/HTMLTextFormControlElement.cpp

Issue 170603003: Use nullptr_t for RefPtr, PassRefPtr and RawPtr. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Final rebase Created 6 years, 10 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/html/HTMLTableRowElement.cpp ('k') | Source/core/html/ImageData.cpp » ('j') | 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.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 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 offsetInContainer = offset; 415 offsetInContainer = offset;
416 } else { 416 } else {
417 containerNode = node->parentNode(); 417 containerNode = node->parentNode();
418 offsetInContainer = node->nodeIndex() + offset; 418 offsetInContainer = node->nodeIndex() + offset;
419 } 419 }
420 } 420 }
421 421
422 PassRefPtr<Range> HTMLTextFormControlElement::selection() const 422 PassRefPtr<Range> HTMLTextFormControlElement::selection() const
423 { 423 {
424 if (!renderer() || !isTextFormControl() || !hasCachedSelection()) 424 if (!renderer() || !isTextFormControl() || !hasCachedSelection())
425 return 0; 425 return nullptr;
426 426
427 int start = m_cachedSelectionStart; 427 int start = m_cachedSelectionStart;
428 int end = m_cachedSelectionEnd; 428 int end = m_cachedSelectionEnd;
429 429
430 ASSERT(start <= end); 430 ASSERT(start <= end);
431 HTMLElement* innerText = innerTextElement(); 431 HTMLElement* innerText = innerTextElement();
432 if (!innerText) 432 if (!innerText)
433 return 0; 433 return nullptr;
434 434
435 if (!innerText->firstChild()) 435 if (!innerText->firstChild())
436 return Range::create(document(), innerText, 0, innerText, 0); 436 return Range::create(document(), innerText, 0, innerText, 0);
437 437
438 int offset = 0; 438 int offset = 0;
439 Node* startNode = 0; 439 Node* startNode = 0;
440 Node* endNode = 0; 440 Node* endNode = 0;
441 for (Node* node = innerText->firstChild(); node; node = NodeTraversal::next( *node, innerText)) { 441 for (Node* node = innerText->firstChild(); node; node = NodeTraversal::next( *node, innerText)) {
442 ASSERT(!node->firstChild()); 442 ASSERT(!node->firstChild());
443 ASSERT(node->isTextNode() || node->hasTagName(brTag)); 443 ASSERT(node->isTextNode() || node->hasTagName(brTag));
444 int length = node->isTextNode() ? lastOffsetInNode(node) : 1; 444 int length = node->isTextNode() ? lastOffsetInNode(node) : 1;
445 445
446 if (offset <= start && start <= offset + length) 446 if (offset <= start && start <= offset + length)
447 setContainerAndOffsetForRange(node, start - offset, startNode, start ); 447 setContainerAndOffsetForRange(node, start - offset, startNode, start );
448 448
449 if (offset <= end && end <= offset + length) { 449 if (offset <= end && end <= offset + length) {
450 setContainerAndOffsetForRange(node, end - offset, endNode, end); 450 setContainerAndOffsetForRange(node, end - offset, endNode, end);
451 break; 451 break;
452 } 452 }
453 453
454 offset += length; 454 offset += length;
455 } 455 }
456 456
457 if (!startNode || !endNode) 457 if (!startNode || !endNode)
458 return 0; 458 return nullptr;
459 459
460 return Range::create(document(), startNode, start, endNode, end); 460 return Range::create(document(), startNode, start, endNode, end);
461 } 461 }
462 462
463 void HTMLTextFormControlElement::restoreCachedSelection() 463 void HTMLTextFormControlElement::restoreCachedSelection()
464 { 464 {
465 setSelectionRange(m_cachedSelectionStart, m_cachedSelectionEnd, m_cachedSele ctionDirection); 465 setSelectionRange(m_cachedSelectionStart, m_cachedSelectionEnd, m_cachedSele ctionDirection);
466 } 466 }
467 467
468 void HTMLTextFormControlElement::selectionChanged(bool userTriggered) 468 void HTMLTextFormControlElement::selectionChanged(bool userTriggered)
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 643
644 return "ltr"; 644 return "ltr";
645 } 645 }
646 646
647 HTMLElement* HTMLTextFormControlElement::innerTextElement() const 647 HTMLElement* HTMLTextFormControlElement::innerTextElement() const
648 { 648 {
649 return toHTMLElement(userAgentShadowRoot()->getElementById(ShadowElementName s::innerEditor())); 649 return toHTMLElement(userAgentShadowRoot()->getElementById(ShadowElementName s::innerEditor()));
650 } 650 }
651 651
652 } // namespace Webcore 652 } // namespace Webcore
OLDNEW
« no previous file with comments | « Source/core/html/HTMLTableRowElement.cpp ('k') | Source/core/html/ImageData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698