| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. |
| 3 * Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved. | 3 * Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "core/editing/VisiblePosition.h" | 28 #include "core/editing/VisiblePosition.h" |
| 29 | 29 |
| 30 #include <stdio.h> | 30 #include <stdio.h> |
| 31 #include "HTMLNames.h" | 31 #include "HTMLNames.h" |
| 32 #include "core/dom/Document.h" | 32 #include "core/dom/Document.h" |
| 33 #include "core/dom/Range.h" | 33 #include "core/dom/Range.h" |
| 34 #include "core/dom/Text.h" | 34 #include "core/dom/Text.h" |
| 35 #include "core/editing/VisibleUnits.h" | 35 #include "core/editing/VisibleUnits.h" |
| 36 #include "core/editing/htmlediting.h" | 36 #include "core/editing/htmlediting.h" |
| 37 #include "core/html/HTMLElement.h" | 37 #include "core/html/HTMLElement.h" |
| 38 #include "core/html/HTMLHtmlElement.h" |
| 38 #include "core/platform/graphics/FloatQuad.h" | 39 #include "core/platform/graphics/FloatQuad.h" |
| 39 #include "core/rendering/RenderBlock.h" | 40 #include "core/rendering/RenderBlock.h" |
| 40 #include "core/rendering/RootInlineBox.h" | 41 #include "core/rendering/RootInlineBox.h" |
| 41 #include <wtf/text/CString.h> | 42 #include <wtf/text/CString.h> |
| 42 | 43 |
| 43 namespace WebCore { | 44 namespace WebCore { |
| 44 | 45 |
| 45 using namespace HTMLNames; | 46 using namespace HTMLNames; |
| 46 | 47 |
| 47 VisiblePosition::VisiblePosition(const Position &pos, EAffinity affinity) | 48 VisiblePosition::VisiblePosition(const Position &pos, EAffinity affinity) |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 | 528 |
| 528 // When neither upstream or downstream gets us to a candidate (upstream/down
stream won't leave | 529 // When neither upstream or downstream gets us to a candidate (upstream/down
stream won't leave |
| 529 // blocks or enter new ones), we search forward and backward until we find o
ne. | 530 // blocks or enter new ones), we search forward and backward until we find o
ne. |
| 530 Position next = canonicalizeCandidate(nextCandidate(position)); | 531 Position next = canonicalizeCandidate(nextCandidate(position)); |
| 531 Position prev = canonicalizeCandidate(previousCandidate(position)); | 532 Position prev = canonicalizeCandidate(previousCandidate(position)); |
| 532 Node* nextNode = next.deprecatedNode(); | 533 Node* nextNode = next.deprecatedNode(); |
| 533 Node* prevNode = prev.deprecatedNode(); | 534 Node* prevNode = prev.deprecatedNode(); |
| 534 | 535 |
| 535 // The new position must be in the same editable element. Enforce that first
. | 536 // The new position must be in the same editable element. Enforce that first
. |
| 536 // Unless the descent is from a non-editable html element to an editable bod
y. | 537 // Unless the descent is from a non-editable html element to an editable bod
y. |
| 537 if (node && node->hasTagName(htmlTag) && !node->rendererIsEditable() && node
->document()->body() && node->document()->body()->rendererIsEditable()) | 538 if (node && isHTMLHtmlElement(node) && !node->rendererIsEditable() && node->
document()->body() && node->document()->body()->rendererIsEditable()) |
| 538 return next.isNotNull() ? next : prev; | 539 return next.isNotNull() ? next : prev; |
| 539 | 540 |
| 540 Node* editingRoot = editableRootForPosition(position); | 541 Node* editingRoot = editableRootForPosition(position); |
| 541 | 542 |
| 542 // If the html element is editable, descending into its body will look like
a descent | 543 // If the html element is editable, descending into its body will look like
a descent |
| 543 // from non-editable to editable content since rootEditableElement() always
stops at the body. | 544 // from non-editable to editable content since rootEditableElement() always
stops at the body. |
| 544 if ((editingRoot && editingRoot->hasTagName(htmlTag)) || position.deprecated
Node()->isDocumentNode()) | 545 if ((editingRoot && isHTMLHtmlElement(editingRoot)) || position.deprecatedNo
de()->isDocumentNode()) |
| 545 return next.isNotNull() ? next : prev; | 546 return next.isNotNull() ? next : prev; |
| 546 | 547 |
| 547 bool prevIsInSameEditableElement = prevNode && editableRootForPosition(prev)
== editingRoot; | 548 bool prevIsInSameEditableElement = prevNode && editableRootForPosition(prev)
== editingRoot; |
| 548 bool nextIsInSameEditableElement = nextNode && editableRootForPosition(next)
== editingRoot; | 549 bool nextIsInSameEditableElement = nextNode && editableRootForPosition(next)
== editingRoot; |
| 549 if (prevIsInSameEditableElement && !nextIsInSameEditableElement) | 550 if (prevIsInSameEditableElement && !nextIsInSameEditableElement) |
| 550 return prev; | 551 return prev; |
| 551 | 552 |
| 552 if (nextIsInSameEditableElement && !prevIsInSameEditableElement) | 553 if (nextIsInSameEditableElement && !prevIsInSameEditableElement) |
| 553 return next; | 554 return next; |
| 554 | 555 |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 if (vpos) | 748 if (vpos) |
| 748 vpos->showTreeForThis(); | 749 vpos->showTreeForThis(); |
| 749 } | 750 } |
| 750 | 751 |
| 751 void showTree(const WebCore::VisiblePosition& vpos) | 752 void showTree(const WebCore::VisiblePosition& vpos) |
| 752 { | 753 { |
| 753 vpos.showTreeForThis(); | 754 vpos.showTreeForThis(); |
| 754 } | 755 } |
| 755 | 756 |
| 756 #endif | 757 #endif |
| OLD | NEW |