Skip to content

Commit

Permalink
Remove PassRefPtr use from the "dom" directory, related cleanup
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=166569

Reviewed by Alex Christensen.

Source/WebCore:

* CMakeLists.txt: Removed DocumentMarker.cpp.
* WebCore.xcodeproj/project.pbxproj: Ditto.

* bindings/js/JSPopStateEventCustom.cpp:
(WebCore::JSPopStateEvent::state): Pass ExecState by reference.

* dom/CharacterData.cpp:
(WebCore::CharacterData::dispatchModifiedEvent): Use auto.

* dom/DOMAllInOne.cpp: Removed DocumentMarker.cpp.

* dom/DOMNamedFlowCollection.cpp:
(WebCore::DOMNamedFlowCollection::DOMNamedFlowCollection): Updated to take
ownership of the passed in vector.
(WebCore::DOMNamedFlowCollection::create): Moved here from header.
(WebCore::DOMNamedFlowCollection::~DOMNamedFlowCollection): Moved here so we
don't need to include "WebKitNamedFlow.h" in the header.
(WebCore::DOMNamedFlowCollection::item): Rewrote to use Vector.
(WebCore::DOMNamedFlowCollection::namedItem): Rewrote to use a HashSet that
we build from the Vector. Uses a set of hash functions defined right here.
Note that the privor version of this class had incorrect use of ListHashSet
with safeToCompareToEmptyOrDeleted inaccurately set to true.
(WebCore::DOMNamedFlowCollection::supportedPropertyNames): Added this.
Old version just had an empty placeholder.
* dom/DOMNamedFlowCollection.h: Changed to no longer use ListHashSet, not
the right data structure for this. Removed incorrect use of "long" and
made some other simplifications.
* dom/DOMNamedFlowCollection.idl: Changed return types of item and namedItem
to accurately reflect the fact that they return null when the index or name
not found in the collection.

* dom/DataTransfer.h: Remove indentation. Remove unimplemented
incorrect declarations of items for ENABLE(DATA_TRANSFER_ITEMS).
Will be added back when someone implements that feature, or perhaps
ENABLE(DATA_TRANSFER_ITEMS) should be entirely removed for now?

* dom/DataTransferItem.h: Changed return type for getAsFile to
RefPtr. Again, part of ENABLE(DATA_TRANSFER_ITEMS), so dead code for now.

* dom/Document.cpp:
(WebCore::canonicalizedTitle): Removed incorrect comment claiming we
convert control characters to spaces. Simplified logic, removing two
extra loops. Changed to work on just a String rather than StringWithDirection.
(WebCore::Document::updateTitle): Updated to call the function above.
Also updated since StringWithDirection is now a struct instead of a class.
Call displayBuffer on the encoding directly instead of calling a member
function named displayBufferModifiedByEncoding.
(WebCore::Document::updateTitleFromTitleElement): Updated since
StringWithDirection is now a struct.
(WebCore::Document::setTitle): Removed code that unnecessarily calls
updateTitle twice; once indirectly by calling setTextContent on the
title elmeent and once by directly calling updateTitle.
(WebCore::Document::setWindowAttributeEventListener): Take a RefPtr&&.
(WebCore::Document::statePopped): Take a Ref&&.
(WebCore::Document::displayStringModifiedByEncoding): Deleted unused overload.
(WebCore::Document::displayBufferModifiedByEncodingInternal): Deleted.
(WebCore::Document::requestAnimationFrame): Take a Ref&&.
* dom/Document.h: Updated for changes above. Also changed the title function
to return a const String& to slightly cut down on reference count churn.
(WebCore::Document::displayBufferModifiedByEncoding): Deleted.

* dom/DocumentMarker.cpp: Removed.
* dom/DocumentMarker.h: Reworked the DocumentMarker class to use a variant
instead of a separate reference counted DocumentMarkerDetails object.

* dom/DocumentMarkerController.cpp:
(WebCore::DocumentMarkerController::addMarkerToNode): Changed argument
type to DocumentMarker::Data&&.
(DocumentMarkerController::clearDescriptionOnMarkersIntersectingRange):
clearDetails -> clearData
(DocumentMarkerController::showMarkers): activeMatch -> isActiveMatch
* dom/DocumentMarkerController.h: Updated for the above.

* dom/DocumentParser.h: Fixed incorrect reference to PassRefPtr in a comment.

* dom/Element.cpp:
(WebCore::Element::willModifyAttribute): Use auto.

* dom/Event.cpp:
(WebCore::Event::isDragEvent): Deleted. Unused.
(WebCore::Event::cloneFor): Deleted. Unused function left over from the
start of an implementation of seamless frames.
* dom/Event.h: Updated for the above.

