Bug 153270 - Reduce PassRefPtr uses in dom - 4
Summary: Reduce PassRefPtr uses in dom - 4
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Gyuyoung Kim
URL:
Keywords:
Depends on:
Blocks: 144092
  Show dependency treegraph
 
Reported: 2016-01-19 22:23 PST by Gyuyoung Kim
Modified: 2016-01-24 22:13 PST (History)
6 users (show)

See Also:


Attachments
Patch (14.78 KB, patch)
2016-01-19 22:56 PST, Gyuyoung Kim
no flags Details | Formatted Diff | Diff
Patch (14.78 KB, patch)
2016-01-20 21:57 PST, Gyuyoung Kim
no flags Details | Formatted Diff | Diff
Patch (14.69 KB, patch)
2016-01-21 03:17 PST, Gyuyoung Kim
no flags Details | Formatted Diff | Diff
Patch (16.33 KB, patch)
2016-01-21 05:05 PST, Gyuyoung Kim
no flags Details | Formatted Diff | Diff
Patch (15.54 KB, patch)
2016-01-21 05:38 PST, Gyuyoung Kim
no flags Details | Formatted Diff | Diff
Patch (16.77 KB, patch)
2016-01-21 05:58 PST, Gyuyoung Kim
no flags Details | Formatted Diff | Diff
Patch (17.13 KB, patch)
2016-01-21 23:26 PST, Gyuyoung Kim
no flags Details | Formatted Diff | Diff
Patch (16.91 KB, patch)
2016-01-21 23:42 PST, Gyuyoung Kim
no flags Details | Formatted Diff | Diff
Patch (21.10 KB, patch)
2016-01-22 21:23 PST, Gyuyoung Kim
no flags Details | Formatted Diff | Diff
Patch (20.35 KB, patch)
2016-01-23 03:45 PST, Gyuyoung Kim
no flags Details | Formatted Diff | Diff
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 Details
Patch (20.35 KB, patch)
2016-01-23 07:38 PST, Gyuyoung Kim
no flags Details | Formatted Diff | Diff
Patch for landing (20.35 KB, patch)
2016-01-24 19:14 PST, Gyuyoung Kim
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gyuyoung Kim 2016-01-19 22:23:47 PST
SSIA
Comment 1 Gyuyoung Kim 2016-01-19 22:56:01 PST
Created attachment 269344 [details]
Patch
Comment 2 WebKit Commit Bot 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.
Comment 3 Gyuyoung Kim 2016-01-20 21:57:48 PST
Created attachment 269431 [details]
Patch
Comment 4 Gyuyoung Kim 2016-01-21 03:17:49 PST
Created attachment 269442 [details]
Patch
Comment 5 WebKit Commit Bot 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.
Comment 6 Gyuyoung Kim 2016-01-21 05:05:14 PST
Created attachment 269448 [details]
Patch
Comment 7 WebKit Commit Bot 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.
Comment 8 Gyuyoung Kim 2016-01-21 05:38:44 PST
Created attachment 269450 [details]
Patch
Comment 9 WebKit Commit Bot 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.
Comment 10 Gyuyoung Kim 2016-01-21 05:58:52 PST
Created attachment 269451 [details]
Patch
Comment 11 WebKit Commit Bot 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.
Comment 12 Alex Christensen 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.
Comment 13 Gyuyoung Kim 2016-01-21 23:26:31 PST
Created attachment 269553 [details]
Patch
Comment 14 Gyuyoung Kim 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.
Comment 15 Gyuyoung Kim 2016-01-21 23:42:09 PST
Created attachment 269554 [details]
Patch
Comment 16 Alex Christensen 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.
Comment 17 Alex Christensen 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.
Comment 18 Darin Adler 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.
Comment 19 Gyuyoung Kim 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
Comment 20 Gyuyoung Kim 2016-01-22 21:23:48 PST
Created attachment 269640 [details]
Patch
Comment 21 Gyuyoung Kim 2016-01-23 03:45:34 PST
Created attachment 269666 [details]
Patch
Comment 22 Build Bot 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
Comment 23 Build Bot 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
Comment 24 Gyuyoung Kim 2016-01-23 07:38:12 PST
Created attachment 269670 [details]
Patch
Comment 25 Darin Adler 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()
Comment 26 Gyuyoung Kim 2016-01-24 19:14:15 PST
Created attachment 269716 [details]
Patch for landing
Comment 27 WebKit Commit Bot 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>
Comment 28 WebKit Commit Bot 2016-01-24 22:13:24 PST
All reviewed patches have been landed.  Closing bug.