Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split DOM into two classes: Document and DOM #237

Merged
merged 1 commit into from
Aug 17, 2015

Conversation

ichub
Copy link
Contributor

@ichub ichub commented Jul 28, 2015

DOM now handles only the communication between Chrome and Stetho, whereas Document is responsible for accessing, modifying, and maintaining information about elements on the Android side. The motivation for this change is that DOM is not the only class that needs access to information about elements - CSS also needs this information. By splitting these classes up it is possible for both DOM and CSS to be able to get and set element data.

@ichub ichub changed the title Split DOMinto two classes: Document and DOM Split DOM into two classes: Document and DOM Jul 28, 2015
private ArrayListAccumulator<Object> mCachedChildrenAccumulator;

public Document(DOMProvider.Factory factory) {
this.mFactory = factory;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: drop this.

Document doc = new Document(new AndroidDOMProviderFactory((Application)context.getApplicationContext()));

modules.add(new DOM(doc));
modules.add(new CSS(doc));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes it so that the CSS module also requires the same minimum API level as DOM. @jasta should comment on this too.

@@ -226,18 +190,12 @@ public PerformSearchResponse performSearch(JsonRpcPeer peer, final JSONObject pa
params,
PerformSearchRequest.class);

final Pattern queryPattern = Pattern.compile(Pattern.quote(request.query), Pattern.CASE_INSENSITIVE);
final ArrayListAccumulator<Integer> results = new ArrayListAccumulator<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's an opportunity to increase clarity here ... what do the integers inside of results represent? Are they node IDs? If so, calling this nodeIdResults might help to illuminate this fact.

@rickbrew
Copy link
Contributor

Okay there's another round of feedback. This is shaping up well, despite how confusing it all is :)


public class AndroidDOMProviderFactory implements DOMProvider.Factory {
public final class AndroidDOMProviderFactory
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename class to AndroidDocumentProviderFactory

@rickbrew
Copy link
Contributor

Looks like we're almost done here. You have some conflicts to resolve, then need to squash, and then I think we can merge!

DOM now handles only the communication between Chrome and Stetho, whereas Document is responsible for accessing, modifying, and maintaining information about elements on the Android side. The motivation for this change is that DOM is not the only class that needs access to information about elements - CSS also needs this information. By splitting these classes up it is possible for both DOM and CSS to be able to get and set element data.
rickbrew added a commit that referenced this pull request Aug 17, 2015
Split DOM into two classes: Document and DOM
@rickbrew rickbrew merged commit 53e1e75 into facebook:master Aug 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants