RESOLVED FIXED 153270
Reduce PassRefPtr uses in dom - 4
https://bugs.webkit.org/show_bug.cgi?id=153270
Summary Reduce PassRefPtr uses in dom - 4
Gyuyoung Kim
Reported 2016-01-19 22:23:47 PST
SSIA
Attachments
Patch (14.78 KB, patch)
2016-01-19 22:56 PST, Gyuyoung Kim
no flags
Patch (14.78 KB, patch)
2016-01-20 21:57 PST, Gyuyoung Kim
no flags
Patch (14.69 KB, patch)
2016-01-21 03:17 PST, Gyuyoung Kim
no flags
Patch (16.33 KB, patch)
2016-01-21 05:05 PST, Gyuyoung Kim
no flags
Patch (15.54 KB, patch)
2016-01-21 05:38 PST, Gyuyoung Kim
no flags
Patch (16.77 KB, patch)
2016-01-21 05:58 PST, Gyuyoung Kim
no flags
Patch (17.13 KB, patch)
2016-01-21 23:26 PST, Gyuyoung Kim
no flags
Patch (16.91 KB, patch)
2016-01-21 23:42 PST, Gyuyoung Kim
no flags
Patch (21.10 KB, patch)
2016-01-22 21:23 PST, Gyuyoung Kim
no flags
Patch (20.35 KB, patch)
2016-01-23 03:45 PST, Gyuyoung Kim
no flags
Archive of layout-test-results from ews117 for mac-yosemite (772.06 KB, application/zip)
2016-01-23 04:48 PST, Build Bot
no flags
Patch (20.35 KB, patch)
2016-01-23 07:38 PST, Gyuyoung Kim
no flags
Patch for landing (20.35 KB, patch)
2016-01-24 19:14 PST, Gyuyoung Kim
no flags
Gyuyoung Kim
Comment 1 2016-01-19 22:56:01 PST
WebKit Commit Bot
Comment 2 2016-01-19 22:59:06 PST
Attachment 269344 [details] did not pass style-queue: ERROR: Source/WebCore/dom/DeviceMotionData.cpp:72: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] ERROR: Source/WebCore/dom/DeviceMotionData.cpp:84: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] ERROR: Source/WebCore/dom/DeviceMotionData.h:86: The parameter name "rotationRate" adds no information, so it should be removed. [readability/parameter_name] [5] ERROR: Source/WebCore/dom/DeviceMotionData.h:86: When wrapping a line, only indent 4 spaces. [whitespace/indent] [3] ERROR: Source/WebCore/dom/DeviceMotionData.h:96: The parameter name "acceleration" adds no information, so it should be removed. [readability/parameter_name] [5] ERROR: Source/WebCore/dom/DeviceMotionData.h:97: The parameter name "rotationRate" adds no information, so it should be removed. [readability/parameter_name] [5] ERROR: Source/WebCore/dom/DeviceMotionData.h:97: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] Total errors found: 7 in 12 files If any of these errors are false positives, please file a bug against check-webkit-style.
Gyuyoung Kim
Comment 3 2016-01-20 21:57:48 PST
Gyuyoung Kim
Comment 4 2016-01-21 03:17:49 PST
WebKit Commit Bot
Comment 5 2016-01-21 03:20:25 PST
Attachment 269442 [details] did not pass style-queue: ERROR: Source/WebCore/dom/DeviceMotionData.cpp:72: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] ERROR: Source/WebCore/dom/DeviceMotionData.cpp:84: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] ERROR: Source/WebCore/dom/DeviceMotionData.h:86: The parameter name "rotationRate" adds no information, so it should be removed. [readability/parameter_name] [5] ERROR: Source/WebCore/dom/DeviceMotionData.h:86: When wrapping a line, only indent 4 spaces. [whitespace/indent] [3] ERROR: Source/WebCore/dom/DeviceMotionData.h:96: The parameter name "acceleration" adds no information, so it should be removed. [readability/parameter_name] [5] ERROR: Source/WebCore/dom/DeviceMotionData.h:97: The parameter name "rotationRate" adds no information, so it should be removed. [readability/parameter_name] [5] ERROR: Source/WebCore/dom/DeviceMotionData.h:97: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] Total errors found: 7 in 12 files If any of these errors are false positives, please file a bug against check-webkit-style.
Gyuyoung Kim
Comment 6 2016-01-21 05:05:14 PST
WebKit Commit Bot
Comment 7 2016-01-21 05:06:20 PST
Attachment 269448 [details] did not pass style-queue: ERROR: Source/WebCore/dom/DeviceMotionData.cpp:72: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] ERROR: Source/WebCore/dom/DeviceMotionData.cpp:84: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] ERROR: Source/WebCore/dom/DeviceMotionData.h:86: The parameter name "rotationRate" adds no information, so it should be removed. [readability/parameter_name] [5] ERROR: Source/WebCore/dom/DeviceMotionData.h:86: When wrapping a line, only indent 4 spaces. [whitespace/indent] [3] ERROR: Source/WebCore/dom/DeviceMotionData.h:96: The parameter name "acceleration" adds no information, so it should be removed. [readability/parameter_name] [5] ERROR: Source/WebCore/dom/DeviceMotionData.h:97: The parameter name "rotationRate" adds no information, so it should be removed. [readability/parameter_name] [5] ERROR: Source/WebCore/dom/DeviceMotionData.h:97: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] Total errors found: 7 in 14 files If any of these errors are false positives, please file a bug against check-webkit-style.
Gyuyoung Kim
Comment 8 2016-01-21 05:38:44 PST
WebKit Commit Bot
Comment 9 2016-01-21 05:39:44 PST
Attachment 269450 [details] did not pass style-queue: ERROR: Source/WebCore/dom/DeviceMotionData.cpp:72: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] ERROR: Source/WebCore/dom/DeviceMotionData.cpp:84: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] ERROR: Source/WebCore/dom/DeviceMotionData.h:86: The parameter name "rotationRate" adds no information, so it should be removed. [readability/parameter_name] [5] ERROR: Source/WebCore/dom/DeviceMotionData.h:86: When wrapping a line, only indent 4 spaces. [whitespace/indent] [3] ERROR: Source/WebCore/dom/DeviceMotionData.h:96: The parameter name "acceleration" adds no information, so it should be removed. [readability/parameter_name] [5] ERROR: Source/WebCore/dom/DeviceMotionData.h:97: The parameter name "rotationRate" adds no information, so it should be removed. [readability/parameter_name] [5] ERROR: Source/WebCore/dom/DeviceMotionData.h:97: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] Total errors found: 7 in 13 files If any of these errors are false positives, please file a bug against check-webkit-style.
Gyuyoung Kim
Comment 10 2016-01-21 05:58:52 PST
WebKit Commit Bot
Comment 11 2016-01-21 06:00:33 PST
Attachment 269451 [details] did not pass style-queue: ERROR: Source/WebCore/dom/DeviceMotionData.cpp:72: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] ERROR: Source/WebCore/dom/DeviceMotionData.cpp:84: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] ERROR: Source/WebCore/dom/DeviceMotionData.h:86: The parameter name "rotationRate" adds no information, so it should be removed. [readability/parameter_name] [5] ERROR: Source/WebCore/dom/DeviceMotionData.h:86: When wrapping a line, only indent 4 spaces. [whitespace/indent] [3] ERROR: Source/WebCore/dom/DeviceMotionData.h:96: The parameter name "acceleration" adds no information, so it should be removed. [readability/parameter_name] [5] ERROR: Source/WebCore/dom/DeviceMotionData.h:97: The parameter name "rotationRate" adds no information, so it should be removed. [readability/parameter_name] [5] ERROR: Source/WebCore/dom/DeviceMotionData.h:97: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] Total errors found: 7 in 14 files If any of these errors are false positives, please file a bug against check-webkit-style.
Alex Christensen
Comment 12 2016-01-21 21:39:03 PST
Comment on attachment 269451 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=269451&action=review > Source/WebCore/bindings/js/JSDeviceMotionEventCustom.cpp:192 > wrapped().initDeviceMotionEvent(type, bubbles, cancelable, deviceMotionData.get()); I think all these parameters should be RefPtr&& instead of a pointers, and all parameters could be WTFMoved into this call. > Source/WebCore/dom/DeviceMotionData.cpp:72 > +Ref<DeviceMotionData> DeviceMotionData::create(Acceleration* acceleration, Acceleration* accelerationIncludingGravity, > + RotationRate* rotationRate, bool canProvideInterval, double interval) Ditto. And these should be on the same line to make the style bot happy. > Source/WebCore/dom/DeviceMotionData.cpp:84 > +DeviceMotionData::DeviceMotionData(Acceleration* acceleration, Acceleration* accelerationIncludingGravity, > + RotationRate* rotationRate, bool canProvideInterval, double interval) ditto. And in the header > Source/WebCore/dom/Document.cpp:4832 > +void Document::pushCurrentScript(HTMLScriptElement* newCurrentScript) I don't think this is called anywhere. Could it be removed? Same with popCurrentScript and m_currentScriptStack. > Source/WebCore/dom/Document.h:927 > + void setBodyOrFrameset(RefPtr<HTMLElement>&&, ExceptionCode&); I don't think this is called. Remove if not. Also in header. > Source/WebCore/dom/MouseEvent.cpp:256 > + return WTFMove(clonedMouseEvent); I don't think you need WTFMove with return.
Gyuyoung Kim
Comment 13 2016-01-21 23:26:31 PST
Gyuyoung Kim
Comment 14 2016-01-21 23:32:29 PST
Comment on attachment 269451 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=269451&action=review >> Source/WebCore/bindings/js/JSDeviceMotionEventCustom.cpp:192 >> wrapped().initDeviceMotionEvent(type, bubbles, cancelable, deviceMotionData.get()); > > I think all these parameters should be RefPtr&& instead of a pointers, and all parameters could be WTFMoved into this call. I thought that nobody hands DeviceMotionData ownership. But in this case it might be good to hand ownership to DeviceMotionData. Fixed. >> Source/WebCore/dom/DeviceMotionData.cpp:72 >> + RotationRate* rotationRate, bool canProvideInterval, double interval) > > Ditto. And these should be on the same line to make the style bot happy. Done. >> Source/WebCore/dom/Document.cpp:4832 >> +void Document::pushCurrentScript(HTMLScriptElement* newCurrentScript) > > I don't think this is called anywhere. Could it be removed? Same with popCurrentScript and m_currentScriptStack. No, pushCurrentScript() is being used by CurrentScriptIncrementer class. class CurrentScriptIncrementer { WTF_MAKE_NONCOPYABLE(CurrentScriptIncrementer); public: CurrentScriptIncrementer(Document& document, Element* element) : m_document(document) , m_isHTMLScriptElement(is<HTMLScriptElement>(*element)) { if (m_isHTMLScriptElement) m_document.pushCurrentScript(downcast<HTMLScriptElement>(element)); } >> Source/WebCore/dom/Document.h:927 >> + void setBodyOrFrameset(RefPtr<HTMLElement>&&, ExceptionCode&); > > I don't think this is called. Remove if not. Also in header. I find where it is used. It is used by DerivedSources/WebCore/JSDocument.cpp. DerivedSources/WebCore/JSDocument.cpp:3178:10: error: ‘class WebCore::Document’ has no member named ‘setBodyOrFrameset’ impl.setBodyOrFrameset(nativeValue, ec); >> Source/WebCore/dom/MouseEvent.cpp:256 >> + return WTFMove(clonedMouseEvent); > > I don't think you need WTFMove with return. done.
Gyuyoung Kim
Comment 15 2016-01-21 23:42:09 PST
Alex Christensen
Comment 16 2016-01-22 10:00:16 PST
Comment on attachment 269554 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=269554&action=review > Source/WebCore/dom/MouseEvent.cpp:256 > + return clonedMouseEvent.releaseNonNull(); clonedMouseEvent should be a Ref, not a RefPtr, then you don't need NonNull. Just return the ref.
Alex Christensen
Comment 17 2016-01-22 10:02:19 PST
(In reply to comment #14) > No, pushCurrentScript() is being used by CurrentScriptIncrementer class. CurrentScriptIncrementer.h is not in the Xcode project, so searching for it yielded no results :( It should be added. > I find where it is used. It is used by DerivedSources/WebCore/JSDocument.cpp. Ok, also not searchable, but for a good reason.
Darin Adler
Comment 18 2016-01-22 17:42:52 PST
Comment on attachment 269554 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=269554&action=review > Source/WebCore/bindings/js/JSDeviceMotionEventCustom.cpp:191 > + RefPtr<DeviceMotionData> deviceMotionData = DeviceMotionData::create(WTFMove(acceleration), WTFMove(accelerationIncludingGravity), WTFMove(rotationRate), intervalProvided, interval); This should be going into a Ref, not a RefPtr. I suggest using auto. > Source/WebCore/dom/Document.cpp:2586 > +void Document::setBodyOrFrameset(RefPtr<HTMLElement>&& newBody, ExceptionCode& ec) I don’t think this is quite right. The code below assigns a new value to newBody, which could modify the argument passed in. We don’t want that to happen. > Source/WebCore/dom/Document.cpp:3757 > +bool Document::setFocusedElement(RefPtr<Element>&& newFocusedElement, FocusDirection direction) This function takes no advantage of being passed a RefPtr&& and doesn’t take ownership of the argument; I suggest we consider changing the argument type to a raw pointer. I worry about object lifetime problems, though, if we remove the protection of being in a RefPtr from the argument. The code calls a lot of arbitrary JavaScript that could delete the last reference to the object. So probably want to use a raw pointer but have a local variable of type RefPtr (or Ref) inside the function.
Gyuyoung Kim
Comment 19 2016-01-22 19:50:26 PST
(In reply to comment #16) > Comment on attachment 269554 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=269554&action=review > > > Source/WebCore/dom/MouseEvent.cpp:256 > > + return clonedMouseEvent.releaseNonNull(); > > clonedMouseEvent should be a Ref, not a RefPtr, then you don't need NonNull. > Just return the ref. (In reply to comment #16) > Comment on attachment 269554 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=269554&action=review > > > Source/WebCore/dom/MouseEvent.cpp:256 > > + return clonedMouseEvent.releaseNonNull(); > > clonedMouseEvent should be a Ref, not a RefPtr, then you don't need NonNull. > Just return the ref. When *clonedMouseEvent* is a Ref, there was a build break on GTK port. It seems we need to use WTFMove() explicitly in this case. Failed to run "['Tools/Scripts/build-webkit', '--release', '--gtk', '--update-gtk', '--makeargs="-j16"']" exit_code: 1 -Wundef -Wwrite-strings -fPIC -MMD -MT Source/WebCore/CMakeFiles/WebCore.dir/dom/MouseEvent.cpp.o -MF Source/WebCore/CMakeFiles/WebCore.dir/dom/MouseEvent.cpp.o.d -o Source/WebCore/CMakeFiles/WebCore.dir/dom/MouseEvent.cpp.o -c ../../Source/WebCore/dom/MouseEvent.cpp ../../Source/WebCore/dom/MouseEvent.cpp: In member function 'virtual WTF::Ref<WebCore::Event> WebCore::MouseEvent::cloneFor(WebCore::HTMLIFrameElement*) const': ../../Source/WebCore/dom/MouseEvent.cpp:256:12: error: use of deleted function 'WTF::Ref<T>::Ref(const WTF::Ref<U>&) [with U = WebCore::MouseEvent; T = WebCore::Event]' In file included from ../../Source/WTF/wtf/PassRefPtr.h:25:0, from ../../Source/WTF/wtf/RefPtr.h:30, from ../../Source/WebCore/dom/RegisteredEventListener.h:28, from ../../Source/WebCore/dom/EventListenerMap.h:36, from ../../Source/WebCore/dom/EventTarget.h:34, from ../../Source/WebCore/page/DOMWindow.h:31, from ../../Source/WebCore/dom/UIEvent.h:27, from ../../Source/WebCore/dom/UIEventWithKeyState.h:27, from ../../Source/WebCore/dom/MouseRelatedEvent.h:28, from ../../Source/WebCore/dom/MouseEvent.h:27, from ../../Source/WebCore/dom/MouseEvent.cpp:24: ../../Source/WTF/wtf/Ref.h:67:26: note: declared here
Gyuyoung Kim
Comment 20 2016-01-22 21:23:48 PST
Gyuyoung Kim
Comment 21 2016-01-23 03:45:34 PST
Build Bot
Comment 22 2016-01-23 04:48:10 PST
Comment on attachment 269666 [details] Patch Attachment 269666 [details] did not pass mac-debug-ews (mac): Output: http://webkit-queues.webkit.org/results/729048 New failing tests: imported/w3c/web-platform-tests/streams-api/readable-streams/garbage-collection.html
Build Bot
Comment 23 2016-01-23 04:48:14 PST
Created attachment 269668 [details] Archive of layout-test-results from ews117 for mac-yosemite The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews117 Port: mac-yosemite Platform: Mac OS X 10.10.5
Gyuyoung Kim
Comment 24 2016-01-23 07:38:12 PST
Darin Adler
Comment 25 2016-01-24 12:12:32 PST
Comment on attachment 269670 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=269670&action=review > Source/WebCore/bindings/js/JSDeviceMotionEventCustom.cpp:192 > + wrapped().initDeviceMotionEvent(type, bubbles, cancelable, &deviceMotionData.get()); deviceMotionData.ptr() is the better idiom here instead of &deviceMotionData.get()
Gyuyoung Kim
Comment 26 2016-01-24 19:14:15 PST
Created attachment 269716 [details] Patch for landing
WebKit Commit Bot
Comment 27 2016-01-24 22:13:19 PST
Comment on attachment 269716 [details] Patch for landing Clearing flags on attachment: 269716 Committed r195524: <http://trac.webkit.org/changeset/195524>
WebKit Commit Bot
Comment 28 2016-01-24 22:13:24 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.