Skip to content

Commit

Permalink
Auto merge of #23999 - paulrouget:missingCMethods, r=jdm
Browse files Browse the repository at this point in the history
Missing C methods

Depends on #23983

Fix #23969

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23999)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Aug 23, 2019
2 parents cacd4ed + b642ff2 commit 8672ab5
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ports/libsimpleservo/api/src/lib.rs
Expand Up @@ -559,6 +559,12 @@ impl ServoGlue {
EmbedderMsg::Shutdown => {
self.callbacks.host_callbacks.on_shutdown_complete();
},
EmbedderMsg::ShowIME(..) => {
self.callbacks.host_callbacks.on_ime_state_changed(true);
},
EmbedderMsg::HideIME => {
self.callbacks.host_callbacks.on_ime_state_changed(false);
},
EmbedderMsg::Status(..) |
EmbedderMsg::SelectFiles(..) |
EmbedderMsg::MoveTo(..) |
Expand All @@ -568,8 +574,6 @@ impl ServoGlue {
EmbedderMsg::NewFavicon(..) |
EmbedderMsg::HeadParsed |
EmbedderMsg::SetFullscreenState(..) |
EmbedderMsg::ShowIME(..) |
EmbedderMsg::HideIME |
EmbedderMsg::Panic(..) |
EmbedderMsg::ReportProfile(..) => {},
}
Expand Down
27 changes: 27 additions & 0 deletions support/hololens/ServoApp/ServoControl/Servo.cpp
Expand Up @@ -4,26 +4,37 @@
namespace winrt::servo {

void on_load_started() { sServo->Delegate().OnServoLoadStarted(); }

void on_load_ended() { sServo->Delegate().OnServoLoadEnded(); }

void on_history_changed(bool back, bool forward) {
sServo->Delegate().OnServoHistoryChanged(back, forward);
}

void on_shutdown_complete() { sServo->Delegate().OnServoShutdownComplete(); }

void on_alert(const char *message) {
sServo->Delegate().OnServoAlert(char2hstring(message));
}

void on_title_changed(const char *title) {
sServo->Delegate().OnServoTitleChanged(char2hstring(title));
}

void on_url_changed(const char *url) {
sServo->Delegate().OnServoURLChanged(char2hstring(url));
}

void flush() { sServo->Delegate().Flush(); }

void make_current() { sServo->Delegate().MakeCurrent(); }

void wakeup() { sServo->Delegate().WakeUp(); }

bool on_allow_navigation(const char *url) {
return sServo->Delegate().OnServoAllowNavigation(char2hstring(url));
};

void on_animating_changed(bool aAnimating) {
sServo->Delegate().OnServoAnimatingChanged(aAnimating);
}
Expand All @@ -32,6 +43,19 @@ void on_panic(const char *backtrace) {
throw hresult_error(E_FAIL, char2hstring(backtrace));
}

void on_ime_state_changed(bool aShow) {
sServo->Delegate().OnServoIMEStateChanged(aShow);
}

void set_clipboard_contents(const char* content) {
// FIXME
}

const char* get_clipboard_contents() {
// FIXME
return nullptr;
}

Servo::Servo(hstring url, GLsizei width, GLsizei height,
ServoDelegate &aDelegate)
: mWindowHeight(height), mWindowWidth(width), mDelegate(aDelegate) {
Expand Down Expand Up @@ -59,6 +83,9 @@ Servo::Servo(hstring url, GLsizei width, GLsizei height,
c.on_animating_changed = &on_animating_changed;
c.on_shutdown_complete = &on_shutdown_complete;
c.on_allow_navigation = &on_allow_navigation;
c.on_ime_state_changed = &on_ime_state_changed;
c.get_clipboard_contents = &get_clipboard_contents;
c.set_clipboard_contents = &set_clipboard_contents;

capi::register_panic_handler(&on_panic);

Expand Down
1 change: 1 addition & 0 deletions support/hololens/ServoApp/ServoControl/Servo.h
Expand Up @@ -33,6 +33,7 @@ class ServoDelegate {
virtual void OnServoURLChanged(hstring) = 0;
virtual bool OnServoAllowNavigation(hstring) = 0;
virtual void OnServoAnimatingChanged(bool) = 0;
virtual void OnServoIMEStateChanged(bool) = 0;
virtual void Flush() = 0;
virtual void MakeCurrent() = 0;

Expand Down
4 changes: 4 additions & 0 deletions support/hololens/ServoApp/ServoControl/ServoControl.cpp
Expand Up @@ -254,6 +254,10 @@ void ServoControl::OnServoAnimatingChanged(bool animating) {
WakeConditionVariable(&mGLCondVar);
}

void ServoControl::OnServoIMEStateChanged(bool aShow) {
// FIXME: https://docs.microsoft.com/en-us/windows/win32/winauto/uiauto-implementingtextandtextrange
}

template <typename Callable> void ServoControl::RunOnUIThread(Callable cb) {
Dispatcher().RunAsync(CoreDispatcherPriority::High, cb);
}
Expand Down
1 change: 1 addition & 0 deletions support/hololens/ServoApp/ServoControl/ServoControl.h
Expand Up @@ -56,6 +56,7 @@ struct ServoControl : ServoControlT<ServoControl>, public servo::ServoDelegate {
virtual void MakeCurrent();
virtual bool OnServoAllowNavigation(winrt::hstring);
virtual void OnServoAnimatingChanged(bool);
virtual void OnServoIMEStateChanged(bool);

private:
winrt::event<Windows::Foundation::EventHandler<hstring>> mOnURLChangedEvent;
Expand Down

0 comments on commit 8672ab5

Please sign in to comment.