OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * Copyright (C) 2013 Apple Inc. All rights reserved. | 3 * Copyright (C) 2013 Apple 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 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
814 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Node")); | 814 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Node")); |
815 return 0; | 815 return 0; |
816 } | 816 } |
817 | 817 |
818 DocumentMarker::MarkerTypes markerTypes = 0; | 818 DocumentMarker::MarkerTypes markerTypes = 0; |
819 if (!markerTypesFrom(markerType, markerTypes)) { | 819 if (!markerTypesFrom(markerType, markerTypes)) { |
820 exceptionState.throwDOMException(SyntaxError, "The marker type provided
('" + markerType + "') is invalid."); | 820 exceptionState.throwDOMException(SyntaxError, "The marker type provided
('" + markerType + "') is invalid."); |
821 return 0; | 821 return 0; |
822 } | 822 } |
823 | 823 |
824 return node->document().markers()->markersFor(node, markerTypes).size(); | 824 return node->document().markers().markersFor(node, markerTypes).size(); |
825 } | 825 } |
826 | 826 |
827 unsigned Internals::activeMarkerCountForNode(Node* node, ExceptionState& excepti
onState) | 827 unsigned Internals::activeMarkerCountForNode(Node* node, ExceptionState& excepti
onState) |
828 { | 828 { |
829 if (!node) { | 829 if (!node) { |
830 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Node")); | 830 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Node")); |
831 return 0; | 831 return 0; |
832 } | 832 } |
833 | 833 |
834 // Only TextMatch markers can be active. | 834 // Only TextMatch markers can be active. |
835 DocumentMarker::MarkerType markerType = DocumentMarker::TextMatch; | 835 DocumentMarker::MarkerType markerType = DocumentMarker::TextMatch; |
836 Vector<DocumentMarker*> markers = node->document().markers()->markersFor(nod
e, markerType); | 836 Vector<DocumentMarker*> markers = node->document().markers().markersFor(node
, markerType); |
837 | 837 |
838 unsigned activeMarkerCount = 0; | 838 unsigned activeMarkerCount = 0; |
839 for (Vector<DocumentMarker*>::iterator iter = markers.begin(); iter != marke
rs.end(); ++iter) { | 839 for (Vector<DocumentMarker*>::iterator iter = markers.begin(); iter != marke
rs.end(); ++iter) { |
840 if ((*iter)->activeMatch()) | 840 if ((*iter)->activeMatch()) |
841 activeMarkerCount++; | 841 activeMarkerCount++; |
842 } | 842 } |
843 | 843 |
844 return activeMarkerCount; | 844 return activeMarkerCount; |
845 } | 845 } |
846 | 846 |
847 DocumentMarker* Internals::markerAt(Node* node, const String& markerType, unsign
ed index, ExceptionState& exceptionState) | 847 DocumentMarker* Internals::markerAt(Node* node, const String& markerType, unsign
ed index, ExceptionState& exceptionState) |
848 { | 848 { |
849 if (!node) { | 849 if (!node) { |
850 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Node")); | 850 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Node")); |
851 return 0; | 851 return 0; |
852 } | 852 } |
853 | 853 |
854 DocumentMarker::MarkerTypes markerTypes = 0; | 854 DocumentMarker::MarkerTypes markerTypes = 0; |
855 if (!markerTypesFrom(markerType, markerTypes)) { | 855 if (!markerTypesFrom(markerType, markerTypes)) { |
856 exceptionState.throwDOMException(SyntaxError, "The marker type provided
('" + markerType + "') is invalid."); | 856 exceptionState.throwDOMException(SyntaxError, "The marker type provided
('" + markerType + "') is invalid."); |
857 return 0; | 857 return 0; |
858 } | 858 } |
859 | 859 |
860 Vector<DocumentMarker*> markers = node->document().markers()->markersFor(nod
e, markerTypes); | 860 Vector<DocumentMarker*> markers = node->document().markers().markersFor(node
, markerTypes); |
861 if (markers.size() <= index) | 861 if (markers.size() <= index) |
862 return 0; | 862 return 0; |
863 return markers[index]; | 863 return markers[index]; |
864 } | 864 } |
865 | 865 |
866 PassRefPtr<Range> Internals::markerRangeForNode(Node* node, const String& marker
Type, unsigned index, ExceptionState& exceptionState) | 866 PassRefPtr<Range> Internals::markerRangeForNode(Node* node, const String& marker
Type, unsigned index, ExceptionState& exceptionState) |
867 { | 867 { |
868 DocumentMarker* marker = markerAt(node, markerType, index, exceptionState); | 868 DocumentMarker* marker = markerAt(node, markerType, index, exceptionState); |
869 if (!marker) | 869 if (!marker) |
870 return nullptr; | 870 return nullptr; |
871 return Range::create(node->document(), node, marker->startOffset(), node, ma
rker->endOffset()); | 871 return Range::create(node->document(), node, marker->startOffset(), node, ma
rker->endOffset()); |
872 } | 872 } |
873 | 873 |
874 String Internals::markerDescriptionForNode(Node* node, const String& markerType,
unsigned index, ExceptionState& exceptionState) | 874 String Internals::markerDescriptionForNode(Node* node, const String& markerType,
unsigned index, ExceptionState& exceptionState) |
875 { | 875 { |
876 DocumentMarker* marker = markerAt(node, markerType, index, exceptionState); | 876 DocumentMarker* marker = markerAt(node, markerType, index, exceptionState); |
877 if (!marker) | 877 if (!marker) |
878 return String(); | 878 return String(); |
879 return marker->description(); | 879 return marker->description(); |
880 } | 880 } |
881 | 881 |
882 void Internals::addTextMatchMarker(const Range* range, bool isActive) | 882 void Internals::addTextMatchMarker(const Range* range, bool isActive) |
883 { | 883 { |
884 range->ownerDocument().updateLayoutIgnorePendingStylesheets(); | 884 range->ownerDocument().updateLayoutIgnorePendingStylesheets(); |
885 range->ownerDocument().markers()->addTextMatchMarker(range, isActive); | 885 range->ownerDocument().markers().addTextMatchMarker(range, isActive); |
886 } | 886 } |
887 | 887 |
888 void Internals::setMarkersActive(Node* node, unsigned startOffset, unsigned endO
ffset, bool active, ExceptionState& exceptionState) | 888 void Internals::setMarkersActive(Node* node, unsigned startOffset, unsigned endO
ffset, bool active, ExceptionState& exceptionState) |
889 { | 889 { |
890 if (!node) { | 890 if (!node) { |
891 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Node")); | 891 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
argumentNullOrIncorrectType(1, "Node")); |
892 return; | 892 return; |
893 } | 893 } |
894 | 894 |
895 node->document().markers()->setMarkersActive(node, startOffset, endOffset, a
ctive); | 895 node->document().markers().setMarkersActive(node, startOffset, endOffset, ac
tive); |
896 } | 896 } |
897 | 897 |
898 void Internals::setMarkedTextMatchesAreHighlighted(Document* document, bool high
light, ExceptionState&) | 898 void Internals::setMarkedTextMatchesAreHighlighted(Document* document, bool high
light, ExceptionState&) |
899 { | 899 { |
900 if (!document || !document->frame()) | 900 if (!document || !document->frame()) |
901 return; | 901 return; |
902 | 902 |
903 document->frame()->editor().setMarkedTextMatchesAreHighlighted(highlight); | 903 document->frame()->editor().setMarkedTextMatchesAreHighlighted(highlight); |
904 } | 904 } |
905 | 905 |
(...skipping 1465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2371 return promise.then(AddOneFunction::create(context)); | 2371 return promise.then(AddOneFunction::create(context)); |
2372 } | 2372 } |
2373 | 2373 |
2374 void Internals::trace(Visitor* visitor) | 2374 void Internals::trace(Visitor* visitor) |
2375 { | 2375 { |
2376 visitor->trace(m_runtimeFlags); | 2376 visitor->trace(m_runtimeFlags); |
2377 visitor->trace(m_profilers); | 2377 visitor->trace(m_profilers); |
2378 } | 2378 } |
2379 | 2379 |
2380 } | 2380 } |
OLD | NEW |