* dom/EventContext.cpp: Tweaked blank lines.
* dom/EventContext.h: Removed unnecessary includes and forward declarations.
Changed setRelatedTarget to take a raw pointer instead of PassRefPtr since
callers aren't passing ownership. Moved TouchEventContext::touchList body
out of the class definition since it's a bit long. Deleted unused
toTouchEventContext functions. FIxed incorrect comment.

* dom/MessageEvent.cpp:
(WebCore::MessageEvent::initMessageEvent): Removed unused overload.
* dom/MessageEvent.h: Updated for above. Also changed the
dataAsSerializedScriptValue function to return a raw pointer instead of
PassRefPtr since it is not passing ownership.

* dom/MouseEvent.cpp:
(WebCore::MouseEvent::create): Use raw pointer instead of PassRefPtr for
data transfer and related target arguments.
(WebCore::MouseEvent::MouseEvent): Ditto. Also use IntPoint instead of
separate ints for the various X/Y pairs.
(WebCore::MouseEvent::initMouseEvent): Take a raw pointer for event target.
(WebCore::MouseEvent::isDragEvent): Reformatted, sorted alphabetically,
added comment about why this function probably needs to go.
(WebCore::adjustedClientX): Deleted.
(WebCore::adjustedClientY): Deleted.
(WebCore::MouseEvent::cloneFor): Deleted.
* dom/MouseEvent.h: Updated for the above. Also made more functions private
and final and initialized more of the data members.

* dom/MutationEvent.cpp:
(WebCore::MutationEvent::MutationEvent): Pass related node as a raw pointer.
(WebCore::MutationEvent::initMutationEvent): Ditto.
* dom/MutationEvent.h: Updated for the above. Fixed indentation. Removed
unnecessary explicit destructor; default generated one is fine. Initialize
m_attrChange in the class definition.

* dom/MutationObserver.cpp:
(WebCore::MutationObserver::observe): Pass reference.
(WebCore::MutationObserver::disconnect): Call unregisterMutationObserver
directly instead of calling unregisterAndDelete.

* dom/MutationObserverInterestGroup.cpp:
(WebCore::MutationObserverInterestGroup::MutationObserverInterestGroup):
Take an rvalue reference to the HashMap and use move.
(WebCore::MutationObserverInterestGroup::createIfNeeded): Updated to call
registeredMutationObservers.
* dom/MutationObserverInterestGroup.h: Updated for the above.

* dom/MutationObserverRegistration.cpp:
(WebCore::MutationObserverRegistration::MutationObserverRegistration):
Take a reference to the observer instead of PassRefPtr. Also take a
refererence to the node rather than a pointer.
(WebCore::MutationObserverRegistration::observedSubtreeNodeWillDetach):
Updated to use references instead of pointers.
(WebCore::MutationObserverRegistration::clearTransientRegistrations): Ditto.
(WebCore::MutationObserverRegistration::unregisterAndDelete): Deleted.
(WebCore::MutationObserverRegistration::shouldReceiveMutationFrom): Ditto.
(WebCore::MutationObserverRegistration::addRegistrationNodesToSet): Ditto.
* dom/MutationObserverRegistration.h: Updated for above changes. Also added
a node member function. Changed m_observer to a Ref and m_node to a reference.
Removed the NodeHashSet typedef.

* dom/NamedFlowCollection.cpp:
(WebCore::NamedFlowCollection::createCSSOMSnapshot): Pass a vector of Ref
instead of a vector of raw pointers and pass it as an rvalue reference so
it can be taken over by the named flow collection wrapper.

* dom/Node.cpp:
(WebCore::Node::mutationObserverRegistry): Use auto and nullptr.
(WebCore::Node::transientMutationObserverRegistry): Ditto.
(WebCore::collectMatchingObserversForMutation): Use references instead of pointers.
(WebCore::Node::registeredMutationObservers): Changed to return a map instead of
filling one in and renamed to remove "get" from name.
(WebCore::Node::registerMutationObserver): Use references instead of pointers.
(WebCore::Node::unregisterMutationObserver): Ditto.
(WebCore::Node::registerTransientMutationObserver): Ditto.
(WebCore::Node::unregisterTransientMutationObserver): Ditto.
(WebCore::Node::notifyMutationObserversNodeWillDetach): Ditto.
* dom/Node.h: Updated for the above.

* dom/PopStateEvent.cpp:
(WebCore::PopStateEvent::PopStateEvent): Use RefPtr&& instead of PassRefPtr.
(WebCore::PopStateEvent::create): Use a raw pointer instead of PassRefPtr.
(WebCore::PopStateEvent::trySerializeState): Take a reference to ExecState.
* dom/PopStateEvent.h: Updated for the above.

