| OLD | NEW |
| 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 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 return nullptr; | 435 return nullptr; |
| 436 | 436 |
| 437 if (!innerText->firstChild()) | 437 if (!innerText->firstChild()) |
| 438 return Range::create(document(), innerText, 0, innerText, 0); | 438 return Range::create(document(), innerText, 0, innerText, 0); |
| 439 | 439 |
| 440 int offset = 0; | 440 int offset = 0; |
| 441 Node* startNode = 0; | 441 Node* startNode = 0; |
| 442 Node* endNode = 0; | 442 Node* endNode = 0; |
| 443 for (Node* node = innerText->firstChild(); node; node = NodeTraversal::next(
*node, innerText)) { | 443 for (Node* node = innerText->firstChild(); node; node = NodeTraversal::next(
*node, innerText)) { |
| 444 ASSERT(!node->firstChild()); | 444 ASSERT(!node->firstChild()); |
| 445 ASSERT(node->isTextNode() || node->hasTagName(brTag)); | 445 ASSERT(node->isTextNode() || isHTMLBRElement(*node)); |
| 446 int length = node->isTextNode() ? lastOffsetInNode(node) : 1; | 446 int length = node->isTextNode() ? lastOffsetInNode(node) : 1; |
| 447 | 447 |
| 448 if (offset <= start && start <= offset + length) | 448 if (offset <= start && start <= offset + length) |
| 449 setContainerAndOffsetForRange(node, start - offset, startNode, start
); | 449 setContainerAndOffsetForRange(node, start - offset, startNode, start
); |
| 450 | 450 |
| 451 if (offset <= end && end <= offset + length) { | 451 if (offset <= end && end <= offset + length) { |
| 452 setContainerAndOffsetForRange(node, end - offset, endNode, end); | 452 setContainerAndOffsetForRange(node, end - offset, endNode, end); |
| 453 break; | 453 break; |
| 454 } | 454 } |
| 455 | 455 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 | 529 |
| 530 String HTMLTextFormControlElement::innerTextValue() const | 530 String HTMLTextFormControlElement::innerTextValue() const |
| 531 { | 531 { |
| 532 ASSERT(!hasAuthorShadowRoot()); | 532 ASSERT(!hasAuthorShadowRoot()); |
| 533 HTMLElement* innerText = innerTextElement(); | 533 HTMLElement* innerText = innerTextElement(); |
| 534 if (!innerText || !isTextFormControl()) | 534 if (!innerText || !isTextFormControl()) |
| 535 return emptyString(); | 535 return emptyString(); |
| 536 | 536 |
| 537 StringBuilder result; | 537 StringBuilder result; |
| 538 for (Node* node = innerText; node; node = NodeTraversal::next(*node, innerTe
xt)) { | 538 for (Node* node = innerText; node; node = NodeTraversal::next(*node, innerTe
xt)) { |
| 539 if (node->hasTagName(brTag)) | 539 if (isHTMLBRElement(*node)) |
| 540 result.append(newlineCharacter); | 540 result.append(newlineCharacter); |
| 541 else if (node->isTextNode()) | 541 else if (node->isTextNode()) |
| 542 result.append(toText(node)->data()); | 542 result.append(toText(node)->data()); |
| 543 } | 543 } |
| 544 return finishText(result); | 544 return finishText(result); |
| 545 } | 545 } |
| 546 | 546 |
| 547 static void getNextSoftBreak(RootInlineBox*& line, Node*& breakNode, unsigned& b
reakOffset) | 547 static void getNextSoftBreak(RootInlineBox*& line, Node*& breakNode, unsigned& b
reakOffset) |
| 548 { | 548 { |
| 549 RootInlineBox* next; | 549 RootInlineBox* next; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 576 Node* breakNode; | 576 Node* breakNode; |
| 577 unsigned breakOffset; | 577 unsigned breakOffset; |
| 578 RootInlineBox* line = renderer->firstRootBox(); | 578 RootInlineBox* line = renderer->firstRootBox(); |
| 579 if (!line) | 579 if (!line) |
| 580 return value(); | 580 return value(); |
| 581 | 581 |
| 582 getNextSoftBreak(line, breakNode, breakOffset); | 582 getNextSoftBreak(line, breakNode, breakOffset); |
| 583 | 583 |
| 584 StringBuilder result; | 584 StringBuilder result; |
| 585 for (Node* node = innerText->firstChild(); node; node = NodeTraversal::next(
*node, innerText)) { | 585 for (Node* node = innerText->firstChild(); node; node = NodeTraversal::next(
*node, innerText)) { |
| 586 if (node->hasTagName(brTag)) | 586 if (isHTMLBRElement(*node)) |
| 587 result.append(newlineCharacter); | 587 result.append(newlineCharacter); |
| 588 else if (node->isTextNode()) { | 588 else if (node->isTextNode()) { |
| 589 String data = toText(node)->data(); | 589 String data = toText(node)->data(); |
| 590 unsigned length = data.length(); | 590 unsigned length = data.length(); |
| 591 unsigned position = 0; | 591 unsigned position = 0; |
| 592 while (breakNode == node && breakOffset <= length) { | 592 while (breakNode == node && breakOffset <= length) { |
| 593 if (breakOffset > position) { | 593 if (breakOffset > position) { |
| 594 result.append(data, position, breakOffset - position); | 594 result.append(data, position, breakOffset - position); |
| 595 position = breakOffset; | 595 position = breakOffset; |
| 596 result.append(newlineCharacter); | 596 result.append(newlineCharacter); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 | 647 |
| 648 return "ltr"; | 648 return "ltr"; |
| 649 } | 649 } |
| 650 | 650 |
| 651 HTMLElement* HTMLTextFormControlElement::innerTextElement() const | 651 HTMLElement* HTMLTextFormControlElement::innerTextElement() const |
| 652 { | 652 { |
| 653 return toHTMLElement(userAgentShadowRoot()->getElementById(ShadowElementName
s::innerEditor())); | 653 return toHTMLElement(userAgentShadowRoot()->getElementById(ShadowElementName
s::innerEditor())); |
| 654 } | 654 } |
| 655 | 655 |
| 656 } // namespace Webcore | 656 } // namespace Webcore |
| OLD | NEW |