* dom/Position.cpp:
(WebCore::Position::Position): Take a raw pointer instead of PassRefPtr.
(WebCore::Position::moveToPosition): Ditto.
* dom/Position.h: Updated for the above, also changed createLegacyEditingPosition
in the same way and got rid of the LegacyEditingPosition class.

* dom/Range.cpp:
(WebCore::Range::Range): Changed startContainer and endContainer to RefPtr<Node>&&.
Later this needs to be changed more, but for now this keeps code changes to a minimum.
(WebCore::Range::create): Changed startContainer and endContainer to Node*.
* dom/Range.h: Updated for the above.

* dom/ScopedEventQueue.cpp:
(WebCore::ScopedEventQueue::dispatchEvent): Removed a comment that talks about
PassRefPtr, and simplified the code since the comment is no longer valid.

* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::PendingException::PendingException):
Take a RefPtr&& instead of a PassRefPtr.
(WebCore::ScriptExecutionContext::ScriptExecutionContext): Moved initialization
of all the data members up to the class definition.
(WebCore::ScriptExecutionContext::sanitizeScriptError): Use ASCIILiteral.
(WebCore::ScriptExecutionContext::reportException): Use WTFMove when passing
arguments to the PendingException constructor and using a value from the
PendingException just before destroying it.

* dom/ScriptExecutionContext.h: Changed addTimeout to take a reference rather
than a PassRefPtr to the timer. Callers were not passing ownership. Also
initialize all the data members here in the class definition.

* dom/ScriptedAnimationController.cpp:
(WebCore::ScriptedAnimationController::registerCallback): Take a Ref&&.
* dom/ScriptedAnimationController.h: Updated for the above.

* dom/SimulatedClick.cpp:
(WebCore::SimulatedMouseEvent::SimulatedMouseEvent): Updated since MouseEvent
constructor arguments changed to use IntPoint.
* dom/WheelEvent.cpp:
(WebCore::WheelEvent::WheelEvent): Ditto. Also removed some unneeded initializers
now that the header does more.
(WebCore::WheelEvent::initWheelEvent): Tweaed style a bit.
(WebCore::WheelEvent::initWebKitWheelEvent): Deleted. Moved to the header since it's
just an inline that forwards to initWheelEvent.
* dom/WheelEvent.h: Updated for the above.

* dom/make_event_factory.pl:
(generateImplementation): Use RefPtr instead of PassRefPtr. A couple other tweaks.

* editing/AlternativeTextController.cpp:
(WebCore::AlternativeTextController::respondToMarkerAtEndOfWord): Use the data
insetad of details.
(WebCore::AlternativeTextController::removeDictationAlternativesForMarker):
Ditto, also changed to take reference instead of pointer.
(WebCore::AlternativeTextController::dictationAlternativesForMarker): Ditto.
(WebCore::AlternativeTextController::applyDictationAlternative): Ditto.
* editing/AlternativeTextController.h: Updated for the above.

* editing/ApplyBlockElementCommand.cpp:
(WebCore::ApplyBlockElementCommand::rangeForParagraphSplittingTextNodesIfNeeded):
Updated since Position now takes a raw pointer.
* editing/ApplyStyleCommand.cpp:
(WebCore::ApplyStyleCommand::joinChildTextNodes): Ditto.
* editing/CompositeEditCommand.cpp:
(WebCore::CompositeEditCommand::replaceSelectedTextInNode): Ditto.
(WebCore::CompositeEditCommand::rebalanceWhitespaceOnTextSubstring): Ditto.

* editing/DictationCommand.cpp:
(WebCore::DictationMarkerSupplier::addMarkersToTextNode): Updated to use the
DictationData struct.

* editing/Editor.cpp:
(WebCore::Editor::updateMarkersForWordsAffectedByEditing): Pass a reference.
(WebCore::Editor::dictationAlternativesForMarker): Take a reference.
* editing/Editor.h: Updated for the above.

* editing/InsertTextCommand.cpp:
(WebCore::InsertTextCommand::performOverwrite): Updated since Position now takes
a raw pointer.
(WebCore::InsertTextCommand::doApply): Ditto.
(WebCore::InsertTextCommand::insertTab): Ditto.
* editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplaceSelectionCommand::mergeTextNodesAroundPosition): Ditto.

* html/HTMLTitleElement.cpp:
(WebCore::HTMLTitleElement::computedTextWithDirection): Updated since
StringWithDirection is now a struct.

* loader/FrameLoader.cpp:
(WebCore::FrameLoader::submitForm): Use Ref&& for the form submission.
(WebCore::FrameLoader::receivedFirstData): Updated for change to StringWithDirection.
(WebCore::FrameLoader::commitProvisionalLoad):
(WebCore::FrameLoader::didBeginDocument): Pass a reference.
(WebCore::FrameLoader::loadURLIntoChildFrame): Pass a Ref to loadArchive.
(WebCore::FrameLoader::loadArchive): Take a Ref&& for the archive.
(WebCore::FrameLoader::loadInSameDocument): Take a raw pointer for the
serialized script value state object. No one was passing ownership.
But pass it along to statePopped as a Ref since we need to pass ownership
of the null value, at least for now.
(WebCore::FrameLoader::loadFrameRequest): Take a raw pointer for form state.
No one was passing ownership.
(WebCore::FrameLoader::loadURL): Ditto.
(WebCore::FrameLoader::load): Ditto.
(WebCore::FrameLoader::loadWithNavigationAction): Ditto.
(WebCore::FrameLoader::loadWithDocumentLoader): Ditto.
(WebCore::FrameLoader::loadPostRequest): Ditto.
(WebCore::FrameLoader::continueLoadAfterNavigationPolicy): Ditto.
(WebCore::FrameLoader::continueLoadAfterNewWindowPolicy): Ditto.
* loader/FrameLoader.h: Updated for the above and to remove an unneeded forward
declaration of StringWithDirection, which is not used here.

* loader/FrameLoaderClient.h: Updated forward declaration of StringWithDirection.
Also sorted the others and removed unneeded conditionals.

* loader/HistoryController.cpp:
(WebCore::HistoryController::setCurrentItemTitle): Updated to use struct.
(WebCore::HistoryController::initializeItem): Ditto.
* loader/HistoryController.h: Updated forward declaration of StringWithDirection.

* loader/PolicyCallback.cpp:
(WebCore::PolicyCallback::PolicyCallback): Deleted. Default works fine.
(WebCore::PolicyCallback::~PolicyCallback): Ditto.
(WebCore::PolicyCallback::set): Take a raw pointer to form state.
* loader/PolicyCallback.h: Use raw pointer for form state.

* loader/PolicyChecker.cpp:
(WebCore::PolicyChecker::checkNavigationPolicy): Take a raw pointer for form state.
(WebCore::PolicyChecker::checkNewWindowPolicy): Ditto.
* loader/PolicyChecker.h: Updated for the above.

* page/DOMTimer.cpp:
(WebCore::DOMTimer::DOMTimer): Pass reference to addTimeout function.

* page/DOMWindow.cpp:
(WebCore::DOMWindow::requestAnimationFrame): Use Ref&& for callback.
(WebCore::DOMWindow::webkitRequestAnimationFrame): Ditto.
(WebCore::DOMWindow::cancelAnimationFrame): Tweak coding style.
* page/DOMWindow.h: Updated for the above.

* platform/PlatformWheelEvent.h: Use pragma once. Tweaked header indentation.
Simplified constructors by initializing data members.

* platform/text/StringWithDirection.h: Use pragma once. Use struct instead of class.

* rendering/HitTestResult.cpp:
(WebCore::HitTestResult::dictationAlternatives): Pass a reference.

* rendering/InlineTextBox.cpp:
(WebCore::InlineTextBox::paintTextMatchMarker): activeMatch -> isActiveMatch

Source/WebKit/ios:

* WebView/WebPDFViewIOS.mm:
(-[WebPDFView _checkPDFTitle]): Use aggregate-style syntax for StringWithDirection.
Not needed now, but useful later if we ever can get rid of the explicit constructors.

Source/WebKit/mac:

* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::dispatchDidReceiveTitle): Updated to use struct.
(WebFrameLoaderClient::updateGlobalHistory): Ditto.
(WebFrameLoaderClient::setTitle): Ditto.
(WebFrameLoaderClient::transitionToCommittedForNewPage): Ditto.
* WebView/WebFrame.mm:
(-[WebFrame _dispatchDidReceiveTitle:]): Use aggregate-style syntax for StringWithDirection.
Not needed now, but useful later if we ever can get rid of the explicit constructors.
(-[WebFrame loadArchive:]): Pass a reference to loadArchive.
* WebView/WebHTMLRepresentation.mm:
(-[WebHTMLRepresentation title]): Updated to use struct.

Source/WebKit/win:

* WebCoreSupport/WebFrameLoaderClient.cpp:
(WebFrameLoaderClient::dispatchDidReceiveTitle): Updated since StringWithDirection::title
is now a data member, not a function member.
(WebFrameLoaderClient::updateGlobalHistory): Ditto.
(WebFrameLoaderClient::setTitle): Ditto.
* WebDataSource.cpp:
(WebDataSource::pageTitle): Ditto.

Source/WebKit2:

* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchDidReceiveTitle): Updated to use struct.
(WebKit::WebFrameLoaderClient::updateGlobalHistory): Ditto.
(WebKit::WebFrameLoaderClient::setTitle): Ditto.

LayoutTests:

* fast/dom/title-text-property-2-expected.txt:
* http/tests/globalhistory/history-delegate-basic-title-expected.txt:
Updated expected results for progression where we no longer send duplicate updates
of the title when setting the title property on a document.

* fast/regions/cssom/webkit-named-flow-collection-expected.txt:
* fast/regions/cssom/webkit-named-flow-collection.html:
Added test cases cover property names in the named flow collection.
Specifically, check both Object.keys for just the indices, and also
Object.getOwnPropertyNames for including the names of the flows.

Canonical link: https://commits.webkit.org/183776@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210216 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
darinadler committed Dec 31, 2016
1 parent 2db8230 commit aa31b6b
Show file tree
Hide file tree
Showing 95 changed files with 1,336 additions and 1,365 deletions.
18 changes: 18 additions & 0 deletions LayoutTests/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
2016-12-31 Darin Adler <darin@apple.com>

Remove PassRefPtr use from the "dom" directory, related cleanup
https://bugs.webkit.org/show_bug.cgi?id=166569

Reviewed by Alex Christensen.

* fast/dom/title-text-property-2-expected.txt:
* http/tests/globalhistory/history-delegate-basic-title-expected.txt:
Updated expected results for progression where we no longer send duplicate updates
of the title when setting the title property on a document.

* fast/regions/cssom/webkit-named-flow-collection-expected.txt:
* fast/regions/cssom/webkit-named-flow-collection.html:
Added test cases cover property names in the named flow collection.
Specifically, check both Object.keys for just the indices, and also
Object.getOwnPropertyNames for including the names of the flows.

2016-12-28 Sergio Villar Senin <svillar@igalia.com>

[css-grid] Isolate instrinsic size computation from layout
Expand Down
1 change: 0 additions & 1 deletion LayoutTests/fast/dom/title-text-property-2-expected.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
TITLE CHANGED: '1. setting document.title'
TITLE CHANGED: ''
TITLE CHANGED: '1. setting document.title'
TITLE CHANGED: ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ PASS region2.style.webkitFlowFrom = 'flow2'; document.webkitGetNamedFlows().leng
PASS region1.style.webkitFlowFrom = ''; document.webkitGetNamedFlows().length is 1
PASS region2.style.webkitFlowFrom = ''; document.webkitGetNamedFlows().length is 0
Test WebKitNamedFlowCollection index getter
PASS (document.webkitGetNamedFlows()[0].name == 'flow1' && document.webkitGetNamedFlows()[1].name == 'flow2') || (document.webkitGetNamedFlows()[0].name == 'flow2' && document.webkitGetNamedFlows()[1].name == 'flow1') is true
PASS document.webkitGetNamedFlows()[0].name is "flow1"
PASS document.webkitGetNamedFlows()[1].name is "flow2"
Test WebKitNamedFlowCollection name getter
PASS document.webkitGetNamedFlows().flow1.name is "flow1"
PASS document.webkitGetNamedFlows().flow2.name is "flow2"
Test WebKitNamedFlowCollection property names
PASS Object.keys(document.webkitGetNamedFlows()) is ['0', '1']
PASS Object.getOwnPropertyNames(document.webkitGetNamedFlows()) is ['0', '1', 'flow1', 'flow2']
PASS successfullyParsed is true

TEST COMPLETE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,17 @@
region2.style.webkitFlowFrom = 'flow2';

debug("Test WebKitNamedFlowCollection index getter");
shouldBeTrue("(document.webkitGetNamedFlows()[0].name == 'flow1' && document.webkitGetNamedFlows()[1].name == 'flow2') \
|| (document.webkitGetNamedFlows()[0].name == 'flow2' && document.webkitGetNamedFlows()[1].name == 'flow1')");
shouldBeEqualToString("document.webkitGetNamedFlows()[0].name", "flow1");
shouldBeEqualToString("document.webkitGetNamedFlows()[1].name", "flow2");

debug("Test WebKitNamedFlowCollection name getter");
shouldBeEqualToString("document.webkitGetNamedFlows().flow1.name", "flow1");
shouldBeEqualToString("document.webkitGetNamedFlows().flow2.name", "flow2");

debug("Test WebKitNamedFlowCollection property names");
shouldBe("Object.keys(document.webkitGetNamedFlows())", "['0', '1']");
shouldBe("Object.getOwnPropertyNames(document.webkitGetNamedFlows())", "['0', '1', 'flow1', 'flow2']");

document.body.removeChild(region1);
document.body.removeChild(region2);
</script>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
WebView navigated to url "http://127.0.0.1:8000/globalhistory/history-delegate-basic-title.html" with title "" with HTTP equivalent method "GET". The navigation was successful and was not a client redirect.
WebView updated the title for history URL "http://127.0.0.1:8000/globalhistory/history-delegate-basic-title.html" to "Test Title 1".
WebView updated the title for history URL "http://127.0.0.1:8000/globalhistory/history-delegate-basic-title.html" to "Test Title 2".
WebView updated the title for history URL "http://127.0.0.1:8000/globalhistory/history-delegate-basic-title.html" to "".
WebView updated the title for history URL "http://127.0.0.1:8000/globalhistory/history-delegate-basic-title.html" to "Test Title 2".
This test sees if the history delegate is notified of title changes.
1 change: 0 additions & 1 deletion Source/WebCore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1425,7 +1425,6 @@ set(WebCore_SOURCES
dom/Document.cpp
dom/DocumentEventQueue.cpp
dom/DocumentFragment.cpp
dom/DocumentMarker.cpp
dom/DocumentMarkerController.cpp
dom/DocumentOrderedMap.cpp
dom/DocumentParser.cpp
Expand Down
324 changes: 324 additions & 0 deletions Source/WebCore/ChangeLog

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions Source/WebCore/WebCore.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -4078,7 +4078,6 @@
A77D0012133B0AEB00D6658C /* TextChecking.h in Headers */ = {isa = PBXBuildFile; fileRef = A77D0011133B0AEB00D6658C /* TextChecking.h */; settings = {ATTRIBUTES = (Private, ); }; };
A77E1FEF14AACB6E005B7CB6 /* TreeScopeAdopter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A77E1FED14AACB6E005B7CB6 /* TreeScopeAdopter.cpp */; };
A77E1FF014AACB6E005B7CB6 /* TreeScopeAdopter.h in Headers */ = {isa = PBXBuildFile; fileRef = A77E1FEE14AACB6E005B7CB6 /* TreeScopeAdopter.h */; };
A781C6A713828B5D0012A62A /* DocumentMarker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A781C6A613828B5D0012A62A /* DocumentMarker.cpp */; };
A784941B0B5FE507001E237A /* DataTransfer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A784941A0B5FE507001E237A /* DataTransfer.cpp */; };
A78FE13B12366B1000ACE8D0 /* SpellChecker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A78FE13912366B1000ACE8D0 /* SpellChecker.cpp */; };
A78FE13C12366B1000ACE8D0 /* SpellChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = A78FE13A12366B1000ACE8D0 /* SpellChecker.h */; settings = {ATTRIBUTES = (Private, ); }; };
Expand Down Expand Up @@ -11760,7 +11759,6 @@
A77D0011133B0AEB00D6658C /* TextChecking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextChecking.h; sourceTree = "<group>"; };
A77E1FED14AACB6E005B7CB6 /* TreeScopeAdopter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TreeScopeAdopter.cpp; sourceTree = "<group>"; };
A77E1FEE14AACB6E005B7CB6 /* TreeScopeAdopter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TreeScopeAdopter.h; sourceTree = "<group>"; };
A781C6A613828B5D0012A62A /* DocumentMarker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentMarker.cpp; sourceTree = "<group>"; };
A784941A0B5FE507001E237A /* DataTransfer.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = DataTransfer.cpp; sourceTree = "<group>"; };
A78FE13912366B1000ACE8D0 /* SpellChecker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpellChecker.cpp; sourceTree = "<group>"; };
A78FE13A12366B1000ACE8D0 /* SpellChecker.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; path = SpellChecker.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -24055,7 +24053,6 @@
A8185F3709765765005826D9 /* DocumentFragment.cpp */,
A8185F3509765765005826D9 /* DocumentFragment.h */,
1A494ED50A123F1A00FDAFC1 /* DocumentFragment.idl */,
A781C6A613828B5D0012A62A /* DocumentMarker.cpp */,
ED2BA83B09A24B91006C0AC4 /* DocumentMarker.h */,
CE057FA31220731100A476D5 /* DocumentMarkerController.cpp */,
CE057FA41220731100A476D5 /* DocumentMarkerController.h */,
Expand Down Expand Up @@ -29246,7 +29243,6 @@
A8185F3F09765766005826D9 /* DocumentFragment.cpp in Sources */,
93E227E00AF589AD00D48324 /* DocumentLoader.cpp in Sources */,
1C26497A0D7E248A00BD10F2 /* DocumentLoaderMac.cpp in Sources */,
A781C6A713828B5D0012A62A /* DocumentMarker.cpp in Sources */,
CE057FA51220731100A476D5 /* DocumentMarkerController.cpp in Sources */,
14947FFD12F80CD200A0F631 /* DocumentOrderedMap.cpp in Sources */,
A8C2280E11D4A59700D5A7D3 /* DocumentParser.cpp in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/bindings/js/JSPopStateEventCustom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ JSValue JSPopStateEvent::state(ExecState& state) const
// We need to make sure a PopStateEvent does not leak objects in its state property across isolated DOM worlds.
// Ideally, we would check that the worlds have different privileges but that's not possible yet.
if (eventState.isObject() && &worldForDOMObject(eventState.getObject()) != &currentWorld(&state)) {
if (auto serializedValue = event.trySerializeState(&state))
if (auto serializedValue = event.trySerializeState(state))
eventState = serializedValue->deserialize(state, globalObject());
else
eventState = jsNull();
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/dom/CharacterData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ void CharacterData::notifyParentAfterChange(ContainerNode::ChildChangeSource sou

void CharacterData::dispatchModifiedEvent(const String& oldData)
{
if (std::unique_ptr<MutationObserverInterestGroup> mutationRecipients = MutationObserverInterestGroup::createForCharacterDataMutation(*this))
if (auto mutationRecipients = MutationObserverInterestGroup::createForCharacterDataMutation(*this))
mutationRecipients->enqueueMutationRecord(MutationRecord::createCharacterData(*this, oldData));

if (!isInShadowTree()) {
Expand Down
1 change: 0 additions & 1 deletion Source/WebCore/dom/DOMAllInOne.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
#include "Document.cpp"
#include "DocumentEventQueue.cpp"
#include "DocumentFragment.cpp"
#include "DocumentMarker.cpp"
#include "DocumentMarkerController.cpp"
#include "DocumentOrderedMap.cpp"
#include "DocumentParser.cpp"
Expand Down
78 changes: 42 additions & 36 deletions Source/WebCore/dom/DOMNamedFlowCollection.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
* Copyright (C) 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
Expand All @@ -26,62 +27,67 @@
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/

#include "config.h"
#include "DOMNamedFlowCollection.h"

#include "EventNames.h"
#include "WebKitNamedFlow.h"
#include <wtf/text/AtomicStringHash.h>

namespace WebCore {

DOMNamedFlowCollection::DOMNamedFlowCollection(const Vector<WebKitNamedFlow*>& namedFlows)
{
for (auto& flow : namedFlows)
m_namedFlows.add(flow);
}

unsigned long DOMNamedFlowCollection::length() const
inline DOMNamedFlowCollection::DOMNamedFlowCollection(Vector<Ref<WebKitNamedFlow>>&& flows)
: m_flows(WTFMove(flows))
{
return m_namedFlows.size();
}

RefPtr<WebKitNamedFlow> DOMNamedFlowCollection::item(unsigned long index) const
Ref<DOMNamedFlowCollection> DOMNamedFlowCollection::create(Vector<Ref<WebKitNamedFlow>>&& flows)
{
if (index >= static_cast<unsigned long>(m_namedFlows.size()))
return nullptr;
auto it = m_namedFlows.begin();
for (unsigned long i = 0; i < index; ++i)
++it;
return *it;
return adoptRef(*new DOMNamedFlowCollection(WTFMove(flows)));
}

RefPtr<WebKitNamedFlow> DOMNamedFlowCollection::namedItem(const AtomicString& name) const
DOMNamedFlowCollection::~DOMNamedFlowCollection()
{
auto it = m_namedFlows.find<String, DOMNamedFlowHashTranslator>(name);
if (it != m_namedFlows.end())
return *it;
return nullptr;
}

Vector<AtomicString> DOMNamedFlowCollection::supportedPropertyNames()
WebKitNamedFlow* DOMNamedFlowCollection::item(unsigned index) const
{
// FIXME: Should be implemented.
return Vector<AtomicString>();
if (index >= m_flows.size())
return nullptr;
return const_cast<WebKitNamedFlow*>(m_flows[index].ptr());
}

// The HashFunctions object used by the HashSet to compare between RefPtr<NamedFlows>.
// It is safe to set safeToCompareToEmptyOrDeleted because the HashSet will never contain null pointers or deleted values.
struct DOMNamedFlowCollection::DOMNamedFlowHashFunctions {
static unsigned hash(PassRefPtr<WebKitNamedFlow> key) { return DefaultHash<String>::Hash::hash(key->name()); }
static bool equal(PassRefPtr<WebKitNamedFlow> a, PassRefPtr<WebKitNamedFlow> b) { return a->name() == b->name(); }
static const bool safeToCompareToEmptyOrDeleted = true;
};
struct DOMNamedFlowCollection::HashFunctions {
static unsigned hash(const WebKitNamedFlow* key) { return AtomicStringHash::hash(key->name()); }
static bool equal(const WebKitNamedFlow* a, const WebKitNamedFlow* b) { return a->name() == b->name(); }
static const bool safeToCompareToEmptyOrDeleted = false;

// The HashTranslator is used to lookup a RefPtr<NamedFlow> in the set using a name.
struct DOMNamedFlowCollection::DOMNamedFlowHashTranslator {
static unsigned hash(const String& key) { return DefaultHash<String>::Hash::hash(key); }
static bool equal(PassRefPtr<WebKitNamedFlow> a, const String& b) { return a->name() == b; }
static unsigned hash(const AtomicString& key) { return AtomicStringHash::hash(key); }
static bool equal(const WebKitNamedFlow* a, const AtomicString& b) { return a->name() == b; }
};
} // namespace WebCore

WebKitNamedFlow* DOMNamedFlowCollection::namedItem(const AtomicString& name) const
{
if (m_flowsByName.isEmpty()) {
// No need to optimize the case where m_flows is empty; will do nothing very quickly.
for (auto& flow : m_flows)
m_flowsByName.add(const_cast<WebKitNamedFlow*>(flow.ptr()));
}
auto it = m_flowsByName.find<HashFunctions>(name);
if (it == m_flowsByName.end())
return nullptr;
return *it;
}

const Vector<AtomicString>& DOMNamedFlowCollection::supportedPropertyNames()
{
if (m_flowNames.isEmpty()) {
// No need to optimize the case where m_flows is empty; will do nothing relatively quickly.
m_flowNames.reserveInitialCapacity(m_flows.size());
for (auto& flow : m_flows)
m_flowNames.uncheckedAppend(flow->name());
}
return m_flowNames;
}

} // namespace WebCore
36 changes: 20 additions & 16 deletions Source/WebCore/dom/DOMNamedFlowCollection.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
* Copyright (C) 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -29,35 +30,38 @@

#pragma once

#include "NamedFlowCollection.h"
#include <wtf/ListHashSet.h>
#include <wtf/Forward.h>
#include <wtf/HashSet.h>
#include <wtf/RefCounted.h>
#include <wtf/Vector.h>

namespace WebCore {

class Document;
class WebKitNamedFlow;

class DOMNamedFlowCollection : public RefCounted<DOMNamedFlowCollection> {
public:
static Ref<DOMNamedFlowCollection> create(const Vector<WebKitNamedFlow*>& namedFlows)
{
return adoptRef(*new DOMNamedFlowCollection(namedFlows));
}
static Ref<DOMNamedFlowCollection> create(Vector<Ref<WebKitNamedFlow>>&&);
~DOMNamedFlowCollection();

unsigned long length() const;
RefPtr<WebKitNamedFlow> item(unsigned long index) const;
RefPtr<WebKitNamedFlow> namedItem(const AtomicString& name) const;
Vector<AtomicString> supportedPropertyNames();
unsigned length() const;
WebKitNamedFlow* item(unsigned index) const;
WebKitNamedFlow* namedItem(const AtomicString& name) const;
const Vector<AtomicString>& supportedPropertyNames();

private:
struct DOMNamedFlowHashFunctions;
struct DOMNamedFlowHashTranslator;
struct HashFunctions;

typedef ListHashSet<RefPtr<WebKitNamedFlow>, DOMNamedFlowHashFunctions> DOMNamedFlowSet;
explicit DOMNamedFlowCollection(const Vector<WebKitNamedFlow*>&);
DOMNamedFlowSet m_namedFlows;
explicit DOMNamedFlowCollection(Vector<Ref<WebKitNamedFlow>>&&);

const Vector<Ref<WebKitNamedFlow>> m_flows;
mutable HashSet<WebKitNamedFlow*, HashFunctions> m_flowsByName;
mutable Vector<AtomicString> m_flowNames;
};

inline unsigned DOMNamedFlowCollection::length() const
{
return m_flows.size();
}

} // namespace WebCore
4 changes: 2 additions & 2 deletions Source/WebCore/dom/DOMNamedFlowCollection.idl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@
ImplementationLacksVTable,
] interface DOMNamedFlowCollection {
readonly attribute unsigned long length;
getter WebKitNamedFlow item(unsigned long index);
getter WebKitNamedFlow namedItem(DOMString name);
getter WebKitNamedFlow? item(unsigned long index);
getter WebKitNamedFlow? namedItem(DOMString name);
};
Loading

0 comments on commit aa31b6b

Please sign in to comment.